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

Function luaL_pushmodule

third-party/lua-5.3.5/src/lauxlib.c:897–910  ·  view source on GitHub ↗

** Find or create a module table with a given name. The function ** first looks at the LOADED table and, if that fails, try a ** global variable with that name. In any case, leaves on the stack ** the module table. */

Source from the content-addressed store, hash-verified

895** the module table.
896*/
897LUALIB_API void luaL_pushmodule (lua_State *L, const char *modname,
898 int sizehint) {
899 luaL_findtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE, 1);
900 if (lua_getfield(L, -1, modname) != LUA_TTABLE) { /* no LOADED[modname]? */
901 lua_pop(L, 1); /* remove previous result */
902 /* try global variable (and create one if it does not exist) */
903 lua_pushglobaltable(L);
904 if (luaL_findtable(L, 0, modname, sizehint) != NULL)
905 luaL_error(L, "name conflict for module '%s'", modname);
906 lua_pushvalue(L, -1);
907 lua_setfield(L, -3, modname); /* LOADED[modname] = new table */
908 }
909 lua_remove(L, -2); /* remove LOADED table */
910}
911
912
913LUALIB_API void luaL_openlib (lua_State *L, const char *libname,

Callers 2

luaL_openlibFunction · 0.70
ll_moduleFunction · 0.70

Calls 7

luaL_findtableFunction · 0.70
lua_getfieldFunction · 0.70
luaL_errorFunction · 0.70
lua_pushvalueFunction · 0.70
lua_setfieldFunction · 0.70
lua_pushglobaltableFunction · 0.50
lua_removeFunction · 0.50

Tested by

no test coverage detected