summaryrefslogtreecommitdiff
path: root/Zend/zend_iterators.c
diff options
context:
space:
mode:
authorStanley Sufficool <ssufficool@php.net>2014-10-20 21:33:32 -0700
committerStanley Sufficool <ssufficool@php.net>2014-10-20 21:33:32 -0700
commit8defcb855ab01d9c8ab4759cb793d80149b55a8c (patch)
treeed51eb30a2cbc92b102557498fb3e4113da1bb07 /Zend/zend_iterators.c
parent9c7dbb0487f5991fde03873ea8f5e66d6688415f (diff)
parentbaddb1c73a170ef1d2c31bd54cddbc6e1ab596b9 (diff)
downloadphp-git-8defcb855ab01d9c8ab4759cb793d80149b55a8c.tar.gz
Merge branch 'master' of https://git.php.net/push/php-src
* 'master' of https://git.php.net/push/php-src: (6215 commits) Extra comma Moved proxy object support in ASSIGN_ADD (and family) from VM to slow paths of corresponding operators Simplification zend_get_property_info_quick() cleanup and optimization initialize lineno before calling compile file file in phar Use ADDREF instead of DUP, it must be enough. Removed old irrelevant comment fixed compilation error Fix bug #68262: Broken reference across cloned objects export functions needed for phpdbg Fixed compilation Optimized property access handlers. Removed EG(std_property_info). Fixed bug #68199 (PDO::pgsqlGetNotify doesn't support NOTIFY payloads) Don't make difference between undefined and unaccessible properies when call __get() and family Don't make useless CSE array_pop/array_shift optimization check for zlib headers as well as lib for mysqlnd a realpath cache key can be int or float, catching this News entry for new curl constants News entry for new curl constants ...
Diffstat (limited to 'Zend/zend_iterators.c')
-rw-r--r--Zend/zend_iterators.c60
1 files changed, 27 insertions, 33 deletions
diff --git a/Zend/zend_iterators.c b/Zend/zend_iterators.c
index f2c27fa63d..8edd5dbdc4 100644
--- a/Zend/zend_iterators.c
+++ b/Zend/zend_iterators.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) 1998-2013 Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright (c) 1998-2014 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -24,8 +24,14 @@
static zend_class_entry zend_iterator_class_entry;
+static void iter_wrapper_free(zend_object *object TSRMLS_DC);
+static void iter_wrapper_dtor(zend_object *object TSRMLS_DC);
+
static zend_object_handlers iterator_object_handlers = {
- ZEND_OBJECTS_STORE_HANDLERS,
+ 0,
+ iter_wrapper_free,
+ iter_wrapper_dtor,
+ NULL,
NULL, /* prop read */
NULL, /* prop write */
NULL, /* read dim */
@@ -41,7 +47,6 @@ static zend_object_handlers iterator_object_handlers = {
NULL, /* method get */
NULL, /* call */
NULL, /* get ctor */
- NULL, /* get_ce */
NULL, /* get class name */
NULL, /* compare */
NULL, /* cast */
@@ -51,51 +56,40 @@ static zend_object_handlers iterator_object_handlers = {
ZEND_API void zend_register_iterator_wrapper(TSRMLS_D)
{
INIT_CLASS_ENTRY(zend_iterator_class_entry, "__iterator_wrapper", NULL);
- str_free(zend_iterator_class_entry.name);
- zend_iterator_class_entry.name = "__iterator_wrapper";
}
-static void iter_wrapper_dtor(void *object, zend_object_handle handle TSRMLS_DC)
+static void iter_wrapper_free(zend_object *object TSRMLS_DC)
{
zend_object_iterator *iter = (zend_object_iterator*)object;
iter->funcs->dtor(iter TSRMLS_CC);
}
-ZEND_API zval *zend_iterator_wrap(zend_object_iterator *iter TSRMLS_DC)
+static void iter_wrapper_dtor(zend_object *object TSRMLS_DC)
{
- zval *wrapped;
-
- MAKE_STD_ZVAL(wrapped);
- Z_TYPE_P(wrapped) = IS_OBJECT;
- Z_OBJ_HANDLE_P(wrapped) = zend_objects_store_put(iter, iter_wrapper_dtor, NULL, NULL TSRMLS_CC);
- Z_OBJ_HT_P(wrapped) = &iterator_object_handlers;
+}
- return wrapped;
+ZEND_API void zend_iterator_init(zend_object_iterator *iter TSRMLS_DC)
+{
+ zend_object_std_init(&iter->std, &zend_iterator_class_entry TSRMLS_CC);
+ iter->std.handlers = &iterator_object_handlers;
}
-ZEND_API enum zend_object_iterator_kind zend_iterator_unwrap(
- zval *array_ptr, zend_object_iterator **iter TSRMLS_DC)
+ZEND_API void zend_iterator_dtor(zend_object_iterator *iter TSRMLS_DC)
{
- switch (Z_TYPE_P(array_ptr)) {
- case IS_OBJECT:
- if (Z_OBJ_HT_P(array_ptr) == &iterator_object_handlers) {
- *iter = (zend_object_iterator *)zend_object_store_get_object(array_ptr TSRMLS_CC);
- return ZEND_ITER_OBJECT;
- }
- if (Z_OBJPROP_P(array_ptr)) {
- return ZEND_ITER_PLAIN_OBJECT;
- }
- return ZEND_ITER_INVALID;
+ if (--GC_REFCOUNT(iter) > 0) {
+ return;
+ }
- case IS_ARRAY:
- if (Z_ARRVAL_P(array_ptr)) {
- return ZEND_ITER_PLAIN_ARRAY;
- }
- return ZEND_ITER_INVALID;
+ zend_objects_store_del(&iter->std TSRMLS_CC);
+}
- default:
- return ZEND_ITER_INVALID;
+ZEND_API zend_object_iterator* zend_iterator_unwrap(zval *array_ptr TSRMLS_DC)
+{
+ if (Z_TYPE_P(array_ptr) &&
+ Z_OBJ_HT_P(array_ptr) == &iterator_object_handlers) {
+ return (zend_object_iterator *)Z_OBJ_P(array_ptr);
}
+ return NULL;
}
/*