| 50 | |
| 51 | |
| 52 | LUALIB_API void luaL_openlibs (lua_State *L) { |
| 53 | const luaL_Reg *lib; |
| 54 | /* call open functions from 'loadedlibs' and set results to global table */ |
| 55 | for (lib = loadedlibs; lib->func; lib++) { |
| 56 | luaL_requiref(L, lib->name, lib->func, 1); |
| 57 | lua_pop(L, 1); /* remove lib */ |
| 58 | } |
| 59 | /* add open functions from 'preloadedlibs' into 'package.preload' table */ |
| 60 | luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD"); |
| 61 | for (lib = preloadedlibs; lib->func; lib++) { |
| 62 | lua_pushcfunction(L, lib->func); |
| 63 | lua_setfield(L, -2, lib->name); |
| 64 | } |
| 65 | lua_pop(L, 1); /* remove _PRELOAD table */ |
| 66 | } |
| 67 |
no test coverage detected