helly Mon Oct 3 12:05:09 2005 EDT
Modified files: (Branch: PHP_5_1)
/php-src/ext/spl spl_iterators.c spl_sxe.c
/php-src/ext/spl/internal cachingiterator.inc
/php-src/ext/simplexml php_simplexml_exports.h simplexml.c
Log:
- MFH Really allow SXE being shared by not using anything from it directly in
SPL
http://cvs.php.net/diff.php/php-src/ext/spl/spl_iterators.c?r1=1.73.2.2&r2=1.73.2.3&ty=u
Index: php-src/ext/spl/spl_iterators.c
diff -u php-src/ext/spl/spl_iterators.c:1.73.2.2
php-src/ext/spl/spl_iterators.c:1.73.2.3
--- php-src/ext/spl/spl_iterators.c:1.73.2.2 Sun Sep 18 13:15:04 2005
+++ php-src/ext/spl/spl_iterators.c Mon Oct 3 12:05:08 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_iterators.c,v 1.73.2.2 2005/09/18 17:15:04 helly Exp $ */
+/* $Id: spl_iterators.c,v 1.73.2.3 2005/10/03 16:05:08 helly Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -764,6 +764,12 @@
php_set_error_handling(EH_NORMAL, NULL
TSRMLS_CC);
return NULL;
}
+ if (((flags & CIT_CALL_TOSTRING) && (flags &
(CIT_TOSTRING_USE_KEY|CIT_TOSTRING_USE_CURRENT)))
+ || ((flags &
(CIT_TOSTRING_USE_KEY|CIT_TOSTRING_USE_CURRENT)) ==
(CIT_TOSTRING_USE_KEY|CIT_TOSTRING_USE_CURRENT))) {
+ php_set_error_handling(EH_NORMAL, NULL
TSRMLS_CC);
+
zend_throw_exception(spl_ce_InvalidArgumentException, "Flags must contain only
one of CIT_CALL_TOSTRING, CIT_TOSTRING_USE_KEY, CIT_TOSTRING_USE_CURRENT", 0
TSRMLS_CC);
+ return NULL;
+ }
intern->u.caching.flags |= flags & CIT_PUBLIC;
break;
}
@@ -1517,9 +1523,22 @@
intern = (spl_dual_it_object*)zend_object_store_get_object(getThis()
TSRMLS_CC);
- if (!(intern->u.caching.flags & CIT_CALL_TOSTRING)) {
+ if (!(intern->u.caching.flags &
(CIT_CALL_TOSTRING|CIT_TOSTRING_USE_KEY|CIT_TOSTRING_USE_CURRENT))) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0
TSRMLS_CC, "%s does not fetch string value (see CachingIterator::__construct)",
Z_OBJCE_P(getThis())->name);
}
+ if (intern->u.caching.flags & CIT_TOSTRING_USE_KEY) {
+ if (intern->current.key_type == HASH_KEY_IS_STRING) {
+ RETURN_STRINGL(intern->current.str_key,
intern->current.str_key_len, 1);
+ } else {
+ RETVAL_LONG(intern->current.int_key);
+ convert_to_string(return_value);
+ return;
+ }
+ } else if (intern->u.caching.flags & CIT_TOSTRING_USE_CURRENT) {
+ RETVAL_ZVAL(intern->current.data, 1, 0);
+
+ return;
+ }
if (intern->u.caching.zstr) {
RETURN_STRINGL(Z_STRVAL_P(intern->u.caching.zstr),
Z_STRLEN_P(intern->u.caching.zstr), 1);
} else {
@@ -2018,8 +2037,10 @@
REGISTER_SPL_STD_CLASS_EX(CachingIterator, spl_dual_it_new,
spl_funcs_CachingIterator);
REGISTER_SPL_ITERATOR(CachingIterator);
- REGISTER_SPL_CLASS_CONST_LONG(CachingIterator, "CALL_TOSTRING",
CIT_CALL_TOSTRING);
- REGISTER_SPL_CLASS_CONST_LONG(CachingIterator, "CATCH_GET_CHILD",
CIT_CATCH_GET_CHILD);
+ REGISTER_SPL_CLASS_CONST_LONG(CachingIterator, "CALL_TOSTRING",
CIT_CALL_TOSTRING);
+ REGISTER_SPL_CLASS_CONST_LONG(CachingIterator, "CATCH_GET_CHILD",
CIT_CATCH_GET_CHILD);
+ REGISTER_SPL_CLASS_CONST_LONG(CachingIterator, "TOSTRING_USE_KEY",
CIT_TOSTRING_USE_KEY);
+ REGISTER_SPL_CLASS_CONST_LONG(CachingIterator, "TOSTRING_USE_CURRENT",
CIT_TOSTRING_USE_CURRENT);
REGISTER_SPL_SUB_CLASS_EX(RecursiveCachingIterator, CachingIterator,
spl_dual_it_new, spl_funcs_RecursiveCachingIterator);
REGISTER_SPL_IMPLEMENTS(RecursiveCachingIterator, RecursiveIterator);
http://cvs.php.net/diff.php/php-src/ext/spl/spl_sxe.c?r1=1.8.2.1&r2=1.8.2.2&ty=u
Index: php-src/ext/spl/spl_sxe.c
diff -u php-src/ext/spl/spl_sxe.c:1.8.2.1 php-src/ext/spl/spl_sxe.c:1.8.2.2
--- php-src/ext/spl/spl_sxe.c:1.8.2.1 Sat Oct 1 11:41:35 2005
+++ php-src/ext/spl/spl_sxe.c Mon Oct 3 12:05:08 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_sxe.c,v 1.8.2.1 2005/10/01 15:41:35 helly Exp $ */
+/* $Id: spl_sxe.c,v 1.8.2.2 2005/10/03 16:05:08 helly Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -34,6 +34,7 @@
#include "spl_sxe.h"
zend_class_entry *spl_ce_SimpleXMLIterator = NULL;
+zend_class_entry *spl_ce_SimpleXMLElement;
#if HAVE_LIBXML && HAVE_SIMPLEXML
@@ -41,9 +42,10 @@
SPL_METHOD(SimpleXMLIterator, rewind) /* {{{ */
{
- php_sxe_object *sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
+ php_sxe_iterator iter;
- php_sxe_reset_iterator(sxe TSRMLS_CC);
+ iter.sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
+
spl_ce_SimpleXMLElement->iterator_funcs.funcs->rewind((zend_object_iterator*)&iter
TSRMLS_CC);
}
/* }}} */
@@ -89,9 +91,10 @@
SPL_METHOD(SimpleXMLIterator, next) /* {{{ */
{
- php_sxe_object *sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
+ php_sxe_iterator iter;
- php_sxe_move_forward_iterator(sxe TSRMLS_CC);
+ iter.sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
+
spl_ce_SimpleXMLElement->iterator_funcs.funcs->move_forward((zend_object_iterator*)&iter
TSRMLS_CC);
}
/* }}} */
@@ -146,16 +149,17 @@
SPL_API PHP_MINIT_FUNCTION(spl_sxe) /* {{{ */
{
- zend_class_entry **pce, *spl_ce_SimpleXMLElement;
+ zend_class_entry **pce;
if (zend_hash_find(CG(class_table), "simplexmlelement",
sizeof("SimpleXMLElement"), (void **) &pce) == FAILURE) {
+ spl_ce_SimpleXMLElement = NULL;
spl_ce_SimpleXMLIterator = NULL;
return SUCCESS; /* SimpleXML must be initialized before */
}
spl_ce_SimpleXMLElement = *pce;
- REGISTER_SPL_SUB_CLASS_EX(SimpleXMLIterator, SimpleXMLElement,
sxe_object_new, spl_funcs_SimpleXMLIterator);
+ REGISTER_SPL_SUB_CLASS_EX(SimpleXMLIterator, SimpleXMLElement,
spl_ce_SimpleXMLElement->create_object, spl_funcs_SimpleXMLIterator);
REGISTER_SPL_IMPLEMENTS(SimpleXMLIterator, RecursiveIterator);
return SUCCESS;
http://cvs.php.net/diff.php/php-src/ext/spl/internal/cachingiterator.inc?r1=1.7.2.1&r2=1.7.2.2&ty=u
Index: php-src/ext/spl/internal/cachingiterator.inc
diff -u php-src/ext/spl/internal/cachingiterator.inc:1.7.2.1
php-src/ext/spl/internal/cachingiterator.inc:1.7.2.2
--- php-src/ext/spl/internal/cachingiterator.inc:1.7.2.1 Wed Sep 14
23:33:04 2005
+++ php-src/ext/spl/internal/cachingiterator.inc Mon Oct 3 12:05:08 2005
@@ -27,8 +27,10 @@
*/
class CachingIterator implements OuterIterator
{
- const CALL_TOSTRING = 1;
- const CATCH_GET_CHILD = 2;
+ const CALL_TOSTRING = 1;
+ const CATCH_GET_CHILD = 2;
+ const TOSTRING_USE_KEY = 4;
+ const TOSTRING_USE_CURRENT = 8;
private $it;
private $current;
@@ -44,8 +46,13 @@
*/
function __construct(Iterator $it, $flags = self::CALL_TOSTRING)
{
+ if ((($flags & self::CALL_TOSTRING) && ($flags &
(self::TOSTRING_USE_KEY|self::TOSTRING_USE_CURRENT)))
+ || ((flags &
(self::CIT_TOSTRING_USE_KEY|self::CIT_TOSTRING_USE_CURRENT)) ==
(self::CIT_TOSTRING_USE_KEY|self::CIT_TOSTRING_USE_CURRENT)))
+ {
+ throw new InvalidArgumentException('Flags must contain
only one of CIT_CALL_TOSTRING, CIT_TOSTRING_USE_KEY, CIT_TOSTRING_USE_CURRENT');
+ }
$this->it = $it;
- $this->flags = $flags &
(self::CALL_TOSTRING|self::CATCH_GET_CHILD);
+ $this->flags = $flags & (0x0000FFFF);
$this->next();
}
@@ -123,7 +130,16 @@
*/
function __toString()
{
- if (!$this->flags & self::CALL_TOSTRING) {
+ if ($this->flags & self::TOSTRING_USE_KEY)
+ {
+ return $this->key;
+ }
+ else if ($this->flags & self::TOSTRING_USE_CURRENT)
+ {
+ return $this->current;
+ }
+ if (!$this->flags & self::CALL_TOSTRING)
+ {
throw new exception('CachingIterator does not fetch
string value (see CachingIterator::__construct)');
}
return $this->strValue;
http://cvs.php.net/diff.php/php-src/ext/simplexml/php_simplexml_exports.h?r1=1.3&r2=1.3.2.1&ty=u
Index: php-src/ext/simplexml/php_simplexml_exports.h
diff -u php-src/ext/simplexml/php_simplexml_exports.h:1.3
php-src/ext/simplexml/php_simplexml_exports.h:1.3.2.1
--- php-src/ext/simplexml/php_simplexml_exports.h:1.3 Wed Aug 3 10:07:45 2005
+++ php-src/ext/simplexml/php_simplexml_exports.h Mon Oct 3 12:05:08 2005
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_simplexml_exports.h,v 1.3 2005/08/03 14:07:45 sniper Exp $ */
+/* $Id: php_simplexml_exports.h,v 1.3.2.1 2005/10/03 16:05:08 helly Exp $ */
#ifndef PHP_SIMPLEXML_EXPORTS_H
#define PHP_SIMPLEXML_EXPORTS_H
@@ -52,6 +52,11 @@
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);
+typedef struct {
+ zend_object_iterator intern;
+ php_sxe_object *sxe;
+} php_sxe_iterator;
+
#endif /* PHP_SIMPLEXML_EXPORTS_H */
/**
http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.151.2.2&r2=1.151.2.3&ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.151.2.2
php-src/ext/simplexml/simplexml.c:1.151.2.3
--- php-src/ext/simplexml/simplexml.c:1.151.2.2 Wed Aug 31 13:00:46 2005
+++ php-src/ext/simplexml/simplexml.c Mon Oct 3 12:05:08 2005
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: simplexml.c,v 1.151.2.2 2005/08/31 17:00:46 rrichards Exp $ */
+/* $Id: simplexml.c,v 1.151.2.3 2005/10/03 16:05:08 helly Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -1383,11 +1383,6 @@
/* }}} */
-typedef struct {
- zend_object_iterator intern;
- php_sxe_object *sxe;
-} php_sxe_iterator;
-
static void php_sxe_iterator_dtor(zend_object_iterator *iter TSRMLS_DC);
static int php_sxe_iterator_valid(zend_object_iterator *iter TSRMLS_DC);
static void php_sxe_iterator_current_data(zend_object_iterator *iter, zval
***data TSRMLS_DC);
@@ -1704,6 +1699,7 @@
sxe.create_object = sxe_object_new;
sxe_class_entry = zend_register_internal_class(&sxe TSRMLS_CC);
sxe_class_entry->get_iterator = php_sxe_get_iterator;
+ sxe_class_entry->iterator_funcs.funcs = &php_sxe_iterator_funcs;
zend_class_implements(sxe_class_entry TSRMLS_CC, 1,
zend_ce_traversable);
sxe_object_handlers.get_method =
zend_get_std_object_handlers()->get_method;
sxe_object_handlers.get_constructor =
zend_get_std_object_handlers()->get_constructor;
@@ -1742,7 +1738,7 @@
{
php_info_print_table_start();
php_info_print_table_header(2, "Simplexml support", "enabled");
- php_info_print_table_row(2, "Revision", "$Revision: 1.151.2.2 $");
+ php_info_print_table_row(2, "Revision", "$Revision: 1.151.2.3 $");
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