Lua/LuaInstance: Fix movement
This commit is contained in:
parent
5ec913311f
commit
bb272c57f5
|
|
@ -31,7 +31,7 @@ namespace Nz
|
|||
public:
|
||||
LuaInstance();
|
||||
LuaInstance(const LuaInstance&) = delete;
|
||||
inline LuaInstance(LuaInstance&& instance) noexcept;
|
||||
LuaInstance(LuaInstance&& instance) noexcept;
|
||||
~LuaInstance();
|
||||
|
||||
void ArgCheck(bool condition, unsigned int argNum, const char* error) const;
|
||||
|
|
@ -173,7 +173,7 @@ namespace Nz
|
|||
void* ToUserdata(int index, const String& tname) const;
|
||||
|
||||
LuaInstance& operator=(const LuaInstance&) = delete;
|
||||
inline LuaInstance& operator=(LuaInstance&& instance) noexcept;
|
||||
LuaInstance& operator=(LuaInstance&& instance) noexcept;
|
||||
|
||||
static int GetIndexOfUpValue(int upValue);
|
||||
static LuaInstance* GetInstance(lua_State* state);
|
||||
|
|
|
|||
|
|
@ -14,18 +14,6 @@
|
|||
|
||||
namespace Nz
|
||||
{
|
||||
inline LuaInstance::LuaInstance(LuaInstance&& instance) noexcept :
|
||||
m_memoryLimit(instance.m_memoryLimit),
|
||||
m_memoryUsage(instance.m_memoryUsage),
|
||||
m_timeLimit(instance.m_timeLimit),
|
||||
m_clock(std::move(instance.m_clock)),
|
||||
m_lastError(std::move(instance.m_lastError)),
|
||||
m_state(instance.m_state),
|
||||
m_level(instance.m_level)
|
||||
{
|
||||
instance.m_state = nullptr;
|
||||
}
|
||||
|
||||
inline lua_State* LuaInstance::GetInternalState() const
|
||||
{
|
||||
return m_state;
|
||||
|
|
@ -51,21 +39,6 @@ namespace Nz
|
|||
return m_timeLimit;
|
||||
}
|
||||
|
||||
inline LuaInstance& LuaInstance::operator=(LuaInstance&& instance) noexcept
|
||||
{
|
||||
m_clock = std::move(instance.m_clock);
|
||||
m_lastError = std::move(instance.m_lastError);
|
||||
m_level = instance.m_level;
|
||||
m_memoryLimit = instance.m_memoryLimit;
|
||||
m_memoryUsage = instance.m_memoryUsage;
|
||||
m_state = instance.m_state;
|
||||
m_timeLimit = instance.m_timeLimit;
|
||||
|
||||
instance.m_state = nullptr;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Functions args
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, bool* arg, TypeTag<bool>)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -143,6 +143,20 @@ namespace Nz
|
|||
luaL_openlibs(m_state);
|
||||
}
|
||||
|
||||
LuaInstance::LuaInstance(LuaInstance&& instance) noexcept :
|
||||
m_memoryLimit(instance.m_memoryLimit),
|
||||
m_memoryUsage(instance.m_memoryUsage),
|
||||
m_timeLimit(instance.m_timeLimit),
|
||||
m_clock(std::move(instance.m_clock)),
|
||||
m_lastError(std::move(instance.m_lastError)),
|
||||
m_state(instance.m_state),
|
||||
m_level(instance.m_level)
|
||||
{
|
||||
instance.m_state = nullptr;
|
||||
|
||||
lua_setallocf(m_state, MemoryAllocator, this);
|
||||
}
|
||||
|
||||
LuaInstance::~LuaInstance()
|
||||
{
|
||||
if (m_state)
|
||||
|
|
@ -801,6 +815,24 @@ namespace Nz
|
|||
return luaL_testudata(m_state, index, tname.GetConstBuffer());
|
||||
}
|
||||
|
||||
LuaInstance& LuaInstance::operator=(LuaInstance&& instance) noexcept
|
||||
{
|
||||
m_clock = std::move(instance.m_clock);
|
||||
m_lastError = std::move(instance.m_lastError);
|
||||
m_level = instance.m_level;
|
||||
m_memoryLimit = instance.m_memoryLimit;
|
||||
m_memoryUsage = instance.m_memoryUsage;
|
||||
m_state = instance.m_state;
|
||||
m_timeLimit = instance.m_timeLimit;
|
||||
|
||||
instance.m_state = nullptr;
|
||||
|
||||
// Update allocator pointer
|
||||
lua_setallocf(m_state, MemoryAllocator, this);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
int LuaInstance::GetIndexOfUpValue(int upValue)
|
||||
{
|
||||
return lua_upvalueindex(upValue);
|
||||
|
|
|
|||
Loading…
Reference in New Issue