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