Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 426 lines (359 sloc) 16.792 kb
573b460 andigutmans Zend Library
andigutmans authored
1 /*
2 +----------------------------------------------------------------------+
3 | Zend Engine |
4 +----------------------------------------------------------------------+
5e55e47 Zeev Suraski It's official now...
zsuraski authored
5 | Copyright (c) 1998-2000 Zend Technologies Ltd. (http://www.zend.com) |
573b460 andigutmans Zend Library
andigutmans authored
6 +----------------------------------------------------------------------+
5e55e47 Zeev Suraski It's official now...
zsuraski authored
7 | This source file is subject to version 0.92 of the Zend license, |
b5b1117 Zeev Suraski License update
zsuraski authored
8 | that is bundled with this package in the file LICENSE, and is |
9 | available at through the world-wide-web at |
5e55e47 Zeev Suraski It's official now...
zsuraski authored
10 | http://www.zend.com/license/0_92.txt. |
b5b1117 Zeev Suraski License update
zsuraski authored
11 | If you did not receive a copy of the Zend license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@zend.com so we can mail you a copy immediately. |
573b460 andigutmans Zend Library
andigutmans authored
14 +----------------------------------------------------------------------+
15 | Authors: Andi Gutmans <andi@zend.com> |
16 | Zeev Suraski <zeev@zend.com> |
17 +----------------------------------------------------------------------+
18 */
19
b5b1117 Zeev Suraski License update
zsuraski authored
20
573b460 andigutmans Zend Library
andigutmans authored
21 #ifndef _ZEND_API_H
22 #define _ZEND_API_H
23
24 #include "modules.h"
25 #include "zend_list.h"
b7a5b3c Zeev Suraski - Generalize the fast cache mechanism
zsuraski authored
26 #include "zend_fast_cache.h"
5dba477 Zeev Suraski - Some header dependencies cleanup
zsuraski authored
27 #include "zend_operators.h"
28 #include "zend_variables.h"
573b460 andigutmans Zend Library
andigutmans authored
29
e9d126a andigutmans - Make sure zend_API.h has Zend'ish versions of the ZEND macros so that
andigutmans authored
30 #define ZEND_FN(name) zend_if_##name
342c6e0 Zeev Suraski Whatnot:
zsuraski authored
31 #define ZEND_NAMED_FUNCTION(name) void name(INTERNAL_FUNCTION_PARAMETERS)
e9d126a andigutmans - Make sure zend_API.h has Zend'ish versions of the ZEND macros so that
andigutmans authored
32 #define ZEND_FUNCTION(name) ZEND_NAMED_FUNCTION(ZEND_FN(name))
33
34 #define ZEND_NAMED_FE(zend_name, name, arg_types) { #zend_name, name, arg_types },
35 #define ZEND_FE(name, arg_types) ZEND_NAMED_FE(name, ZEND_FN(name), arg_types)
36 #define ZEND_FALIAS(name, alias, arg_types) ZEND_NAMED_FE(name, ZEND_FN(alias), arg_types)
342c6e0 Zeev Suraski Whatnot:
zsuraski authored
37
e9d126a andigutmans - Make sure zend_API.h has Zend'ish versions of the ZEND macros so that
andigutmans authored
38 #define ZEND_MINIT(module) zend_minit_##module
39 #define ZEND_MSHUTDOWN(module) zend_mshutdown_##module
40 #define ZEND_RINIT(module) zend_rinit_##module
41 #define ZEND_RSHUTDOWN(module) zend_rshutdown_##module
42 #define ZEND_MINFO(module) zend_info_##module
43 #define ZEND_GINIT(module) zend_ginit_##module
44 #define ZEND_GSHUTDOWN(module) zend_gshutdown_##module
342c6e0 Zeev Suraski Whatnot:
zsuraski authored
45
e9d126a andigutmans - Make sure zend_API.h has Zend'ish versions of the ZEND macros so that
andigutmans authored
46 #define ZEND_MINIT_FUNCTION(module) int ZEND_MINIT(module)(INIT_FUNC_ARGS)
47 #define ZEND_MSHUTDOWN_FUNCTION(module) int ZEND_MSHUTDOWN(module)(SHUTDOWN_FUNC_ARGS)
48 #define ZEND_RINIT_FUNCTION(module) int ZEND_RINIT(module)(INIT_FUNC_ARGS)
49 #define ZEND_RSHUTDOWN_FUNCTION(module) int ZEND_RSHUTDOWN(module)(SHUTDOWN_FUNC_ARGS)
50 #define ZEND_MINFO_FUNCTION(module) void ZEND_MINFO(module)(ZEND_MODULE_INFO_FUNC_ARGS)
51 #define ZEND_GINIT_FUNCTION(module) int ZEND_GINIT(module)(GINIT_FUNC_ARGS)
52 #define ZEND_GSHUTDOWN_FUNCTION(module) int ZEND_GSHUTDOWN(module)(void)
342c6e0 Zeev Suraski Whatnot:
zsuraski authored
53
0b6d923 Add ZEND_GET_MODULE(name). This is a short-cut for the common
Sascha Schumann authored
54 #define ZEND_GET_MODULE(name) \
55 ZEND_DLEXPORT zend_module_entry *get_module(void) { return &name##_module_entry; }
0d21940 Zeev Suraski Generalize some common thread-safety stuff
zsuraski authored
56
57 #define ZEND_BEGIN_MODULE_GLOBALS(module_name) \
58 typedef struct _zend_##module_name##_globals {
59 #define ZEND_END_MODULE_GLOBALS(module_name) \
60 } zend_##module_name##_globals;
61
62 #ifdef ZTS
63
64 #define ZEND_DECLARE_MODULE_GLOBALS(module_name) \
65 static ts_rsrc_id module_name##_globals_id;
66 #define ZEND_INIT_MODULE_GLOBALS(module_name, globals_ctor, globals_dtor) \
67 module_name##_globals_id = ts_allocate_id(sizeof(zend_##module_name##_globals), (ts_allocate_ctor) globals_ctor, (ts_allocate_dtor) globals_dtor);
68
69 #else
70
71 #define ZEND_DECLARE_MODULE_GLOBALS(module_name) \
72 static zend_##module_name##_globals module_name##_globals;
73 #define ZEND_INIT_MODULE_GLOBALS(module_name, globals_ctor, globals_dtor) \
74 globals_ctor(&module_name##_globals);
75
76 #endif
77
78
79
741b816 Zeev Suraski * Support getThis() for internal functions.
zsuraski authored
80 #define INIT_CLASS_ENTRY(class_container, class_name, functions) \
81 { \
82 class_container.name = strdup(class_name); \
83 class_container.name_length = sizeof(class_name)-1; \
84 class_container.builtin_functions = functions; \
85 class_container.handle_function_call = NULL; \
86 class_container.handle_property_get = NULL; \
87 class_container.handle_property_set = NULL; \
88 }
89
90 #define INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, handle_fcall, handle_propget, handle_propset) \
91 { \
92 class_container.name = strdup(class_name); \
93 class_container.name_length = sizeof(class_name)-1; \
94 class_container.builtin_functions = functions; \
95 class_container.handle_function_call = handle_fcall; \
96 class_container.handle_property_get = handle_propget; \
97 class_container.handle_property_set = handle_propset; \
98 }
99
100
101
573b460 andigutmans Zend Library
andigutmans authored
102 int zend_next_free_module(void);
103
f77e6a4 Zeev Suraski Generalize macros
zsuraski authored
104 ZEND_API int zend_get_parameters(int ht, int param_count, ...);
cd7d554 Zeev Suraski - Introduce ZEND_NUM_ARGS(), to replace ARG_COUNT(ht)
zsuraski authored
105 ZEND_API int zend_get_parameters_array(int ht, int param_count, zval **argument_array);
f77e6a4 Zeev Suraski Generalize macros
zsuraski authored
106 ZEND_API int zend_get_parameters_ex(int param_count, ...);
cd7d554 Zeev Suraski - Introduce ZEND_NUM_ARGS(), to replace ARG_COUNT(ht)
zsuraski authored
107 ZEND_API int zend_get_parameters_array_ex(int param_count, zval ***argument_array);
39f9487 andigutmans -Tiny patches
andigutmans authored
108
9deab41 andigutmans Add a couple of ZEND_API's
andigutmans authored
109 ZEND_API int ParameterPassedByReference(int ht, uint n);
39f9487 andigutmans -Tiny patches
andigutmans authored
110
741b816 Zeev Suraski * Support getThis() for internal functions.
zsuraski authored
111 int zend_register_functions(zend_function_entry *functions, HashTable *function_table);
112 void zend_unregister_functions(zend_function_entry *functions, int count, HashTable *function_table);
7a87fcb Zeev Suraski Thread safety patch. We're still not quite there but it compiles again,...
zsuraski authored
113 ZEND_API int zend_register_module(zend_module_entry *module_entry);
eb0e694 andigutmans - Andrei, this is for you!
andigutmans authored
114
6ce07a8 andigutmans - Change register_internal_class to zend_register_internal_class for
andigutmans authored
115 ZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry *class_entry);
eb0e694 andigutmans - Andrei, this is for you!
andigutmans authored
116 ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *parent_ce, char *parent_name);
117
bfbe861 Zeev Suraski Almost forgot to commit those
zsuraski authored
118 ZEND_API zend_module_entry *zend_get_module(int module_number);
bc7abb3 Zeev Suraski Allow disabling of functions for security reasons
zsuraski authored
119 ZEND_API int zend_disable_function(char *function_name, uint function_name_length);
573b460 andigutmans Zend Library
andigutmans authored
120
121 ZEND_API void wrong_param_count(void);
122
741b816 Zeev Suraski * Support getThis() for internal functions.
zsuraski authored
123 #define getThis() (this_ptr)
124
131d9cb Zeev Suraski *** empty log message ***
zsuraski authored
125 #define WRONG_PARAM_COUNT ZEND_WRONG_PARAM_COUNT()
126 #define WRONG_PARAM_COUNT_WITH_RETVAL(ret) ZEND_WRONG_PARAM_COUNT_WITH_RETVAL(ret)
a1ad287 Zeev Suraski - The tree compiles again
zsuraski authored
127 #define ARG_COUNT(dummy) (ht)
128 #define ZEND_NUM_ARGS() (ht)
131d9cb Zeev Suraski *** empty log message ***
zsuraski authored
129 #define ZEND_WRONG_PARAM_COUNT() { wrong_param_count(); return; }
130 #define ZEND_WRONG_PARAM_COUNT_WITH_RETVAL(ret) { wrong_param_count(); return ret; }
573b460 andigutmans Zend Library
andigutmans authored
131
80bdd19 Zeev Suraski Fine tune Andi's patch
zsuraski authored
132 #ifndef ZEND_WIN32
573b460 andigutmans Zend Library
andigutmans authored
133 #define DLEXPORT
134 #endif
135
e062843 *** empty log message ***
Andrei Zmievski authored
136 ZEND_API int zend_startup_module(zend_module_entry *module);
573b460 andigutmans Zend Library
andigutmans authored
137
ceba50b Zeev Suraski - Fix a nasty bug in the hash, introduced in the recent migration to mac...
zsuraski authored
138 #define array_init(arg) _array_init((arg) ZEND_FILE_LINE_CC)
139 #define object_init(arg) _object_init((arg) ZEND_FILE_LINE_CC)
140 #define object_init_ex(arg, ce) _object_init_ex((arg), (ce) ZEND_FILE_LINE_CC)
141 ZEND_API int _array_init(zval *arg ZEND_FILE_LINE_DC);
142 ZEND_API int _object_init(zval *arg ZEND_FILE_LINE_DC);
143 ZEND_API int _object_init_ex(zval *arg, zend_class_entry *ce ZEND_FILE_LINE_DC);
6847fef added add_*_resource() and add_*_bool() functions
Thies C. Arntzen authored
144
145 /* no longer supported */
146 ZEND_API int add_assoc_function(zval *arg, char *key,void (*function_ptr)(INTERNAL_FUNCTION_PARAMETERS));
147
573b460 andigutmans Zend Library
andigutmans authored
148 ZEND_API int add_assoc_long(zval *arg, char *key, long n);
f2d703e Zeev Suraski - Nuke undefined_variable_string
zsuraski authored
149 ZEND_API int add_assoc_unset(zval *arg, char *key);
6847fef added add_*_resource() and add_*_bool() functions
Thies C. Arntzen authored
150 ZEND_API int add_assoc_bool(zval *arg, char *key, int b);
151 ZEND_API int add_assoc_resource(zval *arg, char *key, int r);
573b460 andigutmans Zend Library
andigutmans authored
152 ZEND_API int add_assoc_double(zval *arg, char *key, double d);
153 ZEND_API int add_assoc_string(zval *arg, char *key, char *str, int duplicate);
154 ZEND_API int add_assoc_stringl(zval *arg, char *key, char *str, uint length, int duplicate);
6847fef added add_*_resource() and add_*_bool() functions
Thies C. Arntzen authored
155
573b460 andigutmans Zend Library
andigutmans authored
156 ZEND_API int add_index_long(zval *arg, uint idx, long n);
f2d703e Zeev Suraski - Nuke undefined_variable_string
zsuraski authored
157 ZEND_API int add_index_unset(zval *arg, uint idx);
6847fef added add_*_resource() and add_*_bool() functions
Thies C. Arntzen authored
158 ZEND_API int add_index_bool(zval *arg, uint idx, int b);
159 ZEND_API int add_index_resource(zval *arg, uint idx, int r);
573b460 andigutmans Zend Library
andigutmans authored
160 ZEND_API int add_index_double(zval *arg, uint idx, double d);
161 ZEND_API int add_index_string(zval *arg, uint idx, char *str, int duplicate);
162 ZEND_API int add_index_stringl(zval *arg, uint idx, char *str, uint length, int duplicate);
6847fef added add_*_resource() and add_*_bool() functions
Thies C. Arntzen authored
163
573b460 andigutmans Zend Library
andigutmans authored
164 ZEND_API int add_next_index_long(zval *arg, long n);
f2d703e Zeev Suraski - Nuke undefined_variable_string
zsuraski authored
165 ZEND_API int add_next_index_unset(zval *arg);
6847fef added add_*_resource() and add_*_bool() functions
Thies C. Arntzen authored
166 ZEND_API int add_next_index_bool(zval *arg, int b);
167 ZEND_API int add_next_index_resource(zval *arg, int r);
573b460 andigutmans Zend Library
andigutmans authored
168 ZEND_API int add_next_index_double(zval *arg, double d);
169 ZEND_API int add_next_index_string(zval *arg, char *str, int duplicate);
170 ZEND_API int add_next_index_stringl(zval *arg, char *str, uint length, int duplicate);
171
172 ZEND_API int add_get_index_long(zval *arg, uint idx, long l, void **dest);
173 ZEND_API int add_get_index_double(zval *arg, uint idx, double d, void **dest);
6847fef added add_*_resource() and add_*_bool() functions
Thies C. Arntzen authored
174 ZEND_API int add_get_assoc_string(zval *arg, char *key, char *str, void **dest, int duplicate);
175 ZEND_API int add_get_assoc_stringl(zval *arg, char *key, char *str, uint length, void **dest, int duplicate);
573b460 andigutmans Zend Library
andigutmans authored
176 ZEND_API int add_get_index_string(zval *arg, uint idx, char *str, void **dest, int duplicate);
177 ZEND_API int add_get_index_stringl(zval *arg, uint idx, char *str, uint length, void **dest, int duplicate);
178
223c674 Zeev Suraski - Made things work again (Thies, everybody - please check the latest CVS...
zsuraski authored
179 ZEND_API int call_user_function(HashTable *function_table, zval *object, zval *function_name, zval *retval_ptr, int param_count, zval *params[]);
180 ZEND_API int call_user_function_ex(HashTable *function_table, zval *object, zval *function_name, zval **retval_ptr_ptr, int param_count, zval **params[], int no_separation);
573b460 andigutmans Zend Library
andigutmans authored
181
182 ZEND_API int add_property_long(zval *arg, char *key, long l);
b995d2c Added add_property_unset() and add_property_bool().
Andrei Zmievski authored
183 ZEND_API int add_property_unset(zval *arg, char *key);
184 ZEND_API int add_property_bool(zval *arg, char *key, int b);
446e5d0 added add_property_resource
Thies C. Arntzen authored
185 ZEND_API int add_property_resource(zval *arg, char *key, long r);
573b460 andigutmans Zend Library
andigutmans authored
186 ZEND_API int add_property_double(zval *arg, char *key, double d);
187 ZEND_API int add_property_string(zval *arg, char *key, char *str, int duplicate);
188 ZEND_API int add_property_stringl(zval *arg, char *key, char *str, uint length, int duplicate);
189
f962a35 Added zend_set_hash_symbol() function.
Andrei Zmievski authored
190 ZEND_API int zend_set_hash_symbol(zval *symbol, char *name, int name_length,
191 int is_ref, int num_symbol_tables, ...);
192
573b460 andigutmans Zend Library
andigutmans authored
193 #define add_method(arg,key,method) add_assoc_function((arg),(key),(method))
194
af22085 added ZVAL_*() macros.
Thies C. Arntzen authored
195 #define ZVAL_RESOURCE(z,l) { \
196 (z)->type = IS_RESOURCE; \
197 (z)->value.lval = l; \
198 }
199 #define ZVAL_BOOL(z,b) { \
200 (z)->type = IS_BOOL; \
201 (z)->value.lval = b; \
202 }
203 #define ZVAL_NULL(z) { \
204 (z)->type = IS_NULL; \
205 }
206 #define ZVAL_LONG(z,l) { \
207 (z)->type = IS_LONG; \
208 (z)->value.lval = l; \
209 }
210 #define ZVAL_DOUBLE(z,d) { \
211 (z)->type = IS_DOUBLE; \
212 (z)->value.dval = d; \
213 }
214 #define ZVAL_STRING(z,s,duplicate) { \
215 char *__s=(s); \
216 (z)->value.str.len = strlen(__s); \
217 (z)->value.str.val = (duplicate?estrndup(__s,(z)->value.str.len):__s); \
218 (z)->type = IS_STRING; \
219 }
220 #define ZVAL_STRINGL(z,s,l,duplicate) { \
221 char *__s=(s); int __l=l; \
222 (z)->value.str.len = __l; \
223 (z)->value.str.val = (duplicate?estrndup(__s,__l):__s); \
224 (z)->type = IS_STRING; \
225 }
226
227 #define ZVAL_EMPTY_STRING(z) { \
228 (z)->value.str.len = 0; \
229 (z)->value.str.val = empty_string \
230 (z)->type = IS_STRING; \
231 }
232
233 #define ZVAL_FALSE { (z)->value.lval = 0; (z)->type = IS_BOOL; }
234 #define ZVAL_TRUE { (z)->value.lval = 1; (z)->type = IS_BOOL; }
235
eb5c6da added RETVAL_RESOURCE and RETURN_RESOURCE
Thies C. Arntzen authored
236 #define RETVAL_RESOURCE(l) { \
237 return_value->type = IS_RESOURCE;\
238 return_value->value.lval = l; \
239 }
1fe57c9 Zeev Suraski - Fix function_exists()
zsuraski authored
240 #define RETVAL_BOOL(b) { \
241 return_value->type = IS_BOOL; \
242 return_value->value.lval = b; \
243 }
fb6a1b8 RETURN_NULL -> RETURN_NULL() // we don't want macros without an argumnet
Thies C. Arntzen authored
244 #define RETVAL_NULL() { \
bdefd5d andigutmans - Change IS_UNSET -> IS_NULL
andigutmans authored
245 return_value->type = IS_NULL; \
f2d703e Zeev Suraski - Nuke undefined_variable_string
zsuraski authored
246 }
1f985ed Zeev Suraski Moved all #define's for SET_ and RETURN_ to zend_API.h
zsuraski authored
247 #define RETVAL_LONG(l) { \
248 return_value->type = IS_LONG; \
249 return_value->value.lval = l; \
250 }
251 #define RETVAL_DOUBLE(d) { \
252 return_value->type = IS_DOUBLE; \
253 return_value->value.dval = d; \
254 }
255 #define RETVAL_STRING(s,duplicate) { \
256 char *__s=(s); \
257 return_value->value.str.len = strlen(__s); \
258 return_value->value.str.val = (duplicate?estrndup(__s,return_value->value.str.len):__s); \
259 return_value->type = IS_STRING; \
260 }
261 #define RETVAL_STRINGL(s,l,duplicate) { \
262 char *__s=(s); int __l=l; \
263 return_value->value.str.len = __l; \
264 return_value->value.str.val = (duplicate?estrndup(__s,__l):__s); \
265 return_value->type = IS_STRING; \
266 }
267
af22085 added ZVAL_*() macros.
Thies C. Arntzen authored
268 #define RETVAL_EMPTY_STRING() { \
269 return_value->value.str.len = 0; \
270 return_value->value.str.val = empty_string \
271 return_value->type = IS_STRING; \
272 }
273
1f985ed Zeev Suraski Moved all #define's for SET_ and RETURN_ to zend_API.h
zsuraski authored
274 #define RETVAL_FALSE { return_value->value.lval = 0; return_value->type = IS_BOOL; }
275 #define RETVAL_TRUE { return_value->value.lval = 1; return_value->type = IS_BOOL; }
276
eb5c6da added RETVAL_RESOURCE and RETURN_RESOURCE
Thies C. Arntzen authored
277 #define RETURN_RESOURCE(l) { \
278 return_value->type = IS_RESOURCE;\
279 return_value->value.lval = l; \
280 return; \
281 }
1fe57c9 Zeev Suraski - Fix function_exists()
zsuraski authored
282
283 #define RETURN_BOOL(b) { \
284 return_value->type = IS_BOOL; \
285 return_value->value.lval = b; \
286 return; \
287 }
288
fb6a1b8 RETURN_NULL -> RETURN_NULL() // we don't want macros without an argumnet
Thies C. Arntzen authored
289 #define RETURN_NULL() { \
bdefd5d andigutmans - Change IS_UNSET -> IS_NULL
andigutmans authored
290 return_value->type = IS_NULL; \
f2d703e Zeev Suraski - Nuke undefined_variable_string
zsuraski authored
291 return; \
292 }
293
1f985ed Zeev Suraski Moved all #define's for SET_ and RETURN_ to zend_API.h
zsuraski authored
294 #define RETURN_LONG(l) { \
295 return_value->type = IS_LONG; \
296 return_value->value.lval = l; \
297 return; \
298 }
299 #define RETURN_DOUBLE(d) { \
300 return_value->type = IS_DOUBLE; \
301 return_value->value.dval = d; \
302 return; \
303 }
304 #define RETURN_STRING(s,duplicate) { \
305 char *__s=(s); \
306 return_value->value.str.len = strlen(__s); \
307 return_value->value.str.val = (duplicate?estrndup(__s,return_value->value.str.len):__s); \
308 return_value->type = IS_STRING; \
309 return; \
310 }
311 #define RETURN_STRINGL(s,l,duplicate) { \
312 char *__s=(s); int __l=l; \
313 return_value->value.str.len = __l; \
314 return_value->value.str.val = (duplicate?estrndup(__s,__l):__s); \
315 return_value->type = IS_STRING; \
316 return; \
317 }
318
af22085 added ZVAL_*() macros.
Thies C. Arntzen authored
319 #define RETURN_EMPTY_STRING() { \
320 return_value->value.str.len = 0; \
321 return_value->value.str.val = empty_string \
322 return_value->type = IS_STRING; \
323 return; \
324 }
325
1f985ed Zeev Suraski Moved all #define's for SET_ and RETURN_ to zend_API.h
zsuraski authored
326 #define RETURN_FALSE { RETVAL_FALSE; return; }
327 #define RETURN_TRUE { RETVAL_TRUE; return; }
328
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
329 #define SET_VAR_STRING(n,v) { \
330 { \
235386b Zeev Suraski Change ALLOC_ZVAL() semantics
zsuraski authored
331 zval *var; \
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
332 char *str=(v); /* prevent 'v' from being evaluated more than once */ \
333 \
235386b Zeev Suraski Change ALLOC_ZVAL() semantics
zsuraski authored
334 ALLOC_ZVAL(var); \
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
335 var->value.str.val = (str); \
336 var->value.str.len = strlen((str)); \
337 var->type = IS_STRING; \
6393ab1 Zeev Suraski Now that's an annoying bug.
zsuraski authored
338 ZEND_SET_GLOBAL_VAR(n, var); \
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
339 } \
1f985ed Zeev Suraski Moved all #define's for SET_ and RETURN_ to zend_API.h
zsuraski authored
340 }
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
341
342 #define SET_VAR_STRINGL(n,v,l) { \
343 { \
235386b Zeev Suraski Change ALLOC_ZVAL() semantics
zsuraski authored
344 zval *var; \
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
345 \
235386b Zeev Suraski Change ALLOC_ZVAL() semantics
zsuraski authored
346 ALLOC_ZVAL(var); \
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
347 var->value.str.val = (v); \
348 var->value.str.len = (l); \
349 var->type = IS_STRING; \
350 ZEND_SET_GLOBAL_VAR(n, var); \
351 } \
1f985ed Zeev Suraski Moved all #define's for SET_ and RETURN_ to zend_API.h
zsuraski authored
352 }
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
353
354 #define SET_VAR_LONG(n,v) { \
355 { \
235386b Zeev Suraski Change ALLOC_ZVAL() semantics
zsuraski authored
356 zval *var; \
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
357 \
235386b Zeev Suraski Change ALLOC_ZVAL() semantics
zsuraski authored
358 ALLOC_ZVAL(var); \
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
359 var->value.lval = (v); \
360 var->type = IS_LONG; \
361 ZEND_SET_GLOBAL_VAR(n, var); \
362 } \
1f985ed Zeev Suraski Moved all #define's for SET_ and RETURN_ to zend_API.h
zsuraski authored
363 }
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
364
365 #define SET_VAR_DOUBLE(n,v) { \
366 { \
235386b Zeev Suraski Change ALLOC_ZVAL() semantics
zsuraski authored
367 zval *var; \
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
368 \
235386b Zeev Suraski Change ALLOC_ZVAL() semantics
zsuraski authored
369 ALLOC_ZVAL(var); \
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
370 var->value.dval = (v); \
371 var->type = IS_DOUBLE; \
372 ZEND_SET_GLOBAL_VAR(n, var); \
373 } \
1f985ed Zeev Suraski Moved all #define's for SET_ and RETURN_ to zend_API.h
zsuraski authored
374 }
375
376
c34560b andigutmans - Remove _EX and make it the old _LENGTH
andigutmans authored
377 #define ZEND_SET_SYMBOL(symtable, name, var) \
378 { \
379 char *_name = (name); \
380 \
4c8259b andigutmans - Call ZEND_SET_SYMBOL_WITH_LENGTH() with refcount 1 from the standard
andigutmans authored
381 ZEND_SET_SYMBOL_WITH_LENGTH(symtable, _name, strlen(_name)+1, var, 1, 0); \
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
382 }
383
c34560b andigutmans - Remove _EX and make it the old _LENGTH
andigutmans authored
384 #define ZEND_SET_SYMBOL_WITH_LENGTH(symtable, name, name_length, var, _refcount, _is_ref) \
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
385 { \
386 zval **orig_var; \
387 \
620d013 Zeev Suraski Support symbols in any symbol table, not just the active one
zsuraski authored
388 if (zend_hash_find(symtable, (name), (name_length), (void **) &orig_var)==SUCCESS \
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
389 && PZVAL_IS_REF(*orig_var)) { \
158088c Zeev Suraski Allow to set the reference count explicitly for ZEND_SET_SYMBOL_WITH_LEN...
zsuraski authored
390 (var)->refcount = (*orig_var)->refcount; \
52a30fd Be safe, use ().
Andrei Zmievski authored
391 (var)->is_ref = 1; \
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
392 \
2ddc4fe Zeev Suraski Make it possible to explicitly set refcount in ZEND_SET_SYMBOL_WITH_LENG...
zsuraski authored
393 if (_refcount) { \
394 (var)->refcount += _refcount-1; \
395 } \
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
396 zval_dtor(*orig_var); \
158088c Zeev Suraski Allow to set the reference count explicitly for ZEND_SET_SYMBOL_WITH_LEN...
zsuraski authored
397 **orig_var = *(var); \
62b2087 andigutmans - Create two new macro's. ALLOC_ZVAL() and FREE_ZVAL(z) and make Zend us...
andigutmans authored
398 FREE_ZVAL(var); \
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
399 } else { \
2f5efbd andigutmans - Add _EX macro for Andrei
andigutmans authored
400 (var)->is_ref = _is_ref; \
158088c Zeev Suraski Allow to set the reference count explicitly for ZEND_SET_SYMBOL_WITH_LEN...
zsuraski authored
401 if (_refcount) { \
402 (var)->refcount = _refcount; \
403 } \
404 zend_hash_update(symtable, (name), (name_length), &(var), sizeof(zval *), NULL); \
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
405 } \
406 }
407
620d013 Zeev Suraski Support symbols in any symbol table, not just the active one
zsuraski authored
408
409 #define ZEND_SET_GLOBAL_VAR(name, var) \
410 ZEND_SET_SYMBOL(&EG(symbol_table), name, var)
411
e345066 *** empty log message ***
Andrei Zmievski authored
412 #define ZEND_SET_GLOBAL_VAR_WITH_LENGTH(name, name_length, var, _refcount, _is_ref) \
413 ZEND_SET_SYMBOL_WITH_LENGTH(&EG(symbol_table), name, name_length, var, _refcount, _is_ref)
fec413c Added ZEND_SET_GLOBAL_VAR_WITH_LENGTH_EX() macro.
Andrei Zmievski authored
414
06a18f1 andigutmans - Add some internal functions to Zend
andigutmans authored
415 #define HASH_OF(p) ((p)->type==IS_ARRAY ? (p)->value.ht : (((p)->type==IS_OBJECT ? (p)->value.obj.properties : NULL)))
af22085 added ZVAL_*() macros.
Thies C. Arntzen authored
416 #define ZVAL_IS_NULL(z) ((z)->type==IS_NULL)
06a18f1 andigutmans - Add some internal functions to Zend
andigutmans authored
417
f962a35 Added zend_set_hash_symbol() function.
Andrei Zmievski authored
418 #endif /* _ZEND_API_H */
573b460 andigutmans Zend Library
andigutmans authored
419
420 /*
421 * Local variables:
422 * tab-width: 4
423 * c-basic-offset: 4
424 * End:
425 */
Something went wrong with that request. Please try again.