cvs: ZendEngine2 / zend_execute_API.c

"Dmitry Stogov" <[email protected]>
Newsgroups gmane.comp.php.cvs.zend
Message-ID <cvsdmitry1217091719@cvsserver>
dmitry		Sat Jul 26 17:01:59 2008 UTC

  Modified files:              
    /ZendEngine2	zend_execute_API.c 
  Log:
  Added support for overloaded functions (e.g. COM) in call_user_func().
  
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_execute_API.c?r1=1.454&r2=1.455&diff_format=u
Index: ZendEngine2/zend_execute_API.c
diff -u ZendEngine2/zend_execute_API.c:1.454 ZendEngine2/zend_execute_API.c:1.455
--- ZendEngine2/zend_execute_API.c:1.454	Sat Jul 26 13:14:55 2008
+++ ZendEngine2/zend_execute_API.c	Sat Jul 26 17:01:59 2008
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_execute_API.c,v 1.454 2008/07/26 13:14:55 dmitry Exp $ */
+/* $Id: zend_execute_API.c,v 1.455 2008/07/26 17:01:59 dmitry Exp $ */
 
 #include <stdio.h>
 #include <signal.h>
@@ -945,7 +945,7 @@
 		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);
@@ -968,6 +968,26 @@
 			/* 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.v);
+		}
+		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);
 



-- 
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.