MCPcopy Create free account
hub / github.com/PlutoLang/Pluto / luaopen_package

Function luaopen_package

src/loadlib.cpp:775–800  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

773
774
775LUAMOD_API int luaopen_package (lua_State *L) {
776 luaL_getsubtable(L, LUA_REGISTRYINDEX, CLIBS); /* create CLIBS table */
777 lua_pop(L, 1); /* will not use it now */
778 luaL_newlib(L, pk_funcs); /* create 'package' table */
779 createsearcherstable(L);
780 /* set paths */
781 setpath(L, "path", LUA_PATH_VAR, LUA_PATH_DEFAULT);
782#ifndef PLUTO_NO_BINARIES
783 setpath(L, "cpath", LUA_CPATH_VAR, LUA_CPATH_DEFAULT);
784#endif
785 /* store config information */
786 lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATH_SEP "\n" LUA_PATH_MARK "\n"
787 LUA_EXEC_DIR "\n" LUA_IGMARK "\n");
788 lua_setfield(L, -2, "config");
789 /* set field 'loaded' */
790 luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE);
791 lua_setfield(L, -2, "loaded");
792 /* set field 'preload' */
793 luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE);
794 lua_setfield(L, -2, "preload");
795 lua_pushglobaltable(L);
796 lua_pushvalue(L, -2); /* set 'package' as upvalue for next lib */
797 luaL_setfuncs(L, ll_funcs, 1); /* open lib into global table */
798 lua_pop(L, 1); /* pop global table */
799 return 1; /* return 'package' table */
800}
801

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected