generateSliceElementReadDirectIndented generates code to read slice elements directly with custom indentation
(buf *bytes.Buffer, elemType types.Type, elemAccess string, indent string)
| 768 | |
| 769 | // generateSliceElementReadDirectIndented generates code to read slice elements directly with custom indentation |
| 770 | func generateSliceElementReadDirectIndented(buf *bytes.Buffer, elemType types.Type, elemAccess string, indent string) error { |
| 771 | if basic, ok := elemType.Underlying().(*types.Basic); ok { |
| 772 | switch basic.Kind() { |
| 773 | case types.Bool: |
| 774 | fmt.Fprintf(buf, "%s%s = buf.ReadBool(err)\n", indent, elemAccess) |
| 775 | case types.Int8: |
| 776 | fmt.Fprintf(buf, "%s%s = buf.ReadInt8(err)\n", indent, elemAccess) |
| 777 | case types.Int16: |
| 778 | fmt.Fprintf(buf, "%s%s = buf.ReadInt16(err)\n", indent, elemAccess) |
| 779 | case types.Int32: |
| 780 | fmt.Fprintf(buf, "%s%s = buf.ReadVarint32(err)\n", indent, elemAccess) |
| 781 | case types.Int, types.Int64: |
| 782 | fmt.Fprintf(buf, "%s%s = buf.ReadVarint64(err)\n", indent, elemAccess) |
| 783 | case types.Uint8: |
| 784 | fmt.Fprintf(buf, "%s%s = buf.ReadByte(err)\n", indent, elemAccess) |
| 785 | case types.Uint16: |
| 786 | fmt.Fprintf(buf, "%s%s = uint16(buf.ReadInt16(err))\n", indent, elemAccess) |
| 787 | case types.Uint32: |
| 788 | fmt.Fprintf(buf, "%s%s = uint32(buf.ReadInt32(err))\n", indent, elemAccess) |
| 789 | case types.Uint, types.Uint64: |
| 790 | fmt.Fprintf(buf, "%s%s = uint64(buf.ReadInt64(err))\n", indent, elemAccess) |
| 791 | case types.Float32: |
| 792 | fmt.Fprintf(buf, "%s%s = buf.ReadFloat32(err)\n", indent, elemAccess) |
| 793 | case types.Float64: |
| 794 | fmt.Fprintf(buf, "%s%s = buf.ReadFloat64(err)\n", indent, elemAccess) |
| 795 | case types.String: |
| 796 | fmt.Fprintf(buf, "%s%s = ctx.ReadString()\n", indent, elemAccess) |
| 797 | default: |
| 798 | return fmt.Errorf("unsupported basic type for direct element read: %s", basic.String()) |
| 799 | } |
| 800 | return nil |
| 801 | } |
| 802 | |
| 803 | return fmt.Errorf("unsupported element type for direct read: %s", elemType.String()) |
| 804 | } |
| 805 | |
| 806 | // generateMapReadInline generates inline map deserialization code following the chunk-based format |
| 807 | // Uses error-aware methods for deferred error checking |
no test coverage detected