From 61ba30d716dab670a5f2ed0ee2f6650375b2058d Mon Sep 17 00:00:00 2001 From: Emiel Bruijntjes Date: Tue, 15 Oct 2013 05:54:52 -0700 Subject: Calling custom member methods is now functional --- src/methodmember.h | 44 +++++++++++++++++--------------------------- 1 file changed, 17 insertions(+), 27 deletions(-) (limited to 'src/methodmember.h') diff --git a/src/methodmember.h b/src/methodmember.h index 16f0dd0..20f2749 100644 --- a/src/methodmember.h +++ b/src/methodmember.h @@ -24,14 +24,7 @@ public: * @param method * @param arguments */ - MethodMember(const char *name, method_callback_0 method, const std::initializer_list &arguments = {}) : Function(name, arguments), _type(0) { _method.m0 = method; } - MethodMember(const char *name, method_callback_1 method, const std::initializer_list &arguments = {}) : Function(name, arguments), _type(1) { _method.m1 = method; } - MethodMember(const char *name, method_callback_2 method, const std::initializer_list &arguments = {}) : Function(name, arguments), _type(2) { _method.m2 = method; } - MethodMember(const char *name, method_callback_3 method, const std::initializer_list &arguments = {}) : Function(name, arguments), _type(3) { _method.m3 = method; } - MethodMember(const char *name, method_callback_4 method, const std::initializer_list &arguments = {}) : Function(name, arguments), _type(4) { _method.m4 = method; } - MethodMember(const char *name, method_callback_5 method, const std::initializer_list &arguments = {}) : Function(name, arguments), _type(5) { _method.m5 = method; } - MethodMember(const char *name, method_callback_6 method, const std::initializer_list &arguments = {}) : Function(name, arguments), _type(6) { _method.m6 = method; } - MethodMember(const char *name, method_callback_7 method, const std::initializer_list &arguments = {}) : Function(name, arguments), _type(7) { _method.m7 = method; } + MethodMember(const char *name, const _Method &method, const std::initializer_list &arguments = {}) : Function(name, arguments), _method(method) {} /** * Destructor @@ -48,34 +41,31 @@ public: * Fill a function entry object * @param entry Function entry * @param classname Name of the class + * @param pub Is this a public entry */ - virtual void fill(struct _zend_function_entry *entry, const char *classname) + virtual void fill(struct _zend_function_entry *entry, const char *classname, bool pub) { // call function object - Function::fill(entry, classname); + Function::fill(entry, classname, pub); } -private: /** - * Union of supported callbacks - * One of the callbacks will be set + * Method that gets called every time the function is executed + * @param environment Environment object + * @param params The parameters that were passed + * @return Variable Return value */ - union { - method_callback_0 m0; - method_callback_1 m1; - method_callback_2 m2; - method_callback_3 m3; - method_callback_4 m4; - method_callback_5 m5; - method_callback_6 m6; - method_callback_7 m7; - } _method; - + virtual Value invoke(Environment &environment, Parameters ¶ms) + { + return _method.invoke(environment, params); + } + +private: /** - * The method type that is set - * @var integer + * The method pointer + * @var _Method */ - int _type; + _Method _method; }; /** -- cgit v1.2.3