skipValue is the main dispatcher for skipping values based on their type Uses context error state for deferred error checking.
(ctx *ReadContext, fieldDef FieldDef, readRefFlag bool, isField bool, typeInfo *TypeInfo)
| 546 | // skipValue is the main dispatcher for skipping values based on their type |
| 547 | // Uses context error state for deferred error checking. |
| 548 | func skipValue(ctx *ReadContext, fieldDef FieldDef, readRefFlag bool, isField bool, typeInfo *TypeInfo) { |
| 549 | err := ctx.Err() |
| 550 | if readRefFlag { |
| 551 | refFlag := ctx.buffer.ReadInt8(err) |
| 552 | if ctx.HasError() { |
| 553 | return |
| 554 | } |
| 555 | if refFlag == NullFlag { |
| 556 | return |
| 557 | } |
| 558 | if refFlag == RefFlag { |
| 559 | // Reference to already-seen object, skip the reference index |
| 560 | _ = ctx.buffer.ReadVarUint32(err) |
| 561 | return |
| 562 | } |
| 563 | // RefValueFlag (0) or NotNullValueFlag (-1) means we need to read the actual object |
| 564 | } |
| 565 | |
| 566 | typeIDNum := uint32(fieldDef.typeSpec.TypeId()) |
| 567 | |
| 568 | internalID := TypeId(typeIDNum) |
| 569 | // Handle struct-like types |
| 570 | if internalID == COMPATIBLE_STRUCT || internalID == STRUCT || |
| 571 | internalID == NAMED_STRUCT || internalID == NAMED_COMPATIBLE_STRUCT { |
| 572 | // If type_info is provided (from SkipAnyValue), use skipStruct directly |
| 573 | if typeInfo != nil { |
| 574 | skipStruct(ctx, typeInfo) |
| 575 | return |
| 576 | } |
| 577 | // Otherwise we need to read type info |
| 578 | ti := readKnownTypeInfoForSkip(ctx, typeIDNum) |
| 579 | if ctx.HasError() { |
| 580 | return |
| 581 | } |
| 582 | skipStruct(ctx, ti) |
| 583 | return |
| 584 | } |
| 585 | if internalID == ENUM || internalID == NAMED_ENUM { |
| 586 | // Enum values are encoded as ordinal only (VarUint32Small7) for xlang. |
| 587 | _ = ctx.buffer.ReadVarUint32Small7(err) |
| 588 | return |
| 589 | } |
| 590 | if internalID == EXT || internalID == NAMED_EXT || internalID == TYPED_UNION || internalID == NAMED_UNION { |
| 591 | if typeInfo == nil { |
| 592 | typeInfo = readKnownTypeInfoForSkip(ctx, typeIDNum) |
| 593 | if ctx.HasError() { |
| 594 | return |
| 595 | } |
| 596 | } |
| 597 | if typeInfo != nil && typeInfo.Serializer != nil { |
| 598 | // Use the serializer to read and discard the value |
| 599 | var dummy any |
| 600 | dummyVal := reflect.ValueOf(&dummy).Elem() |
| 601 | typeInfo.Serializer.Read(ctx, RefModeNone, false, false, dummyVal) |
| 602 | return |
| 603 | } |
| 604 | ctx.SetError(DeserializationErrorf("cannot skip type %d: no serializer registered", typeIDNum)) |
| 605 | return |