MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / luaL_openselectedlibs

Function luaL_openselectedlibs

third-party/lua-5.5.0/src/linit.c:46–62  ·  view source on GitHub ↗

** require and preload selected standard libraries */

Source from the content-addressed store, hash-verified

44** require and preload selected standard libraries
45*/
46LUALIB_API void luaL_openselectedlibs (lua_State *L, int load, int preload) {
47 int mask;
48 const luaL_Reg *lib;
49 luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE);
50 for (lib = stdlibs, mask = 1; lib->name != NULL; lib++, mask <<= 1) {
51 if (load & mask) { /* selected? */
52 luaL_requiref(L, lib->name, lib->func, 1); /* require library */
53 lua_pop(L, 1); /* remove result from the stack */
54 }
55 else if (preload & mask) { /* selected? */
56 lua_pushcfunction(L, lib->func);
57 lua_setfield(L, -2, lib->name); /* add library to PRELOAD table */
58 }
59 }
60 lua_assert((mask >> 1) == LUA_UTF8LIBK);
61 lua_pop(L, 1); /* remove PRELOAD table */
62}
63

Callers

nothing calls this directly

Calls 3

luaL_getsubtableFunction · 0.70
luaL_requirefFunction · 0.70
lua_setfieldFunction · 0.70

Tested by

no test coverage detected