xref: /PHP-7.0/ext/spl/spl_engine.h (revision 478f119a)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 7                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 1997-2017 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 /* $Id$ */
20 
21 #ifndef SPL_ENGINE_H
22 #define SPL_ENGINE_H
23 
24 #include "php.h"
25 #include "php_spl.h"
26 #include "zend_interfaces.h"
27 
28 PHPAPI void spl_instantiate(zend_class_entry *pce, zval *object);
29 
30 PHPAPI zend_long spl_offset_convert_to_long(zval *offset);
31 
32 /* {{{ spl_instantiate_arg_ex1 */
spl_instantiate_arg_ex1(zend_class_entry * pce,zval * retval,zval * arg1)33 static inline int spl_instantiate_arg_ex1(zend_class_entry *pce, zval *retval, zval *arg1)
34 {
35 	zend_function *func = pce->constructor;
36 	spl_instantiate(pce, retval);
37 
38 	zend_call_method(retval, pce, &func, ZSTR_VAL(func->common.function_name), ZSTR_LEN(func->common.function_name), NULL, 1, arg1, NULL);
39 	return 0;
40 }
41 /* }}} */
42 
43 /* {{{ spl_instantiate_arg_ex2 */
spl_instantiate_arg_ex2(zend_class_entry * pce,zval * retval,zval * arg1,zval * arg2)44 static inline int spl_instantiate_arg_ex2(zend_class_entry *pce, zval *retval, zval *arg1, zval *arg2)
45 {
46 	zend_function *func = pce->constructor;
47 	spl_instantiate(pce, retval);
48 
49 	zend_call_method(retval, pce, &func, ZSTR_VAL(func->common.function_name), ZSTR_LEN(func->common.function_name), NULL, 2, arg1, arg2);
50 	return 0;
51 }
52 /* }}} */
53 
54 /* {{{ spl_instantiate_arg_n */
spl_instantiate_arg_n(zend_class_entry * pce,zval * retval,int argc,zval * argv)55 static inline void spl_instantiate_arg_n(zend_class_entry *pce, zval *retval, int argc, zval *argv)
56 {
57 	zend_function *func = pce->constructor;
58 	zend_fcall_info fci;
59 	zend_fcall_info_cache fcc;
60 	zval dummy;
61 
62 	spl_instantiate(pce, retval);
63 
64 	fci.size = sizeof(zend_fcall_info);
65 	fci.function_table = &pce->function_table;
66 	ZVAL_STR(&fci.function_name, func->common.function_name);
67 	fci.object = Z_OBJ_P(retval);
68 	fci.symbol_table = NULL;
69 	fci.retval = &dummy;
70 	fci.param_count = argc;
71 	fci.params = argv;
72 	fci.no_separation = 1;
73 
74 	fcc.initialized = 1;
75 	fcc.function_handler = func;
76 	fcc.calling_scope = EG(scope);
77 	fcc.called_scope = pce;
78 	fcc.object = Z_OBJ_P(retval);
79 
80 	zend_call_function(&fci, &fcc);
81 }
82 /* }}} */
83 
84 #endif /* SPL_ENGINE_H */
85 
86 /*
87  * Local Variables:
88  * c-basic-offset: 4
89  * tab-width: 4
90  * End:
91  * vim600: fdm=marker
92  * vim: noet sw=4 ts=4
93  */
94