code / tomo

Lines41.3K C23.7K Markdown9.7K YAML5.0K Tomo2.3K
7 others 763
Python231 Shell230 make212 INI47 Text21 SVG16 Lua6
(42 lines)
1 // Type infos and methods for Pointer types
3 #pragma once
5 #include <stdbool.h>
6 #include <stdint.h>
8 #include "datatypes.h"
9 #include "types.h"
10 #include "util.h"
12 Text_t Pointer$as_text(const void *x, bool colorize, const TypeInfo_t *type);
13 PUREFUNC int32_t Pointer$compare(const void *x, const void *y, const TypeInfo_t *type);
14 PUREFUNC bool Pointer$equal(const void *x, const void *y, const TypeInfo_t *type);
15 PUREFUNC bool Pointer$is_none(const void *x, const TypeInfo_t *);
16 void Pointer$serialize(const void *obj, FILE *out, Table_t *pointers, const TypeInfo_t *type);
17 void Pointer$deserialize(FILE *in, void *outval, List_t *pointers, const TypeInfo_t *type);
19 #define Null(t) (t *)NULL
20 #define POINTER_TYPE(_sigil, _pointed) \
21 (&(TypeInfo_t){.size = sizeof(void *), \
22 .align = __alignof__(void *), \
23 .tag = PointerInfo, \
24 .PointerInfo.sigil = _sigil, \
25 .PointerInfo.pointed = _pointed})
27 #define Pointer$metamethods \
28 { \
29 .as_text = Pointer$as_text, \
30 .compare = Pointer$compare, \
31 .equal = Pointer$equal, \
32 .is_none = Pointer$is_none, \
33 .serialize = Pointer$serialize, \
34 .deserialize = Pointer$deserialize, \
37 #define Pointer$info(sigil_expr, pointed_info) \
38 &((TypeInfo_t){.size = sizeof(void *), \
39 .align = __alignof__(void *), \
40 .tag = PointerInfo, \
41 .PointerInfo = {.sigil = sigil_expr, .pointed = pointed_info}, \
42 .metamethods = Pointer$metamethods})