@@ -61,28 +61,28 @@ ZEND_TSRMLS_CACHE_EXTERN()
6161zend_object_handlers * phongo_get_std_object_handlers (void );
6262
6363#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+ } \
6767 return props;
6868
69- #define PHONGO_GET_PROPERTY_HASH_INIT_PROPS (is_temp , intern , props , size ) \
70- do { \
71- if (!(intern)->php_properties) { \
72- ALLOC_HASHTABLE((intern)->php_properties); \
69+ #define PHONGO_GET_PROPERTY_HASH_INIT_PROPS (is_temp , intern , props , size ) \
70+ do { \
71+ if (!(intern)->php_properties) { \
72+ ALLOC_HASHTABLE((intern)->php_properties); \
7373 zend_hash_init((intern)->php_properties, 0, NULL, ZVAL_PTR_DTOR, 0); \
74- } \
75- if (is_temp) { \
76- (props) = zend_array_dup((intern)->php_properties); \
77- } else { \
78- (props) = zend_array_dup((intern)->php_properties); \
79- if ((intern)->properties) { \
80- HashTable * __tmp = (intern)->properties; \
81- (intern)->properties = NULL; \
82- zend_hash_release(__tmp); \
83- } \
84- (intern)->properties = (props); \
85- } \
74+ } \
75+ if (is_temp) { \
76+ (props) = zend_array_dup((intern)->php_properties); \
77+ } else { \
78+ (props) = zend_array_dup((intern)->php_properties); \
79+ if ((intern)->properties) { \
80+ HashTable* __tmp = (intern)->properties; \
81+ (intern)->properties = NULL; \
82+ zend_hash_release(__tmp); \
83+ } \
84+ (intern)->properties = (props); \
85+ } \
8686 } while (0)
8787
8888#define PHONGO_GET_PROPERTY_HASH_FREE_PROPS (is_temp , props ) \
@@ -92,87 +92,87 @@ zend_object_handlers* phongo_get_std_object_handlers(void);
9292 } \
9393 } while (0)
9494
95- #define PHONGO_GET_PROPERTY_HANDLERS (_name , _intern_extractor ) \
96- PHONGO_GET_PROPERTY_HANDLERS_NO_GC(_name, _intern_extractor) \
97- \
95+ #define PHONGO_GET_PROPERTY_HANDLERS (_name , _intern_extractor ) \
96+ PHONGO_GET_PROPERTY_HANDLERS_NO_GC(_name, _intern_extractor) \
97+ \
9898 static HashTable* php_phongo_##_name##_get_gc(zend_object* zobj, zval** table, int* n) \
99- { \
100- *table = NULL; \
101- *n = 0; \
102- return _intern_extractor(zobj)->php_properties; \
99+ { \
100+ *table = NULL; \
101+ *n = 0; \
102+ return _intern_extractor(zobj)->php_properties; \
103103 }
104104
105- #define PHONGO_GET_PROPERTY_HANDLERS_NO_GC (_name , _intern_extractor ) \
106- static zval* php_phongo_##_name##_read_property(zend_object * zobj, zend_string * member, int type, void ** cache_slot, zval * rv) \
107- { \
108- HashTable * props = _intern_extractor(zobj)->php_properties; \
109- if (!props) { \
110- ALLOC_HASHTABLE(props); \
111- zend_hash_init(props, 0, NULL, ZVAL_PTR_DTOR, 0); \
112- _intern_extractor(zobj)->php_properties = props; \
113- } \
114- return zend_hash_find(props, member); \
115- } \
116- \
117- static zval * php_phongo_##_name##_write_property(zend_object * zobj, zend_string * name, zval * value, void ** cache_slot) \
118- { \
119- Z_TRY_ADDREF_P(value); \
120- HashTable * props = _intern_extractor(zobj)->php_properties; \
121- if (!props) { \
122- ALLOC_HASHTABLE(props); \
123- zend_hash_init(props, 0, NULL, ZVAL_PTR_DTOR, 0); \
124- _intern_extractor(zobj)->php_properties = props; \
125- } \
126- return zend_hash_add_new(props, name, value); \
127- } \
128- static int php_phongo_##_name##_has_property(zend_object * zobj, zend_string * name, int has_set_exists, void ** cache_slot) \
129- { \
130- HashTable * props = _intern_extractor(zobj)->php_properties; \
131- if (!props) { \
132- ALLOC_HASHTABLE(props); \
133- zend_hash_init(props, 0, NULL, ZVAL_PTR_DTOR, 0); \
134- _intern_extractor(zobj)->php_properties = props; \
135- } \
136- zval * value = zend_hash_find(props, name); \
137- if (value) { \
138- if (has_set_exists == ZEND_PROPERTY_NOT_EMPTY) { \
139- return zend_is_true(value); \
140- } \
141- if (has_set_exists < ZEND_PROPERTY_NOT_EMPTY) { \
142- ZEND_ASSERT(has_set_exists == ZEND_PROPERTY_ISSET); \
143- ZVAL_DEREF(value); \
144- return (Z_TYPE_P(value) != IS_NULL); \
145- } \
146- ZEND_ASSERT(has_set_exists == ZEND_PROPERTY_EXISTS); \
147- return true; \
148- } \
149- return false; \
150- } \
151- static void php_phongo_##_name##_unset_property(zend_object * zobj, zend_string * name, 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- zend_hash_del(props, name); \
160- } \
161- \
162- static zval * php_phongo_##_name##_get_property_ptr_ptr(zend_object * zobj, zend_string * name, int type, void ** cache_slot) \
163- { \
164- HashTable * props = _intern_extractor(zobj)->php_properties; \
165- if (!props) { \
166- ALLOC_HASHTABLE(props); \
167- zend_hash_init(props, 0, NULL, ZVAL_PTR_DTOR, 0); \
168- _intern_extractor(zobj)->php_properties = props; \
169- } \
170- \
171- zval * value = zend_hash_find(props, name); \
172- if (value) { \
173- return value; \
174- } \
175- return zend_hash_add(props, name, &EG(uninitialized_zval)); \
105+ #define PHONGO_GET_PROPERTY_HANDLERS_NO_GC (_name , _intern_extractor ) \
106+ static zval* php_phongo_##_name##_read_property(zend_object* zobj, zend_string* member, int type, void** cache_slot, zval* rv) \
107+ { \
108+ HashTable* props = _intern_extractor(zobj)->php_properties; \
109+ if (!props) { \
110+ ALLOC_HASHTABLE(props); \
111+ zend_hash_init(props, 0, NULL, ZVAL_PTR_DTOR, 0); \
112+ _intern_extractor(zobj)->php_properties = props; \
113+ } \
114+ return zend_hash_find(props, member); \
115+ } \
116+ \
117+ static zval* php_phongo_##_name##_write_property(zend_object* zobj, zend_string* name, zval* value, void** cache_slot) \
118+ { \
119+ Z_TRY_ADDREF_P(value); \
120+ HashTable* props = _intern_extractor(zobj)->php_properties; \
121+ if (!props) { \
122+ ALLOC_HASHTABLE(props); \
123+ zend_hash_init(props, 0, NULL, ZVAL_PTR_DTOR, 0); \
124+ _intern_extractor(zobj)->php_properties = props; \
125+ } \
126+ return zend_hash_add_new(props, name, value); \
127+ } \
128+ static int php_phongo_##_name##_has_property(zend_object* zobj, zend_string* name, int has_set_exists, void** cache_slot) \
129+ { \
130+ HashTable* props = _intern_extractor(zobj)->php_properties; \
131+ if (!props) { \
132+ ALLOC_HASHTABLE(props); \
133+ zend_hash_init(props, 0, NULL, ZVAL_PTR_DTOR, 0); \
134+ _intern_extractor(zobj)->php_properties = props; \
135+ } \
136+ zval* value = zend_hash_find(props, name); \
137+ if (value) { \
138+ if (has_set_exists == ZEND_PROPERTY_NOT_EMPTY) { \
139+ return zend_is_true(value); \
140+ } \
141+ if (has_set_exists < ZEND_PROPERTY_NOT_EMPTY) { \
142+ ZEND_ASSERT(has_set_exists == ZEND_PROPERTY_ISSET); \
143+ ZVAL_DEREF(value); \
144+ return (Z_TYPE_P(value) != IS_NULL); \
145+ } \
146+ ZEND_ASSERT(has_set_exists == ZEND_PROPERTY_EXISTS); \
147+ return true; \
148+ } \
149+ return false; \
150+ } \
151+ static void php_phongo_##_name##_unset_property(zend_object* zobj, zend_string* name, 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+ zend_hash_del(props, name); \
160+ } \
161+ \
162+ static zval* php_phongo_##_name##_get_property_ptr_ptr(zend_object* zobj, zend_string* name, int type, void** cache_slot) \
163+ { \
164+ HashTable* props = _intern_extractor(zobj)->php_properties; \
165+ if (!props) { \
166+ ALLOC_HASHTABLE(props); \
167+ zend_hash_init(props, 0, NULL, ZVAL_PTR_DTOR, 0); \
168+ _intern_extractor(zobj)->php_properties = props; \
169+ } \
170+ \
171+ zval* value = zend_hash_find(props, name); \
172+ if (value) { \
173+ return value; \
174+ } \
175+ return zend_hash_add(props, name, &EG(uninitialized_zval)); \
176176 }
177177
178178#define PHONGO_ZVAL_EXCEPTION_NAME (e ) (ZSTR_VAL(e->ce->name))
0 commit comments