diff --git a/src/mouse-events.cc b/src/mouse-events.cc index 0f75b97db..6e861bf2f 100644 --- a/src/mouse-events.cc +++ b/src/mouse-events.cc @@ -24,32 +24,28 @@ #include #include #include +#include /* Lua helper functions */ -template -void push_table_value(lua_State *L, std::string key, T value); - void push_table_value(lua_State *L, std::string key, std::string value) { lua_pushstring(L, key.c_str()); lua_pushstring(L, value.c_str()); lua_settable(L, -3); } -void push_table_value(lua_State *L, std::string key, int value) { - lua_pushstring(L, key.c_str()); - lua_pushinteger(L, value); - lua_settable(L, -3); -} - -void push_table_value(lua_State *L, std::string key, uint32_t value) { - lua_pushstring(L, key.c_str()); - lua_pushinteger(L, value); - lua_settable(L, -3); +template +typename std::enable_if::value>::type +push_table_value(lua_State *L, std::string key, T value) { + lua_pushstring(L, key.c_str()); + lua_pushinteger(L, value); + lua_settable(L, -3); } -void push_table_value(lua_State *L, std::string key, uint64_t value) { +template +typename std::enable_if::value>::type +push_table_value(lua_State *L, std::string key, T value) { lua_pushstring(L, key.c_str()); - lua_pushinteger(L, value); + lua_pushnumber(L, value); lua_settable(L, -3); } @@ -59,18 +55,6 @@ void push_table_value(lua_State *L, std::string key, bool value) { lua_settable(L, -3); } -void push_table_value(lua_State *L, std::string key, float value) { - lua_pushstring(L, key.c_str()); - lua_pushnumber(L, value); - lua_settable(L, -3); -} - -void push_table_value(lua_State *L, std::string key, double value) { - lua_pushstring(L, key.c_str()); - lua_pushnumber(L, value); - lua_settable(L, -3); -} - template void push_bitset(lua_State *L, std::bitset it, std::array labels) { @@ -177,7 +161,7 @@ void mouse_event::push_lua_table(lua_State *L) const { void mouse_positioned_event::push_lua_data(lua_State *L) const { push_table_value(L, "x", this->x); - push_table_value(L, "y", this->y); + push_table_value(L, "y", this->y); push_table_value(L, "x_abs", this->x_abs); push_table_value(L, "y_abs", this->y_abs); }