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/argument.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/argument.cpp')
-rw-r--r-- | src/argument.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/argument.cpp b/src/argument.cpp new file mode 100644 index 0000000..153da9c --- /dev/null +++ b/src/argument.cpp @@ -0,0 +1,60 @@ +/** + * Argument.cpp + * + * Implementation for the Argument class + * + * @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com> + * @copyright 2013 Copernica BV + */ +#include "includes.h" + +/** + * Set up namespace + */ +namespace PhpCpp { + +/** + * Constructor if this argument should be an instance of a certain class + * @param name Name of the argument + * @param classname If a specific class is required, the class type + * @param null Are NULL values allowed in stead of an instance? + * @param ref Is this a pass-by-reference argument? + */ +Argument::Argument(const std::string &name, const std::string &classname, bool null, bool ref) +{ + _refcount = new int[1]; + _info = new ArgInfo(name, classname, null, ref); +} + +/** + * Constructor if the argument can be anything + * @param name Name of the argument + * @param type Type hint + * @param ref Is this a pass-by-reference argument? + */ +Argument::Argument(const std::string &name, Type type, bool ref) +{ + _refcount = new int[1]; + _info = new ArgInfo(name, type, ref); +} + +/** + * Clean up the object + */ +void Argument::cleanup() +{ + // one reference less + (*_refcount)--; + + // leap out if still in use + if (*_refcount > 0) return; + + // release memory + delete _refcount; + delete _info; +} + +/** + * End of namespace + */ +} |