@@ -61,9 +61,9 @@ ZEND_TSRMLS_CACHE_EXTERN()
61
61
zend_object_handlers * phongo_get_std_object_handlers (void );
62
62
63
63
#define PHONGO_RETURN_PROPS (is_temp , props ) \
64
- if (!(is_temp)) { \
65
- GC_ADDREF(props); \
66
- } \
64
+ if (!(is_temp)) { \
65
+ GC_ADDREF(props); \
66
+ } \
67
67
return props;
68
68
69
69
#define PHONGO_GET_PROPERTY_HASH_INIT_PROPS (is_temp , intern , props , size ) \
@@ -87,81 +87,91 @@ zend_object_handlers* phongo_get_std_object_handlers(void);
87
87
} \
88
88
} while (0)
89
89
90
- #define PHONGO_GET_PROPERTY_HANDLERS (_name , _intern_extractor ) \
91
- static zval* php_phongo_##_name##_read_property(zend_object *zobj, zend_string *member, int type, void **cache_slot, zval *rv) \
92
- { \
93
- HashTable *props = _intern_extractor(zobj)->php_properties; \
94
- if (!props) { \
95
- ALLOC_HASHTABLE(props); \
96
- zend_hash_init(props, 0, NULL, ZVAL_PTR_DTOR, 0); \
97
- _intern_extractor(zobj)->php_properties = props; \
98
- } \
99
- zval *ret = zend_hash_find(props, member); \
100
- if (ret) { \
101
- return ret; \
102
- } \
103
- return &EG(uninitialized_zval); \
104
- } \
105
- \
106
- static zval *php_phongo_##_name##_write_property(zend_object *zobj, zend_string *name, zval *value, void **cache_slot) \
107
- { \
108
- Z_TRY_ADDREF_P(value); \
109
- HashTable *props = _intern_extractor(zobj)->php_properties; \
110
- if (!props) { \
111
- ALLOC_HASHTABLE(props); \
112
- zend_hash_init(props, 0, NULL, ZVAL_PTR_DTOR, 0); \
113
- _intern_extractor(zobj)->php_properties = props; \
114
- } \
115
- return zend_hash_add_new(props, name, value); \
116
- } \
117
- static int php_phongo_##_name##_has_property(zend_object *zobj, zend_string *name, int has_set_exists, void **cache_slot) \
118
- { \
119
- HashTable *props = _intern_extractor(zobj)->php_properties; \
120
- if (!props) { \
121
- ALLOC_HASHTABLE(props); \
122
- zend_hash_init(props, 0, NULL, ZVAL_PTR_DTOR, 0); \
123
- _intern_extractor(zobj)->php_properties = props; \
124
- } \
125
- zval *value = zend_hash_find(props, name); \
126
- if (value) { \
127
- if (has_set_exists == ZEND_PROPERTY_NOT_EMPTY) { \
128
- return zend_is_true(value); \
129
- } \
130
- if (has_set_exists < ZEND_PROPERTY_NOT_EMPTY) { \
131
- ZEND_ASSERT(has_set_exists == ZEND_PROPERTY_ISSET); \
132
- ZVAL_DEREF(value); \
133
- return (Z_TYPE_P(value) != IS_NULL); \
134
- } \
135
- ZEND_ASSERT(has_set_exists == ZEND_PROPERTY_EXISTS); \
136
- return true; \
137
- } \
138
- return false; \
139
- } \
140
- static void php_phongo_##_name##_unset_property(zend_object *zobj, zend_string *name, void **cache_slot) \
141
- { \
142
- HashTable *props = _intern_extractor(zobj)->php_properties; \
143
- if (!props) { \
144
- ALLOC_HASHTABLE(props); \
145
- zend_hash_init(props, 0, NULL, ZVAL_PTR_DTOR, 0); \
146
- _intern_extractor(zobj)->php_properties = props; \
147
- } \
148
- zend_hash_del(props, name); \
149
- } \
150
- \
151
- static zval *php_phongo_##_name##_get_property_ptr_ptr(zend_object *zobj, zend_string *name, int type, void **cache_slot) \
152
- { \
153
- HashTable *props = _intern_extractor(zobj)->php_properties; \
154
- if (!props) { \
155
- ALLOC_HASHTABLE(props); \
156
- zend_hash_init(props, 0, NULL, ZVAL_PTR_DTOR, 0); \
157
- _intern_extractor(zobj)->php_properties = props; \
158
- } \
159
- \
160
- zval *value = zend_hash_find(props, name); \
161
- if (value) { \
162
- return value; \
163
- } \
164
- return zend_hash_add(props, name, &EG(uninitialized_zval)); \
90
+ #define PHONGO_GET_PROPERTY_HANDLERS (_name , _intern_extractor ) \
91
+ PHONGO_GET_PROPERTY_HANDLERS_NO_GC(_name, _intern_extractor) \
92
+ \
93
+ static HashTable* php_phongo_##_name##_get_gc(zend_object* zobj, zval** table, int* n) \
94
+ { \
95
+ *table = NULL; \
96
+ *n = 0; \
97
+ return _intern_extractor(zobj)->php_properties; \
98
+ }
99
+
100
+ #define PHONGO_GET_PROPERTY_HANDLERS_NO_GC (_name , _intern_extractor ) \
101
+ static zval* php_phongo_##_name##_read_property(zend_object* zobj, zend_string* member, int type, void** cache_slot, zval* rv) \
102
+ { \
103
+ HashTable* props = _intern_extractor(zobj)->php_properties; \
104
+ if (!props) { \
105
+ ALLOC_HASHTABLE(props); \
106
+ zend_hash_init(props, 0, NULL, ZVAL_PTR_DTOR, 0); \
107
+ _intern_extractor(zobj)->php_properties = props; \
108
+ } \
109
+ zval* ret = zend_hash_find(props, member); \
110
+ if (ret) { \
111
+ return ret; \
112
+ } \
113
+ return &EG(uninitialized_zval); \
114
+ } \
115
+ \
116
+ static zval* php_phongo_##_name##_write_property(zend_object* zobj, zend_string* name, zval* value, void** cache_slot) \
117
+ { \
118
+ Z_TRY_ADDREF_P(value); \
119
+ HashTable* props = _intern_extractor(zobj)->php_properties; \
120
+ if (!props) { \
121
+ ALLOC_HASHTABLE(props); \
122
+ zend_hash_init(props, 0, NULL, ZVAL_PTR_DTOR, 0); \
123
+ _intern_extractor(zobj)->php_properties = props; \
124
+ } \
125
+ return zend_hash_add_new(props, name, value); \
126
+ } \
127
+ static int php_phongo_##_name##_has_property(zend_object* zobj, zend_string* name, int has_set_exists, void** cache_slot) \
128
+ { \
129
+ HashTable* props = _intern_extractor(zobj)->php_properties; \
130
+ if (!props) { \
131
+ ALLOC_HASHTABLE(props); \
132
+ zend_hash_init(props, 0, NULL, ZVAL_PTR_DTOR, 0); \
133
+ _intern_extractor(zobj)->php_properties = props; \
134
+ } \
135
+ zval* value = zend_hash_find(props, name); \
136
+ if (value) { \
137
+ if (has_set_exists == ZEND_PROPERTY_NOT_EMPTY) { \
138
+ return zend_is_true(value); \
139
+ } \
140
+ if (has_set_exists < ZEND_PROPERTY_NOT_EMPTY) { \
141
+ ZEND_ASSERT(has_set_exists == ZEND_PROPERTY_ISSET); \
142
+ ZVAL_DEREF(value); \
143
+ return (Z_TYPE_P(value) != IS_NULL); \
144
+ } \
145
+ ZEND_ASSERT(has_set_exists == ZEND_PROPERTY_EXISTS); \
146
+ return true; \
147
+ } \
148
+ return false; \
149
+ } \
150
+ static void php_phongo_##_name##_unset_property(zend_object* zobj, zend_string* name, void** cache_slot) \
151
+ { \
152
+ HashTable* props = _intern_extractor(zobj)->php_properties; \
153
+ if (!props) { \
154
+ ALLOC_HASHTABLE(props); \
155
+ zend_hash_init(props, 0, NULL, ZVAL_PTR_DTOR, 0); \
156
+ _intern_extractor(zobj)->php_properties = props; \
157
+ } \
158
+ zend_hash_del(props, name); \
159
+ } \
160
+ \
161
+ static zval* php_phongo_##_name##_get_property_ptr_ptr(zend_object* zobj, zend_string* name, int type, void** cache_slot) \
162
+ { \
163
+ HashTable* props = _intern_extractor(zobj)->php_properties; \
164
+ if (!props) { \
165
+ ALLOC_HASHTABLE(props); \
166
+ zend_hash_init(props, 0, NULL, ZVAL_PTR_DTOR, 0); \
167
+ _intern_extractor(zobj)->php_properties = props; \
168
+ } \
169
+ \
170
+ zval* value = zend_hash_find(props, name); \
171
+ if (value) { \
172
+ return value; \
173
+ } \
174
+ return zend_hash_add(props, name, &EG(uninitialized_zval)); \
165
175
}
166
176
167
177
#define PHONGO_ZVAL_EXCEPTION_NAME (e ) (ZSTR_VAL(e->ce->name))
0 commit comments