1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-01-31 09:57:14 +01:00

Implement move semantics on the Sqrat object wrapper.

This commit is contained in:
Sandu Liviu Catalin 2016-06-12 13:31:21 +03:00
parent 67d6f54426
commit f71a1aa667

View File

@ -83,6 +83,21 @@ public:
sq_addref(vm, &obj);
}
#ifdef SCRAT_USE_CXX11_OPTIMIZATIONS
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Move constructor
///
/// \param so Object to move
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Object(Object&& so) : vm(so.vm), obj(so.obj), release(so.release) {
sq_resetobject(&so.GetObject());
so.release = false;
}
#endif // SCRAT_USE_CXX11_OPTIMIZATIONS
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Constructs an Object from a Squirrel object
///
@ -140,6 +155,30 @@ public:
return *this;
}
#ifdef SCRAT_USE_CXX11_OPTIMIZATIONS
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Assignment operator
///
/// \param so Object to move
///
/// \return The Object itself
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Object& operator=(Object&& so) {
if(release) {
Release();
}
vm = so.vm;
obj = so.obj;
release = so.release;
sq_resetobject(&so.GetObject());
so.release = false;
return *this;
}
#endif // SCRAT_USE_CXX11_OPTIMIZATIONS
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Gets the Squirrel VM for this Object (reference)
///