diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2013-08-25 17:40:03 +0200 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2013-08-25 17:40:03 +0200 |
commit | e14055694478d70e58b5fc653b08a9a514bbc455 (patch) | |
tree | ab47d723699a7fe86f47f68c182ab695bf9b3bab /src/function.cpp | |
parent | e838e180f5bbcf19e7235f30311645e942ff92d2 (diff) |
{more work in progress: the function that was defined with c++ now gets calls, but it does not yet call the actual implementation
Diffstat (limited to 'src/function.cpp')
-rw-r--r-- | src/function.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/function.cpp b/src/function.cpp new file mode 100644 index 0000000..54f0717 --- /dev/null +++ b/src/function.cpp @@ -0,0 +1,49 @@ +/** + * Function.cpp + * + * Implementation for the function class + * + * @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com> + * @copyright 2013 Copernica BV + */ +#include "includes.h" + +/** + * Set up namespace + */ +namespace PhpCpp { + +/** + * Constructor + * @param name Name of the function + * @param arguments The arguments that can be passed to the function + */ +Function::Function(const std::string &name, const std::initializer_list<Argument> &arguments) +{ + // one reference to the callable + _refcount = new int(1); + _callable = new Callable(name, arguments); +} + +/** + * Remove one reference + */ +void Function::cleanup() +{ + // decrease number of references + (*_refcount)--; + + // leap out if there are still other references + if (*_refcount > 0) return; + + // release memory + delete _refcount; + delete _callable; +} + +/** + * End of namespace + */ +} + + |