Browse Source

- Update cast_object handlers

migration/RELEASE_1_0_0
Marcus Boerger 21 years ago
parent
commit
6ccd7ef74d
  1. 10
      ext/simplexml/simplexml.c
  2. 9
      ext/spl/spl_directory.c
  3. 51
      ext/spl/spl_iterators.c
  4. 8
      ext/tidy/tidy.c

10
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;
}
/* }}} */

9
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;

51
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);

8
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;

Loading…
Cancel
Save