From f4e38fd061a158ecb94881273c6db6e6a332f61d Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 17 Aug 2025 20:35:09 -0400 Subject: =?UTF-8?q?Switch=20from=20using=20dollar=20signs=20as=20namespace?= =?UTF-8?q?=20delimiters=20to=20using=20=E3=80=85,=20=E3=83=BD,=20and=20?= =?UTF-8?q?=E3=80=87.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stdlib/bytes.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'src/stdlib/bytes.c') diff --git a/src/stdlib/bytes.c b/src/stdlib/bytes.c index 130a645f..9492c14c 100644 --- a/src/stdlib/bytes.c +++ b/src/stdlib/bytes.c @@ -8,10 +8,10 @@ #include "text.h" #include "util.h" -public const Byte_t Byte$min = 0; -public const Byte_t Byte$max = UINT8_MAX; +public const Byte_t Byteヽmin = 0; +public const Byte_t Byteヽmax = UINT8_MAX; -PUREFUNC public Text_t Byte$as_text(const void *b, bool colorize, const TypeInfo_t *info) +PUREFUNC public Text_t Byteヽas_text(const void *b, bool colorize, const TypeInfo_t *info) { (void)info; if (!b) return Text("Byte"); @@ -21,28 +21,28 @@ PUREFUNC public Text_t Byte$as_text(const void *b, bool colorize, const TypeInfo (byte & 15) <= 9 ? '0' + (byte & 15) : 'a' + (byte & 15) - 10, '\0', }; - Text_t text = Text$from_str(digits); + Text_t text = Textヽfrom_str(digits); if (colorize) text = Texts(Text("\x1b[35m"), text, Text("\x1b[m")); return text; } -public CONSTFUNC bool Byte$is_between(const Byte_t x, const Byte_t low, const Byte_t high) { +public CONSTFUNC bool Byteヽis_between(const Byte_t x, const Byte_t low, const Byte_t high) { return low <= x && x <= high; } -public OptionalByte_t Byte$parse(Text_t text, Text_t *remainder) +public OptionalByte_t Byteヽparse(Text_t text, Text_t *remainder) { - OptionalInt_t full_int = Int$parse(text, remainder); + OptionalInt_t full_int = Intヽparse(text, remainder); if (full_int.small != 0L - && Int$compare_value(full_int, I(0)) >= 0 - && Int$compare_value(full_int, I(255)) <= 0) { - return (OptionalByte_t){.value=Byte$from_int(full_int, true)}; + && Intヽcompare_value(full_int, I(0)) >= 0 + && Intヽcompare_value(full_int, I(255)) <= 0) { + return (OptionalByte_t){.value=Byteヽfrom_int(full_int, true)}; } else { return NONE_BYTE; } } -public Text_t Byte$hex(Byte_t byte, bool uppercase, bool prefix) { +public Text_t Byteヽhex(Byte_t byte, bool uppercase, bool prefix) { struct Text_s text = {.tag=TEXT_ASCII}; text.ascii = GC_MALLOC_ATOMIC(8); char *p = (char*)text.ascii; @@ -62,12 +62,12 @@ public Text_t Byte$hex(Byte_t byte, bool uppercase, bool prefix) { return text; } -public bool Byte$get_bit(Byte_t x, Int_t bit_index) { - if (Int$compare_value(bit_index, I(1)) < 0) +public bool Byteヽget_bit(Byte_t x, Int_t bit_index) { + if (Intヽcompare_value(bit_index, I(1)) < 0) fail("Invalid bit index (expected 1 or higher): ", bit_index); - if (Int$compare_value(bit_index, I(8)) > 0) + if (Intヽcompare_value(bit_index, I(8)) > 0) fail("Bit index is too large! There are only 8 bits in a byte, but index is: ", bit_index); - return ((x & (Byte_t)(1L << (Int64$from_int(bit_index, true)-1L))) != 0); + return ((x & (Byte_t)(1L << (Int64ヽfrom_int(bit_index, true)-1L))) != 0); } #ifdef __TINYC__ @@ -91,7 +91,7 @@ static OptionalByte_t _next_Byte(ByteRange_t *info) { return i; } -public CONSTFUNC Closure_t Byte$to(Byte_t first, Byte_t last, OptionalInt8_t step) { +public CONSTFUNC Closure_t Byteヽto(Byte_t first, Byte_t last, OptionalInt8_t step) { ByteRange_t *range = GC_MALLOC(sizeof(ByteRange_t)); range->current = (OptionalByte_t){.value=first}; range->last = (OptionalByte_t){.value=last}; @@ -99,34 +99,34 @@ public CONSTFUNC Closure_t Byte$to(Byte_t first, Byte_t last, OptionalInt8_t ste return (Closure_t){.fn=_next_Byte, .userdata=range}; } -public PUREFUNC Byte_t Byte$from_int(Int_t i, bool truncate) { - if unlikely (!truncate && Int$compare_value(i, I_small(0xFF)) > 0) +public PUREFUNC Byte_t Byteヽfrom_int(Int_t i, bool truncate) { + if unlikely (!truncate && Intヽcompare_value(i, I_small(0xFF)) > 0) fail("This value is too large to convert to a byte without truncation: ", i); - else if unlikely (!truncate && Int$compare_value(i, I_small(0)) < 0) + else if unlikely (!truncate && Intヽcompare_value(i, I_small(0)) < 0) fail("Negative values can't be converted to bytes: ", i); return (Byte_t)(i.small >> 2); } -public PUREFUNC Byte_t Byte$from_int64(Int64_t i, bool truncate) { +public PUREFUNC Byte_t Byteヽfrom_int64(Int64_t i, bool truncate) { if unlikely (!truncate && i != (Int64_t)(Byte_t)i) fail("This value can't be converted to a byte without truncation: ", i); return (Byte_t)i; } -public PUREFUNC Byte_t Byte$from_int32(Int32_t i, bool truncate) { +public PUREFUNC Byte_t Byteヽfrom_int32(Int32_t i, bool truncate) { if unlikely (!truncate && i != (Int32_t)(Byte_t)i) fail("This value can't be converted to a byte without truncation: ", i); return (Byte_t)i; } -public PUREFUNC Byte_t Byte$from_int16(Int16_t i, bool truncate) { +public PUREFUNC Byte_t Byteヽfrom_int16(Int16_t i, bool truncate) { if unlikely (!truncate && i != (Int16_t)(Byte_t)i) fail("This value can't be converted to a byte without truncation: ", i); return (Byte_t)i; } -public const TypeInfo_t Byte$info = { +public const TypeInfo_t Byteヽinfo = { .size=sizeof(Byte_t), .align=__alignof__(Byte_t), .metamethods={ - .as_text=Byte$as_text, + .as_text=Byteヽas_text, }, }; -- cgit v1.2.3