#ifndef SMLUA_H #define SMLUA_H #include #include #include #include #include "types.h" #include "smlua_cobject.h" #include "smlua_cobject_allowlist.h" #include "smlua_cobject_autogen.h" #include "smlua_utils.h" #include "smlua_functions.h" #include "smlua_functions_autogen.h" #include "smlua_hooks.h" #include "smlua_sync_table.h" #include "pc/debuglog.h" #define LOG_LUA(...) { if (!gSmLuaSuppressErrors) { _debuglog_print_log("LUA ", __FILE__), printf(__VA_ARGS__), printf("\n"), smlua_mod_error(); } } #define LOG_LUA_LINE(...) { if (!gSmLuaSuppressErrors) { _debuglog_print_log("LUA ", __FILE__), printf(__VA_ARGS__), printf("\n"), smlua_mod_error(); smlua_logline(); } } #ifdef DEVELOPMENT #define LUA_STACK_CHECK_BEGIN() int __LUA_STACK_TOP = lua_gettop(gLuaState) #define LUA_STACK_CHECK_END() if ((__LUA_STACK_TOP) != lua_gettop(gLuaState)) { smlua_dump_stack(); fflush(stdout); } assert((__LUA_STACK_TOP) == lua_gettop(gLuaState)) #else #define LUA_STACK_CHECK_BEGIN() #define LUA_STACK_CHECK_END() #endif extern lua_State* gLuaState; extern u8 gLuaInitializingScript; extern u8 gSmLuaSuppressErrors; extern struct Mod* gLuaLoadingMod; extern struct Mod* gLuaActiveMod; extern struct Mod* gLuaLastHookMod; void smlua_mod_error(void); int smlua_error_handler(UNUSED lua_State* L); int smlua_pcall(lua_State* L, int nargs, int nresults, int errfunc); void smlua_init(void); void smlua_update(void); void smlua_shutdown(void); #endif