code / tomo

Lines41.3K C23.7K Markdown9.7K YAML5.0K Tomo2.3K
7 others 763
Python231 Shell230 make212 INI47 Text21 SVG16 Lua6
(38 lines)
1 // Metamethods for enums
3 #include <stdbool.h>
4 #include <stdint.h>
6 #include "datatypes.h"
7 #include "types.h"
8 #include "util.h"
10 PUREFUNC uint64_t Enum$hash(const void *obj, const TypeInfo_t *type);
11 PUREFUNC int32_t Enum$compare(const void *x, const void *y, const TypeInfo_t *type);
12 PUREFUNC bool Enum$equal(const void *x, const void *y, const TypeInfo_t *type);
13 PUREFUNC Text_t Enum$as_text(const void *obj, bool colorize, const TypeInfo_t *type);
14 PUREFUNC bool Enum$is_none(const void *obj, const TypeInfo_t *type);
15 void Enum$serialize(const void *obj, FILE *out, Table_t *pointers, const TypeInfo_t *type);
16 void Enum$deserialize(FILE *in, void *outval, List_t *pointers, const TypeInfo_t *type);
18 #define Enum$metamethods \
19 { \
20 .as_text = Enum$as_text, \
21 .compare = Enum$compare, \
22 .equal = Enum$equal, \
23 .hash = Enum$hash, \
24 .is_none = Enum$is_none, \
25 .serialize = Enum$serialize, \
26 .deserialize = Enum$deserialize, \
29 #define PackedDataEnum$metamethods \
30 { \
31 .hash = PackedData$hash, \
32 .compare = Enum$compare, \
33 .equal = PackedData$equal, \
34 .as_text = Enum$as_text, \
35 .is_none = Enum$is_none, \
36 .serialize = Enum$serialize, \
37 .deserialize = Enum$deserialize, \