From 4a71fb2922d3b3bb0244368ccf7c6e9bfb9d4a58 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 10 Dec 2015 14:09:13 +0100 Subject: [PATCH] Lua/LuaClass: Fix parameters sent to Getter/Setter Former-commit-id: 7ca17fab640f8fb0c5836f8c1ae6186873d645f2 --- include/Nazara/Lua/LuaClass.inl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/Nazara/Lua/LuaClass.inl b/include/Nazara/Lua/LuaClass.inl index 7d5f179c7..afe89c702 100644 --- a/include/Nazara/Lua/LuaClass.inl +++ b/include/Nazara/Lua/LuaClass.inl @@ -271,6 +271,7 @@ namespace Nz FinalizerFunc finalizer = info->finalizer; T* instance = *static_cast(lua.CheckUserdata(1, info->name)); + lua.Remove(1); //< Remove the instance from the Lua stack if (!finalizer || finalizer(lua, *instance)) delete instance; @@ -301,6 +302,7 @@ namespace Nz ClassIndexFunc getter = info->getter; T& instance = *(*static_cast(lua.CheckUserdata(1, info->name))); + lua.Remove(1); //< Remove the instance from the Lua stack if (!getter(lua, instance)) { @@ -323,8 +325,7 @@ namespace Nz ClassFunc method = info->methods[index]; T& instance = *(*static_cast(lua.CheckUserdata(1, info->name))); - - lua.Remove(1); // On enlève l'argument "userdata" du stack + lua.Remove(1); //< Remove the instance from the Lua stack return method(lua, instance); } @@ -338,13 +339,14 @@ namespace Nz ClassIndexFunc setter = info->setter; T& instance = *(*static_cast(lua.CheckUserdata(1, info->name))); + lua.Remove(1); //< Remove the instance from the Lua stack if (!setter(lua, instance)) { std::size_t length; const char* str = lua.ToString(2, &length); - lua.Error("Class \"" + info->name + "\" has no field \"" + String(str, length) + ')'); + lua.Error("Class \"" + info->name + "\" has no field \"" + String(str, length) + "\")"); } return 1;