From: Brendan Hansen Date: Mon, 5 Feb 2024 22:57:37 +0000 (-0600) Subject: standard library changes for optional semicolons X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=a2eba8eac927a6c2ea999a1353621d3f41722169;p=onyx.git standard library changes for optional semicolons --- diff --git a/core/container/array.onyx b/core/container/array.onyx index 421345c0..5b9abc7b 100644 --- a/core/container/array.onyx +++ b/core/container/array.onyx @@ -152,7 +152,9 @@ push :: (arr: &[..] $T, x: T) -> bool { } // Semi-useful shortcut for adding something to an array. -#operator << macro (arr: [..] $T, v: T) do #this_package.push(&arr, v); +#operator << macro (arr: [..] $T, v: T) { + #this_package.push(&arr, v) +} #doc """ diff --git a/core/container/bucket_array.onyx b/core/container/bucket_array.onyx index 5c5750df..47ef1cd3 100644 --- a/core/container/bucket_array.onyx +++ b/core/container/bucket_array.onyx @@ -86,7 +86,9 @@ push :: (use b: &Bucket_Array($T), elem: T) -> bool { } } -#operator << macro (b: Bucket_Array($T), elem: T) do #this_package.push(&b, elem); +#operator << macro (b: Bucket_Array($T), elem: T) { + #this_package.push(&b, elem) +} pop :: (use b: &Bucket_Array($T)) { last_bucket := &buckets[buckets.count - 1]; diff --git a/core/container/heap.onyx b/core/container/heap.onyx index 3ff0837d..5db9bbcd 100644 --- a/core/container/heap.onyx +++ b/core/container/heap.onyx @@ -23,7 +23,9 @@ insert :: (use heap: &Heap, v: heap.T) { shift_up(heap, data.count - 1); } -#operator << macro (heap: Heap($T), v: T) do #this_package.insert(&heap, v); +#operator << macro (heap: Heap($T), v: T) { + #this_package.insert(&heap, v) +} remove_top :: (use heap: &Heap) -> heap.T { x := data[0]; diff --git a/core/container/set.onyx b/core/container/set.onyx index 9a28755f..c7cda96c 100644 --- a/core/container/set.onyx +++ b/core/container/set.onyx @@ -84,7 +84,9 @@ insert :: (use set: &Set, value: set.Elem_Type) { if full(set) do grow(set); } -#operator << macro (set: Set($T), value: T) do #this_package.insert(&set, value); +#operator << macro (set: Set($T), value: T) { + #this_package.insert(&set, value) +} has :: (use set: &Set, value: set.Elem_Type) -> bool { lr := lookup(set, value); diff --git a/core/hash/sha256.onyx b/core/hash/sha256.onyx index 1492f52e..9ff449f7 100644 --- a/core/hash/sha256.onyx +++ b/core/hash/sha256.onyx @@ -106,10 +106,10 @@ do_cycle :: (self: &Hasher, data: [] u8) { for i in 0 .. 16 { j := 4 * i; - m[i] = (cast(u32, data[j]) << 24) - | (cast(u32, data[j + 1]) << 16) - | (cast(u32, data[j + 2]) << 8) - | (cast(u32, data[j + 3])); + m[i] = (cast(u32, data[j]) << 24) | + (cast(u32, data[j + 1]) << 16) | + (cast(u32, data[j + 2]) << 8) | + (cast(u32, data[j + 3])); } for i in 16 .. 64 { diff --git a/core/io/reader.onyx b/core/io/reader.onyx index 4d25f063..e5f0c3a7 100644 --- a/core/io/reader.onyx +++ b/core/io/reader.onyx @@ -393,9 +393,9 @@ read_word :: (use reader: &Reader, numeric_allowed := false, allocator := contex while count < end { curr := buffer[count]; - if (curr >= #char "a" && curr <= #char "z") - || (curr >= #char "A" && curr <= #char "Z") - || curr == #char "_" { + if (curr >= #char "a" && curr <= #char "z") || + (curr >= #char "A" && curr <= #char "Z") || + curr == #char "_" { count += 1; } elseif numeric_allowed && (curr >= #char "0" && curr <= #char "9") { count += 1; @@ -413,9 +413,9 @@ read_word :: (use reader: &Reader, numeric_allowed := false, allocator := contex count := start; while count < end { curr := buffer[count]; - if (curr >= #char "a" && curr <= #char "z") - || (curr >= #char "A" && curr <= #char "Z") - || curr == #char "_" { + if (curr >= #char "a" && curr <= #char "z") || + (curr >= #char "A" && curr <= #char "Z") || + curr == #char "_" { count += 1; } elseif numeric_allowed && (curr >= #char "0" && curr <= #char "9") { count += 1; diff --git a/core/math/math.onyx b/core/math/math.onyx index e313ad05..76b5b37c 100644 --- a/core/math/math.onyx +++ b/core/math/math.onyx @@ -370,16 +370,16 @@ is_nan :: #match #local {} is_nan :: (x: f32) -> bool { v := x; i := *cast(&u32) &v; - return (i & 0x7f800000) == 0x7f800000 - && (i & 0x007fffff) != 0; + return (i & 0x7f800000) == 0x7f800000 && + (i & 0x007fffff) != 0; } #overload is_nan :: (x: f64) -> bool { v := x; i := *cast(&u64) &v; - return (i & 0x7ff0000000000000) == 0x7ff0000000000000 - && (i & 0x000fffffffffffff) != 0; + return (i & 0x7ff0000000000000) == 0x7ff0000000000000 && + (i & 0x000fffffffffffff) != 0; } @@ -389,16 +389,16 @@ is_inf :: #match #local {} is_inf :: (x: f32) -> bool { v := x; i := *cast(&u32) &v; - return (i & 0x7f800000) == 0x7f800000 - && (i & 0x007fffff) == 0; + return (i & 0x7f800000) == 0x7f800000 && + (i & 0x007fffff) == 0; } #overload is_inf :: (x: f64) -> bool { v := x; i := *cast(&u64) &v; - return (i & 0x7ff0000000000000) == 0x7ff0000000000000 - && (i & 0x000fffffffffffff) == 0; + return (i & 0x7ff0000000000000) == 0x7ff0000000000000 && + (i & 0x000fffffffffffff) == 0; } diff --git a/core/misc/arg_parse.onyx b/core/misc/arg_parse.onyx index edc8c547..2a7837c3 100644 --- a/core/misc/arg_parse.onyx +++ b/core/misc/arg_parse.onyx @@ -28,8 +28,8 @@ use runtime false and are true if one or more of the option values are present. """ arg_parse :: (c_args: [] cstr, output: any) -> bool { - arg_iter := iter.as_iter(c_args) - |> iter.map(string.from_cstr); + arg_iter := iter.as_iter(c_args) |> + iter.map(string.from_cstr); defer arg_iter.close(arg_iter.data); use runtime.info {*}; diff --git a/core/string/char_utils.onyx b/core/string/char_utils.onyx index 0a79830d..d6b3c2cf 100644 --- a/core/string/char_utils.onyx +++ b/core/string/char_utils.onyx @@ -2,8 +2,8 @@ package core.string #inject u8 { is_alpha :: (c: u8) -> bool { - return (c >= #char "A" && c <= #char "Z") - || (c >= #char "a" && c <= #char "z"); + return (c >= #char "A" && c <= #char "Z") || + (c >= #char "a" && c <= #char "z"); } is_num :: (c: u8) -> bool { diff --git a/core/string/string.onyx b/core/string/string.onyx index 034a4aa2..565f8f4b 100644 --- a/core/string/string.onyx +++ b/core/string/string.onyx @@ -322,8 +322,7 @@ strip_whitespace :: (s: &str) { #overload strip_whitespace :: (s: str) => - s |> strip_leading_whitespace() - |> strip_trailing_whitespace() + s |> strip_leading_whitespace() |> strip_trailing_whitespace() strip_leading_whitespace :: #match #local {} diff --git a/core/string/string_pool.onyx b/core/string/string_pool.onyx index ecf77ee1..3822ed31 100644 --- a/core/string/string_pool.onyx +++ b/core/string/string_pool.onyx @@ -27,8 +27,8 @@ StringPool :: struct { // // Creates a StringPool capable of storing a string of at // most `maximum_string_length` bytes. -pool_make :: (maximum_string_length := 16384, allocator := context.allocator) - => StringPool.{ +pool_make :: (maximum_string_length := 16384, allocator := context.allocator) => + StringPool.{ arena.make(allocator, maximum_string_length) } diff --git a/core/time/time.onyx b/core/time/time.onyx index c02f57cf..90439283 100644 --- a/core/time/time.onyx +++ b/core/time/time.onyx @@ -556,10 +556,10 @@ tm_to_time :: (tm: Timestamp) -> i64 { mi := cast(i64, tm.min); s := cast(i64, tm.sec); - return (365 * y + y / 4 - y / 100 + y / 400 + 3 * (m + 1) / 5 + 30 * m + d - 719561) * 86400 - + 3600 * h - + 60 * mi - + s; + return (365 * y + y / 4 - y / 100 + y / 400 + 3 * (m + 1) / 5 + 30 * m + d - 719561) * 86400 + + 3600 * h + + 60 * mi + + s; }