@@ -55,7 +55,6 @@ const zend_function_entry php_dom_attr_class_functions[] = {
55
55
/* {{{ proto void DOMAttr::__construct(string name, [string value]); */
56
56
PHP_METHOD (domattr , __construct )
57
57
{
58
-
59
58
zval * id ;
60
59
xmlAttrPtr nodep = NULL ;
61
60
xmlNodePtr oldnode = NULL ;
@@ -71,7 +70,7 @@ PHP_METHOD(domattr, __construct)
71
70
}
72
71
73
72
zend_restore_error_handling (& error_handling TSRMLS_CC );
74
- intern = ( dom_object * ) zend_object_store_get_object ( id TSRMLS_CC );
73
+ intern = Z_DOMOBJ_P ( id );
75
74
76
75
name_valid = xmlValidateName ((xmlChar * ) name , 0 );
77
76
if (name_valid != 0 ) {
@@ -102,7 +101,7 @@ readonly=yes
102
101
URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-1112119403
103
102
Since:
104
103
*/
105
- int dom_attr_name_read (dom_object * obj , zval * * retval TSRMLS_DC )
104
+ int dom_attr_name_read (dom_object * obj , zval * retval TSRMLS_DC )
106
105
{
107
106
xmlAttrPtr attrp ;
108
107
@@ -113,8 +112,7 @@ int dom_attr_name_read(dom_object *obj, zval **retval TSRMLS_DC)
113
112
return FAILURE ;
114
113
}
115
114
116
- ALLOC_ZVAL (* retval );
117
- ZVAL_STRING (* retval , (char * ) (attrp -> name ), 1 );
115
+ ZVAL_STRING (retval , (char * ) attrp -> name );
118
116
119
117
return SUCCESS ;
120
118
}
@@ -126,11 +124,10 @@ readonly=yes
126
124
URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-862529273
127
125
Since:
128
126
*/
129
- int dom_attr_specified_read (dom_object * obj , zval * * retval TSRMLS_DC )
127
+ int dom_attr_specified_read (dom_object * obj , zval * retval TSRMLS_DC )
130
128
{
131
129
/* TODO */
132
- ALLOC_ZVAL (* retval );
133
- ZVAL_TRUE (* retval );
130
+ ZVAL_TRUE (retval );
134
131
return SUCCESS ;
135
132
}
136
133
@@ -141,26 +138,21 @@ readonly=no
141
138
URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-221662474
142
139
Since:
143
140
*/
144
- int dom_attr_value_read (dom_object * obj , zval * * retval TSRMLS_DC )
141
+ int dom_attr_value_read (dom_object * obj , zval * retval TSRMLS_DC )
145
142
{
146
- xmlAttrPtr attrp ;
143
+ xmlAttrPtr attrp = ( xmlAttrPtr ) dom_object_get_node ( obj ) ;
147
144
xmlChar * content ;
148
145
149
- attrp = (xmlAttrPtr ) dom_object_get_node (obj );
150
-
151
146
if (attrp == NULL ) {
152
147
php_dom_throw_error (INVALID_STATE_ERR , 0 TSRMLS_CC );
153
148
return FAILURE ;
154
149
}
155
150
156
- ALLOC_ZVAL (* retval );
157
-
158
-
159
151
if ((content = xmlNodeGetContent ((xmlNodePtr ) attrp )) != NULL ) {
160
- ZVAL_STRING (* retval , content , 1 );
152
+ ZVAL_STRING (retval , content );
161
153
xmlFree (content );
162
154
} else {
163
- ZVAL_EMPTY_STRING (* retval );
155
+ ZVAL_EMPTY_STRING (retval );
164
156
}
165
157
166
158
return SUCCESS ;
@@ -170,9 +162,7 @@ int dom_attr_value_read(dom_object *obj, zval **retval TSRMLS_DC)
170
162
int dom_attr_value_write (dom_object * obj , zval * newval TSRMLS_DC )
171
163
{
172
164
zval value_copy ;
173
- xmlAttrPtr attrp ;
174
-
175
- attrp = (xmlAttrPtr ) dom_object_get_node (obj );
165
+ xmlAttrPtr attrp = (xmlAttrPtr ) dom_object_get_node (obj );
176
166
177
167
if (attrp == NULL ) {
178
168
php_dom_throw_error (INVALID_STATE_ERR , 0 TSRMLS_CC );
@@ -183,12 +173,9 @@ int dom_attr_value_write(dom_object *obj, zval *newval TSRMLS_DC)
183
173
node_list_unlink (attrp -> children TSRMLS_CC );
184
174
}
185
175
186
- if (newval -> type != IS_STRING ) {
187
- if (Z_REFCOUNT_P (newval ) > 1 ) {
188
- value_copy = * newval ;
189
- zval_copy_ctor (& value_copy );
190
- newval = & value_copy ;
191
- }
176
+ if (Z_TYPE_P (newval ) != IS_STRING ) {
177
+ ZVAL_DUP (& value_copy , newval );
178
+ newval = & value_copy ;
192
179
convert_to_string (newval );
193
180
}
194
181
@@ -208,10 +195,9 @@ readonly=yes
208
195
URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Attr-ownerElement
209
196
Since: DOM Level 2
210
197
*/
211
- int dom_attr_owner_element_read (dom_object * obj , zval * * retval TSRMLS_DC )
198
+ int dom_attr_owner_element_read (dom_object * obj , zval * retval TSRMLS_DC )
212
199
{
213
200
xmlNodePtr nodep , nodeparent ;
214
- int ret ;
215
201
216
202
nodep = dom_object_get_node (obj );
217
203
@@ -220,18 +206,13 @@ int dom_attr_owner_element_read(dom_object *obj, zval **retval TSRMLS_DC)
220
206
return FAILURE ;
221
207
}
222
208
223
- ALLOC_ZVAL (* retval );
224
-
225
209
nodeparent = nodep -> parent ;
226
210
if (!nodeparent ) {
227
- ZVAL_NULL (* retval );
211
+ ZVAL_NULL (retval );
228
212
return SUCCESS ;
229
213
}
230
214
231
- if (NULL == (* retval = php_dom_create_object (nodeparent , & ret , * retval , obj TSRMLS_CC ))) {
232
- php_error_docref (NULL TSRMLS_CC , E_WARNING , "Cannot create required DOM object" );
233
- return FAILURE ;
234
- }
215
+ php_dom_create_object (nodeparent , retval , obj TSRMLS_CC );
235
216
return SUCCESS ;
236
217
237
218
}
@@ -243,11 +224,10 @@ readonly=yes
243
224
URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Attr-schemaTypeInfo
244
225
Since: DOM Level 3
245
226
*/
246
- int dom_attr_schema_type_info_read (dom_object * obj , zval * * retval TSRMLS_DC )
227
+ int dom_attr_schema_type_info_read (dom_object * obj , zval * retval TSRMLS_DC )
247
228
{
248
229
php_error_docref (NULL TSRMLS_CC , E_WARNING , "Not yet implemented ");
249
- ALLOC_ZVAL (* retval );
250
- ZVAL_NULL (* retval );
230
+ ZVAL_NULL (retval );
251
231
return SUCCESS ;
252
232
}
253
233
0 commit comments