]> granicus.if.org Git - php/commitdiff
- Update cast_object handlers
authorMarcus Boerger <helly@php.net>
Wed, 5 Oct 2005 19:12:44 +0000 (19:12 +0000)
committerMarcus Boerger <helly@php.net>
Wed, 5 Oct 2005 19:12:44 +0000 (19:12 +0000)
ext/simplexml/simplexml.c
ext/spl/spl_directory.c
ext/spl/spl_iterators.c
ext/tidy/tidy.c

index f4318c6c6d75cace3cdbea421dd2b8b61131c662..9f54263c72cb91da5d6e715560dd9e610d7fb834 100644 (file)
@@ -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;
 }
 /* }}} */
index 25d37d61174e19ef58960eabfe0dd6b1204211cc..1af7706f899b3f3931e7a4d10895beba931e206d 100755 (executable)
@@ -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;
index 7cfeac33394cd26248e1539d2b7c96f4d1411700..c98643ccf58fd6ce9a6fcf6de320f57afd5064f0 100755 (executable)
@@ -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);  
index 655e2781146f0eb215dda7ce053d612646fbfd13..bb0279ebd31452fa532950365c1b702900dfcbdd 100644 (file)
@@ -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;