cvs: ZendEngine2(PHP_5_3) / zend_execute_API.c

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

  Modified files:              (Branch: PHP_5_3)
    /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.331.2.20.2.24.2.46&r2=1.331.2.20.2.24.2.47&diff_format=u
Index: ZendEngine2/zend_execute_API.c
diff -u ZendEngine2/zend_execute_API.c:1.331.2.20.2.24.2.46 ZendEngine2/zend_execute_API.c:1.331.2.20.2.24.2.47
--- ZendEngine2/zend_execute_API.c:1.331.2.20.2.24.2.46	Sat Jul 26 13:14:00 2008
+++ ZendEngine2/zend_execute_API.c	Sat Jul 26 17:01:40 2008
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_execute_API.c,v 1.331.2.20.2.24.2.46 2008/07/26 13:14:00 dmitry Exp $ */
+/* $Id: zend_execute_API.c,v 1.331.2.20.2.24.2.47 2008/07/26 17:01:40 dmitry Exp $ */
 
 #include <stdio.h>
 #include <signal.h>
@@ -886,7 +886,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);
@@ -909,6 +909,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);
+		}
+		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.