diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-09-28 14:17:17 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-09-28 14:17:17 -0400 |
| commit | 8f717fe9f498642ca6f857ef329d73760b98d44c (patch) | |
| tree | db30b6e2d53d38fd29b5f770f34234367bc6e068 /stdlib/optionals.h | |
| parent | 794c1343ba36d62e6dcb4df9a51e89e2c4f42b74 (diff) | |
Redefine NULL_* values as #defines so they can be constant initializers
Diffstat (limited to 'stdlib/optionals.h')
| -rw-r--r-- | stdlib/optionals.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/stdlib/optionals.h b/stdlib/optionals.h index 34ea3b41..31fad710 100644 --- a/stdlib/optionals.h +++ b/stdlib/optionals.h @@ -16,12 +16,12 @@ #define OptionalText_t Text_t #define OptionalClosure_t Closure_t -extern const OptionalBool_t NULL_BOOL; -extern const OptionalTable_t NULL_TABLE; -extern const OptionalArray_t NULL_ARRAY; -extern const OptionalInt_t NULL_INT; -extern const OptionalClosure_t NULL_CLOSURE; -extern const OptionalText_t NULL_TEXT; +#define NULL_ARRAY ((Array_t){.length=-1}) +#define NULL_BOOL ((OptionalBool_t)2) +#define NULL_INT ((OptionalInt_t){.small=0}) +#define NULL_TABLE ((OptionalTable_t){.entries.length=-1}) +#define NULL_CLOSURE ((OptionalClosure_t){.fn=NULL}) +#define NULL_TEXT ((OptionalText_t){.length=-1}) PUREFUNC bool is_null(const void *obj, const TypeInfo *non_optional_type); Text_t Optional$as_text(const void *obj, bool colorize, const TypeInfo *type); |
