From 05bdda5d05d3a0522130791f77903b0e5549191c Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Sat, 8 Jul 2023 18:46:09 +1200 Subject: [PATCH] Add function callisto_openall(lua_State *) --- lcallisto.c | 15 ++++++++++----- lcallisto.h | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lcallisto.c b/lcallisto.c index 2728220..d7051f9 100644 --- a/lcallisto.c +++ b/lcallisto.c @@ -32,20 +32,25 @@ callisto_newstate(void) } void -callisto_openlibs(lua_State *L) +callisto_openall(lua_State *L) { const luaL_Reg *lib; - luaL_openlibs(L); - - /* "require" functions from 'loadedlibs' and set results to global table */ + /* for every Callisto library */ for (lib = loadedlibs; lib->func; lib++) { - lua_newtable(L); + lua_newtable(L); /* make a new table for the library */ lib->func(L); /* load library */ lua_setglobal(L, lib->name); } } +void +callisto_openlibs(lua_State *L) +{ + luaL_openlibs(L); + callisto_openall(L); +} + void callisto_setversion(lua_State *L) { diff --git a/lcallisto.h b/lcallisto.h index 468029e..7371141 100644 --- a/lcallisto.h +++ b/lcallisto.h @@ -38,6 +38,7 @@ int luaopen_process(lua_State *); int luaopen_socket(lua_State *); lua_State *callisto_newstate(void); +void callisto_openall(lua_State *); void callisto_openlibs(lua_State *); void callisto_setversion(lua_State *);