| 551 | } |
| 552 | |
| 553 | void skip_unknown(ReadContext &ctx) { |
| 554 | // UNKNOWN type means the actual type info is written inline. |
| 555 | // We need to read the type info and then skip based on the actual type. |
| 556 | // This is used for polymorphic fields like List<Animal>. |
| 557 | const TypeInfo *type_info = ctx.read_any_type_info(ctx.error()); |
| 558 | if (FORY_PREDICT_FALSE(ctx.has_error())) { |
| 559 | return; |
| 560 | } |
| 561 | if (!type_info) { |
| 562 | ctx.set_error(Error::type_error("TypeInfo not found for UNKNOWN skip")); |
| 563 | return; |
| 564 | } |
| 565 | |
| 566 | // Check the actual type and skip accordingly |
| 567 | TypeId actual_tid = static_cast<TypeId>(type_info->type_id); |
| 568 | |
| 569 | switch (actual_tid) { |
| 570 | case TypeId::STRUCT: |
| 571 | case TypeId::COMPATIBLE_STRUCT: |
| 572 | case TypeId::NAMED_STRUCT: |
| 573 | case TypeId::NAMED_COMPATIBLE_STRUCT: { |
| 574 | // For struct types, we already have the type_info with field_infos |
| 575 | if (!type_info->type_meta) { |
| 576 | ctx.set_error( |
| 577 | Error::type_error("TypeMeta not found for UNKNOWN struct skip")); |
| 578 | return; |
| 579 | } |
| 580 | const auto &field_infos = type_info->type_meta->get_field_infos(); |
| 581 | for (const auto &fi : field_infos) { |
| 582 | // Use precomputed ref_mode from field metadata |
| 583 | skip_field_value(ctx, fi.field_type, fi.field_type.ref_mode); |
| 584 | if (FORY_PREDICT_FALSE(ctx.has_error())) { |
| 585 | return; |
| 586 | } |
| 587 | } |
| 588 | return; |
| 589 | } |
| 590 | default: { |
| 591 | // For non-struct types (primitives, arrays, maps, etc.), |
| 592 | // recursively call skip_field_value with the actual type |
| 593 | FieldType actual_field_type; |
| 594 | actual_field_type.set_type_id(type_info->type_id); |
| 595 | actual_field_type.nullable = false; |
| 596 | skip_field_value(ctx, actual_field_type, RefMode::None); |
| 597 | return; |
| 598 | } |
| 599 | } |
| 600 | } |
| 601 | |
| 602 | void skip_union(ReadContext &ctx) { |
| 603 | // Read the variant index |
no test coverage detected