cvs: ZendEngine2 / zend_default_classes.c

From: Date: Sun, 30 Nov 2003 13:53:19 +0000
Subject: cvs: ZendEngine2 / zend_default_classes.c
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-2033@lists.php.net to get a copy of this message
helly Sun Nov 30 08:53:19 2003 EDT Modified files: /ZendEngine2 zend_default_classes.c Log: Check return value of exception::__tostring() Index: ZendEngine2/zend_default_classes.c diff -u ZendEngine2/zend_default_classes.c:1.47 ZendEngine2/zend_default_classes.c:1.48 --- ZendEngine2/zend_default_classes.c:1.47 Sat Nov 29 12:03:45 2003 +++ ZendEngine2/zend_default_classes.c Sun Nov 30 08:53:19 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_default_classes.c,v 1.47 2003/11/29 17:03:45 helly Exp $ */ +/* $Id: zend_default_classes.c,v 1.48 2003/11/30 13:53:19 helly Exp $ */ #include "zend.h" #include "zend_API.h" @@ -375,21 +375,6 @@ {NULL, NULL, NULL} }; -int zend_cast_exception(zval *readobj, zval *writeobj, int type, int should_free TSRMLS_DC) -{ - if (type == IS_STRING) { - zval fname, *retval; - - ZVAL_STRING(&fname, "__tostring", 0); - if (call_user_function_ex(NULL, &readobj, &fname, &retval, 0, NULL, 0, NULL TSRMLS_CC) == SUCCESS) { - ZVAL_STRING(writeobj, Z_STRVAL_P(retval), 1); - zval_ptr_dtor(&retval); - return SUCCESS; - } - } - return FAILURE; -} - static void zend_register_default_exception(TSRMLS_D) { zend_class_entry ce; @@ -399,7 +384,6 @@ default_exception_ptr->create_object = zend_default_exception_new; memcpy(&default_exception_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); default_exception_handlers.clone_obj = NULL; - default_exception_handlers.cast_object = zend_cast_exception; zend_declare_property_string(default_exception_ptr, "message", sizeof("message")-1, "Unknown exception", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(default_exception_ptr, "string", sizeof("string")-1, "", ZEND_ACC_PRIVATE TSRMLS_CC); @@ -490,34 +474,17 @@ ZEND_API void zend_exception_error(zval *exception TSRMLS_DC) { if (instanceof_function(Z_OBJCE_P(exception), default_exception_ptr TSRMLS_CC)) { - zend_fcall_info fci; - zval fname; zval *str, *file, *line; zval *old_exception = EG(exception); + zend_object_handlers *handler = Z_OBJ_HT_P(exception); EG(exception) = NULL; - ZVAL_STRINGL(&fname, "__tostring", sizeof("__tostring")-1, 0); - - fci.size = sizeof(fci); - fci.function_table = &Z_OBJCE_P(exception)->function_table; - fci.function_name = &fname; - fci.symbol_table = NULL; - fci.object_pp = &exception; - fci.retval_ptr_ptr = &str; - fci.param_count = 0; - fci.params = NULL; - fci.no_separation = 1; - - zend_call_function(&fci, NULL TSRMLS_CC); - - if (str) { - zend_update_property_string(default_exception_ptr, exception, "string", sizeof("string")-1, Z_STRVAL_P(str) TSRMLS_CC); - zval_ptr_dtor(&str); - } else if (EG(exception)) { - /* no result because of exception __tostring(), so at least return the class_name */ - zend_update_property_string(default_exception_ptr, exception, "string", sizeof("string")-1, Z_OBJCE_P(exception)->name TSRMLS_CC); - } + MAKE_STD_ZVAL(str); + handler->cast_object(exception, str, IS_STRING, 0 TSRMLS_CC); + + zend_update_property_string(default_exception_ptr, exception, "string", sizeof("string")-1, EG(exception) ? Z_OBJCE_P(exception)->name : Z_STRVAL_P(str) TSRMLS_CC); + zval_ptr_dtor(&str); if (EG(exception)) { /* do the best we can to inform about the inner exception */

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