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 // Logic for handling function type values
3 #pragma once
5 #include <stdbool.h>
6 #include <stdint.h>
8 #include "types.h"
9 #include "util.h"
11 void register_function(void *fn, Text_t filename, int64_t line_num, Text_t name);
12 OptionalText_t get_function_name(void *fn);
13 OptionalText_t get_function_filename(void *fn);
14 int64_t get_function_line_num(void *fn);
15 Text_t Func$as_text(const void *fn, bool colorize, const TypeInfo_t *type);
16 PUREFUNC bool Func$is_none(const void *obj, const TypeInfo_t *);
18 #define Func$metamethods \
19 { \
20 .as_text = Func$as_text, \
21 .is_none = Func$is_none, \
22 .serialize = cannot_serialize, \
23 .deserialize = cannot_deserialize, \
26 #define Function$info(typestr) \
27 &((TypeInfo_t){.size = sizeof(void *), \
28 .align = __alignof__(void *), \
29 .tag = FunctionInfo, \
30 .FunctionInfo.type_str = typestr, \
31 .metamethods = Func$metamethods})
32 #define Closure$info(typestr) \
33 &((TypeInfo_t){.size = sizeof(void *[2]), \
34 .align = __alignof__(void *), \
35 .tag = FunctionInfo, \
36 .FunctionInfo.type_str = typestr, \
37 .metamethods = Func$metamethods})