| 24357 | |
| 24358 | template <typename... Args> |
| 24359 | void open_libraries(Args&&... args) { |
| 24360 | static_assert(meta::all_same<lib, meta::unqualified_t<Args>...>::value, "all types must be libraries"); |
| 24361 | if constexpr (sizeof...(args) == 0) { |
| 24362 | luaL_openlibs(L); |
| 24363 | return; |
| 24364 | } |
| 24365 | else { |
| 24366 | lib libraries[1 + sizeof...(args)] = { lib::count, std::forward<Args>(args)... }; |
| 24367 | |
| 24368 | for (auto&& library : libraries) { |
| 24369 | switch (library) { |
| 24370 | #if SOL_LUA_VERSION <= 501 && defined(SOL_LUAJIT) |
| 24371 | case lib::coroutine: |
| 24372 | #endif // luajit opens coroutine base stuff |
| 24373 | case lib::base: |
| 24374 | luaL_requiref(L, "base", luaopen_base, 1); |
| 24375 | lua_pop(L, 1); |
| 24376 | break; |
| 24377 | case lib::package: |
| 24378 | luaL_requiref(L, "package", luaopen_package, 1); |
| 24379 | lua_pop(L, 1); |
| 24380 | break; |
| 24381 | #if !defined(SOL_LUAJIT) |
| 24382 | case lib::coroutine: |
| 24383 | #if SOL_LUA_VERSION > 501 |
| 24384 | luaL_requiref(L, "coroutine", luaopen_coroutine, 1); |
| 24385 | lua_pop(L, 1); |
| 24386 | #endif // Lua 5.2+ only |
| 24387 | break; |
| 24388 | #endif // Not LuaJIT - comes builtin |
| 24389 | case lib::string: |
| 24390 | luaL_requiref(L, "string", luaopen_string, 1); |
| 24391 | lua_pop(L, 1); |
| 24392 | break; |
| 24393 | case lib::table: |
| 24394 | luaL_requiref(L, "table", luaopen_table, 1); |
| 24395 | lua_pop(L, 1); |
| 24396 | break; |
| 24397 | case lib::math: |
| 24398 | luaL_requiref(L, "math", luaopen_math, 1); |
| 24399 | lua_pop(L, 1); |
| 24400 | break; |
| 24401 | case lib::bit32: |
| 24402 | #ifdef SOL_LUAJIT |
| 24403 | luaL_requiref(L, "bit32", luaopen_bit, 1); |
| 24404 | lua_pop(L, 1); |
| 24405 | #elif (SOL_LUA_VERSION == 502) || defined(LUA_COMPAT_BITLIB) || defined(LUA_COMPAT_5_2) |
| 24406 | luaL_requiref(L, "bit32", luaopen_bit32, 1); |
| 24407 | lua_pop(L, 1); |
| 24408 | #else |
| 24409 | #endif // Lua 5.2 only (deprecated in 5.3 (503)) (Can be turned on with Compat flags) |
| 24410 | break; |
| 24411 | case lib::io: |
| 24412 | luaL_requiref(L, "io", luaopen_io, 1); |
| 24413 | lua_pop(L, 1); |
| 24414 | break; |
| 24415 | case lib::os: |
| 24416 | luaL_requiref(L, "os", luaopen_os, 1); |
no test coverage detected