(ctx *ReadContext, info *unionCaseInfo)
| 433 | } |
| 434 | |
| 435 | func readUnionOverrideValue(ctx *ReadContext, info *unionCaseInfo) (any, bool) { |
| 436 | buf := ctx.Buffer() |
| 437 | refID, refErr := ctx.RefResolver().TryPreserveRefId(buf) |
| 438 | if refErr != nil { |
| 439 | ctx.SetError(FromError(refErr)) |
| 440 | return nil, false |
| 441 | } |
| 442 | if refID < int32(NotNullValueFlag) { |
| 443 | obj := ctx.RefResolver().GetReadObject(refID) |
| 444 | if obj.IsValid() { |
| 445 | return obj.Interface(), true |
| 446 | } |
| 447 | return nil, true |
| 448 | } |
| 449 | |
| 450 | typeID := TypeId(buf.ReadUint8(ctx.Err())) |
| 451 | if ctx.HasError() { |
| 452 | return nil, false |
| 453 | } |
| 454 | if typeID != info.typeID { |
| 455 | ctx.SetError(TypeMismatchError(typeID, info.typeID)) |
| 456 | return nil, false |
| 457 | } |
| 458 | |
| 459 | value, ok := readNumericValueByTypeID(ctx, info.type_, info.typeID) |
| 460 | if !ok { |
| 461 | return nil, false |
| 462 | } |
| 463 | if value.Kind() == reflect.Ptr { |
| 464 | ctx.RefResolver().Reference(value) |
| 465 | } |
| 466 | return value.Interface(), true |
| 467 | } |
| 468 | |
| 469 | func writeNumericValueByTypeID(ctx *WriteContext, typeID TypeId, value reflect.Value) { |
| 470 | buf := ctx.Buffer() |
no test coverage detected