aboutsummaryrefslogtreecommitdiff
path: root/stdlib/bytes.h
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-03-05 18:20:54 -0500
committerBruce Hill <bruce@bruce-hill.com>2025-03-05 18:20:54 -0500
commit147e0f0269440fce15d6b88a8a90627f3a3b2df2 (patch)
treebc33522ba71b5a2996fae22e102cce5046cf1333 /stdlib/bytes.h
parent2c4324670ff569ede360d13875c5e4b5720a626d (diff)
Overhaul of constructors, making it more consistent and correct. Also
changed T(), T, T_t, T_s type names to T(), T$$info, T$$type, T$$struct for unambiguity
Diffstat (limited to 'stdlib/bytes.h')
-rw-r--r--stdlib/bytes.h18
1 files changed, 8 insertions, 10 deletions
diff --git a/stdlib/bytes.h b/stdlib/bytes.h
index 9bd4e1c2..ac1b61a3 100644
--- a/stdlib/bytes.h
+++ b/stdlib/bytes.h
@@ -5,23 +5,21 @@
#include <stdbool.h>
#include <stdint.h>
+#include "datatypes.h"
+#include "stdlib.h"
#include "types.h"
#include "util.h"
-#define Byte_t uint8_t
#define Byte(b) ((Byte_t)(b))
PUREFUNC Text_t Byte$as_text(const void *b, bool colorize, const TypeInfo_t *type);
-#define Byte_to_Int64(b, _) ((Int64_t)(b))
-#define Byte_to_Int32(b, _) ((Int32_t)(b))
-#define Byte_to_Int16(b, _) ((Int16_t)(b))
-#define Byte_to_Int8(b, _) ((Int8_t)(b))
-
-#define Int64_to_Byte(b, _) ((Byte_t)(b))
-#define Int32_to_Byte(b, _) ((Byte_t)(b))
-#define Int16_to_Byte(b, _) ((Byte_t)(b))
-#define Int8_to_Byte(b, _) ((Byte_t)(b))
+Byte_t Byte$from_int(Int_t i, bool truncate);
+Byte_t Byte$from_int64(int64_t i, bool truncate);
+Byte_t Byte$from_int32(int32_t i, bool truncate);
+Byte_t Byte$from_int16(int16_t i, bool truncate);
+MACROLIKE Byte_t Byte$from_int8(int8_t i) { return (Byte_t)i; }
+MACROLIKE Byte_t Byte$from_bool(bool b) { return (Byte_t)b; }
extern const Byte_t Byte$min;
extern const Byte_t Byte$max;