diff options
Diffstat (limited to 'include/lua_state.h')
| -rw-r--r-- | include/lua_state.h | 22 |
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 |
