On Wed, Feb 18, 2009 at 6:16 AM, Johannes Schlüter <[email protected]> wrote:
> But I don't think that a new limitation is any better: Tomorrow we have
> to change it again as somebody has a reason to use 5 parameters, so if
> it is changed it should be changed to take any number of arguments and
> no fixed limit.... (or add a new API for that)
given Johannes' feedback this morning, i created another patch, which adds
zend_call_method_va(), it accepts an array of zvals. then i changed
zend_call_method() to build the array and call zend_call_method_va().
it seems like this meets all the objectives.
. support for n parameters
. no emalloc calls
. no va_list usage
. zend_call_method() backwards compatible (lesser extent)
your feedback appreciated,
-nathan
(and i did the diff in the right direction this time :D)
--- zend_interfaces.ORIG.c 2009-02-17 20:24:47.000000000 -0700
+++ zend_interfaces.c 2009-02-18 11:44:53.000000000 -0700
@@ -29,9 +29,10 @@
ZEND_API zend_class_entry *zend_ce_arrayaccess;
ZEND_API zend_class_entry *zend_ce_serializable;
-/* {{{ zend_call_method
+
+/* {{{ zend_call_method_va
Only returns the returned zval if retval_ptr != NULL */
-ZEND_API zval* zend_call_method(zval **object_pp, zend_class_entry *obj_ce,
zend_function **fn_proxy, char *function_name, int function_name_len, zval
**retval_ptr_ptr, int param_count, zval* arg1, zval* arg2 TSRMLS_DC)
+ZEND_API zval* zend_call_method_va(zval **object_pp, zend_class_entry
*obj_ce, zend_function **fn_proxy, char *function_name, int
function_name_len, zval **retval_ptr_ptr, int param_count, zval** params
TSRMLS_DC)
{
int result;
zend_fcall_info fci;
@@ -39,11 +40,6 @@
zval *retval;
HashTable *function_table;
- zval **params[2];
-
- params[0] = &arg1;
- params[1] = &arg2;
-
fci.size = sizeof(fci);
/*fci.function_table = NULL; will be read form zend_class_entry of
object if needed */
fci.object_ptr = object_pp ? *object_pp : NULL;
@@ -107,6 +103,19 @@
}
/* }}} */
+/* {{{ zend_call_method
+ Only returns the returned zval if retval_ptr != NULL */
+ZEND_API zval* zend_call_method(zval **object_pp, zend_class_entry *obj_ce,
zend_function **fn_proxy, char *function_name, int function_name_len, zval
**retval_ptr_ptr, int param_count, zval* arg1, zval* arg2 TSRMLS_DC)
+{
+ zval **params[2];
+
+ params[0] = &arg1;
+ params[1] = &arg2;
+
+ return zend_call_method_va(object_pp, obj_ce, fn_proxy, function_name,
function_name_len, retval_ptr_ptr, param_count, params TSRMLS_CC);
+}
+/* }}} */
+
/* iterator interface, c-level functions used by engine */
/* {{{ zend_user_it_new_iterator */
--- zend_interfaces.ORIG.h 2009-02-17 20:24:36.000000000 -0700
+++ zend_interfaces.h 2009-02-18 11:28:55.000000000 -0700
@@ -38,6 +38,8 @@
zval *value;
} zend_user_iterator;
+ZEND_API zval* zend_call_method_va(zval **object_pp, zend_class_entry
*obj_ce, zend_function **fn_proxy, char *function_name, int
function_name_len, zval **retval_ptr_ptr, int param_count, zval** params
TSRMLS_DC);
+
ZEND_API zval* zend_call_method(zval **object_pp, zend_class_entry *obj_ce,
zend_function **fn_proxy, char *function_name, int function_name_len, zval
**retval_ptr_ptr, int param_count, zval* arg1, zval* arg2 TSRMLS_DC);
#define zend_call_method_with_0_params(obj, obj_ce, fn_proxy,
function_name, retval) \