diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/callable.h | 28 | ||||
-rw-r--r-- | src/function.h | 12 | ||||
-rw-r--r-- | src/method.h | 8 |
3 files changed, 46 insertions, 2 deletions
diff --git a/src/callable.h b/src/callable.h index 5b32558..9b5cdcd 100644 --- a/src/callable.h +++ b/src/callable.h @@ -49,13 +49,39 @@ public: // @todo find out number of required arguments _required = _argc; } + + /** + * Copy constructor + * @param that + */ + Callable(const Callable &that) : + _ptr(that._ptr), + _return(that._return), + _required(that._required), + _argc(that._argc), + _argv(nullptr) {} + + /** + * Move constructor + * @param that + */ + Callable(Callable &&that) : + _ptr(std::move(that._ptr)), + _return(that._return), + _required(that._required), + _argc(that._argc), + _argv(that._argv) + { + // invalidate other object + that._argv = nullptr; + } /** * Destructor */ virtual ~Callable() { - delete[] _argv; + if (_argv) delete[] _argv; } /** diff --git a/src/function.h b/src/function.h index 40c392f..eabc2e2 100644 --- a/src/function.h +++ b/src/function.h @@ -30,6 +30,18 @@ public: Function(const char *name, native_callback_3 function, const Arguments &arguments = {}) : Callable(name, arguments), _type(3) { _function.f3 = function; } /** + * Copy constructor + * @param that + */ + Function(const Function &that) : Callable(that), _function(that._function), _type(that._type) {} + + /** + * Move constructor + * @param that + */ + Function(Function &&that) : Callable(std::move(that)), _function(that._function), _type(that._type) {} + + /** * Destructor */ virtual ~Function() {} diff --git a/src/method.h b/src/method.h index 8b545b0..f583fc8 100644 --- a/src/method.h +++ b/src/method.h @@ -34,6 +34,13 @@ public: Method(const char *name, int flags, const Arguments &args) : Callable(name, args), _type(4), _flags(flags) { _callback.m0 = nullptr; } /** + * Copy and move constructors + * @param that + */ + Method(const Method &that) : Callable(that), _type(that._type), _flags(that._flags), _callback(that._callback) {} + Method(Method &&that) : Callable(std::move(that)), _type(that._type), _flags(that._flags), _callback(that._callback) {} + + /** * Destructor * @param type * @param callback @@ -86,7 +93,6 @@ private: /** * Access flags (protected, public, abstract, final, private, etc) * @var int - * @todo use this */ int _flags; |