MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / luaopen_package

Function luaopen_package

3rd/lua-5.4.3/src/loadlib.c:739–761  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

737
738
739LUAMOD_API int luaopen_package (lua_State *L) {
740 createclibstable(L);
741 luaL_newlib(L, pk_funcs); /* create 'package' table */
742 createsearcherstable(L);
743 /* set paths */
744 setpath(L, "path", LUA_PATH_VAR, LUA_PATH_DEFAULT);
745 setpath(L, "cpath", LUA_CPATH_VAR, LUA_CPATH_DEFAULT);
746 /* store config information */
747 lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATH_SEP "\n" LUA_PATH_MARK "\n"
748 LUA_EXEC_DIR "\n" LUA_IGMARK "\n");
749 lua_setfield(L, -2, "config");
750 /* set field 'loaded' */
751 luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE);
752 lua_setfield(L, -2, "loaded");
753 /* set field 'preload' */
754 luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE);
755 lua_setfield(L, -2, "preload");
756 lua_pushglobaltable(L);
757 lua_pushvalue(L, -2); /* set 'package' as upvalue for next lib */
758 luaL_setfuncs(L, ll_funcs, 1); /* open lib into global table */
759 lua_pop(L, 1); /* pop global table */
760 return 1; /* return 'package' table */
761}
762

Callers

nothing calls this directly

Calls 7

createclibstableFunction · 0.85
createsearcherstableFunction · 0.85
setpathFunction · 0.85
lua_setfieldFunction · 0.85
luaL_getsubtableFunction · 0.85
lua_pushvalueFunction · 0.85
luaL_setfuncsFunction · 0.85

Tested by

no test coverage detected