diff options
author | Zeev Suraski <zeev@php.net> | 2003-08-05 10:24:40 +0000 |
---|---|---|
committer | Zeev Suraski <zeev@php.net> | 2003-08-05 10:24:40 +0000 |
commit | 92b4013e8d6fb3a92f958e9c01abf824bbdb4aaa (patch) | |
tree | 85e2d271c92ef8bd6dcc50944327933e3391d781 /ext/reflection/php_reflection.c | |
parent | 97c2522128815964b450aed41ef095d6d9ccc8aa (diff) | |
download | php-git-92b4013e8d6fb3a92f958e9c01abf824bbdb4aaa.tar.gz |
Try to put an end to the endless number of call_user_function variants.
zend_call_function() now takes a structure that should contain all of the
necessary information. If further information is necessary in the future,
then we'll be able to add it without having to introduce a new function.
As for caching - the 2nd, optional argument is a struct that can hold all
of the information that's necessary to invoke the function, including its
handler, scope and object it operates on (if any). Note that you may only
use a cache if the arguments you provide to zend_call_function() are
identical to the ones of the last call, except for the argument and return
value information.
The recently introduced fast_call_user_function() was removed
I fixed most of the places that used fast_call_user_function() to use caching
but there are still some that need to be fixed (XML and reflection)
Diffstat (limited to 'ext/reflection/php_reflection.c')
-rw-r--r-- | ext/reflection/php_reflection.c | 69 |
1 files changed, 44 insertions, 25 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 648144b957..2a9a4e5292 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -249,7 +249,8 @@ static void _class_string(string *str, zend_class_entry *ce, char *indent TSRMLS } if (ce->num_interfaces) { - int i; + zend_uint i; + string_printf(str, " implements %s", ce->interfaces[0]->name); for (i = 1; i < ce->num_interfaces; ++i) { string_printf(str, ", %s", ce->interfaces[i]->name); @@ -337,7 +338,7 @@ static void _class_string(string *str, zend_class_entry *ce, char *indent TSRMLS static void _function_parameter_string(string *str, zend_function *fptr, char* indent TSRMLS_DC) { - int i; + zend_uint i; struct _zend_arg_info *arg_info = fptr->common.arg_info; if (!arg_info) return; @@ -757,6 +758,7 @@ ZEND_FUNCTION(reflection_function_invoke) zval *fname; int result; int argc = ZEND_NUM_ARGS(); + zend_fcall_info fci; METHOD_NOTSTATIC; GET_REFLECTION_OBJECT_PTR(fptr); @@ -774,15 +776,18 @@ ZEND_FUNCTION(reflection_function_invoke) */ MAKE_STD_ZVAL(fname); ZVAL_NULL(fname); - result = fast_call_user_function( - EG(function_table), NULL, fname, - &retval_ptr, - argc, - params, - 1, - NULL, - &fptr TSRMLS_CC - ); + + fci.size = sizeof(fci); + fci.function_table = EG(function_table); + fci.function_name = fname; + fci.symbol_table = NULL; + fci.object_pp = NULL; + fci.retval_ptr_ptr = &retval_ptr; + fci.param_count = argc; + fci.no_separation = 1; + /*fci.function_handler_cache = &fptr;*/ + + result = zend_call_function(&fci, NULL TSRMLS_CC); zval_ptr_dtor(&fname); efree(params); @@ -983,6 +988,7 @@ ZEND_FUNCTION(reflection_method_invoke) zval *fname; int argc = ZEND_NUM_ARGS(); int result; + zend_fcall_info fci; METHOD_NOTSTATIC; @@ -1032,17 +1038,19 @@ ZEND_FUNCTION(reflection_method_invoke) */ MAKE_STD_ZVAL(fname); ZVAL_NULL(fname); - result = fast_call_user_function( - EG(function_table), - object_pp, - fname, - &retval_ptr, - argc - 1, - params+ 1, - 1, - NULL, - &mptr TSRMLS_CC - ); + + fci.size = sizeof(fci); + fci.function_table = EG(function_table); + fci.function_name = fname; + fci.symbol_table = NULL; + fci.object_pp = object_pp; + fci.retval_ptr_ptr = &retval_ptr; + fci.param_count = argc-1; + fci.params = params+1; + fci.no_separation = 1; + /*fci.function_handler_cache = &mptr;*/ + + result = zend_call_function(&fci, NULL TSRMLS_CC); zval_ptr_dtor(&fname); efree(params); @@ -1611,6 +1619,7 @@ ZEND_FUNCTION(reflection_class_newinstance) if (ce->constructor) { zval ***params; zval *fname; + zend_fcall_info fci; params = safe_emalloc(sizeof(zval **), argc, 0); if (zend_get_parameters_array_ex(argc, params) == FAILURE) { @@ -1625,9 +1634,19 @@ ZEND_FUNCTION(reflection_class_newinstance) */ MAKE_STD_ZVAL(fname); ZVAL_NULL(fname); - if (fast_call_user_function(EG(function_table), &return_value, fname, - &retval_ptr, argc, params, - 1, NULL, &ce->constructor TSRMLS_CC) == FAILURE) { + + fci.size = sizeof(fci); + fci.function_table = EG(function_table); + fci.function_name = fname; + fci.symbol_table = NULL; + fci.object_pp = &return_value; + fci.retval_ptr_ptr = &retval_ptr; + fci.param_count = argc; + fci.params = params; + fci.no_separation = 1; + /*fci.function_handler_cache = &ce->constructor;*/ + + if (zend_call_function(&fci, NULL TSRMLS_CC) == FAILURE) { efree(params); zval_ptr_dtor(&fname); zend_error(E_WARNING, "Invokation of %s's constructor failed\n", ce->name); |