Lua/LuaClass: Fix global table

This commit is contained in:
Lynix 2016-10-24 13:45:42 +02:00
parent 55a010e0de
commit 46e4bb41b5
1 changed files with 4 additions and 3 deletions

View File

@ -297,6 +297,9 @@ namespace Nz
template<class T> template<class T>
void LuaClass<T>::SetupGlobalTable(LuaInstance& lua) void LuaClass<T>::SetupGlobalTable(LuaInstance& lua)
{ {
// Create the global table
lua.PushTable(); // Class = {}
// Create a metatable which will be used for our global table // Create a metatable which will be used for our global table
lua.PushTable(); // ClassMeta = {} lua.PushTable(); // ClassMeta = {}
@ -317,9 +320,7 @@ namespace Nz
SetupMethod(lua, StaticMethodProxy, pair.first, methodIndex); SetupMethod(lua, StaticMethodProxy, pair.first, methodIndex);
} }
// Now let's create the global table lua.SetMetatable(-2); // setmetatable(Class, ClassMeta), pops ClassMeta
lua.PushTable(); // Class = {}
lua.SetMetatable(-2); // setmetatable(Class, ClassMeta)
lua.PushValue(-1); // As CreateReference() pops the table, push a copy lua.PushValue(-1); // As CreateReference() pops the table, push a copy
m_info->globalTableRef = lua.CreateReference(); m_info->globalTableRef = lua.CreateReference();