MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / luaopen_package

Function luaopen_package

extlibs/lua/src/loadlib.c:731–753  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected