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    | http://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: Mel Dafert (mel@dafert.at)                                  |
12    +----------------------------------------------------------------------+
13 */
14 
15 #ifndef DATEPATTERNGENERATOR_CLASS_H
16 #define DATEPATTERNGENERATOR_CLASS_H
17 
18 #include <php.h>
19 #include "intl_common.h"
20 #include "intl_error.h"
21 #include "intl_data.h"
22 
23 #ifndef USE_DATETIMEPATTERNGENERATOR_POINTER
24 typedef void DateTimePatternGenerator;
25 #else
26 using icu::DateTimePatternGenerator;
27 #endif
28 
29 typedef struct {
30 	// 	error handling
31 	intl_error err;
32 
33 	// ICU break iterator
34 	DateTimePatternGenerator *dtpg;
35 
36 	zend_object	zo;
37 } IntlDatePatternGenerator_object;
38 
php_intl_datepatterngenerator_fetch_object(zend_object * obj)39 static inline IntlDatePatternGenerator_object *php_intl_datepatterngenerator_fetch_object(zend_object *obj) {
40 	return (IntlDatePatternGenerator_object *)((char*)(obj) - XtOffsetOf(IntlDatePatternGenerator_object, zo));
41 }
42 #define Z_INTL_DATEPATTERNGENERATOR_P(zv) php_intl_datepatterngenerator_fetch_object(Z_OBJ_P(zv))
43 
44 #define DTPATTERNGEN_ERROR(dtpgo)		(dtpgo)->err
45 #define DTPATTERNGEN_ERROR_P(dtpgo)		&(DTPATTERNGEN_ERROR(dtpgo))
46 
47 #define DTPATTERNGEN_ERROR_CODE(dtpgo)	INTL_ERROR_CODE(DTPATTERNGEN_ERROR(dtpgo))
48 #define DTPATTERNGEN_ERROR_CODE_P(dtpgo)	&(INTL_ERROR_CODE(DTPATTERNGEN_ERROR(dtpgo)))
49 
50 #define DTPATTERNGEN_METHOD_INIT_VARS		        INTL_METHOD_INIT_VARS(IntlDatePatternGenerator, dtpgo)
51 #define DTPATTERNGEN_METHOD_FETCH_OBJECT_NO_CHECK	INTL_METHOD_FETCH_OBJECT(INTL_DATEPATTERNGENERATOR, dtpgo)
52 #define DTPATTERNGEN_METHOD_FETCH_OBJECT \
53 	DTPATTERNGEN_METHOD_FETCH_OBJECT_NO_CHECK; \
54 	if (dtpgo->dtpg == NULL) \
55 	{ \
56 		zend_throw_error(NULL, "Found unconstructed IntlDatePatternGenerator"); \
57 		RETURN_THROWS(); \
58 	}
59 
60 void dateformat_register_IntlDatePatternGenerator_class(void);
61 
62 extern zend_class_entry *IntlDatePatternGenerator_ce_ptr;
63 
64 extern zend_object_handlers IntlDatePatternGenerator_handlers;
65 
66 #endif /* #ifndef DATEPATTERNGENERATOR_CLASS_H */
67