2003-10-18 01:19:44 +08:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Zend Engine |
|
|
|
|
+----------------------------------------------------------------------+
|
2017-01-02 23:30:12 +08:00
|
|
|
| Copyright (c) 1998-2017 Zend Technologies Ltd. (http://www.zend.com) |
|
2003-10-18 01:19:44 +08:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| This source file is subject to version 2.00 of the Zend license, |
|
2015-01-03 17:22:58 +08:00
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
2003-10-18 01:19:44 +08:00
|
|
|
| available through the world-wide-web at the following url: |
|
|
|
|
| http://www.zend.com/license/2_00.txt. |
|
|
|
|
| If you did not receive a copy of the Zend license and are unable to |
|
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
| license@zend.com so we can mail you a copy immediately. |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Author: Wez Furlong <wez@thebrainroom.com> |
|
|
|
|
| Marcus Boerger <helly@php.net> |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
#include "zend.h"
|
|
|
|
#include "zend_API.h"
|
|
|
|
|
|
|
|
static zend_class_entry zend_iterator_class_entry;
|
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
static void iter_wrapper_free(zend_object *object);
|
|
|
|
static void iter_wrapper_dtor(zend_object *object);
|
2014-02-12 22:08:11 +08:00
|
|
|
|
2003-10-18 01:19:44 +08:00
|
|
|
static zend_object_handlers iterator_object_handlers = {
|
2014-04-09 05:50:15 +08:00
|
|
|
0,
|
2014-08-21 15:17:05 +08:00
|
|
|
iter_wrapper_free,
|
2014-02-12 22:08:11 +08:00
|
|
|
iter_wrapper_dtor,
|
|
|
|
NULL,
|
2003-10-18 01:19:44 +08:00
|
|
|
NULL, /* prop read */
|
|
|
|
NULL, /* prop write */
|
|
|
|
NULL, /* read dim */
|
|
|
|
NULL, /* write dim */
|
|
|
|
NULL,
|
|
|
|
NULL, /* get */
|
|
|
|
NULL, /* set */
|
2003-11-11 02:05:02 +08:00
|
|
|
NULL, /* has prop */
|
|
|
|
NULL, /* unset prop */
|
|
|
|
NULL, /* has dim */
|
|
|
|
NULL, /* unset dim */
|
2003-10-18 01:19:44 +08:00
|
|
|
NULL, /* props get */
|
|
|
|
NULL, /* method get */
|
|
|
|
NULL, /* call */
|
|
|
|
NULL, /* get ctor */
|
|
|
|
NULL, /* get class name */
|
|
|
|
NULL, /* compare */
|
2004-05-04 23:03:28 +08:00
|
|
|
NULL, /* cast */
|
2014-12-13 02:57:34 +08:00
|
|
|
NULL, /* count */
|
|
|
|
NULL, /* get_debug_info */
|
|
|
|
NULL, /* get_closure */
|
|
|
|
NULL, /* get_gc */
|
|
|
|
NULL, /* do_operation */
|
|
|
|
NULL /* compare */
|
2003-10-18 01:19:44 +08:00
|
|
|
};
|
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
ZEND_API void zend_register_iterator_wrapper(void)
|
2003-10-18 01:19:44 +08:00
|
|
|
{
|
|
|
|
INIT_CLASS_ENTRY(zend_iterator_class_entry, "__iterator_wrapper", NULL);
|
|
|
|
}
|
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
static void iter_wrapper_free(zend_object *object)
|
2003-10-18 01:19:44 +08:00
|
|
|
{
|
|
|
|
zend_object_iterator *iter = (zend_object_iterator*)object;
|
2014-12-14 06:06:14 +08:00
|
|
|
iter->funcs->dtor(iter);
|
2003-10-18 01:19:44 +08:00
|
|
|
}
|
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
static void iter_wrapper_dtor(zend_object *object)
|
2014-08-21 15:17:05 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
ZEND_API void zend_iterator_init(zend_object_iterator *iter)
|
2003-10-18 01:19:44 +08:00
|
|
|
{
|
2014-12-14 06:06:14 +08:00
|
|
|
zend_object_std_init(&iter->std, &zend_iterator_class_entry);
|
2014-02-26 19:01:08 +08:00
|
|
|
iter->std.handlers = &iterator_object_handlers;
|
2003-10-18 01:19:44 +08:00
|
|
|
}
|
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
ZEND_API void zend_iterator_dtor(zend_object_iterator *iter)
|
2014-02-28 15:03:43 +08:00
|
|
|
{
|
2017-10-27 06:28:58 +08:00
|
|
|
if (GC_DELREF(&iter->std) > 0) {
|
2014-02-28 15:03:43 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
zend_objects_store_del(&iter->std);
|
2014-02-28 15:03:43 +08:00
|
|
|
}
|
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
ZEND_API zend_object_iterator* zend_iterator_unwrap(zval *array_ptr)
|
2003-10-18 01:19:44 +08:00
|
|
|
{
|
2016-06-08 17:11:47 +08:00
|
|
|
ZEND_ASSERT(Z_TYPE_P(array_ptr) == IS_OBJECT);
|
|
|
|
if (Z_OBJ_HT_P(array_ptr) == &iterator_object_handlers) {
|
2014-09-16 05:34:27 +08:00
|
|
|
return (zend_object_iterator *)Z_OBJ_P(array_ptr);
|
2003-10-18 01:19:44 +08:00
|
|
|
}
|
2014-09-16 05:34:27 +08:00
|
|
|
return NULL;
|
2003-10-18 01:19:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* tab-width: 4
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* indent-tabs-mode: t
|
|
|
|
* End:
|
2017-07-05 00:12:45 +08:00
|
|
|
* vim600: sw=4 ts=4 fdm=marker
|
|
|
|
* vim<600: sw=4 ts=4
|
2003-10-18 01:19:44 +08:00
|
|
|
*/
|