From 5b2acc934ee1cda4a514b617a56b43fc4ddf6a0f Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 11 Oct 2025 14:21:35 -0400 Subject: Added Empty() struct --- src/stdlib/datatypes.h | 3 +++ src/stdlib/structs.c | 12 ++++++++++++ src/stdlib/structs.h | 2 ++ src/stdlib/types.h | 1 - 4 files changed, 17 insertions(+), 1 deletion(-) (limited to 'src/stdlib') diff --git a/src/stdlib/datatypes.h b/src/stdlib/datatypes.h index fc665401..0ac97019 100644 --- a/src/stdlib/datatypes.h +++ b/src/stdlib/datatypes.h @@ -69,6 +69,9 @@ typedef struct table_s { struct table_s *fallback; } Table_t; +typedef struct Empty$$struct { +} Empty$$type; + typedef struct { void *fn, *userdata; } Closure_t; diff --git a/src/stdlib/structs.c b/src/stdlib/structs.c index 885b903c..89b5581b 100644 --- a/src/stdlib/structs.c +++ b/src/stdlib/structs.c @@ -6,6 +6,7 @@ #include "bools.h" #include "metamethods.h" #include "siphash.h" +#include "structs.h" #include "text.h" #include "util.h" @@ -214,3 +215,14 @@ void Struct$deserialize(FILE *in, void *outval, List_t *pointers, const TypeInfo } } } + +public +const TypeInfo_t Empty$$info = {.size = 0, + .align = 0, + .tag = StructInfo, + .metamethods = Struct$metamethods, + .StructInfo.name = "Empty", + .StructInfo.num_fields = 0}; + +public +const Empty$$type EMPTY = {}; diff --git a/src/stdlib/structs.h b/src/stdlib/structs.h index a582e9fb..83904377 100644 --- a/src/stdlib/structs.h +++ b/src/stdlib/structs.h @@ -15,6 +15,8 @@ PUREFUNC bool PackedData$equal(const void *x, const void *y, const TypeInfo_t *t PUREFUNC Text_t Struct$as_text(const void *obj, bool colorize, const TypeInfo_t *type); void Struct$serialize(const void *obj, FILE *out, Table_t *pointers, const TypeInfo_t *type); void Struct$deserialize(FILE *in, void *outval, List_t *pointers, const TypeInfo_t *type); +extern const TypeInfo_t Empty$$info; +extern const Empty$$type EMPTY; #define Struct$metamethods \ { \ diff --git a/src/stdlib/types.h b/src/stdlib/types.h index bd2474fa..5cd622e7 100644 --- a/src/stdlib/types.h +++ b/src/stdlib/types.h @@ -91,7 +91,6 @@ struct TypeInfo_s { extern const TypeInfo_t Void$info; extern const TypeInfo_t Abort$info; -#define Void_t void Text_t Type$as_text(const void *typeinfo, bool colorize, const TypeInfo_t *type); -- cgit v1.2.3