From: Marcus Boerger Date: Wed, 5 Oct 2005 19:12:44 +0000 (+0000) Subject: - Update cast_object handlers X-Git-Tag: RELEASE_0_9_1~243 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6ccd7ef74d139af714ed57626d80b95519c5df26;p=php - Update cast_object handlers --- diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index f4318c6c6d..9f54263c72 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -1040,20 +1040,15 @@ cast_object(zval *object, int type, char *contents TSRMLS_DC) /* {{{ sxe_object_cast() */ static int -sxe_object_cast(zval *readobj, zval *writeobj, int type, int should_free TSRMLS_DC) +sxe_object_cast(zval *readobj, zval *writeobj, int type TSRMLS_DC) { php_sxe_object *sxe; char *contents = NULL; xmlNodePtr node; - zval free_obj; int rv; sxe = php_sxe_fetch_object(readobj TSRMLS_CC); - if (should_free) { - free_obj = *writeobj; - } - if (sxe->iter.type != SXE_ITER_NONE) { node = php_sxe_get_first_node(sxe, NULL TSRMLS_CC); if (node) { @@ -1078,9 +1073,6 @@ sxe_object_cast(zval *readobj, zval *writeobj, int type, int should_free TSRMLS_ if (contents) { xmlFree(contents); } - if (should_free) { - zval_dtor(&free_obj); - } return rv; } /* }}} */ diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 25d37d6117..1af7706f89 100755 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -793,19 +793,12 @@ zend_object_iterator *spl_ce_dir_tree_get_iterator(zend_class_entry *ce, zval *o /* }}} */ /* {{{ spl_ce_dir_cast */ -static int spl_ce_dir_cast(zval *readobj, zval *writeobj, int type, int should_free TSRMLS_DC) +static int spl_ce_dir_cast(zval *readobj, zval *writeobj, int type TSRMLS_DC) { - zval free_obj; spl_ce_dir_object *dir_object = (spl_ce_dir_object*)zend_object_store_get_object(readobj TSRMLS_CC); if (type ==IS_STRING && *dir_object->entry.d_name) { - if (should_free) { - free_obj = *writeobj; - } ZVAL_STRING(writeobj, dir_object->entry.d_name, 1); - if (should_free) { - zval_dtor(&free_obj); - } return SUCCESS; } return FAILURE; diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index 7cfeac3339..c98643ccf5 100755 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -1522,46 +1522,19 @@ static INLINE void spl_caching_it_next(spl_dual_it_object *intern TSRMLS_DC) zval_ptr_dtor(&retval); } if (intern->u.caching.flags & CIT_CALL_TOSTRING) { - if (Z_TYPE_P(intern->current.data) == IS_OBJECT) { - zval expr_copy; - if (intern->current.data->value.obj.handlers->cast_object && - intern->current.data->value.obj.handlers->cast_object(intern->current.data, &expr_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS) - { - ALLOC_ZVAL(intern->u.caching.zstr); - *intern->u.caching.zstr = expr_copy; - INIT_PZVAL(intern->u.caching.zstr); - zval_copy_ctor(intern->u.caching.zstr); - zval_dtor(&expr_copy); - } else { - zend_class_entry *ce_data = spl_get_class_entry(intern->current.data TSRMLS_CC); - if (ce_data && zend_hash_exists(&ce_data->function_table, "__tostring", sizeof("__tostring"))) { - zend_call_method_with_0_params(&intern->current.data, ce_data, NULL, "__tostring", &intern->u.caching.zstr); - } else { - ALLOC_ZVAL(intern->u.caching.zstr); - *intern->u.caching.zstr = *intern->current.data; - zval_copy_ctor(intern->u.caching.zstr); - INIT_PZVAL(intern->u.caching.zstr); - convert_to_string(intern->u.caching.zstr); - } - } + int use_copy; + zval expr_copy; + ALLOC_ZVAL(intern->u.caching.zstr); + *intern->u.caching.zstr = *intern->current.data; + zend_make_printable_zval(intern->u.caching.zstr, &expr_copy, &use_copy); + if (use_copy) { + *intern->u.caching.zstr = expr_copy; + INIT_PZVAL(intern->u.caching.zstr); + zval_copy_ctor(intern->u.caching.zstr); + zval_dtor(&expr_copy); } else { - /* This version requires zend_make_printable_zval() being able to - * call __toString(). - */ - int use_copy; - zval expr_copy; - ALLOC_ZVAL(intern->u.caching.zstr); - *intern->u.caching.zstr = *intern->current.data; - zend_make_printable_zval(intern->u.caching.zstr, &expr_copy, &use_copy); - if (use_copy) { - *intern->u.caching.zstr = expr_copy; - INIT_PZVAL(intern->u.caching.zstr); - zval_copy_ctor(intern->u.caching.zstr); - zval_dtor(&expr_copy); - } else { - INIT_PZVAL(intern->u.caching.zstr); - zval_copy_ctor(intern->u.caching.zstr); - } + INIT_PZVAL(intern->u.caching.zstr); + zval_copy_ctor(intern->u.caching.zstr); } } spl_dual_it_next(intern, 0 TSRMLS_CC); diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c index 655e278114..bb0279ebd3 100644 --- a/ext/tidy/tidy.c +++ b/ext/tidy/tidy.c @@ -206,8 +206,8 @@ static zend_object_value tidy_object_new_exception(zend_class_entry * TSRMLS_DC) static zend_class_entry *tidy_get_ce_node(zval * TSRMLS_DC); static zend_class_entry *tidy_get_ce_doc(zval * TSRMLS_DC); static zval * tidy_instanciate(zend_class_entry *, zval * TSRMLS_DC); -static int tidy_doc_cast_handler(zval *, zval *, int, int TSRMLS_DC); -static int tidy_node_cast_handler(zval *, zval *, int, int TSRMLS_DC); +static int tidy_doc_cast_handler(zval *, zval *, int TSRMLS_DC); +static int tidy_node_cast_handler(zval *, zval *, int TSRMLS_DC); static void tidy_doc_update_properties(PHPTidyObj * TSRMLS_DC); static void tidy_add_default_properties(PHPTidyObj *, tidy_obj_type TSRMLS_DC); static void *php_tidy_get_opt_val(PHPTidyDoc *, TidyOption, TidyOptionType * TSRMLS_DC); @@ -626,7 +626,7 @@ static zval * tidy_instanciate(zend_class_entry *pce, zval *object TSRMLS_DC) return object; } -static int tidy_doc_cast_handler(zval *in, zval *out, int type, int free TSRMLS_DC) +static int tidy_doc_cast_handler(zval *in, zval *out, int type TSRMLS_DC) { TidyBuffer output = {0}; PHPTidyObj *obj; @@ -658,7 +658,7 @@ static int tidy_doc_cast_handler(zval *in, zval *out, int type, int free TSRMLS_ return SUCCESS; } -static int tidy_node_cast_handler(zval *in, zval *out, int type, int free TSRMLS_DC) +static int tidy_node_cast_handler(zval *in, zval *out, int type TSRMLS_DC) { TidyBuffer buf = {0}; PHPTidyObj *obj;