| 163 | } |
| 164 | |
| 165 | void skip_list(ReadContext &ctx, const FieldType &field_type) { |
| 166 | // Read list length |
| 167 | uint64_t length = ctx.read_var_uint64(ctx.error()); |
| 168 | if (FORY_PREDICT_FALSE(ctx.has_error())) { |
| 169 | return; |
| 170 | } |
| 171 | if (length == 0) { |
| 172 | return; |
| 173 | } |
| 174 | |
| 175 | // Read elements header |
| 176 | uint8_t header = ctx.read_uint8(ctx.error()); |
| 177 | if (FORY_PREDICT_FALSE(ctx.has_error())) { |
| 178 | return; |
| 179 | } |
| 180 | |
| 181 | bool track_ref = (header & 0b1) != 0; |
| 182 | bool has_null = (header & 0b10) != 0; |
| 183 | bool is_declared_type = (header & 0b100) != 0; |
| 184 | bool is_same_type = (header & 0b1000) != 0; |
| 185 | |
| 186 | const TypeInfo *same_type_info = nullptr; |
| 187 | if (is_same_type && !is_declared_type) { |
| 188 | same_type_info = ctx.read_any_type_info(ctx.error()); |
| 189 | if (FORY_PREDICT_FALSE(ctx.has_error())) { |
| 190 | return; |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | // get element type |
| 195 | FieldType elem_type; |
| 196 | if (!field_type.generics.empty()) { |
| 197 | elem_type = field_type.generics[0]; |
| 198 | } else { |
| 199 | // Unknown element type, need to read type info for each element |
| 200 | elem_type.set_type_id(static_cast<uint32_t>(TypeId::UNKNOWN)); |
| 201 | elem_type.nullable = false; |
| 202 | } |
| 203 | |
| 204 | // skip each element |
| 205 | for (uint64_t i = 0; i < length; ++i) { |
| 206 | bool has_value = consume_ref_flag(ctx, track_ref, has_null); |
| 207 | if (FORY_PREDICT_FALSE(ctx.has_error())) { |
| 208 | return; |
| 209 | } |
| 210 | if (!has_value) { |
| 211 | continue; |
| 212 | } |
| 213 | |
| 214 | if (!is_same_type) { |
| 215 | const TypeInfo *elem_type_info = ctx.read_any_type_info(ctx.error()); |
| 216 | if (FORY_PREDICT_FALSE(ctx.has_error())) { |
| 217 | return; |
| 218 | } |
| 219 | skip_data_with_type_info(ctx, elem_type_info); |
| 220 | } else { |
| 221 | skip_schema_or_type_info(ctx, elem_type, same_type_info); |
| 222 | } |
no test coverage detected