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: Hans-Peter Oeri (University of St.Gallen) <hp@oeri.ch>      |
12    +----------------------------------------------------------------------+
13  */
14 
15 #ifndef RESOURCEBUNDLE_CLASS_H
16 #define RESOURCEBUNDLE_CLASS_H
17 
18 #include <unicode/ures.h>
19 
20 #include <zend.h>
21 #include "php.h"
22 
23 #include "intl_error.h"
24 
25 typedef struct {
26 	intl_error      error;
27 
28 	UResourceBundle *me;
29 	UResourceBundle *child;
30 	zend_object     zend;
31 } ResourceBundle_object;
32 
php_intl_resourcebundle_fetch_object(zend_object * obj)33 static inline ResourceBundle_object *php_intl_resourcebundle_fetch_object(zend_object *obj) {
34 	return (ResourceBundle_object *)((char*)(obj) - XtOffsetOf(ResourceBundle_object, zend));
35 }
36 #define Z_INTL_RESOURCEBUNDLE_P(zv) php_intl_resourcebundle_fetch_object(Z_OBJ_P(zv))
37 
38 #define RESOURCEBUNDLE_METHOD_INIT_VARS		INTL_METHOD_INIT_VARS(ResourceBundle, rb)
39 #define RESOURCEBUNDLE_METHOD_FETCH_OBJECT_NO_CHECK	INTL_METHOD_FETCH_OBJECT(INTL_RESOURCEBUNDLE, rb)
40 #define RESOURCEBUNDLE_METHOD_FETCH_OBJECT							\
41 	INTL_METHOD_FETCH_OBJECT(INTL_RESOURCEBUNDLE, rb);				\
42 	if (RESOURCEBUNDLE_OBJECT(rb) == NULL) {						\
43 		zend_throw_error(NULL, "Found unconstructed ResourceBundle");	\
44 		RETURN_THROWS();											\
45 	}
46 
47 #define RESOURCEBUNDLE_OBJECT(rb)			(rb)->me
48 
49 void resourcebundle_register_class( void );
50 extern zend_class_entry *ResourceBundle_ce_ptr;
51 
52 #endif // #ifndef RESOURCEBUNDLE_CLASS_H
53