mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-02-04 21:18:33 +00:00
Use SFINAE to collapse numeric pust_table_value impls
Signed-off-by: Tin <tin.svagelj@live.com>
This commit is contained in:
parent
b5652006ef
commit
c4ef5f5e8c
@ -24,32 +24,28 @@
|
||||
#include <string>
|
||||
#include <lua.h>
|
||||
#include <time.h>
|
||||
#include <type_traits>
|
||||
|
||||
/* Lua helper functions */
|
||||
template <typename T>
|
||||
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);
|
||||
template <typename T>
|
||||
typename std::enable_if<std::is_integral<T>::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, uint32_t value) {
|
||||
template <typename T>
|
||||
typename std::enable_if<std::is_floating_point<T>::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) {
|
||||
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 <size_t N>
|
||||
void push_bitset(lua_State *L, std::bitset<N> it,
|
||||
std::array<std::string, N> labels) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user