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: Kirti Velankar <kirtig@yahoo-inc.com>                       |
12    +----------------------------------------------------------------------+
13 */
14 #ifndef DATE_FORMAT_CLASS_H
15 #define DATE_FORMAT_CLASS_H
16 
17 #include <php.h>
18 
19 #include "intl_common.h"
20 #include "intl_error.h"
21 #include "intl_data.h"
22 #include "dateformat_data.h"
23 
24 typedef struct {
25 	dateformat_data	datef_data;
26 	int				date_type;
27 	int				time_type;
28 	int				calendar;
29 	char			*requested_locale;
30 	zend_object		zo;
31 } IntlDateFormatter_object;
32 
php_intl_dateformatter_fetch_object(zend_object * obj)33 static inline IntlDateFormatter_object *php_intl_dateformatter_fetch_object(zend_object *obj) {
34 	return (IntlDateFormatter_object *)((char*)(obj) - XtOffsetOf(IntlDateFormatter_object, zo));
35 }
36 #define Z_INTL_DATEFORMATTER_P(zv) php_intl_dateformatter_fetch_object(Z_OBJ_P(zv))
37 
38 void dateformat_register_IntlDateFormatter_class( void );
39 extern zend_class_entry *IntlDateFormatter_ce_ptr;
40 
41 /* Auxiliary macros */
42 
43 #define DATE_FORMAT_METHOD_INIT_VARS	INTL_METHOD_INIT_VARS(IntlDateFormatter, dfo)
44 #define DATE_FORMAT_METHOD_FETCH_OBJECT_NO_CHECK	INTL_METHOD_FETCH_OBJECT(INTL_DATEFORMATTER, dfo)
45 #define DATE_FORMAT_METHOD_FETCH_OBJECT				\
46 		DATE_FORMAT_METHOD_FETCH_OBJECT_NO_CHECK;	\
47 	if (dfo->datef_data.udatf == NULL)				\
48 	{												\
49 		zend_throw_error(NULL, "Found unconstructed IntlDateFormatter"); \
50 		RETURN_THROWS();								\
51 	}
52 
53 #define DATE_FORMAT_OBJECT(dfo)		(dfo)->datef_data.udatf
54 
55 #endif // #ifndef DATE_FORMAT_CLASS_H
56