mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-03-03 18:57:28 +01:00
Implement move semantics on the Sqrat function wrapper.
This commit is contained in:
parent
3ca90d0698
commit
0240d192e9
@ -75,6 +75,21 @@ public:
|
||||
sq_addref(vm, &obj);
|
||||
}
|
||||
|
||||
#ifdef SCRAT_USE_CXX11_OPTIMIZATIONS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// Move constructor
|
||||
///
|
||||
/// \param sf Function to move
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Function(Function&& sf) : vm(sf.vm), env(sf.env), obj(sf.obj) {
|
||||
sq_resetobject(&sf.GetEnv());
|
||||
sq_resetobject(&sf.GetFunc());
|
||||
}
|
||||
|
||||
#endif // SCRAT_USE_CXX11_OPTIMIZATIONS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// Constructs a Function from a slot in an Object
|
||||
///
|
||||
@ -138,6 +153,28 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifdef SCRAT_USE_CXX11_OPTIMIZATIONS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// Assignment operator
|
||||
///
|
||||
/// \param sf Function to move
|
||||
///
|
||||
/// \return The Function itself
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Function& operator=(Function&& sf) {
|
||||
Release();
|
||||
vm = sf.vm;
|
||||
env = sf.env;
|
||||
obj = sf.obj;
|
||||
sq_resetobject(&sf.GetEnv());
|
||||
sq_resetobject(&sf.GetFunc());
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif // SCRAT_USE_CXX11_OPTIMIZATIONS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// Checks whether the Function is null
|
||||
///
|
||||
|
Loading…
x
Reference in New Issue
Block a user