aboutsummaryrefslogtreecommitdiff
path: root/stdlib/enums.h
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-11-29 12:55:14 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-11-29 12:55:14 -0500
commit4b5e4cd1f21582f5e5fa682ab4e4bff252963468 (patch)
treee8fecb01f444c1d392c09255adba5cf6b312b326 /stdlib/enums.h
parent0b0e0a0a1d41e9574de8dc17c688a4894c5e7f92 (diff)
Change how types handle metamethods
Diffstat (limited to 'stdlib/enums.h')
-rw-r--r--stdlib/enums.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/stdlib/enums.h b/stdlib/enums.h
new file mode 100644
index 00000000..8afa5c9b
--- /dev/null
+++ b/stdlib/enums.h
@@ -0,0 +1,24 @@
+// Metamethods for enums
+
+#include <stdbool.h>
+#include <stdint.h>
+
+#include "datatypes.h"
+#include "types.h"
+#include "util.h"
+
+PUREFUNC uint64_t Enum$hash(const void *obj, const TypeInfo_t *type);
+PUREFUNC int32_t Enum$compare(const void *x, const void *y, const TypeInfo_t *type);
+PUREFUNC bool Enum$equal(const void *x, const void *y, const TypeInfo_t *type);
+PUREFUNC Text_t Enum$as_text(const void *obj, bool colorize, const TypeInfo_t *type);
+PUREFUNC bool Enum$is_none(const void *obj, const TypeInfo_t *type);
+
+#define Enum$metamethods ((metamethods_t){ \
+ .as_text=Enum$as_text, \
+ .compare=Enum$compare, \
+ .equal=Enum$equal, \
+ .hash=Enum$hash, \
+ .is_none=Enum$is_none, \
+})
+
+// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0