From: Marcus Boerger Date: Sun, 18 Jan 2004 15:16:26 +0000 (+0000) Subject: Enable inherited classes inside SPL and respect order of module init. X-Git-Tag: php_ibase_before_split~134 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8f4e9d9e42e415f1794ab0801af8c02386373df7;p=php Enable inherited classes inside SPL and respect order of module init. --- diff --git a/ext/simplexml/php_simplexml.h b/ext/simplexml/php_simplexml.h index 94b668aa92..de3872133a 100644 --- a/ext/simplexml/php_simplexml.h +++ b/ext/simplexml/php_simplexml.h @@ -80,7 +80,7 @@ typedef struct { #define SIMPLEXML_G(v) (simplexml_globals.v) #endif -PHP_API zend_class_entry *sxe_get_element_class_entry(); +ZEND_API zend_class_entry *sxe_get_element_class_entry(); #endif diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 3569cfbf70..3bd3065b3b 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -31,12 +31,16 @@ #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; } @@ -45,23 +49,8 @@ PHP_API zend_class_entry *sxe_get_element_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) @@ -106,8 +95,6 @@ static void _node_as_zval(php_sxe_object *sxe, xmlNodePtr node, zval *value, int } \ } -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; @@ -1053,7 +1040,7 @@ php_sxe_register_object(php_sxe_object *intern TSRMLS_DC) /* {{{ 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; @@ -1186,7 +1173,7 @@ zend_object_iterator_funcs php_sxe_iterator_funcs = { 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; @@ -1305,16 +1292,12 @@ static int php_sxe_iterator_current_key(zend_object_iterator *iter, char **str_k } -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) @@ -1366,6 +1349,12 @@ next_iter: } } +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; @@ -1485,6 +1474,12 @@ PHP_MINIT_FUNCTION(simplexml) 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; } /* }}} */ diff --git a/ext/simplexml/simplexml.h b/ext/simplexml/simplexml.h new file mode 100755 index 0000000000..6b2234cd10 --- /dev/null +++ b/ext/simplexml/simplexml.h @@ -0,0 +1,65 @@ +/* + +----------------------------------------------------------------------+ + | 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 | + | Marcus Boerger | + | Rob Richards | + +----------------------------------------------------------------------+ +*/ + +/* $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 + */