From d2bff8aa39c98c4ebc904b836dcffbea3f7045bb Mon Sep 17 00:00:00 2001 From: bloodstalker Date: Sun, 31 Dec 2017 22:55:40 +0330 Subject: wip --- bruiser/executioner.h | 48 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 9 deletions(-) (limited to 'bruiser/executioner.h') diff --git a/bruiser/executioner.h b/bruiser/executioner.h index ed5009b..b881902 100644 --- a/bruiser/executioner.h +++ b/bruiser/executioner.h @@ -54,12 +54,45 @@ namespace { // start of anonymous namespace return 0; } - int LuaGenericWrapper(lua_State* __ls, XObject __x) { - int numargs = lua_gettop(__ls); - std::vector arg_vec; + std::vector arg_emitter(std::vector _args) {} - for (int i = 0; i < numargs; ++i) { - arg_vec.push_back(lua_tonumber(__ls, i + 1)); + int LuaXobjWrapper(lua_State* __ls) { + int numargs = lua_gettop(__ls); + std::vector arg_vec; + std::string xfuncname; + std::vector> arg_ptr; + std::vector> arg_str; + std::vector> arg_double; + std::vector> arg_bool; + + if (lua_type(__ls, 1) == LUA_TSTRING) { + xfuncname = lua_tostring(__ls, 1); + } else { + //PRINT_WITH_COLOR_LB(RED, "the first argument should be a string that is the name of the xfunc to be called."); + } + + // detecting arg types + for (int i = 2; i <= numargs; ++i) { + if (lua_type(__ls, i) == LUA_TBOOLEAN) { + arg_bool.push_back(std::make_pair(!!lua_tonumber(__ls, i), i)); + } + else if (lua_type(__ls, i) == LUA_TLIGHTUSERDATA) { + } + else if (lua_type(__ls, i) == LUA_TNUMBER) { + } + else if (lua_type(__ls, i) == LUA_TSTRING) { + } + else if (lua_type(__ls, i) == LUA_TTABLE) { + } + else if (lua_type(__ls, i) == LUA_TFUNCTION) { + } + else if (lua_type(__ls, i) == LUA_TUSERDATA) { + } + else if (lua_type(__ls, i) == LUA_TTHREAD) { + } + // type is Nil + else { + } } pid_t pid = fork(); @@ -69,7 +102,6 @@ namespace { // start of anonymous namespace } if (pid == 0) {} if (pid > 0) { - __x; } return 0; @@ -125,9 +157,7 @@ class Executioner { } void registerWithLua(lua_State* _lua_State) { - for (auto& iter : names) { - //lua_register(_lua_State, iter.c_str(), LuaGeneric); - } + lua_register(_lua_State, "xobjwrapper", LuaXobjWrapper); } void xobjsGetPtrs(void) { -- cgit v1.2.3