1 /*
2 +----------------------------------------------------------------------+
3 | PHP Version 7 |
4 +----------------------------------------------------------------------+
5 | Copyright (c) The PHP Group |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
15 | Authors: Marcus Boerger <helly@php.net> |
16 +----------------------------------------------------------------------+
17 */
18
19 #ifndef SPL_ENGINE_H
20 #define SPL_ENGINE_H
21
22 #include "php.h"
23 #include "php_spl.h"
24 #include "zend_interfaces.h"
25
26 PHPAPI void spl_instantiate(zend_class_entry *pce, zval *object);
27
28 PHPAPI zend_long spl_offset_convert_to_long(zval *offset);
29
30 /* {{{ spl_instantiate_arg_ex1 */
spl_instantiate_arg_ex1(zend_class_entry * pce,zval * retval,zval * arg1)31 static inline int spl_instantiate_arg_ex1(zend_class_entry *pce, zval *retval, zval *arg1)
32 {
33 zend_function *func = pce->constructor;
34 spl_instantiate(pce, retval);
35
36 zend_call_method(retval, pce, &func, ZSTR_VAL(func->common.function_name), ZSTR_LEN(func->common.function_name), NULL, 1, arg1, NULL);
37 return 0;
38 }
39 /* }}} */
40
41 /* {{{ spl_instantiate_arg_ex2 */
spl_instantiate_arg_ex2(zend_class_entry * pce,zval * retval,zval * arg1,zval * arg2)42 static inline int spl_instantiate_arg_ex2(zend_class_entry *pce, zval *retval, zval *arg1, zval *arg2)
43 {
44 zend_function *func = pce->constructor;
45 spl_instantiate(pce, retval);
46
47 zend_call_method(retval, pce, &func, ZSTR_VAL(func->common.function_name), ZSTR_LEN(func->common.function_name), NULL, 2, arg1, arg2);
48 return 0;
49 }
50 /* }}} */
51
52 /* {{{ spl_instantiate_arg_n */
spl_instantiate_arg_n(zend_class_entry * pce,zval * retval,int argc,zval * argv)53 static inline void spl_instantiate_arg_n(zend_class_entry *pce, zval *retval, int argc, zval *argv)
54 {
55 zend_function *func = pce->constructor;
56 zend_fcall_info fci;
57 zend_fcall_info_cache fcc;
58 zval dummy;
59
60 spl_instantiate(pce, retval);
61
62 fci.size = sizeof(zend_fcall_info);
63 ZVAL_STR(&fci.function_name, func->common.function_name);
64 fci.object = Z_OBJ_P(retval);
65 fci.retval = &dummy;
66 fci.param_count = argc;
67 fci.params = argv;
68 fci.no_separation = 1;
69
70 fcc.function_handler = func;
71 fcc.called_scope = pce;
72 fcc.object = Z_OBJ_P(retval);
73
74 zend_call_function(&fci, &fcc);
75 }
76 /* }}} */
77
78 #endif /* SPL_ENGINE_H */
79