xref: /PHP-5.6/ext/intl/calendar/calendar_class.h (revision eb346ef0)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 5                                                        |
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: Gustavo Lopes <cataphract@php.net>                          |
14    +----------------------------------------------------------------------+
15  */
16 
17 #ifndef CALENDAR_CLASS_H
18 #define CALENDAR_CLASS_H
19 
20 //redefinition of inline in PHP headers causes problems, so include this before
21 #include <math.h>
22 
23 #include <php.h>
24 #include "intl_error.h"
25 #include "intl_data.h"
26 
27 #ifndef USE_CALENDAR_POINTER
28 typedef void Calendar;
29 #endif
30 
31 typedef struct {
32 	zend_object	zo;
33 
34 	// 	error handling
35 	intl_error  err;
36 
37 	// ICU calendar
38 	Calendar*	ucal;
39 } Calendar_object;
40 
41 #define CALENDAR_ERROR(co)		(co)->err
42 #define CALENDAR_ERROR_P(co)	&(CALENDAR_ERROR(co))
43 
44 #define CALENDAR_ERROR_CODE(co)		INTL_ERROR_CODE(CALENDAR_ERROR(co))
45 #define CALENDAR_ERROR_CODE_P(co)	&(INTL_ERROR_CODE(CALENDAR_ERROR(co)))
46 
47 #define CALENDAR_METHOD_INIT_VARS		        INTL_METHOD_INIT_VARS(Calendar, co)
48 #define CALENDAR_METHOD_FETCH_OBJECT_NO_CHECK	INTL_METHOD_FETCH_OBJECT(Calendar, co)
49 #define CALENDAR_METHOD_FETCH_OBJECT \
50 	CALENDAR_METHOD_FETCH_OBJECT_NO_CHECK; \
51 	if (co->ucal == NULL) \
52 	{ \
53 		intl_errors_set(&co->err, U_ILLEGAL_ARGUMENT_ERROR, "Found unconstructed IntlCalendar", 0 TSRMLS_CC); \
54 		RETURN_FALSE; \
55 	}
56 
57 void calendar_object_create(zval *object, Calendar *calendar TSRMLS_DC);
58 
59 Calendar *calendar_fetch_native_calendar(zval *object TSRMLS_DC);
60 
61 void calendar_object_construct(zval *object, Calendar *calendar TSRMLS_DC);
62 
63 void calendar_register_IntlCalendar_class(TSRMLS_D);
64 
65 extern zend_class_entry *Calendar_ce_ptr,
66 						*GregorianCalendar_ce_ptr;
67 
68 extern zend_object_handlers Calendar_handlers;
69 
70 #endif /* #ifndef CALENDAR_CLASS_H */
71