Lua/LuaClass: Fix argument count via GetStackTop (Close #75)
Former-commit-id: 3a0e60a6e7ec7c85ff5f179cc84a468d8c0682f4 [formerly f0712658e69c7ced1fa46f8878f96776d6b36567] [formerly 3035b072473d17863c3c0f6950451ccf582c107e [formerly fe3cbf8a2cf87cf6cc3d3e8577011159bff04387]] Former-commit-id: df8812d712d28efc2bc83258df53dcb21bbb4b2d [formerly 6d2d8773c96d406690bd5cfc19cef7d1706ff6fc] Former-commit-id: 461fec0cc2dd99690a3de10436730514712beb73
This commit is contained in:
@@ -19,9 +19,10 @@ namespace Nz
|
||||
template<class T>
|
||||
inline void LuaClass<T>::BindDefaultConstructor()
|
||||
{
|
||||
SetConstructor([] (Nz::LuaInstance& lua, T* instance)
|
||||
SetConstructor([] (Nz::LuaInstance& lua, T* instance, std::size_t argumentCount)
|
||||
{
|
||||
NazaraUnused(lua);
|
||||
NazaraUnused(argumentCount);
|
||||
|
||||
PlacementNew(instance);
|
||||
return true;
|
||||
@@ -334,9 +335,11 @@ namespace Nz
|
||||
|
||||
lua.Remove(1); // On enlève l'argument "table" du stack
|
||||
|
||||
std::size_t argCount = lua.GetStackTop();
|
||||
|
||||
T* instance = static_cast<T*>(lua.PushUserdata(sizeof(T)));
|
||||
|
||||
if (!constructor(lua, instance))
|
||||
if (!constructor(lua, instance, argCount))
|
||||
{
|
||||
lua.Error("Constructor failed");
|
||||
return 0; // Normalement jamais exécuté (l'erreur provoquant une exception)
|
||||
|
||||
Reference in New Issue
Block a user