summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2008-07-26 17:01:40 +0000
committerDmitry Stogov <dmitry@php.net>2008-07-26 17:01:40 +0000
commitb25f9f6a6ab91daf72c0a11f4fa8bd1451b81211 (patch)
treeb9b55df2f42af2acc2e9dd9a2c3437fe6fabb655 /Zend
parent478acfd8b4ae8f209e0f515faa391d53256f364f (diff)
downloadphp-git-b25f9f6a6ab91daf72c0a11f4fa8bd1451b81211.tar.gz
Added support for overloaded functions (e.g. COM) in call_user_func().
Diffstat (limited to 'Zend')
-rw-r--r--Zend/zend_execute_API.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index 360e403b1c..561bbdcf49 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -886,7 +886,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
EG(active_op_array) = original_op_array;
EG(return_value_ptr_ptr)=original_return_value;
EG(opline_ptr) = original_opline_ptr;
- } else {
+ } else if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION) {
int call_via_handler = (EX(function_state).function->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0;
ALLOC_INIT_ZVAL(*fci->retval_ptr_ptr);
@@ -909,6 +909,26 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
/* We must re-initialize function again */
fci_cache->initialized = 0;
}
+ } else { /* ZEND_OVERLOADED_FUNCTION */
+
+ ALLOC_INIT_ZVAL(*fci->retval_ptr_ptr);
+
+ /* Not sure what should be done here if it's a static method */
+ if (fci->object_pp) {
+ Z_OBJ_HT_PP(fci->object_pp)->call_method(EX(function_state).function->common.function_name, fci->param_count, *fci->retval_ptr_ptr, fci->retval_ptr_ptr, *fci->object_pp, 1 TSRMLS_CC);
+ } else {
+ zend_error_noreturn(E_ERROR, "Cannot call overloaded function for non-object");
+ }
+
+ if (EX(function_state).function->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) {
+ efree(EX(function_state).function->common.function_name);
+ }
+ efree(EX(function_state).function);
+
+ if (EG(exception) && fci->retval_ptr_ptr) {
+ zval_ptr_dtor(fci->retval_ptr_ptr);
+ *fci->retval_ptr_ptr = NULL;
+ }
}
zend_vm_stack_clear_multiple(TSRMLS_C);