aboutsummaryrefslogtreecommitdiffstats
path: root/xlua.h
diff options
context:
space:
mode:
authorTomasz Kramkowski <tk@the-tk.com>2021-02-11 12:15:12 +0000
committerTomasz Kramkowski <tk@the-tk.com>2021-02-11 14:25:14 +0000
commitbb97e8aaa15217afe1f3fcdc93662ab03b8ae9d9 (patch)
tree64fa5b5ba419e72bc6acaddadbc51c73646295fa /xlua.h
downloadluiml-bb97e8aaa15217afe1f3fcdc93662ab03b8ae9d9.tar.gz
luiml-bb97e8aaa15217afe1f3fcdc93662ab03b8ae9d9.tar.xz
luiml-bb97e8aaa15217afe1f3fcdc93662ab03b8ae9d9.zip
init commit
Diffstat (limited to 'xlua.h')
-rw-r--r--xlua.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/xlua.h b/xlua.h
new file mode 100644
index 0000000..ac2838e
--- /dev/null
+++ b/xlua.h
@@ -0,0 +1,31 @@
+#ifndef XLUA_H
+#define XLUA_H
+
+#include <stdbool.h>
+
+struct key {
+ enum key_type {
+ KT_NULL,
+ KT_STRING,
+ KT_NUMBER,
+ } type;
+ union {
+ const char *str;
+ double num;
+ } key;
+ enum value_type {
+ VT_STRING,
+ VT_NUMBER,
+ VT_BOOLEAN,
+ } vtype;
+};
+#define _STR(s) #s
+#define STR(s) _STR(s)
+#define KEY_STR(k, vt) (struct key){ .type = KT_STRING, .key.str = _STR(k), .vtype = (vt)}
+#define KEY_NUM(k, vt) (struct key){ .type = KT_NUMBER, .key.mum = (k), .vtype = (vt)}
+#define KEY_END (struct key){ .type = KT_NULL }
+
+void pushtable(lua_State *L, const struct key *keys, ...);
+void pushsetmember(lua_State *L, int index, const char *name, bool in_set);
+
+#endif /* !XLUA_H */