-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfcall.h
executable file
·476 lines (409 loc) · 18.7 KB
/
fcall.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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
/**
* This file is part of the Zephir.
*
* (c) Phalcon Team <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code. If you did not receive
* a copy of the license it is available through the world-wide-web at the
* following url: https://docs.zephir-lang.com/en/latest/license
*/
#ifndef ZEPHIR_KERNEL_FCALL_H
#define ZEPHIR_KERNEL_FCALL_H
#include "php_ext.h"
#include "kernel/main.h"
#include "kernel/memory.h"
#include "kernel/fcall_internal.h"
#include <Zend/zend_hash.h>
#include <Zend/zend.h>
typedef enum _zephir_call_type {
zephir_fcall_parent,
zephir_fcall_self,
zephir_fcall_static,
zephir_fcall_ce,
zephir_fcall_method,
zephir_fcall_function
} zephir_call_type;
/**
* @addtogroup callfuncs Calling Functions
* @{
*/
#if defined(_MSC_VER)
#define ZEPHIR_PASS_CALL_PARAMS(x) x + 1
#define ZEPHIR_CALL_NUM_PARAMS(x) ((sizeof(x) - sizeof(x[0]))/sizeof(x[0]))
#define ZEPHIR_FETCH_VA_ARGS NULL,
#else
#define ZEPHIR_PASS_CALL_PARAMS(x) x
#define ZEPHIR_CALL_NUM_PARAMS(x) sizeof(x)/sizeof(zval*)
#define ZEPHIR_FETCH_VA_ARGS
#endif
#define ZEPHIR_CALL_FUNCTION(return_value_ptr, func_name, cache, cache_slot, ...) \
do { \
zephir_fcall_cache_entry **cache_entry_ = cache; \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \
ZEPHIR_LAST_CALL_STATUS = zephir_call_func_aparams(return_value_ptr, func_name, strlen(func_name), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
} while (0)
#define ZEPHIR_CALL_ZVAL_FUNCTION(return_value_ptr, func_name, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \
ZEPHIR_LAST_CALL_STATUS = zephir_call_zval_func_aparams(return_value_ptr, func_name, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
} while (0)
#define ZEPHIR_SET_THIS(zv) ZEPHIR_SET_THIS_OBJ((zv ? Z_OBJ_P(zv) : NULL))
#define ZEPHIR_SET_THIS_EXPLICIT_NULL() \
ZVAL_NULL(&EG(current_execute_data)->This); \
Z_OBJ(EG(current_execute_data)->This) = NULL;
#define ZEPHIR_SET_THIS_OBJ(obj) \
if (obj) { \
ZVAL_OBJ(&EG(current_execute_data)->This, obj); \
} \
else { ZEPHIR_SET_THIS_EXPLICIT_NULL(); } \
#define ZEPHIR_BACKUP_SCOPE() \
zend_class_entry *old_scope = EG(fake_scope); \
zend_execute_data *old_call = execute_data; \
zend_execute_data *old_execute_data = EG(current_execute_data), new_execute_data; \
if (!EG(current_execute_data)) { \
memset(&new_execute_data, 0, sizeof(zend_execute_data)); \
execute_data = EG(current_execute_data) = &new_execute_data; \
} else { \
new_execute_data = *EG(current_execute_data); \
new_execute_data.prev_execute_data = EG(current_execute_data); \
new_execute_data.call = NULL; \
new_execute_data.opline = NULL; \
new_execute_data.func = NULL; \
execute_data = EG(current_execute_data) = &new_execute_data; \
}
#define ZEPHIR_RESTORE_SCOPE() \
EG(fake_scope) = old_scope; \
execute_data = old_call; \
EG(current_execute_data) = old_execute_data;
#define ZEPHIR_SET_SCOPE(_scope, _scope_called) \
EG(fake_scope) = _scope; \
zephir_set_called_scope(EG(current_execute_data), _scope_called); \
/* End internal calls */
#define ZEPHIR_RETURN_CALL_ZVAL_FUNCTION(func_name, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
ZEPHIR_LAST_CALL_STATUS = zephir_return_call_zval_function(return_value, func_name, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
} while (0)
#define ZEPHIR_RETURN_CALL_FUNCTION(func_name, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
ZEPHIR_LAST_CALL_STATUS = zephir_return_call_function(return_value, func_name, strlen(func_name), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
} while (0)
#define ZEPHIR_CALL_METHOD_WITHOUT_OBSERVE(return_value_ptr, object, method, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
} while (0)
#define ZEPHIR_CALL_METHOD(return_value_ptr, object, method, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \
ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
} while (0)
#define ZEPHIR_RETURN_CALL_METHOD_ZVAL(object, method, cache, cache_slot, ...) \
do { \
char *method_name; \
int method_len; \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
if (Z_TYPE_P(method) == IS_STRING) { \
method_len = Z_STRLEN_P(method); \
method_name = zend_str_tolower_dup(Z_STRVAL_P(method), method_len); \
} else { \
method_len = 0; \
method_name = zend_str_tolower_dup("", 0); \
} \
ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method_name, method_len, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
efree(method_name); \
} while (0)
#define ZEPHIR_CALL_METHOD_ZVAL(return_value_ptr, object, method, cache, cache_slot, ...) \
do { \
char *method_name; \
int method_len; \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
if (Z_TYPE_P(method) == IS_STRING) { \
method_len = Z_STRLEN_P(method); \
method_name = zend_str_tolower_dup(Z_STRVAL_P(method), method_len); \
} else { \
method_len = 0; \
method_name = zend_str_tolower_dup("", 0); \
} \
ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \
ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method_name, method_len, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
efree(method_name); \
} while (0)
#define ZEPHIR_CALL_PARENT(return_value_ptr, class_entry, this_ptr, method, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \
ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, class_entry, zephir_fcall_parent, this_ptr, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
} while (0)
#define ZEPHIR_RETURN_CALL_METHOD(object, method, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
} while (0)
#if PHP_VERSION_ID >= 80000
#define ZEPHIR_RETURN_CALL_STATIC(method, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, (getThis() ? Z_OBJCE_P(getThis()) : NULL), zephir_fcall_static, getThis(), method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
} while (0)
#else
#define ZEPHIR_RETURN_CALL_STATIC(method, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, NULL, zephir_fcall_static, NULL, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
} while (0)
#endif
#define ZEPHIR_RETURN_CALL_PARENT(class_entry, this_ptr, method, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, class_entry, zephir_fcall_parent, this_ptr, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
} while (0)
#if PHP_VERSION_ID >= 80000
#define ZEPHIR_CALL_SELF(return_value_ptr, method, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \
ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, (getThis() ? Z_OBJCE_P(getThis()) : NULL), zephir_fcall_self, getThis(), method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
} while (0)
#else
#define ZEPHIR_CALL_SELF(return_value_ptr, method, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \
ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, NULL, zephir_fcall_self, NULL, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
} while (0)
#endif
#if PHP_VERSION_ID >= 80000
#define ZEPHIR_RETURN_CALL_SELF(method, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, (getThis() ? Z_OBJCE_P(getThis()) : NULL), zephir_fcall_self, getThis(), method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
} while (0)
#else
#define ZEPHIR_RETURN_CALL_SELF(method, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, NULL, zephir_fcall_self, NULL, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
} while (0)
#endif
#if PHP_VERSION_ID >= 80000
#define ZEPHIR_CALL_STATIC(return_value_ptr, method, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \
ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, (getThis() ? Z_OBJCE_P(getThis()) : NULL), zephir_fcall_static, getThis(), method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
} while (0)
#else
#define ZEPHIR_CALL_STATIC(return_value_ptr, method, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \
ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, NULL, zephir_fcall_static, NULL, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
} while (0)
#endif
#define ZEPHIR_CALL_CE_STATIC(return_value_ptr, class_entry, method, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \
ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, class_entry, zephir_fcall_ce, NULL, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
} while (0)
#define ZEPHIR_RETURN_CALL_CE_STATIC(class_entry, method, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, class_entry, zephir_fcall_ce, NULL, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
} while (0)
#define ZEPHIR_CALL_CE_STATIC_ZVAL(return_value_ptr, class_entry, method, cache, cache_slot, ...) \
do { \
char *method_name; \
int method_len; \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
if (Z_TYPE(method) == IS_STRING) { \
method_len = Z_STRLEN(method); \
method_name = zend_str_tolower_dup(Z_STRVAL(method), method_len); \
} else { \
method_len = 0; \
method_name = zend_str_tolower_dup("", 0); \
} \
ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \
ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, class_entry, zephir_fcall_ce, NULL, method_name, method_len, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
efree(method_name); \
} while (0)
#define ZEPHIR_RETURN_CALL_CE_STATIC_ZVAL(class_entry, method, cache, cache_slot, ...) \
do { \
char *method_name; \
int method_len; \
zval *params_[] = { ZEPHIR_FETCH_VA_ARGS __VA_ARGS__ }; \
if (Z_TYPE(method) == IS_STRING) { \
method_len = Z_STRLEN(method); \
method_name = zend_str_tolower_dup(Z_STRVAL(method), method_len); \
} else { \
method_len = 0; \
method_name = zend_str_tolower_dup("", 0); \
} \
ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, class_entry, zephir_fcall_ce, NULL, method_name, method_len, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
efree(method_name); \
} while (0)
/** Use these functions to call functions in the PHP userland using an arbitrary zval as callable */
#define ZEPHIR_CALL_USER_FUNC(return_value, handler) ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, handler, NULL)
#define ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, handler, params) \
do { \
ZEPHIR_LAST_CALL_STATUS = zephir_call_user_func_array(return_value, handler, params); \
} while (0)
#define ZEPHIR_CALL_USER_FUNC_ARRAY_NOEX(return_value, handler, params) \
do { \
ZEPHIR_LAST_CALL_STATUS = zephir_call_user_func_array_noex(return_value, handler, params); \
} while (0)
int zephir_call_func_aparams(zval *return_value_ptr, const char *func_name, uint32_t func_length,
zephir_fcall_cache_entry **cache_entry, int cache_slot,
uint32_t param_count, zval **params);
int zephir_call_zval_func_aparams(zval *return_value_ptr, zval *func_name,
zephir_fcall_cache_entry **cache_entry, int cache_slot,
uint32_t param_count, zval **params) ZEPHIR_ATTR_WARN_UNUSED_RESULT;
int zephir_call_class_method_aparams(
zval *return_value_ptr,
zend_class_entry *ce,
zephir_call_type type,
zval *object,
const char *method_name,
uint32_t method_len,
zephir_fcall_cache_entry **cache_entry,
int cache_slot,
uint32_t param_count,
zval **params) ZEPHIR_ATTR_WARN_UNUSED_RESULT;
ZEPHIR_ATTR_WARN_UNUSED_RESULT static inline int zephir_return_call_function(zval *return_value,
const char *func, uint32_t func_len, zephir_fcall_cache_entry **cache_entry, int cache_slot, uint32_t param_count, zval **params)
{
zval rv, *rvp = return_value ? return_value : &rv;
int status;
if (return_value) {
zval_ptr_dtor(return_value);
ZVAL_UNDEF(return_value);
}
status = zephir_call_func_aparams(rvp, func, func_len, cache_entry, cache_slot, param_count, params);
if (status == FAILURE) {
if (return_value && EG(exception)) {
ZVAL_NULL(return_value);
}
return FAILURE;
}
if (!return_value) {
zval_ptr_dtor(&rv);
}
return SUCCESS;
}
ZEPHIR_ATTR_WARN_UNUSED_RESULT static inline int zephir_return_call_zval_function(zval *return_value,
zval *func, zephir_fcall_cache_entry **cache_entry, int cache_slot, uint32_t param_count, zval **params)
{
zval rv, *rvp = return_value ? return_value : &rv;
int status;
if (return_value) {
zval_ptr_dtor(return_value);
ZVAL_UNDEF(return_value);
}
status = zephir_call_zval_func_aparams(rvp, func, cache_entry, cache_slot, param_count, params);
if (status == FAILURE) {
if (return_value && EG(exception)) {
ZVAL_NULL(return_value);
}
return FAILURE;
}
if (!return_value) {
zval_ptr_dtor(&rv);
}
return SUCCESS;
}
ZEPHIR_ATTR_WARN_UNUSED_RESULT static inline int zephir_return_call_class_method(
zval *return_value,
zend_class_entry *ce,
zephir_call_type type,
zval *object,
const char *method_name,
uint32_t method_len,
zephir_fcall_cache_entry **cache_entry,
int cache_slot,
uint32_t param_count,
zval **params
) {
zval rv, *rvp = return_value ? return_value : &rv;
int status;
ZVAL_UNDEF(&rv);
if (return_value) {
zval_ptr_dtor(return_value);
ZVAL_UNDEF(return_value);
}
status = zephir_call_class_method_aparams(rvp, ce, type, object, method_name, method_len, cache_entry, cache_slot, param_count, params);
if (status == FAILURE) {
if (return_value && EG(exception)) {
ZVAL_NULL(return_value);
}
return FAILURE;
}
if (!return_value) {
zval_ptr_dtor(&rv);
}
return SUCCESS;
}
/** Fast call_user_func_array/call_user_func */
int zephir_call_user_func_array_noex(zval *return_value, zval *handler, zval *params) ZEPHIR_ATTR_WARN_UNUSED_RESULT;
/**
* Replaces call_user_func_array avoiding function lookup
*/
ZEPHIR_ATTR_WARN_UNUSED_RESULT static inline int zephir_call_user_func_array(zval *return_value, zval *handler, zval *params)
{
int status = zephir_call_user_func_array_noex(return_value, handler, params);
return (EG(exception)) ? FAILURE : status;
}
int zephir_has_constructor_ce(const zend_class_entry *ce) ZEPHIR_ATTR_PURE ZEPHIR_ATTR_NONNULL;
ZEPHIR_ATTR_WARN_UNUSED_RESULT ZEPHIR_ATTR_NONNULL static inline int zephir_has_constructor(const zval *object)
{
return Z_TYPE_P(object) == IS_OBJECT ? zephir_has_constructor_ce(Z_OBJCE_P(object)) : 0;
}
#define zephir_check_call_status() \
do { \
if (ZEPHIR_LAST_CALL_STATUS == FAILURE) { \
ZEPHIR_MM_RESTORE(); \
return; \
} \
} while(0)
#define zephir_check_call_status_or_jump(label) \
do { \
if (ZEPHIR_LAST_CALL_STATUS == FAILURE) { \
if (EG(exception)) { \
goto label; \
} else { \
ZEPHIR_MM_RESTORE(); \
return; \
} \
} \
} while (0)
#ifdef ZEPHIR_RELEASE
#define ZEPHIR_TEMP_PARAM_COPY 0
#define zephir_check_temp_parameter(param) do { if (Z_REFCOUNT(param) > 1) zval_copy_ctor(¶m); else ZVAL_NULL(¶m); } while(0)
#else
#define ZEPHIR_TEMP_PARAM_COPY 1
#define zephir_check_temp_parameter(param)
#endif
void zephir_eval_php(zval *str, zval *retval_ptr, char *context);
static inline void zephir_set_called_scope(zend_execute_data *ex, zend_class_entry *called_scope)
{
while (ex) {
if (Z_TYPE(ex->This) == IS_OBJECT) {
Z_OBJCE(ex->This) = called_scope;
return;
}else if (ex->func) {
if (ex->func->type != ZEND_INTERNAL_FUNCTION || ex->func->common.scope) {
return;
}
} else {
Z_CE(ex->This) = called_scope;
return;
}
ex = ex->prev_execute_data;
}
}
#endif /* ZEPHIR_KERNEL_FCALL_H */