#include "ext/standard/info.h"
#include "ext/standard/php_string.h"
#include "php_simplexml.h"
+#include "simplexml.h"
#include "zend_default_classes.h"
#include "zend_interfaces.h"
+#if HAVE_SPL
+#include "ext/spl/spl_sxe.h"
+#endif
zend_class_entry *sxe_class_entry = NULL;
-PHP_API zend_class_entry *sxe_get_element_class_entry()
+ZEND_API zend_class_entry *sxe_get_element_class_entry()
{
return sxe_class_entry;
}
#define SXE_METHOD(func) PHP_METHOD(simplexml_element, func)
-#define SKIP_TEXT(__p) \
- if ((__p)->type == XML_TEXT_NODE) { \
- goto next_iter; \
- }
-
-static php_sxe_object *php_sxe_object_new(zend_class_entry *ce TSRMLS_DC);
static zend_object_value php_sxe_register_object(php_sxe_object * TSRMLS_DC);
-/* {{{ php_sxe_fetch_object()
- */
-static inline php_sxe_object *
-php_sxe_fetch_object(zval *object TSRMLS_DC)
-{
- return (php_sxe_object *) zend_object_store_get_object(object TSRMLS_CC);
-}
-/* }}} */
-
/* {{{ _node_as_zval()
*/
static void _node_as_zval(php_sxe_object *sxe, xmlNodePtr node, zval *value, int itertype, char *name, char *prefix TSRMLS_DC)
} \
}
-static void php_sxe_reset_iterator(php_sxe_object *sxe TSRMLS_DC);
-
static xmlNodePtr php_sxe_get_first_node(php_sxe_object *sxe, xmlNodePtr node TSRMLS_DC) {
php_sxe_object *intern;
xmlNodePtr retnode = NULL;
/* {{{ sxe_object_new()
*/
-static zend_object_value
+ZEND_API zend_object_value
sxe_object_new(zend_class_entry *ce TSRMLS_DC)
{
php_sxe_object *intern;
php_sxe_iterator_rewind,
};
-static void php_sxe_reset_iterator(php_sxe_object *sxe TSRMLS_DC)
+ZEND_API void php_sxe_reset_iterator(php_sxe_object *sxe TSRMLS_DC)
{
xmlNodePtr node;
char *prefix;
}
-static void php_sxe_iterator_move_forward(zend_object_iterator *iter TSRMLS_DC)
+ZEND_API void php_sxe_move_forward_iterator(php_sxe_object *sxe TSRMLS_DC)
{
xmlNodePtr node;
php_sxe_object *intern;
- php_sxe_object *sxe;
char *prefix;
- php_sxe_iterator *iterator = (php_sxe_iterator *)iter;
- sxe = iterator->sxe;
-
if (sxe->iter.data) {
intern = (php_sxe_object *)zend_object_store_get_object(sxe->iter.data TSRMLS_CC);
GET_NODE(intern, node)
}
}
+static void php_sxe_iterator_move_forward(zend_object_iterator *iter TSRMLS_DC)
+{
+ php_sxe_iterator *iterator = (php_sxe_iterator *)iter;
+ php_sxe_move_forward_iterator(iterator->sxe TSRMLS_CC);
+}
+
static void php_sxe_iterator_rewind(zend_object_iterator *iter TSRMLS_DC)
{
php_sxe_object *sxe;
sxe_object_handlers.get_class_entry = zend_get_std_object_handlers()->get_class_entry;
sxe_object_handlers.get_class_name = zend_get_std_object_handlers()->get_class_name;
+#if HAVE_SPL
+ if (zend_get_module_started("spl") == SUCCESS) {
+ PHP_MINIT(spl_sxe)(INIT_FUNC_ARGS_PASSTHRU);
+ }
+#endif /* HAVE_SPL */
+
return SUCCESS;
}
/* }}} */
--- /dev/null
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2004 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.0 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_0.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Author: Sterling Hughes <sterling@php.net> |
+ | Marcus Boerger <helly@php.net> |
+ | Rob Richards <rrichards@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+#ifndef _SIMPLEXML_H_
+#define _SIMPLEXML_H_
+
+#include "php_simplexml.h"
+
+#define SKIP_TEXT(__p) \
+ if ((__p)->type == XML_TEXT_NODE) { \
+ goto next_iter; \
+ }
+
+#define GET_NODE(__s, __n) { \
+ if ((__s)->node && (__s)->node->node) { \
+ __n = (__s)->node->node; \
+ } else { \
+ __n = NULL; \
+ php_error(E_WARNING, "Node no longer exists"); \
+ } \
+}
+
+ZEND_API zend_object_value sxe_object_new(zend_class_entry *ce TSRMLS_DC);
+/* {{{ php_sxe_fetch_object()
+ */
+static inline php_sxe_object *
+php_sxe_fetch_object(zval *object TSRMLS_DC)
+{
+ return (php_sxe_object *) zend_object_store_get_object(object TSRMLS_CC);
+}
+/* }}} */
+
+ZEND_API void php_sxe_reset_iterator(php_sxe_object *sxe TSRMLS_DC);
+ZEND_API void php_sxe_move_forward_iterator(php_sxe_object *sxe TSRMLS_DC);
+
+#endif /* _SIMPLEXML_H_ */
+
+/**
+ * Local Variables:
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: t
+ * End:
+ * vim600: fdm=marker
+ * vim: noet sw=4 ts=4
+ */