Lua/LuaState: Fix movement not stealing pointer
This commit is contained in:
@@ -33,7 +33,7 @@ namespace Nz
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LuaState(const LuaState&) = default;
|
LuaState(const LuaState&) = default;
|
||||||
LuaState(LuaState&& instance) noexcept;
|
inline LuaState(LuaState&& instance) noexcept;
|
||||||
~LuaState() = default;
|
~LuaState() = default;
|
||||||
|
|
||||||
void ArgCheck(bool condition, unsigned int argNum, const char* error) const;
|
void ArgCheck(bool condition, unsigned int argNum, const char* error) const;
|
||||||
@@ -174,7 +174,7 @@ namespace Nz
|
|||||||
void* ToUserdata(int index, const String& tname) const;
|
void* ToUserdata(int index, const String& tname) const;
|
||||||
|
|
||||||
LuaState& operator=(const LuaState&) = default;
|
LuaState& operator=(const LuaState&) = default;
|
||||||
LuaState& operator=(LuaState&& instance) noexcept;
|
inline LuaState& operator=(LuaState&& instance) noexcept;
|
||||||
|
|
||||||
static int GetIndexOfUpValue(int upValue);
|
static int GetIndexOfUpValue(int upValue);
|
||||||
static LuaInstance& GetInstance(lua_State* internalState);
|
static LuaInstance& GetInstance(lua_State* internalState);
|
||||||
|
|||||||
@@ -20,6 +20,13 @@ namespace Nz
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline LuaState::LuaState(LuaState&& state) noexcept :
|
||||||
|
m_lastError(state.m_lastError),
|
||||||
|
m_state(state.m_state)
|
||||||
|
{
|
||||||
|
state.m_state = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
inline lua_State* LuaState::GetInternalState() const
|
inline lua_State* LuaState::GetInternalState() const
|
||||||
{
|
{
|
||||||
return m_state;
|
return m_state;
|
||||||
@@ -770,6 +777,16 @@ namespace Nz
|
|||||||
SetMetatable(tname);
|
SetMetatable(tname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline LuaState& LuaState::operator=(LuaState&& state) noexcept
|
||||||
|
{
|
||||||
|
m_lastError = std::move(state.m_lastError);
|
||||||
|
m_state = state.m_state;
|
||||||
|
|
||||||
|
state.m_state = nullptr;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
std::enable_if_t<std::is_signed<T>::value, T> LuaState::CheckBounds(int index, long long value) const
|
std::enable_if_t<std::is_signed<T>::value, T> LuaState::CheckBounds(int index, long long value) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -126,12 +126,6 @@ namespace Nz
|
|||||||
static_assert(sizeof(s_types)/sizeof(int) == LuaType_Max+1, "Lua type array is incomplete");
|
static_assert(sizeof(s_types)/sizeof(int) == LuaType_Max+1, "Lua type array is incomplete");
|
||||||
}
|
}
|
||||||
|
|
||||||
LuaState::LuaState(LuaState&& state) noexcept :
|
|
||||||
m_lastError(state.m_lastError),
|
|
||||||
m_state(state.m_state)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void LuaState::ArgCheck(bool condition, unsigned int argNum, const char* error) const
|
void LuaState::ArgCheck(bool condition, unsigned int argNum, const char* error) const
|
||||||
{
|
{
|
||||||
luaL_argcheck(m_state, condition, argNum, error);
|
luaL_argcheck(m_state, condition, argNum, error);
|
||||||
@@ -789,14 +783,6 @@ namespace Nz
|
|||||||
return luaL_testudata(m_state, index, tname.GetConstBuffer());
|
return luaL_testudata(m_state, index, tname.GetConstBuffer());
|
||||||
}
|
}
|
||||||
|
|
||||||
LuaState& LuaState::operator=(LuaState&& state) noexcept
|
|
||||||
{
|
|
||||||
m_lastError = std::move(state.m_lastError);
|
|
||||||
m_state = state.m_state;
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LuaState::Run(int argCount, int resultCount)
|
bool LuaState::Run(int argCount, int resultCount)
|
||||||
{
|
{
|
||||||
LuaInstance& instance = GetInstance(m_state);
|
LuaInstance& instance = GetInstance(m_state);
|
||||||
|
|||||||
Reference in New Issue
Block a user