Lua/LuaInstance: Add PushInstance
Former-commit-id: 0e65124d5920a1b5ea3c644e496ae58ddee1cd8e
This commit is contained in:
@@ -404,4 +404,18 @@ namespace Nz
|
||||
return handler.Invoke(func);
|
||||
});
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void LuaInstance::PushInstance(const char* tname, T* instance)
|
||||
{
|
||||
T** userdata = static_cast<T**>(PushUserdata(sizeof(T*)));
|
||||
*userdata = instance;
|
||||
SetMetatable(tname);
|
||||
}
|
||||
|
||||
template<typename T, typename... Args>
|
||||
void LuaInstance::PushInstance(const char* tname, Args&&... args)
|
||||
{
|
||||
PushInstance(tname, new T(std::forward<Args>(args)...));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user