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

Function luaL_pushmodule

third-party/lua-5.2.4/src/lauxlib.c:810–824  ·  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

808** the module table.
809*/
810LUALIB_API void luaL_pushmodule (lua_State *L, const char *modname,
811 int sizehint) {
812 luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1); /* get _LOADED table */
813 lua_getfield(L, -1, modname); /* get _LOADED[modname] */
814 if (!lua_istable(L, -1)) { /* not found? */
815 lua_pop(L, 1); /* remove previous result */
816 /* try global variable (and create one if it does not exist) */
817 lua_pushglobaltable(L);
818 if (luaL_findtable(L, 0, modname, sizehint) != NULL)
819 luaL_error(L, "name conflict for module " LUA_QS, modname);
820 lua_pushvalue(L, -1);
821 lua_setfield(L, -3, modname); /* _LOADED[modname] = new table */
822 }
823 lua_remove(L, -2); /* remove _LOADED table */
824}
825
826
827LUALIB_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_removeFunction · 0.70
lua_pushglobaltableFunction · 0.50

Tested by

no test coverage detected