Skip to content

Commit e80ff22

Browse files
committed
PHPC-460: Split PHONGO_CE_INIT macro
This is prep work for enabling serialization for BSON classes.
1 parent 2062a30 commit e80ff22

26 files changed

+58
-33
lines changed

php_phongo.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,19 +177,19 @@ void php_phongo_cursor_free(php_phongo_cursor_t *cursor);
177177
zend_object_iterator* php_phongo_cursor_get_iterator(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC);
178178

179179
#if PHP_VERSION_ID >= 70000
180-
#define PHONGO_CE_INIT(ce) do { \
181-
ce->ce_flags |= ZEND_ACC_FINAL; \
182-
ce->serialize = zend_class_serialize_deny; \
183-
ce->unserialize = zend_class_unserialize_deny; \
180+
#define PHONGO_CE_FINAL(ce) do { \
181+
ce->ce_flags |= ZEND_ACC_FINAL; \
184182
} while(0);
185183
#else
186-
#define PHONGO_CE_INIT(ce) do { \
187-
ce->ce_flags |= ZEND_ACC_FINAL_CLASS; \
188-
ce->serialize = zend_class_serialize_deny; \
189-
ce->unserialize = zend_class_unserialize_deny; \
184+
#define PHONGO_CE_FINAL(ce) do { \
185+
ce->ce_flags |= ZEND_ACC_FINAL_CLASS; \
190186
} while(0);
191187
#endif
192188

189+
#define PHONGO_CE_DISABLE_SERIALIZATION(ce) do { \
190+
ce->serialize = zend_class_serialize_deny; \
191+
ce->unserialize = zend_class_unserialize_deny; \
192+
} while(0);
193193

194194
#ifdef PHP_DEBUG
195195
void _phongo_debug_bson(bson_t *bson);

src/BSON/Binary.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ PHP_MINIT_FUNCTION(Binary)
203203
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Binary", php_phongo_binary_me);
204204
php_phongo_binary_ce = zend_register_internal_class(&ce TSRMLS_CC);
205205
php_phongo_binary_ce->create_object = php_phongo_binary_create_object;
206-
PHONGO_CE_INIT(php_phongo_binary_ce);
206+
PHONGO_CE_FINAL(php_phongo_binary_ce);
207+
PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_binary_ce);
207208

208209
zend_class_implements(php_phongo_binary_ce TSRMLS_CC, 1, php_phongo_type_ce);
209210

src/BSON/Decimal128.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ PHP_MINIT_FUNCTION(Decimal128)
178178
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Decimal128", php_phongo_decimal128_me);
179179
php_phongo_decimal128_ce = zend_register_internal_class(&ce TSRMLS_CC);
180180
php_phongo_decimal128_ce->create_object = php_phongo_decimal128_create_object;
181-
PHONGO_CE_INIT(php_phongo_decimal128_ce);
181+
PHONGO_CE_FINAL(php_phongo_decimal128_ce);
182+
PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_decimal128_ce);
182183

183184
zend_class_implements(php_phongo_decimal128_ce TSRMLS_CC, 1, php_phongo_type_ce);
184185

src/BSON/Javascript.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ PHP_MINIT_FUNCTION(Javascript)
187187
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Javascript", php_phongo_javascript_me);
188188
php_phongo_javascript_ce = zend_register_internal_class(&ce TSRMLS_CC);
189189
php_phongo_javascript_ce->create_object = php_phongo_javascript_create_object;
190-
PHONGO_CE_INIT(php_phongo_javascript_ce);
190+
PHONGO_CE_FINAL(php_phongo_javascript_ce);
191+
PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_javascript_ce);
191192

192193
zend_class_implements(php_phongo_javascript_ce TSRMLS_CC, 1, php_phongo_type_ce);
193194

src/BSON/MaxKey.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ PHP_MINIT_FUNCTION(MaxKey)
103103
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "MaxKey", php_phongo_maxkey_me);
104104
php_phongo_maxkey_ce = zend_register_internal_class(&ce TSRMLS_CC);
105105
php_phongo_maxkey_ce->create_object = php_phongo_maxkey_create_object;
106-
PHONGO_CE_INIT(php_phongo_maxkey_ce);
106+
PHONGO_CE_FINAL(php_phongo_maxkey_ce);
107+
PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_maxkey_ce);
107108

108109
zend_class_implements(php_phongo_maxkey_ce TSRMLS_CC, 1, php_phongo_type_ce);
109110
memcpy(&php_phongo_handler_maxkey, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));

src/BSON/MinKey.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ PHP_MINIT_FUNCTION(MinKey)
104104
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "MinKey", php_phongo_minkey_me);
105105
php_phongo_minkey_ce = zend_register_internal_class(&ce TSRMLS_CC);
106106
php_phongo_minkey_ce->create_object = php_phongo_minkey_create_object;
107-
PHONGO_CE_INIT(php_phongo_minkey_ce);
107+
PHONGO_CE_FINAL(php_phongo_minkey_ce);
108+
PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_minkey_ce);
108109

109110
zend_class_implements(php_phongo_minkey_ce TSRMLS_CC, 1, php_phongo_type_ce);
110111
memcpy(&php_phongo_handler_minkey, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));

src/BSON/ObjectID.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ PHP_MINIT_FUNCTION(ObjectID)
202202
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "ObjectID", php_phongo_objectid_me);
203203
php_phongo_objectid_ce = zend_register_internal_class(&ce TSRMLS_CC);
204204
php_phongo_objectid_ce->create_object = php_phongo_objectid_create_object;
205-
PHONGO_CE_INIT(php_phongo_objectid_ce);
205+
PHONGO_CE_FINAL(php_phongo_objectid_ce);
206+
PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_objectid_ce);
206207

207208
zend_class_implements(php_phongo_objectid_ce TSRMLS_CC, 1, php_phongo_type_ce);
208209

src/BSON/Regex.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ PHP_MINIT_FUNCTION(Regex)
235235
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Regex", php_phongo_regex_me);
236236
php_phongo_regex_ce = zend_register_internal_class(&ce TSRMLS_CC);
237237
php_phongo_regex_ce->create_object = php_phongo_regex_create_object;
238-
PHONGO_CE_INIT(php_phongo_regex_ce);
238+
PHONGO_CE_FINAL(php_phongo_regex_ce);
239+
PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_regex_ce);
239240

240241
zend_class_implements(php_phongo_regex_ce TSRMLS_CC, 1, php_phongo_type_ce);
241242
memcpy(&php_phongo_handler_regex, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));

src/BSON/Timestamp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ PHP_MINIT_FUNCTION(Timestamp)
188188
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Timestamp", php_phongo_timestamp_me);
189189
php_phongo_timestamp_ce = zend_register_internal_class(&ce TSRMLS_CC);
190190
php_phongo_timestamp_ce->create_object = php_phongo_timestamp_create_object;
191-
PHONGO_CE_INIT(php_phongo_timestamp_ce);
191+
PHONGO_CE_FINAL(php_phongo_timestamp_ce);
192+
PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_timestamp_ce);
192193

193194
zend_class_implements(php_phongo_timestamp_ce TSRMLS_CC, 1, php_phongo_type_ce);
194195
memcpy(&php_phongo_handler_timestamp, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));

src/BSON/UTCDateTime.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ PHP_MINIT_FUNCTION(UTCDateTime)
284284
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "UTCDateTime", php_phongo_utcdatetime_me);
285285
php_phongo_utcdatetime_ce = zend_register_internal_class(&ce TSRMLS_CC);
286286
php_phongo_utcdatetime_ce->create_object = php_phongo_utcdatetime_create_object;
287-
PHONGO_CE_INIT(php_phongo_utcdatetime_ce);
287+
PHONGO_CE_FINAL(php_phongo_utcdatetime_ce);
288+
PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_utcdatetime_ce);
288289

289290
zend_class_implements(php_phongo_utcdatetime_ce TSRMLS_CC, 1, php_phongo_type_ce);
290291
memcpy(&php_phongo_handler_utcdatetime, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));

0 commit comments

Comments
 (0)