calendar_class.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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: Gustavo Lopes <cataphract@php.net> |
  12. +----------------------------------------------------------------------+
  13. */
  14. #ifndef CALENDAR_CLASS_H
  15. #define CALENDAR_CLASS_H
  16. //redefinition of inline in PHP headers causes problems, so include this before
  17. #include <math.h>
  18. #include <php.h>
  19. #include "intl_error.h"
  20. #include "intl_data.h"
  21. #ifndef USE_CALENDAR_POINTER
  22. typedef void Calendar;
  23. #else
  24. using icu::Calendar;
  25. #endif
  26. typedef struct {
  27. // error handling
  28. intl_error err;
  29. // ICU calendar
  30. Calendar* ucal;
  31. zend_object zo;
  32. } Calendar_object;
  33. static inline Calendar_object *php_intl_calendar_fetch_object(zend_object *obj) {
  34. return (Calendar_object *)((char*)(obj) - XtOffsetOf(Calendar_object, zo));
  35. }
  36. #define Z_INTL_CALENDAR_P(zv) php_intl_calendar_fetch_object(Z_OBJ_P(zv))
  37. #define CALENDAR_ERROR(co) (co)->err
  38. #define CALENDAR_ERROR_P(co) &(CALENDAR_ERROR(co))
  39. #define CALENDAR_ERROR_CODE(co) INTL_ERROR_CODE(CALENDAR_ERROR(co))
  40. #define CALENDAR_ERROR_CODE_P(co) &(INTL_ERROR_CODE(CALENDAR_ERROR(co)))
  41. #define CALENDAR_METHOD_INIT_VARS INTL_METHOD_INIT_VARS(Calendar, co)
  42. #define CALENDAR_METHOD_FETCH_OBJECT_NO_CHECK INTL_METHOD_FETCH_OBJECT(INTL_CALENDAR, co)
  43. #define CALENDAR_METHOD_FETCH_OBJECT \
  44. CALENDAR_METHOD_FETCH_OBJECT_NO_CHECK; \
  45. if (co->ucal == NULL) \
  46. { \
  47. zend_throw_error(NULL, "Found unconstructed IntlCalendar"); \
  48. RETURN_THROWS(); \
  49. }
  50. void calendar_object_create(zval *object, Calendar *calendar);
  51. Calendar *calendar_fetch_native_calendar(zend_object *object);
  52. void calendar_object_construct(zval *object, Calendar *calendar);
  53. void calendar_register_IntlCalendar_class(void);
  54. extern zend_class_entry *Calendar_ce_ptr, *GregorianCalendar_ce_ptr;
  55. extern zend_object_handlers Calendar_handlers;
  56. #endif /* #ifndef CALENDAR_CLASS_H */