1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
|
--- phpc/phpc.h 2016-06-26 16:59:54.000000000 +0200
+++ /work/GIT/pecl-and-ext/phpc/phpc.h 2020-08-25 10:43:46.675520654 +0200
@@ -50,33 +50,13 @@
#define PHPC_OBJ_INIT_HANDLERS(_name) \
memcpy(&PHPC_OBJ_GET_HANDLER_VAR_NAME(_name), \
zend_get_std_object_handlers(), sizeof(zend_object_handlers))
-#define PHPC_CLASS_SET_HANDLER_CREATE(_class_entry, _name) \
- _class_entry.create_object = PHPC_OBJ_GET_HANDLER_FCE(_name, create)
-#define PHPC_OBJ_SET_HANDLER_CLONE(_name) \
- PHPC_OBJ_GET_HANDLER_VAR_NAME(_name).clone_obj = PHPC_OBJ_GET_HANDLER_FCE(_name, clone)
-#define PHPC_OBJ_SET_HANDLER_COMPARE(_name) \
- PHPC_OBJ_GET_HANDLER_VAR_NAME(_name).compare_objects = PHPC_OBJ_GET_HANDLER_FCE(_name, compare)
-#define PHPC_OBJ_HAS_HANDLER_GET_GC (PHP_VERSION_ID > 50399)
-#if PHPC_OBJ_HAS_HANDLER_GET_GC
-#define PHPC_OBJ_SET_HANDLER_GET_GC(_name) \
- PHPC_OBJ_GET_HANDLER_VAR_NAME(_name).get_gc = PHPC_OBJ_GET_HANDLER_FCE(_name, get_gc)
-#else
-#define PHPC_OBJ_SET_HANDLER_GET_GC(_name) PHPC_NOOP
-#endif
-#define PHPC_OBJ_HAS_HANDLER_GET_DEBUG_INFO (PHP_VERSION_ID > 50299)
-#if PHPC_OBJ_HAS_HANDLER_GET_DEBUG_INFO
-#define PHPC_OBJ_SET_HANDLER_GET_DEBUG_INFO(_name) \
- PHPC_OBJ_GET_HANDLER_VAR_NAME(_name).get_debug_info = PHPC_OBJ_GET_HANDLER_FCE(_name, get_debug_info)
-#else
-#define PHPC_OBJ_SET_HANDLER_GET_DEBUG_INFO(_name) PHPC_NOOP
+
+/* ZEND_ACC_CTOR and ZEND_ACC_DTOR is removed in 7.4 */
+#ifndef ZEND_ACC_CTOR
+#define ZEND_ACC_CTOR 0
#endif
-/* there is such handler in 5.2 but we would have to re-implement zend_std_get_properties */
-#define PHPC_OBJ_HAS_HANDLER_GET_PROPERTIES (PHP_VERSION_ID > 50299)
-#if PHPC_OBJ_HAS_HANDLER_GET_PROPERTIES
-#define PHPC_OBJ_SET_HANDLER_GET_PROPERTIES(_name) \
- PHPC_OBJ_GET_HANDLER_VAR_NAME(_name).get_properties = PHPC_OBJ_GET_HANDLER_FCE(_name, get_properties)
-#else
-#define PHPC_OBJ_SET_HANDLER_GET_PROPERTIES(_name) PHPC_NOOP
+#ifndef ZEND_ACC_DTOR
+#define ZEND_ACC_DTOR 0
#endif
#if PHP_VERSION_ID < 50299
@@ -85,25 +65,58 @@
#define phpc_function_entry const zend_function_entry
#endif
+#if PHP_MAJOR_VERSION < 8
+#define PHPC_OBJ_FOR_PROP(_obj) (_obj)
+#else
+#define PHPC_OBJ_FOR_PROP(_obj) Z_OBJ_P(_obj)
+/* ZTS */
+#define TSRMLS_D void
+#define TSRMLS_DC
+#define TSRMLS_C
+#define TSRMLS_CC
+#define TSRMLS_FETCH()
+#endif
-/* initializing properties in obejct (object_properties_init was added in PHP 5.4) */
#if PHP_VERSION_ID < 50399
-#define PHPC_OBJ_PROPERTIES_INIT(zo, class_type) \
- { \
- zval *tmp; \
- zend_hash_copy((*(zo)).properties, \
- &(class_type)->default_properties, \
+/* initializing properties in obejct (object_properties_init was added in PHP 5.4) */
+#define PHPC_OBJ_PROPERTIES_INIT(_zo, _class_type) \
+ do { \
+ zval *_phpc_tmp; \
+ zend_hash_copy((*(_zo)).properties, \
+ &(_class_type)->default_properties, \
(copy_ctor_func_t) zval_add_ref, \
- (void *) &tmp, \
+ (void *) &_phpc_tmp, \
sizeof(zval *)); \
- }
+ } while(0)
+
+/* write property */
+#define PHPC_OBJ_STD_WRITE_PROPERTY(_obj, _member, _value) \
+ Z_OBJ_HT_P(_obj)->write_property(_obj, _member, _value TSRMLS_CC)
#else
#define PHPC_OBJ_PROPERTIES_INIT object_properties_init
+#define PHPC_OBJ_STD_WRITE_PROPERTY(_obj, _member, _value) \
+ zend_std_write_property(_obj, _member, _value, NULL TSRMLS_CC)
#endif
/* common fcall macros */
#define PHPC_FCALL_PARAMS_NAME(_pname) _phpc_fcall_params__ ## _pname
+#if PHP_MAJOR_VERSION == 8
+#define PHPC_FCALL_FCI_INIT(_fci, callback, count, no_separ) \
+ do { \
+ (_fci).params = PHPC_FCALL_PARAMS_NAME(callback); \
+ (_fci).param_count = (count); \
+ } while (0)
+#else
+#define PHPC_FCALL_FCI_INIT(_fci, callback, count, no_separ) \
+ do { \
+ (_fci).params = PHPC_FCALL_PARAMS_NAME(callback); \
+ (_fci).param_count = (count); \
+ (_fci).no_separation = (no_separ); \
+ } while (0)
+#endif
+
+
/* integer conversions */
#define PHPC_CONVERT_NUMBER(_pn, _n, _exc_over, _exc_under, _type_from, _type_to, _max, _min) \
if (_pn > (_type_from) _max) { \
@@ -195,6 +208,12 @@
#define PHPC_STR_FROM_PTR_VAL(_str, _strpv) \
PHPC_STR_VAL(_str) = *PHPC_STR_VAL(_strpv); \
PHPC_STR_LEN(_str) = strlen(*PHPC_STR_VAL(_strpv))
+#define PHPC_STR_FROM_ZVAL(_str, _zv) \
+ PHPC_STR_VAL(_str) = Z_STRVAL(_zv); \
+ PHPC_STR_LEN(_str) = Z_STRLEN(_zv)
+#define PHPC_STR_FROM_PZVAL(_str, _pzv) \
+ PHPC_STR_VAL(_str) = Z_STRVAL_P(_pzv); \
+ PHPC_STR_LEN(_str) = Z_STRLEN_P(_pzv)
#define PHPC_STR_RETURN(_name) \
RETURN_STRINGL(PHPC_STR_VAL(_name), PHPC_STR_LEN(_name), 0)
@@ -347,8 +366,8 @@
PHPC_OBJ_STRUCT_DECLARE(_name, _obj) = PHPC_OBJ_FROM_ZVAL(_name, _phpc_obj ## _id)
/* handler setters */
-#define PHPC_OBJ_SET_HANDLER_OFFSET(_name) PHPC_NOOP
-#define PHPC_OBJ_SET_HANDLER_FREE(_name) PHPC_NOOP
+#define PHPC_OBJ_SET_SPECIFIC_HANDLER_OFFSET(_handlers, _name) PHPC_NOOP
+#define PHPC_OBJ_SET_SPECIFIC_HANDLER_FREE(_handlers, _name) PHPC_NOOP
/* read propery */
#define PHPC_READ_PROPERTY_RV_NAME
@@ -359,6 +378,7 @@
/* HASH */
/* apply count */
+#define PHPC_HASH_HAS_APPLY_COUNT(_ht) (_ht->nApplyCount > 0)
#define PHPC_HASH_GET_APPLY_COUNT(_ht) _ht->nApplyCount
#define PHPC_HASH_INC_APPLY_COUNT(_ht) _ht->nApplyCount++
#define PHPC_HASH_DEC_APPLY_COUNT(_ht) _ht->nApplyCount--
@@ -383,6 +403,12 @@
#define PHPC_HASH_CSTR_ADD(_ht, _cstr_value, _pzv) \
zend_hash_add(_ht, _cstr_value, strlen(_cstr_value) + 1, &_pzv, sizeof(_pzv), NULL)
+/* next insert */
+#define PHPC_HASH_NEXT_INDEX_INSERT_PTR(_ht, _ptr, _ptr_size) \
+ zend_hash_next_index_insert(_ht, _ptr, _ptr_size, NULL)
+#define PHPC_HASH_NEXT_INDEX_INSERT(_ht, _pzv) \
+ zend_hash_next_index_insert(_ht, _pzv, sizeof(_pzv), NULL)
+
/* update ptr */
#define PHPC_HASH_INDEX_UPDATE_PTR(_ht, _idx, _ptr, _ptr_size) \
zend_hash_index_update(_ht, _idx, _ptr, _ptr_size, NULL)
@@ -459,6 +485,13 @@
#define PHPC_HASH_COPY_EX(_target, _source, _copy_ctr) \
zend_hash_copy(_target, _source, NULL, NULL, sizeof(zval *))
+/* key result constant has been renamed in 5.4 */
+#if PHP_VERSION_ID < 50399
+#define _PHPC_HASH_KEY_NON_EXISTENT HASH_KEY_NON_EXISTANT
+#else
+#define _PHPC_HASH_KEY_NON_EXISTENT HASH_KEY_NON_EXISTENT
+#endif
+
/* iteration for each element */
#define PHPC_HASH_FOREACH_KEY(_ht, _h, _key) do { \
HashPosition _pos; \
@@ -466,7 +499,7 @@
int _key_type; \
for (zend_hash_internal_pointer_reset_ex((_ht), &_pos); \
(_key_type = zend_hash_get_current_key_ex( \
- (_ht), &PHPC_STR_VAL(_key), &_str_length, &_h, 0, &_pos)) != HASH_KEY_NON_EXISTENT; \
+ (_ht), &PHPC_STR_VAL(_key), &_str_length, &_h, 0, &_pos)) != _PHPC_HASH_KEY_NON_EXISTENT; \
zend_hash_move_forward_ex((_ht), &_pos) ) { \
if (_key_type == HASH_KEY_IS_STRING) { \
PHPC_STR_LEN(_key) = (int) _str_length - 1; \
@@ -529,7 +562,15 @@
} while(0)
+/* SYMTABLE */
+
+/* update*/
+#define PHPC_SYMTABLE_UPDATE(_ht, _str, _pzv) \
+ zend_symtable_update(_ht, PHPC_STR_VAL(_str), PHPC_STR_LEN(_str) + 1, &_pzv, sizeof(_pzv), NULL)
+
+
/* ARRAY */
+
#define PHPC_ARRAY_ADD_ASSOC_NULL_EX(_arr, _key, _key_len) \
add_assoc_null_ex(_arr, _key, (_key_len) + 1)
#define PHPC_ARRAY_ADD_ASSOC_BOOL_EX(_arr, _key, _key_len, _b) \
@@ -642,6 +683,9 @@
#define PHPC_OBJDEBUG Z_OBJDEBUG_P
#define PHPC_OBJDEBUG_P Z_OBJDEBUG_PP
+#define PHPC_REFCOUNTED(_zv) 1
+#define PHPC_REFCOUNTED_P(_pzv) 1
+
#define PHPC_PZVAL_CAST_TO_PVAL(_pzv) &_pzv
#define PHPC_VAL_CAST_TO_ZVAL(_pv) *(_pv)
@@ -659,19 +703,39 @@
#define PHPC_VAL_COPY(_pv, _zv) ZVAL_ZVAL(_pv, _zv, 1, 0)
#define PHPC_VAL_ASSIGN(_pv, _zv) _pv = _zv
+#define PHPC_PZVAL_MAKE MAKE_STD_ZVAL
+#define PHPC_PZVAL_FREE FREE_ZVAL
+#define PHPC_PZVAL_SET(_pv, _zv) ZVAL_ZVAL(_pv, _zv, 0, 0)
#define PHPC_PVAL_DEREF(_pv) PHPC_NOOP
#define PHPC_PZVAL_DEREF(_pv) PHPC_NOOP
-#define PHPC_VAL_STR(_pv, _str) \
+#define PHPC_PZVAL_COPY_INIT INIT_PZVAL_COPY
+#define PHPC_PZVAL_COPY(_pzv_dst, _pzv_src) \
+ *_pzv_dst = *_pzv_src
+
+#define PHPC_VAL_NEW_STR(_pv, _str) \
ZVAL_STRINGL(_pv, PHPC_STR_VAL(_str), PHPC_STR_LEN(_str), 0)
+#define PHPC_VAL_STR PHPC_VAL_NEW_STR
#define PHPC_VAL_CSTR(_pv, _cstr) \
ZVAL_STRING(_pv, _cstr, 1)
#define PHPC_VAL_CSTRL(_pv, _cstr, _cstr_len) \
ZVAL_STRINGL(_pv, _cstr, _cstr_len, 1)
-#define PHPC_PZVAL_STR PHPC_VAL_STR
-#define PHPC_PZVAL_CSTR PHPC_VAL_CSTR
-#define PHPC_PZVAL_CSTRL PHPC_VAL_CSTRL
+#define PHPC_PZVAL_NEW_STR PHPC_VAL_NEW_STR
+#define PHPC_PZVAL_STR PHPC_VAL_STR
+#define PHPC_PZVAL_CSTR PHPC_VAL_CSTR
+#define PHPC_PZVAL_CSTRL PHPC_VAL_CSTRL
+
+#define PHPC_ZVAL_COPY(_zv_dst, _zv_src) \
+ _zv_dst = _zv_src
+
+#define PHPC_ZVAL_NEW_STR(_zv, _str) \
+ PHPC_VAL_STR(&_zv, _str)
+#define PHPC_ZVAL_STR PHPC_ZVAL_NEW_STR
+#define PHPC_ZVAL_CSTR(_zv, _cstr) \
+ PHPC_VAL_CSTR(&_zv, _cstr)
+#define PHPC_ZVAL_CSTRL(_zv, _cstr, _cstr_len) \
+ PHPC_VAL_CSTRL(&_zv, _cstr, _cstr_len)
#define PHPC_ZVAL_IS_TRUE(_zv) \
(Z_TYPE(_zv) == IS_BOOL && Z_BVAL(_zv))
@@ -815,6 +879,8 @@
#define PHPC_STR_FROM_PTR_STR(_str, _strp) _str = *_strp
#define PHPC_STR_FROM_PTR_VAL(_str, _strpv) _str = *_strpv
#define PHPC_STR_RETURN RETURN_STR
+#define PHPC_STR_FROM_ZVAL(_str, _zv) _str = Z_STR(_zv)
+#define PHPC_STR_FROM_PZVAL(_str, _pzv) _str = Z_STR_P(_pzv)
/* wrapper macros */
#define PHPC_STR_INIT(_name, _cstr, _len) \
_name = zend_string_init(_cstr, _len, 0)
@@ -948,26 +1014,34 @@
PHPC_OBJ_STRUCT_DECLARE(_name, _obj) = PHPC_OBJ_FROM_ZVAL(_name, _phpc_obj ## _id)
/* handler setters */
-#define PHPC_OBJ_SET_HANDLER_OFFSET(_name) \
- PHPC_OBJ_GET_HANDLER_VAR_NAME(_name).offset = XtOffsetOf(PHPC_OBJ_STRUCT_NAME(_name), std)
-#define PHPC_OBJ_SET_HANDLER_FREE(_name) \
- PHPC_OBJ_GET_HANDLER_VAR_NAME(_name).free_obj = PHPC_OBJ_GET_HANDLER_FCE(_name, free)
+#define PHPC_OBJ_SET_SPECIFIC_HANDLER_OFFSET(_handlers, _name) \
+ (_handlers).offset = XtOffsetOf(PHPC_OBJ_STRUCT_NAME(_name), std)
+#define PHPC_OBJ_SET_SPECIFIC_HANDLER_FREE(_handlers, _name) \
+ (_handlers).free_obj = PHPC_OBJ_GET_HANDLER_FCE(_name, free)
/* read propery */
#define PHPC_READ_PROPERTY_RV_NAME _phpc_read_property_rv
#define PHPC_READ_PROPERTY_RV_DECLARE zval PHPC_READ_PROPERTY_RV_NAME
#define PHPC_READ_PROPERTY(_scope, _object, _name, _name_len, _silent) \
- zend_read_property(_scope, _object, _name, _name_len, _silent, &PHPC_READ_PROPERTY_RV_NAME)
+ zend_read_property(_scope, PHPC_OBJ_FOR_PROP(_object), _name, _name_len, _silent, &PHPC_READ_PROPERTY_RV_NAME)
/* HASH */
-/* apply count */
-#define PHPC_HASH_GET_APPLY_COUNT ZEND_HASH_GET_APPLY_COUNT
-#define PHPC_HASH_INC_APPLY_COUNT ZEND_HASH_INC_APPLY_COUNT
-#define PHPC_HASH_DEC_APPLY_COUNT ZEND_HASH_DEC_APPLY_COUNT
-#define PHPC_HASH_APPLY_PROTECTION ZEND_HASH_APPLY_PROTECTION
-
+/* recursion protection */
+#if PHP_VERSION_ID < 70299
+#define PHPC_HASH_HAS_APPLY_COUNT(_tht) (ZEND_HASH_GET_APPLY_COUNT(_tht) > 0)
+#define PHPC_HASH_GET_APPLY_COUNT ZEND_HASH_GET_APPLY_COUNT
+#define PHPC_HASH_INC_APPLY_COUNT ZEND_HASH_INC_APPLY_COUNT
+#define PHPC_HASH_DEC_APPLY_COUNT ZEND_HASH_DEC_APPLY_COUNT
+#define PHPC_HASH_APPLY_PROTECTION ZEND_HASH_APPLY_PROTECTION
+#else
+#define PHPC_HASH_HAS_APPLY_COUNT GC_IS_RECURSIVE
+#define PHPC_HASH_GET_APPLY_COUNT GC_IS_RECURSIVE
+#define PHPC_HASH_INC_APPLY_COUNT GC_PROTECT_RECURSION
+#define PHPC_HASH_DEC_APPLY_COUNT GC_UNPROTECT_RECURSION
+#define PHPC_HASH_APPLY_PROTECTION(_tht) (!(GC_FLAGS(_tht) & GC_IMMUTABLE))
+#endif
/* add ptr */
#define PHPC_HASH_INDEX_ADD_PTR(_ht, _idx, _ptr, _ptr_size) \
zend_hash_index_add_ptr(_ht, _idx, _ptr)
@@ -984,6 +1058,11 @@
#define PHPC_HASH_CSTR_ADD(_ht, _cstr_value, _pzv) \
zend_hash_str_add(_ht, _cstr_value, strlen(_cstr_value), _pzv)
+/* next insert */
+#define PHPC_HASH_NEXT_INDEX_INSERT_PTR(_ht, _ptr, _ptr_size) \
+ zend_hash_next_index_insert_ptr(_ht, _ptr)
+#define PHPC_HASH_NEXT_INDEX_INSERT zend_hash_next_index_insert
+
/* update ptr */
#define PHPC_HASH_INDEX_UPDATE_PTR(_ht, _idx, _ptr, _ptr_size) \
zend_hash_index_update_ptr(_ht, _idx, _ptr)
@@ -1067,6 +1146,12 @@
#define PHPC_HASH_RETURN RETURN_ARR
+/* SYMTABLE */
+
+/* update*/
+#define PHPC_SYMTABLE_UPDATE zend_symtable_update
+
+
/* ARRAY */
#define PHPC_ARRAY_ADD_ASSOC_NULL_EX add_assoc_null_ex
@@ -1157,6 +1242,9 @@
#define PHPC_OBJDEBUG Z_OBJDEBUG
#define PHPC_OBJDEBUG_P Z_OBJDEBUG_P
+#define PHPC_REFCOUNTED Z_REFCOUNTED
+#define PHPC_REFCOUNTED_P Z_REFCOUNTED_P
+
#define PHPC_PZVAL_CAST_TO_PVAL(_pzv) _pzv
#define PHPC_VAL_CAST_TO_ZVAL(_pv) _pv
@@ -1174,9 +1262,17 @@
#define PHPC_VAL_COPY(_pv, _zv) ZVAL_COPY(&(_pv), _zv)
#define PHPC_VAL_ASSIGN PHPC_VAL_COPY
-#define PHPC_PVAL_DEREF ZVAL_DEREF
-#define PHPC_PZVAL_DEREF ZVAL_DEREF
+#define PHPC_PZVAL_MAKE(_pzv) PHPC_NOOP
+#define PHPC_PZVAL_FREE(_pzv) PHPC_NOOP
+#define PHPC_PZVAL_SET(_pv, _zv) _pv = _zv
+#define PHPC_PVAL_DEREF ZVAL_DEREF
+#define PHPC_PZVAL_DEREF ZVAL_DEREF
+
+#define PHPC_PZVAL_COPY_INIT ZVAL_COPY_VALUE
+#define PHPC_PZVAL_COPY ZVAL_COPY_VALUE
+#define PHPC_VAL_NEW_STR(_pv, _str) \
+ ZVAL_NEW_STR(&_pv, _str)
#define PHPC_VAL_STR(_pv, _str) \
ZVAL_STR(&_pv, _str)
#define PHPC_VAL_CSTR(_pv, _cstr) \
@@ -1184,9 +1280,18 @@
#define PHPC_VAL_CSTRL(_pv, _cstr, _cstr_len) \
ZVAL_STRINGL(&_pv, _cstr, _cstr_len)
-#define PHPC_PZVAL_STR ZVAL_STR
-#define PHPC_PZVAL_CSTR ZVAL_STRING
-#define PHPC_PZVAL_CSTRL ZVAL_STRINGL
+#define PHPC_PZVAL_NEW_STR ZVAL_NEW_STR
+#define PHPC_PZVAL_STR ZVAL_STR
+#define PHPC_PZVAL_CSTR ZVAL_STRING
+#define PHPC_PZVAL_CSTRL ZVAL_STRINGL
+
+#define PHPC_ZVAL_COPY(_zv_dst, _zv_src) \
+ ZVAL_COPY_VALUE(&_zv_dst, &_zv_src)
+
+#define PHPC_ZVAL_NEW_STR PHPC_VAL_NEW_STR
+#define PHPC_ZVAL_STR PHPC_VAL_STR
+#define PHPC_ZVAL_CSTR PHPC_VAL_CSTR
+#define PHPC_ZVAL_CSTRL PHPC_VAL_CSTRL
#define PHPC_ZVAL_IS_TRUE(_zv) \
(Z_TYPE(_zv) == IS_TRUE)
@@ -1313,6 +1418,42 @@
PHPC_OBJ_DEFINE_HANDLER_FCE(HashTable *, _name, get_properties)\
(zval *PHPC_SELF TSRMLS_DC)
+/* object handler setters */
+#define PHPC_CLASS_SET_HANDLER_CREATE(_class_entry, _name) \
+ _class_entry.create_object = PHPC_OBJ_GET_HANDLER_FCE(_name, create)
+#define PHPC_OBJ_SET_SPECIFIC_HANDLER_CLONE(_handlers, _name) \
+ (_handlers).clone_obj = PHPC_OBJ_GET_HANDLER_FCE(_name, clone)
+#define PHPC_OBJ_SET_HANDLER_CLONE(_name) \
+ PHPC_OBJ_SET_SPECIFIC_HANDLER_CLONE(PHPC_OBJ_GET_HANDLER_VAR_NAME(_name), _name)
+#define PHPC_OBJ_SET_HANDLER_COMPARE(_name) \
+ PHPC_OBJ_GET_HANDLER_VAR_NAME(_name).compare_objects = PHPC_OBJ_GET_HANDLER_FCE(_name, compare)
+#define PHPC_OBJ_HAS_HANDLER_GET_GC (PHP_VERSION_ID > 50399)
+#if PHPC_OBJ_HAS_HANDLER_GET_GC
+#define PHPC_OBJ_SET_HANDLER_GET_GC(_name) \
+ PHPC_OBJ_GET_HANDLER_VAR_NAME(_name).get_gc = PHPC_OBJ_GET_HANDLER_FCE(_name, get_gc)
+#else
+#define PHPC_OBJ_SET_HANDLER_GET_GC(_name) PHPC_NOOP
+#endif
+#define PHPC_OBJ_HAS_HANDLER_GET_DEBUG_INFO (PHP_VERSION_ID > 50299)
+#if PHPC_OBJ_HAS_HANDLER_GET_DEBUG_INFO
+#define PHPC_OBJ_SET_HANDLER_GET_DEBUG_INFO(_name) \
+ PHPC_OBJ_GET_HANDLER_VAR_NAME(_name).get_debug_info = PHPC_OBJ_GET_HANDLER_FCE(_name, get_debug_info)
+#else
+#define PHPC_OBJ_SET_HANDLER_GET_DEBUG_INFO(_name) PHPC_NOOP
+#endif
+/* there is such handler in 5.2 but we would have to re-implement zend_std_get_properties */
+#define PHPC_OBJ_HAS_HANDLER_GET_PROPERTIES (PHP_VERSION_ID > 50299)
+#if PHPC_OBJ_HAS_HANDLER_GET_PROPERTIES
+#define PHPC_OBJ_SET_HANDLER_GET_PROPERTIES(_name) \
+ PHPC_OBJ_GET_HANDLER_VAR_NAME(_name).get_properties = PHPC_OBJ_GET_HANDLER_FCE(_name, get_properties)
+#else
+#define PHPC_OBJ_SET_HANDLER_GET_PROPERTIES(_name) PHPC_NOOP
+#endif
+#define PHPC_OBJ_SET_HANDLER_OFFSET(_name) \
+ PHPC_OBJ_SET_SPECIFIC_HANDLER_OFFSET(PHPC_OBJ_GET_HANDLER_VAR_NAME(_name), _name)
+#define PHPC_OBJ_SET_HANDLER_FREE(_name) \
+ PHPC_OBJ_SET_SPECIFIC_HANDLER_FREE(PHPC_OBJ_GET_HANDLER_VAR_NAME(_name), _name)
+
/* hash */
#define PHPC_HASH_ALLOC ALLOC_HASHTABLE
#define PHPC_HASH_INIT zend_hash_init
|