helly Mon Nov 10 15:27:17 2003 EDT
Modified files:
/php-src/ext/simplexml simplexml.c
Log:
Split into element=property and attribute=dimension overloading.
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.82 php-src/ext/simplexml/simplexml.c:1.83
--- php-src/ext/simplexml/simplexml.c:1.82 Wed Nov 5 18:44:09 2003
+++ php-src/ext/simplexml/simplexml.c Mon Nov 10 15:27:16 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: simplexml.c,v 1.82 2003/11/05 23:44:09 iliaa Exp $ */
+/* $Id: simplexml.c,v 1.83 2003/11/10 20:27:16 helly Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -340,7 +340,7 @@
*/
static void sxe_property_write(zval *object, zval *member, zval *value TSRMLS_DC)
{
- sxe_prop_dim_write(object, member, value, 1, 1 TSRMLS_CC);
+ sxe_prop_dim_write(object, member, value, 1, 0 TSRMLS_CC);
}
/* }}} */
@@ -352,14 +352,14 @@
}
/* }}} */
-/* {{{ sxe_property_exists()
+/* {{{ sxe_prop_dim_exists()
*/
-static int
-sxe_property_exists(zval *object, zval *member, int check_empty TSRMLS_DC)
+static int sxe_prop_dim_exists(zval *object, zval *member, int check_empty, zend_bool
elements, zend_bool attribs TSRMLS_DC)
{
php_sxe_object *sxe;
char *name;
xmlNodePtr node;
+ xmlAttrPtr attr = NULL;
sxe = php_sxe_fetch_object(object TSRMLS_CC);
name = Z_STRVAL_P(member);
@@ -367,16 +367,29 @@
GET_NODE(sxe, node);
if (node) {
- node = node->children;
- while (node) {
- SKIP_TEXT(node);
-
- if (!xmlStrcmp(node->name, name)) {
- return 1;
+ if (attribs) {
+ attr = node->properties;
+ while (attr) {
+ if (!xmlStrcmp(attr->name, name)) {
+ return 1;
+ }
+
+ attr = attr->next;
}
+ }
+
+ if (elements) {
+ node = node->children;
+ while (node) {
+ SKIP_TEXT(node);
+
+ if (!xmlStrcmp(node->name, name)) {
+ return 1;
+ }
next_iter:
- node = node->next;
+ node = node->next;
+ }
}
}
@@ -384,6 +397,22 @@
}
/* }}} */
+/* {{{ sxe_property_exists()
+ */
+static int sxe_property_exists(zval *object, zval *member, int check_empty TSRMLS_DC)
+{
+ return sxe_prop_dim_exists(object, member, check_empty, 1, 0 TSRMLS_CC);
+}
+/* }}} */
+
+/* {{{ sxe_property_exists()
+ */
+static int sxe_dimension_exists(zval *object, zval *member, int check_empty TSRMLS_DC)
+{
+ return sxe_prop_dim_exists(object, member, check_empty, 0, 1 TSRMLS_CC);
+}
+/* }}} */
+
/* {{{ sxe_prop_dim_delete()
*/
static void sxe_prop_dim_delete(zval *object, zval *member, zend_bool elements,
zend_bool attribs TSRMLS_DC)
@@ -445,10 +474,9 @@
/* {{{ sxe_property_delete()
*/
-static void
-sxe_property_delete(zval *object, zval *member TSRMLS_DC)
+static void sxe_property_delete(zval *object, zval *member TSRMLS_DC)
{
- sxe_prop_dim_delete(object, member, 1, 1 TSRMLS_CC);
+ sxe_prop_dim_delete(object, member, 1, 0 TSRMLS_CC);
}
/* }}} */
@@ -456,7 +484,7 @@
*/
static void sxe_dimension_delete(zval *object, zval *offset TSRMLS_DC)
{
- sxe_prop_dim_delete(object, offset, 1, 1 TSRMLS_CC);
+ sxe_prop_dim_delete(object, offset, 0, 1 TSRMLS_CC);
}
/* }}} */
@@ -970,6 +998,7 @@
sxe_object_set,
sxe_property_exists,
sxe_property_delete,
+ sxe_dimension_exists,
sxe_dimension_delete,
sxe_properties_get,
sxe_method_get,
@@ -1390,7 +1419,7 @@
{
php_info_print_table_start();
php_info_print_table_header(2, "Simplexml support", "enabled");
- php_info_print_table_row(2, "Revision", "$Revision: 1.82 $");
+ php_info_print_table_row(2, "Revision", "$Revision: 1.83 $");
php_info_print_table_row(2, "Schema support",
#ifdef LIBXML_SCHEMAS_ENABLED
"enabled");
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php