common_enum.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. #ifndef INTL_COMMON_ENUM_H
  16. #define INTL_COMMON_ENUM_H
  17. #include <unicode/umachine.h>
  18. #ifdef __cplusplus
  19. #include <unicode/strenum.h>
  20. extern "C" {
  21. #include <math.h>
  22. #endif
  23. #include <php.h>
  24. #include "../intl_error.h"
  25. #include "../intl_data.h"
  26. #ifdef __cplusplus
  27. }
  28. #endif
  29. #define INTLITERATOR_ERROR(ii) (ii)->err
  30. #define INTLITERATOR_ERROR_P(ii) &(INTLITERATOR_ERROR(ii))
  31. #define INTLITERATOR_ERROR_CODE(ii) INTL_ERROR_CODE(INTLITERATOR_ERROR(ii))
  32. #define INTLITERATOR_ERROR_CODE_P(ii) &(INTL_ERROR_CODE(INTLITERATOR_ERROR(ii)))
  33. #define INTLITERATOR_METHOD_INIT_VARS INTL_METHOD_INIT_VARS(IntlIterator, ii)
  34. #define INTLITERATOR_METHOD_FETCH_OBJECT_NO_CHECK INTL_METHOD_FETCH_OBJECT(INTL_ITERATOR, ii)
  35. #define INTLITERATOR_METHOD_FETCH_OBJECT\
  36. object = ZEND_THIS; \
  37. INTLITERATOR_METHOD_FETCH_OBJECT_NO_CHECK; \
  38. if (ii->iterator == NULL) { \
  39. zend_throw_error(NULL, "Found unconstructed IntlIterator"); \
  40. RETURN_THROWS(); \
  41. }
  42. typedef struct {
  43. intl_error err;
  44. zend_object_iterator *iterator;
  45. zend_object zo;
  46. } IntlIterator_object;
  47. static inline IntlIterator_object *php_intl_iterator_fetch_object(zend_object *obj) {
  48. return (IntlIterator_object *)((char*)(obj) - XtOffsetOf(IntlIterator_object, zo));
  49. }
  50. #define Z_INTL_ITERATOR_P(zv) php_intl_iterator_fetch_object(Z_OBJ_P(zv))
  51. typedef struct {
  52. zend_object_iterator zoi;
  53. zval current;
  54. zval wrapping_obj;
  55. void (*destroy_it)(zend_object_iterator *iterator);
  56. } zoi_with_current;
  57. extern zend_class_entry *IntlIterator_ce_ptr;
  58. extern zend_object_handlers IntlIterator_handlers;
  59. U_CFUNC void zoi_with_current_dtor(zend_object_iterator *iter);
  60. U_CFUNC int zoi_with_current_valid(zend_object_iterator *iter);
  61. U_CFUNC zval *zoi_with_current_get_current_data(zend_object_iterator *iter);
  62. U_CFUNC void zoi_with_current_invalidate_current(zend_object_iterator *iter);
  63. #ifdef __cplusplus
  64. using icu::StringEnumeration;
  65. U_CFUNC void IntlIterator_from_StringEnumeration(StringEnumeration *se, zval *object);
  66. #endif
  67. U_CFUNC void intl_register_IntlIterator_class(void);
  68. #endif // INTL_COMMON_ENUM_H