** require and preload selected standard libraries */
| 44 | ** require and preload selected standard libraries |
| 45 | */ |
| 46 | LUALIB_API void luaL_openselectedlibs (lua_State *L, int load, int preload) { |
| 47 | int mask; |
| 48 | const luaL_Reg *lib; |
| 49 | luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE); |
| 50 | for (lib = stdlibs, mask = 1; lib->name != NULL; lib++, mask <<= 1) { |
| 51 | if (load & mask) { /* selected? */ |
| 52 | luaL_requiref(L, lib->name, lib->func, 1); /* require library */ |
| 53 | lua_pop(L, 1); /* remove result from the stack */ |
| 54 | } |
| 55 | else if (preload & mask) { /* selected? */ |
| 56 | lua_pushcfunction(L, lib->func); |
| 57 | lua_setfield(L, -2, lib->name); /* add library to PRELOAD table */ |
| 58 | } |
| 59 | } |
| 60 | lua_assert((mask >> 1) == LUA_UTF8LIBK); |
| 61 | lua_pop(L, 1); /* remove PRELOAD table */ |
| 62 | } |
| 63 |
nothing calls this directly
no test coverage detected