aboutsummaryrefslogtreecommitdiff
path: root/include/lua_state.h
diff options
context:
space:
mode:
authordacctal <donotcontactmevia@email.invalid>2026-08-09 07:30:59 +0000
committerdacctal <donotcontactmevia@email.invalid>2026-08-09 07:30:59 +0000
commit4fa342bcfdb5ebcbe65cabe1fb9ac3a46ea4ddca (patch)
treee7398fc7b26e9bd225f2c10ed0557baa771fca78 /include/lua_state.h
parente2cda84ebbd073ece54692c6a3d785afc6148268 (diff)
checkpoint (it doesn't compile)
Diffstat (limited to 'include/lua_state.h')
-rw-r--r--include/lua_state.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/include/lua_state.h b/include/lua_state.h
index 49f35e4..db689fe 100644
--- a/include/lua_state.h
+++ b/include/lua_state.h
@@ -12,5 +12,27 @@ extern bool L_is_loaded;
bool init_lua_state(void);
bool init_lua_config(void);
void free_lua_state(void);
+void free_lua_config(void);
+
+#define lua_get_field_type(name, type, file, pop_num) \
+ do { \
+ lua_getfield(L, -1, name); \
+ if (!lua_is##type(L, -1)) { \
+ log_error("lua: expected type '" #type "' for %s in %.*s", \
+ name, str_fmt(file)); \
+ lua_pop(L, pop_num); \
+ return false; \
+ } \
+ } while (0)
+
+#define lua_run_function(name, file, params, returns, pop_num) \
+ do { \
+ if (lua_pcall(L, params, returns, 0) { \
+ log_error("lua: '%s' function borked in %.*s: %s", \
+ name, str_fmt(file)), lua_tostring(L, -1); \
+ lua_pop(L, pop_num); \
+ return false; \
+ } \
+ } while (0)
#endif