From 7b10bbaab087c5a30206687c0814b129990a3918 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 23 Apr 2016 22:18:43 +0200 Subject: [PATCH] Lua/LuaInstance: Rename automatic SetField/SetGlobal to PushField/PushGlobal Former-commit-id: add576baa5ee7c12121925b5b4fb5fc37fe85042 --- SDK/src/NDK/LuaBinding_Network.cpp | 8 ++--- include/Nazara/Lua/LuaInstance.hpp | 12 +++---- include/Nazara/Lua/LuaInstance.inl | 52 +++++++++++++++--------------- src/Nazara/Lua/LuaInstance.cpp | 4 +-- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/SDK/src/NDK/LuaBinding_Network.cpp b/SDK/src/NDK/LuaBinding_Network.cpp index 4b8334017..7860322ff 100644 --- a/SDK/src/NDK/LuaBinding_Network.cpp +++ b/SDK/src/NDK/LuaBinding_Network.cpp @@ -90,10 +90,10 @@ namespace Ndk { instance.PushInteger(index++); instance.PushTable(0, 4); - instance.SetField("Address", std::move(info.address)); - instance.SetField("CanonicalName", std::move(info.canonicalName)); - instance.SetField("Protocol", std::move(info.protocol)); - instance.SetField("SocketType", std::move(info.socketType)); + instance.PushField("Address", std::move(info.address)); + instance.PushField("CanonicalName", std::move(info.canonicalName)); + instance.PushField("Protocol", std::move(info.protocol)); + instance.PushField("SocketType", std::move(info.socketType)); instance.SetTable(); } diff --git a/include/Nazara/Lua/LuaInstance.hpp b/include/Nazara/Lua/LuaInstance.hpp index 9dd5c3571..e2d15958f 100644 --- a/include/Nazara/Lua/LuaInstance.hpp +++ b/include/Nazara/Lua/LuaInstance.hpp @@ -125,8 +125,12 @@ namespace Nz template int Push(T arg) const; void PushBoolean(bool value) const; void PushCFunction(LuaCFunction func, unsigned int upvalueCount = 0) const; + template void PushField(const char* name, T&& arg, int tableIndex = -2) const; + template void PushField(const String& name, T&& arg, int tableIndex = -2) const; void PushFunction(LuaFunction func) const; template void PushFunction(R(*func)(Args...), DefArgs&&... defArgs) const; + template void PushGlobal(const char* name, T&& arg); + template void PushGlobal(const String& name, T&& arg); template void PushInstance(const char* tname, T* instance) const; template void PushInstance(const char* tname, Args&&... args) const; void PushInteger(long long value) const; @@ -146,12 +150,8 @@ namespace Nz void Remove(int index) const; void Replace(int index) const; - template void SetField(const char* name, T&& arg, int tableIndex = -2); - template void SetField(const String& name, T&& arg, int tableIndex = -2); - void SetField(const char* name, int tableIndex = -2); - void SetField(const String& name, int tableIndex = -2); - template void SetGlobal(const char* name, T&& arg); - template void SetGlobal(const String& name, T&& arg); + void SetField(const char* name, int tableIndex = -2) const; + void SetField(const String& name, int tableIndex = -2) const; void SetGlobal(const char* name); void SetGlobal(const String& name); void SetMetatable(const char* tname) const; diff --git a/include/Nazara/Lua/LuaInstance.inl b/include/Nazara/Lua/LuaInstance.inl index a445df491..5cc87c61e 100644 --- a/include/Nazara/Lua/LuaInstance.inl +++ b/include/Nazara/Lua/LuaInstance.inl @@ -541,6 +541,19 @@ namespace Nz return LuaImplReplyVal(*this, std::move(arg), TypeTag()); } + template + void LuaInstance::PushField(const char* name, T&& arg, int tableIndex) const + { + Push(std::forward(arg)); + SetField(name, tableIndex); + } + + template + void LuaInstance::PushField(const String& name, T&& arg, int tableIndex) const + { + PushField(name.GetConstBuffer(), std::forward(arg), tableIndex); + } + template void LuaInstance::PushFunction(R(*func)(Args...), DefArgs&&... defArgs) const { @@ -554,6 +567,19 @@ namespace Nz }); } + template + void LuaInstance::PushGlobal(const char* name, T&& arg) + { + Push(std::forward(arg)); + SetGlobal(name); + } + + template + void LuaInstance::PushGlobal(const String& name, T&& arg) + { + PushGlobal(name.GetConstBuffer(), std::forward(arg)); + } + template void LuaInstance::PushInstance(const char* tname, T* instance) const { @@ -568,32 +594,6 @@ namespace Nz PushInstance(tname, new T(std::forward(args)...)); } - template - void LuaInstance::SetField(const char* name, T&& arg, int tableIndex) - { - Push(std::forward(arg)); - SetField(name, tableIndex); - } - - template - void LuaInstance::SetField(const String& name, T&& arg, int tableIndex) - { - SetField(name.GetConstBuffer(), std::forward(arg), tableIndex); - } - - template - void LuaInstance::SetGlobal(const char* name, T&& arg) - { - Push(std::forward(arg)); - SetGlobal(name); - } - - template - void LuaInstance::SetGlobal(const String& name, T&& arg) - { - SetGlobal(name.GetConstBuffer(), std::forward(arg)); - } - template T LuaInstance::CheckBounds(int index, long long value) const { diff --git a/src/Nazara/Lua/LuaInstance.cpp b/src/Nazara/Lua/LuaInstance.cpp index 8e437d759..a93013567 100644 --- a/src/Nazara/Lua/LuaInstance.cpp +++ b/src/Nazara/Lua/LuaInstance.cpp @@ -714,12 +714,12 @@ namespace Nz lua_replace(m_state, index); } - void LuaInstance::SetField(const char* name, int tableIndex) + void LuaInstance::SetField(const char* name, int tableIndex) const { lua_setfield(m_state, tableIndex, name); } - void LuaInstance::SetField(const String& name, int tableIndex) + void LuaInstance::SetField(const String& name, int tableIndex) const { lua_setfield(m_state, tableIndex, name.GetConstBuffer()); }