From a07410d771c9ea1f38d5df56d097ec3084d87d3c Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Mon, 20 Feb 2017 11:21:55 +0100 Subject: [PATCH] LuaWrapper: Don't shadow variables Fix shadowed variables reported by `-Wshadow`. --- ext/luawrapper/include/LuaContext.hpp | 92 +++++++++++++-------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/ext/luawrapper/include/LuaContext.hpp b/ext/luawrapper/include/LuaContext.hpp index c7090f676f..827e185771 100644 --- a/ext/luawrapper/include/LuaContext.hpp +++ b/ext/luawrapper/include/LuaContext.hpp @@ -169,10 +169,10 @@ public: class WrongTypeException : public std::runtime_error { public: - WrongTypeException(std::string luaType, const std::type_info& destination) : - std::runtime_error("Trying to cast a lua variable from \"" + luaType + "\" to \"" + destination.name() + "\""), - luaType(luaType), - destination(destination) + WrongTypeException(std::string luaType_, const std::type_info& destination_) : + std::runtime_error("Trying to cast a lua variable from \"" + luaType_ + "\" to \"" + destination_.name() + "\""), + luaType(luaType_), + destination(destination_) { } @@ -426,12 +426,12 @@ public: * @tparam TVarType Type of the member * @param name Name of the member to register * @param readFunction Function of type "TVarType (const TObject&)" - * @param writeFunction Function of type "void (TObject&, const TVarType&)" + * @param writeFunction_ Function of type "void (TObject&, const TVarType&)" */ template - void registerMember(const std::string& name, TReadFunction readFunction, TWriteFunction writeFunction) + void registerMember(const std::string& name, TReadFunction readFunction, TWriteFunction writeFunction_) { - registerMemberImpl(name, std::move(readFunction), std::move(writeFunction)); + registerMemberImpl(name, std::move(readFunction), std::move(writeFunction_)); } /** @@ -440,13 +440,13 @@ public: * @tparam TMemberType Pointer to member object representing the type * @param name Name of the member to register * @param readFunction Function of type "TVarType (const TObject&)" - * @param writeFunction Function of type "void (TObject&, const TVarType&)" + * @param writeFunction_ Function of type "void (TObject&, const TVarType&)" */ template - void registerMember(const std::string& name, TReadFunction readFunction, TWriteFunction writeFunction) + void registerMember(const std::string& name, TReadFunction readFunction, TWriteFunction writeFunction_) { static_assert(std::is_member_object_pointer::value, "registerMember must take a member object pointer type as template parameter"); - registerMemberImpl(tag{}, name, std::move(readFunction), std::move(writeFunction)); + registerMemberImpl(tag{}, name, std::move(readFunction), std::move(writeFunction_)); } /** @@ -483,12 +483,12 @@ public: * @tparam TObject Type to register the member to * @tparam TVarType Type of the member * @param readFunction Function of type "TVarType (const TObject&, const std::string&)" - * @param writeFunction Function of type "void (TObject&, const std::string&, const TVarType&)" + * @param writeFunction_ Function of type "void (TObject&, const std::string&, const TVarType&)" */ template - void registerMember(TReadFunction readFunction, TWriteFunction writeFunction) + void registerMember(TReadFunction readFunction, TWriteFunction writeFunction_) { - registerMemberImpl(std::move(readFunction), std::move(writeFunction)); + registerMemberImpl(std::move(readFunction), std::move(writeFunction_)); } /** @@ -496,13 +496,13 @@ public: * This is the version "registerMember(getter, setter)" * @tparam TMemberType Pointer to member object representing the type * @param readFunction Function of type "TVarType (const TObject&, const std::string&)" - * @param writeFunction Function of type "void (TObject&, const std::string&, const TVarType&)" + * @param writeFunction_ Function of type "void (TObject&, const std::string&, const TVarType&)" */ template - void registerMember(TReadFunction readFunction, TWriteFunction writeFunction) + void registerMember(TReadFunction readFunction, TWriteFunction writeFunction_) { static_assert(std::is_member_object_pointer::value, "registerMember must take a member object pointer type as template parameter"); - registerMemberImpl(tag{}, std::move(readFunction), std::move(writeFunction)); + registerMemberImpl(tag{}, std::move(readFunction), std::move(writeFunction_)); } /** @@ -680,7 +680,7 @@ private: /* PUSH OBJECT */ /**************************************************/ struct PushedObject { - PushedObject(lua_State* state, int num = 1) : state(state), num(num) {} + PushedObject(lua_State* state_, int num_ = 1) : state(state_), num(num_) {} ~PushedObject() { assert(lua_gettop(state) >= num); if (num >= 1) lua_pop(state, num); } PushedObject& operator=(const PushedObject&) = delete; @@ -1132,29 +1132,29 @@ private: } template - void registerMemberImpl(const std::string& name, TReadFunction readFunction, TWriteFunction writeFunction) + void registerMemberImpl(const std::string& name, TReadFunction readFunction, TWriteFunction writeFunction_) { registerMemberImpl(name, readFunction); - setTable(mState, Registry, &typeid(TObject), 4, name, [writeFunction](TObject& object, const TVarType& value) { - writeFunction(object, value); + setTable(mState, Registry, &typeid(TObject), 4, name, [writeFunction_](TObject& object, const TVarType& value) { + writeFunction_(object, value); }); - setTable(mState, Registry, &typeid(TObject*), 4, name, [writeFunction](TObject* object, const TVarType& value) { + setTable(mState, Registry, &typeid(TObject*), 4, name, [writeFunction_](TObject* object, const TVarType& value) { assert(object); - writeFunction(*object, value); + writeFunction_(*object, value); }); - setTable, TVarType)>(mState, Registry, &typeid(std::shared_ptr), 4, name, [writeFunction](std::shared_ptr object, const TVarType& value) { + setTable, TVarType)>(mState, Registry, &typeid(std::shared_ptr), 4, name, [writeFunction_](std::shared_ptr object, const TVarType& value) { assert(object); - writeFunction(*object, value); + writeFunction_(*object, value); }); } template - void registerMemberImpl(tag, const std::string& name, TReadFunction readFunction, TWriteFunction writeFunction) + void registerMemberImpl(tag, const std::string& name, TReadFunction readFunction, TWriteFunction writeFunction_) { - registerMemberImpl(name, std::move(readFunction), std::move(writeFunction)); + registerMemberImpl(name, std::move(readFunction), std::move(writeFunction_)); } template @@ -1198,29 +1198,29 @@ private: } template - void registerMemberImpl(TReadFunction readFunction, TWriteFunction writeFunction) + void registerMemberImpl(TReadFunction readFunction, TWriteFunction writeFunction_) { registerMemberImpl(readFunction); - setTable(mState, Registry, &typeid(TObject), 5, [writeFunction](TObject& object, const std::string& name, const TVarType& value) { - writeFunction(object, name, value); + setTable(mState, Registry, &typeid(TObject), 5, [writeFunction_](TObject& object, const std::string& name, const TVarType& value) { + writeFunction_(object, name, value); }); - setTable(mState, Registry, &typeid(TObject*), 2, [writeFunction](TObject* object, const std::string& name, const TVarType& value) { + setTable(mState, Registry, &typeid(TObject*), 2, [writeFunction_](TObject* object, const std::string& name, const TVarType& value) { assert(object); - writeFunction(*object, name, value); + writeFunction_(*object, name, value); }); - setTable, std::string, TVarType)>(mState, Registry, &typeid(std::shared_ptr), 2, [writeFunction](const std::shared_ptr& object, const std::string& name, const TVarType& value) { + setTable, std::string, TVarType)>(mState, Registry, &typeid(std::shared_ptr), 2, [writeFunction_](const std::shared_ptr& object, const std::string& name, const TVarType& value) { assert(object); - writeFunction(*object, name, value); + writeFunction_(*object, name, value); }); } template - void registerMemberImpl(tag, TReadFunction readFunction, TWriteFunction writeFunction) + void registerMemberImpl(tag, TReadFunction readFunction, TWriteFunction writeFunction_) { - registerMemberImpl(std::move(readFunction), std::move(writeFunction)); + registerMemberImpl(std::move(readFunction), std::move(writeFunction_)); } template @@ -1642,7 +1642,7 @@ private: // structure that will ensure that a certain value is stored somewhere in the registry struct ValueInRegistry { // this constructor will clone and hold the value at the specified index (or by default at the top of the stack) in the registry - ValueInRegistry(lua_State* lua, int index=-1) : lua{lua} + ValueInRegistry(lua_State* lua_, int index=-1) : lua{lua_} { lua_pushlightuserdata(lua, this); lua_pushvalue(lua, -1 + index); @@ -1821,9 +1821,9 @@ private: private: friend LuaContext; - explicit LuaFunctionCaller(lua_State* state, int index) : - valueHolder(std::make_shared(state, index)), - state(state) + explicit LuaFunctionCaller(lua_State* state_, int index) : + valueHolder(std::make_shared(state_, index)), + state(state_) {} }; @@ -2143,11 +2143,11 @@ struct LuaContext::Pusher // since "fn" doesn't need to be destroyed, we simply push it on the stack // this is the cfunction that is the callback - const auto function = [](lua_State* state) -> int + const auto function = [](lua_State* state_) -> int { // the function object is an upvalue - const auto toCall = static_cast(lua_touserdata(state, lua_upvalueindex(1))); - return callback(state, toCall, lua_gettop(state)).release(); + const auto toCall = static_cast(lua_touserdata(state_, lua_upvalueindex(1))); + return callback(state_, toCall, lua_gettop(state_)).release(); }; // we copy the function object onto the stack @@ -2167,11 +2167,11 @@ struct LuaContext::Pusher // since "fn" doesn't need to be destroyed, we simply push it on the stack // this is the cfunction that is the callback - const auto function = [](lua_State* state) -> int + const auto function = [](lua_State* state_) -> int { // the function object is an upvalue - const auto toCall = reinterpret_cast(lua_touserdata(state, lua_upvalueindex(1))); - return callback(state, toCall, lua_gettop(state)).release(); + const auto toCall = reinterpret_cast(lua_touserdata(state_, lua_upvalueindex(1))); + return callback(state_, toCall, lua_gettop(state_)).release(); }; // we copy the function object onto the stack @@ -2324,7 +2324,7 @@ private: obj = Pusher::type>::push(state, std::move(value)); } - VariantWriter(lua_State* state, PushedObject& obj) : state(state), obj(obj) {} + VariantWriter(lua_State* state_, PushedObject& obj_) : state(state_), obj(obj_) {} lua_State* state; PushedObject& obj; }; -- 2.47.2