Use doubles instead of floats for lua numbers (this unpins the ui task)

custom
jacqueline 1 year ago
parent abdc00fd2d
commit 1b2d791a05
  1. 4
      lib/esp-idf-lua/lua/luaconf.h
  2. 2
      src/lua/include/property.hpp
  3. 5
      src/lua/property.cpp

@ -118,14 +118,14 @@
/* Default configuration ('long long' and 'double', for 64-bit Lua) */ /* Default configuration ('long long' and 'double', for 64-bit Lua) */
#define LUA_INT_DEFAULT LUA_INT_LONGLONG #define LUA_INT_DEFAULT LUA_INT_LONG
#define LUA_FLOAT_DEFAULT LUA_FLOAT_DOUBLE #define LUA_FLOAT_DEFAULT LUA_FLOAT_DOUBLE
/* /*
@@ LUA_32BITS enables Lua with 32-bit integers and 32-bit floats. @@ LUA_32BITS enables Lua with 32-bit integers and 32-bit floats.
*/ */
#define LUA_32BITS 1 #define LUA_32BITS 0
/* /*

@ -17,7 +17,7 @@
namespace lua { namespace lua {
using LuaValue = 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*)>; using LuaFunction = std::function<int(lua_State*)>;
class Property { class Property {

@ -7,6 +7,7 @@
#include "property.hpp" #include "property.hpp"
#include <sys/_stdint.h> #include <sys/_stdint.h>
#include <cmath>
#include <memory> #include <memory>
#include <string> #include <string>
@ -192,8 +193,6 @@ auto Property::PushValue(lua_State& s) -> int {
lua_pushnil(&s); lua_pushnil(&s);
} else if constexpr (std::is_same_v<T, int>) { } else if constexpr (std::is_same_v<T, int>) {
lua_pushinteger(&s, arg); 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>) { } else if constexpr (std::is_same_v<T, bool>) {
lua_pushboolean(&s, arg); lua_pushboolean(&s, arg);
} else if constexpr (std::is_same_v<T, std::string>) { } 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)) { if (lua_isinteger(&s, 2)) {
new_val = lua_tointeger(&s, 2); new_val = lua_tointeger(&s, 2);
} else { } else {
new_val = lua_tonumber(&s, 2); new_val = static_cast<lua_Integer>(std::round(lua_tonumber(&s, 2)));
} }
break; break;
case LUA_TBOOLEAN: case LUA_TBOOLEAN:

Loading…
Cancel
Save