Lua/LuaClass: Don't remove instance from the Lua stack
The instance Lua entry now remains as the first index, shifting all the parameters indexes by 1
This commit is contained in:
parent
c58ec94e2d
commit
5ffc5a8784
|
|
@ -124,7 +124,7 @@ namespace Ndk
|
|||
Nz::String name;
|
||||
};
|
||||
|
||||
ComponentBinding* QueryComponentIndex(Nz::LuaInstance& lua, int argIndex = 1);
|
||||
ComponentBinding* QueryComponentIndex(Nz::LuaInstance& lua, int argIndex = 2);
|
||||
|
||||
std::vector<ComponentBinding> m_componentBinding;
|
||||
std::unordered_map<Nz::String, ComponentIndex> m_componentBindingByName;
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ namespace Ndk
|
|||
music.BindMethod("Stop", &Nz::Music::Stop);
|
||||
|
||||
// Manual
|
||||
music.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Music& music) -> int
|
||||
music.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Music& music, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
Nz::StringStream stream("Music(");
|
||||
stream << music.GetFilePath() << ')';
|
||||
|
|
@ -65,7 +65,7 @@ namespace Ndk
|
|||
sound.BindMethod("SetPlayingOffset", &Nz::Sound::SetPlayingOffset);
|
||||
|
||||
// Manual
|
||||
sound.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Sound& sound) -> int
|
||||
sound.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Sound& sound, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
Nz::StringStream stream("Sound(");
|
||||
if (const Nz::SoundBuffer* buffer = sound.GetBuffer())
|
||||
|
|
@ -101,9 +101,9 @@ namespace Ndk
|
|||
soundBuffer.BindStaticMethod("IsFormatSupported", &Nz::SoundBuffer::IsFormatSupported);
|
||||
|
||||
// Manual
|
||||
soundBuffer.BindMethod("Create", [] (Nz::LuaInstance& lua, Nz::SoundBufferRef& instance) -> int
|
||||
soundBuffer.BindMethod("Create", [] (Nz::LuaInstance& lua, Nz::SoundBufferRef& instance, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
int index = 1;
|
||||
int index = 2;
|
||||
Nz::AudioFormat format = lua.Check<Nz::AudioFormat>(&index);
|
||||
unsigned int sampleCount = lua.Check<unsigned int>(&index);
|
||||
unsigned int sampleRate = lua.Check<unsigned int>(&index);
|
||||
|
|
@ -116,13 +116,13 @@ namespace Ndk
|
|||
return 1;
|
||||
});
|
||||
|
||||
soundBuffer.BindMethod("GetSamples", [] (Nz::LuaInstance& lua, Nz::SoundBufferRef& instance) -> int
|
||||
soundBuffer.BindMethod("GetSamples", [] (Nz::LuaInstance& lua, Nz::SoundBufferRef& instance, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
lua.PushString(reinterpret_cast<const char*>(instance->GetSamples()), instance->GetSampleCount() * sizeof(Nz::Int16));
|
||||
return 1;
|
||||
});
|
||||
|
||||
soundBuffer.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::SoundBufferRef& instance) -> int
|
||||
soundBuffer.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::SoundBufferRef& instance, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
Nz::StringStream stream("SoundBuffer(");
|
||||
if (instance->IsValid())
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace Ndk
|
|||
/*********************************** Nz::Clock **********************************/
|
||||
clock.SetConstructor([](Nz::LuaInstance& lua, Nz::Clock* clock, std::size_t /*argumentCount*/)
|
||||
{
|
||||
int argIndex = 1;
|
||||
int argIndex = 2;
|
||||
Nz::Int64 startingValue = lua.Check<Nz::Int64>(&argIndex, 0);
|
||||
bool paused = lua.Check<bool>(&argIndex, false);
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ namespace Ndk
|
|||
clock.BindMethod("Unpause", &Nz::Clock::Unpause);
|
||||
|
||||
// Manual
|
||||
clock.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Clock& clock) -> int {
|
||||
clock.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Clock& clock, std::size_t /*argumentCount*/) -> int {
|
||||
Nz::StringStream stream("Clock(Elapsed: ");
|
||||
stream << clock.GetSeconds();
|
||||
stream << "s, Paused: ";
|
||||
|
|
@ -48,7 +48,7 @@ namespace Ndk
|
|||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 1U);
|
||||
|
||||
int argIndex = 1;
|
||||
int argIndex = 2;
|
||||
switch (argCount)
|
||||
{
|
||||
case 0:
|
||||
|
|
@ -85,7 +85,7 @@ namespace Ndk
|
|||
directory.BindStaticMethod("SetCurrent", Nz::Directory::SetCurrent);
|
||||
|
||||
// Manual
|
||||
directory.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Directory& directory) -> int {
|
||||
directory.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Directory& directory, std::size_t /*argumentCount*/) -> int {
|
||||
Nz::StringStream stream("Directory(");
|
||||
stream << directory.GetPath();
|
||||
stream << ')';
|
||||
|
|
@ -110,8 +110,8 @@ namespace Ndk
|
|||
stream.BindMethod("IsWritable", &Nz::Stream::IsWritable);
|
||||
stream.BindMethod("SetCursorPos", &Nz::Stream::SetCursorPos);
|
||||
|
||||
stream.BindMethod("Read", [] (Nz::LuaInstance& lua, Nz::Stream& stream) -> int {
|
||||
int argIndex = 1;
|
||||
stream.BindMethod("Read", [] (Nz::LuaInstance& lua, Nz::Stream& stream, std::size_t /*argumentCount*/) -> int {
|
||||
int argIndex = 2;
|
||||
|
||||
std::size_t length = lua.Check<std::size_t>(&argIndex);
|
||||
|
||||
|
|
@ -122,8 +122,8 @@ namespace Ndk
|
|||
return 1;
|
||||
});
|
||||
|
||||
stream.BindMethod("Write", [] (Nz::LuaInstance& lua, Nz::Stream& stream) -> int {
|
||||
int argIndex = 1;
|
||||
stream.BindMethod("Write", [] (Nz::LuaInstance& lua, Nz::Stream& stream, std::size_t /*argumentCount*/) -> int {
|
||||
int argIndex = 2;
|
||||
|
||||
std::size_t bufferSize = 0;
|
||||
const char* buffer = lua.CheckString(argIndex, &bufferSize);
|
||||
|
|
@ -142,7 +142,7 @@ namespace Ndk
|
|||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 1U);
|
||||
|
||||
int argIndex = 1;
|
||||
int argIndex = 2;
|
||||
switch (argCount)
|
||||
{
|
||||
case 0:
|
||||
|
|
@ -201,11 +201,11 @@ namespace Ndk
|
|||
file.BindStaticMethod("Rename", &Nz::File::Rename);
|
||||
|
||||
// Manual
|
||||
file.BindMethod("Open", [] (Nz::LuaInstance& lua, Nz::File& file) -> int
|
||||
file.BindMethod("Open", [] (Nz::LuaInstance& lua, Nz::File& file, std::size_t argumentCount) -> int
|
||||
{
|
||||
unsigned int argCount = std::min(lua.GetStackTop(), 2U);
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 2U);
|
||||
|
||||
int argIndex = 1;
|
||||
int argIndex = 2;
|
||||
switch (argCount)
|
||||
{
|
||||
case 0:
|
||||
|
|
@ -224,11 +224,11 @@ namespace Ndk
|
|||
return 0;
|
||||
});
|
||||
|
||||
file.BindMethod("SetCursorPos", [] (Nz::LuaInstance& lua, Nz::File& file) -> int
|
||||
file.BindMethod("SetCursorPos", [] (Nz::LuaInstance& lua, Nz::File& file, std::size_t argumentCount) -> int
|
||||
{
|
||||
unsigned int argCount = std::min(lua.GetStackTop(), 2U);
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 2U);
|
||||
|
||||
int argIndex = 1;
|
||||
int argIndex = 2;
|
||||
switch (argCount)
|
||||
{
|
||||
case 1:
|
||||
|
|
@ -246,7 +246,7 @@ namespace Ndk
|
|||
return 0;
|
||||
});
|
||||
|
||||
file.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::File& file) -> int {
|
||||
file.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::File& file, std::size_t /*argumentCount*/) -> int {
|
||||
Nz::StringStream stream("File(");
|
||||
if (file.IsOpen())
|
||||
stream << "Path: " << file.GetPath();
|
||||
|
|
|
|||
|
|
@ -25,19 +25,19 @@ namespace Ndk
|
|||
|
||||
case 1:
|
||||
{
|
||||
if (lua.IsOfType(1, "MaterialPipeline"))
|
||||
int argIndex = 1;
|
||||
if (lua.IsOfType(argIndex, "MaterialPipeline"))
|
||||
{
|
||||
Nz::PlacementNew(instance, Nz::Material::New(*static_cast<Nz::MaterialPipelineRef*>(lua.ToUserdata(1))));
|
||||
Nz::PlacementNew(instance, Nz::Material::New(*static_cast<Nz::MaterialPipelineRef*>(lua.ToUserdata(argIndex))));
|
||||
return true;
|
||||
}
|
||||
else if (lua.IsOfType(1, "Material"))
|
||||
else if (lua.IsOfType(argIndex, "Material"))
|
||||
{
|
||||
Nz::PlacementNew(instance, Nz::Material::New(**static_cast<Nz::MaterialRef*>(lua.ToUserdata(1))));
|
||||
Nz::PlacementNew(instance, Nz::Material::New(**static_cast<Nz::MaterialRef*>(lua.ToUserdata(argIndex))));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
int argIndex = 1;
|
||||
Nz::PlacementNew(instance, Nz::Material::New(lua.Check<Nz::String>(&argIndex)));
|
||||
return true;
|
||||
}
|
||||
|
|
@ -48,16 +48,16 @@ namespace Ndk
|
|||
return false;
|
||||
});
|
||||
|
||||
material.BindMethod("Configure", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance) -> int
|
||||
material.BindMethod("Configure", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
if (lua.IsOfType(1, "MaterialPipeline"))
|
||||
int argIndex = 2;
|
||||
if (lua.IsOfType(argIndex, "MaterialPipeline"))
|
||||
{
|
||||
instance->Configure(*static_cast<Nz::MaterialPipelineRef*>(lua.ToUserdata(1)));
|
||||
instance->Configure(*static_cast<Nz::MaterialPipelineRef*>(lua.ToUserdata(argIndex)));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int argIndex = 1;
|
||||
lua.Push(instance->Configure(lua.Check<Nz::String>(&argIndex)));
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -146,106 +146,106 @@ namespace Ndk
|
|||
|
||||
material.BindStaticMethod("GetDefault", &Nz::Material::GetDefault);
|
||||
|
||||
material.BindMethod("SetAlphaMap", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance) -> int
|
||||
material.BindMethod("SetAlphaMap", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
if (lua.IsOfType(1, "Texture"))
|
||||
int argIndex = 2;
|
||||
if (lua.IsOfType(argIndex, "Texture"))
|
||||
{
|
||||
instance->SetAlphaMap(*static_cast<Nz::TextureRef*>(lua.ToUserdata(1)));
|
||||
instance->SetAlphaMap(*static_cast<Nz::TextureRef*>(lua.ToUserdata(argIndex)));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int argIndex = 1;
|
||||
lua.Push(instance->SetAlphaMap(lua.Check<Nz::String>(&argIndex)));
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
|
||||
material.BindMethod("SetDiffuseMap", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance) -> int
|
||||
material.BindMethod("SetDiffuseMap", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
if (lua.IsOfType(1, "Texture"))
|
||||
int argIndex = 2;
|
||||
if (lua.IsOfType(argIndex, "Texture"))
|
||||
{
|
||||
instance->SetDiffuseMap(*static_cast<Nz::TextureRef*>(lua.ToUserdata(1)));
|
||||
instance->SetDiffuseMap(*static_cast<Nz::TextureRef*>(lua.ToUserdata(argIndex)));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int argIndex = 1;
|
||||
lua.Push(instance->SetDiffuseMap(lua.Check<Nz::String>(&argIndex)));
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
|
||||
material.BindMethod("SetEmissiveMap", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance) -> int
|
||||
material.BindMethod("SetEmissiveMap", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
if (lua.IsOfType(1, "Texture"))
|
||||
int argIndex = 2;
|
||||
if (lua.IsOfType(argIndex, "Texture"))
|
||||
{
|
||||
instance->SetEmissiveMap(*static_cast<Nz::TextureRef*>(lua.ToUserdata(1)));
|
||||
instance->SetEmissiveMap(*static_cast<Nz::TextureRef*>(lua.ToUserdata(argIndex)));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int argIndex = 1;
|
||||
lua.Push(instance->SetEmissiveMap(lua.Check<Nz::String>(&argIndex)));
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
|
||||
material.BindMethod("SetHeightMap", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance) -> int
|
||||
material.BindMethod("SetHeightMap", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
if (lua.IsOfType(1, "Texture"))
|
||||
int argIndex = 2;
|
||||
if (lua.IsOfType(argIndex, "Texture"))
|
||||
{
|
||||
instance->SetHeightMap(*static_cast<Nz::TextureRef*>(lua.ToUserdata(1)));
|
||||
instance->SetHeightMap(*static_cast<Nz::TextureRef*>(lua.ToUserdata(argIndex)));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int argIndex = 1;
|
||||
lua.Push(instance->SetHeightMap(lua.Check<Nz::String>(&argIndex)));
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
|
||||
material.BindMethod("SetNormalMap", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance) -> int
|
||||
material.BindMethod("SetNormalMap", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
if (lua.IsOfType(1, "Texture"))
|
||||
int argIndex = 2;
|
||||
if (lua.IsOfType(argIndex, "Texture"))
|
||||
{
|
||||
instance->SetNormalMap(*static_cast<Nz::TextureRef*>(lua.ToUserdata(1)));
|
||||
instance->SetNormalMap(*static_cast<Nz::TextureRef*>(lua.ToUserdata(argIndex)));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int argIndex = 1;
|
||||
lua.Push(instance->SetNormalMap(lua.Check<Nz::String>(&argIndex)));
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
|
||||
material.BindMethod("SetShader", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance) -> int
|
||||
material.BindMethod("SetShader", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
if (lua.IsOfType(1, "UberShader"))
|
||||
int argIndex = 2;
|
||||
if (lua.IsOfType(argIndex, "UberShader"))
|
||||
{
|
||||
instance->SetShader(*static_cast<Nz::UberShaderRef*>(lua.ToUserdata(1)));
|
||||
instance->SetShader(*static_cast<Nz::UberShaderRef*>(lua.ToUserdata(argIndex)));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int argIndex = 1;
|
||||
lua.Push(instance->SetShader(lua.Check<Nz::String>(&argIndex)));
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
|
||||
material.BindMethod("SetSpecularMap", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance) -> int
|
||||
material.BindMethod("SetSpecularMap", [] (Nz::LuaInstance& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
if (lua.IsOfType(1, "Texture"))
|
||||
int argIndex = 2;
|
||||
if (lua.IsOfType(argIndex, "Texture"))
|
||||
{
|
||||
instance->SetSpecularMap(*static_cast<Nz::TextureRef*>(lua.ToUserdata(1)));
|
||||
instance->SetSpecularMap(*static_cast<Nz::TextureRef*>(lua.ToUserdata(argIndex)));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int argIndex = 1;
|
||||
lua.Push(instance->SetSpecularMap(lua.Check<Nz::String>(&argIndex)));
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ namespace Ndk
|
|||
eulerAngles.SetGetter([] (Nz::LuaInstance& lua, Nz::EulerAnglesd& instance)
|
||||
{
|
||||
std::size_t length;
|
||||
const char* ypr = lua.CheckString(1, &length);
|
||||
const char* ypr = lua.CheckString(2, &length);
|
||||
|
||||
switch (length)
|
||||
{
|
||||
|
|
@ -99,8 +99,8 @@ namespace Ndk
|
|||
eulerAngles.SetSetter([] (Nz::LuaInstance& lua, Nz::EulerAnglesd& instance)
|
||||
{
|
||||
std::size_t length;
|
||||
const char* ypr = lua.CheckString(1, &length);
|
||||
double value = lua.CheckNumber(2);
|
||||
const char* ypr = lua.CheckString(2, &length);
|
||||
double value = lua.CheckNumber(3);
|
||||
|
||||
switch (length)
|
||||
{
|
||||
|
|
@ -191,9 +191,9 @@ namespace Ndk
|
|||
|
||||
matrix4d.SetGetter([] (Nz::LuaInstance& lua, Nz::Matrix4d& instance)
|
||||
{
|
||||
int argIndex = 1;
|
||||
std::size_t index = lua.Check<std::size_t>(&argIndex);
|
||||
if (index < 1 || index > 16)
|
||||
bool succeeded = false;
|
||||
std::size_t index = static_cast<std::size_t>(lua.ToInteger(2, &succeeded));
|
||||
if (!succeeded || index < 1 || index > 16)
|
||||
return false;
|
||||
|
||||
lua.Push(instance[index - 1]);
|
||||
|
|
@ -202,12 +202,12 @@ namespace Ndk
|
|||
|
||||
matrix4d.SetSetter([] (Nz::LuaInstance& lua, Nz::Matrix4d& instance)
|
||||
{
|
||||
int argIndex = 1;
|
||||
std::size_t index = lua.Check<std::size_t>(&argIndex);
|
||||
if (index < 1 || index > 16)
|
||||
bool succeeded = false;
|
||||
std::size_t index = static_cast<std::size_t>(lua.ToInteger(2, &succeeded));
|
||||
if (!succeeded || index < 1 || index > 16)
|
||||
return false;
|
||||
|
||||
instance[index - 1] = lua.CheckNumber(argIndex);
|
||||
instance[index - 1] = lua.CheckNumber(3);
|
||||
|
||||
return true;
|
||||
});
|
||||
|
|
@ -265,11 +265,11 @@ namespace Ndk
|
|||
|
||||
rect.SetGetter([] (Nz::LuaInstance& lua, Nz::Rectd& instance)
|
||||
{
|
||||
switch (lua.GetType(1))
|
||||
switch (lua.GetType(2))
|
||||
{
|
||||
case Nz::LuaType_Number:
|
||||
{
|
||||
auto index = lua.CheckBoundInteger<std::size_t>(1);
|
||||
auto index = lua.CheckBoundInteger<std::size_t>(2);
|
||||
if (index < 1 || index > 4)
|
||||
return false;
|
||||
|
||||
|
|
@ -280,7 +280,7 @@ namespace Ndk
|
|||
case Nz::LuaType_String:
|
||||
{
|
||||
std::size_t length;
|
||||
const char* xywh = lua.CheckString(1, &length);
|
||||
const char* xywh = lua.CheckString(2, &length);
|
||||
|
||||
if (length != 1)
|
||||
break;
|
||||
|
|
@ -318,11 +318,11 @@ namespace Ndk
|
|||
|
||||
rect.SetSetter([] (Nz::LuaInstance& lua, Nz::Rectd& instance)
|
||||
{
|
||||
switch (lua.GetType(1))
|
||||
switch (lua.GetType(2))
|
||||
{
|
||||
case Nz::LuaType_Number:
|
||||
{
|
||||
auto index = lua.CheckBoundInteger<std::size_t>(1);
|
||||
auto index = lua.CheckBoundInteger<std::size_t>(2);
|
||||
if (index < 1 || index > 4)
|
||||
return false;
|
||||
|
||||
|
|
@ -333,12 +333,12 @@ namespace Ndk
|
|||
case Nz::LuaType_String:
|
||||
{
|
||||
std::size_t length;
|
||||
const char* xywh = lua.CheckString(1, &length);
|
||||
const char* xywh = lua.CheckString(2, &length);
|
||||
|
||||
if (length != 1)
|
||||
break;
|
||||
|
||||
double value = lua.CheckNumber(2);
|
||||
double value = lua.CheckNumber(3);
|
||||
|
||||
switch (xywh[0])
|
||||
{
|
||||
|
|
@ -412,7 +412,7 @@ namespace Ndk
|
|||
quaternion.SetGetter([] (Nz::LuaInstance& lua, Nz::Quaterniond& instance)
|
||||
{
|
||||
std::size_t length;
|
||||
const char* wxyz = lua.CheckString(1, &length);
|
||||
const char* wxyz = lua.CheckString(2, &length);
|
||||
|
||||
if (length != 1)
|
||||
return false;
|
||||
|
|
@ -442,12 +442,12 @@ namespace Ndk
|
|||
quaternion.SetSetter([] (Nz::LuaInstance& lua, Nz::Quaterniond& instance)
|
||||
{
|
||||
std::size_t length;
|
||||
const char* wxyz = lua.CheckString(1, &length);
|
||||
const char* wxyz = lua.CheckString(2, &length);
|
||||
|
||||
if (length != 1)
|
||||
return false;
|
||||
|
||||
double value = lua.CheckNumber(2);
|
||||
double value = lua.CheckNumber(3);
|
||||
|
||||
switch (wxyz[0])
|
||||
{
|
||||
|
|
@ -507,11 +507,11 @@ namespace Ndk
|
|||
|
||||
vector2d.SetGetter([](Nz::LuaInstance& lua, Nz::Vector2d& instance)
|
||||
{
|
||||
switch (lua.GetType(1))
|
||||
switch (lua.GetType(2))
|
||||
{
|
||||
case Nz::LuaType_Number:
|
||||
{
|
||||
long long index = lua.CheckInteger(1);
|
||||
long long index = lua.CheckInteger(2);
|
||||
if (index < 1 || index > 2)
|
||||
return false;
|
||||
|
||||
|
|
@ -522,7 +522,7 @@ namespace Ndk
|
|||
case Nz::LuaType_String:
|
||||
{
|
||||
std::size_t length;
|
||||
const char* xy = lua.CheckString(1, &length);
|
||||
const char* xy = lua.CheckString(2, &length);
|
||||
|
||||
if (length != 1)
|
||||
break;
|
||||
|
|
@ -552,27 +552,27 @@ namespace Ndk
|
|||
|
||||
vector2d.SetSetter([](Nz::LuaInstance& lua, Nz::Vector2d& instance)
|
||||
{
|
||||
switch (lua.GetType(1))
|
||||
switch (lua.GetType(2))
|
||||
{
|
||||
case Nz::LuaType_Number:
|
||||
{
|
||||
long long index = lua.CheckInteger(1);
|
||||
long long index = lua.CheckInteger(2);
|
||||
if (index < 1 || index > 2)
|
||||
return false;
|
||||
|
||||
instance[index - 1] = lua.CheckNumber(2);
|
||||
instance[index - 1] = lua.CheckNumber(3);
|
||||
return true;
|
||||
}
|
||||
|
||||
case Nz::LuaType_String:
|
||||
{
|
||||
std::size_t length;
|
||||
const char* xy = lua.CheckString(1, &length);
|
||||
const char* xy = lua.CheckString(2, &length);
|
||||
|
||||
if (length != 1)
|
||||
break;
|
||||
|
||||
double value = lua.CheckNumber(2);
|
||||
double value = lua.CheckNumber(3);
|
||||
|
||||
switch (xy[0])
|
||||
{
|
||||
|
|
@ -644,11 +644,11 @@ namespace Ndk
|
|||
|
||||
vector3d.SetGetter([] (Nz::LuaInstance& lua, Nz::Vector3d& instance)
|
||||
{
|
||||
switch (lua.GetType(1))
|
||||
switch (lua.GetType(2))
|
||||
{
|
||||
case Nz::LuaType_Number:
|
||||
{
|
||||
long long index = lua.CheckInteger(1);
|
||||
long long index = lua.CheckInteger(2);
|
||||
if (index < 1 || index > 3)
|
||||
return false;
|
||||
|
||||
|
|
@ -659,7 +659,7 @@ namespace Ndk
|
|||
case Nz::LuaType_String:
|
||||
{
|
||||
std::size_t length;
|
||||
const char* xyz = lua.CheckString(1, &length);
|
||||
const char* xyz = lua.CheckString(2, &length);
|
||||
|
||||
if (length != 1)
|
||||
break;
|
||||
|
|
@ -693,27 +693,27 @@ namespace Ndk
|
|||
|
||||
vector3d.SetSetter([] (Nz::LuaInstance& lua, Nz::Vector3d& instance)
|
||||
{
|
||||
switch (lua.GetType(1))
|
||||
switch (lua.GetType(2))
|
||||
{
|
||||
case Nz::LuaType_Number:
|
||||
{
|
||||
long long index = lua.CheckInteger(1);
|
||||
long long index = lua.CheckInteger(2);
|
||||
if (index < 1 || index > 3)
|
||||
return false;
|
||||
|
||||
instance[index - 1] = lua.CheckNumber(2);
|
||||
instance[index - 1] = lua.CheckNumber(3);
|
||||
return true;
|
||||
}
|
||||
|
||||
case Nz::LuaType_String:
|
||||
{
|
||||
std::size_t length;
|
||||
const char* xyz = lua.CheckString(1, &length);
|
||||
const char* xyz = lua.CheckString(2, &length);
|
||||
|
||||
if (length != 1)
|
||||
break;
|
||||
|
||||
double value = lua.CheckNumber(2);
|
||||
double value = lua.CheckNumber(3);
|
||||
|
||||
switch (xyz[0])
|
||||
{
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ namespace Ndk
|
|||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 9U);
|
||||
|
||||
int argIndex = 1;
|
||||
int argIndex = 2;
|
||||
switch (argCount)
|
||||
{
|
||||
case 0:
|
||||
|
|
@ -83,7 +83,7 @@ namespace Ndk
|
|||
Nz::String service;
|
||||
Nz::ResolveError error = Nz::ResolveError_Unknown;
|
||||
|
||||
int argIndex = 1;
|
||||
int argIndex = 2;
|
||||
Nz::String hostName = Nz::IpAddress::ResolveAddress(instance.Check<Nz::IpAddress>(&argIndex), &service, &error);
|
||||
|
||||
if (error == Nz::ResolveError_NoError)
|
||||
|
|
@ -104,7 +104,7 @@ namespace Ndk
|
|||
{
|
||||
Nz::ResolveError error = Nz::ResolveError_Unknown;
|
||||
|
||||
int argIndex = 1;
|
||||
int argIndex = 2;
|
||||
Nz::NetProtocol protocol = instance.Check<Nz::NetProtocol>(&argIndex);
|
||||
Nz::String hostname = instance.Check<Nz::String>(&argIndex);
|
||||
Nz::String service = instance.Check<Nz::String>(&argIndex, "http");
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ namespace Ndk
|
|||
application.BindMethod("IsFPSCounterEnabled", &Application::IsFPSCounterEnabled);
|
||||
#endif
|
||||
|
||||
application.BindMethod("AddWorld", [] (Nz::LuaInstance& instance, Application* application) -> int
|
||||
application.BindMethod("AddWorld", [] (Nz::LuaInstance& instance, Application* application, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
instance.Push(application->AddWorld().CreateHandle());
|
||||
return 1;
|
||||
|
|
@ -73,21 +73,21 @@ namespace Ndk
|
|||
entity.BindMethod("RemoveAllComponents", &Entity::RemoveAllComponents);
|
||||
entity.BindMethod("__tostring", &EntityHandle::ToString);
|
||||
|
||||
entity.BindMethod("AddComponent", [this] (Nz::LuaInstance& instance, EntityHandle& handle) -> int
|
||||
entity.BindMethod("AddComponent", [this] (Nz::LuaInstance& instance, EntityHandle& handle, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
ComponentBinding* binding = QueryComponentIndex(instance);
|
||||
|
||||
return binding->adder(instance, handle);
|
||||
});
|
||||
|
||||
entity.BindMethod("GetComponent", [this] (Nz::LuaInstance& instance, EntityHandle& handle) -> int
|
||||
entity.BindMethod("GetComponent", [this] (Nz::LuaInstance& instance, EntityHandle& handle, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
ComponentBinding* binding = QueryComponentIndex(instance);
|
||||
|
||||
return binding->getter(instance, handle->GetComponent(binding->index));
|
||||
});
|
||||
|
||||
entity.BindMethod("RemoveComponent", [this] (Nz::LuaInstance& instance, EntityHandle& handle) -> int
|
||||
entity.BindMethod("RemoveComponent", [this] (Nz::LuaInstance& instance, EntityHandle& handle, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
ComponentBinding* binding = QueryComponentIndex(instance);
|
||||
|
||||
|
|
@ -105,7 +105,7 @@ namespace Ndk
|
|||
velocityComponent.SetGetter([] (Nz::LuaInstance& lua, VelocityComponentHandle& instance)
|
||||
{
|
||||
std::size_t length;
|
||||
const char* member = lua.CheckString(1, &length);
|
||||
const char* member = lua.CheckString(2, &length);
|
||||
|
||||
if (std::strcmp(member, "Linear") == 0)
|
||||
{
|
||||
|
|
@ -119,9 +119,9 @@ namespace Ndk
|
|||
velocityComponent.SetSetter([] (Nz::LuaInstance& lua, VelocityComponentHandle& instance)
|
||||
{
|
||||
std::size_t length;
|
||||
const char* member = lua.CheckString(1, &length);
|
||||
const char* member = lua.CheckString(2, &length);
|
||||
|
||||
int argIndex = 2;
|
||||
int argIndex = 3;
|
||||
if (std::strcmp(member, "Linear") == 0)
|
||||
{
|
||||
instance->linearVelocity = lua.Check<Nz::Vector3f>(&argIndex);
|
||||
|
|
@ -139,38 +139,38 @@ namespace Ndk
|
|||
|
||||
#ifndef NDK_SERVER
|
||||
/*********************************** Ndk::GraphicsComponent **********************************/
|
||||
graphicsComponent.BindMethod("Attach", [] (Nz::LuaInstance& lua, Ndk::GraphicsComponent *gfxComponent) -> int
|
||||
graphicsComponent.BindMethod("Attach", [] (Nz::LuaInstance& lua, Ndk::GraphicsComponent *gfxComponent, std::size_t argumentCount) -> int
|
||||
{
|
||||
/*
|
||||
void Attach(Nz::InstancedRenderableRef renderable, int renderOrder = 0);
|
||||
void Attach(Nz::InstancedRenderableRef renderable, const Nz::Matrix4f& localMatrix, int renderOrder = 0);
|
||||
*/
|
||||
|
||||
unsigned int argCount = std::min(lua.GetStackTop(), 3U);
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 3U);
|
||||
|
||||
switch (argCount)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
int argIndex = 1;
|
||||
int argIndex = 2;
|
||||
gfxComponent->Attach(lua.Check<Nz::InstancedRenderableRef>(&argIndex));
|
||||
return 0;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
int index = 1;
|
||||
Nz::InstancedRenderableRef renderable = lua.Check<Nz::InstancedRenderableRef>(&index);
|
||||
int argIndex = 2;
|
||||
Nz::InstancedRenderableRef renderable = lua.Check<Nz::InstancedRenderableRef>(&argIndex);
|
||||
|
||||
if (lua.IsOfType(index, Nz::LuaType_Number))
|
||||
if (lua.IsOfType(argIndex, Nz::LuaType_Number))
|
||||
{
|
||||
int renderOrder = lua.Check<int>(&index);
|
||||
int renderOrder = lua.Check<int>(&argIndex);
|
||||
|
||||
gfxComponent->Attach(renderable, renderOrder);
|
||||
}
|
||||
else if (lua.IsOfType(index, "Matrix4"))
|
||||
else if (lua.IsOfType(argIndex, "Matrix4"))
|
||||
{
|
||||
Nz::Matrix4f localMatrix = lua.Check<Nz::Matrix4f>(&index);
|
||||
Nz::Matrix4f localMatrix = lua.Check<Nz::Matrix4f>(&argIndex);
|
||||
|
||||
gfxComponent->Attach(renderable, localMatrix);
|
||||
}
|
||||
|
|
@ -182,10 +182,10 @@ namespace Ndk
|
|||
|
||||
case 3:
|
||||
{
|
||||
int index = 1;
|
||||
Nz::InstancedRenderableRef renderable = lua.Check<Nz::InstancedRenderableRef>(&index);
|
||||
Nz::Matrix4f localMatrix = lua.Check<Nz::Matrix4f>(&index);
|
||||
int renderOrder = lua.Check<int>(&index);
|
||||
int argIndex = 2;
|
||||
Nz::InstancedRenderableRef renderable = lua.Check<Nz::InstancedRenderableRef>(&argIndex);
|
||||
Nz::Matrix4f localMatrix = lua.Check<Nz::Matrix4f>(&argIndex);
|
||||
int renderOrder = lua.Check<int>(&argIndex);
|
||||
|
||||
gfxComponent->Attach(renderable, localMatrix, renderOrder);
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@ namespace Ndk
|
|||
abstractImage.BindMethod("IsCompressed", &Nz::AbstractImage::IsCompressed);
|
||||
abstractImage.BindMethod("IsCubemap", &Nz::AbstractImage::IsCubemap);
|
||||
|
||||
abstractImage.BindMethod("GetMemoryUsage", [] (Nz::LuaInstance& lua, Nz::AbstractImage* abstractImage) -> int
|
||||
abstractImage.BindMethod("GetMemoryUsage", [] (Nz::LuaInstance& lua, Nz::AbstractImage* abstractImage, std::size_t argumentCount) -> int
|
||||
{
|
||||
unsigned int argCount = std::min(lua.GetStackTop(), 1U);
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 1U);
|
||||
switch (argCount)
|
||||
{
|
||||
case 0:
|
||||
|
|
@ -35,8 +35,8 @@ namespace Ndk
|
|||
|
||||
case 1:
|
||||
{
|
||||
int index = 1;
|
||||
Nz::UInt8 level(lua.Check<Nz::UInt8>(&index));
|
||||
int argIndex = 2;
|
||||
Nz::UInt8 level(lua.Check<Nz::UInt8>(&argIndex));
|
||||
|
||||
return lua.Push(abstractImage->GetMemoryUsage(level));
|
||||
}
|
||||
|
|
@ -46,10 +46,10 @@ namespace Ndk
|
|||
return 0;
|
||||
});
|
||||
|
||||
abstractImage.BindMethod("Update", [] (Nz::LuaInstance& lua, Nz::AbstractImage* abstractImage) -> int
|
||||
abstractImage.BindMethod("Update", [] (Nz::LuaInstance& lua, Nz::AbstractImage* abstractImage, std::size_t argumentCount) -> int
|
||||
{
|
||||
unsigned int argCount = std::min(lua.GetStackTop(), 6U);
|
||||
int argIndex = 1;
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 6U);
|
||||
int argIndex = 2;
|
||||
|
||||
std::size_t bufferSize = 0;
|
||||
const Nz::UInt8* pixels = reinterpret_cast<const Nz::UInt8*>(lua.CheckString(argIndex++, &bufferSize));
|
||||
|
|
@ -105,11 +105,11 @@ namespace Ndk
|
|||
|
||||
font.BindMethod("Destroy", &Nz::Font::Destroy);
|
||||
|
||||
font.BindMethod("GetCachedGlyphCount", [] (Nz::LuaInstance& lua, Nz::FontRef& instance) -> int
|
||||
font.BindMethod("GetCachedGlyphCount", [] (Nz::LuaInstance& lua, Nz::FontRef& instance, std::size_t argumentCount) -> int
|
||||
{
|
||||
unsigned int argCount = std::min(lua.GetStackTop(), 2U);
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 2U);
|
||||
|
||||
int argIndex = 1;
|
||||
int argIndex = 2;
|
||||
switch (argCount)
|
||||
{
|
||||
case 0:
|
||||
|
|
@ -199,9 +199,9 @@ namespace Ndk
|
|||
node.BindMethod("SetPosition", (void(Nz::Node::*)(const Nz::Vector3f&, Nz::CoordSys)) &Nz::Node::SetPosition, Nz::CoordSys_Local);
|
||||
node.BindMethod("SetRotation", (void(Nz::Node::*)(const Nz::Quaternionf&, Nz::CoordSys)) &Nz::Node::SetRotation, Nz::CoordSys_Local);
|
||||
|
||||
node.BindMethod("Move", [] (Nz::LuaInstance& lua, Nz::Node& node) -> int
|
||||
node.BindMethod("Move", [] (Nz::LuaInstance& lua, Nz::Node& node, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
int argIndex = 1;
|
||||
int argIndex = 2;
|
||||
|
||||
Nz::Vector3f offset = lua.Check<Nz::Vector3f>(&argIndex);
|
||||
Nz::CoordSys coordSys = lua.Check<Nz::CoordSys>(&argIndex, Nz::CoordSys_Local);
|
||||
|
|
@ -210,9 +210,9 @@ namespace Ndk
|
|||
return 0;
|
||||
});
|
||||
|
||||
node.BindMethod("Rotate", [] (Nz::LuaInstance& lua, Nz::Node& node) -> int
|
||||
node.BindMethod("Rotate", [] (Nz::LuaInstance& lua, Nz::Node& node, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
int argIndex = 1;
|
||||
int argIndex = 2;
|
||||
|
||||
Nz::Quaternionf rotation = lua.Check<Nz::Quaternionf>(&argIndex);
|
||||
Nz::CoordSys coordSys = lua.Check<Nz::CoordSys>(&argIndex, Nz::CoordSys_Local);
|
||||
|
|
@ -221,11 +221,11 @@ namespace Ndk
|
|||
return 0;
|
||||
});
|
||||
|
||||
node.BindMethod("Scale", [] (Nz::LuaInstance& lua, Nz::Node& node) -> int
|
||||
node.BindMethod("Scale", [] (Nz::LuaInstance& lua, Nz::Node& node, std::size_t argumentCount) -> int
|
||||
{
|
||||
unsigned int argCount = std::min(lua.GetStackTop(), 4U);
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 4U);
|
||||
|
||||
int argIndex = 1;
|
||||
int argIndex = 2;
|
||||
switch (argCount)
|
||||
{
|
||||
case 1:
|
||||
|
|
@ -247,11 +247,11 @@ namespace Ndk
|
|||
return 0;
|
||||
});
|
||||
|
||||
node.BindMethod("SetScale", [] (Nz::LuaInstance& lua, Nz::Node& node) -> int
|
||||
node.BindMethod("SetScale", [] (Nz::LuaInstance& lua, Nz::Node& node, std::size_t argumentCount) -> int
|
||||
{
|
||||
unsigned int argCount = std::min(lua.GetStackTop(), 4U);
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 4U);
|
||||
|
||||
int argIndex = 1;
|
||||
int argIndex = 2;
|
||||
switch (argCount)
|
||||
{
|
||||
case 1:
|
||||
|
|
@ -284,11 +284,11 @@ namespace Ndk
|
|||
return 0;
|
||||
});
|
||||
|
||||
node.BindMethod("SetInitialScale", [] (Nz::LuaInstance& lua, Nz::Node& node) -> int
|
||||
node.BindMethod("SetInitialScale", [] (Nz::LuaInstance& lua, Nz::Node& node, std::size_t argumentCount) -> int
|
||||
{
|
||||
unsigned int argCount = std::min(lua.GetStackTop(), 4U);
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 4U);
|
||||
|
||||
int argIndex = 1;
|
||||
int argIndex = 2;
|
||||
switch (argCount)
|
||||
{
|
||||
case 1:
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace Nz
|
|||
friend class LuaClass;
|
||||
|
||||
public:
|
||||
using ClassFunc = std::function<int(LuaInstance& lua, T& instance)>;
|
||||
using ClassFunc = std::function<int(LuaInstance& lua, T& instance, std::size_t argumentCount)>;
|
||||
using ClassIndexFunc = std::function<bool(LuaInstance& lua, T& instance)>;
|
||||
using ConstructorFunc = std::function<bool(LuaInstance& lua, T* instance, std::size_t argumentCount)>;
|
||||
template<typename P> using ConvertToParent = std::function<P*(T*)>;
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ namespace Nz
|
|||
// Let's create the metatable which will be associated with every instance.
|
||||
SetupMetatable(lua);
|
||||
|
||||
if (m_info->constructor || m_info->staticGetter || m_info->staticSetter || !m_info->staticMethods.empty())
|
||||
if (m_info->constructor || m_info->staticGetter || m_info->staticSetter || !m_staticMethods.empty())
|
||||
SetupGlobalTable(lua);
|
||||
|
||||
lua.Pop(); // Pop our ClassInfo, which is now referenced by all our functions
|
||||
|
|
@ -127,7 +127,7 @@ namespace Nz
|
|||
{
|
||||
typename LuaImplMethodProxy<Args...>::template Impl<DefArgs...> handler(std::forward<DefArgs>(defArgs)...);
|
||||
|
||||
BindMethod(name, [func, handler] (LuaInstance& lua, T& object) -> int
|
||||
BindMethod(name, [func, handler] (LuaInstance& lua, T& object, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
handler.ProcessArgs(lua);
|
||||
|
||||
|
|
@ -141,7 +141,7 @@ namespace Nz
|
|||
{
|
||||
typename LuaImplMethodProxy<Args...>::template Impl<DefArgs...> handler(std::forward<DefArgs>(defArgs)...);
|
||||
|
||||
BindMethod(name, [func, handler] (LuaInstance& lua, T& object) -> int
|
||||
BindMethod(name, [func, handler] (LuaInstance& lua, T& object, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
handler.ProcessArgs(lua);
|
||||
|
||||
|
|
@ -155,7 +155,7 @@ namespace Nz
|
|||
{
|
||||
typename LuaImplMethodProxy<Args...>::template Impl<DefArgs...> handler(std::forward<DefArgs>(defArgs)...);
|
||||
|
||||
BindMethod(name, [func, handler] (LuaInstance& lua, T& object) -> int
|
||||
BindMethod(name, [func, handler] (LuaInstance& lua, T& object, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
handler.ProcessArgs(lua);
|
||||
|
||||
|
|
@ -169,7 +169,7 @@ namespace Nz
|
|||
{
|
||||
typename LuaImplMethodProxy<Args...>::template Impl<DefArgs...> handler(std::forward<DefArgs>(defArgs)...);
|
||||
|
||||
BindMethod(name, [func, handler] (LuaInstance& lua, T& object) -> int
|
||||
BindMethod(name, [func, handler] (LuaInstance& lua, T& object, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
handler.ProcessArgs(lua);
|
||||
|
||||
|
|
@ -449,7 +449,7 @@ namespace Nz
|
|||
{
|
||||
// Query from the metatable
|
||||
lua.GetMetatable(info->name); //< Metatable
|
||||
lua.PushValue(1); //< Field
|
||||
lua.PushValue(2); //< Field
|
||||
lua.GetTable(); // Metatable[Field]
|
||||
|
||||
lua.Remove(-2); // Remove Metatable
|
||||
|
|
@ -476,7 +476,6 @@ namespace Nz
|
|||
std::shared_ptr<ClassInfo>& info = *static_cast<std::shared_ptr<ClassInfo>*>(lua.ToUserdata(lua.GetIndexOfUpValue(1)));
|
||||
|
||||
T* instance = static_cast<T*>(lua.CheckUserdata(1, info->name));
|
||||
lua.Remove(1); //< Remove the instance from the Lua stack
|
||||
|
||||
Get(info, lua, instance);
|
||||
return 1;
|
||||
|
|
@ -501,8 +500,6 @@ namespace Nz
|
|||
instance = it->second(lua);
|
||||
}
|
||||
lua.Pop(2);
|
||||
|
||||
lua.Remove(1); //< Remove the instance from the Lua stack
|
||||
}
|
||||
|
||||
if (!instance)
|
||||
|
|
@ -511,9 +508,11 @@ namespace Nz
|
|||
return 0;
|
||||
}
|
||||
|
||||
std::size_t argCount = lua.GetStackTop() - 1U;
|
||||
|
||||
unsigned int index = static_cast<unsigned int>(lua.ToInteger(lua.GetIndexOfUpValue(2)));
|
||||
const ClassFunc& method = info->methods[index];
|
||||
return method(lua, *instance);
|
||||
return method(lua, *instance, argCount);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
|
|
@ -525,7 +524,6 @@ namespace Nz
|
|||
const ClassIndexFunc& setter = info->setter;
|
||||
|
||||
T& instance = *static_cast<T*>(lua.CheckUserdata(1, info->name));
|
||||
lua.Remove(1); //< Remove the instance from the Lua stack
|
||||
|
||||
if (!setter(lua, instance))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -209,6 +209,24 @@ namespace Nz
|
|||
return LuaImplReplyVal(instance, val, TypeTag<T>());
|
||||
}
|
||||
|
||||
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<T&>)
|
||||
{
|
||||
return LuaImplReplyVal(instance, std::move(val), TypeTag<T>());
|
||||
}
|
||||
|
||||
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, std::move(val), TypeTag<T>());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
int LuaImplReplyVal(const LuaInstance& instance, T&& val, TypeTag<T&&>)
|
||||
{
|
||||
return LuaImplReplyVal(instance, std::forward<T>(val), TypeTag<T>());
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, std::string&& val, TypeTag<std::string>)
|
||||
{
|
||||
instance.PushString(val.c_str(), val.size());
|
||||
|
|
@ -375,7 +393,7 @@ namespace Nz
|
|||
|
||||
void ProcessArgs(const LuaInstance& instance) const
|
||||
{
|
||||
m_index = 1;
|
||||
m_index = 2; //< 1 being the instance
|
||||
ProcessArgs<0, Args...>(instance);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue