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: Stanislav Malyshev <stas@zend.com>                          |
12    +----------------------------------------------------------------------+
13  */
14 
15 #ifndef MSG_FORMAT_CLASS_H
16 #define MSG_FORMAT_CLASS_H
17 
18 #include <php.h>
19 
20 #include <unicode/uconfig.h>
21 
22 #include "../intl_common.h"
23 #include "../intl_error.h"
24 #include "../intl_data.h"
25 
26 #include "msgformat_data.h"
27 
28 typedef struct {
29 	msgformat_data  mf_data;
30 	zend_object     zo;
31 } MessageFormatter_object;
32 
33 
php_intl_messageformatter_fetch_object(zend_object * obj)34 static inline MessageFormatter_object *php_intl_messageformatter_fetch_object(zend_object *obj) {
35 	return (MessageFormatter_object *)((char*)(obj) - XtOffsetOf(MessageFormatter_object, zo));
36 }
37 #define Z_INTL_MESSAGEFORMATTER_P(zv) php_intl_messageformatter_fetch_object(Z_OBJ_P(zv))
38 
39 void msgformat_register_class( void );
40 extern zend_class_entry *MessageFormatter_ce_ptr;
41 
42 /* Auxiliary macros */
43 
44 #define MSG_FORMAT_METHOD_INIT_VARS		INTL_METHOD_INIT_VARS(MessageFormatter, mfo)
45 #define MSG_FORMAT_METHOD_FETCH_OBJECT_NO_CHECK	INTL_METHOD_FETCH_OBJECT(INTL_MESSAGEFORMATTER, mfo)
46 #define MSG_FORMAT_METHOD_FETCH_OBJECT									\
47 	MSG_FORMAT_METHOD_FETCH_OBJECT_NO_CHECK;							\
48 	if (MSG_FORMAT_OBJECT(mfo) == NULL)	{								\
49 		zend_throw_error(NULL, "Found unconstructed MessageFormatter");	\
50 		RETURN_THROWS();												\
51 	}
52 
53 #define MSG_FORMAT_OBJECT(mfo)			(mfo)->mf_data.umsgf
54 
55 #endif // #ifndef MSG_FORMAT_CLASS_H
56