diff --git a/include/sqrat/sqratFunction.h b/include/sqrat/sqratFunction.h index b9d3f10c..426e6030 100644 --- a/include/sqrat/sqratFunction.h +++ b/include/sqrat/sqratFunction.h @@ -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 ///