Skip to content

Commit

Permalink
app_lua: added internal alternative to luaL_openlib()
Browse files Browse the repository at this point in the history
- it was deprecated in Lua API, no longer available in newer versions [wip]
  • Loading branch information
miconda committed Jan 17, 2022
1 parent 3da3a78 commit a30a6ce
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/modules/app_lua/app_lua_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,34 @@ int sr_lua_reload_module(unsigned int reload)
return 0;
}

/**
*
*/
void ksr_luaL_openlib_mode(lua_State *L, const char *libname,
const luaL_Reg *lfuncs, int nup, int mode)
{
if(mode) {
lua_getglobal(L, libname);
if (lua_isnil(L, -1)) {
lua_pop(L, 1);
lua_newtable(L);
}
} else {
lua_newtable(L);
}
luaL_setfuncs(L, lfuncs, 0);
lua_setglobal(L, libname);
}

/**
*
*/
void ksr_luaL_openlib(lua_State *L, const char *libname,
const luaL_Reg *lfuncs, int nup)
{
ksr_luaL_openlib_mode(L, libname, lfuncs, nup, 0);
}

/**
*
*/
Expand Down

0 comments on commit a30a6ce

Please sign in to comment.