Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 177 lines (141 sloc) 8.621 kb
637a404 - MFH as discussed
Marcus Boerger authored
1 /*
333406b - Added some missing CVS $Id$ tags, headers and footers.
foobar authored
2 +----------------------------------------------------------------------+
3 | Zend Engine |
4 +----------------------------------------------------------------------+
e4ca0ed @felipensp - Year++
felipensp authored
5 | Copyright (c) 1998-2012 Zend Technologies Ltd. (http://www.zend.com) |
333406b - Added some missing CVS $Id$ tags, headers and footers.
foobar authored
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 2.00 of the Zend license, |
8 | that is bundled with this package in the file LICENSE, and is |
f68c7ff updating license information in the headers.
James Cox authored
9 | available through the world-wide-web at the following url: |
333406b - Added some missing CVS $Id$ tags, headers and footers.
foobar authored
10 | http://www.zend.com/license/2_00.txt. |
11 | If you did not receive a copy of the Zend license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@zend.com so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
15 | Authors: Andi Gutmans <andi@zend.com> |
16 | Zeev Suraski <zeev@zend.com> |
17 +----------------------------------------------------------------------+
18 */
19
20 /* $Id$ */
21
6608f07 @smalyshev Mega-commit: Enter the new object model
smalyshev authored
22 #ifndef ZEND_OBJECT_HANDLERS_H
23 #define ZEND_OBJECT_HANDLERS_H
24
25 union _zend_function;
698d301 - Simplify getting property info and make it an api function
Marcus Boerger authored
26 struct _zend_property_info;
6608f07 @smalyshev Mega-commit: Enter the new object model
smalyshev authored
27
7d3215d @andigutmans - Add comments to read/write property/dimension for extension authors
andigutmans authored
28 /* The following rule applies to read_property() and read_dimension() implementations:
29 If you return a zval which is not otherwise referenced by the extension or the engine's
30 symbol table, its reference count should be 0.
31 */
6608f07 @smalyshev Mega-commit: Enter the new object model
smalyshev authored
32 /* Used to fetch property from the object, read-only */
bd9b600 @smalyshev API change for read_property:
smalyshev authored
33 typedef zval *(*zend_object_read_property_t)(zval *object, zval *member, int type TSRMLS_DC);
938c0fb @zsuraski Initial support for overloading of array syntax for objects (very ini…
zsuraski authored
34
3cfa6a6 @zsuraski Add get_dim callback
zsuraski authored
35 /* Used to fetch dimension from the object, read-only */
473927e @zsuraski Fix write-mode of overloaded objects when using array dimensions
zsuraski authored
36 typedef zval *(*zend_object_read_dimension_t)(zval *object, zval *offset, int type TSRMLS_DC);
3cfa6a6 @zsuraski Add get_dim callback
zsuraski authored
37
7d3215d @andigutmans - Add comments to read/write property/dimension for extension authors
andigutmans authored
38
39 /* The following rule applies to write_property() and write_dimension() implementations:
40 If you receive a value zval in write_property/write_dimension, you may only modify it if
41 its reference count is 1. Otherwise, you must create a copy of that zval before making
42 any changes. You should NOT modify the reference count of the value passed to you.
43 */
6608f07 @smalyshev Mega-commit: Enter the new object model
smalyshev authored
44 /* Used to set property of the object */
938c0fb @zsuraski Initial support for overloading of array syntax for objects (very ini…
zsuraski authored
45 typedef void (*zend_object_write_property_t)(zval *object, zval *member, zval *value TSRMLS_DC);
46
47 /* Used to set dimension of the object */
48 typedef void (*zend_object_write_dimension_t)(zval *object, zval *offset, zval *value TSRMLS_DC);
6608f07 @smalyshev Mega-commit: Enter the new object model
smalyshev authored
49
7d3215d @andigutmans - Add comments to read/write property/dimension for extension authors
andigutmans authored
50
04ed2b5 @smalyshev New stuff for objects API:
smalyshev authored
51 /* Used to create pointer to the property of the object, for future direct r/w access */
3f5acc7 @zsuraski Remove redundant callback, simplify API
zsuraski authored
52 typedef zval **(*zend_object_get_property_ptr_ptr_t)(zval *object, zval *member TSRMLS_DC);
938c0fb @zsuraski Initial support for overloading of array syntax for objects (very ini…
zsuraski authored
53
bcf30a0 @smalyshev some more clear comments
smalyshev authored
54 /* Used to set object value. Can be used to override assignments and scalar
55 write ops (like ++, +=) on the object */
6783be7 @tony2001 change argument name, it should be "object" not "property"
tony2001 authored
56 typedef void (*zend_object_set_t)(zval **object, zval *value TSRMLS_DC);
938c0fb @zsuraski Initial support for overloading of array syntax for objects (very ini…
zsuraski authored
57
bcf30a0 @smalyshev some more clear comments
smalyshev authored
58 /* Used to get object value. Can be used when converting object value to
59 * one of the basic types and when using scalar ops (like ++, +=) on the object
938c0fb @zsuraski Initial support for overloading of array syntax for objects (very ini…
zsuraski authored
60 */
6783be7 @tony2001 change argument name, it should be "object" not "property"
tony2001 authored
61 typedef zval* (*zend_object_get_t)(zval *object TSRMLS_DC);
6608f07 @smalyshev Mega-commit: Enter the new object model
smalyshev authored
62
63 /* Used to check if a property of the object exists */
56d543c - Extend API to support real existance test without the need to add a…
Marcus Boerger authored
64 /* param has_set_exists:
625d5ba typofix :)
foobar authored
65 * 0 (has) whether property exists and is not NULL
56d543c - Extend API to support real existance test without the need to add a…
Marcus Boerger authored
66 * 1 (set) whether property exists and is true
67 * 2 (exists) whether property exists
68 */
69 typedef int (*zend_object_has_property_t)(zval *object, zval *member, int has_set_exists TSRMLS_DC);
938c0fb @zsuraski Initial support for overloading of array syntax for objects (very ini…
zsuraski authored
70
296529b Split isset/isempty for object property and object dimension hooking.
Marcus Boerger authored
71 /* Used to check if a dimension of the object exists */
72 typedef int (*zend_object_has_dimension_t)(zval *object, zval *member, int check_empty TSRMLS_DC);
73
6608f07 @smalyshev Mega-commit: Enter the new object model
smalyshev authored
74 /* Used to remove a property of the object */
938c0fb @zsuraski Initial support for overloading of array syntax for objects (very ini…
zsuraski authored
75 typedef void (*zend_object_unset_property_t)(zval *object, zval *member TSRMLS_DC);
6608f07 @smalyshev Mega-commit: Enter the new object model
smalyshev authored
76
296529b Split isset/isempty for object property and object dimension hooking.
Marcus Boerger authored
77 /* Used to remove a dimension of the object */
c0b4673 @zsuraski Improve array overloading - support unset($foo["bar"])
zsuraski authored
78 typedef void (*zend_object_unset_dimension_t)(zval *object, zval *offset TSRMLS_DC);
79
6608f07 @smalyshev Mega-commit: Enter the new object model
smalyshev authored
80 /* Used to get hash of the properties of the object, as hash of zval's */
938c0fb @zsuraski Initial support for overloading of array syntax for objects (very ini…
zsuraski authored
81 typedef HashTable *(*zend_object_get_properties_t)(zval *object TSRMLS_DC);
6608f07 @smalyshev Mega-commit: Enter the new object model
smalyshev authored
82
8ce1211 - MFH debug object helper
Marcus Boerger authored
83 typedef HashTable *(*zend_object_get_debug_info_t)(zval *object, int *is_temp TSRMLS_DC);
84
6608f07 @smalyshev Mega-commit: Enter the new object model
smalyshev authored
85 /* Used to call methods */
86 /* args on stack! */
938c0fb @zsuraski Initial support for overloading of array syntax for objects (very ini…
zsuraski authored
87 /* Andi - EX(fbc) (function being called) needs to be initialized already in the INIT fcall opcode so that the parameters can be parsed the right way. We need to add another callback for this.
88 */
89 typedef int (*zend_object_call_method_t)(char *method, INTERNAL_FUNCTION_PARAMETERS);
c5a9a5a - Change zend_object_handlers->get_method() to allow aggregation for …
Marcus Boerger authored
90 typedef union _zend_function *(*zend_object_get_method_t)(zval **object_ptr, char *method, int method_len TSRMLS_DC);
6608f07 @smalyshev Mega-commit: Enter the new object model
smalyshev authored
91 typedef union _zend_function *(*zend_object_get_constructor_t)(zval *object TSRMLS_DC);
92
93 /* Object maintenance/destruction */
c84a4ea @andigutmans - Pass TSRMLS to callbacks.
andigutmans authored
94 typedef void (*zend_object_add_ref_t)(zval *object TSRMLS_DC);
95 typedef void (*zend_object_del_ref_t)(zval *object TSRMLS_DC);
96 typedef void (*zend_object_delete_obj_t)(zval *object TSRMLS_DC);
97 typedef zend_object_value (*zend_object_clone_obj_t)(zval *object TSRMLS_DC);
6608f07 @smalyshev Mega-commit: Enter the new object model
smalyshev authored
98
cf7384a @felipensp - MFH: Constness (Added const qualifier to several function parameters)
felipensp authored
99 typedef zend_class_entry *(*zend_object_get_class_entry_t)(const zval *object TSRMLS_DC);
100 typedef int (*zend_object_get_class_name_t)(const zval *object, char **class_name, zend_uint *class_name_len, int parent TSRMLS_DC);
6608f07 @smalyshev Mega-commit: Enter the new object model
smalyshev authored
101 typedef int (*zend_object_compare_t)(zval *object1, zval *object2 TSRMLS_DC);
637a404 - MFH as discussed
Marcus Boerger authored
102
103 /* Cast an object to some other type
104 */
105 typedef int (*zend_object_cast_t)(zval *readobj, zval *retval, int type TSRMLS_DC);
ae2bfb7 Assume lazy consensus regarding the cast_object() patch. *Only* impl…
Sterling Hughes authored
106
d056b25 @wez Add count_elements handler for overloaded objects.
wez authored
107 /* updates *count to hold the number of elements present and returns SUCCESS.
108 * Returns FAILURE if the object does not have any sense of overloaded dimensions */
109 typedef int (*zend_object_count_elements_t)(zval *object, long *count TSRMLS_DC);
6608f07 @smalyshev Mega-commit: Enter the new object model
smalyshev authored
110
7d4fd3f Fixed bug #46409 (__invoke method called outside of object context wh…
Dmitry Stogov authored
111 typedef int (*zend_object_get_closure_t)(zval *obj, zend_class_entry **ce_ptr, union _zend_function **fptr_ptr, zval **zobj_ptr TSRMLS_DC);
f90255c @colder MFH: Handlerify get_closure
colder authored
112
eb99c74 - MFH move zend_object_Value definition to zend_types.h
Marcus Boerger authored
113 struct _zend_object_handlers {
6608f07 @smalyshev Mega-commit: Enter the new object model
smalyshev authored
114 /* general object functions */
ae6a1e7 @zsuraski whitespace
zsuraski authored
115 zend_object_add_ref_t add_ref;
116 zend_object_del_ref_t del_ref;
7a12eb8 WS
Marcus Boerger authored
117 zend_object_clone_obj_t clone_obj;
6608f07 @smalyshev Mega-commit: Enter the new object model
smalyshev authored
118 /* individual object functions */
ae6a1e7 @zsuraski whitespace
zsuraski authored
119 zend_object_read_property_t read_property;
120 zend_object_write_property_t write_property;
3cfa6a6 @zsuraski Add get_dim callback
zsuraski authored
121 zend_object_read_dimension_t read_dimension;
ae6a1e7 @zsuraski whitespace
zsuraski authored
122 zend_object_write_dimension_t write_dimension;
3f5acc7 @zsuraski Remove redundant callback, simplify API
zsuraski authored
123 zend_object_get_property_ptr_ptr_t get_property_ptr_ptr;
ae6a1e7 @zsuraski whitespace
zsuraski authored
124 zend_object_get_t get;
125 zend_object_set_t set;
126 zend_object_has_property_t has_property;
127 zend_object_unset_property_t unset_property;
296529b Split isset/isempty for object property and object dimension hooking.
Marcus Boerger authored
128 zend_object_has_dimension_t has_dimension;
c0b4673 @zsuraski Improve array overloading - support unset($foo["bar"])
zsuraski authored
129 zend_object_unset_dimension_t unset_dimension;
ae6a1e7 @zsuraski whitespace
zsuraski authored
130 zend_object_get_properties_t get_properties;
131 zend_object_get_method_t get_method;
132 zend_object_call_method_t call_method;
133 zend_object_get_constructor_t get_constructor;
134 zend_object_get_class_entry_t get_class_entry;
135 zend_object_get_class_name_t get_class_name;
136 zend_object_compare_t compare_objects;
137 zend_object_cast_t cast_object;
d056b25 @wez Add count_elements handler for overloaded objects.
wez authored
138 zend_object_count_elements_t count_elements;
8ce1211 - MFH debug object helper
Marcus Boerger authored
139 zend_object_get_debug_info_t get_debug_info;
f90255c @colder MFH: Handlerify get_closure
colder authored
140 zend_object_get_closure_t get_closure;
eb99c74 - MFH move zend_object_Value definition to zend_types.h
Marcus Boerger authored
141 };
6608f07 @smalyshev Mega-commit: Enter the new object model
smalyshev authored
142
e3baf1a @wez must be extern to avoid problems with some compilers
wez authored
143 extern ZEND_API zend_object_handlers std_object_handlers;
eb99c74 - MFH move zend_object_Value definition to zend_types.h
Marcus Boerger authored
144
3a3f95a wrap ZEND_API prototypes into BEGIN_EXTERN_C/END_EXTERN_C
Hartmut Holzgraefe authored
145 BEGIN_EXTERN_C()
9c909f4 Sync: Export externally used functions.
Sebastian Bergmann authored
146 ZEND_API union _zend_function *zend_std_get_static_method(zend_class_entry *ce, char *function_name_strval, int function_name_strlen TSRMLS_DC);
147 ZEND_API zval **zend_std_get_static_property(zend_class_entry *ce, char *property_name, int property_name_len, zend_bool silent TSRMLS_DC);
148 ZEND_API zend_bool zend_std_unset_static_property(zend_class_entry *ce, char *property_name, int property_name_len TSRMLS_DC);
c4c96c0 @tony2001 MFH: export zend_std_get_constructor()
tony2001 authored
149 ZEND_API union _zend_function *zend_std_get_constructor(zval *object TSRMLS_DC);
698d301 - Simplify getting property info and make it an api function
Marcus Boerger authored
150 ZEND_API struct _zend_property_info *zend_get_property_info(zend_class_entry *ce, zval *member, int silent TSRMLS_DC);
8ce1211 - MFH debug object helper
Marcus Boerger authored
151 ZEND_API HashTable *zend_std_get_properties(zval *object TSRMLS_DC);
152 ZEND_API HashTable *zend_std_get_debug_info(zval *object, int *is_temp TSRMLS_DC);
637a404 - MFH as discussed
Marcus Boerger authored
153 ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int type TSRMLS_DC);
d4f64f8 Reenable __tostring() magic for print,echo,concatenation,function nam…
Marcus Boerger authored
154
6608f07 @smalyshev Mega-commit: Enter the new object model
smalyshev authored
155
637a404 - MFH as discussed
Marcus Boerger authored
156 #define IS_ZEND_STD_OBJECT(z) (Z_TYPE(z) == IS_OBJECT && (Z_OBJ_HT((z))->get_class_entry != NULL))
3738a6e only check for an available class entry instead of
Harald Radi authored
157 #define HAS_CLASS_ENTRY(z) (Z_OBJ_HT(z)->get_class_entry != NULL)
6608f07 @smalyshev Mega-commit: Enter the new object model
smalyshev authored
158
c81db6b Fixed bug #29210 (Function: is_callable - no support for private and …
Dmitry Stogov authored
159 ZEND_API int zend_check_private(union _zend_function *fbc, zend_class_entry *ce, char *function_name_strval, int function_name_strlen TSRMLS_DC);
160
9c909f4 Sync: Export externally used functions.
Sebastian Bergmann authored
161 ZEND_API int zend_check_protected(zend_class_entry *ce, zend_class_entry *scope);
35c4093 Fix destructor visibility
Marcus Boerger authored
162
519ed8e - Better fix for #34505 and related, drop zend_unmangle_property_name…
Marcus Boerger authored
163 ZEND_API int zend_check_property_access(zend_object *zobj, char *prop_info_name, int prop_info_name_len TSRMLS_DC);
49efcd4 Fixed bug #24837 Incorrect behaviour of PPP using foreach.
Marcus Boerger authored
164
0a8a950 Expose zend_std_call_user_call(), needed for implementation of things…
Ilia Alshanetsky authored
165 ZEND_API void zend_std_call_user_call(INTERNAL_FUNCTION_PARAMETERS);
3a3f95a wrap ZEND_API prototypes into BEGIN_EXTERN_C/END_EXTERN_C
Hartmut Holzgraefe authored
166 END_EXTERN_C()
0a8a950 Expose zend_std_call_user_call(), needed for implementation of things…
Ilia Alshanetsky authored
167
6608f07 @smalyshev Mega-commit: Enter the new object model
smalyshev authored
168 #endif
333406b - Added some missing CVS $Id$ tags, headers and footers.
foobar authored
169
170 /*
171 * Local variables:
172 * tab-width: 4
173 * c-basic-offset: 4
174 * indent-tabs-mode: t
175 * End:
176 */
Something went wrong with that request. Please try again.