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

Function luaopen_package

third-party/lua-5.3.5/src/loadlib.c:767–789  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

765
766
767LUAMOD_API int luaopen_package (lua_State *L) {
768 createclibstable(L);
769 luaL_newlib(L, pk_funcs); /* create 'package' table */
770 createsearcherstable(L);
771 /* set paths */
772 setpath(L, "path", LUA_PATH_VAR, LUA_PATH_DEFAULT);
773 setpath(L, "cpath", LUA_CPATH_VAR, LUA_CPATH_DEFAULT);
774 /* store config information */
775 lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATH_SEP "\n" LUA_PATH_MARK "\n"
776 LUA_EXEC_DIR "\n" LUA_IGMARK "\n");
777 lua_setfield(L, -2, "config");
778 /* set field 'loaded' */
779 luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE);
780 lua_setfield(L, -2, "loaded");
781 /* set field 'preload' */
782 luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE);
783 lua_setfield(L, -2, "preload");
784 lua_pushglobaltable(L);
785 lua_pushvalue(L, -2); /* set 'package' as upvalue for next lib */
786 luaL_setfuncs(L, ll_funcs, 1); /* open lib into global table */
787 lua_pop(L, 1); /* pop global table */
788 return 1; /* return 'package' table */
789}
790

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected