code / tomo

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