calendar_class.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 5 |
  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. #endif
  26. typedef struct {
  27. zend_object zo;
  28. // error handling
  29. intl_error err;
  30. // ICU calendar
  31. Calendar* ucal;
  32. } Calendar_object;
  33. #define CALENDAR_ERROR(co) (co)->err
  34. #define CALENDAR_ERROR_P(co) &(CALENDAR_ERROR(co))
  35. #define CALENDAR_ERROR_CODE(co) INTL_ERROR_CODE(CALENDAR_ERROR(co))
  36. #define CALENDAR_ERROR_CODE_P(co) &(INTL_ERROR_CODE(CALENDAR_ERROR(co)))
  37. #define CALENDAR_METHOD_INIT_VARS INTL_METHOD_INIT_VARS(Calendar, co)
  38. #define CALENDAR_METHOD_FETCH_OBJECT_NO_CHECK INTL_METHOD_FETCH_OBJECT(Calendar, co)
  39. #define CALENDAR_METHOD_FETCH_OBJECT \
  40. CALENDAR_METHOD_FETCH_OBJECT_NO_CHECK; \
  41. if (co->ucal == NULL) \
  42. { \
  43. intl_errors_set(&co->err, U_ILLEGAL_ARGUMENT_ERROR, "Found unconstructed IntlCalendar", 0 TSRMLS_CC); \
  44. RETURN_FALSE; \
  45. }
  46. void calendar_object_create(zval *object, Calendar *calendar TSRMLS_DC);
  47. Calendar *calendar_fetch_native_calendar(zval *object TSRMLS_DC);
  48. void calendar_object_construct(zval *object, Calendar *calendar TSRMLS_DC);
  49. void calendar_register_IntlCalendar_class(TSRMLS_D);
  50. extern zend_class_entry *Calendar_ce_ptr,
  51. *GregorianCalendar_ce_ptr;
  52. extern zend_object_handlers Calendar_handlers;
  53. #endif /* #ifndef CALENDAR_CLASS_H */