-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathphp_yii.h
286 lines (244 loc) · 8.39 KB
/
php_yii.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2013 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| [email protected] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifndef PHP_YII_H
#define PHP_YII_H
extern zend_module_entry yii_module_entry;
#define phpext_yii_ptr &yii_module_entry
#ifdef PHP_WIN32
# define PHP_YII_API __declspec(dllexport)
#elif defined(__GNUC__) && __GNUC__ >= 4
# define PHP_YII_API __attribute__ ((visibility("default")))
#else
# define PHP_YII_API
#endif
#ifdef ZTS
#include "TSRM.h"
#endif
#define YII_VERSION "1.1.14-dev"
/* Declaration Class */
#define YII_CLASS_FUNCTION(name) ZEND_MINIT_FUNCTION(yii_##name)
/* Call Class */
#define YII_CLASS(name) ZEND_MODULE_STARTUP_N(yii_##name)(INIT_FUNC_ARGS_PASSTHRU)
/* Declaration Class Method */
#define YII_CLASS_METHODS(name) const zend_function_entry yii_ ##name## _method_entry[] =
/* Declaration class Entry */
#define YII_CLASS_DECLARE_ENTRY(name) zend_class_entry *yii_ ##name## _ce;
/* Declaration class Entry Extern*/
#define YII_CLASS_DECLARE_ENTRY_EX(name) extern zend_class_entry *yii_ ##name## _ce;
/* Call class Entry Extern*/
#define YII_CLASS_ENTRY(name) yii_ ##name## _ce
/** class/interface registering */
#define YII_CLASS_DECLARE(class_name, name, flags) \
{ \
zend_class_entry ce; \
INIT_CLASS_ENTRY(ce, #class_name, yii_ ##name## _method_entry); \
yii_ ##name## _ce = zend_register_internal_class(&ce TSRMLS_CC); \
yii_ ##name## _ce->ce_flags |= flags; \
}
#define YII_CLASS_DECLARE_EX(class_name, name, parent_name, parent, flags) \
{ \
zend_class_entry ce; \
INIT_CLASS_ENTRY(ce, #class_name, yii_ ##name## _method_entry); \
yii_ ##name## _ce = zend_register_internal_class_ex(&ce, parent_name, parent TSRMLS_CC); \
if (!yii_ ##name## _ce) { \
yii_inherit_not_found(parent, #class_name); \
return FAILURE; \
} \
yii_ ##name## _ce->ce_flags |= flags; \
}
#define YII_NS_CLASS_DECLARE(ns, class_name, name, flags) \
{ \
zend_class_entry ce; \
INIT_NS_CLASS_ENTRY(ce, #ns, #class_name, yii_ ##name## _method_entry); \
yii_ ##name## _ce = zend_register_internal_class(&ce TSRMLS_CC); \
yii_ ##name## _ce->ce_flags |= flags; \
}
#define YII_NS_CLASS_DECLARE_EX(ns, class_name, name, parent_name, parent, flags) \
{ \
zend_class_entry ce; \
INIT_NS_CLASS_ENTRY(ce, #ns, #class_name, yii_ ##name## _method_entry); \
yii_ ##name## _ce = zend_register_internal_class_ex(&ce, NULL, parent TSRMLS_CC); \
if (!yii_ ##name## _ce) { \
yii_inherit_not_found(parent, ZEND_NS_NAME(#ns, #class_name)); \
return FAILURE; \
} \
yii_ ##name## _ce->ce_flags |= flags; \
}
#define YII_CLASS_INTERFACE(class_name, name) \
{ \
zend_class_entry ce; \
INIT_CLASS_ENTRY(ce, #class_name, yii_ ##name## _method_entry); \
yii_ ##name## _ce = zend_register_internal_interface(&ce TSRMLS_CC); \
}
#define YII_CLASS_INTERFACE_EX(class_name, name, parent) \
{ \
zend_class_entry ce; \
INIT_CLASS_ENTRY(ce, #class_name, yii_ ##name## _method_entry); \
yii_ ##name## _ce = yii_register_internal_interface_ex(&ce, parent TSRMLS_CC); \
if (!yii_ ##name## _ce) { \
fprintf(stderr, "Can't register interface with parent: %s", parent); \
return FAILURE; \
} \
}
#define YII_NS_CLASS_INTERFACE(ns, class_name, name) \
{ \
zend_class_entry ce; \
INIT_NS_CLASS_ENTRY(ce, #ns, #class_name, yii_ ##name## _method_entry); \
yii_ ##name## _ce = zend_register_internal_interface(&ce TSRMLS_CC); \
}
#define YII_NS_CLASS_INTERFACE_EX(ns, class_name, name, parent) \
{ \
zend_class_entry ce; \
INIT_NS_CLASS_ENTRY(ce, #ns, #class_name, yii_ ##name## _method_entry); \
yii_ ##name## _ce = yii_register_internal_interface_ex(&ce, parent TSRMLS_CC); \
if (!yii_ ##name## _ce) { \
fprintf(stderr, "Can't register interface with parent: %s", parent); \
return FAILURE; \
} \
}
#define YII_SL(str) ZEND_STRL(str)
#define YII_SS(str) ZEND_STRS(str)
#define YII_NEW_STRING(zv, str) \
MAKE_STD_ZVAL(zv); \
ZVAL_STRING(zv, str, 1);
#define YII_NEW_LONG(zv, l) \
MAKE_STD_ZVAL(zv); \
ZVAL_LONG(zv, l);
#define YII_NEW_BOOL(zv, l) \
MAKE_STD_ZVAL(zv); \
ZVAL_BOOL(zv, l);
#define YII_NEW_NULL(zv) \
MAKE_STD_ZVAL(zv); \
ZVAL_NULL(zv);
#define YII_NEW_ARRAY(arr_name) \
ALLOC_INIT_ZVAL(arr_name); \
array_init(arr_name);
#define YII_ADD_ARRAY(arr_name, index, item) \
switch(Z_TYPE_P(item)) { \
case IS_ARRAY: case IS_OBJECT: \
add_index_zval(arr_name, index, item); \
break; \
case IS_BOOL: \
add_index_bool(arr_name, index, Z_BVAL_P(item)); \
break; \
case IS_LONG: \
add_index_long(arr_name, index, Z_LVAL_P(item)); \
break; \
case IS_DOUBLE: \
add_index_double(arr_name, index, Z_DVAL_P(item)); \
break; \
case IS_RESOURCE: \
add_index_resource(arr_name, index, Z_RESVAL_P(item)); \
break; \
case IS_STRING: \
add_index_stringl(arr_name, index, Z_STRVAL_P(item), Z_STRLEN_P(item), 1); \
break; \
default: \
add_index_null(arr_name, index); \
}
#define YII_ADD_NEXT_ARRAY(arr_name, item) \
switch(Z_TYPE_P(item)) { \
case IS_ARRAY: case IS_OBJECT: \
add_next_index_zval(arr_name, item); \
break; \
case IS_BOOL: \
add_next_index_bool(arr_name, Z_BVAL_P(item)); \
break; \
case IS_LONG: \
add_next_index_long(arr_name, Z_LVAL_P(item)); \
break; \
case IS_DOUBLE: \
add_next_index_double(arr_name, Z_DVAL_P(item)); \
break; \
case IS_RESOURCE: \
add_next_index_resource(arr_name, Z_RESVAL_P(item)); \
break; \
case IS_STRING: \
add_next_index_stringl(arr_name, Z_STRVAL_P(item), Z_STRLEN_P(item), 1); \
break; \
default: \
add_next_index_null(arr_name); \
}
#define YII_ADD_ARRAY_EX(arr_name, key, item) \
switch(Z_TYPE_P(item)) { \
case IS_ARRAY: case IS_OBJECT: \
add_assoc_zval(arr_name, key, item); \
break; \
case IS_BOOL: \
add_assoc_bool(arr_name, key, Z_BVAL_P(item)); \
break; \
case IS_LONG: \
add_assoc_long(arr_name, key, Z_LVAL_P(item)); \
break; \
case IS_DOUBLE: \
add_assoc_double(arr_name, key, Z_DVAL_P(item)); \
break; \
case IS_RESOURCE: \
add_assoc_resource(arr_name, key, Z_RESVAL_P(item)); \
break; \
case IS_STRING: \
add_assoc_stringl(arr_name, key, Z_STRVAL_P(item), Z_STRLEN_P(item), 1); \
break; \
default: \
add_assoc_null(arr_name, key); \
}
#define YII_DTOR(z) \
if (&z) { \
zval_dtor(&z); \
}
#define YII_PTR_DTOR(zp) \
if (zp) { \
zval_ptr_dtor(&zp); \
}
PHP_MINIT_FUNCTION(yii);
PHP_MSHUTDOWN_FUNCTION(yii);
PHP_RINIT_FUNCTION(yii);
PHP_RSHUTDOWN_FUNCTION(yii);
PHP_MINFO_FUNCTION(yii);
/*
Declare any global variables you may need between the BEGIN
and END macros here:
ZEND_BEGIN_MODULE_GLOBALS(yii)
long global_value;
char *global_string;
ZEND_END_MODULE_GLOBALS(yii)
*/
/* In every utility function you add that needs to use variables
in php_yii_globals, call TSRMLS_FETCH(); after declaring other
variables used by that function, or better yet, pass in TSRMLS_CC
after the last function argument and declare your utility function
with TSRMLS_DC after the last declared argument. Always refer to
the globals in your function as YII_G(variable). You are
encouraged to rename these macros something shorter, see
examples in any other php module directory.
*/
#ifdef ZTS
#define YII_G(v) TSRMG(yii_globals_id, zend_yii_globals *, v)
#else
#define YII_G(v) (yii_globals.v)
#endif
#endif /* PHP_YII_H */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/