diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-02-13 15:03:22 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-02-13 15:03:22 -0500 |
| commit | 5be955904682300153af0abdfd6b711b9da2ac8f (patch) | |
| tree | e616bc83904817fdefa43354fa815f13daf18739 /stdlib/integers.h | |
| parent | 8e0f1fa227be762cab19234abc106ba4c572077d (diff) | |
Deprecate Range datatype in favor of using iterator methods
Diffstat (limited to 'stdlib/integers.h')
| -rw-r--r-- | stdlib/integers.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/stdlib/integers.h b/stdlib/integers.h index 033a6873..fce243a9 100644 --- a/stdlib/integers.h +++ b/stdlib/integers.h @@ -22,7 +22,7 @@ #define I16(x) ((int16_t)x) #define I8(x) ((int8_t)x) -#define DEFINE_INT_TYPE(c_type, type_name, to_attr) \ +#define DEFINE_INT_TYPE(c_type, type_name) \ typedef struct { \ c_type i; \ bool is_none:1; \ @@ -34,7 +34,7 @@ Text_t type_name ## $hex(c_type i, Int_t digits, bool uppercase, bool prefix); \ Text_t type_name ## $octal(c_type i, Int_t digits, bool prefix); \ Array_t type_name ## $bits(c_type x); \ - to_attr Range_t type_name ## $to(c_type from, c_type to); \ + Closure_t type_name ## $to(c_type first, c_type last, Optional ## type_name ## _t step); \ PUREFUNC Optional ## type_name ## _t type_name ## $parse(Text_t text); \ MACROLIKE PUREFUNC c_type type_name ## $clamped(c_type x, c_type min, c_type max) { \ return x < min ? min : (x > max ? max : x); \ @@ -68,10 +68,10 @@ return (c_type)((u##c_type)x >> y); \ } -DEFINE_INT_TYPE(int64_t, Int64, __attribute__(())) -DEFINE_INT_TYPE(int32_t, Int32, CONSTFUNC) -DEFINE_INT_TYPE(int16_t, Int16, CONSTFUNC) -DEFINE_INT_TYPE(int8_t, Int8, CONSTFUNC) +DEFINE_INT_TYPE(int64_t, Int64) +DEFINE_INT_TYPE(int32_t, Int32) +DEFINE_INT_TYPE(int16_t, Int16) +DEFINE_INT_TYPE(int8_t, Int8) #undef DEFINE_INT_TYPE #define NONE_INT64 ((OptionalInt64_t){.is_none=true}) @@ -101,7 +101,7 @@ PUREFUNC bool Int$equal_value(const Int_t x, const Int_t y); Text_t Int$format(Int_t i, Int_t digits); Text_t Int$hex(Int_t i, Int_t digits, bool uppercase, bool prefix); Text_t Int$octal(Int_t i, Int_t digits, bool prefix); -PUREFUNC Range_t Int$to(Int_t from, Int_t to); +PUREFUNC Closure_t Int$to(Int_t first, Int_t last, OptionalInt_t step); OptionalInt_t Int$from_str(const char *str); OptionalInt_t Int$parse(Text_t text); Int_t Int$abs(Int_t x); |
