aboutsummaryrefslogtreecommitdiff
path: root/stdlib/functiontype.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/functiontype.h
parent0b0e0a0a1d41e9574de8dc17c688a4894c5e7f92 (diff)
Change how types handle metamethods
Diffstat (limited to 'stdlib/functiontype.h')
-rw-r--r--stdlib/functiontype.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/stdlib/functiontype.h b/stdlib/functiontype.h
index 8fdabb8c..7745bff8 100644
--- a/stdlib/functiontype.h
+++ b/stdlib/functiontype.h
@@ -1,9 +1,27 @@
#pragma once
+#include <stdbool.h>
+
+#include "types.h"
+#include "util.h"
+
// Logic for handling function type values
void register_function(void *fn, Text_t name);
Text_t *get_function_name(void *fn);
Text_t Func$as_text(const void *fn, bool colorize, const TypeInfo_t *type);
+PUREFUNC bool Func$is_none(const void *obj, const TypeInfo_t*);
+
+#define Func$metamethods ((metamethods_t){ \
+ .as_text=Func$as_text, \
+ .is_none=Func$is_none, \
+})
+
+#define Function$info(typestr) &((TypeInfo_t){.size=sizeof(void*), .align=__alignof__(void*), \
+ .tag=FunctionInfo, .FunctionInfo.type_str=typestr, \
+ .metamethods=Func$metamethods})
+#define Closure$info(typestr) &((TypeInfo_t){.size=sizeof(void*[2]), .align=__alignof__(void*), \
+ .tag=FunctionInfo, .FunctionInfo.type_str=typestr, \
+ .metamethods=Func$metamethods})
// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0