summaryrefslogtreecommitdiff
path: root/src/namespace.cpp
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-03-29 14:57:47 +0100
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-03-29 14:57:47 +0100
commit6a760adf754ed4b736b2a2e4c08936f005a71bcb (patch)
tree88345e2941d09db3e3cae20f7ad67b3ba55bf39b /src/namespace.cpp
parentb21f7778fb106a425467c7ee5819e544ef0a2de8 (diff)
all methods to register functions, methods, properties and classes not return *this, to allow chaining these methods. This was suggested by valmat in issue #55
Diffstat (limited to 'src/namespace.cpp')
-rw-r--r--src/namespace.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/namespace.cpp b/src/namespace.cpp
index fd5b37e..e828112 100644
--- a/src/namespace.cpp
+++ b/src/namespace.cpp
@@ -18,11 +18,15 @@ namespace Php {
* @param name Name of the function
* @param function The function to add
* @param arguments Optional argument specification
+ * @return Namespace Same object to allow chaining
*/
-void Namespace::add(const char *name, const native_callback_0 &function, const Arguments &arguments)
+Namespace &Namespace::add(const char *name, const native_callback_0 &function, const Arguments &arguments)
{
// add a function
_functions.push_back(std::make_shared<Function>(name, function, arguments));
+
+ // allow chaining
+ return *this;
}
/**
@@ -30,11 +34,15 @@ void Namespace::add(const char *name, const native_callback_0 &function, const A
* @param name Name of the function
* @param function The function to add
* @param arguments Optional argument specification
+ * @return Namespace Same object to allow chaining
*/
-void Namespace::add(const char *name, const native_callback_1 &function, const Arguments &arguments)
+Namespace &Namespace::add(const char *name, const native_callback_1 &function, const Arguments &arguments)
{
// add a function
_functions.push_back(std::make_shared<Function>(name, function, arguments));
+
+ // allow chaining
+ return *this;
}
/**
@@ -42,11 +50,15 @@ void Namespace::add(const char *name, const native_callback_1 &function, const A
* @param name Name of the function
* @param function The function to add
* @param arguments Optional argument specification
+ * @return Namespace Same object to allow chaining
*/
-void Namespace::add(const char *name, const native_callback_2 &function, const Arguments &arguments)
+Namespace &Namespace::add(const char *name, const native_callback_2 &function, const Arguments &arguments)
{
// add a function
_functions.push_back(std::make_shared<Function>(name, function, arguments));
+
+ // allow chaining
+ return *this;
}
/**
@@ -54,11 +66,15 @@ void Namespace::add(const char *name, const native_callback_2 &function, const A
* @param name Name of the function
* @param function The function to add
* @param arguments Optional argument specification
+ * @return Namespace Same object to allow chaining
*/
-void Namespace::add(const char *name, const native_callback_3 &function, const Arguments &arguments)
+Namespace &Namespace::add(const char *name, const native_callback_3 &function, const Arguments &arguments)
{
// add a function
_functions.push_back(std::make_shared<Function>(name, function, arguments));
+
+ // allow chaining
+ return *this;
}
/**