diff options
Diffstat (limited to 'ext/dom/php_dom.c')
-rw-r--r-- | ext/dom/php_dom.c | 67 |
1 files changed, 31 insertions, 36 deletions
diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index 726b74b934..1a3689926b 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -310,31 +310,27 @@ static void dom_register_prop_handler(HashTable *prop_handler, char *name, size_ } /* }}} */ -static zval *dom_get_property_ptr_ptr(zval *object, zval *member, int type, void **cache_slot) /* {{{ */ +static zval *dom_get_property_ptr_ptr(zend_object *object, zend_string *name, int type, void **cache_slot) /* {{{ */ { - dom_object *obj = Z_DOMOBJ_P(object); - zend_string *member_str = zval_get_string(member); + dom_object *obj = php_dom_obj_from_obj(object); zval *retval = NULL; - if (!obj->prop_handler || !zend_hash_exists(obj->prop_handler, member_str)) { - retval = zend_std_get_property_ptr_ptr(object, member, type, cache_slot); + if (!obj->prop_handler || !zend_hash_exists(obj->prop_handler, name)) { + retval = zend_std_get_property_ptr_ptr(object, name, type, cache_slot); } - - zend_string_release_ex(member_str, 0); return retval; } /* }}} */ /* {{{ dom_read_property */ -zval *dom_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) +zval *dom_read_property(zend_object *object, zend_string *name, int type, void **cache_slot, zval *rv) { - dom_object *obj = Z_DOMOBJ_P(object); - zend_string *member_str = zval_get_string(member); + dom_object *obj = php_dom_obj_from_obj(object); zval *retval; dom_prop_handler *hnd = NULL; if (obj->prop_handler != NULL) { - hnd = zend_hash_find_ptr(obj->prop_handler, member_str); + hnd = zend_hash_find_ptr(obj->prop_handler, name); } else if (instanceof_function(obj->std.ce, dom_node_class_entry)) { php_error(E_WARNING, "Couldn't fetch %s. Node no longer exists", ZSTR_VAL(obj->std.ce->name)); } @@ -347,46 +343,41 @@ zval *dom_read_property(zval *object, zval *member, int type, void **cache_slot, retval = &EG(uninitialized_zval); } } else { - retval = zend_std_read_property(object, member, type, cache_slot, rv); + retval = zend_std_read_property(object, name, type, cache_slot, rv); } - zend_string_release_ex(member_str, 0); return retval; } /* }}} */ /* {{{ dom_write_property */ -zval *dom_write_property(zval *object, zval *member, zval *value, void **cache_slot) +zval *dom_write_property(zend_object *object, zend_string *name, zval *value, void **cache_slot) { - dom_object *obj = Z_DOMOBJ_P(object); - zend_string *member_str = zval_get_string(member); + dom_object *obj = php_dom_obj_from_obj(object); dom_prop_handler *hnd = NULL; if (obj->prop_handler != NULL) { - hnd = zend_hash_find_ptr(obj->prop_handler, member_str); + hnd = zend_hash_find_ptr(obj->prop_handler, name); } if (hnd) { hnd->write_func(obj, value); } else { - value = zend_std_write_property(object, member, value, cache_slot); + value = zend_std_write_property(object, name, value, cache_slot); } - zend_string_release_ex(member_str, 0); - return value; } /* }}} */ /* {{{ dom_property_exists */ -static int dom_property_exists(zval *object, zval *member, int check_empty, void **cache_slot) +static int dom_property_exists(zend_object *object, zend_string *name, int check_empty, void **cache_slot) { - dom_object *obj = Z_DOMOBJ_P(object); - zend_string *member_str = zval_get_string(member); + dom_object *obj = php_dom_obj_from_obj(object); dom_prop_handler *hnd = NULL; int retval = 0; if (obj->prop_handler != NULL) { - hnd = zend_hash_find_ptr(obj->prop_handler, member_str); + hnd = zend_hash_find_ptr(obj->prop_handler, name); } if (hnd) { zval tmp; @@ -402,17 +393,16 @@ static int dom_property_exists(zval *object, zval *member, int check_empty, void zval_ptr_dtor(&tmp); } } else { - retval = zend_std_has_property(object, member, check_empty, cache_slot); + retval = zend_std_has_property(object, name, check_empty, cache_slot); } - zend_string_release_ex(member_str, 0); return retval; } /* }}} */ -static HashTable* dom_get_debug_info_helper(zval *object, int *is_temp) /* {{{ */ +static HashTable* dom_get_debug_info_helper(zend_object *object, int *is_temp) /* {{{ */ { - dom_object *obj = Z_DOMOBJ_P(object); + dom_object *obj = php_dom_obj_from_obj(object); HashTable *debug_info, *prop_handlers = obj->prop_handler, *std_props; @@ -453,7 +443,7 @@ static HashTable* dom_get_debug_info_helper(zval *object, int *is_temp) /* {{{ * } /* }}} */ -static HashTable* dom_get_debug_info(zval *object, int *is_temp) /* {{{ */ +static HashTable* dom_get_debug_info(zend_object *object, int *is_temp) /* {{{ */ { return dom_get_debug_info_helper(object, is_temp); } @@ -500,9 +490,9 @@ PHP_FUNCTION(dom_import_simplexml) static dom_object* dom_objects_set_class(zend_class_entry *class_type); -static zend_object *dom_objects_store_clone_obj(zval *zobject) /* {{{ */ +static zend_object *dom_objects_store_clone_obj(zend_object *zobject) /* {{{ */ { - dom_object *intern = Z_DOMOBJ_P(zobject); + dom_object *intern = php_dom_obj_from_obj(zobject); dom_object *clone = dom_objects_set_class(intern->std.ce); clone->std.handlers = dom_get_obj_handlers(); @@ -583,7 +573,9 @@ ZEND_GET_MODULE(dom) void dom_objects_free_storage(zend_object *object); void dom_nnodemap_objects_free_storage(zend_object *object); -static zend_object *dom_objects_store_clone_obj(zval *zobject); +static zval *dom_nodelist_read_dimension(zend_object *object, zval *offset, int type, zval *rv); +static int dom_nodelist_has_dimension(zend_object *object, zval *member, int check_empty); +static zend_object *dom_objects_store_clone_obj(zend_object *zobject); static void dom_nnodemap_object_dtor(zend_object *object); #if defined(LIBXML_XPATH_ENABLED) void dom_xpath_objects_free_storage(zend_object *object); @@ -1530,7 +1522,7 @@ xmlNsPtr dom_get_nsdecl(xmlNode *node, xmlChar *localName) { } /* }}} end dom_get_nsdecl */ -zval *dom_nodelist_read_dimension(zval *object, zval *offset, int type, zval *rv) /* {{{ */ +static zval *dom_nodelist_read_dimension(zend_object *object, zval *offset, int type, zval *rv) /* {{{ */ { zval offset_copy; @@ -1540,12 +1532,12 @@ zval *dom_nodelist_read_dimension(zval *object, zval *offset, int type, zval *rv ZVAL_LONG(&offset_copy, zval_get_long(offset)); - zend_call_method_with_1_params(object, Z_OBJCE_P(object), NULL, "item", rv, &offset_copy); + zend_call_method_with_1_params(object, object->ce, NULL, "item", rv, &offset_copy); return rv; } /* }}} end dom_nodelist_read_dimension */ -int dom_nodelist_has_dimension(zval *object, zval *member, int check_empty) +static int dom_nodelist_has_dimension(zend_object *object, zval *member, int check_empty) { zend_long offset = zval_get_long(member); zval rv; @@ -1553,8 +1545,11 @@ int dom_nodelist_has_dimension(zval *object, zval *member, int check_empty) if (offset < 0) { return 0; } else { - zval *length = zend_read_property(Z_OBJCE_P(object), object, "length", sizeof("length") - 1, 0, &rv); + zval obj; + zval *length; + ZVAL_OBJ(&obj, object); + length = zend_read_property(object->ce, &obj, "length", sizeof("length") - 1, 0, &rv); return length && offset < Z_LVAL_P(length); } } /* }}} end dom_nodelist_has_dimension */ |