U_CFUNC zend_object_iterator *_breakiterator_get_iterator( zend_class_entry *ce, zval *object, int by_ref) { BreakIterator_object *bio; if (by_ref) { zend_throw_exception(NULL, "Iteration by reference is not supported", 0); return NULL; } bio = Z_INTL_BREAKITERATOR_P(object); BreakIterator *biter = bio->biter; if (biter == NULL) { zend_throw_exception(NULL, "The BreakIterator is not properly constructed", 0); return NULL; } zoi_with_current *zoi_iter = static_cast<zoi_with_current*>(emalloc(sizeof *zoi_iter)); zend_iterator_init(&zoi_iter->zoi); ZVAL_COPY(&zoi_iter->zoi.data, object); zoi_iter->zoi.funcs = &breakiterator_iterator_funcs; zoi_iter->zoi.index = 0; zoi_iter->destroy_it = _breakiterator_destroy_it; ZVAL_UNDEF(&zoi_iter->wrapping_obj); /* not used; object is in zoi.data */ ZVAL_UNDEF(&zoi_iter->current); return reinterpret_cast<zend_object_iterator *>(zoi_iter); }
void IntlIterator_from_BreakIterator_parts(zval *break_iter_zv, zval *object, parts_iter_key_type key_type) { IntlIterator_object *ii; object_init_ex(object, IntlPartsIterator_ce_ptr); ii = Z_INTL_ITERATOR_P(object); ii->iterator = (zend_object_iterator*)emalloc(sizeof(zoi_break_iter_parts)); zend_iterator_init(ii->iterator); ZVAL_COPY(&ii->iterator->data, break_iter_zv); ii->iterator->funcs = &breakiterator_parts_it_funcs; ii->iterator->index = 0; ((zoi_with_current*)ii->iterator)->destroy_it = _breakiterator_parts_destroy_it; ZVAL_COPY_VALUE(&((zoi_with_current*)ii->iterator)->wrapping_obj, object); ZVAL_UNDEF(&((zoi_with_current*)ii->iterator)->current); ((zoi_break_iter_parts*)ii->iterator)->bio = Z_INTL_BREAKITERATOR_P(break_iter_zv); assert(((zoi_break_iter_parts*)ii->iterator)->bio->biter != NULL); ((zoi_break_iter_parts*)ii->iterator)->key_type = key_type; }
inline BreakIterator *_breakiter_prolog(zend_object_iterator *iter) { BreakIterator_object *bio; bio = Z_INTL_BREAKITERATOR_P(&iter->data); intl_errors_reset(BREAKITER_ERROR_P(bio)); if (bio->biter == NULL) { intl_errors_set(BREAKITER_ERROR_P(bio), U_INVALID_STATE_ERROR, "The BreakIterator object backing the PHP iterator is not " "properly constructed", 0); } return bio->biter; }
#define USE_BREAKITERATOR_POINTER #include "breakiterator_class.h" #include "../intl_convert.h" #include "../locale/locale.h" #include <zend_exceptions.h> } static zend_class_entry *IntlPartsIterator_ce_ptr; static zend_object_handlers IntlPartsIterator_handlers; /* BreakIterator's iterator */ inline BreakIterator *_breakiter_prolog(zend_object_iterator *iter TSRMLS_DC) { BreakIterator_object *bio; bio = Z_INTL_BREAKITERATOR_P(&iter->data); intl_errors_reset(BREAKITER_ERROR_P(bio) TSRMLS_CC); if (bio->biter == NULL) { intl_errors_set(BREAKITER_ERROR_P(bio), U_INVALID_STATE_ERROR, "The BreakIterator object backing the PHP iterator is not " "properly constructed", 0 TSRMLS_CC); } return bio->biter; } static void _breakiterator_destroy_it(zend_object_iterator *iter TSRMLS_DC) { zval_ptr_dtor(&iter->data); } static void _breakiterator_move_forward(zend_object_iterator *iter TSRMLS_DC)