diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-01-10 16:58:29 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-01-10 16:59:07 +1100 |
| commit | 1b2d791a05954fd161376e3ddce0d44f74fcc6c0 (patch) | |
| tree | acf97e17272d86c5d8b16247baf2f8e220126dd5 /src | |
| parent | abdc00fd2dbe013bffe8a303fe899e209006f7ce (diff) | |
| download | tangara-fw-1b2d791a05954fd161376e3ddce0d44f74fcc6c0.tar.gz | |
Use doubles instead of floats for lua numbers (this unpins the ui task)
Diffstat (limited to 'src')
| -rw-r--r-- | src/lua/include/property.hpp | 2 | ||||
| -rw-r--r-- | src/lua/property.cpp | 5 |
2 files changed, 3 insertions, 4 deletions
diff --git a/src/lua/include/property.hpp b/src/lua/include/property.hpp index c1dcf44b..a8a88125 100644 --- a/src/lua/include/property.hpp +++ b/src/lua/include/property.hpp @@ -17,7 +17,7 @@ namespace lua { using LuaValue = - std::variant<std::monostate, int, float, bool, std::string, audio::Track>; + std::variant<std::monostate, int, bool, std::string, audio::Track>; using LuaFunction = std::function<int(lua_State*)>; class Property { diff --git a/src/lua/property.cpp b/src/lua/property.cpp index 7a45552b..89351579 100644 --- a/src/lua/property.cpp +++ b/src/lua/property.cpp @@ -7,6 +7,7 @@ #include "property.hpp" #include <sys/_stdint.h> +#include <cmath> #include <memory> #include <string> @@ -192,8 +193,6 @@ auto Property::PushValue(lua_State& s) -> int { lua_pushnil(&s); } else if constexpr (std::is_same_v<T, int>) { lua_pushinteger(&s, arg); - } else if constexpr (std::is_same_v<T, float>) { - lua_pushnumber(&s, arg); } else if constexpr (std::is_same_v<T, bool>) { lua_pushboolean(&s, arg); } else if constexpr (std::is_same_v<T, std::string>) { @@ -241,7 +240,7 @@ auto Property::PopValue(lua_State& s) -> bool { if (lua_isinteger(&s, 2)) { new_val = lua_tointeger(&s, 2); } else { - new_val = lua_tonumber(&s, 2); + new_val = static_cast<lua_Integer>(std::round(lua_tonumber(&s, 2))); } break; case LUA_TBOOLEAN: |
