From 4fa342bcfdb5ebcbe65cabe1fb9ac3a46ea4ddca Mon Sep 17 00:00:00 2001 From: dacctal Date: Sun, 9 Aug 2026 07:30:59 +0000 Subject: checkpoint (it doesn't compile) --- include/lua_state.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'include/lua_state.h') 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 -- cgit v1.2.3