@@ -747,19 +747,19 @@ static php_phongo_field_path_map_element* map_find_field_path_entry(php_phongo_b
747
747
return NULL ;
748
748
}
749
749
750
- static void php_phongo_handle_field_path_entry_for_compound_type (php_phongo_bson_state * state , php_phongo_bson_typemap_types * type , zend_class_entry * * ce )
750
+ static void php_phongo_handle_field_path_entry_for_compound_type (php_phongo_bson_state * state , php_phongo_bson_typemap_element * element )
751
751
{
752
752
php_phongo_field_path_map_element * entry = map_find_field_path_entry (state );
753
753
754
754
if (entry ) {
755
- switch (entry -> node_type ) {
755
+ switch (entry -> node . type ) {
756
756
case PHONGO_TYPEMAP_NATIVE_ARRAY :
757
757
case PHONGO_TYPEMAP_NATIVE_OBJECT :
758
- * type = entry -> node_type ;
758
+ element -> type = entry -> node . type ;
759
759
break ;
760
760
case PHONGO_TYPEMAP_CLASS :
761
- * type = entry -> node_type ;
762
- * ce = entry -> node_ce ;
761
+ element -> type = entry -> node . type ;
762
+ element -> class = entry -> node . class ;
763
763
break ;
764
764
default :
765
765
/* Do nothing - pacify compiler */
@@ -836,15 +836,15 @@ static bool php_phongo_bson_visit_document(const bson_iter_t* iter ARG_UNUSED, c
836
836
if (!bson_iter_visit_all (& child , & php_bson_visitors , & state ) && !child .err_off ) {
837
837
/* Check for entries in the fieldPath type map key, and use them to
838
838
* override the default ones for this type */
839
- php_phongo_handle_field_path_entry_for_compound_type (& state , & state .map .document_type , & state . map . document );
839
+ php_phongo_handle_field_path_entry_for_compound_type (& state , & state .map .document );
840
840
841
841
/* If php_phongo_bson_visit_binary() finds an ODM class, it should
842
842
* supersede a default type map and named document class. */
843
- if (state .odm && state .map .document_type == PHONGO_TYPEMAP_NONE ) {
844
- state .map .document_type = PHONGO_TYPEMAP_CLASS ;
843
+ if (state .odm && state .map .document . type == PHONGO_TYPEMAP_NONE ) {
844
+ state .map .document . type = PHONGO_TYPEMAP_CLASS ;
845
845
}
846
846
847
- switch (state .map .document_type ) {
847
+ switch (state .map .document . type ) {
848
848
case PHONGO_TYPEMAP_NATIVE_ARRAY :
849
849
if (((php_phongo_bson_state * ) data )-> is_visiting_array ) {
850
850
add_next_index_zval (retval , & state .zchild );
@@ -855,7 +855,7 @@ static bool php_phongo_bson_visit_document(const bson_iter_t* iter ARG_UNUSED, c
855
855
856
856
case PHONGO_TYPEMAP_CLASS : {
857
857
zval obj ;
858
- zend_class_entry * obj_ce = state .odm ? state .odm : state .map .document ;
858
+ zend_class_entry * obj_ce = state .odm ? state .odm : state .map .document . class ;
859
859
860
860
#if PHP_VERSION_ID >= 80100
861
861
/* Enums require special handling for instantiation */
@@ -959,13 +959,13 @@ static bool php_phongo_bson_visit_array(const bson_iter_t* iter ARG_UNUSED, cons
959
959
if (!bson_iter_visit_all (& child , & php_bson_visitors , & state ) && !child .err_off ) {
960
960
/* Check for entries in the fieldPath type map key, and use them to
961
961
* override the default ones for this type */
962
- php_phongo_handle_field_path_entry_for_compound_type (& state , & state .map .array_type , & state . map . array );
962
+ php_phongo_handle_field_path_entry_for_compound_type (& state , & state .map .array );
963
963
964
- switch (state .map .array_type ) {
964
+ switch (state .map .array . type ) {
965
965
case PHONGO_TYPEMAP_CLASS : {
966
966
zval obj ;
967
967
968
- object_init_ex (& obj , state .map .array );
968
+ object_init_ex (& obj , state .map .array . class );
969
969
zend_call_method_with_1_params (PHONGO_COMPAT_OBJ_P (& obj ), NULL , NULL , BSON_UNSERIALIZE_FUNC_NAME , NULL , & state .zchild );
970
970
if (((php_phongo_bson_state * ) data )-> is_visiting_array ) {
971
971
add_next_index_zval (retval , & obj );
@@ -1047,7 +1047,7 @@ bool php_phongo_bson_value_to_zval(const bson_value_t* value, zval* zv)
1047
1047
bool retval = false;
1048
1048
1049
1049
PHONGO_BSON_INIT_STATE (state );
1050
- state .map .root_type = PHONGO_TYPEMAP_NATIVE_ARRAY ;
1050
+ state .map .root . type = PHONGO_TYPEMAP_NATIVE_ARRAY ;
1051
1051
1052
1052
bson_append_value (& bson , "data" , 4 , value );
1053
1053
if (!php_phongo_bson_to_zval_ex (& bson , & state )) {
@@ -1119,18 +1119,18 @@ bool php_phongo_bson_to_zval_ex(const bson_t* b, php_phongo_bson_state* state)
1119
1119
1120
1120
/* If php_phongo_bson_visit_binary() finds an ODM class, it should supersede
1121
1121
* a default type map and named root class. */
1122
- if (state -> odm && state -> map .root_type == PHONGO_TYPEMAP_NONE ) {
1123
- state -> map .root_type = PHONGO_TYPEMAP_CLASS ;
1122
+ if (state -> odm && state -> map .root . type == PHONGO_TYPEMAP_NONE ) {
1123
+ state -> map .root . type = PHONGO_TYPEMAP_CLASS ;
1124
1124
}
1125
1125
1126
- switch (state -> map .root_type ) {
1126
+ switch (state -> map .root . type ) {
1127
1127
case PHONGO_TYPEMAP_NATIVE_ARRAY :
1128
1128
/* Nothing to do here */
1129
1129
break ;
1130
1130
1131
1131
case PHONGO_TYPEMAP_CLASS : {
1132
1132
zval obj ;
1133
- zend_class_entry * obj_ce = state -> odm ? state -> odm : state -> map .root ;
1133
+ zend_class_entry * obj_ce = state -> odm ? state -> odm : state -> map .root . class ;
1134
1134
1135
1135
#if PHP_VERSION_ID >= 80100
1136
1136
/* Enums require special handling for instantiation */
@@ -1258,7 +1258,7 @@ static zend_class_entry* php_phongo_bson_state_fetch_class(const char* classname
1258
1258
/* Parses a BSON type (i.e. array, document, or root). On success, the type and
1259
1259
* type_ce output arguments will be assigned and true will be returned;
1260
1260
* otherwise, false is returned and an exception is thrown. */
1261
- static bool php_phongo_bson_state_parse_type (zval * options , const char * name , php_phongo_bson_typemap_types * type , zend_class_entry * * type_ce )
1261
+ static bool php_phongo_bson_state_parse_type (zval * options , const char * name , php_phongo_bson_typemap_element * element )
1262
1262
{
1263
1263
char * classname ;
1264
1264
int classname_len ;
@@ -1272,14 +1272,14 @@ static bool php_phongo_bson_state_parse_type(zval* options, const char* name, ph
1272
1272
}
1273
1273
1274
1274
if (!strcasecmp (classname , "array" )) {
1275
- * type = PHONGO_TYPEMAP_NATIVE_ARRAY ;
1276
- * type_ce = NULL ;
1275
+ element -> type = PHONGO_TYPEMAP_NATIVE_ARRAY ;
1276
+ element -> class = NULL ;
1277
1277
} else if (!strcasecmp (classname , "stdclass" ) || !strcasecmp (classname , "object" )) {
1278
- * type = PHONGO_TYPEMAP_NATIVE_OBJECT ;
1279
- * type_ce = NULL ;
1278
+ element -> type = PHONGO_TYPEMAP_NATIVE_OBJECT ;
1279
+ element -> class = NULL ;
1280
1280
} else {
1281
- if ((* type_ce = php_phongo_bson_state_fetch_class (classname , classname_len , php_phongo_unserializable_ce ))) {
1282
- * type = PHONGO_TYPEMAP_CLASS ;
1281
+ if ((element -> class = php_phongo_bson_state_fetch_class (classname , classname_len , php_phongo_unserializable_ce ))) {
1282
+ element -> type = PHONGO_TYPEMAP_CLASS ;
1283
1283
} else {
1284
1284
retval = false;
1285
1285
}
@@ -1293,10 +1293,10 @@ static bool php_phongo_bson_state_parse_type(zval* options, const char* name, ph
1293
1293
return retval ;
1294
1294
}
1295
1295
1296
- static void field_path_map_element_set_info (php_phongo_field_path_map_element * element , php_phongo_bson_typemap_types type , zend_class_entry * ce )
1296
+ static void field_path_map_element_set_info (php_phongo_field_path_map_element * element , php_phongo_bson_typemap_element * typemap_element )
1297
1297
{
1298
- element -> node_type = type ;
1299
- element -> node_ce = ce ;
1298
+ element -> node . type = typemap_element -> type ;
1299
+ element -> node . class = typemap_element -> class ;
1300
1300
}
1301
1301
1302
1302
static void map_add_field_path_element (php_phongo_bson_typemap * map , php_phongo_field_path_map_element * element )
@@ -1326,7 +1326,7 @@ static void field_path_map_element_dtor(php_phongo_field_path_map_element* eleme
1326
1326
efree (element );
1327
1327
}
1328
1328
1329
- static bool php_phongo_bson_state_add_field_path (php_phongo_bson_typemap * map , char * field_path_original , php_phongo_bson_typemap_types type , zend_class_entry * ce )
1329
+ static bool php_phongo_bson_state_add_field_path (php_phongo_bson_typemap * map , char * field_path_original , php_phongo_bson_typemap_element * typemap_element )
1330
1330
{
1331
1331
char * ptr = NULL ;
1332
1332
char * segment_end = NULL ;
@@ -1367,7 +1367,7 @@ static bool php_phongo_bson_state_add_field_path(php_phongo_bson_typemap* map, c
1367
1367
/* Add the last (or single) element */
1368
1368
php_phongo_field_path_push (field_path_map_element -> entry , ptr , PHONGO_FIELD_PATH_ITEM_NONE );
1369
1369
1370
- field_path_map_element_set_info (field_path_map_element , type , ce );
1370
+ field_path_map_element_set_info (field_path_map_element , typemap_element );
1371
1371
map_add_field_path_element (map , field_path_map_element );
1372
1372
1373
1373
return true;
@@ -1414,8 +1414,7 @@ static bool php_phongo_bson_state_parse_fieldpaths(zval* typemap, php_phongo_bso
1414
1414
1415
1415
ZEND_HASH_FOREACH_KEY_VAL (ht_data , num_key , string_key , property )
1416
1416
{
1417
- zend_class_entry * map_ce = NULL ;
1418
- php_phongo_bson_typemap_types map_type ;
1417
+ php_phongo_bson_typemap_element element ;
1419
1418
1420
1419
if (!string_key ) {
1421
1420
phongo_throw_exception (PHONGO_ERROR_INVALID_ARGUMENT , "The 'fieldPaths' element is not an associative array" );
@@ -1427,11 +1426,11 @@ static bool php_phongo_bson_state_parse_fieldpaths(zval* typemap, php_phongo_bso
1427
1426
return false;
1428
1427
}
1429
1428
1430
- if (!php_phongo_bson_state_parse_type (fieldpaths , ZSTR_VAL (string_key ), & map_type , & map_ce )) {
1429
+ if (!php_phongo_bson_state_parse_type (fieldpaths , ZSTR_VAL (string_key ), & element )) {
1431
1430
return false;
1432
1431
}
1433
1432
1434
- if (!php_phongo_bson_state_add_field_path (map , ZSTR_VAL (string_key ), map_type , map_ce )) {
1433
+ if (!php_phongo_bson_state_add_field_path (map , ZSTR_VAL (string_key ), & element )) {
1435
1434
return false;
1436
1435
}
1437
1436
}
@@ -1449,9 +1448,9 @@ bool php_phongo_bson_typemap_to_state(zval* typemap, php_phongo_bson_typemap* ma
1449
1448
return true;
1450
1449
}
1451
1450
1452
- if (!php_phongo_bson_state_parse_type (typemap , "array" , & map -> array_type , & map -> array ) ||
1453
- !php_phongo_bson_state_parse_type (typemap , "document" , & map -> document_type , & map -> document ) ||
1454
- !php_phongo_bson_state_parse_type (typemap , "root" , & map -> root_type , & map -> root ) ||
1451
+ if (!php_phongo_bson_state_parse_type (typemap , "array" , & map -> array ) ||
1452
+ !php_phongo_bson_state_parse_type (typemap , "document" , & map -> document ) ||
1453
+ !php_phongo_bson_state_parse_type (typemap , "root" , & map -> root ) ||
1455
1454
!php_phongo_bson_state_parse_fieldpaths (typemap , map )) {
1456
1455
1457
1456
/* Exception should already have been thrown */
0 commit comments