diff --git a/src/framework/luaengine/luainterface.h b/src/framework/luaengine/luainterface.h index 9e642641..25a0cf0f 100644 --- a/src/framework/luaengine/luainterface.h +++ b/src/framework/luaengine/luainterface.h @@ -189,7 +189,10 @@ public: int newSandboxEnv(); template - int callGlobalField(const std::string& global, const std::string& field, const T&... args); + int luaCallGlobalField(const std::string& global, const std::string& field, const T&... args); + + template + void callGlobalField(const std::string& global, const std::string& field, const T&... args); template R callGlobalField(const std::string& global, const std::string& field, const T&... args); @@ -425,7 +428,7 @@ T LuaInterface::castValue(int index) { } template -int LuaInterface::callGlobalField(const std::string& global, const std::string& field, const T&... args) { +int LuaInterface::luaCallGlobalField(const std::string& global, const std::string& field, const T&... args) { g_lua.getGlobalField(global, field); if(!g_lua.isNil()) { int numArgs = g_lua.polymorphicPush(args...); @@ -435,10 +438,17 @@ int LuaInterface::callGlobalField(const std::string& global, const std::string& return 0; } +template +void LuaInterface::callGlobalField(const std::string& global, const std::string& field, const T&... args) { + int rets = luaCallGlobalField(global, field, args...); + if(rets > 0) + pop(rets); +} + template R LuaInterface::callGlobalField(const std::string& global, const std::string& field, const T&... args) { R result; - int rets = callGlobalField(global, field, args...); + int rets = luaCallGlobalField(global, field, args...); if(rets > 0) { assert(rets == 1); result = g_lua.polymorphicPop(); diff --git a/src/framework/luaengine/luaobject.h b/src/framework/luaengine/luaobject.h index b7689498..f6e588bf 100644 --- a/src/framework/luaengine/luaobject.h +++ b/src/framework/luaengine/luaobject.h @@ -40,7 +40,7 @@ public: /// if any lua error occurs, it will be reported to stdout and return 0 results /// @return the number of results template - int luaCallField(const std::string& field, const T&... args); + int luaCallLuaField(const std::string& field, const T&... args); template R callLuaField(const std::string& field, const T&... args); @@ -149,7 +149,7 @@ connect(const LuaObjectPtr& obj, const std::string& field, const Lambda& f, bool } template -int LuaObject::luaCallField(const std::string& field, const T&... args) { +int LuaObject::luaCallLuaField(const std::string& field, const T&... args) { // note that the field must be retrieved from this object lua value // to force using the __index metamethod of it's metatable // so cannot use LuaObject::getField here @@ -171,7 +171,7 @@ int LuaObject::luaCallField(const std::string& field, const T&... args) { template R LuaObject::callLuaField(const std::string& field, const T&... args) { R result; - int rets = luaCallField(field, args...); + int rets = luaCallLuaField(field, args...); if(rets > 0) { assert(rets == 1); result = g_lua.polymorphicPop(); @@ -182,7 +182,7 @@ R LuaObject::callLuaField(const std::string& field, const T&... args) { template void LuaObject::callLuaField(const std::string& field, const T&... args) { - int rets = luaCallField(field, args...); + int rets = luaCallLuaField(field, args...); if(rets > 0) g_lua.pop(rets); }