diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index 3b1da6d98c536..217f3aa19c038 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -23,6 +23,7 @@ #include "ext/standard/info.h" #include "zend_exceptions.h" #include "zend_interfaces.h" +#include "ext/pcre/php_pcre.h" #include "php_spl.h" #include "spl_functions.h" @@ -113,6 +114,53 @@ typedef struct _spl_recursive_it_iterator { zend_object_iterator intern; } spl_recursive_it_iterator; +typedef struct _spl_cbfilter_it_intern { + zend_fcall_info fci; + zend_fcall_info_cache fcc; + zend_object *object; +} _spl_cbfilter_it_intern; + +typedef struct _spl_dual_it_object { + struct { + zval zobject; + zend_class_entry *ce; + zend_object *object; + zend_object_iterator *iterator; + } inner; + struct { + zval data; + zval key; + zend_long pos; + } current; + dual_it_type dit_type; + union { + struct { + zend_long offset; + zend_long count; + } limit; + struct { + zend_long flags; /* CIT_* */ + zend_string *zstr; + zval zchildren; + zval zcache; + } caching; + struct { + zval zarrayit; + zend_object_iterator *iterator; + } append; + struct { + zend_long flags; + zend_long preg_flags; + pcre_cache_entry *pce; + zend_string *regex; + regex_mode mode; + int use_flags; + } regex; + _spl_cbfilter_it_intern *cbfilter; + } u; + zend_object std; +} spl_dual_it_object; + static zend_object_handlers spl_handlers_rec_it_it; static zend_object_handlers spl_handlers_dual_it; @@ -123,6 +171,12 @@ static inline spl_recursive_it_object *spl_recursive_it_from_obj(zend_object *ob #define Z_SPLRECURSIVE_IT_P(zv) spl_recursive_it_from_obj(Z_OBJ_P((zv))) +static inline spl_dual_it_object *spl_dual_it_from_obj(zend_object *obj) /* {{{ */ { + return (spl_dual_it_object*)((char*)(obj) - XtOffsetOf(spl_dual_it_object, std)); +} /* }}} */ + +#define Z_SPLDUAL_IT_P(zv) spl_dual_it_from_obj(Z_OBJ_P((zv))) + #define SPL_FETCH_AND_CHECK_DUAL_IT(var, objzval) \ do { \ spl_dual_it_object *it = Z_SPLDUAL_IT_P(objzval); \ diff --git a/ext/spl/spl_iterators.h b/ext/spl/spl_iterators.h index 1f42201b769cf..61e899de34f2b 100644 --- a/ext/spl/spl_iterators.h +++ b/ext/spl/spl_iterators.h @@ -19,7 +19,6 @@ #include "php.h" #include "php_spl.h" -#include "ext/pcre/php_pcre.h" extern PHPAPI zend_class_entry *spl_ce_AppendIterator; extern PHPAPI zend_class_entry *spl_ce_CachingIterator; @@ -99,59 +98,6 @@ typedef enum { REGIT_MODE_MAX } regex_mode; -typedef struct _spl_cbfilter_it_intern { - zend_fcall_info fci; - zend_fcall_info_cache fcc; - zend_object *object; -} _spl_cbfilter_it_intern; - -typedef struct _spl_dual_it_object { - struct { - zval zobject; - zend_class_entry *ce; - zend_object *object; - zend_object_iterator *iterator; - } inner; - struct { - zval data; - zval key; - zend_long pos; - } current; - dual_it_type dit_type; - union { - struct { - zend_long offset; - zend_long count; - } limit; - struct { - zend_long flags; /* CIT_* */ - zend_string *zstr; - zval zchildren; - zval zcache; - } caching; - struct { - zval zarrayit; - zend_object_iterator *iterator; - } append; - struct { - zend_long flags; - zend_long preg_flags; - pcre_cache_entry *pce; - zend_string *regex; - regex_mode mode; - int use_flags; - } regex; - _spl_cbfilter_it_intern *cbfilter; - } u; - zend_object std; -} spl_dual_it_object; - -static inline spl_dual_it_object *spl_dual_it_from_obj(zend_object *obj) /* {{{ */ { - return (spl_dual_it_object*)((char*)(obj) - XtOffsetOf(spl_dual_it_object, std)); -} /* }}} */ - -#define Z_SPLDUAL_IT_P(zv) spl_dual_it_from_obj(Z_OBJ_P((zv))) - typedef int (*spl_iterator_apply_func_t)(zend_object_iterator *iter, void *puser); PHPAPI int spl_iterator_apply(zval *obj, spl_iterator_apply_func_t apply_func, void *puser);