diff options
Diffstat (limited to 'src/control/ScriptContext.hpp')
-rw-r--r-- | src/control/ScriptContext.hpp | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/src/control/ScriptContext.hpp b/src/control/ScriptContext.hpp index 9416d0e..13279ec 100644 --- a/src/control/ScriptContext.hpp +++ b/src/control/ScriptContext.hpp @@ -59,12 +59,32 @@ private: } template<typename... Args> - size_t pushArgs(Model::ScriptValue *v, Args ...args) { - if (v) - v->push(L); - else - lua_pushnil(L); + size_t pushArgs(std::nullptr_t __attribute__((unused)) v, Args ...args) { + lua_pushnil(L); + return pushArgs(args...) + 1; + } + + template<typename... Args> + size_t pushArgs(const std::string &v, Args ...args) { + lua_pushstring(L, v.c_str()); + return pushArgs(args...) + 1; + } + + template<typename T, typename... Args> + size_t pushArgs(T v, Args ...args) { + lua_pushnumber(L, v); + return pushArgs(args...) + 1; + } + template<typename... Args> + size_t pushArgs(bool v, Args ...args) { + lua_pushboolean(L, v); + return pushArgs(args...) + 1; + } + + template<typename... Args> + size_t pushArgs(Model::ScriptValue &v, Args ...args) { + v.push(L); return pushArgs(args...) + 1; } |