formatter_class.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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: Stanislav Malyshev <stas@zend.com> |
  14. +----------------------------------------------------------------------+
  15. */
  16. #ifndef FORMATTER_CLASS_H
  17. #define FORMATTER_CLASS_H
  18. #include <php.h>
  19. #include "intl_common.h"
  20. #include "intl_error.h"
  21. #include "intl_data.h"
  22. #include "formatter_data.h"
  23. typedef struct {
  24. formatter_data nf_data;
  25. zend_object zo;
  26. } NumberFormatter_object;
  27. static inline NumberFormatter_object *php_intl_number_format_fetch_object(zend_object *obj) {
  28. return (NumberFormatter_object *)((char*)(obj) - XtOffsetOf(NumberFormatter_object, zo));
  29. }
  30. #define Z_INTL_NUMBERFORMATTER_P(zv) php_intl_number_format_fetch_object(Z_OBJ_P(zv))
  31. void formatter_register_class( void );
  32. extern zend_class_entry *NumberFormatter_ce_ptr;
  33. /* Auxiliary macros */
  34. #define FORMATTER_METHOD_INIT_VARS INTL_METHOD_INIT_VARS(NumberFormatter, nfo)
  35. #define FORMATTER_OBJECT(nfo) (nfo)->nf_data.unum
  36. #define FORMATTER_METHOD_FETCH_OBJECT_NO_CHECK INTL_METHOD_FETCH_OBJECT(INTL_NUMBERFORMATTER, nfo)
  37. #define FORMATTER_METHOD_FETCH_OBJECT \
  38. FORMATTER_METHOD_FETCH_OBJECT_NO_CHECK; \
  39. if (FORMATTER_OBJECT(nfo) == NULL) \
  40. { \
  41. intl_errors_set(&nfo->nf_data.error, U_ILLEGAL_ARGUMENT_ERROR, \
  42. "Found unconstructed NumberFormatter", 0); \
  43. RETURN_FALSE; \
  44. }
  45. #endif // #ifndef FORMATTER_CLASS_H