From b7729b98bbd91dcff66c3712f85f477dbd86d4a3 Mon Sep 17 00:00:00 2001 From: Toon Schoenmakers Date: Mon, 18 May 2015 14:42:36 +0200 Subject: We are now ABI compatible with the latest release again --- include/value.h | 16 ++++++++++++++++ zend/value.cpp | 27 +++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/include/value.h b/include/value.h index 9959a9c..ca3fb9d 100644 --- a/include/value.h +++ b/include/value.h @@ -1003,6 +1003,7 @@ public: * @return Value */ Value call(const char *name) const; + Value call(const char *name); /** * @@ -1025,6 +1026,20 @@ public: return exec(name, sizeof...(Args), params); } + template + Value call(const char *name, Args&&... args) + { + // store arguments + Value vargs[] = { static_cast(args)... }; + + // array of parameters + _zval_struct **params[sizeof...(Args)]; + for(unsigned i=0; i < sizeof...(Args); i++) {params[i] = &vargs[i]._val;} + + // call the function + return exec(name, sizeof...(Args), params); + } + /** * Retrieve the original implementation * @@ -1108,6 +1123,7 @@ private: * @return Value */ Value exec(const char *name, int argc, struct _zval_struct ***params) const; + Value exec(const char *name, int argc, struct _zval_struct ***params); /** * Refcount - the number of references to the value diff --git a/zend/value.cpp b/zend/value.cpp index a728dcc..9fb59f4 100644 --- a/zend/value.cpp +++ b/zend/value.cpp @@ -883,6 +883,17 @@ Value Value::call(const char *name) const return exec(name, 0, NULL); } +/** + * Call the method - if the variable holds an object with the given method + * @param name name of the method to call + * @return Value + */ +Value Value::call(const char *name) +{ + // call with zero parameters + return exec(name, 0, NULL); +} + /** * Helper function that runs the actual call * @param object The object to call it on @@ -952,6 +963,22 @@ Value Value::exec(const char *name, int argc, struct _zval_struct ***params) con return do_exec(&_val, method._val, argc, params); } +/** + * Call method with a number of parameters + * @param name Name of method to call + * @param argc Number of parameters + * @param argv The parameters + * @return Value + */ +Value Value::exec(const char *name, int argc, struct _zval_struct ***params) +{ + // wrap the name in a Php::Value object to get a zval + Value method(name); + + // call helper function + return do_exec(&_val, method._val, argc, params); +} + /** * Comparison operators== for hardcoded Value * @param value -- cgit v1.2.3