Sdk/Binding: Fix binding initialization

Former-commit-id: e9dde83bcd950bf3a8f3665f88d253ef6e71ffc2
This commit is contained in:
Lynix 2016-04-23 22:38:47 +02:00
parent 0df824517a
commit 346e9d7081
4 changed files with 75 additions and 71 deletions

View File

@ -252,9 +252,9 @@ namespace Ndk
static_assert(Nz::CursorPosition_Max + 1 == 3, "Nz::CursorPosition has been updated but change was not reflected to Lua binding"); static_assert(Nz::CursorPosition_Max + 1 == 3, "Nz::CursorPosition has been updated but change was not reflected to Lua binding");
instance.PushTable(0, 3); instance.PushTable(0, 3);
{ {
instance.SetField("AtBegin", Nz::CursorPosition_AtBegin); instance.PushField("AtBegin", Nz::CursorPosition_AtBegin);
instance.SetField("AtCurrent", Nz::CursorPosition_AtCurrent); instance.PushField("AtCurrent", Nz::CursorPosition_AtCurrent);
instance.SetField("AtEnd", Nz::CursorPosition_AtEnd); instance.PushField("AtEnd", Nz::CursorPosition_AtEnd);
} }
instance.SetGlobal("CursorPosition"); instance.SetGlobal("CursorPosition");
@ -262,15 +262,15 @@ namespace Ndk
static_assert(Nz::HashType_Max + 1 == 9, "Nz::HashType has been updated but change was not reflected to Lua binding"); static_assert(Nz::HashType_Max + 1 == 9, "Nz::HashType has been updated but change was not reflected to Lua binding");
instance.PushTable(0, 9); instance.PushTable(0, 9);
{ {
instance.SetField("CRC32", Nz::HashType_CRC32); instance.PushField("CRC32", Nz::HashType_CRC32);
instance.SetField("Fletcher16", Nz::HashType_Fletcher16); instance.PushField("Fletcher16", Nz::HashType_Fletcher16);
instance.SetField("MD5", Nz::HashType_MD5); instance.PushField("MD5", Nz::HashType_MD5);
instance.SetField("SHA1", Nz::HashType_SHA1); instance.PushField("SHA1", Nz::HashType_SHA1);
instance.SetField("SHA224", Nz::HashType_SHA224); instance.PushField("SHA224", Nz::HashType_SHA224);
instance.SetField("SHA256", Nz::HashType_SHA256); instance.PushField("SHA256", Nz::HashType_SHA256);
instance.SetField("SHA384", Nz::HashType_SHA384); instance.PushField("SHA384", Nz::HashType_SHA384);
instance.SetField("SHA512", Nz::HashType_SHA512); instance.PushField("SHA512", Nz::HashType_SHA512);
instance.SetField("Whirlpool", Nz::HashType_Whirlpool); instance.PushField("Whirlpool", Nz::HashType_Whirlpool);
} }
instance.SetGlobal("HashType"); instance.SetGlobal("HashType");
@ -278,14 +278,14 @@ namespace Ndk
static_assert(Nz::OpenMode_Max + 1 == 2 * (64), "Nz::OpenModeFlags has been updated but change was not reflected to Lua binding"); static_assert(Nz::OpenMode_Max + 1 == 2 * (64), "Nz::OpenModeFlags has been updated but change was not reflected to Lua binding");
instance.PushTable(0, 8); instance.PushTable(0, 8);
{ {
instance.SetField("Append", Nz::OpenMode_Append); instance.PushField("Append", Nz::OpenMode_Append);
instance.SetField("NotOpen", Nz::OpenMode_NotOpen); instance.PushField("NotOpen", Nz::OpenMode_NotOpen);
instance.SetField("Lock", Nz::OpenMode_Lock); instance.PushField("Lock", Nz::OpenMode_Lock);
instance.SetField("ReadOnly", Nz::OpenMode_ReadOnly); instance.PushField("ReadOnly", Nz::OpenMode_ReadOnly);
instance.SetField("ReadWrite", Nz::OpenMode_ReadWrite); instance.PushField("ReadWrite", Nz::OpenMode_ReadWrite);
instance.SetField("Text", Nz::OpenMode_Text); instance.PushField("Text", Nz::OpenMode_Text);
instance.SetField("Truncate", Nz::OpenMode_Truncate); instance.PushField("Truncate", Nz::OpenMode_Truncate);
instance.SetField("WriteOnly", Nz::OpenMode_WriteOnly); instance.PushField("WriteOnly", Nz::OpenMode_WriteOnly);
} }
instance.SetGlobal("OpenMode"); instance.SetGlobal("OpenMode");
} }

View File

@ -120,10 +120,10 @@ namespace Ndk
static_assert(Nz::NetProtocol_Max + 1 == 4, "Nz::NetProtocol has been updated but change was not reflected to Lua binding"); static_assert(Nz::NetProtocol_Max + 1 == 4, "Nz::NetProtocol has been updated but change was not reflected to Lua binding");
instance.PushTable(0, 4); instance.PushTable(0, 4);
{ {
instance.SetField("Any", Nz::NetProtocol_Any); instance.PushField("Any", Nz::NetProtocol_Any);
instance.SetField("IPv4", Nz::NetProtocol_IPv4); instance.PushField("IPv4", Nz::NetProtocol_IPv4);
instance.SetField("IPv6", Nz::NetProtocol_IPv6); instance.PushField("IPv6", Nz::NetProtocol_IPv6);
instance.SetField("Unknown", Nz::NetProtocol_Unknown); instance.PushField("Unknown", Nz::NetProtocol_Unknown);
} }
instance.SetGlobal("NetProtocol"); instance.SetGlobal("NetProtocol");
@ -131,12 +131,12 @@ namespace Ndk
static_assert(Nz::PacketPriority_Max + 1 == 4, "Nz::PacketPriority has been updated but change was not reflected to Lua binding"); static_assert(Nz::PacketPriority_Max + 1 == 4, "Nz::PacketPriority has been updated but change was not reflected to Lua binding");
instance.PushTable(0, 6); instance.PushTable(0, 6);
{ {
instance.SetField("High", Nz::PacketPriority_High); instance.PushField("High", Nz::PacketPriority_High);
instance.SetField("Highest", Nz::PacketPriority_Highest); instance.PushField("Highest", Nz::PacketPriority_Highest);
instance.SetField("Immediate", Nz::PacketPriority_Immediate); instance.PushField("Immediate", Nz::PacketPriority_Immediate);
instance.SetField("Medium", Nz::PacketPriority_Medium); instance.PushField("Medium", Nz::PacketPriority_Medium);
instance.SetField("Low", Nz::PacketPriority_Low); instance.PushField("Low", Nz::PacketPriority_Low);
instance.SetField("Lowest", Nz::PacketPriority_Lowest); instance.PushField("Lowest", Nz::PacketPriority_Lowest);
} }
instance.SetGlobal("PacketPriority"); instance.SetGlobal("PacketPriority");
@ -144,9 +144,9 @@ namespace Ndk
static_assert(Nz::PacketReliability_Max + 1 == 3, "Nz::PacketReliability has been updated but change was not reflected to Lua binding"); static_assert(Nz::PacketReliability_Max + 1 == 3, "Nz::PacketReliability has been updated but change was not reflected to Lua binding");
instance.PushTable(0, 3); instance.PushTable(0, 3);
{ {
instance.SetField("Reliable", Nz::PacketReliability_Reliable); instance.PushField("Reliable", Nz::PacketReliability_Reliable);
instance.SetField("ReliableOrdered", Nz::PacketReliability_ReliableOrdered); instance.PushField("ReliableOrdered", Nz::PacketReliability_ReliableOrdered);
instance.SetField("Unreliable", Nz::PacketReliability_Unreliable); instance.PushField("Unreliable", Nz::PacketReliability_Unreliable);
} }
instance.SetGlobal("PacketReliability"); instance.SetGlobal("PacketReliability");
@ -154,15 +154,15 @@ namespace Ndk
static_assert(Nz::ResolveError_Max + 1 == 9, "Nz::ResolveError has been updated but change was not reflected to Lua binding"); static_assert(Nz::ResolveError_Max + 1 == 9, "Nz::ResolveError has been updated but change was not reflected to Lua binding");
instance.PushTable(0, 9); instance.PushTable(0, 9);
{ {
instance.SetField("Internal", Nz::ResolveError_Internal); instance.PushField("Internal", Nz::ResolveError_Internal);
instance.SetField("ResourceError", Nz::ResolveError_ResourceError); instance.PushField("ResourceError", Nz::ResolveError_ResourceError);
instance.SetField("NoError", Nz::ResolveError_NoError); instance.PushField("NoError", Nz::ResolveError_NoError);
instance.SetField("NonRecoverable", Nz::ResolveError_NonRecoverable); instance.PushField("NonRecoverable", Nz::ResolveError_NonRecoverable);
instance.SetField("NotFound", Nz::ResolveError_NotFound); instance.PushField("NotFound", Nz::ResolveError_NotFound);
instance.SetField("NotInitialized", Nz::ResolveError_NotInitialized); instance.PushField("NotInitialized", Nz::ResolveError_NotInitialized);
instance.SetField("ProtocolNotSupported", Nz::ResolveError_ProtocolNotSupported); instance.PushField("ProtocolNotSupported", Nz::ResolveError_ProtocolNotSupported);
instance.SetField("TemporaryFailure", Nz::ResolveError_TemporaryFailure); instance.PushField("TemporaryFailure", Nz::ResolveError_TemporaryFailure);
instance.SetField("Unknown", Nz::ResolveError_Unknown); instance.PushField("Unknown", Nz::ResolveError_Unknown);
} }
instance.SetGlobal("ResolveError"); instance.SetGlobal("ResolveError");
@ -170,21 +170,21 @@ namespace Ndk
static_assert(Nz::SocketError_Max + 1 == 15, "Nz::ResolveError has been updated but change was not reflected to Lua binding"); static_assert(Nz::SocketError_Max + 1 == 15, "Nz::ResolveError has been updated but change was not reflected to Lua binding");
instance.PushTable(0, 15); instance.PushTable(0, 15);
{ {
instance.SetField("AddressNotAvailable", Nz::SocketError_AddressNotAvailable); instance.PushField("AddressNotAvailable", Nz::SocketError_AddressNotAvailable);
instance.SetField("ConnectionClosed", Nz::SocketError_ConnectionClosed); instance.PushField("ConnectionClosed", Nz::SocketError_ConnectionClosed);
instance.SetField("ConnectionRefused", Nz::SocketError_ConnectionRefused); instance.PushField("ConnectionRefused", Nz::SocketError_ConnectionRefused);
instance.SetField("DatagramSize", Nz::SocketError_DatagramSize); instance.PushField("DatagramSize", Nz::SocketError_DatagramSize);
instance.SetField("Internal", Nz::SocketError_Internal); instance.PushField("Internal", Nz::SocketError_Internal);
instance.SetField("Packet", Nz::SocketError_Packet); instance.PushField("Packet", Nz::SocketError_Packet);
instance.SetField("NetworkError", Nz::SocketError_NetworkError); instance.PushField("NetworkError", Nz::SocketError_NetworkError);
instance.SetField("NoError", Nz::SocketError_NoError); instance.PushField("NoError", Nz::SocketError_NoError);
instance.SetField("NotInitialized", Nz::SocketError_NotInitialized); instance.PushField("NotInitialized", Nz::SocketError_NotInitialized);
instance.SetField("NotSupported", Nz::SocketError_NotSupported); instance.PushField("NotSupported", Nz::SocketError_NotSupported);
instance.SetField("ResolveError", Nz::SocketError_ResolveError); instance.PushField("ResolveError", Nz::SocketError_ResolveError);
instance.SetField("ResourceError", Nz::SocketError_ResourceError); instance.PushField("ResourceError", Nz::SocketError_ResourceError);
instance.SetField("TimedOut", Nz::SocketError_TimedOut); instance.PushField("TimedOut", Nz::SocketError_TimedOut);
instance.SetField("Unknown", Nz::SocketError_Unknown); instance.PushField("Unknown", Nz::SocketError_Unknown);
instance.SetField("UnreachableHost", Nz::SocketError_UnreachableHost); instance.PushField("UnreachableHost", Nz::SocketError_UnreachableHost);
} }
instance.SetGlobal("SocketError"); instance.SetGlobal("SocketError");
@ -192,11 +192,11 @@ namespace Ndk
static_assert(Nz::SocketState_Max + 1 == 5, "Nz::SocketState has been updated but change was not reflected to Lua binding"); static_assert(Nz::SocketState_Max + 1 == 5, "Nz::SocketState has been updated but change was not reflected to Lua binding");
instance.PushTable(0, 5); instance.PushTable(0, 5);
{ {
instance.SetField("Bound", Nz::SocketState_Bound); instance.PushField("Bound", Nz::SocketState_Bound);
instance.SetField("Connecting", Nz::SocketState_Connecting); instance.PushField("Connecting", Nz::SocketState_Connecting);
instance.SetField("Connected", Nz::SocketState_Connected); instance.PushField("Connected", Nz::SocketState_Connected);
instance.SetField("NotConnected", Nz::SocketState_NotConnected); instance.PushField("NotConnected", Nz::SocketState_NotConnected);
instance.SetField("Resolving", Nz::SocketState_Resolving); instance.PushField("Resolving", Nz::SocketState_Resolving);
} }
instance.SetGlobal("SocketState"); instance.SetGlobal("SocketState");
@ -204,10 +204,10 @@ namespace Ndk
static_assert(Nz::SocketType_Max + 1 == 4, "Nz::SocketState has been updated but change was not reflected to Lua binding"); static_assert(Nz::SocketType_Max + 1 == 4, "Nz::SocketState has been updated but change was not reflected to Lua binding");
instance.PushTable(0, 4); instance.PushTable(0, 4);
{ {
instance.SetField("Raw", Nz::SocketType_Raw); instance.PushField("Raw", Nz::SocketType_Raw);
instance.SetField("TCP", Nz::SocketType_TCP); instance.PushField("TCP", Nz::SocketType_TCP);
instance.SetField("UDP", Nz::SocketType_UDP); instance.PushField("UDP", Nz::SocketType_UDP);
instance.SetField("Unknown", Nz::SocketType_Unknown); instance.PushField("Unknown", Nz::SocketType_Unknown);
} }
instance.SetGlobal("SocketType"); instance.SetGlobal("SocketType");
} }

View File

@ -194,8 +194,7 @@ namespace Ndk
if (entry.name.IsEmpty()) if (entry.name.IsEmpty())
continue; continue;
instance.PushInteger(entry.index); instance.PushField(entry.name, entry.index);
instance.SetField(entry.name);
} }
} }
instance.SetGlobal("ComponentType"); instance.SetGlobal("ComponentType");

View File

@ -145,10 +145,15 @@ namespace Nz
} }
template<typename T> template<typename T>
std::enable_if_t<std::is_arithmetic<T>::value, int> LuaImplReplyVal(const LuaInstance& instance, T val, TypeTag<T&>) std::enable_if_t<std::is_arithmetic<T>::value || std::is_enum<T>::value, int> LuaImplReplyVal(const LuaInstance& instance, T val, TypeTag<T&>)
{ {
using NoRefT = typename std::remove_reference<T>::type; return LuaImplReplyVal(instance, val, TypeTag<T>());
return LuaImplReplyVal(instance, val, TypeTag<NoRefT>()); }
template<typename T>
std::enable_if_t<std::is_arithmetic<T>::value || std::is_enum<T>::value, int> LuaImplReplyVal(const LuaInstance& instance, T val, TypeTag<const T&>)
{
return LuaImplReplyVal(instance, val, TypeTag<T>());
} }
inline int LuaImplReplyVal(const LuaInstance& instance, std::string val, TypeTag<std::string>) inline int LuaImplReplyVal(const LuaInstance& instance, std::string val, TypeTag<std::string>)