summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/class.h88
-rw-r--r--include/classbase.h63
-rw-r--r--include/namespace.h41
-rw-r--r--include/value.h4
-rw-r--r--src/classbase.cpp170
-rw-r--r--src/namespace.cpp24
6 files changed, 272 insertions, 118 deletions
diff --git a/include/class.h b/include/class.h
index 192e653..a63d35d 100644
--- a/include/class.h
+++ b/include/class.h
@@ -78,23 +78,24 @@ public:
* @param method The actual method
* @param flags Optional flags
* @param args Argument descriptions
- */
- void method(const char *name, void (T::*method)(), int flags, const Arguments &args = {}) { ClassBase::method(name, static_cast<method_callback_0>(method), flags, args); }
- void method(const char *name, void (T::*method)(Parameters &params), int flags, const Arguments &args = {}) { ClassBase::method(name, static_cast<method_callback_1>(method), flags, args); }
- void method(const char *name, Value (T::*method)(), int flags, const Arguments &args = {}) { ClassBase::method(name, static_cast<method_callback_2>(method), flags, args); }
- void method(const char *name, Value (T::*method)(Parameters &params), int flags, const Arguments &args = {}) { ClassBase::method(name, static_cast<method_callback_3>(method), flags, args); }
- void method(const char *name, void (T::*method)(), const Arguments &args = {}) { ClassBase::method(name, static_cast<method_callback_0>(method), Public, args); }
- void method(const char *name, void (T::*method)(Parameters &params), const Arguments &args = {}) { ClassBase::method(name, static_cast<method_callback_1>(method), Public, args); }
- void method(const char *name, Value (T::*method)(), const Arguments &args = {}) { ClassBase::method(name, static_cast<method_callback_2>(method), Public, args); }
- void method(const char *name, Value (T::*method)(Parameters &params), const Arguments &args = {}) { ClassBase::method(name, static_cast<method_callback_3>(method), Public, args); }
- void method(const char *name, void (T::*method)() const, int flags, const Arguments &args = {}) { ClassBase::method(name, static_cast<method_callback_4>(method), flags, args); }
- void method(const char *name, void (T::*method)(Parameters &params) const, int flags, const Arguments &args = {}) { ClassBase::method(name, static_cast<method_callback_5>(method), flags, args); }
- void method(const char *name, Value (T::*method)() const, int flags, const Arguments &args = {}) { ClassBase::method(name, static_cast<method_callback_6>(method), flags, args); }
- void method(const char *name, Value (T::*method)(Parameters &params) const, int flags, const Arguments &args = {}) { ClassBase::method(name, static_cast<method_callback_7>(method), flags, args); }
- void method(const char *name, void (T::*method)() const, const Arguments &args = {}) { ClassBase::method(name, static_cast<method_callback_4>(method), Public, args); }
- void method(const char *name, void (T::*method)(Parameters &params) const, const Arguments &args = {}) { ClassBase::method(name, static_cast<method_callback_5>(method), Public, args); }
- void method(const char *name, Value (T::*method)() const, const Arguments &args = {}) { ClassBase::method(name, static_cast<method_callback_6>(method), Public, args); }
- void method(const char *name, Value (T::*method)(Parameters &params) const, const Arguments &args = {}) { ClassBase::method(name, static_cast<method_callback_7>(method), Public, args); }
+ * @return Class Same object to allow chaining
+ */
+ Class<T> &method(const char *name, void (T::*method)(), int flags, const Arguments &args = {}) { return ClassBase::method(name, static_cast<method_callback_0>(method), flags, args); }
+ Class<T> &method(const char *name, void (T::*method)(Parameters &params), int flags, const Arguments &args = {}) { return ClassBase::method(name, static_cast<method_callback_1>(method), flags, args); }
+ Class<T> &method(const char *name, Value (T::*method)(), int flags, const Arguments &args = {}) { return ClassBase::method(name, static_cast<method_callback_2>(method), flags, args); }
+ Class<T> &method(const char *name, Value (T::*method)(Parameters &params), int flags, const Arguments &args = {}) { return ClassBase::method(name, static_cast<method_callback_3>(method), flags, args); }
+ Class<T> &method(const char *name, void (T::*method)(), const Arguments &args = {}) { return ClassBase::method(name, static_cast<method_callback_0>(method), Public, args); }
+ Class<T> &method(const char *name, void (T::*method)(Parameters &params), const Arguments &args = {}) { return ClassBase::method(name, static_cast<method_callback_1>(method), Public, args); }
+ Class<T> &method(const char *name, Value (T::*method)(), const Arguments &args = {}) { return ClassBase::method(name, static_cast<method_callback_2>(method), Public, args); }
+ Class<T> &method(const char *name, Value (T::*method)(Parameters &params), const Arguments &args = {}) { return ClassBase::method(name, static_cast<method_callback_3>(method), Public, args); }
+ Class<T> &method(const char *name, void (T::*method)() const, int flags, const Arguments &args = {}) { return ClassBase::method(name, static_cast<method_callback_4>(method), flags, args); }
+ Class<T> &method(const char *name, void (T::*method)(Parameters &params) const, int flags, const Arguments &args = {}) { return ClassBase::method(name, static_cast<method_callback_5>(method), flags, args); }
+ Class<T> &method(const char *name, Value (T::*method)() const, int flags, const Arguments &args = {}) { return ClassBase::method(name, static_cast<method_callback_6>(method), flags, args); }
+ Class<T> &method(const char *name, Value (T::*method)(Parameters &params) const, int flags, const Arguments &args = {}) { return ClassBase::method(name, static_cast<method_callback_7>(method), flags, args); }
+ Class<T> &method(const char *name, void (T::*method)() const, const Arguments &args = {}) { return ClassBase::method(name, static_cast<method_callback_4>(method), Public, args); }
+ Class<T> &method(const char *name, void (T::*method)(Parameters &params) const, const Arguments &args = {}) { return ClassBase::method(name, static_cast<method_callback_5>(method), Public, args); }
+ Class<T> &method(const char *name, Value (T::*method)() const, const Arguments &args = {}) { return ClassBase::method(name, static_cast<method_callback_6>(method), Public, args); }
+ Class<T> &method(const char *name, Value (T::*method)(Parameters &params) const, const Arguments &args = {}) { return ClassBase::method(name, static_cast<method_callback_7>(method), Public, args); }
/**
* Add a static method to a class
@@ -110,15 +111,16 @@ public:
* @param method The actual method
* @param flags Optional flags
* @param args Argument descriptions
- */
- void method(const char *name, const native_callback_0 &function, int flags, const Arguments &args = {}) { ClassBase::method(name, function, flags, args); }
- void method(const char *name, const native_callback_1 &function, int flags, const Arguments &args = {}) { ClassBase::method(name, function, flags, args); }
- void method(const char *name, const native_callback_2 &function, int flags, const Arguments &args = {}) { ClassBase::method(name, function, flags, args); }
- void method(const char *name, const native_callback_3 &function, int flags, const Arguments &args = {}) { ClassBase::method(name, function, flags, args); }
- void method(const char *name, const native_callback_0 &function, const Arguments &args = {}) { ClassBase::method(name, function, Public, args); }
- void method(const char *name, const native_callback_1 &function, const Arguments &args = {}) { ClassBase::method(name, function, Public, args); }
- void method(const char *name, const native_callback_2 &function, const Arguments &args = {}) { ClassBase::method(name, function, Public, args); }
- void method(const char *name, const native_callback_3 &function, const Arguments &args = {}) { ClassBase::method(name, function, Public, args); }
+ * @return Class Same object to allow chaining
+ */
+ Class<T> &method(const char *name, const native_callback_0 &function, int flags, const Arguments &args = {}) { return ClassBase::method(name, function, flags, args); }
+ Class<T> &method(const char *name, const native_callback_1 &function, int flags, const Arguments &args = {}) { return ClassBase::method(name, function, flags, args); }
+ Class<T> &method(const char *name, const native_callback_2 &function, int flags, const Arguments &args = {}) { return ClassBase::method(name, function, flags, args); }
+ Class<T> &method(const char *name, const native_callback_3 &function, int flags, const Arguments &args = {}) { return ClassBase::method(name, function, flags, args); }
+ Class<T> &method(const char *name, const native_callback_0 &function, const Arguments &args = {}) { return ClassBase::method(name, function, Public, args); }
+ Class<T> &method(const char *name, const native_callback_1 &function, const Arguments &args = {}) { return ClassBase::method(name, function, Public, args); }
+ Class<T> &method(const char *name, const native_callback_2 &function, const Arguments &args = {}) { return ClassBase::method(name, function, Public, args); }
+ Class<T> &method(const char *name, const native_callback_3 &function, const Arguments &args = {}) { return ClassBase::method(name, function, Public, args); }
/**
* Add an abstract method to the class
@@ -131,8 +133,8 @@ public:
* @param flags Optional flags
* @param args Argument descriptions
*/
- void method(const char *name, int flags, const Arguments &args = {}) { ClassBase::method(name, flags | Abstract, args); }
- void method(const char *name, const Arguments &args = {}) { ClassBase::method(name, Public | Abstract, args); }
+ Class<T> &method(const char *name, int flags, const Arguments &args = {}) { return ClassBase::method(name, flags | Abstract, args); }
+ Class<T> &method(const char *name, const Arguments &args = {}) { return ClassBase::method(name, Public | Abstract, args); }
/**
* Add a property to the class
@@ -147,15 +149,15 @@ public:
* @param value Actual property value
* @param flags Optional flags
*/
- void property(const char *name, std::nullptr_t value, int flags = Public) { ClassBase::property(name, value, flags); }
- void property(const char *name, int64_t value, int flags = Public) { ClassBase::property(name, value, flags); }
- void property(const char *name, int32_t value, int flags = Public) { ClassBase::property(name, value, flags); }
- void property(const char *name, int16_t value, int flags = Public) { ClassBase::property(name, value, flags); }
- void property(const char *name, char value, int flags = Public) { ClassBase::property(name, value, flags); }
- void property(const char *name, const char *value, int flags = Public) { ClassBase::property(name, value, flags); }
- void property(const char *name, const std::string &value, int flags = Public) { ClassBase::property(name, value, flags); }
- void property(const char *name, bool value, int flags = Public) { ClassBase::property(name, value, flags); }
- void property(const char *name, double value, int flags = Public) { ClassBase::property(name, value, flags); }
+ Class<T> &property(const char *name, std::nullptr_t value, int flags = Public) { return ClassBase::property(name, value, flags); }
+ Class<T> &property(const char *name, int64_t value, int flags = Public) { return ClassBase::property(name, value, flags); }
+ Class<T> &property(const char *name, int32_t value, int flags = Public) { return ClassBase::property(name, value, flags); }
+ Class<T> &property(const char *name, int16_t value, int flags = Public) { return ClassBase::property(name, value, flags); }
+ Class<T> &property(const char *name, char value, int flags = Public) { return ClassBase::property(name, value, flags); }
+ Class<T> &property(const char *name, const char *value, int flags = Public) { return ClassBase::property(name, value, flags); }
+ Class<T> &property(const char *name, const std::string &value, int flags = Public) { return ClassBase::property(name, value, flags); }
+ Class<T> &property(const char *name, bool value, int flags = Public) { return ClassBase::property(name, value, flags); }
+ Class<T> &property(const char *name, double value, int flags = Public) { return ClassBase::property(name, value, flags); }
/**
* Properties as methods
@@ -170,12 +172,12 @@ public:
* @param getter The getter method
* @param setter The setter method
*/
- void property(const char *name, Value (T::*getter)() ) { ClassBase::property(name, static_cast<getter_callback_0>(getter)); }
- void property(const char *name, Value (T::*getter)() const ) { ClassBase::property(name, static_cast<getter_callback_1>(getter)); }
- void property(const char *name, Value (T::*getter)() , void (T::*setter)(const Value &value) ) { ClassBase::property(name, static_cast<getter_callback_0>(getter), static_cast<setter_callback_0>(setter)); }
- void property(const char *name, Value (T::*getter)() const, void (T::*setter)(const Value &value) ) { ClassBase::property(name, static_cast<getter_callback_1>(getter), static_cast<setter_callback_0>(setter)); }
- void property(const char *name, Value (T::*getter)() , void (T::*setter)(const Value &value) const) { ClassBase::property(name, static_cast<getter_callback_0>(getter), static_cast<setter_callback_1>(setter)); }
- void property(const char *name, Value (T::*getter)() const, void (T::*setter)(const Value &value) const) { ClassBase::property(name, static_cast<getter_callback_1>(getter), static_cast<setter_callback_1>(setter)); }
+ Class<T> &property(const char *name, Value (T::*getter)() ) { return ClassBase::property(name, static_cast<getter_callback_0>(getter)); }
+ Class<T> &property(const char *name, Value (T::*getter)() const ) { return ClassBase::property(name, static_cast<getter_callback_1>(getter)); }
+ Class<T> &property(const char *name, Value (T::*getter)() , void (T::*setter)(const Value &value) ) { return ClassBase::property(name, static_cast<getter_callback_0>(getter), static_cast<setter_callback_0>(setter)); }
+ Class<T> &property(const char *name, Value (T::*getter)() const, void (T::*setter)(const Value &value) ) { return ClassBase::property(name, static_cast<getter_callback_1>(getter), static_cast<setter_callback_0>(setter)); }
+ Class<T> &property(const char *name, Value (T::*getter)() , void (T::*setter)(const Value &value) const) { return ClassBase::property(name, static_cast<getter_callback_0>(getter), static_cast<setter_callback_1>(setter)); }
+ Class<T> &property(const char *name, Value (T::*getter)() const, void (T::*setter)(const Value &value) const) { return ClassBase::property(name, static_cast<getter_callback_1>(getter), static_cast<setter_callback_1>(setter)); }
private:
/**
diff --git a/include/classbase.h b/include/classbase.h
index d0c67fa..4e03f1c 100644
--- a/include/classbase.h
+++ b/include/classbase.h
@@ -224,15 +224,16 @@ protected:
* @param method The actual method
* @param flags Optional flags
* @param args Description of the supported arguments
+ * @return ClassBase Same object to allow chaining
*/
- void method(const char *name, const method_callback_0 &method, int flags=0, const Arguments &args = {});
- void method(const char *name, const method_callback_1 &method, int flags=0, const Arguments &args = {});
- void method(const char *name, const method_callback_2 &method, int flags=0, const Arguments &args = {});
- void method(const char *name, const method_callback_3 &method, int flags=0, const Arguments &args = {});
- void method(const char *name, const method_callback_4 &method, int flags=0, const Arguments &args = {});
- void method(const char *name, const method_callback_5 &method, int flags=0, const Arguments &args = {});
- void method(const char *name, const method_callback_6 &method, int flags=0, const Arguments &args = {});
- void method(const char *name, const method_callback_7 &method, int flags=0, const Arguments &args = {});
+ ClassBase &method(const char *name, const method_callback_0 &method, int flags=0, const Arguments &args = {});
+ ClassBase &method(const char *name, const method_callback_1 &method, int flags=0, const Arguments &args = {});
+ ClassBase &method(const char *name, const method_callback_2 &method, int flags=0, const Arguments &args = {});
+ ClassBase &method(const char *name, const method_callback_3 &method, int flags=0, const Arguments &args = {});
+ ClassBase &method(const char *name, const method_callback_4 &method, int flags=0, const Arguments &args = {});
+ ClassBase &method(const char *name, const method_callback_5 &method, int flags=0, const Arguments &args = {});
+ ClassBase &method(const char *name, const method_callback_6 &method, int flags=0, const Arguments &args = {});
+ ClassBase &method(const char *name, const method_callback_7 &method, int flags=0, const Arguments &args = {});
/**
* Add a static method to the class
@@ -245,11 +246,12 @@ protected:
* @param method The actual method
* @param flags Optional flags
* @param args Description of the supported arguments
+ * @return ClassBase Same object to allow chaining
*/
- void method(const char *name, const native_callback_0 &method, int flags=0, const Arguments &args = {});
- void method(const char *name, const native_callback_1 &method, int flags=0, const Arguments &args = {});
- void method(const char *name, const native_callback_2 &method, int flags=0, const Arguments &args = {});
- void method(const char *name, const native_callback_3 &method, int flags=0, const Arguments &args = {});
+ ClassBase &method(const char *name, const native_callback_0 &method, int flags=0, const Arguments &args = {});
+ ClassBase &method(const char *name, const native_callback_1 &method, int flags=0, const Arguments &args = {});
+ ClassBase &method(const char *name, const native_callback_2 &method, int flags=0, const Arguments &args = {});
+ ClassBase &method(const char *name, const native_callback_3 &method, int flags=0, const Arguments &args = {});
/**
* Add an abstract method to the class
@@ -257,8 +259,9 @@ protected:
* @param name Name of the method
* @param flags Optional flags (like public or protected)
* @param args Description of the supported arguments
+ * @return ClassBase Same object to allow chaining
*/
- void method(const char *name, int flags=0, const Arguments &args = {});
+ ClassBase &method(const char *name, int flags=0, const Arguments &args = {});
/**
* Add a property to the class
@@ -272,29 +275,31 @@ protected:
* @param name Name of the property
* @param value Actual property value
* @param flags Optional flags
+ * @return ClassBase Same object to allow chaining
*/
- void property(const char *name, std::nullptr_t value, int flags = Php::Public);
- void property(const char *name, int16_t value, int flags = Php::Public);
- void property(const char *name, int32_t value, int flags = Php::Public);
- void property(const char *name, int64_t value, int flags = Php::Public);
- void property(const char *name, bool value, int flags = Php::Public);
- void property(const char *name, char value, int flags = Php::Public);
- void property(const char *name, const std::string &value, int flags = Php::Public);
- void property(const char *name, const char *value, int flags = Php::Public);
- void property(const char *name, double value, int flags = Php::Public);
+ ClassBase &property(const char *name, std::nullptr_t value, int flags = Php::Public);
+ ClassBase &property(const char *name, int16_t value, int flags = Php::Public);
+ ClassBase &property(const char *name, int32_t value, int flags = Php::Public);
+ ClassBase &property(const char *name, int64_t value, int flags = Php::Public);
+ ClassBase &property(const char *name, bool value, int flags = Php::Public);
+ ClassBase &property(const char *name, char value, int flags = Php::Public);
+ ClassBase &property(const char *name, const std::string &value, int flags = Php::Public);
+ ClassBase &property(const char *name, const char *value, int flags = Php::Public);
+ ClassBase &property(const char *name, double value, int flags = Php::Public);
/**
* Set property with callbacks
* @param name Name of the property
* @param getter Getter method
* @param setter Setter method
- */
- void property(const char *name, const getter_callback_0 &getter);
- void property(const char *name, const getter_callback_1 &getter);
- void property(const char *name, const getter_callback_0 &getter, const setter_callback_0 &setter);
- void property(const char *name, const getter_callback_1 &getter, const setter_callback_0 &setter);
- void property(const char *name, const getter_callback_0 &getter, const setter_callback_1 &setter);
- void property(const char *name, const getter_callback_1 &getter, const setter_callback_1 &setter);
+ * @return ClassBase Same object to allow chaining
+ */
+ ClassBase &property(const char *name, const getter_callback_0 &getter);
+ ClassBase &property(const char *name, const getter_callback_1 &getter);
+ ClassBase &property(const char *name, const getter_callback_0 &getter, const setter_callback_0 &setter);
+ ClassBase &property(const char *name, const getter_callback_1 &getter, const setter_callback_0 &setter);
+ ClassBase &property(const char *name, const getter_callback_0 &getter, const setter_callback_1 &setter);
+ ClassBase &property(const char *name, const getter_callback_1 &getter, const setter_callback_1 &setter);
private:
/**
diff --git a/include/namespace.h b/include/namespace.h
index 1319976..de73924 100644
--- a/include/namespace.h
+++ b/include/namespace.h
@@ -60,90 +60,111 @@ public:
* @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 add(const char *name, const native_callback_0 &function, const Arguments &arguments = {});
- void add(const char *name, const native_callback_1 &function, const Arguments &arguments = {});
- void add(const char *name, const native_callback_2 &function, const Arguments &arguments = {});
- void add(const char *name, const native_callback_3 &function, const Arguments &arguments = {});
+ Namespace &add(const char *name, const native_callback_0 &function, const Arguments &arguments = {});
+ Namespace &add(const char *name, const native_callback_1 &function, const Arguments &arguments = {});
+ Namespace &add(const char *name, const native_callback_2 &function, const Arguments &arguments = {});
+ Namespace &add(const char *name, const native_callback_3 &function, const Arguments &arguments = {});
/**
* Add a native class to the extension by moving it
* @param type The class implementation
+ * @return Namespace Same object to allow chaining
*/
template<typename T>
- void add(Class<T> &&type)
+ Namespace &add(Class<T> &&type)
{
// make a copy of the object
auto *copy = new Class<T>(std::move(type));
// and add it to the list of classes
_classes.push_back(std::unique_ptr<ClassBase>(copy));
+
+ // allow chaining
+ return *this;
}
/**
* Add a native class to the extension by copying it
* @param type The class implementation
+ * @param Namespace Same object to allow chaining
*/
template<typename T>
- void add(const Class<T> &type)
+ Namespace &add(const Class<T> &type)
{
// make a copy of the object
auto *copy = new Class<T>(std::move(type));
// and add it to the list of classes
_classes.push_back(std::unique_ptr<ClassBase>(copy));
+
+ // allow chaining
+ return *this;
}
/**
* Add an interface to the extension by moving it
* @param interface The interface properties
*/
- void add(Interface &&interface)
+ Namespace &add(Interface &&interface)
{
// make a copy of the object
auto *copy = new Interface(std::move(interface));
// and add it to the list of classes
_classes.push_back(std::unique_ptr<ClassBase>(copy));
+
+ // allow chaining
+ return *this;
}
/**
* Add an interface to the extension by copying it
* @param interface The interface properties
*/
- void add(const Interface &interface)
+ Namespace &add(const Interface &interface)
{
// make a copy of the object
auto *copy = new Interface(interface);
// and add it to the list of classes
_classes.push_back(std::unique_ptr<ClassBase>(copy));
+
+ // allow chaining
+ return *this;
}
/**
* Add a namespace to the extension by moving it
* @param ns The namespace
*/
- void add(Namespace &&ns)
+ Namespace &add(Namespace &&ns)
{
// make a copy of the object
auto *copy = new Namespace(std::move(ns));
// add it to the list of namespaces
_namespaces.push_back(std::unique_ptr<Namespace>(copy));
+
+ // allow chaining
+ return *this;
}
/**
* Add a namespace to the extension by copying it
* @param ns The namespace
*/
- void add(const Namespace &ns)
+ Namespace &add(const Namespace &ns)
{
// make a copy of the object
auto *copy = new Namespace(std::move(ns));
// add it to the list of namespaces
_namespaces.push_back(std::unique_ptr<Namespace>(copy));
+
+ // allow chaining
+ return *this;
}
diff --git a/include/value.h b/include/value.h
index 47cebcf..36f82af 100644
--- a/include/value.h
+++ b/include/value.h
@@ -580,7 +580,7 @@ public:
*/
operator int16_t () const
{
- return numericValue();
+ return (int16_t)numericValue();
}
/**
@@ -589,7 +589,7 @@ public:
*/
operator int32_t () const
{
- return numericValue();
+ return (int32_t)numericValue();
}
/**
diff --git a/src/classbase.cpp b/src/classbase.cpp
index db32601..afb37aa 100644
--- a/src/classbase.cpp
+++ b/src/classbase.cpp
@@ -1436,11 +1436,15 @@ void ClassBase::notImplemented()
* @param method The actual method
* @param flags Optional flags
* @param args Description of the supported arguments
+ * @return ClassBase Same object to allow chaining
*/
-void ClassBase::method(const char *name, const method_callback_0 &callback, int flags, const Arguments &args)
+ClassBase &ClassBase::method(const char *name, const method_callback_0 &callback, int flags, const Arguments &args)
{
// add the method
_methods.push_back(std::make_shared<Method>(name, callback, flags, args));
+
+ // allow chaining
+ return *this;
}
/**
@@ -1449,11 +1453,15 @@ void ClassBase::method(const char *name, const method_callback_0 &callback, int
* @param method The actual method
* @param flags Optional flags
* @param args Description of the supported arguments
+ * @return ClassBase Same object to allow chaining
*/
-void ClassBase::method(const char *name, const method_callback_1 &callback, int flags, const Arguments &args)
+ClassBase &ClassBase::method(const char *name, const method_callback_1 &callback, int flags, const Arguments &args)
{
// add the method
_methods.push_back(std::make_shared<Method>(name, callback, flags, args));
+
+ // allow chaining
+ return *this;
}
/**
@@ -1462,11 +1470,15 @@ void ClassBase::method(const char *name, const method_callback_1 &callback, int
* @param method The actual method
* @param flags Optional flags
* @param args Description of the supported arguments
+ * @return ClassBase Same object to allow chaining
*/
-void ClassBase::method(const char *name, const method_callback_2 &callback, int flags, const Arguments &args)
+ClassBase &ClassBase::method(const char *name, const method_callback_2 &callback, int flags, const Arguments &args)
{
// add the method
_methods.push_back(std::make_shared<Method>(name, callback, flags, args));
+
+ // allow chaining
+ return *this;
}
/**
@@ -1475,11 +1487,15 @@ void ClassBase::method(const char *name, const method_callback_2 &callback, int
* @param method The actual method
* @param flags Optional flags
* @param args Description of the supported arguments
+ * @return ClassBase Same object to allow chaining
*/
-void ClassBase::method(const char *name, const method_callback_3 &callback, int flags, const Arguments &args)
+ClassBase &ClassBase::method(const char *name, const method_callback_3 &callback, int flags, const Arguments &args)
{
// add the method
_methods.push_back(std::make_shared<Method>(name, callback, flags, args));
+
+ // allow chaining
+ return *this;
}
/**
@@ -1488,11 +1504,15 @@ void ClassBase::method(const char *name, const method_callback_3 &callback, int
* @param method The actual method
* @param flags Optional flags
* @param args Description of the supported arguments
+ * @return ClassBase Same object to allow chaining
*/
-void ClassBase::method(const char *name, const method_callback_4 &callback, int flags, const Arguments &args)
+ClassBase &ClassBase::method(const char *name, const method_callback_4 &callback, int flags, const Arguments &args)
{
// add the method
_methods.push_back(std::make_shared<Method>(name, callback, flags, args));
+
+ // allow chaining
+ return *this;
}
/**
@@ -1501,11 +1521,15 @@ void ClassBase::method(const char *name, const method_callback_4 &callback, int
* @param method The actual method
* @param flags Optional flags
* @param args Description of the supported arguments
+ * @return ClassBase Same object to allow chaining
*/
-void ClassBase::method(const char *name, const method_callback_5 &callback, int flags, const Arguments &args)
+ClassBase &ClassBase::method(const char *name, const method_callback_5 &callback, int flags, const Arguments &args)
{
// add the method
_methods.push_back(std::make_shared<Method>(name, callback, flags, args));
+
+ // allow chaining
+ return *this;
}
/**
@@ -1514,11 +1538,15 @@ void ClassBase::method(const char *name, const method_callback_5 &callback, int
* @param method The actual method
* @param flags Optional flags
* @param args Description of the supported arguments
+ * @return ClassBase Same object to allow chaining
*/
-void ClassBase::method(const char *name, const method_callback_6 &callback, int flags, const Arguments &args)
+ClassBase &ClassBase::method(const char *name, const method_callback_6 &callback, int flags, const Arguments &args)
{
// add the method
_methods.push_back(std::make_shared<Method>(name, callback, flags, args));
+
+ // allow chaining
+ return *this;
}
/**
@@ -1527,11 +1555,15 @@ void ClassBase::method(const char *name, const method_callback_6 &callback, int
* @param method The actual method
* @param flags Optional flags
* @param args Description of the supported arguments
+ * @return ClassBase Same object to allow chaining
*/
-void ClassBase::method(const char *name, const method_callback_7 &callback, int flags, const Arguments &args)
+ClassBase &ClassBase::method(const char *name, const method_callback_7 &callback, int flags, const Arguments &args)
{
// add the method
_methods.push_back(std::make_shared<Method>(name, callback, flags, args));
+
+ // allow chaining
+ return *this;
}
/**
@@ -1540,11 +1572,15 @@ void ClassBase::method(const char *name, const method_callback_7 &callback, int
* @param method The actual method
* @param flags Optional flags
* @param args Description of the supported arguments
+ * @return ClassBase Same object to allow chaining
*/
-void ClassBase::method(const char *name, const native_callback_0 &method, int flags, const Arguments &args)
+ClassBase &ClassBase::method(const char *name, const native_callback_0 &method, int flags, const Arguments &args)
{
// add the method
_methods.push_back(std::make_shared<Method>(name, method, flags | ZEND_ACC_STATIC, args));
+
+ // allow chaining
+ return *this;
}
/**
@@ -1553,11 +1589,15 @@ void ClassBase::method(const char *name, const native_callback_0 &method, int fl
* @param method The actual method
* @param flags Optional flags
* @param args Description of the supported arguments
+ * @return ClassBase Same object to allow chaining
*/
-void ClassBase::method(const char *name, const native_callback_1 &method, int flags, const Arguments &args)
+ClassBase &ClassBase::method(const char *name, const native_callback_1 &method, int flags, const Arguments &args)
{
// add the method
_methods.push_back(std::make_shared<Method>(name, method, flags | ZEND_ACC_STATIC, args));
+
+ // allow chaining
+ return *this;
}
/**
@@ -1566,11 +1606,15 @@ void ClassBase::method(const char *name, const native_callback_1 &method, int fl
* @param method The actual method
* @param flags Optional flags
* @param args Description of the supported arguments
+ * @return ClassBase Same object to allow chaining
*/
-void ClassBase::method(const char *name, const native_callback_2 &method, int flags, const Arguments &args)
+ClassBase &ClassBase::method(const char *name, const native_callback_2 &method, int flags, const Arguments &args)
{
// add the method
_methods.push_back(std::make_shared<Method>(name, method, flags | ZEND_ACC_STATIC, args));
+
+ // allow chaining
+ return *this;
}
/**
@@ -1579,11 +1623,15 @@ void ClassBase::method(const char *name, const native_callback_2 &method, int fl
* @param method The actual method
* @param flags Optional flags
* @param args Description of the supported arguments
+ * @return ClassBase Same object to allow chaining
*/
-void ClassBase::method(const char *name, const native_callback_3 &method, int flags, const Arguments &args)
+ClassBase &ClassBase::method(const char *name, const native_callback_3 &method, int flags, const Arguments &args)
{
// add the method
_methods.push_back(std::make_shared<Method>(name, method, flags | ZEND_ACC_STATIC, args));
+
+ // allow chaining
+ return *this;
}
/**
@@ -1591,25 +1639,31 @@ void ClassBase::method(const char *name, const native_callback_3 &method, int fl
* @param name Name of the method
* @param flags Optional flags (like public or protected)
* @param args Description of the supported arguments
+ * @return ClassBase Same object to allow chaining
*/
-void ClassBase::method(const char *name, int flags, const Arguments &args)
+ClassBase &ClassBase::method(const char *name, int flags, const Arguments &args)
{
// add the method
_methods.push_back(std::make_shared<Method>(name, Abstract | flags, args));
-}
-
+ // allow chaining
+ return *this;
+}
/**
* Add a property to the class
* @param name Name of the property
* @param value Actual property value
* @param flags Optional flags
+ * @return ClassBase Same object to allow chaining
*/
-void ClassBase::property(const char *name, std::nullptr_t value, int flags)
+ClassBase &ClassBase::property(const char *name, std::nullptr_t value, int flags)
{
// add property
_members.push_back(std::make_shared<NullMember>(name, flags));
+
+ // allow chaining
+ return *this;
}
/**
@@ -1617,11 +1671,15 @@ void ClassBase::property(const char *name, std::nullptr_t value, int flags)
* @param name Name of the property
* @param value Actual property value
* @param flags Optional flags
+ * @return ClassBase Same object to allow chaining
*/
-void ClassBase::property(const char *name, int16_t value, int flags)
+ClassBase &ClassBase::property(const char *name, int16_t value, int flags)
{
// add property
_members.push_back(std::make_shared<NumericMember>(name, value, flags));
+
+ // allow chaining
+ return *this;
}
/**
@@ -1629,11 +1687,15 @@ void ClassBase::property(const char *name, int16_t value, int flags)
* @param name Name of the property
* @param value Actual property value
* @param flags Optional flags
+ * @return ClassBase Same object to allow chaining
*/
-void ClassBase::property(const char *name, int32_t value, int flags)
+ClassBase &ClassBase::property(const char *name, int32_t value, int flags)
{
// add property
_members.push_back(std::make_shared<NumericMember>(name, value, flags));
+
+ // allow chaining
+ return *this;
}
/**
@@ -1641,11 +1703,15 @@ void ClassBase::property(const char *name, int32_t value, int flags)
* @param name Name of the property
* @param value Actual property value
* @param flags Optional flags
+ * @return ClassBase Same object to allow chaining
*/
-void ClassBase::property(const char *name, int64_t value, int flags)
+ClassBase &ClassBase::property(const char *name, int64_t value, int flags)
{
// add property
_members.push_back(std::make_shared<NumericMember>(name, value, flags));
+
+ // allow chaining
+ return *this;
}
/**
@@ -1653,11 +1719,15 @@ void ClassBase::property(const char *name, int64_t value, int flags)
* @param name Name of the property
* @param value Actual property value
* @param flags Optional flags
+ * @return ClassBase Same object to allow chaining
*/
-void ClassBase::property(const char *name, bool value, int flags)
+ClassBase &ClassBase::property(const char *name, bool value, int flags)
{
// add property
_members.push_back(std::make_shared<BoolMember>(name, value, flags));
+
+ // allow chaining
+ return *this;
}
/**
@@ -1665,11 +1735,15 @@ void ClassBase::property(const char *name, bool value, int flags)
* @param name Name of the property
* @param value Actual property value
* @param flags Optional flags
+ * @return ClassBase Same object to allow chaining
*/
-void ClassBase::property(const char *name, char value, int flags)
+ClassBase &ClassBase::property(const char *name, char value, int flags)
{
// add property
_members.push_back(std::make_shared<StringMember>(name, &value, 1, flags));
+
+ // allow chaining
+ return *this;
}
/**
@@ -1677,11 +1751,15 @@ void ClassBase::property(const char *name, char value, int flags)
* @param name Name of the property
* @param value Actual property value
* @param flags Optional flags
+ * @return ClassBase Same object to allow chaining
*/
-void ClassBase::property(const char *name, const std::string &value, int flags)
+ClassBase &ClassBase::property(const char *name, const std::string &value, int flags)
{
// add property
_members.push_back(std::make_shared<StringMember>(name, value, flags));
+
+ // allow chaining
+ return *this;
}
/**
@@ -1689,11 +1767,15 @@ void ClassBase::property(const char *name, const std::string &value, int flags)
* @param name Name of the property
* @param value Actual property value
* @param flags Optional flags
+ * @return ClassBase Same object to allow chaining
*/
-void ClassBase::property(const char *name, const char *value, int flags)
+ClassBase &ClassBase::property(const char *name, const char *value, int flags)
{
// add property
_members.push_back(std::make_shared<StringMember>(name, value, strlen(value), flags));
+
+ // allow chaining
+ return *this;
}
/**
@@ -1701,33 +1783,45 @@ void ClassBase::property(const char *name, const char *value, int flags)
* @param name Name of the property
* @param value Actual property value
* @param flags Optional flags
+ * @return ClassBase Same object to allow chaining
*/
-void ClassBase::property(const char *name, double value, int flags)
+ClassBase &ClassBase::property(const char *name, double value, int flags)
{
// add property
_members.push_back(std::make_shared<FloatMember>(name, value, flags));
+
+ // allow chaining
+ return *this;
}
/**
* Set property with callbacks
* @param name Name of the property
* @param getter Getter method
+ * @return ClassBase Same object to allow chaining
*/
-void ClassBase::property(const char *name, const getter_callback_0 &getter)
+ClassBase &ClassBase::property(const char *name, const getter_callback_0 &getter)
{
// add property
_properties[name] = std::make_shared<Property>(getter);
+
+ // allow chaining
+ return *this;
}
/**
* Set property with callbacks
* @param name Name of the property
* @param getter Getter method
+ * @return ClassBase Same object to allow chaining
*/
-void ClassBase::property(const char *name, const getter_callback_1 &getter)
+ClassBase &ClassBase::property(const char *name, const getter_callback_1 &getter)
{
// add property
_properties[name] = std::make_shared<Property>(getter);
+
+ // allow chaining
+ return *this;
}
/**
@@ -1735,11 +1829,15 @@ void ClassBase::property(const char *name, const getter_callback_1 &getter)
* @param name Name of the property
* @param getter Getter method
* @param setter Setter method
+ * @return ClassBase Same object to allow chaining
*/
-void ClassBase::property(const char *name, const getter_callback_0 &getter, const setter_callback_0 &setter)
+ClassBase &ClassBase::property(const char *name, const getter_callback_0 &getter, const setter_callback_0 &setter)
{
// add property
_properties[name] = std::make_shared<Property>(getter,setter);
+
+ // allow chaining
+ return *this;
}
/**
@@ -1747,11 +1845,15 @@ void ClassBase::property(const char *name, const getter_callback_0 &getter, cons
* @param name Name of the property
* @param getter Getter method
* @param setter Setter method
+ * @return ClassBase Same object to allow chaining
*/
-void ClassBase::property(const char *name, const getter_callback_1 &getter, const setter_callback_0 &setter)
+ClassBase &ClassBase::property(const char *name, const getter_callback_1 &getter, const setter_callback_0 &setter)
{
// add property
_properties[name] = std::make_shared<Property>(getter,setter);
+
+ // allow chaining
+ return *this;
}
/**
@@ -1759,11 +1861,15 @@ void ClassBase::property(const char *name, const getter_callback_1 &getter, cons
* @param name Name of the property
* @param getter Getter method
* @param setter Setter method
+ * @return ClassBase Same object to allow chaining
*/
-void ClassBase::property(const char *name, const getter_callback_0 &getter, const setter_callback_1 &setter)
+ClassBase &ClassBase::property(const char *name, const getter_callback_0 &getter, const setter_callback_1 &setter)
{
// add property
_properties[name] = std::make_shared<Property>(getter,setter);
+
+ // allow chaining
+ return *this;
}
/**
@@ -1771,11 +1877,15 @@ void ClassBase::property(const char *name, const getter_callback_0 &getter, cons
* @param name Name of the property
* @param getter Getter method
* @param setter Setter method
+ * @return ClassBase Same object to allow chaining
*/
-void ClassBase::property(const char *name, const getter_callback_1 &getter, const setter_callback_1 &setter)
+ClassBase &ClassBase::property(const char *name, const getter_callback_1 &getter, const setter_callback_1 &setter)
{
// add property
_properties[name] = std::make_shared<Property>(getter,setter);
+
+ // allow chaining
+ return *this;
}
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;
}
/**