1 | /* |
2 | +----------------------------------------------------------------------+ |
3 | | PHP Version 5 | |
4 | +----------------------------------------------------------------------+ |
5 | | Copyright (c) 1997-2015 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, int alloc TSRMLS_DC); |
29 | |
30 | PHPAPI long spl_offset_convert_to_long(zval *offset TSRMLS_DC); |
31 | |
32 | /* {{{ spl_instantiate_arg_ex1 */ |
33 | static inline int spl_instantiate_arg_ex1(zend_class_entry *pce, zval **retval, int alloc, zval *arg1 TSRMLS_DC) |
34 | { |
35 | spl_instantiate(pce, retval, alloc TSRMLS_CC); |
36 | |
37 | zend_call_method(retval, pce, &pce->constructor, pce->constructor->common.function_name, strlen(pce->constructor->common.function_name), NULL, 1, arg1, NULL TSRMLS_CC); |
38 | return 0; |
39 | } |
40 | /* }}} */ |
41 | |
42 | /* {{{ spl_instantiate_arg_ex2 */ |
43 | static inline int spl_instantiate_arg_ex2(zend_class_entry *pce, zval **retval, int alloc, zval *arg1, zval *arg2 TSRMLS_DC) |
44 | { |
45 | spl_instantiate(pce, retval, alloc TSRMLS_CC); |
46 | |
47 | zend_call_method(retval, pce, &pce->constructor, pce->constructor->common.function_name, strlen(pce->constructor->common.function_name), NULL, 2, arg1, arg2 TSRMLS_CC); |
48 | return 0; |
49 | } |
50 | /* }}} */ |
51 | |
52 | /* {{{ spl_instantiate_arg_n */ |
53 | static inline void spl_instantiate_arg_n(zend_class_entry *pce, zval **retval, int argc, zval ***argv TSRMLS_DC) |
54 | { |
55 | zend_function *func = pce->constructor; |
56 | zend_fcall_info fci; |
57 | zend_fcall_info_cache fcc; |
58 | zval *dummy; |
59 | zval z_name; |
60 | |
61 | spl_instantiate(pce, retval, 0 TSRMLS_CC); |
62 | |
63 | ZVAL_STRING(&z_name, func->common.function_name, 0); |
64 | |
65 | fci.size = sizeof(zend_fcall_info); |
66 | fci.function_table = &pce->function_table; |
67 | fci.function_name = &z_name; |
68 | fci.object_ptr = *retval; |
69 | fci.symbol_table = NULL; |
70 | fci.retval_ptr_ptr = &dummy; |
71 | fci.param_count = argc; |
72 | fci.params = argv; |
73 | fci.no_separation = 1; |
74 | |
75 | fcc.initialized = 1; |
76 | fcc.function_handler = func; |
77 | fcc.calling_scope = EG(scope); |
78 | fcc.called_scope = pce; |
79 | fcc.object_ptr = *retval; |
80 | |
81 | zend_call_function(&fci, &fcc TSRMLS_CC); |
82 | |
83 | zval_ptr_dtor(&dummy); |
84 | } |
85 | /* }}} */ |
86 | |
87 | #endif /* SPL_ENGINE_H */ |
88 | |
89 | /* |
90 | * Local Variables: |
91 | * c-basic-offset: 4 |
92 | * tab-width: 4 |
93 | * End: |
94 | * vim600: fdm=marker |
95 | * vim: noet sw=4 ts=4 |
96 | */ |
97 | |