Add function callisto_openall(lua_State *)

This commit is contained in:
Jeremy Baxter 2023-07-08 18:46:09 +12:00
parent 941722cb01
commit 05bdda5d05
2 changed files with 11 additions and 5 deletions

View file

@ -32,20 +32,25 @@ callisto_newstate(void)
} }
void void
callisto_openlibs(lua_State *L) callisto_openall(lua_State *L)
{ {
const luaL_Reg *lib; const luaL_Reg *lib;
luaL_openlibs(L); /* for every Callisto library */
/* "require" functions from 'loadedlibs' and set results to global table */
for (lib = loadedlibs; lib->func; lib++) { for (lib = loadedlibs; lib->func; lib++) {
lua_newtable(L); lua_newtable(L); /* make a new table for the library */
lib->func(L); /* load library */ lib->func(L); /* load library */
lua_setglobal(L, lib->name); lua_setglobal(L, lib->name);
} }
} }
void
callisto_openlibs(lua_State *L)
{
luaL_openlibs(L);
callisto_openall(L);
}
void void
callisto_setversion(lua_State *L) callisto_setversion(lua_State *L)
{ {

View file

@ -38,6 +38,7 @@ int luaopen_process(lua_State *);
int luaopen_socket(lua_State *); int luaopen_socket(lua_State *);
lua_State *callisto_newstate(void); lua_State *callisto_newstate(void);
void callisto_openall(lua_State *);
void callisto_openlibs(lua_State *); void callisto_openlibs(lua_State *);
void callisto_setversion(lua_State *); void callisto_setversion(lua_State *);