Annotation of embedaddon/php/Zend/zend_iterators.h, revision 1.1.1.4

1.1       misho       1: /*
                      2:    +----------------------------------------------------------------------+
                      3:    | Zend Engine                                                          |
                      4:    +----------------------------------------------------------------------+
1.1.1.4 ! misho       5:    | Copyright (c) 1998-2014 Zend Technologies Ltd. (http://www.zend.com) |
1.1       misho       6:    +----------------------------------------------------------------------+
                      7:    | This source file is subject to version 2.00 of the Zend license,     |
                      8:    | that is bundled with this package in the file LICENSE, and is        |
                      9:    | available through the world-wide-web at the following url:           |
                     10:    | http://www.zend.com/license/2_00.txt.                                |
                     11:    | If you did not receive a copy of the Zend license and are unable to  |
                     12:    | obtain it through the world-wide-web, please send a note to          |
                     13:    | license@zend.com so we can mail you a copy immediately.              |
                     14:    +----------------------------------------------------------------------+
                     15:    | Author: Wez Furlong <wez@thebrainroom.com>                           |
                     16:    |         Marcus Boerger <helly@php.net>                               |
                     17:    +----------------------------------------------------------------------+
                     18: */
                     19: 
1.1.1.2   misho      20: /* $Id$ */
1.1       misho      21: 
                     22: /* These iterators were designed to operate within the foreach()
                     23:  * structures provided by the engine, but could be extended for use
                     24:  * with other iterative engine opcodes.
                     25:  * These methods have similar semantics to the zend_hash API functions
                     26:  * with similar names.
                     27:  * */
                     28: 
                     29: typedef struct _zend_object_iterator zend_object_iterator;
                     30: 
                     31: typedef struct _zend_object_iterator_funcs {
                     32:        /* release all resources associated with this iterator instance */
                     33:        void (*dtor)(zend_object_iterator *iter TSRMLS_DC);
                     34: 
                     35:        /* check for end of iteration (FAILURE or SUCCESS if data is valid) */
                     36:        int (*valid)(zend_object_iterator *iter TSRMLS_DC);
                     37: 
                     38:        /* fetch the item data for the current element */
                     39:        void (*get_current_data)(zend_object_iterator *iter, zval ***data TSRMLS_DC);
                     40: 
                     41:        /* fetch the key for the current element (return HASH_KEY_IS_STRING or HASH_KEY_IS_LONG) (optional, may be NULL) */
                     42:        int (*get_current_key)(zend_object_iterator *iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC);
                     43: 
                     44:        /* step forwards to next element */
                     45:        void (*move_forward)(zend_object_iterator *iter TSRMLS_DC);
                     46: 
                     47:        /* rewind to start of data (optional, may be NULL) */
                     48:        void (*rewind)(zend_object_iterator *iter TSRMLS_DC);
                     49: 
                     50:        /* invalidate current value/key (optional, may be NULL) */
                     51:        void (*invalidate_current)(zend_object_iterator *iter TSRMLS_DC);
                     52: } zend_object_iterator_funcs;
                     53: 
                     54: struct _zend_object_iterator {
                     55:        void *data;
                     56:        zend_object_iterator_funcs *funcs;
                     57:        ulong index; /* private to fe_reset/fe_fetch opcodes */
                     58: };
                     59: 
                     60: typedef struct _zend_class_iterator_funcs {
                     61:        zend_object_iterator_funcs  *funcs;
                     62:        union _zend_function *zf_new_iterator;
                     63:        union _zend_function *zf_valid;
                     64:        union _zend_function *zf_current;
                     65:        union _zend_function *zf_key;
                     66:        union _zend_function *zf_next;
                     67:        union _zend_function *zf_rewind;
                     68: } zend_class_iterator_funcs;
                     69: 
                     70: enum zend_object_iterator_kind {
                     71:        ZEND_ITER_INVALID,
                     72:        ZEND_ITER_PLAIN_ARRAY,
                     73:        ZEND_ITER_PLAIN_OBJECT,
                     74:        ZEND_ITER_OBJECT
                     75: };
                     76: 
                     77: BEGIN_EXTERN_C()
                     78: /* given a zval, returns stuff that can be used to iterate it. */
                     79: ZEND_API enum zend_object_iterator_kind zend_iterator_unwrap(zval *array_ptr, zend_object_iterator **iter TSRMLS_DC);
                     80: 
                     81: /* given an iterator, wrap it up as a zval for use by the engine opcodes */
                     82: ZEND_API zval *zend_iterator_wrap(zend_object_iterator *iter TSRMLS_DC);
                     83: 
                     84: ZEND_API void zend_register_iterator_wrapper(TSRMLS_D);
                     85: END_EXTERN_C()
                     86: 
                     87: /*
                     88:  * Local variables:
                     89:  * tab-width: 4
                     90:  * c-basic-offset: 4
                     91:  * indent-tabs-mode: t
                     92:  * End:
                     93:  */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>