Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c
- index 9301bbd..2716859 100755
- --- a/Zend/zend_interfaces.c
- +++ b/Zend/zend_interfaces.c
- @@ -29,89 +29,98 @@ ZEND_API zend_class_entry *zend_ce_iterator;
- ZEND_API zend_class_entry *zend_ce_arrayaccess;
- ZEND_API zend_class_entry *zend_ce_serializable;
- +/* {{{ zend_call_method_multi; accepts an arbitrary number of paramters
- + Only returns the returned zval if retval_ptr != NULL */
- +ZEND_API zval* zend_call_method_multi(zval **object_pp, zend_class_entry *obj_ce, zend_function **fn_proxy, const char *function_name, int function_name_len, zval **retval_ptr_ptr, int param_count, zval **params[] TSRMLS_DC)
- +{
- + int result;
- + zend_fcall_info fci;
- + zval z_fname;
- + zval *retval;
- + HashTable *function_table;
- +
- + 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;
- + fci.function_name = &z_fname;
- + fci.retval_ptr_ptr = retval_ptr_ptr ? retval_ptr_ptr : &retval;
- + fci.param_count = param_count;
- + fci.params = params;
- + fci.no_separation = 1;
- + fci.symbol_table = NULL;
- +
- + if (!fn_proxy && !obj_ce) {
- + /* no interest in caching and no information already present that is
- + * needed later inside zend_call_function. */
- + ZVAL_STRINGL(&z_fname, function_name, function_name_len, 0);
- + fci.function_table = !object_pp ? EG(function_table) : NULL;
- + result = zend_call_function(&fci, NULL TSRMLS_CC);
- + } else {
- + zend_fcall_info_cache fcic;
- +
- + fcic.initialized = 1;
- + if (!obj_ce) {
- + obj_ce = object_pp ? Z_OBJCE_PP(object_pp) : NULL;
- + }
- + if (obj_ce) {
- + function_table = &obj_ce->function_table;
- + } else {
- + function_table = EG(function_table);
- + }
- + if (!fn_proxy || !*fn_proxy) {
- + if (zend_hash_find(function_table, function_name, function_name_len+1, (void **) &fcic.function_handler) == FAILURE) {
- + /* error at c-level */
- + zend_error(E_CORE_ERROR, "Couldn't find implementation for method %s%s%s", obj_ce ? obj_ce->name : "", obj_ce ? "::" : "", function_name);
- + }
- + if (fn_proxy) {
- + *fn_proxy = fcic.function_handler;
- + }
- + } else {
- + fcic.function_handler = *fn_proxy;
- + }
- + fcic.calling_scope = obj_ce;
- + if (object_pp) {
- + fcic.called_scope = Z_OBJCE_PP(object_pp);
- + } else if (obj_ce &&
- + !(EG(called_scope) &&
- + instanceof_function(EG(called_scope), obj_ce TSRMLS_CC))) {
- + fcic.called_scope = obj_ce;
- + } else {
- + fcic.called_scope = EG(called_scope);
- + }
- + fcic.object_ptr = object_pp ? *object_pp : NULL;
- + result = zend_call_function(&fci, &fcic TSRMLS_CC);
- + }
- + if (result == FAILURE) {
- + /* error at c-level */
- + if (!obj_ce) {
- + obj_ce = object_pp ? Z_OBJCE_PP(object_pp) : NULL;
- + }
- + if (!EG(exception)) {
- + zend_error(E_CORE_ERROR, "Couldn't execute method %s%s%s", obj_ce ? obj_ce->name : "", obj_ce ? "::" : "", function_name);
- + }
- + }
- + if (!retval_ptr_ptr) {
- + if (retval) {
- + zval_ptr_dtor(&retval);
- + }
- + return NULL;
- + }
- + return *retval_ptr_ptr;
- +}
- +/* }}} */
- +
- /* {{{ zend_call_method
- + zend_call_method which supports up to 2 parameters. For more parameters invoke zend_call_method_multi directly
- 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, const char *function_name, int function_name_len, zval **retval_ptr_ptr, int param_count, zval* arg1, zval* arg2 TSRMLS_DC)
- {
- - int result;
- - zend_fcall_info fci;
- - zval z_fname;
- - 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;
- - fci.function_name = &z_fname;
- - fci.retval_ptr_ptr = retval_ptr_ptr ? retval_ptr_ptr : &retval;
- - fci.param_count = param_count;
- - fci.params = params;
- - fci.no_separation = 1;
- - fci.symbol_table = NULL;
- -
- - if (!fn_proxy && !obj_ce) {
- - /* no interest in caching and no information already present that is
- - * needed later inside zend_call_function. */
- - ZVAL_STRINGL(&z_fname, function_name, function_name_len, 0);
- - fci.function_table = !object_pp ? EG(function_table) : NULL;
- - result = zend_call_function(&fci, NULL TSRMLS_CC);
- - } else {
- - zend_fcall_info_cache fcic;
- + zval **args[2];
- - fcic.initialized = 1;
- - if (!obj_ce) {
- - obj_ce = object_pp ? Z_OBJCE_PP(object_pp) : NULL;
- - }
- - if (obj_ce) {
- - function_table = &obj_ce->function_table;
- - } else {
- - function_table = EG(function_table);
- - }
- - if (!fn_proxy || !*fn_proxy) {
- - if (zend_hash_find(function_table, function_name, function_name_len+1, (void **) &fcic.function_handler) == FAILURE) {
- - /* error at c-level */
- - zend_error(E_CORE_ERROR, "Couldn't find implementation for method %s%s%s", obj_ce ? obj_ce->name : "", obj_ce ? "::" : "", function_name);
- - }
- - if (fn_proxy) {
- - *fn_proxy = fcic.function_handler;
- - }
- - } else {
- - fcic.function_handler = *fn_proxy;
- - }
- - fcic.calling_scope = obj_ce;
- - if (object_pp) {
- - fcic.called_scope = Z_OBJCE_PP(object_pp);
- - } else if (obj_ce &&
- - !(EG(called_scope) &&
- - instanceof_function(EG(called_scope), obj_ce TSRMLS_CC))) {
- - fcic.called_scope = obj_ce;
- - } else {
- - fcic.called_scope = EG(called_scope);
- - }
- - fcic.object_ptr = object_pp ? *object_pp : NULL;
- - result = zend_call_function(&fci, &fcic TSRMLS_CC);
- - }
- - if (result == FAILURE) {
- - /* error at c-level */
- - if (!obj_ce) {
- - obj_ce = object_pp ? Z_OBJCE_PP(object_pp) : NULL;
- - }
- - if (!EG(exception)) {
- - zend_error(E_CORE_ERROR, "Couldn't execute method %s%s%s", obj_ce ? obj_ce->name : "", obj_ce ? "::" : "", function_name);
- - }
- - }
- - if (!retval_ptr_ptr) {
- - if (retval) {
- - zval_ptr_dtor(&retval);
- - }
- - return NULL;
- - }
- - return *retval_ptr_ptr;
- + args[0] = &arg1;
- + args[1] = &arg2;
- +
- + return zend_call_method_multi(object_pp, obj_ce, fn_proxy, function_name, function_name_len, retval_ptr_ptr, param_count, args TSRMLS_CC);
- }
- /* }}} */
Advertisement
Add Comment
Please, Sign In to add comment