| 600 | } |
| 601 | |
| 602 | void skip_union(ReadContext &ctx) { |
| 603 | // Read the variant index |
| 604 | (void)ctx.read_var_uint32(ctx.error()); |
| 605 | if (FORY_PREDICT_FALSE(ctx.has_error())) { |
| 606 | return; |
| 607 | } |
| 608 | // Read ref flag for the union value (Any-style) |
| 609 | int8_t ref_flag = ctx.read_int8(ctx.error()); |
| 610 | if (FORY_PREDICT_FALSE(ctx.has_error())) { |
| 611 | return; |
| 612 | } |
| 613 | if (ref_flag == NULL_FLAG) { |
| 614 | return; |
| 615 | } |
| 616 | if (ref_flag == REF_FLAG) { |
| 617 | (void)ctx.read_var_uint32(ctx.error()); |
| 618 | return; |
| 619 | } |
| 620 | if (ref_flag != NOT_NULL_VALUE_FLAG && ref_flag != REF_VALUE_FLAG) { |
| 621 | ctx.set_error( |
| 622 | Error::invalid_data("Unknown reference flag: " + |
| 623 | std::to_string(static_cast<int>(ref_flag)))); |
| 624 | return; |
| 625 | } |
| 626 | |
| 627 | // Read and skip the alternative's type info |
| 628 | const TypeInfo *type_info = ctx.read_any_type_info(ctx.error()); |
| 629 | if (FORY_PREDICT_FALSE(ctx.has_error())) { |
| 630 | return; |
| 631 | } |
| 632 | if (!type_info) { |
| 633 | ctx.set_error( |
| 634 | Error::type_error("TypeInfo not found for UNION alternative skip")); |
| 635 | return; |
| 636 | } |
| 637 | |
| 638 | // skip the alternative's value |
| 639 | FieldType alt_field_type; |
| 640 | alt_field_type.set_type_id(type_info->type_id); |
| 641 | alt_field_type.nullable = false; |
| 642 | skip_field_value(ctx, alt_field_type, RefMode::None); |
| 643 | } |
| 644 | |
| 645 | void skip_field_value(ReadContext &ctx, const FieldType &field_type, |
| 646 | RefMode ref_mode) { |
no test coverage detected