mirror of
https://github.com/orange-cpp/omath.git
synced 2026-04-19 18:43:26 +00:00
refactored to class
This commit is contained in:
@@ -6,15 +6,18 @@
|
|||||||
#include <sol/forward.hpp>
|
#include <sol/forward.hpp>
|
||||||
namespace omath::lua
|
namespace omath::lua
|
||||||
{
|
{
|
||||||
void register_lib(lua_State* lua_state);
|
class LuaInterpreter final
|
||||||
}
|
|
||||||
namespace omath::lua::detail
|
|
||||||
{
|
{
|
||||||
void register_vec2(sol::table& omath_table);
|
public:
|
||||||
void register_vec3(sol::table& omath_table);
|
static void register_lib(lua_State* lua_state);
|
||||||
void register_vec4(sol::table& omath_table);
|
|
||||||
void register_color(sol::table& omath_table);
|
private:
|
||||||
void register_shared_types(sol::table& omath_table);
|
static void register_vec2(sol::table& omath_table);
|
||||||
void register_engines(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
|
#endif
|
||||||
@@ -8,18 +8,18 @@
|
|||||||
|
|
||||||
namespace omath::lua
|
namespace omath::lua
|
||||||
{
|
{
|
||||||
void register_lib(lua_State* lua_state)
|
void LuaInterpreter::register_lib(lua_State* lua_state)
|
||||||
{
|
{
|
||||||
sol::state_view lua(lua_state);
|
sol::state_view lua(lua_state);
|
||||||
|
|
||||||
auto omath_table = lua["omath"].get_or_create<sol::table>();
|
auto omath_table = lua["omath"].get_or_create<sol::table>();
|
||||||
|
|
||||||
detail::register_vec2(omath_table);
|
register_vec2(omath_table);
|
||||||
detail::register_vec3(omath_table);
|
register_vec3(omath_table);
|
||||||
detail::register_vec4(omath_table);
|
register_vec4(omath_table);
|
||||||
detail::register_color(omath_table);
|
register_color(omath_table);
|
||||||
detail::register_shared_types(omath_table);
|
register_shared_types(omath_table);
|
||||||
detail::register_engines(omath_table);
|
register_engines(omath_table);
|
||||||
}
|
}
|
||||||
} // namespace omath::lua
|
} // namespace omath::lua
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
#include <sol/sol.hpp>
|
#include <sol/sol.hpp>
|
||||||
#include <omath/utility/color.hpp>
|
#include <omath/utility/color.hpp>
|
||||||
|
|
||||||
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<omath::Color>(
|
omath_table.new_usertype<omath::Color>(
|
||||||
"Color",
|
"Color",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Created by orange on 07.03.2026.
|
// Created by orange on 07.03.2026.
|
||||||
//
|
//
|
||||||
#ifdef OMATH_ENABLE_LUA
|
#ifdef OMATH_ENABLE_LUA
|
||||||
#include <sol/sol.hpp>
|
#include "omath/lua/lua.hpp"
|
||||||
#include <omath/engines/cry_engine/camera.hpp>
|
#include <omath/engines/cry_engine/camera.hpp>
|
||||||
#include <omath/engines/cry_engine/constants.hpp>
|
#include <omath/engines/cry_engine/constants.hpp>
|
||||||
#include <omath/engines/frostbite_engine/camera.hpp>
|
#include <omath/engines/frostbite_engine/camera.hpp>
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
#include <omath/engines/unity_engine/constants.hpp>
|
#include <omath/engines/unity_engine/constants.hpp>
|
||||||
#include <omath/engines/unreal_engine/camera.hpp>
|
#include <omath/engines/unreal_engine/camera.hpp>
|
||||||
#include <omath/engines/unreal_engine/constants.hpp>
|
#include <omath/engines/unreal_engine/constants.hpp>
|
||||||
|
#include <sol/sol.hpp>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
@@ -172,9 +173,9 @@ namespace
|
|||||||
};
|
};
|
||||||
} // 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<sol::table>();
|
auto t = omath_table["_types"].get_or_create<sol::table>();
|
||||||
|
|
||||||
@@ -219,7 +220,7 @@ namespace omath::lua::detail
|
|||||||
[](ViewAngles89& va, const SharedYawRoll& val) { va.roll = val; }));
|
[](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<OpenGLEngineTraits>(omath_table, "opengl");
|
register_engine<OpenGLEngineTraits>(omath_table, "opengl");
|
||||||
register_engine<FrostbiteEngineTraits>(omath_table, "frostbite");
|
register_engine<FrostbiteEngineTraits>(omath_table, "frostbite");
|
||||||
|
|||||||
@@ -2,12 +2,13 @@
|
|||||||
// Created by orange on 07.03.2026.
|
// Created by orange on 07.03.2026.
|
||||||
//
|
//
|
||||||
#ifdef OMATH_ENABLE_LUA
|
#ifdef OMATH_ENABLE_LUA
|
||||||
#include <sol/sol.hpp>
|
#include "omath/lua/lua.hpp"
|
||||||
#include <omath/linear_algebra/vector2.hpp>
|
#include <omath/linear_algebra/vector2.hpp>
|
||||||
|
#include <sol/sol.hpp>
|
||||||
|
|
||||||
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<float>;
|
using Vec2f = omath::Vector2<float>;
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
#include <sol/sol.hpp>
|
#include <sol/sol.hpp>
|
||||||
#include <omath/linear_algebra/vector3.hpp>
|
#include <omath/linear_algebra/vector3.hpp>
|
||||||
|
|
||||||
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<float>;
|
using Vec3f = omath::Vector3<float>;
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
#include <sol/sol.hpp>
|
#include <sol/sol.hpp>
|
||||||
#include <omath/linear_algebra/vector4.hpp>
|
#include <omath/linear_algebra/vector4.hpp>
|
||||||
|
|
||||||
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<float>;
|
using Vec4f = omath::Vector4<float>;
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ protected:
|
|||||||
{
|
{
|
||||||
L = luaL_newstate();
|
L = luaL_newstate();
|
||||||
luaL_openlibs(L);
|
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)
|
if (luaL_dofile(L, LUA_SCRIPTS_DIR "/color_tests.lua") != LUA_OK)
|
||||||
FAIL() << lua_tostring(L, -1);
|
FAIL() << lua_tostring(L, -1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ protected:
|
|||||||
{
|
{
|
||||||
L = luaL_newstate();
|
L = luaL_newstate();
|
||||||
luaL_openlibs(L);
|
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)
|
if (luaL_dofile(L, LUA_SCRIPTS_DIR "/source_engine_tests.lua") != LUA_OK)
|
||||||
FAIL() << lua_tostring(L, -1);
|
FAIL() << lua_tostring(L, -1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ protected:
|
|||||||
{
|
{
|
||||||
L = luaL_newstate();
|
L = luaL_newstate();
|
||||||
luaL_openlibs(L);
|
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)
|
if (luaL_dofile(L, LUA_SCRIPTS_DIR "/vec2_tests.lua") != LUA_OK)
|
||||||
FAIL() << lua_tostring(L, -1);
|
FAIL() << lua_tostring(L, -1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ protected:
|
|||||||
{
|
{
|
||||||
L = luaL_newstate();
|
L = luaL_newstate();
|
||||||
luaL_openlibs(L);
|
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)
|
if (luaL_dofile(L, LUA_SCRIPTS_DIR "/vec3_tests.lua") != LUA_OK)
|
||||||
FAIL() << lua_tostring(L, -1);
|
FAIL() << lua_tostring(L, -1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ protected:
|
|||||||
{
|
{
|
||||||
L = luaL_newstate();
|
L = luaL_newstate();
|
||||||
luaL_openlibs(L);
|
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)
|
if (luaL_dofile(L, LUA_SCRIPTS_DIR "/vec4_tests.lua") != LUA_OK)
|
||||||
FAIL() << lua_tostring(L, -1);
|
FAIL() << lua_tostring(L, -1);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user