summaryrefslogtreecommitdiff
path: root/src/member.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/member.cpp')
-rw-r--r--src/member.cpp174
1 files changed, 174 insertions, 0 deletions
diff --git a/src/member.cpp b/src/member.cpp
index 1c32777..5a44a74 100644
--- a/src/member.cpp
+++ b/src/member.cpp
@@ -20,6 +20,8 @@ namespace Php {
*/
Member::Member(const char *name, bool pub) : _name(name), _public(pub)
{
+ std::cout << "Allocate member " << __LINE__ << std::endl;
+
// create a null member
_info = new NullMember();
}
@@ -32,6 +34,8 @@ Member::Member(const char *name, bool pub) : _name(name), _public(pub)
*/
Member::Member(const char *name, bool pub, std::nullptr_t value) : _name(name), _public(pub)
{
+ std::cout << "Allocate member " << __LINE__ << std::endl;
+
// create a null member
_info = new NullMember();
}
@@ -44,6 +48,8 @@ Member::Member(const char *name, bool pub, std::nullptr_t value) : _name(name),
*/
Member::Member(const char *name, bool pub, int value) : _name(name), _public(pub)
{
+ std::cout << "Allocate member " << __LINE__ << std::endl;
+
// create a long member
_info = new LongMember(value);
}
@@ -56,6 +62,8 @@ Member::Member(const char *name, bool pub, int value) : _name(name), _public(pub
*/
Member::Member(const char *name, bool pub, long value) : _name(name), _public(pub)
{
+ std::cout << "Allocate member " << __LINE__ << std::endl;
+
// create a long member
_info = new LongMember(value);
}
@@ -68,6 +76,8 @@ Member::Member(const char *name, bool pub, long value) : _name(name), _public(pu
*/
Member::Member(const char *name, bool pub, bool value) : _name(name), _public(pub)
{
+ std::cout << "Allocate member " << __LINE__ << std::endl;
+
// create a bool member
_info = new BoolMember(value);
}
@@ -80,6 +90,8 @@ Member::Member(const char *name, bool pub, bool value) : _name(name), _public(pu
*/
Member::Member(const char *name, bool pub, char value) : _name(name), _public(pub)
{
+ std::cout << "Allocate member " << __LINE__ << std::endl;
+
// create a new string member
_info = new StringMember(&value, 1);
}
@@ -92,6 +104,8 @@ Member::Member(const char *name, bool pub, char value) : _name(name), _public(pu
*/
Member::Member(const char *name, bool pub, const std::string &value) : _name(name), _public(pub)
{
+ std::cout << "Allocate member " << __LINE__ << std::endl;
+
// create a new string member
_info = new StringMember(value);
}
@@ -105,6 +119,8 @@ Member::Member(const char *name, bool pub, const std::string &value) : _name(nam
*/
Member::Member(const char *name, bool pub, const char *value, int size) : _name(name), _public(pub)
{
+ std::cout << "Allocate member " << __LINE__ << std::endl;
+
// create a new string member
if (size < 0) size = strlen(value);
_info = new StringMember(value, size);
@@ -118,16 +134,140 @@ Member::Member(const char *name, bool pub, const char *value, int size) : _name(
*/
Member::Member(const char *name, bool pub, double value) : _name(name), _public(pub)
{
+ std::cout << "Allocate member " << __LINE__ << std::endl;
+
// create a new double member
_info = new DoubleMember(value);
}
/**
+ * Constructor
+ * @param name Name of the member
+ * @param pub Is this a public property (otherwise it is protected)
+ * @param method The method to call
+ * @param arguments Argument meta data
+ */
+Member::Member(const char *name, bool pub, method_callback_0 method, const std::initializer_list<Argument> &arguments) : _name(name), _public(pub)
+{
+ std::cout << "Allocate member " << __LINE__ << std::endl;
+
+ // create method member
+ _info = new MethodMember(name, method, arguments);
+}
+
+/**
+ * Constructor
+ * @param name Name of the member
+ * @param pub Is this a public property (otherwise it is protected)
+ * @param method The method to call
+ * @param arguments Argument meta data
+ */
+Member::Member(const char *name, bool pub, method_callback_1 method, const std::initializer_list<Argument> &arguments) : _name(name), _public(pub)
+{
+ std::cout << "Allocate member " << __LINE__ << std::endl;
+
+ // create method member
+ _info = new MethodMember(name, method, arguments);
+}
+
+/**
+ * Constructor
+ * @param name Name of the member
+ * @param pub Is this a public property (otherwise it is protected)
+ * @param method The method to call
+ * @param arguments Argument meta data
+ */
+Member::Member(const char *name, bool pub, method_callback_2 method, const std::initializer_list<Argument> &arguments) : _name(name), _public(pub)
+{
+ std::cout << "Allocate member " << __LINE__ << std::endl;
+
+ // create method member
+ _info = new MethodMember(name, method, arguments);
+}
+
+/**
+ * Constructor
+ * @param name Name of the member
+ * @param pub Is this a public property (otherwise it is protected)
+ * @param method The method to call
+ * @param arguments Argument meta data
+ */
+Member::Member(const char *name, bool pub, method_callback_3 method, const std::initializer_list<Argument> &arguments) : _name(name), _public(pub)
+{
+ std::cout << "Allocate member " << __LINE__ << std::endl;
+
+ // create method member
+ _info = new MethodMember(name, method, arguments);
+}
+
+/**
+ * Constructor
+ * @param name Name of the member
+ * @param pub Is this a public property (otherwise it is protected)
+ * @param method The method to call
+ * @param arguments Argument meta data
+ */
+Member::Member(const char *name, bool pub, method_callback_4 method, const std::initializer_list<Argument> &arguments) : _name(name), _public(pub)
+{
+ std::cout << "Allocate member " << __LINE__ << std::endl;
+
+ // create method member
+ _info = new MethodMember(name, method, arguments);
+}
+
+/**
+ * Constructor
+ * @param name Name of the member
+ * @param pub Is this a public property (otherwise it is protected)
+ * @param method The method to call
+ * @param arguments Argument meta data
+ */
+Member::Member(const char *name, bool pub, method_callback_5 method, const std::initializer_list<Argument> &arguments) : _name(name), _public(pub)
+{
+ std::cout << "Allocate member " << __LINE__ << std::endl;
+
+ // create method member
+ _info = new MethodMember(name, method, arguments);
+}
+
+/**
+ * Constructor
+ * @param name Name of the member
+ * @param pub Is this a public property (otherwise it is protected)
+ * @param method The method to call
+ * @param arguments Argument meta data
+ */
+Member::Member(const char *name, bool pub, method_callback_6 method, const std::initializer_list<Argument> &arguments) : _name(name), _public(pub)
+{
+ std::cout << "Allocate member " << __LINE__ << std::endl;
+
+ // create method member
+ _info = new MethodMember(name, method, arguments);
+}
+
+/**
+ * Constructor
+ * @param name Name of the member
+ * @param pub Is this a public property (otherwise it is protected)
+ * @param method The method to call
+ * @param arguments Argument meta data
+ */
+Member::Member(const char *name, bool pub, method_callback_7 method, const std::initializer_list<Argument> &arguments) : _name(name), _public(pub)
+{
+ std::cout << "Allocate member " << __LINE__ << std::endl;
+
+ // create method member
+ _info = new MethodMember(name, method, arguments);
+}
+
+/**
* Copy constructor
* @param member The member to copy
*/
Member::Member(const Member &member)
{
+ std::cout << "Allocate member " << __LINE__ << std::endl;
+
// copy info object, and name and public members
_info = member._info;
_name = member._name;
@@ -143,6 +283,8 @@ Member::Member(const Member &member)
*/
Member::Member(Member &&member)
{
+ std::cout << "Allocate member " << __LINE__ << std::endl;
+
// move info object, and name and public properties
_info = member._info;
_name = std::move(member._name);
@@ -165,6 +307,26 @@ Member::~Member()
}
/**
+ * Is this a property member
+ * @return bool
+ */
+bool Member::isProperty()
+{
+ return _info && _info->isProperty();
+}
+
+/**
+ * Is this a method member
+ * @return bool
+ */
+bool Member::isMethod()
+{
+ std::cout << "call isMethod" << std::endl;
+
+ return _info && _info->isMethod();
+}
+
+/**
* Internal method to declare the property
* @var zend_class_entry
*/
@@ -173,6 +335,18 @@ void Member::declare(struct _zend_class_entry *entry)
// let the info object handle stuff
_info->declare(entry, _name.c_str(), _name.size(), _public ? ZEND_ACC_PUBLIC : ZEND_ACC_PROTECTED TSRMLS_CC);
}
+
+/**
+ * Internal method to fill a function entry
+ * @param zend_function_entry
+ * @param classname
+ * @internal
+ */
+void Member::fill(struct _zend_function_entry *entry, const char *classname)
+{
+ // let the info object do this
+ _info->fill(entry, classname);
+}
/**
* End of namespace