calendar_class.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 CALENDAR_CLASS_H
  17. #define CALENDAR_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_CALENDAR_POINTER
  24. typedef void Calendar;
  25. #else
  26. using icu::Calendar;
  27. #endif
  28. typedef struct {
  29. // error handling
  30. intl_error err;
  31. // ICU calendar
  32. Calendar* ucal;
  33. zend_object zo;
  34. } Calendar_object;
  35. static inline Calendar_object *php_intl_calendar_fetch_object(zend_object *obj) {
  36. return (Calendar_object *)((char*)(obj) - XtOffsetOf(Calendar_object, zo));
  37. }
  38. #define Z_INTL_CALENDAR_P(zv) php_intl_calendar_fetch_object(Z_OBJ_P(zv))
  39. #define CALENDAR_ERROR(co) (co)->err
  40. #define CALENDAR_ERROR_P(co) &(CALENDAR_ERROR(co))
  41. #define CALENDAR_ERROR_CODE(co) INTL_ERROR_CODE(CALENDAR_ERROR(co))
  42. #define CALENDAR_ERROR_CODE_P(co) &(INTL_ERROR_CODE(CALENDAR_ERROR(co)))
  43. #define CALENDAR_METHOD_INIT_VARS INTL_METHOD_INIT_VARS(Calendar, co)
  44. #define CALENDAR_METHOD_FETCH_OBJECT_NO_CHECK INTL_METHOD_FETCH_OBJECT(INTL_CALENDAR, co)
  45. #define CALENDAR_METHOD_FETCH_OBJECT \
  46. CALENDAR_METHOD_FETCH_OBJECT_NO_CHECK; \
  47. if (co->ucal == NULL) \
  48. { \
  49. intl_errors_set(&co->err, U_ILLEGAL_ARGUMENT_ERROR, "Found unconstructed IntlCalendar", 0); \
  50. RETURN_FALSE; \
  51. }
  52. void calendar_object_create(zval *object, Calendar *calendar);
  53. Calendar *calendar_fetch_native_calendar(zval *object);
  54. void calendar_object_construct(zval *object, Calendar *calendar);
  55. void calendar_register_IntlCalendar_class(void);
  56. extern zend_class_entry *Calendar_ce_ptr,
  57. *GregorianCalendar_ce_ptr;
  58. extern zend_object_handlers Calendar_handlers;
  59. #endif /* #ifndef CALENDAR_CLASS_H */