timezone_class.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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@netcabo.pt> |
  12. +----------------------------------------------------------------------+
  13. */
  14. #ifndef TIMEZONE_CLASS_H
  15. #define TIMEZONE_CLASS_H
  16. //redefinition of inline in PHP headers causes problems, so include this before
  17. #include <math.h>
  18. //fixes the build on windows for old versions of ICU
  19. #include <stdio.h>
  20. #include <php.h>
  21. #include "intl_error.h"
  22. #include "intl_data.h"
  23. #ifndef USE_TIMEZONE_POINTER
  24. typedef void TimeZone;
  25. #else
  26. using icu::TimeZone;
  27. #endif
  28. typedef struct {
  29. // error handling
  30. intl_error err;
  31. // ICU TimeZone
  32. const TimeZone *utimezone;
  33. //whether to delete the timezone on object free
  34. bool should_delete;
  35. zend_object zo;
  36. } TimeZone_object;
  37. static inline TimeZone_object *php_intl_timezone_fetch_object(zend_object *obj) {
  38. return (TimeZone_object *)((char*)(obj) - XtOffsetOf(TimeZone_object, zo));
  39. }
  40. #define Z_INTL_TIMEZONE_P(zv) php_intl_timezone_fetch_object(Z_OBJ_P(zv))
  41. #define TIMEZONE_ERROR(to) (to)->err
  42. #define TIMEZONE_ERROR_P(to) &(TIMEZONE_ERROR(to))
  43. #define TIMEZONE_ERROR_CODE(co) INTL_ERROR_CODE(TIMEZONE_ERROR(to))
  44. #define TIMEZONE_ERROR_CODE_P(co) &(INTL_ERROR_CODE(TIMEZONE_ERROR(to)))
  45. #define TIMEZONE_METHOD_INIT_VARS INTL_METHOD_INIT_VARS(TimeZone, to)
  46. #define TIMEZONE_METHOD_FETCH_OBJECT_NO_CHECK INTL_METHOD_FETCH_OBJECT(INTL_TIMEZONE, to)
  47. #define TIMEZONE_METHOD_FETCH_OBJECT\
  48. TIMEZONE_METHOD_FETCH_OBJECT_NO_CHECK; \
  49. if (to->utimezone == NULL) { \
  50. zend_throw_error(NULL, "Found unconstructed IntlTimeZone"); \
  51. RETURN_THROWS(); \
  52. }
  53. zval *timezone_convert_to_datetimezone(const TimeZone *timeZone, intl_error *outside_error, const char *func, zval *ret);
  54. TimeZone *timezone_process_timezone_argument(zval *zv_timezone, intl_error *error, const char *func);
  55. void timezone_object_construct(const TimeZone *zone, zval *object, int owned);
  56. void timezone_register_IntlTimeZone_class(void);
  57. extern zend_class_entry *TimeZone_ce_ptr;
  58. extern zend_object_handlers TimeZone_handlers;
  59. #endif /* #ifndef TIMEZONE_CLASS_H */