diff --git a/include/omath/lua/lua.hpp b/include/omath/lua/lua.hpp index 8fd9f46..91a043f 100644 --- a/include/omath/lua/lua.hpp +++ b/include/omath/lua/lua.hpp @@ -6,15 +6,18 @@ #include namespace omath::lua { - void register_lib(lua_State* lua_state); -} -namespace omath::lua::detail -{ - void register_vec2(sol::table& omath_table); - void register_vec3(sol::table& omath_table); - void register_vec4(sol::table& omath_table); - void register_color(sol::table& omath_table); - void register_shared_types(sol::table& omath_table); - void register_engines(sol::table& omath_table); + class LuaInterpreter final + { + public: + static void register_lib(lua_State* lua_state); + + private: + static void register_vec2(sol::table& omath_table); + static void register_vec3(sol::table& omath_table); + static void register_vec4(sol::table& omath_table); + static void register_color(sol::table& omath_table); + static void register_shared_types(sol::table& omath_table); + static void register_engines(sol::table& omath_table); + }; } #endif \ No newline at end of file diff --git a/source/lua/lua.cpp b/source/lua/lua.cpp index b1258ce..c1e173e 100644 --- a/source/lua/lua.cpp +++ b/source/lua/lua.cpp @@ -8,18 +8,18 @@ namespace omath::lua { - void register_lib(lua_State* lua_state) + void LuaInterpreter::register_lib(lua_State* lua_state) { sol::state_view lua(lua_state); auto omath_table = lua["omath"].get_or_create(); - detail::register_vec2(omath_table); - detail::register_vec3(omath_table); - detail::register_vec4(omath_table); - detail::register_color(omath_table); - detail::register_shared_types(omath_table); - detail::register_engines(omath_table); + register_vec2(omath_table); + register_vec3(omath_table); + register_vec4(omath_table); + register_color(omath_table); + register_shared_types(omath_table); + register_engines(omath_table); } } // namespace omath::lua #endif diff --git a/source/lua/lua_color.cpp b/source/lua/lua_color.cpp index d07c179..8e84fda 100644 --- a/source/lua/lua_color.cpp +++ b/source/lua/lua_color.cpp @@ -6,9 +6,9 @@ #include #include -namespace omath::lua::detail +namespace omath::lua { - void register_color(sol::table& omath_table) + void LuaInterpreter::register_color(sol::table& omath_table) { omath_table.new_usertype( "Color", diff --git a/source/lua/lua_engines.cpp b/source/lua/lua_engines.cpp index db8200b..19995dd 100644 --- a/source/lua/lua_engines.cpp +++ b/source/lua/lua_engines.cpp @@ -2,7 +2,7 @@ // Created by orange on 07.03.2026. // #ifdef OMATH_ENABLE_LUA -#include +#include "omath/lua/lua.hpp" #include #include #include @@ -17,6 +17,7 @@ #include #include #include +#include #include namespace @@ -172,9 +173,9 @@ namespace }; } // namespace -namespace omath::lua::detail +namespace omath::lua { - void register_shared_types(sol::table& omath_table) + void LuaInterpreter::register_shared_types(sol::table& omath_table) { auto t = omath_table["_types"].get_or_create(); @@ -219,7 +220,7 @@ namespace omath::lua::detail [](ViewAngles89& va, const SharedYawRoll& val) { va.roll = val; })); } - void register_engines(sol::table& omath_table) + void LuaInterpreter::register_engines(sol::table& omath_table) { register_engine(omath_table, "opengl"); register_engine(omath_table, "frostbite"); diff --git a/source/lua/lua_vec2.cpp b/source/lua/lua_vec2.cpp index fc5c146..e419621 100644 --- a/source/lua/lua_vec2.cpp +++ b/source/lua/lua_vec2.cpp @@ -2,12 +2,13 @@ // Created by orange on 07.03.2026. // #ifdef OMATH_ENABLE_LUA -#include +#include "omath/lua/lua.hpp" #include +#include -namespace omath::lua::detail +namespace omath::lua { - void register_vec2(sol::table& omath_table) + void LuaInterpreter::register_vec2(sol::table& omath_table) { using Vec2f = omath::Vector2; diff --git a/source/lua/lua_vec3.cpp b/source/lua/lua_vec3.cpp index 5ddc97e..1edb4e8 100644 --- a/source/lua/lua_vec3.cpp +++ b/source/lua/lua_vec3.cpp @@ -6,9 +6,9 @@ #include #include -namespace omath::lua::detail +namespace omath::lua { - void register_vec3(sol::table& omath_table) + void LuaInterpreter::register_vec3(sol::table& omath_table) { using Vec3f = omath::Vector3; diff --git a/source/lua/lua_vec4.cpp b/source/lua/lua_vec4.cpp index af9637f..dfa8b97 100644 --- a/source/lua/lua_vec4.cpp +++ b/source/lua/lua_vec4.cpp @@ -6,9 +6,9 @@ #include #include -namespace omath::lua::detail +namespace omath::lua { - void register_vec4(sol::table& omath_table) + void LuaInterpreter::register_vec4(sol::table& omath_table) { using Vec4f = omath::Vector4; diff --git a/tests/lua/unit_test_lua_color.cpp b/tests/lua/unit_test_lua_color.cpp index ae52419..1397b5e 100644 --- a/tests/lua/unit_test_lua_color.cpp +++ b/tests/lua/unit_test_lua_color.cpp @@ -14,7 +14,7 @@ protected: { L = luaL_newstate(); luaL_openlibs(L); - omath::lua::register_lib(L); + omath::lua::LuaInterpreter::register_lib(L); if (luaL_dofile(L, LUA_SCRIPTS_DIR "/color_tests.lua") != LUA_OK) FAIL() << lua_tostring(L, -1); } diff --git a/tests/lua/unit_test_lua_source_engine.cpp b/tests/lua/unit_test_lua_source_engine.cpp index ef494bd..102644c 100644 --- a/tests/lua/unit_test_lua_source_engine.cpp +++ b/tests/lua/unit_test_lua_source_engine.cpp @@ -14,7 +14,7 @@ protected: { L = luaL_newstate(); luaL_openlibs(L); - omath::lua::register_lib(L); + omath::lua::LuaInterpreter::register_lib(L); if (luaL_dofile(L, LUA_SCRIPTS_DIR "/source_engine_tests.lua") != LUA_OK) FAIL() << lua_tostring(L, -1); } diff --git a/tests/lua/unit_test_lua_vector2.cpp b/tests/lua/unit_test_lua_vector2.cpp index 549caa3..929cb20 100644 --- a/tests/lua/unit_test_lua_vector2.cpp +++ b/tests/lua/unit_test_lua_vector2.cpp @@ -14,7 +14,7 @@ protected: { L = luaL_newstate(); luaL_openlibs(L); - omath::lua::register_lib(L); + omath::lua::LuaInterpreter::register_lib(L); if (luaL_dofile(L, LUA_SCRIPTS_DIR "/vec2_tests.lua") != LUA_OK) FAIL() << lua_tostring(L, -1); } diff --git a/tests/lua/unit_test_lua_vector3.cpp b/tests/lua/unit_test_lua_vector3.cpp index b514596..a214865 100644 --- a/tests/lua/unit_test_lua_vector3.cpp +++ b/tests/lua/unit_test_lua_vector3.cpp @@ -14,7 +14,7 @@ protected: { L = luaL_newstate(); luaL_openlibs(L); - omath::lua::register_lib(L); + omath::lua::LuaInterpreter::register_lib(L); if (luaL_dofile(L, LUA_SCRIPTS_DIR "/vec3_tests.lua") != LUA_OK) FAIL() << lua_tostring(L, -1); } diff --git a/tests/lua/unit_test_lua_vector4.cpp b/tests/lua/unit_test_lua_vector4.cpp index 93e532c..5d07359 100644 --- a/tests/lua/unit_test_lua_vector4.cpp +++ b/tests/lua/unit_test_lua_vector4.cpp @@ -14,7 +14,7 @@ protected: { L = luaL_newstate(); luaL_openlibs(L); - omath::lua::register_lib(L); + omath::lua::LuaInterpreter::register_lib(L); if (luaL_dofile(L, LUA_SCRIPTS_DIR "/vec4_tests.lua") != LUA_OK) FAIL() << lua_tostring(L, -1); }