MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / luaopen_package

Function luaopen_package

lib/lua/src/loadlib.c:735–757  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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