summaryrefslogtreecommitdiff
path: root/include/function.h
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2013-09-10 09:54:14 -0700
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2013-09-10 09:54:14 -0700
commit37c38c70de43d9d9ee3c9f0e2f175e19bcc0b485 (patch)
tree29cf02cfabad5eb22306ac05eaee96efbdb79cd9 /include/function.h
parent85507088051bdfabf8bc71346290949b78c3c914 (diff)
When registering functions, it now is also possible to specify the signature of the parameters
Diffstat (limited to 'include/function.h')
-rw-r--r--include/function.h67
1 files changed, 23 insertions, 44 deletions
diff --git a/include/function.h b/include/function.h
index c2dd9b8..ff4396c 100644
--- a/include/function.h
+++ b/include/function.h
@@ -32,60 +32,26 @@ public:
* @param min Min number of arguments
* @param max Max number of arguments
*/
- Function(const char *name, int min = 0, int max = 0) : _ptr(this, name)
- {
- // construct the arguments
- _arguments = std::shared_ptr<Arguments>(new Arguments(min, max));
- }
+ Function(const char *name, const std::initializer_list<Argument> &arguments = {});
/**
- * No copy constructor
- * @param function The other function
- */
- Function(const Function &function) : _ptr(this, function.name())
- {
- // copy members
- _arguments = function._arguments;
- _type = function._type;
- }
-
- /**
- * Move constructor
+ * No copy and move constructors
* @param function The other function
*/
- Function(Function &&function) : _ptr(this, function.name())
- {
- // copy arguments
- _arguments = function._arguments;
- _type = function._type;
-
- // no longer need the other arguments
- function._arguments.reset();
- }
+ Function(const Function &function) = delete;
+ Function(Function &&function) = delete;
/**
* Destructor
*/
- virtual ~Function() {}
+ virtual ~Function();
/**
- * Assignment operator
+ * No assignment operator
* @param function The other function
* @return Function
*/
- Function &operator=(const Function &function)
- {
- // skip self reference
- if (this == &function) return *this;
-
- // copy members
- _ptr.setText(function.name());
- _arguments = function._arguments;
- _type = function._type;
-
- // done
- return *this;
- }
+ Function &operator=(const Function &function) = delete;
/**
* Comparison
@@ -136,6 +102,7 @@ public:
{
return nullptr;
}
+
protected:
/**
@@ -144,11 +111,23 @@ protected:
*/
Type _type = nullType;
+ /**
+ * Required number of arguments
+ * @var integer
+ */
+ int _required;
+
+ /**
+ * Total number of arguments
+ * @var integer
+ */
+ int _argc;
+
/**
- * Pointer to the arguments
- * @var shared_ptr
+ * The arguments
+ * @var zend_arg_info[]
*/
- std::shared_ptr<Arguments> _arguments;
+ struct _zend_arg_info *_argv;
/**
* The name is stored in a hidden pointer, so that we have access to the function