Skip to content

Commit 3765861

Browse files
committed
Remove conditional macro definitions
1 parent 20a365f commit 3765861

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+245
-481
lines changed

php_phongo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ static zend_class_entry* php_phongo_fetch_internal_class(const char* class_name,
154154
return NULL;
155155
}
156156

157-
static HashTable* php_phongo_std_get_gc(phongo_compat_object_handler_type* object, zval** table, int* n)
157+
static HashTable* php_phongo_std_get_gc(zend_object* object, zval** table, int* n)
158158
{
159159
*table = NULL;
160160
*n = 0;

src/BSON/Binary.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ static bool php_phongo_binary_init_from_hash(php_phongo_binary_t* intern, HashTa
6565
return false;
6666
}
6767

68-
static HashTable* php_phongo_binary_get_properties_hash(phongo_compat_object_handler_type* object, bool is_temp)
68+
static HashTable* php_phongo_binary_get_properties_hash(zend_object* object, bool is_temp)
6969
{
7070
php_phongo_binary_t* intern;
7171
HashTable* props;
7272

73-
intern = Z_OBJ_BINARY(PHONGO_COMPAT_GET_OBJ(object));
73+
intern = Z_OBJ_BINARY(object);
7474

7575
PHONGO_GET_PROPERTY_HASH_INIT_PROPS(is_temp, intern, props, 2);
7676

@@ -242,7 +242,7 @@ static PHP_METHOD(MongoDB_BSON_Binary, __serialize)
242242
{
243243
PHONGO_PARSE_PARAMETERS_NONE();
244244

245-
RETURN_ARR(php_phongo_binary_get_properties_hash(PHONGO_COMPAT_OBJ_P(getThis()), true));
245+
RETURN_ARR(php_phongo_binary_get_properties_hash(Z_OBJ_P(getThis()), true));
246246
}
247247

248248
static PHP_METHOD(MongoDB_BSON_Binary, __unserialize)
@@ -287,14 +287,14 @@ static zend_object* php_phongo_binary_create_object(zend_class_entry* class_type
287287
return &intern->std;
288288
}
289289

290-
static zend_object* php_phongo_binary_clone_object(phongo_compat_object_handler_type* object)
290+
static zend_object* php_phongo_binary_clone_object(zend_object* object)
291291
{
292292
php_phongo_binary_t* intern;
293293
php_phongo_binary_t* new_intern;
294294
zend_object* new_object;
295295

296-
intern = Z_OBJ_BINARY(PHONGO_COMPAT_GET_OBJ(object));
297-
new_object = php_phongo_binary_create_object(PHONGO_COMPAT_GET_OBJ(object)->ce);
296+
intern = Z_OBJ_BINARY(object);
297+
new_object = php_phongo_binary_create_object(object->ce);
298298

299299
new_intern = Z_OBJ_BINARY(new_object);
300300
zend_objects_clone_members(&new_intern->std, &intern->std);
@@ -326,13 +326,13 @@ static int php_phongo_binary_compare_objects(zval* o1, zval* o2)
326326
return zend_binary_strcmp(intern1->data, intern1->data_len, intern2->data, intern2->data_len);
327327
}
328328

329-
static HashTable* php_phongo_binary_get_debug_info(phongo_compat_object_handler_type* object, int* is_temp)
329+
static HashTable* php_phongo_binary_get_debug_info(zend_object* object, int* is_temp)
330330
{
331331
*is_temp = 1;
332332
return php_phongo_binary_get_properties_hash(object, true);
333333
}
334334

335-
static HashTable* php_phongo_binary_get_properties(phongo_compat_object_handler_type* object)
335+
static HashTable* php_phongo_binary_get_properties(zend_object* object)
336336
{
337337
return php_phongo_binary_get_properties_hash(object, false);
338338
}
@@ -347,7 +347,7 @@ void php_phongo_binary_init_ce(INIT_FUNC_ARGS)
347347
#endif
348348

349349
memcpy(&php_phongo_handler_binary, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
350-
PHONGO_COMPAT_SET_COMPARE_OBJECTS_HANDLER(binary);
350+
php_phongo_handler_binary.compare = php_phongo_binary_compare_objects;
351351
php_phongo_handler_binary.clone_obj = php_phongo_binary_clone_object;
352352
php_phongo_handler_binary.get_debug_info = php_phongo_binary_get_debug_info;
353353
php_phongo_handler_binary.get_properties = php_phongo_binary_get_properties;

src/BSON/DBPointer.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ static bool php_phongo_dbpointer_init_from_hash(php_phongo_dbpointer_t* intern,
6666
return false;
6767
}
6868

69-
HashTable* php_phongo_dbpointer_get_properties_hash(phongo_compat_object_handler_type* object, bool is_temp)
69+
HashTable* php_phongo_dbpointer_get_properties_hash(zend_object* object, bool is_temp)
7070
{
7171
php_phongo_dbpointer_t* intern;
7272
HashTable* props;
7373

74-
intern = Z_OBJ_DBPOINTER(PHONGO_COMPAT_GET_OBJ(object));
74+
intern = Z_OBJ_DBPOINTER(object);
7575

7676
PHONGO_GET_PROPERTY_HASH_INIT_PROPS(is_temp, intern, props, 2);
7777

@@ -205,7 +205,7 @@ static PHP_METHOD(MongoDB_BSON_DBPointer, __serialize)
205205
{
206206
PHONGO_PARSE_PARAMETERS_NONE();
207207

208-
RETURN_ARR(php_phongo_dbpointer_get_properties_hash(PHONGO_COMPAT_OBJ_P(getThis()), true));
208+
RETURN_ARR(php_phongo_dbpointer_get_properties_hash(Z_OBJ_P(getThis()), true));
209209
}
210210

211211
static PHP_METHOD(MongoDB_BSON_DBPointer, __unserialize)
@@ -250,14 +250,14 @@ zend_object* php_phongo_dbpointer_create_object(zend_class_entry* class_type)
250250
return &intern->std;
251251
}
252252

253-
static zend_object* php_phongo_dbpointer_clone_object(phongo_compat_object_handler_type* object)
253+
static zend_object* php_phongo_dbpointer_clone_object(zend_object* object)
254254
{
255255
php_phongo_dbpointer_t* intern;
256256
php_phongo_dbpointer_t* new_intern;
257257
zend_object* new_object;
258258

259-
intern = Z_OBJ_DBPOINTER(PHONGO_COMPAT_GET_OBJ(object));
260-
new_object = php_phongo_dbpointer_create_object(PHONGO_COMPAT_GET_OBJ(object)->ce);
259+
intern = Z_OBJ_DBPOINTER(object);
260+
new_object = php_phongo_dbpointer_create_object(object->ce);
261261

262262
new_intern = Z_OBJ_DBPOINTER(new_object);
263263
zend_objects_clone_members(&new_intern->std, &intern->std);
@@ -286,13 +286,13 @@ static int php_phongo_dbpointer_compare_objects(zval* o1, zval* o2)
286286
return strcmp(intern1->id, intern2->id);
287287
}
288288

289-
static HashTable* php_phongo_dbpointer_get_debug_info(phongo_compat_object_handler_type* object, int* is_temp)
289+
static HashTable* php_phongo_dbpointer_get_debug_info(zend_object* object, int* is_temp)
290290
{
291291
*is_temp = 1;
292292
return php_phongo_dbpointer_get_properties_hash(object, true);
293293
}
294294

295-
static HashTable* php_phongo_dbpointer_get_properties(phongo_compat_object_handler_type* object)
295+
static HashTable* php_phongo_dbpointer_get_properties(zend_object* object)
296296
{
297297
return php_phongo_dbpointer_get_properties_hash(object, false);
298298
}
@@ -307,7 +307,7 @@ void php_phongo_dbpointer_init_ce(INIT_FUNC_ARGS)
307307
#endif
308308

309309
memcpy(&php_phongo_handler_dbpointer, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
310-
PHONGO_COMPAT_SET_COMPARE_OBJECTS_HANDLER(dbpointer);
310+
php_phongo_handler_dbpointer.compare = php_phongo_dbpointer_compare_objects;
311311
php_phongo_handler_dbpointer.clone_obj = php_phongo_dbpointer_clone_object;
312312
php_phongo_handler_dbpointer.get_debug_info = php_phongo_dbpointer_get_debug_info;
313313
php_phongo_handler_dbpointer.get_properties = php_phongo_dbpointer_get_properties;

src/BSON/Decimal128.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ static bool php_phongo_decimal128_init_from_hash(php_phongo_decimal128_t* intern
5555
return false;
5656
}
5757

58-
static HashTable* php_phongo_decimal128_get_properties_hash(phongo_compat_object_handler_type* object, bool is_temp)
58+
static HashTable* php_phongo_decimal128_get_properties_hash(zend_object* object, bool is_temp)
5959
{
6060
php_phongo_decimal128_t* intern;
6161
HashTable* props;
6262
char outbuf[BSON_DECIMAL128_STRING] = "";
6363

64-
intern = Z_OBJ_DECIMAL128(PHONGO_COMPAT_GET_OBJ(object));
64+
intern = Z_OBJ_DECIMAL128(object);
6565

6666
PHONGO_GET_PROPERTY_HASH_INIT_PROPS(is_temp, intern, props, 1);
6767

@@ -202,7 +202,7 @@ static PHP_METHOD(MongoDB_BSON_Decimal128, __serialize)
202202
{
203203
PHONGO_PARSE_PARAMETERS_NONE();
204204

205-
RETURN_ARR(php_phongo_decimal128_get_properties_hash(PHONGO_COMPAT_OBJ_P(getThis()), true));
205+
RETURN_ARR(php_phongo_decimal128_get_properties_hash(Z_OBJ_P(getThis()), true));
206206
}
207207

208208
static PHP_METHOD(MongoDB_BSON_Decimal128, __unserialize)
@@ -243,14 +243,14 @@ static zend_object* php_phongo_decimal128_create_object(zend_class_entry* class_
243243
return &intern->std;
244244
}
245245

246-
static zend_object* php_phongo_decimal128_clone_object(phongo_compat_object_handler_type* object)
246+
static zend_object* php_phongo_decimal128_clone_object(zend_object* object)
247247
{
248248
php_phongo_decimal128_t* intern;
249249
php_phongo_decimal128_t* new_intern;
250250
zend_object* new_object;
251251

252-
intern = Z_OBJ_DECIMAL128(PHONGO_COMPAT_GET_OBJ(object));
253-
new_object = php_phongo_decimal128_create_object(PHONGO_COMPAT_GET_OBJ(object)->ce);
252+
intern = Z_OBJ_DECIMAL128(object);
253+
new_object = php_phongo_decimal128_create_object(object->ce);
254254

255255
new_intern = Z_OBJ_DECIMAL128(new_object);
256256
zend_objects_clone_members(&new_intern->std, &intern->std);
@@ -262,13 +262,13 @@ static zend_object* php_phongo_decimal128_clone_object(phongo_compat_object_hand
262262
return new_object;
263263
}
264264

265-
static HashTable* php_phongo_decimal128_get_debug_info(phongo_compat_object_handler_type* object, int* is_temp)
265+
static HashTable* php_phongo_decimal128_get_debug_info(zend_object* object, int* is_temp)
266266
{
267267
*is_temp = 1;
268268
return php_phongo_decimal128_get_properties_hash(object, true);
269269
}
270270

271-
static HashTable* php_phongo_decimal128_get_properties(phongo_compat_object_handler_type* object)
271+
static HashTable* php_phongo_decimal128_get_properties(zend_object* object)
272272
{
273273
return php_phongo_decimal128_get_properties_hash(object, false);
274274
}

src/BSON/Document.c

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ static bool php_phongo_document_init_from_hash(php_phongo_document_t* intern, Ha
5858
return false;
5959
}
6060

61-
static HashTable* php_phongo_document_get_properties_hash(phongo_compat_object_handler_type* object, bool is_temp, int size)
61+
static HashTable* php_phongo_document_get_properties_hash(zend_object* object, bool is_temp, int size)
6262
{
6363
php_phongo_document_t* intern;
6464
HashTable* props;
6565

66-
intern = Z_OBJ_DOCUMENT(PHONGO_COMPAT_GET_OBJ(object));
66+
intern = Z_OBJ_DOCUMENT(object);
6767

6868
PHONGO_GET_PROPERTY_HASH_INIT_PROPS(is_temp, intern, props, size);
6969

@@ -435,7 +435,7 @@ static PHP_METHOD(MongoDB_BSON_Document, __serialize)
435435
{
436436
PHONGO_PARSE_PARAMETERS_NONE();
437437

438-
RETURN_ARR(php_phongo_document_get_properties_hash(PHONGO_COMPAT_OBJ_P(getThis()), true, 1));
438+
RETURN_ARR(php_phongo_document_get_properties_hash(Z_OBJ_P(getThis()), true, 1));
439439
}
440440

441441
static PHP_METHOD(MongoDB_BSON_Document, __unserialize)
@@ -480,14 +480,14 @@ static zend_object* php_phongo_document_create_object(zend_class_entry* class_ty
480480
return &intern->std;
481481
}
482482

483-
static zend_object* php_phongo_document_clone_object(phongo_compat_object_handler_type* object)
483+
static zend_object* php_phongo_document_clone_object(zend_object* object)
484484
{
485485
php_phongo_document_t* intern;
486486
php_phongo_document_t* new_intern;
487487
zend_object* new_object;
488488

489-
intern = Z_OBJ_DOCUMENT(PHONGO_COMPAT_GET_OBJ(object));
490-
new_object = php_phongo_document_create_object(PHONGO_COMPAT_GET_OBJ(object)->ce);
489+
intern = Z_OBJ_DOCUMENT(object);
490+
new_object = php_phongo_document_create_object(object->ce);
491491

492492
new_intern = Z_OBJ_DOCUMENT(new_object);
493493
zend_objects_clone_members(&new_intern->std, &intern->std);
@@ -509,13 +509,13 @@ static int php_phongo_document_compare_objects(zval* o1, zval* o2)
509509
return bson_compare(intern1->bson, intern2->bson);
510510
}
511511

512-
static HashTable* php_phongo_document_get_debug_info(phongo_compat_object_handler_type* object, int* is_temp)
512+
static HashTable* php_phongo_document_get_debug_info(zend_object* object, int* is_temp)
513513
{
514514
php_phongo_document_t* intern;
515515
HashTable* props;
516516

517517
*is_temp = 1;
518-
intern = Z_OBJ_DOCUMENT(PHONGO_COMPAT_GET_OBJ(object));
518+
intern = Z_OBJ_DOCUMENT(object);
519519

520520
/* This get_debug_info handler reports an additional property. This does not
521521
* conflict with other uses of php_phongo_document_get_properties_hash since
@@ -543,20 +543,18 @@ static HashTable* php_phongo_document_get_debug_info(phongo_compat_object_handle
543543
return NULL;
544544
}
545545

546-
static HashTable* php_phongo_document_get_properties(phongo_compat_object_handler_type* object)
546+
static HashTable* php_phongo_document_get_properties(zend_object* object)
547547
{
548548
return php_phongo_document_get_properties_hash(object, false, 1);
549549
}
550550

551-
zval* php_phongo_document_read_property(phongo_compat_object_handler_type* object, phongo_compat_property_accessor_name_type* member, int type, void** cache_slot, zval* rv)
551+
zval* php_phongo_document_read_property(zend_object* object, zend_string* member, int type, void** cache_slot, zval* rv)
552552
{
553553
php_phongo_document_t* intern;
554-
char* key;
555-
size_t key_len;
556-
557-
intern = Z_OBJ_DOCUMENT(PHONGO_COMPAT_GET_OBJ(object));
554+
char* key = ZSTR_VAL(member);
555+
size_t key_len = ZSTR_LEN(member);
558556

559-
PHONGO_COMPAT_PROPERTY_ACCESSOR_NAME_TO_STRING(member, key, key_len);
557+
intern = Z_OBJ_DOCUMENT(object);
560558

561559
if (!php_phongo_document_get(intern, key, key_len, rv, type == BP_VAR_IS)) {
562560
// Exception already thrown
@@ -566,35 +564,33 @@ zval* php_phongo_document_read_property(phongo_compat_object_handler_type* objec
566564
return rv;
567565
}
568566

569-
zval* php_phongo_document_write_property(phongo_compat_object_handler_type* object, phongo_compat_property_accessor_name_type* member, zval* value, void** cache_slot)
567+
zval* php_phongo_document_write_property(zend_object* object, zend_string* member, zval* value, void** cache_slot)
570568
{
571569
phongo_throw_exception(PHONGO_ERROR_LOGIC, "Cannot write to %s property", ZSTR_VAL(php_phongo_document_ce->name));
572570
return value;
573571
}
574572

575-
int php_phongo_document_has_property(phongo_compat_object_handler_type* object, phongo_compat_property_accessor_name_type* name, int has_set_exists, void** cache_slot)
573+
int php_phongo_document_has_property(zend_object* object, zend_string* name, int has_set_exists, void** cache_slot)
576574
{
577575
php_phongo_document_t* intern;
578-
char* key;
579-
size_t key_len;
580-
581-
intern = Z_OBJ_DOCUMENT(PHONGO_COMPAT_GET_OBJ(object));
576+
char* key = ZSTR_VAL(name);
577+
size_t key_len = ZSTR_LEN(name);
582578

583-
PHONGO_COMPAT_PROPERTY_ACCESSOR_NAME_TO_STRING(name, key, key_len);
579+
intern = Z_OBJ_DOCUMENT(object);
584580

585581
return php_phongo_document_has(intern, key, key_len);
586582
}
587583

588-
void php_phongo_document_unset_property(phongo_compat_object_handler_type* object, phongo_compat_property_accessor_name_type* member, void** cache_slot)
584+
void php_phongo_document_unset_property(zend_object* object, zend_string* member, void** cache_slot)
589585
{
590586
phongo_throw_exception(PHONGO_ERROR_LOGIC, "Cannot unset %s property", ZSTR_VAL(php_phongo_document_ce->name));
591587
}
592588

593-
zval* php_phongo_document_read_dimension(phongo_compat_object_handler_type* object, zval* offset, int type, zval* rv)
589+
zval* php_phongo_document_read_dimension(zend_object* object, zval* offset, int type, zval* rv)
594590
{
595591
php_phongo_document_t* intern;
596592

597-
intern = Z_OBJ_DOCUMENT(PHONGO_COMPAT_GET_OBJ(object));
593+
intern = Z_OBJ_DOCUMENT(object);
598594

599595
if (Z_TYPE_P(offset) != IS_STRING) {
600596
if (type == BP_VAR_IS) {
@@ -614,16 +610,16 @@ zval* php_phongo_document_read_dimension(phongo_compat_object_handler_type* obje
614610
return rv;
615611
}
616612

617-
void php_phongo_document_write_dimension(phongo_compat_object_handler_type* object, zval* offset, zval* value)
613+
void php_phongo_document_write_dimension(zend_object* object, zval* offset, zval* value)
618614
{
619615
phongo_throw_exception(PHONGO_ERROR_LOGIC, "Cannot write to %s property", ZSTR_VAL(php_phongo_document_ce->name));
620616
}
621617

622-
int php_phongo_document_has_dimension(phongo_compat_object_handler_type* object, zval* member, int check_empty)
618+
int php_phongo_document_has_dimension(zend_object* object, zval* member, int check_empty)
623619
{
624620
php_phongo_document_t* intern;
625621

626-
intern = Z_OBJ_DOCUMENT(PHONGO_COMPAT_GET_OBJ(object));
622+
intern = Z_OBJ_DOCUMENT(object);
627623

628624
if (Z_TYPE_P(member) != IS_STRING) {
629625
return false;
@@ -632,7 +628,7 @@ int php_phongo_document_has_dimension(phongo_compat_object_handler_type* object,
632628
return php_phongo_document_has(intern, Z_STRVAL_P(member), Z_STRLEN_P(member));
633629
}
634630

635-
void php_phongo_document_unset_dimension(phongo_compat_object_handler_type* object, zval* offset)
631+
void php_phongo_document_unset_dimension(zend_object* object, zval* offset)
636632
{
637633
phongo_throw_exception(PHONGO_ERROR_LOGIC, "Cannot unset %s property", ZSTR_VAL(php_phongo_document_ce->name));
638634
}
@@ -647,7 +643,7 @@ void php_phongo_document_init_ce(INIT_FUNC_ARGS)
647643
#endif
648644

649645
memcpy(&php_phongo_handler_document, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
650-
PHONGO_COMPAT_SET_COMPARE_OBJECTS_HANDLER(document);
646+
php_phongo_handler_document.compare = php_phongo_document_compare_objects;
651647
php_phongo_handler_document.clone_obj = php_phongo_document_clone_object;
652648
php_phongo_handler_document.get_debug_info = php_phongo_document_get_debug_info;
653649
php_phongo_handler_document.get_properties = php_phongo_document_get_properties;

0 commit comments

Comments
 (0)