cvs: ZendEngine2 / zend_API.c zend_execute_API.c

From: Date: Thu, 03 Jul 2003 09:18:41 +0000
Subject: cvs: ZendEngine2 / zend_API.c zend_execute_API.c
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-1449@lists.php.net to get a copy of this message
stas Thu Jul 3 05:18:41 2003 EDT Modified files: /ZendEngine2 zend_API.c zend_execute_API.c Log: Fix bug #19859 - allow fast_call_user_function to support __call Index: ZendEngine2/zend_API.c diff -u ZendEngine2/zend_API.c:1.178 ZendEngine2/zend_API.c:1.179 --- ZendEngine2/zend_API.c:1.178 Mon Jun 30 16:22:35 2003 +++ ZendEngine2/zend_API.c Thu Jul 3 05:18:40 2003 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_API.c,v 1.178 2003/06/30 20:22:35 andi Exp $ */ +/* $Id: zend_API.c,v 1.179 2003/07/03 09:18:40 stas Exp $ */ #include "zend.h" #include "zend_execute.h" @@ -1535,12 +1535,18 @@ if (ce) { lcname = zend_str_tolower_dup(Z_STRVAL_PP(method), Z_STRLEN_PP(method)); - if (zend_hash_exists(&ce->function_table, lcname, Z_STRLEN_PP(method)+1)) + if (zend_hash_exists(&ce->function_table, lcname, Z_STRLEN_PP(method)+1)) { retval = 1; + } + /* check for __call too */ + if (retval == 0 && ce->__call != 0) { + retval = 1; + } efree(lcname); } - } else if (callable_name) + } else if (callable_name) { *callable_name = estrndup("Array", sizeof("Array")-1); + } } break; Index: ZendEngine2/zend_execute_API.c diff -u ZendEngine2/zend_execute_API.c:1.216 ZendEngine2/zend_execute_API.c:1.217 --- ZendEngine2/zend_execute_API.c:1.216 Wed Jul 2 10:44:41 2003 +++ ZendEngine2/zend_execute_API.c Thu Jul 3 05:18:41 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute_API.c,v 1.216 2003/07/02 14:44:41 sterling Exp $ */ +/* $Id: zend_execute_API.c,v 1.217 2003/07/03 09:18:41 stas Exp $ */ #include <stdio.h> #include <signal.h> @@ -492,6 +492,9 @@ char *function_name_lc; zval *current_this; zend_execute_data execute_data; + zval *method_name; + zval *params_array; + int call_via_handler = 0; /* Initialize execute_data */ EX(fbc) = NULL; @@ -573,8 +576,20 @@ original_function_state_ptr = EG(function_state_ptr); if (zend_hash_find(function_table, function_name_lc, function_name->value.str.len+1, (void **) &EX(function_state).function)==FAILURE) { - efree(function_name_lc); - return FAILURE; + /* try calling __call */ + if(calling_scope && calling_scope->__call) { + EX(function_state).function = calling_scope->__call; + /* prepare params */ + ALLOC_INIT_ZVAL(method_name); + ZVAL_STRING(method_name, function_name_lc, 1); + + ALLOC_INIT_ZVAL(params_array); + array_init(params_array); + call_via_handler = 1; + } else { + efree(function_name_lc); + return FAILURE; + } } efree(function_name_lc); *function_pointer = EX(function_state).function; @@ -614,7 +629,17 @@ *param = **(params[i]); INIT_PZVAL(param); } - zend_ptr_stack_push(&EG(argument_stack), param); + if(call_via_handler) { + add_next_index_zval(params_array, param); + } else { + zend_ptr_stack_push(&EG(argument_stack), param); + } + } + + if(call_via_handler) { + zend_ptr_stack_push(&EG(argument_stack), method_name); + zend_ptr_stack_push(&EG(argument_stack), params_array); + param_count = 2; } zend_ptr_stack_n_push(&EG(argument_stack), 2, (void *) (long) param_count, NULL); @@ -684,6 +709,10 @@ INIT_PZVAL(*retval_ptr_ptr); } zend_ptr_stack_clear_multiple(TSRMLS_C); + if(call_via_handler) { + zval_ptr_dtor(&method_name); + zval_ptr_dtor(&params_array); + } EG(function_state_ptr) = original_function_state_ptr; if (EG(This)) {

« previous php.zend-engine.cvs (#1449) next »