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

Function luaopen_package

third-party/lua-5.5.0/src/loadlib.c:724–747  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

722
723
724LUAMOD_API int luaopen_package (lua_State *L) {
725 luaL_getsubtable(L, LUA_REGISTRYINDEX, CLIBS); /* create CLIBS table */
726 lua_pop(L, 1); /* will not use it now */
727 luaL_newlib(L, pk_funcs); /* create 'package' table */
728 createsearcherstable(L);
729 /* set paths */
730 setpath(L, "path", LUA_PATH_VAR, LUA_PATH_DEFAULT);
731 setpath(L, "cpath", LUA_CPATH_VAR, LUA_CPATH_DEFAULT);
732 /* store config information */
733 lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATH_SEP "\n" LUA_PATH_MARK "\n"
734 LUA_EXEC_DIR "\n" LUA_IGMARK "\n");
735 lua_setfield(L, -2, "config");
736 /* set field 'loaded' */
737 luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE);
738 lua_setfield(L, -2, "loaded");
739 /* set field 'preload' */
740 luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE);
741 lua_setfield(L, -2, "preload");
742 lua_pushglobaltable(L);
743 lua_pushvalue(L, -2); /* set 'package' as upvalue for next lib */
744 luaL_setfuncs(L, ll_funcs, 1); /* open lib into global table */
745 lua_pop(L, 1); /* pop global table */
746 return 1; /* return 'package' table */
747}
748

Callers

nothing calls this directly

Calls 7

luaL_getsubtableFunction · 0.70
createsearcherstableFunction · 0.70
setpathFunction · 0.70
lua_setfieldFunction · 0.70
lua_pushvalueFunction · 0.70
luaL_setfuncsFunction · 0.70
lua_pushglobaltableFunction · 0.50

Tested by

no test coverage detected