Lua/LuaInstance: Add move constructor/operator

Former-commit-id: 654b377ce33592ef46de7897c1e0bdf6c7f07c1f [formerly 9327749669eecb4a1d1d5cf56da5b0466a3b3886] [formerly 871d797c2fa0480b80d0436da16854eeeb5e8cd9 [formerly 2cd45f642aaaa3859f66967e0e9ef99a8a3e2a16]]
Former-commit-id: 14fc3c4a28f3c596488c7d70ef4f4620678a472e [formerly 9e069af52441137bbccab5e70feb1310b5416754]
Former-commit-id: 0a6cf051bb0eb5bf439e5eb1071b83e78feacd35
This commit is contained in:
Lynix 2016-08-28 19:03:43 +02:00
parent 65740ac8ae
commit 27ceb07e55
2 changed files with 29 additions and 2 deletions

View File

@ -31,7 +31,7 @@ namespace Nz
public:
LuaInstance();
LuaInstance(const LuaInstance&) = delete;
LuaInstance(LuaInstance&&) = delete; ///TODO
inline LuaInstance(LuaInstance&& instance) noexcept;
~LuaInstance();
void ArgCheck(bool condition, unsigned int argNum, const char* error);
@ -172,7 +172,7 @@ namespace Nz
void* ToUserdata(int index, const String& tname) const;
LuaInstance& operator=(const LuaInstance&) = delete;
LuaInstance& operator=(LuaInstance&&) = delete; ///TODO
inline LuaInstance& operator=(LuaInstance&& instance) noexcept;
static int GetIndexOfUpValue(int upValue);
static LuaInstance* GetInstance(lua_State* state);

View File

@ -13,6 +13,33 @@
namespace Nz
{
inline LuaInstance::LuaInstance(LuaInstance&& instance) noexcept :
m_memoryLimit(instance.m_memoryLimit),
m_memoryUsage(instance.m_memoryUsage),
m_timeLimit(m_timeLimit),
m_clock(std::move(m_clock)),
m_lastError(std::move(m_lastError)),
m_state(m_state),
m_level(m_level)
{
instance.m_state = nullptr;
}
inline LuaInstance& LuaInstance::operator=(LuaInstance&& instance) noexcept
{
m_clock = std::move(m_clock);
m_lastError = std::move(m_lastError);
m_level = m_level;
m_memoryLimit = instance.m_memoryLimit;
m_memoryUsage = instance.m_memoryUsage;
m_state = m_state;
m_timeLimit = m_timeLimit;
instance.m_state = nullptr;
return *this;
}
// Functions args
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, bool* arg, TypeTag<bool>)
{