1 /* 2 +----------------------------------------------------------------------+ 3 | This source file is subject to version 3.01 of the PHP license, | 4 | that is bundled with this package in the file LICENSE, and is | 5 | available through the world-wide-web at the following url: | 6 | https://www.php.net/license/3_01.txt | 7 | If you did not receive a copy of the PHP license and are unable to | 8 | obtain it through the world-wide-web, please send a note to | 9 | license@php.net so we can mail you a copy immediately. | 10 +----------------------------------------------------------------------+ 11 | Authors: Vadim Savchuk <vsavchuk@productengine.com> | 12 | Dmitry Lakhtyuk <dlakhtyuk@productengine.com> | 13 +----------------------------------------------------------------------+ 14 */ 15 16 #ifndef INTL_COMMON_ENUM_H 17 #define INTL_COMMON_ENUM_H 18 19 #include <unicode/umachine.h> 20 #ifdef __cplusplus 21 #include <unicode/strenum.h> 22 extern "C" { 23 #include <math.h> 24 #endif 25 #include <php.h> 26 #include "../intl_error.h" 27 #include "../intl_data.h" 28 #ifdef __cplusplus 29 } 30 #endif 31 32 #define INTLITERATOR_ERROR(ii) (ii)->err 33 #define INTLITERATOR_ERROR_P(ii) &(INTLITERATOR_ERROR(ii)) 34 35 #define INTLITERATOR_ERROR_CODE(ii) INTL_ERROR_CODE(INTLITERATOR_ERROR(ii)) 36 #define INTLITERATOR_ERROR_CODE_P(ii) &(INTL_ERROR_CODE(INTLITERATOR_ERROR(ii))) 37 38 #define INTLITERATOR_METHOD_INIT_VARS INTL_METHOD_INIT_VARS(IntlIterator, ii) 39 #define INTLITERATOR_METHOD_FETCH_OBJECT_NO_CHECK INTL_METHOD_FETCH_OBJECT(INTL_ITERATOR, ii) 40 #define INTLITERATOR_METHOD_FETCH_OBJECT\ 41 object = ZEND_THIS; \ 42 INTLITERATOR_METHOD_FETCH_OBJECT_NO_CHECK; \ 43 if (ii->iterator == NULL) { \ 44 zend_throw_error(NULL, "Found unconstructed IntlIterator"); \ 45 RETURN_THROWS(); \ 46 } 47 48 typedef struct { 49 intl_error err; 50 zend_object_iterator *iterator; 51 zend_object zo; 52 } IntlIterator_object; 53 54 php_intl_iterator_fetch_object(zend_object * obj)55static inline IntlIterator_object *php_intl_iterator_fetch_object(zend_object *obj) { 56 return (IntlIterator_object *)((char*)(obj) - XtOffsetOf(IntlIterator_object, zo)); 57 } 58 #define Z_INTL_ITERATOR_P(zv) php_intl_iterator_fetch_object(Z_OBJ_P(zv)) 59 60 typedef struct { 61 zend_object_iterator zoi; 62 zval current; 63 zval wrapping_obj; 64 void (*destroy_it)(zend_object_iterator *iterator); 65 } zoi_with_current; 66 67 extern zend_class_entry *IntlIterator_ce_ptr; 68 extern zend_object_handlers IntlIterator_handlers; 69 70 U_CFUNC void zoi_with_current_dtor(zend_object_iterator *iter); 71 U_CFUNC int zoi_with_current_valid(zend_object_iterator *iter); 72 U_CFUNC zval *zoi_with_current_get_current_data(zend_object_iterator *iter); 73 U_CFUNC void zoi_with_current_invalidate_current(zend_object_iterator *iter); 74 75 #ifdef __cplusplus 76 using icu::StringEnumeration; 77 U_CFUNC void IntlIterator_from_StringEnumeration(StringEnumeration *se, zval *object); 78 #endif 79 80 U_CFUNC void intl_register_common_symbols(int module_number); 81 82 #endif // INTL_COMMON_ENUM_H 83