New interface to function 'luaL_openselectedlibs'

Instead of preloading all non-loaded libraries, there is another
mask to select which libraries to preload.
This commit is contained in:
Roberto Ierusalimschy
2024-02-15 11:17:39 -03:00
parent c8121ce34b
commit 165389b27b
8 changed files with 80 additions and 56 deletions

View File

@@ -14,11 +14,11 @@
/* version suffix for environment variable names */
#define LUA_VERSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR
#define LUA_GK 1
#define LUA_GLIBK 1
LUAMOD_API int (luaopen_base) (lua_State *L);
#define LUA_LOADLIBNAME "package"
#define LUA_LOADLIBK (LUA_GK << 1)
#define LUA_LOADLIBK (LUA_GLIBK << 1)
LUAMOD_API int (luaopen_package) (lua_State *L);
@@ -56,10 +56,10 @@ LUAMOD_API int (luaopen_utf8) (lua_State *L);
/* open selected libraries */
LUALIB_API void (luaL_openselectedlibs) (lua_State *L, int what);
LUALIB_API void (luaL_openselectedlibs) (lua_State *L, int load, int preload);
/* open all libraries */
#define luaL_openlibs(L) luaL_openselectedlibs(L, ~0)
#define luaL_openlibs(L) luaL_openselectedlibs(L, ~0, 0)
#endif