breakiterator_class.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 7 |
  4. +----------------------------------------------------------------------+
  5. | This source file is subject to version 3.01 of the PHP license, |
  6. | that is bundled with this package in the file LICENSE, and is |
  7. | available through the world-wide-web at the following url: |
  8. | http://www.php.net/license/3_01.txt |
  9. | If you did not receive a copy of the PHP license and are unable to |
  10. | obtain it through the world-wide-web, please send a note to |
  11. | license@php.net so we can mail you a copy immediately. |
  12. +----------------------------------------------------------------------+
  13. | Authors: Gustavo Lopes <cataphract@php.net> |
  14. +----------------------------------------------------------------------+
  15. */
  16. #ifndef BREAKITERATOR_CLASS_H
  17. #define BREAKITERATOR_CLASS_H
  18. //redefinition of inline in PHP headers causes problems, so include this before
  19. #include <math.h>
  20. #include <php.h>
  21. #include "../intl_error.h"
  22. #include "../intl_data.h"
  23. #ifndef USE_BREAKITERATOR_POINTER
  24. typedef void BreakIterator;
  25. #else
  26. using icu::BreakIterator;
  27. #endif
  28. typedef struct {
  29. // error handling
  30. intl_error err;
  31. // ICU break iterator
  32. BreakIterator* biter;
  33. // current text
  34. zval text;
  35. zend_object zo;
  36. } BreakIterator_object;
  37. static inline BreakIterator_object *php_intl_breakiterator_fetch_object(zend_object *obj) {
  38. return (BreakIterator_object *)((char*)(obj) - XtOffsetOf(BreakIterator_object, zo));
  39. }
  40. #define Z_INTL_BREAKITERATOR_P(zv) php_intl_breakiterator_fetch_object(Z_OBJ_P(zv))
  41. #define BREAKITER_ERROR(bio) (bio)->err
  42. #define BREAKITER_ERROR_P(bio) &(BREAKITER_ERROR(bio))
  43. #define BREAKITER_ERROR_CODE(bio) INTL_ERROR_CODE(BREAKITER_ERROR(bio))
  44. #define BREAKITER_ERROR_CODE_P(bio) &(INTL_ERROR_CODE(BREAKITER_ERROR(bio)))
  45. #define BREAKITER_METHOD_INIT_VARS INTL_METHOD_INIT_VARS(BreakIterator, bio)
  46. #define BREAKITER_METHOD_FETCH_OBJECT_NO_CHECK INTL_METHOD_FETCH_OBJECT(INTL_BREAKITERATOR, bio)
  47. #define BREAKITER_METHOD_FETCH_OBJECT \
  48. BREAKITER_METHOD_FETCH_OBJECT_NO_CHECK; \
  49. if (bio->biter == NULL) \
  50. { \
  51. intl_errors_set(&bio->err, U_ILLEGAL_ARGUMENT_ERROR, "Found unconstructed BreakIterator", 0); \
  52. RETURN_FALSE; \
  53. }
  54. void breakiterator_object_create(zval *object, BreakIterator *break_iter, int brand_new);
  55. void breakiterator_object_construct(zval *object, BreakIterator *break_iter);
  56. void breakiterator_register_BreakIterator_class(void);
  57. extern zend_class_entry *BreakIterator_ce_ptr,
  58. *RuleBasedBreakIterator_ce_ptr;
  59. extern zend_object_handlers BreakIterator_handlers;
  60. #endif /* #ifndef BREAKITERATOR_CLASS_H */