diff options
author | Mattes D <github@xoft.cz> | 2016-08-16 14:05:03 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2016-08-22 20:10:48 +0200 |
commit | 11682d1386299d78bab39f77884797981950edee (patch) | |
tree | 370699cd4ec1ff5905d970005162c8be3aa275dd /src/Bindings | |
parent | cLuaState: Added direct support for pushing a nil constant. (diff) | |
download | cuberite-11682d1386299d78bab39f77884797981950edee.tar cuberite-11682d1386299d78bab39f77884797981950edee.tar.gz cuberite-11682d1386299d78bab39f77884797981950edee.tar.bz2 cuberite-11682d1386299d78bab39f77884797981950edee.tar.lz cuberite-11682d1386299d78bab39f77884797981950edee.tar.xz cuberite-11682d1386299d78bab39f77884797981950edee.tar.zst cuberite-11682d1386299d78bab39f77884797981950edee.zip |
Diffstat (limited to 'src/Bindings')
-rw-r--r-- | src/Bindings/BindingsProcessor.lua | 1 | ||||
-rw-r--r-- | src/Bindings/LuaState.cpp | 27 | ||||
-rw-r--r-- | src/Bindings/LuaState.h | 2 |
3 files changed, 2 insertions, 28 deletions
diff --git a/src/Bindings/BindingsProcessor.lua b/src/Bindings/BindingsProcessor.lua index f936d3a68..df479a634 100644 --- a/src/Bindings/BindingsProcessor.lua +++ b/src/Bindings/BindingsProcessor.lua @@ -234,7 +234,6 @@ local function OutputLuaStateHelpers(a_Package) if not(g_HasCustomPushImplementation[item.name]) then f:write("void cLuaState::Push(" .. item.name .. " * a_Value)\n{\n\tASSERT(IsValid());\n") f:write("\ttolua_pushusertype(m_LuaState, a_Value, \"" .. item.name .. "\");\n"); - f:write("\tm_NumCurrentFunctionArgs += 1;\n") f:write("}\n\n\n\n\n\n") end end diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp index 2e1415519..ec6bdb48a 100644 --- a/src/Bindings/LuaState.cpp +++ b/src/Bindings/LuaState.cpp @@ -757,7 +757,6 @@ void cLuaState::Push(const AString & a_String) ASSERT(IsValid()); lua_pushlstring(m_LuaState, a_String.data(), a_String.size()); - m_NumCurrentFunctionArgs += 1; } @@ -794,7 +793,6 @@ void cLuaState::Push(const AStringVector & a_Vector) tolua_pushstring(m_LuaState, itr->c_str()); lua_rawseti(m_LuaState, newTable, index); } - m_NumCurrentFunctionArgs += 1; } @@ -806,7 +804,6 @@ void cLuaState::Push(const cCraftingGrid * a_Grid) ASSERT(IsValid()); tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<cCraftingGrid *>(a_Grid)), "cCraftingGrid"); - m_NumCurrentFunctionArgs += 1; } @@ -818,7 +815,6 @@ void cLuaState::Push(const cCraftingRecipe * a_Recipe) ASSERT(IsValid()); tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<cCraftingRecipe *>(a_Recipe)), "cCraftingRecipe"); - m_NumCurrentFunctionArgs += 1; } @@ -830,7 +826,6 @@ void cLuaState::Push(const char * a_Value) ASSERT(IsValid()); tolua_pushstring(m_LuaState, a_Value); - m_NumCurrentFunctionArgs += 1; } @@ -842,7 +837,6 @@ void cLuaState::Push(const cItems & a_Items) ASSERT(IsValid()); tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<cItems *>(&a_Items)), "cItems"); - m_NumCurrentFunctionArgs += 1; } @@ -854,7 +848,6 @@ void cLuaState::Push(const cNil & a_Nil) ASSERT(IsValid()); lua_pushnil(m_LuaState); - m_NumCurrentFunctionArgs += 1; } @@ -866,7 +859,6 @@ void cLuaState::Push(const cPlayer * a_Player) ASSERT(IsValid()); tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<cPlayer *>(a_Player)), "cPlayer"); - m_NumCurrentFunctionArgs += 1; } @@ -878,7 +870,6 @@ void cLuaState::Push(const cLuaState::cRef & a_Ref) ASSERT(IsValid()); lua_rawgeti(m_LuaState, LUA_REGISTRYINDEX, static_cast<int>(a_Ref)); - m_NumCurrentFunctionArgs += 1; } @@ -890,7 +881,6 @@ void cLuaState::Push(const HTTPRequest * a_Request) ASSERT(IsValid()); tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<HTTPRequest *>(a_Request)), "HTTPRequest"); - m_NumCurrentFunctionArgs += 1; } @@ -902,7 +892,6 @@ void cLuaState::Push(const HTTPTemplateRequest * a_Request) ASSERT(IsValid()); tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<HTTPTemplateRequest *>(a_Request)), "HTTPTemplateRequest"); - m_NumCurrentFunctionArgs += 1; } @@ -914,7 +903,6 @@ void cLuaState::Push(const Vector3d & a_Vector) ASSERT(IsValid()); tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<Vector3d *>(&a_Vector)), "Vector3<double>"); - m_NumCurrentFunctionArgs += 1; } @@ -926,7 +914,6 @@ void cLuaState::Push(const Vector3d * a_Vector) ASSERT(IsValid()); tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<Vector3d *>(a_Vector)), "Vector3<double>"); - m_NumCurrentFunctionArgs += 1; } @@ -938,7 +925,6 @@ void cLuaState::Push(const Vector3i & a_Vector) ASSERT(IsValid()); tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<Vector3i *>(&a_Vector)), "Vector3<int>"); - m_NumCurrentFunctionArgs += 1; } @@ -950,7 +936,6 @@ void cLuaState::Push(const Vector3i * a_Vector) ASSERT(IsValid()); tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<Vector3i *>(a_Vector)), "Vector3<int>"); - m_NumCurrentFunctionArgs += 1; } @@ -962,7 +947,6 @@ void cLuaState::Push(bool a_Value) ASSERT(IsValid()); tolua_pushboolean(m_LuaState, a_Value ? 1 : 0); - m_NumCurrentFunctionArgs += 1; } @@ -1027,8 +1011,6 @@ void cLuaState::Push(cEntity * a_Entity) } } // switch (EntityType) } - - m_NumCurrentFunctionArgs += 1; } @@ -1040,7 +1022,6 @@ void cLuaState::Push(cLuaServerHandle * a_ServerHandle) ASSERT(IsValid()); tolua_pushusertype(m_LuaState, a_ServerHandle, "cServerHandle"); - m_NumCurrentFunctionArgs += 1; } @@ -1052,7 +1033,6 @@ void cLuaState::Push(cLuaTCPLink * a_TCPLink) ASSERT(IsValid()); tolua_pushusertype(m_LuaState, a_TCPLink, "cTCPLink"); - m_NumCurrentFunctionArgs += 1; } @@ -1064,7 +1044,6 @@ void cLuaState::Push(cLuaUDPEndpoint * a_UDPEndpoint) ASSERT(IsValid()); tolua_pushusertype(m_LuaState, a_UDPEndpoint, "cUDPEndpoint"); - m_NumCurrentFunctionArgs += 1; } @@ -1076,7 +1055,6 @@ void cLuaState::Push(double a_Value) ASSERT(IsValid()); tolua_pushnumber(m_LuaState, a_Value); - m_NumCurrentFunctionArgs += 1; } @@ -1088,7 +1066,6 @@ void cLuaState::Push(int a_Value) ASSERT(IsValid()); tolua_pushnumber(m_LuaState, a_Value); - m_NumCurrentFunctionArgs += 1; } @@ -1100,7 +1077,6 @@ void cLuaState::Push(long a_Value) ASSERT(IsValid()); tolua_pushnumber(m_LuaState, static_cast<lua_Number>(a_Value)); - m_NumCurrentFunctionArgs += 1; } @@ -1112,7 +1088,6 @@ void cLuaState::Push(UInt32 a_Value) ASSERT(IsValid()); tolua_pushnumber(m_LuaState, a_Value); - m_NumCurrentFunctionArgs += 1; } @@ -1124,7 +1099,6 @@ void cLuaState::Push(std::chrono::milliseconds a_Value) ASSERT(IsValid()); tolua_pushnumber(m_LuaState, static_cast<lua_Number>(a_Value.count())); - m_NumCurrentFunctionArgs += 1; } @@ -1136,7 +1110,6 @@ void cLuaState::Pop(int a_NumValuesToPop) ASSERT(IsValid()); lua_pop(m_LuaState, a_NumValuesToPop); - m_NumCurrentFunctionArgs -= a_NumValuesToPop; } diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h index 3c07ac5d2..cb68b9a98 100644 --- a/src/Bindings/LuaState.h +++ b/src/Bindings/LuaState.h @@ -634,6 +634,7 @@ public: template <typename FnT, typename... Args> bool Call(const FnT & a_Function, Args &&... args) { + m_NumCurrentFunctionArgs = -1; if (!PushFunction(std::forward<const FnT &>(a_Function))) { // Pushing the function failed @@ -795,6 +796,7 @@ protected: inline bool PushCallPop(T && a_Param, Args &&... args) { Push(std::forward<T>(a_Param)); + m_NumCurrentFunctionArgs += 1; return PushCallPop(std::forward<Args>(args)...); } |