MCPcopy Create free account
hub / github.com/Overload-Technologies/Overload / loadlib

Function loadlib

Dependencies/lua/src/ltests.c:1172–1199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1170
1171
1172static int loadlib (lua_State *L) {
1173 static const luaL_Reg libs[] = {
1174 {LUA_GNAME, luaopen_base},
1175 {"coroutine", luaopen_coroutine},
1176 {"debug", luaopen_debug},
1177 {"io", luaopen_io},
1178 {"os", luaopen_os},
1179 {"math", luaopen_math},
1180 {"string", luaopen_string},
1181 {"table", luaopen_table},
1182 {"T", luaB_opentests},
1183 {NULL, NULL}
1184 };
1185 lua_State *L1 = getstate(L);
1186 int i;
1187 luaL_requiref(L1, "package", luaopen_package, 0);
1188 lua_assert(lua_type(L1, -1) == LUA_TTABLE);
1189 /* 'requiref' should not reload module already loaded... */
1190 luaL_requiref(L1, "package", NULL, 1); /* seg. fault if it reloads */
1191 /* ...but should return the same module */
1192 lua_assert(lua_compare(L1, -1, -2, LUA_OPEQ));
1193 luaL_getsubtable(L1, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE);
1194 for (i = 0; libs[i].name; i++) {
1195 lua_pushcfunction(L1, libs[i].func);
1196 lua_setfield(L1, -2, libs[i].name);
1197 }
1198 return 0;
1199}
1200
1201static int closestate (lua_State *L) {
1202 lua_State *L1 = getstate(L);

Callers

nothing calls this directly

Calls 6

getstateFunction · 0.85
lua_typeFunction · 0.85
lua_setfieldFunction · 0.85
luaL_requirefFunction · 0.70
lua_compareFunction · 0.70
luaL_getsubtableFunction · 0.70

Tested by

no test coverage detected