2003-10-18 01:19:44 +08:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Zend Engine |
|
|
|
|
+----------------------------------------------------------------------+
|
2014-01-03 11:08:10 +08:00
|
|
|
| Copyright (c) 1998-2014 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, |
|
2006-05-10 07:53:23 +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$ */
|
|
|
|
|
|
|
|
/* These iterators were designed to operate within the foreach()
|
|
|
|
* structures provided by the engine, but could be extended for use
|
|
|
|
* with other iterative engine opcodes.
|
|
|
|
* These methods have similar semantics to the zend_hash API functions
|
|
|
|
* with similar names.
|
|
|
|
* */
|
|
|
|
|
|
|
|
typedef struct _zend_object_iterator zend_object_iterator;
|
|
|
|
|
|
|
|
typedef struct _zend_object_iterator_funcs {
|
|
|
|
/* release all resources associated with this iterator instance */
|
|
|
|
void (*dtor)(zend_object_iterator *iter TSRMLS_DC);
|
2006-05-10 07:53:23 +08:00
|
|
|
|
2004-03-09 02:05:41 +08:00
|
|
|
/* check for end of iteration (FAILURE or SUCCESS if data is valid) */
|
|
|
|
int (*valid)(zend_object_iterator *iter TSRMLS_DC);
|
2003-10-18 01:19:44 +08:00
|
|
|
|
|
|
|
/* fetch the item data for the current element */
|
2014-02-10 14:04:30 +08:00
|
|
|
zval *(*get_current_data)(zend_object_iterator *iter TSRMLS_DC);
|
2003-10-18 01:19:44 +08:00
|
|
|
|
2013-02-17 02:13:36 +08:00
|
|
|
/* fetch the key for the current element (optional, may be NULL). The key
|
|
|
|
* should be written into the provided zval* using the ZVAL_* macros. If
|
|
|
|
* this handler is not provided auto-incrementing integer keys will be
|
|
|
|
* used. */
|
|
|
|
void (*get_current_key)(zend_object_iterator *iter, zval *key TSRMLS_DC);
|
2003-10-18 01:19:44 +08:00
|
|
|
|
|
|
|
/* step forwards to next element */
|
|
|
|
void (*move_forward)(zend_object_iterator *iter TSRMLS_DC);
|
2003-10-18 22:56:47 +08:00
|
|
|
|
|
|
|
/* rewind to start of data (optional, may be NULL) */
|
|
|
|
void (*rewind)(zend_object_iterator *iter TSRMLS_DC);
|
2006-05-10 07:53:23 +08:00
|
|
|
|
2004-04-27 23:38:07 +08:00
|
|
|
/* invalidate current value/key (optional, may be NULL) */
|
|
|
|
void (*invalidate_current)(zend_object_iterator *iter TSRMLS_DC);
|
2003-10-18 01:19:44 +08:00
|
|
|
} zend_object_iterator_funcs;
|
|
|
|
|
|
|
|
struct _zend_object_iterator {
|
2014-02-12 22:08:11 +08:00
|
|
|
zend_object std;
|
2003-10-18 01:19:44 +08:00
|
|
|
void *data;
|
|
|
|
zend_object_iterator_funcs *funcs;
|
2003-11-07 18:47:47 +08:00
|
|
|
ulong index; /* private to fe_reset/fe_fetch opcodes */
|
2003-10-18 01:19:44 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _zend_class_iterator_funcs {
|
2003-10-19 02:43:31 +08:00
|
|
|
zend_object_iterator_funcs *funcs;
|
2003-10-18 01:19:44 +08:00
|
|
|
union _zend_function *zf_new_iterator;
|
2004-03-09 02:05:41 +08:00
|
|
|
union _zend_function *zf_valid;
|
2003-10-18 01:19:44 +08:00
|
|
|
union _zend_function *zf_current;
|
|
|
|
union _zend_function *zf_key;
|
|
|
|
union _zend_function *zf_next;
|
|
|
|
union _zend_function *zf_rewind;
|
|
|
|
} zend_class_iterator_funcs;
|
|
|
|
|
|
|
|
enum zend_object_iterator_kind {
|
|
|
|
ZEND_ITER_INVALID,
|
|
|
|
ZEND_ITER_PLAIN_ARRAY,
|
2004-01-25 21:32:02 +08:00
|
|
|
ZEND_ITER_PLAIN_OBJECT,
|
2003-10-18 01:19:44 +08:00
|
|
|
ZEND_ITER_OBJECT
|
|
|
|
};
|
|
|
|
|
2004-02-20 16:03:27 +08:00
|
|
|
BEGIN_EXTERN_C()
|
2003-10-18 01:19:44 +08:00
|
|
|
/* given a zval, returns stuff that can be used to iterate it. */
|
|
|
|
ZEND_API enum zend_object_iterator_kind zend_iterator_unwrap(zval *array_ptr, zend_object_iterator **iter TSRMLS_DC);
|
|
|
|
|
|
|
|
/* given an iterator, wrap it up as a zval for use by the engine opcodes */
|
2014-02-12 22:08:11 +08:00
|
|
|
ZEND_API void zend_iterator_wrap(zend_object_iterator *iter, zval *zv TSRMLS_DC);
|
2003-10-18 01:19:44 +08:00
|
|
|
|
|
|
|
ZEND_API void zend_register_iterator_wrapper(TSRMLS_D);
|
2004-02-20 16:03:27 +08:00
|
|
|
END_EXTERN_C()
|
2003-10-18 01:19:44 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* tab-width: 4
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* indent-tabs-mode: t
|
|
|
|
* End:
|
|
|
|
*/
|