timezone_class.h 2.9 KB

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