xref: /PHP-7.1/ext/spl/spl_engine.h (revision ccd4716e)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 7                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 1997-2018 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 	ZVAL_STR(&fci.function_name, func->common.function_name);
66 	fci.object = Z_OBJ_P(retval);
67 	fci.retval = &dummy;
68 	fci.param_count = argc;
69 	fci.params = argv;
70 	fci.no_separation = 1;
71 
72 	fcc.initialized = 1;
73 	fcc.function_handler = func;
74 	fcc.calling_scope = zend_get_executed_scope();
75 	fcc.called_scope = pce;
76 	fcc.object = Z_OBJ_P(retval);
77 
78 	zend_call_function(&fci, &fcc);
79 }
80 /* }}} */
81 
82 #endif /* SPL_ENGINE_H */
83 
84 /*
85  * Local Variables:
86  * c-basic-offset: 4
87  * tab-width: 4
88  * End:
89  * vim600: fdm=marker
90  * vim: noet sw=4 ts=4
91  */
92