@@ -99,6 +99,9 @@ void php_phongo_field_path_free(php_phongo_field_path* field_path)
99
99
if (field_path -> elements ) {
100
100
efree (field_path -> elements );
101
101
}
102
+ if (field_path -> element_types ) {
103
+ efree (field_path -> element_types );
104
+ }
102
105
efree (field_path );
103
106
}
104
107
@@ -109,9 +112,11 @@ static void php_phongo_field_path_ensure_allocation(php_phongo_field_path* field
109
112
110
113
field_path -> allocated_levels = field_path -> current_level + PHONGO_FIELD_PATH_EXPANSION ;
111
114
field_path -> elements = erealloc (field_path -> elements , sizeof (char * * ) * field_path -> allocated_levels );
115
+ field_path -> element_types = erealloc (field_path -> element_types , sizeof (php_phongo_bson_field_path_item_types * ) * field_path -> allocated_levels );
112
116
113
117
for (i = level ; i < field_path -> allocated_levels ; i ++ ) {
114
- field_path -> elements [i ] = NULL ;
118
+ field_path -> elements [i ] = NULL ;
119
+ field_path -> element_types [i ] = PHONGO_FIELD_PATH_ITEM_NONE ;
115
120
}
116
121
}
117
122
}
@@ -123,9 +128,17 @@ void php_phongo_field_path_write_item_at_current_level(php_phongo_field_path* fi
123
128
field_path -> elements [field_path -> current_level ] = element ;
124
129
}
125
130
126
- bool php_phongo_field_path_push (php_phongo_field_path * field_path , const char * element )
131
+ void php_phongo_field_path_write_type_at_current_level (php_phongo_field_path * field_path , php_phongo_bson_field_path_item_types element_type )
132
+ {
133
+ php_phongo_field_path_ensure_allocation (field_path , field_path -> current_level );
134
+
135
+ field_path -> element_types [field_path -> current_level ] = element_type ;
136
+ }
137
+
138
+ bool php_phongo_field_path_push (php_phongo_field_path * field_path , const char * element , php_phongo_bson_field_path_item_types element_type )
127
139
{
128
140
php_phongo_field_path_write_item_at_current_level (field_path , element );
141
+ php_phongo_field_path_write_type_at_current_level (field_path , element_type );
129
142
130
143
field_path -> current_level ++ ;
131
144
@@ -134,11 +147,13 @@ bool php_phongo_field_path_push(php_phongo_field_path* field_path, const char* e
134
147
135
148
bool php_phongo_field_path_pop (php_phongo_field_path * field_path )
136
149
{
137
- field_path -> elements [field_path -> current_level ] = NULL ;
150
+ field_path -> elements [field_path -> current_level ] = NULL ;
151
+ field_path -> element_types [field_path -> current_level ] = PHONGO_FIELD_PATH_ITEM_NONE ;
138
152
139
153
field_path -> current_level -- ;
140
154
141
- field_path -> elements [field_path -> current_level ] = NULL ;
155
+ field_path -> elements [field_path -> current_level ] = NULL ;
156
+ field_path -> element_types [field_path -> current_level ] = PHONGO_FIELD_PATH_ITEM_NONE ;
142
157
143
158
return true;
144
159
}
@@ -774,7 +789,7 @@ static bool php_phongo_bson_visit_document(const bson_iter_t* iter ARG_UNUSED, c
774
789
php_phongo_bson_state * parent_state = (php_phongo_bson_state * ) data ;
775
790
TSRMLS_FETCH ();
776
791
777
- php_phongo_field_path_push (parent_state -> field_path , key );
792
+ php_phongo_field_path_push (parent_state -> field_path , key , PHONGO_FIELD_PATH_ITEM_DOCUMENT );
778
793
779
794
if (bson_iter_init (& child , v_document )) {
780
795
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER ;
@@ -881,7 +896,7 @@ static bool php_phongo_bson_visit_array(const bson_iter_t* iter ARG_UNUSED, cons
881
896
php_phongo_bson_state * parent_state = (php_phongo_bson_state * ) data ;
882
897
TSRMLS_FETCH ();
883
898
884
- php_phongo_field_path_push (parent_state -> field_path , key );
899
+ php_phongo_field_path_push (parent_state -> field_path , key , PHONGO_FIELD_PATH_ITEM_ARRAY );
885
900
886
901
if (bson_iter_init (& child , v_array )) {
887
902
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER ;
0 commit comments