Lua/LuaState: Fix movement not stealing pointer
This commit is contained in:
parent
9f52932327
commit
305a72a7d2
|
|
@ -33,7 +33,7 @@ namespace Nz
|
|||
{
|
||||
public:
|
||||
LuaState(const LuaState&) = default;
|
||||
LuaState(LuaState&& instance) noexcept;
|
||||
inline LuaState(LuaState&& instance) noexcept;
|
||||
~LuaState() = default;
|
||||
|
||||
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;
|
||||
|
||||
LuaState& operator=(const LuaState&) = default;
|
||||
LuaState& operator=(LuaState&& instance) noexcept;
|
||||
inline LuaState& operator=(LuaState&& instance) noexcept;
|
||||
|
||||
static int GetIndexOfUpValue(int upValue);
|
||||
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
|
||||
{
|
||||
return m_state;
|
||||
|
|
@ -770,6 +777,16 @@ namespace Nz
|
|||
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>
|
||||
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");
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
luaL_argcheck(m_state, condition, argNum, error);
|
||||
|
|
@ -789,14 +783,6 @@ namespace Nz
|
|||
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)
|
||||
{
|
||||
LuaInstance& instance = GetInstance(m_state);
|
||||
|
|
|
|||
Loading…
Reference in New Issue