X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=lib-lua%2Fruntime.c;h=e4482f2c1c86bf67a6aad0dc8a61c70f3affbb7d;hb=b1c9f537b475b3bc8f6517bb4d7008a411bb478e;hp=552587c3dc1e111eeef74b41b51c661d4bc5197d;hpb=6f1bd3d49f9bb02c57e2c7a1ba8e5507edb28ad5;p=apps%2Fmadmutt.git diff --git a/lib-lua/runtime.c b/lib-lua/runtime.c index 552587c..e4482f2 100644 --- a/lib-lua/runtime.c +++ b/lib-lua/runtime.c @@ -21,22 +21,22 @@ #include "lib-lua_priv.h" static lua_State *L; -static reg_entry registry[LTK_count]; -static const luaL_Reg lualibs[] = { - {"", luaopen_base}, - {LUA_OSLIBNAME, luaopen_os}, - {LUA_LOADLIBNAME, luaopen_package}, - {LUA_TABLIBNAME, luaopen_table}, - {LUA_IOLIBNAME, luaopen_io}, - {LUA_STRLIBNAME, luaopen_string}, - {LUA_MATHLIBNAME, luaopen_math}, - {LUA_DBLIBNAME, luaopen_debug}, - {LUA_MADMUTT, luaopen_madmutt}, -}; -void mlua_initialize(void) +void luaM_initialize(void) { + static const luaL_Reg lualibs[] = { + {"", luaopen_base}, + {LUA_OSLIBNAME, luaopen_os}, + {LUA_LOADLIBNAME, luaopen_package}, + {LUA_TABLIBNAME, luaopen_table}, + {LUA_IOLIBNAME, luaopen_io}, + {LUA_STRLIBNAME, luaopen_string}, + {LUA_MATHLIBNAME, luaopen_math}, + {LUA_DBLIBNAME, luaopen_debug}, + {"madmutt", luaopen_madmutt}, + }; + int i; L = lua_open(); @@ -47,18 +47,18 @@ void mlua_initialize(void) } } -void mlua_shutdown(void) +void luaM_shutdown(void) { lua_close(L); } -int mlua_dofile(const char *filename) +int luaM_dofile(const char *filename) { return luaL_dofile(L, filename); } -int mlua_wrap(void (*errfun)(const char *fmt, ...), int status) +int luaM_wrap(void (*errfun)(const char *fmt, ...), int status) { if (status) { (*errfun)("-[lua]-: %s\n", lua_tostring(L, -1)); @@ -67,16 +67,16 @@ int mlua_wrap(void (*errfun)(const char *fmt, ...), int status) return status; } -const char *mlua_reggets(int tk) -{ - if (registry[tk].type != REG_STR) - return NULL; - return registry[tk].s; -} -void mlua_regsets(int tk, const char *s) +quadopt_t luaM_checkquadopt(lua_State *Ls, int narg) { - reg_entry_wipe(registry + tk); - registry[tk].type = REG_STR; - registry[tk].s = m_strdup(s); + const char *s; + int i = luaL_checkinteger(Ls, narg); + + if (i & ~3) { + s = lua_pushfstring(Ls, "int in [0-3] expected, got %d", i); + return luaL_argerror(Ls, narg, s); + } + return i; } +