diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2013-09-10 09:54:14 -0700 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2013-09-10 09:54:14 -0700 |
commit | 37c38c70de43d9d9ee3c9f0e2f175e19bcc0b485 (patch) | |
tree | 29cf02cfabad5eb22306ac05eaee96efbdb79cd9 /include/argument.h | |
parent | 85507088051bdfabf8bc71346290949b78c3c914 (diff) |
When registering functions, it now is also possible to specify the signature of the parameters
Diffstat (limited to 'include/argument.h')
-rw-r--r-- | include/argument.h | 71 |
1 files changed, 32 insertions, 39 deletions
diff --git a/include/argument.h b/include/argument.h index 7a95f7d..c29073d 100644 --- a/include/argument.h +++ b/include/argument.h @@ -4,6 +4,9 @@ * Class holds information about an argument that is passed to a function. * You'll need this class when you're defining your own functions. * + * The constructor of the argument is protected. Use the ByVal or ByRef + * classes instead. + * * @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com> * @copyright 2013 Copernica BV */ @@ -25,65 +28,49 @@ class Argument { public: /** - * Prevent copying + * Copy constructor * @param argument */ - Argument(const Argument &argument) = delete; - + Argument(const Argument &argument); + /** * Move constructor * @param argument */ Argument(Argument &&argument); - + /** * Destructor */ - virtual ~Argument() {}; - - /** - * Change the name - * @param name - * @return Argument - */ - Argument &name(const char *name); - - /** - * Change the type - * @param type - * @return Argument - */ - Argument &type(Type type = nullType); + virtual ~Argument(); +protected: /** - * Require the parameter to be a certain class - * @param name Name of the class - * @param null Are null values allowed? - * @return Argument + * Constructor + * @param name Name of the argument + * @param type Argument type + * @param required Is this argument required? + * @param byref Is this a reference argument */ - Argument &object(const char *classname, bool null = true); + Argument(const char *name, Type type, bool required = true, bool byref = false); /** - * Is this a by-ref argument? - * @param bool Mark as by-ref variable - * @return Argument + * Constructor + * @param name Name of the argument + * @param classname Name of the class + * @param nullable Can it be null? + * @param required Is this argument required? + * @param byref Is this a reference argument? */ - Argument &byref(bool value = true); + Argument(const char *name, const char *classname, bool nullable = true, bool required = true, bool byref = false); +public: /** - * Prevent copy - * @param argument The argument to copy - * @return Argument - */ - Argument &operator=(const Argument &argument) = delete; - -protected: - /** - * Protected constructor, to prevent that users can instantiate the - * argument object themselves + * Fill an arg_info structure with data * @param info + * @internal */ - Argument(struct _zend_arg_info *info) : _info(info) {} + void fill(struct _zend_arg_info *info) const; private: /** @@ -91,6 +78,12 @@ private: * @var zend_arg_info */ struct _zend_arg_info *_info; + + /** + * Is this a required argument + * @var bool + */ + bool _required; }; /** |