diff --git a/sol/state_view.hpp b/sol/state_view.hpp index a34b1608..d102ad7d 100644 --- a/sol/state_view.hpp +++ b/sol/state_view.hpp @@ -38,6 +38,8 @@ enum class lib : char { debug, bit32, io, + ffi, + jit, count }; @@ -108,6 +110,9 @@ public: #if SOL_LUA_VERSION > 501 luaL_requiref(L, "bit32", luaopen_bit32, 1); lua_pop(L, 1); +#elif defined(SOL_LUAJIT) + luaL_requiref(L, "bit32", luaopen_bit, 1); + lua_pop(L, 1); #else #endif // Lua 5.2+ only break; @@ -123,6 +128,16 @@ public: luaL_requiref(L, "debug", luaopen_debug, 1); lua_pop(L, 1); break; + case lib::ffi: +#ifdef SOL_LUAJIT + luaL_requiref(L, "ffi", luaopen_ffi, 1); +#endif + break; + case lib::jit: +#ifdef SOL_LUAJIT + luaL_requiref(L, "jit", luaopen_jit, 1); +#endif + break; case lib::count: default: break; diff --git a/tests.cpp b/tests.cpp index 0234312f..15814f2d 100644 --- a/tests.cpp +++ b/tests.cpp @@ -358,6 +358,21 @@ TEST_CASE("libraries", "Check if we can open libraries") { REQUIRE_NOTHROW(lua.open_libraries(sol::lib::base, sol::lib::os)); } +TEST_CASE("libraries2", "Check if we can open ALL the libraries") { + sol::state lua; + REQUIRE_NOTHROW(lua.open_libraries(sol::lib::base, + sol::lib::bit32, + sol::lib::coroutine, + sol::lib::debug, + sol::lib::ffi, + sol::lib::jit, + sol::lib::math, + sol::lib::os, + sol::lib::package, + sol::lib::string, + sol::lib::table)); +} + TEST_CASE("usertype/usertype", "Show that we can create classes from usertype and use them") { sol::state lua;