protobuf-go/internal/impl/codec_gen.go
Damien Neil 4b3a82f6b1 internal/impl: clean up Value codecs
Remove the Go type from consideration when creating Value codecs, as it
is unnecessary. Value codecs convert between wire form and Values,
while Converters convert between Values and the Go type.

Change-Id: Iaa4bc7db81ad0a29dabd42c2229e6f33a0c91c67
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/193457
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2019-09-05 16:31:05 +00:00

4787 lines
137 KiB
Go

// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style.
// license that can be found in the LICENSE file.
// Code generated by generate-types. DO NOT EDIT.
package impl
import (
"math"
"unicode/utf8"
"google.golang.org/protobuf/internal/encoding/wire"
"google.golang.org/protobuf/reflect/protoreflect"
)
// sizeBool returns the size of wire encoding a bool pointer as a Bool.
func sizeBool(p pointer, tagsize int, _ marshalOptions) (size int) {
v := *p.Bool()
return tagsize + wire.SizeVarint(wire.EncodeBool(v))
}
// appendBool wire encodes a bool pointer as a Bool.
func appendBool(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.Bool()
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, wire.EncodeBool(v))
return b, nil
}
// consumeBool wire decodes a bool pointer as a Bool.
func consumeBool(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.VarintType {
return 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return 0, wire.ParseError(n)
}
*p.Bool() = wire.DecodeBool(v)
return n, nil
}
var coderBool = pointerCoderFuncs{
size: sizeBool,
marshal: appendBool,
unmarshal: consumeBool,
}
// sizeBoolNoZero returns the size of wire encoding a bool pointer as a Bool.
// The zero value is not encoded.
func sizeBoolNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
v := *p.Bool()
if v == false {
return 0
}
return tagsize + wire.SizeVarint(wire.EncodeBool(v))
}
// appendBoolNoZero wire encodes a bool pointer as a Bool.
// The zero value is not encoded.
func appendBoolNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.Bool()
if v == false {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, wire.EncodeBool(v))
return b, nil
}
var coderBoolNoZero = pointerCoderFuncs{
size: sizeBoolNoZero,
marshal: appendBoolNoZero,
unmarshal: consumeBool,
}
// sizeBoolPtr returns the size of wire encoding a *bool pointer as a Bool.
// It panics if the pointer is nil.
func sizeBoolPtr(p pointer, tagsize int, _ marshalOptions) (size int) {
v := **p.BoolPtr()
return tagsize + wire.SizeVarint(wire.EncodeBool(v))
}
// appendBoolPtr wire encodes a *bool pointer as a Bool.
// It panics if the pointer is nil.
func appendBoolPtr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := **p.BoolPtr()
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, wire.EncodeBool(v))
return b, nil
}
// consumeBoolPtr wire decodes a *bool pointer as a Bool.
func consumeBoolPtr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.VarintType {
return 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return 0, wire.ParseError(n)
}
vp := p.BoolPtr()
if *vp == nil {
*vp = new(bool)
}
**vp = wire.DecodeBool(v)
return n, nil
}
var coderBoolPtr = pointerCoderFuncs{
size: sizeBoolPtr,
marshal: appendBoolPtr,
unmarshal: consumeBoolPtr,
}
// sizeBoolSlice returns the size of wire encoding a []bool pointer as a repeated Bool.
func sizeBoolSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
s := *p.BoolSlice()
for _, v := range s {
size += tagsize + wire.SizeVarint(wire.EncodeBool(v))
}
return size
}
// appendBoolSlice encodes a []bool pointer as a repeated Bool.
func appendBoolSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
s := *p.BoolSlice()
for _, v := range s {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, wire.EncodeBool(v))
}
return b, nil
}
// consumeBoolSlice wire decodes a []bool pointer as a repeated Bool.
func consumeBoolSlice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
sp := p.BoolSlice()
if wtyp == wire.BytesType {
s := *sp
b, n = wire.ConsumeBytes(b)
if n < 0 {
return 0, wire.ParseError(n)
}
for len(b) > 0 {
v, n := wire.ConsumeVarint(b)
if n < 0 {
return 0, wire.ParseError(n)
}
s = append(s, wire.DecodeBool(v))
b = b[n:]
}
*sp = s
return n, nil
}
if wtyp != wire.VarintType {
return 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return 0, wire.ParseError(n)
}
*sp = append(*sp, wire.DecodeBool(v))
return n, nil
}
var coderBoolSlice = pointerCoderFuncs{
size: sizeBoolSlice,
marshal: appendBoolSlice,
unmarshal: consumeBoolSlice,
}
// sizeBoolPackedSlice returns the size of wire encoding a []bool pointer as a packed repeated Bool.
func sizeBoolPackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
s := *p.BoolSlice()
if len(s) == 0 {
return 0
}
n := 0
for _, v := range s {
n += wire.SizeVarint(wire.EncodeBool(v))
}
return tagsize + wire.SizeBytes(n)
}
// appendBoolPackedSlice encodes a []bool pointer as a packed repeated Bool.
func appendBoolPackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
s := *p.BoolSlice()
if len(s) == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
n := 0
for _, v := range s {
n += wire.SizeVarint(wire.EncodeBool(v))
}
b = wire.AppendVarint(b, uint64(n))
for _, v := range s {
b = wire.AppendVarint(b, wire.EncodeBool(v))
}
return b, nil
}
var coderBoolPackedSlice = pointerCoderFuncs{
size: sizeBoolPackedSlice,
marshal: appendBoolPackedSlice,
unmarshal: consumeBoolSlice,
}
// sizeBoolValue returns the size of wire encoding a bool value as a Bool.
func sizeBoolValue(v protoreflect.Value, tagsize int, _ marshalOptions) int {
return tagsize + wire.SizeVarint(wire.EncodeBool(v.Bool()))
}
// appendBoolValue encodes a bool value as a Bool.
func appendBoolValue(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, wire.EncodeBool(v.Bool()))
return b, nil
}
// consumeBoolValue decodes a bool value as a Bool.
func consumeBoolValue(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
if wtyp != wire.VarintType {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
return protoreflect.ValueOfBool(wire.DecodeBool(v)), n, nil
}
var coderBoolValue = valueCoderFuncs{
size: sizeBoolValue,
marshal: appendBoolValue,
unmarshal: consumeBoolValue,
}
// sizeBoolSliceValue returns the size of wire encoding a []bool value as a repeated Bool.
func sizeBoolSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
list := listv.List()
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
size += tagsize + wire.SizeVarint(wire.EncodeBool(v.Bool()))
}
return size
}
// appendBoolSliceValue encodes a []bool value as a repeated Bool.
func appendBoolSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
list := listv.List()
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, wire.EncodeBool(v.Bool()))
}
return b, nil
}
// consumeBoolSliceValue wire decodes a []bool value as a repeated Bool.
func consumeBoolSliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
list := listv.List()
if wtyp == wire.BytesType {
b, n = wire.ConsumeBytes(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
for len(b) > 0 {
v, n := wire.ConsumeVarint(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
list.Append(protoreflect.ValueOfBool(wire.DecodeBool(v)))
b = b[n:]
}
return listv, n, nil
}
if wtyp != wire.VarintType {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
list.Append(protoreflect.ValueOfBool(wire.DecodeBool(v)))
return listv, n, nil
}
var coderBoolSliceValue = valueCoderFuncs{
size: sizeBoolSliceValue,
marshal: appendBoolSliceValue,
unmarshal: consumeBoolSliceValue,
}
// sizeBoolPackedSliceValue returns the size of wire encoding a []bool value as a packed repeated Bool.
func sizeBoolPackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
list := listv.List()
n := 0
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
n += wire.SizeVarint(wire.EncodeBool(v.Bool()))
}
return tagsize + wire.SizeBytes(n)
}
// appendBoolPackedSliceValue encodes a []bool value as a packed repeated Bool.
func appendBoolPackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
list := listv.List()
llen := list.Len()
if llen == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
n := 0
for i := 0; i < llen; i++ {
v := list.Get(i)
n += wire.SizeVarint(wire.EncodeBool(v.Bool()))
}
b = wire.AppendVarint(b, uint64(n))
for i := 0; i < llen; i++ {
v := list.Get(i)
b = wire.AppendVarint(b, wire.EncodeBool(v.Bool()))
}
return b, nil
}
var coderBoolPackedSliceValue = valueCoderFuncs{
size: sizeBoolPackedSliceValue,
marshal: appendBoolPackedSliceValue,
unmarshal: consumeBoolSliceValue,
}
// sizeEnumValue returns the size of wire encoding a value as a Enum.
func sizeEnumValue(v protoreflect.Value, tagsize int, _ marshalOptions) int {
return tagsize + wire.SizeVarint(uint64(v.Enum()))
}
// appendEnumValue encodes a value as a Enum.
func appendEnumValue(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, uint64(v.Enum()))
return b, nil
}
// consumeEnumValue decodes a value as a Enum.
func consumeEnumValue(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
if wtyp != wire.VarintType {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
return protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)), n, nil
}
var coderEnumValue = valueCoderFuncs{
size: sizeEnumValue,
marshal: appendEnumValue,
unmarshal: consumeEnumValue,
}
// sizeEnumSliceValue returns the size of wire encoding a [] value as a repeated Enum.
func sizeEnumSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
list := listv.List()
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
size += tagsize + wire.SizeVarint(uint64(v.Enum()))
}
return size
}
// appendEnumSliceValue encodes a [] value as a repeated Enum.
func appendEnumSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
list := listv.List()
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, uint64(v.Enum()))
}
return b, nil
}
// consumeEnumSliceValue wire decodes a [] value as a repeated Enum.
func consumeEnumSliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
list := listv.List()
if wtyp == wire.BytesType {
b, n = wire.ConsumeBytes(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
for len(b) > 0 {
v, n := wire.ConsumeVarint(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
list.Append(protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)))
b = b[n:]
}
return listv, n, nil
}
if wtyp != wire.VarintType {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
list.Append(protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)))
return listv, n, nil
}
var coderEnumSliceValue = valueCoderFuncs{
size: sizeEnumSliceValue,
marshal: appendEnumSliceValue,
unmarshal: consumeEnumSliceValue,
}
// sizeEnumPackedSliceValue returns the size of wire encoding a [] value as a packed repeated Enum.
func sizeEnumPackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
list := listv.List()
n := 0
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
n += wire.SizeVarint(uint64(v.Enum()))
}
return tagsize + wire.SizeBytes(n)
}
// appendEnumPackedSliceValue encodes a [] value as a packed repeated Enum.
func appendEnumPackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
list := listv.List()
llen := list.Len()
if llen == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
n := 0
for i := 0; i < llen; i++ {
v := list.Get(i)
n += wire.SizeVarint(uint64(v.Enum()))
}
b = wire.AppendVarint(b, uint64(n))
for i := 0; i < llen; i++ {
v := list.Get(i)
b = wire.AppendVarint(b, uint64(v.Enum()))
}
return b, nil
}
var coderEnumPackedSliceValue = valueCoderFuncs{
size: sizeEnumPackedSliceValue,
marshal: appendEnumPackedSliceValue,
unmarshal: consumeEnumSliceValue,
}
// sizeInt32 returns the size of wire encoding a int32 pointer as a Int32.
func sizeInt32(p pointer, tagsize int, _ marshalOptions) (size int) {
v := *p.Int32()
return tagsize + wire.SizeVarint(uint64(v))
}
// appendInt32 wire encodes a int32 pointer as a Int32.
func appendInt32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.Int32()
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, uint64(v))
return b, nil
}
// consumeInt32 wire decodes a int32 pointer as a Int32.
func consumeInt32(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.VarintType {
return 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return 0, wire.ParseError(n)
}
*p.Int32() = int32(v)
return n, nil
}
var coderInt32 = pointerCoderFuncs{
size: sizeInt32,
marshal: appendInt32,
unmarshal: consumeInt32,
}
// sizeInt32NoZero returns the size of wire encoding a int32 pointer as a Int32.
// The zero value is not encoded.
func sizeInt32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
v := *p.Int32()
if v == 0 {
return 0
}
return tagsize + wire.SizeVarint(uint64(v))
}
// appendInt32NoZero wire encodes a int32 pointer as a Int32.
// The zero value is not encoded.
func appendInt32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.Int32()
if v == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, uint64(v))
return b, nil
}
var coderInt32NoZero = pointerCoderFuncs{
size: sizeInt32NoZero,
marshal: appendInt32NoZero,
unmarshal: consumeInt32,
}
// sizeInt32Ptr returns the size of wire encoding a *int32 pointer as a Int32.
// It panics if the pointer is nil.
func sizeInt32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
v := **p.Int32Ptr()
return tagsize + wire.SizeVarint(uint64(v))
}
// appendInt32Ptr wire encodes a *int32 pointer as a Int32.
// It panics if the pointer is nil.
func appendInt32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := **p.Int32Ptr()
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, uint64(v))
return b, nil
}
// consumeInt32Ptr wire decodes a *int32 pointer as a Int32.
func consumeInt32Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.VarintType {
return 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return 0, wire.ParseError(n)
}
vp := p.Int32Ptr()
if *vp == nil {
*vp = new(int32)
}
**vp = int32(v)
return n, nil
}
var coderInt32Ptr = pointerCoderFuncs{
size: sizeInt32Ptr,
marshal: appendInt32Ptr,
unmarshal: consumeInt32Ptr,
}
// sizeInt32Slice returns the size of wire encoding a []int32 pointer as a repeated Int32.
func sizeInt32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
s := *p.Int32Slice()
for _, v := range s {
size += tagsize + wire.SizeVarint(uint64(v))
}
return size
}
// appendInt32Slice encodes a []int32 pointer as a repeated Int32.
func appendInt32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
s := *p.Int32Slice()
for _, v := range s {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, uint64(v))
}
return b, nil
}
// consumeInt32Slice wire decodes a []int32 pointer as a repeated Int32.
func consumeInt32Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
sp := p.Int32Slice()
if wtyp == wire.BytesType {
s := *sp
b, n = wire.ConsumeBytes(b)
if n < 0 {
return 0, wire.ParseError(n)
}
for len(b) > 0 {
v, n := wire.ConsumeVarint(b)
if n < 0 {
return 0, wire.ParseError(n)
}
s = append(s, int32(v))
b = b[n:]
}
*sp = s
return n, nil
}
if wtyp != wire.VarintType {
return 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return 0, wire.ParseError(n)
}
*sp = append(*sp, int32(v))
return n, nil
}
var coderInt32Slice = pointerCoderFuncs{
size: sizeInt32Slice,
marshal: appendInt32Slice,
unmarshal: consumeInt32Slice,
}
// sizeInt32PackedSlice returns the size of wire encoding a []int32 pointer as a packed repeated Int32.
func sizeInt32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
s := *p.Int32Slice()
if len(s) == 0 {
return 0
}
n := 0
for _, v := range s {
n += wire.SizeVarint(uint64(v))
}
return tagsize + wire.SizeBytes(n)
}
// appendInt32PackedSlice encodes a []int32 pointer as a packed repeated Int32.
func appendInt32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
s := *p.Int32Slice()
if len(s) == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
n := 0
for _, v := range s {
n += wire.SizeVarint(uint64(v))
}
b = wire.AppendVarint(b, uint64(n))
for _, v := range s {
b = wire.AppendVarint(b, uint64(v))
}
return b, nil
}
var coderInt32PackedSlice = pointerCoderFuncs{
size: sizeInt32PackedSlice,
marshal: appendInt32PackedSlice,
unmarshal: consumeInt32Slice,
}
// sizeInt32Value returns the size of wire encoding a int32 value as a Int32.
func sizeInt32Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
return tagsize + wire.SizeVarint(uint64(int32(v.Int())))
}
// appendInt32Value encodes a int32 value as a Int32.
func appendInt32Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, uint64(int32(v.Int())))
return b, nil
}
// consumeInt32Value decodes a int32 value as a Int32.
func consumeInt32Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
if wtyp != wire.VarintType {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
return protoreflect.ValueOfInt32(int32(v)), n, nil
}
var coderInt32Value = valueCoderFuncs{
size: sizeInt32Value,
marshal: appendInt32Value,
unmarshal: consumeInt32Value,
}
// sizeInt32SliceValue returns the size of wire encoding a []int32 value as a repeated Int32.
func sizeInt32SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
list := listv.List()
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
size += tagsize + wire.SizeVarint(uint64(int32(v.Int())))
}
return size
}
// appendInt32SliceValue encodes a []int32 value as a repeated Int32.
func appendInt32SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
list := listv.List()
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, uint64(int32(v.Int())))
}
return b, nil
}
// consumeInt32SliceValue wire decodes a []int32 value as a repeated Int32.
func consumeInt32SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
list := listv.List()
if wtyp == wire.BytesType {
b, n = wire.ConsumeBytes(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
for len(b) > 0 {
v, n := wire.ConsumeVarint(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
list.Append(protoreflect.ValueOfInt32(int32(v)))
b = b[n:]
}
return listv, n, nil
}
if wtyp != wire.VarintType {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
list.Append(protoreflect.ValueOfInt32(int32(v)))
return listv, n, nil
}
var coderInt32SliceValue = valueCoderFuncs{
size: sizeInt32SliceValue,
marshal: appendInt32SliceValue,
unmarshal: consumeInt32SliceValue,
}
// sizeInt32PackedSliceValue returns the size of wire encoding a []int32 value as a packed repeated Int32.
func sizeInt32PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
list := listv.List()
n := 0
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
n += wire.SizeVarint(uint64(int32(v.Int())))
}
return tagsize + wire.SizeBytes(n)
}
// appendInt32PackedSliceValue encodes a []int32 value as a packed repeated Int32.
func appendInt32PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
list := listv.List()
llen := list.Len()
if llen == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
n := 0
for i := 0; i < llen; i++ {
v := list.Get(i)
n += wire.SizeVarint(uint64(int32(v.Int())))
}
b = wire.AppendVarint(b, uint64(n))
for i := 0; i < llen; i++ {
v := list.Get(i)
b = wire.AppendVarint(b, uint64(int32(v.Int())))
}
return b, nil
}
var coderInt32PackedSliceValue = valueCoderFuncs{
size: sizeInt32PackedSliceValue,
marshal: appendInt32PackedSliceValue,
unmarshal: consumeInt32SliceValue,
}
// sizeSint32 returns the size of wire encoding a int32 pointer as a Sint32.
func sizeSint32(p pointer, tagsize int, _ marshalOptions) (size int) {
v := *p.Int32()
return tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
}
// appendSint32 wire encodes a int32 pointer as a Sint32.
func appendSint32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.Int32()
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
return b, nil
}
// consumeSint32 wire decodes a int32 pointer as a Sint32.
func consumeSint32(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.VarintType {
return 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return 0, wire.ParseError(n)
}
*p.Int32() = int32(wire.DecodeZigZag(v & math.MaxUint32))
return n, nil
}
var coderSint32 = pointerCoderFuncs{
size: sizeSint32,
marshal: appendSint32,
unmarshal: consumeSint32,
}
// sizeSint32NoZero returns the size of wire encoding a int32 pointer as a Sint32.
// The zero value is not encoded.
func sizeSint32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
v := *p.Int32()
if v == 0 {
return 0
}
return tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
}
// appendSint32NoZero wire encodes a int32 pointer as a Sint32.
// The zero value is not encoded.
func appendSint32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.Int32()
if v == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
return b, nil
}
var coderSint32NoZero = pointerCoderFuncs{
size: sizeSint32NoZero,
marshal: appendSint32NoZero,
unmarshal: consumeSint32,
}
// sizeSint32Ptr returns the size of wire encoding a *int32 pointer as a Sint32.
// It panics if the pointer is nil.
func sizeSint32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
v := **p.Int32Ptr()
return tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
}
// appendSint32Ptr wire encodes a *int32 pointer as a Sint32.
// It panics if the pointer is nil.
func appendSint32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := **p.Int32Ptr()
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
return b, nil
}
// consumeSint32Ptr wire decodes a *int32 pointer as a Sint32.
func consumeSint32Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.VarintType {
return 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return 0, wire.ParseError(n)
}
vp := p.Int32Ptr()
if *vp == nil {
*vp = new(int32)
}
**vp = int32(wire.DecodeZigZag(v & math.MaxUint32))
return n, nil
}
var coderSint32Ptr = pointerCoderFuncs{
size: sizeSint32Ptr,
marshal: appendSint32Ptr,
unmarshal: consumeSint32Ptr,
}
// sizeSint32Slice returns the size of wire encoding a []int32 pointer as a repeated Sint32.
func sizeSint32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
s := *p.Int32Slice()
for _, v := range s {
size += tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
}
return size
}
// appendSint32Slice encodes a []int32 pointer as a repeated Sint32.
func appendSint32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
s := *p.Int32Slice()
for _, v := range s {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
}
return b, nil
}
// consumeSint32Slice wire decodes a []int32 pointer as a repeated Sint32.
func consumeSint32Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
sp := p.Int32Slice()
if wtyp == wire.BytesType {
s := *sp
b, n = wire.ConsumeBytes(b)
if n < 0 {
return 0, wire.ParseError(n)
}
for len(b) > 0 {
v, n := wire.ConsumeVarint(b)
if n < 0 {
return 0, wire.ParseError(n)
}
s = append(s, int32(wire.DecodeZigZag(v&math.MaxUint32)))
b = b[n:]
}
*sp = s
return n, nil
}
if wtyp != wire.VarintType {
return 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return 0, wire.ParseError(n)
}
*sp = append(*sp, int32(wire.DecodeZigZag(v&math.MaxUint32)))
return n, nil
}
var coderSint32Slice = pointerCoderFuncs{
size: sizeSint32Slice,
marshal: appendSint32Slice,
unmarshal: consumeSint32Slice,
}
// sizeSint32PackedSlice returns the size of wire encoding a []int32 pointer as a packed repeated Sint32.
func sizeSint32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
s := *p.Int32Slice()
if len(s) == 0 {
return 0
}
n := 0
for _, v := range s {
n += wire.SizeVarint(wire.EncodeZigZag(int64(v)))
}
return tagsize + wire.SizeBytes(n)
}
// appendSint32PackedSlice encodes a []int32 pointer as a packed repeated Sint32.
func appendSint32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
s := *p.Int32Slice()
if len(s) == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
n := 0
for _, v := range s {
n += wire.SizeVarint(wire.EncodeZigZag(int64(v)))
}
b = wire.AppendVarint(b, uint64(n))
for _, v := range s {
b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
}
return b, nil
}
var coderSint32PackedSlice = pointerCoderFuncs{
size: sizeSint32PackedSlice,
marshal: appendSint32PackedSlice,
unmarshal: consumeSint32Slice,
}
// sizeSint32Value returns the size of wire encoding a int32 value as a Sint32.
func sizeSint32Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
return tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(int32(v.Int()))))
}
// appendSint32Value encodes a int32 value as a Sint32.
func appendSint32Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, wire.EncodeZigZag(int64(int32(v.Int()))))
return b, nil
}
// consumeSint32Value decodes a int32 value as a Sint32.
func consumeSint32Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
if wtyp != wire.VarintType {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
return protoreflect.ValueOfInt32(int32(wire.DecodeZigZag(v & math.MaxUint32))), n, nil
}
var coderSint32Value = valueCoderFuncs{
size: sizeSint32Value,
marshal: appendSint32Value,
unmarshal: consumeSint32Value,
}
// sizeSint32SliceValue returns the size of wire encoding a []int32 value as a repeated Sint32.
func sizeSint32SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
list := listv.List()
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
size += tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(int32(v.Int()))))
}
return size
}
// appendSint32SliceValue encodes a []int32 value as a repeated Sint32.
func appendSint32SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
list := listv.List()
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, wire.EncodeZigZag(int64(int32(v.Int()))))
}
return b, nil
}
// consumeSint32SliceValue wire decodes a []int32 value as a repeated Sint32.
func consumeSint32SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
list := listv.List()
if wtyp == wire.BytesType {
b, n = wire.ConsumeBytes(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
for len(b) > 0 {
v, n := wire.ConsumeVarint(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
list.Append(protoreflect.ValueOfInt32(int32(wire.DecodeZigZag(v & math.MaxUint32))))
b = b[n:]
}
return listv, n, nil
}
if wtyp != wire.VarintType {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
list.Append(protoreflect.ValueOfInt32(int32(wire.DecodeZigZag(v & math.MaxUint32))))
return listv, n, nil
}
var coderSint32SliceValue = valueCoderFuncs{
size: sizeSint32SliceValue,
marshal: appendSint32SliceValue,
unmarshal: consumeSint32SliceValue,
}
// sizeSint32PackedSliceValue returns the size of wire encoding a []int32 value as a packed repeated Sint32.
func sizeSint32PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
list := listv.List()
n := 0
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
n += wire.SizeVarint(wire.EncodeZigZag(int64(int32(v.Int()))))
}
return tagsize + wire.SizeBytes(n)
}
// appendSint32PackedSliceValue encodes a []int32 value as a packed repeated Sint32.
func appendSint32PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
list := listv.List()
llen := list.Len()
if llen == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
n := 0
for i := 0; i < llen; i++ {
v := list.Get(i)
n += wire.SizeVarint(wire.EncodeZigZag(int64(int32(v.Int()))))
}
b = wire.AppendVarint(b, uint64(n))
for i := 0; i < llen; i++ {
v := list.Get(i)
b = wire.AppendVarint(b, wire.EncodeZigZag(int64(int32(v.Int()))))
}
return b, nil
}
var coderSint32PackedSliceValue = valueCoderFuncs{
size: sizeSint32PackedSliceValue,
marshal: appendSint32PackedSliceValue,
unmarshal: consumeSint32SliceValue,
}
// sizeUint32 returns the size of wire encoding a uint32 pointer as a Uint32.
func sizeUint32(p pointer, tagsize int, _ marshalOptions) (size int) {
v := *p.Uint32()
return tagsize + wire.SizeVarint(uint64(v))
}
// appendUint32 wire encodes a uint32 pointer as a Uint32.
func appendUint32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.Uint32()
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, uint64(v))
return b, nil
}
// consumeUint32 wire decodes a uint32 pointer as a Uint32.
func consumeUint32(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.VarintType {
return 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return 0, wire.ParseError(n)
}
*p.Uint32() = uint32(v)
return n, nil
}
var coderUint32 = pointerCoderFuncs{
size: sizeUint32,
marshal: appendUint32,
unmarshal: consumeUint32,
}
// sizeUint32NoZero returns the size of wire encoding a uint32 pointer as a Uint32.
// The zero value is not encoded.
func sizeUint32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
v := *p.Uint32()
if v == 0 {
return 0
}
return tagsize + wire.SizeVarint(uint64(v))
}
// appendUint32NoZero wire encodes a uint32 pointer as a Uint32.
// The zero value is not encoded.
func appendUint32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.Uint32()
if v == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, uint64(v))
return b, nil
}
var coderUint32NoZero = pointerCoderFuncs{
size: sizeUint32NoZero,
marshal: appendUint32NoZero,
unmarshal: consumeUint32,
}
// sizeUint32Ptr returns the size of wire encoding a *uint32 pointer as a Uint32.
// It panics if the pointer is nil.
func sizeUint32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
v := **p.Uint32Ptr()
return tagsize + wire.SizeVarint(uint64(v))
}
// appendUint32Ptr wire encodes a *uint32 pointer as a Uint32.
// It panics if the pointer is nil.
func appendUint32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := **p.Uint32Ptr()
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, uint64(v))
return b, nil
}
// consumeUint32Ptr wire decodes a *uint32 pointer as a Uint32.
func consumeUint32Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.VarintType {
return 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return 0, wire.ParseError(n)
}
vp := p.Uint32Ptr()
if *vp == nil {
*vp = new(uint32)
}
**vp = uint32(v)
return n, nil
}
var coderUint32Ptr = pointerCoderFuncs{
size: sizeUint32Ptr,
marshal: appendUint32Ptr,
unmarshal: consumeUint32Ptr,
}
// sizeUint32Slice returns the size of wire encoding a []uint32 pointer as a repeated Uint32.
func sizeUint32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
s := *p.Uint32Slice()
for _, v := range s {
size += tagsize + wire.SizeVarint(uint64(v))
}
return size
}
// appendUint32Slice encodes a []uint32 pointer as a repeated Uint32.
func appendUint32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
s := *p.Uint32Slice()
for _, v := range s {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, uint64(v))
}
return b, nil
}
// consumeUint32Slice wire decodes a []uint32 pointer as a repeated Uint32.
func consumeUint32Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
sp := p.Uint32Slice()
if wtyp == wire.BytesType {
s := *sp
b, n = wire.ConsumeBytes(b)
if n < 0 {
return 0, wire.ParseError(n)
}
for len(b) > 0 {
v, n := wire.ConsumeVarint(b)
if n < 0 {
return 0, wire.ParseError(n)
}
s = append(s, uint32(v))
b = b[n:]
}
*sp = s
return n, nil
}
if wtyp != wire.VarintType {
return 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return 0, wire.ParseError(n)
}
*sp = append(*sp, uint32(v))
return n, nil
}
var coderUint32Slice = pointerCoderFuncs{
size: sizeUint32Slice,
marshal: appendUint32Slice,
unmarshal: consumeUint32Slice,
}
// sizeUint32PackedSlice returns the size of wire encoding a []uint32 pointer as a packed repeated Uint32.
func sizeUint32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
s := *p.Uint32Slice()
if len(s) == 0 {
return 0
}
n := 0
for _, v := range s {
n += wire.SizeVarint(uint64(v))
}
return tagsize + wire.SizeBytes(n)
}
// appendUint32PackedSlice encodes a []uint32 pointer as a packed repeated Uint32.
func appendUint32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
s := *p.Uint32Slice()
if len(s) == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
n := 0
for _, v := range s {
n += wire.SizeVarint(uint64(v))
}
b = wire.AppendVarint(b, uint64(n))
for _, v := range s {
b = wire.AppendVarint(b, uint64(v))
}
return b, nil
}
var coderUint32PackedSlice = pointerCoderFuncs{
size: sizeUint32PackedSlice,
marshal: appendUint32PackedSlice,
unmarshal: consumeUint32Slice,
}
// sizeUint32Value returns the size of wire encoding a uint32 value as a Uint32.
func sizeUint32Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
return tagsize + wire.SizeVarint(uint64(uint32(v.Uint())))
}
// appendUint32Value encodes a uint32 value as a Uint32.
func appendUint32Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, uint64(uint32(v.Uint())))
return b, nil
}
// consumeUint32Value decodes a uint32 value as a Uint32.
func consumeUint32Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
if wtyp != wire.VarintType {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
return protoreflect.ValueOfUint32(uint32(v)), n, nil
}
var coderUint32Value = valueCoderFuncs{
size: sizeUint32Value,
marshal: appendUint32Value,
unmarshal: consumeUint32Value,
}
// sizeUint32SliceValue returns the size of wire encoding a []uint32 value as a repeated Uint32.
func sizeUint32SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
list := listv.List()
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
size += tagsize + wire.SizeVarint(uint64(uint32(v.Uint())))
}
return size
}
// appendUint32SliceValue encodes a []uint32 value as a repeated Uint32.
func appendUint32SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
list := listv.List()
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, uint64(uint32(v.Uint())))
}
return b, nil
}
// consumeUint32SliceValue wire decodes a []uint32 value as a repeated Uint32.
func consumeUint32SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
list := listv.List()
if wtyp == wire.BytesType {
b, n = wire.ConsumeBytes(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
for len(b) > 0 {
v, n := wire.ConsumeVarint(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
list.Append(protoreflect.ValueOfUint32(uint32(v)))
b = b[n:]
}
return listv, n, nil
}
if wtyp != wire.VarintType {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
list.Append(protoreflect.ValueOfUint32(uint32(v)))
return listv, n, nil
}
var coderUint32SliceValue = valueCoderFuncs{
size: sizeUint32SliceValue,
marshal: appendUint32SliceValue,
unmarshal: consumeUint32SliceValue,
}
// sizeUint32PackedSliceValue returns the size of wire encoding a []uint32 value as a packed repeated Uint32.
func sizeUint32PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
list := listv.List()
n := 0
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
n += wire.SizeVarint(uint64(uint32(v.Uint())))
}
return tagsize + wire.SizeBytes(n)
}
// appendUint32PackedSliceValue encodes a []uint32 value as a packed repeated Uint32.
func appendUint32PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
list := listv.List()
llen := list.Len()
if llen == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
n := 0
for i := 0; i < llen; i++ {
v := list.Get(i)
n += wire.SizeVarint(uint64(uint32(v.Uint())))
}
b = wire.AppendVarint(b, uint64(n))
for i := 0; i < llen; i++ {
v := list.Get(i)
b = wire.AppendVarint(b, uint64(uint32(v.Uint())))
}
return b, nil
}
var coderUint32PackedSliceValue = valueCoderFuncs{
size: sizeUint32PackedSliceValue,
marshal: appendUint32PackedSliceValue,
unmarshal: consumeUint32SliceValue,
}
// sizeInt64 returns the size of wire encoding a int64 pointer as a Int64.
func sizeInt64(p pointer, tagsize int, _ marshalOptions) (size int) {
v := *p.Int64()
return tagsize + wire.SizeVarint(uint64(v))
}
// appendInt64 wire encodes a int64 pointer as a Int64.
func appendInt64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.Int64()
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, uint64(v))
return b, nil
}
// consumeInt64 wire decodes a int64 pointer as a Int64.
func consumeInt64(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.VarintType {
return 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return 0, wire.ParseError(n)
}
*p.Int64() = int64(v)
return n, nil
}
var coderInt64 = pointerCoderFuncs{
size: sizeInt64,
marshal: appendInt64,
unmarshal: consumeInt64,
}
// sizeInt64NoZero returns the size of wire encoding a int64 pointer as a Int64.
// The zero value is not encoded.
func sizeInt64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
v := *p.Int64()
if v == 0 {
return 0
}
return tagsize + wire.SizeVarint(uint64(v))
}
// appendInt64NoZero wire encodes a int64 pointer as a Int64.
// The zero value is not encoded.
func appendInt64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.Int64()
if v == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, uint64(v))
return b, nil
}
var coderInt64NoZero = pointerCoderFuncs{
size: sizeInt64NoZero,
marshal: appendInt64NoZero,
unmarshal: consumeInt64,
}
// sizeInt64Ptr returns the size of wire encoding a *int64 pointer as a Int64.
// It panics if the pointer is nil.
func sizeInt64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
v := **p.Int64Ptr()
return tagsize + wire.SizeVarint(uint64(v))
}
// appendInt64Ptr wire encodes a *int64 pointer as a Int64.
// It panics if the pointer is nil.
func appendInt64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := **p.Int64Ptr()
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, uint64(v))
return b, nil
}
// consumeInt64Ptr wire decodes a *int64 pointer as a Int64.
func consumeInt64Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.VarintType {
return 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return 0, wire.ParseError(n)
}
vp := p.Int64Ptr()
if *vp == nil {
*vp = new(int64)
}
**vp = int64(v)
return n, nil
}
var coderInt64Ptr = pointerCoderFuncs{
size: sizeInt64Ptr,
marshal: appendInt64Ptr,
unmarshal: consumeInt64Ptr,
}
// sizeInt64Slice returns the size of wire encoding a []int64 pointer as a repeated Int64.
func sizeInt64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
s := *p.Int64Slice()
for _, v := range s {
size += tagsize + wire.SizeVarint(uint64(v))
}
return size
}
// appendInt64Slice encodes a []int64 pointer as a repeated Int64.
func appendInt64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
s := *p.Int64Slice()
for _, v := range s {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, uint64(v))
}
return b, nil
}
// consumeInt64Slice wire decodes a []int64 pointer as a repeated Int64.
func consumeInt64Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
sp := p.Int64Slice()
if wtyp == wire.BytesType {
s := *sp
b, n = wire.ConsumeBytes(b)
if n < 0 {
return 0, wire.ParseError(n)
}
for len(b) > 0 {
v, n := wire.ConsumeVarint(b)
if n < 0 {
return 0, wire.ParseError(n)
}
s = append(s, int64(v))
b = b[n:]
}
*sp = s
return n, nil
}
if wtyp != wire.VarintType {
return 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return 0, wire.ParseError(n)
}
*sp = append(*sp, int64(v))
return n, nil
}
var coderInt64Slice = pointerCoderFuncs{
size: sizeInt64Slice,
marshal: appendInt64Slice,
unmarshal: consumeInt64Slice,
}
// sizeInt64PackedSlice returns the size of wire encoding a []int64 pointer as a packed repeated Int64.
func sizeInt64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
s := *p.Int64Slice()
if len(s) == 0 {
return 0
}
n := 0
for _, v := range s {
n += wire.SizeVarint(uint64(v))
}
return tagsize + wire.SizeBytes(n)
}
// appendInt64PackedSlice encodes a []int64 pointer as a packed repeated Int64.
func appendInt64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
s := *p.Int64Slice()
if len(s) == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
n := 0
for _, v := range s {
n += wire.SizeVarint(uint64(v))
}
b = wire.AppendVarint(b, uint64(n))
for _, v := range s {
b = wire.AppendVarint(b, uint64(v))
}
return b, nil
}
var coderInt64PackedSlice = pointerCoderFuncs{
size: sizeInt64PackedSlice,
marshal: appendInt64PackedSlice,
unmarshal: consumeInt64Slice,
}
// sizeInt64Value returns the size of wire encoding a int64 value as a Int64.
func sizeInt64Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
return tagsize + wire.SizeVarint(uint64(v.Int()))
}
// appendInt64Value encodes a int64 value as a Int64.
func appendInt64Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, uint64(v.Int()))
return b, nil
}
// consumeInt64Value decodes a int64 value as a Int64.
func consumeInt64Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
if wtyp != wire.VarintType {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
return protoreflect.ValueOfInt64(int64(v)), n, nil
}
var coderInt64Value = valueCoderFuncs{
size: sizeInt64Value,
marshal: appendInt64Value,
unmarshal: consumeInt64Value,
}
// sizeInt64SliceValue returns the size of wire encoding a []int64 value as a repeated Int64.
func sizeInt64SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
list := listv.List()
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
size += tagsize + wire.SizeVarint(uint64(v.Int()))
}
return size
}
// appendInt64SliceValue encodes a []int64 value as a repeated Int64.
func appendInt64SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
list := listv.List()
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, uint64(v.Int()))
}
return b, nil
}
// consumeInt64SliceValue wire decodes a []int64 value as a repeated Int64.
func consumeInt64SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
list := listv.List()
if wtyp == wire.BytesType {
b, n = wire.ConsumeBytes(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
for len(b) > 0 {
v, n := wire.ConsumeVarint(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
list.Append(protoreflect.ValueOfInt64(int64(v)))
b = b[n:]
}
return listv, n, nil
}
if wtyp != wire.VarintType {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
list.Append(protoreflect.ValueOfInt64(int64(v)))
return listv, n, nil
}
var coderInt64SliceValue = valueCoderFuncs{
size: sizeInt64SliceValue,
marshal: appendInt64SliceValue,
unmarshal: consumeInt64SliceValue,
}
// sizeInt64PackedSliceValue returns the size of wire encoding a []int64 value as a packed repeated Int64.
func sizeInt64PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
list := listv.List()
n := 0
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
n += wire.SizeVarint(uint64(v.Int()))
}
return tagsize + wire.SizeBytes(n)
}
// appendInt64PackedSliceValue encodes a []int64 value as a packed repeated Int64.
func appendInt64PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
list := listv.List()
llen := list.Len()
if llen == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
n := 0
for i := 0; i < llen; i++ {
v := list.Get(i)
n += wire.SizeVarint(uint64(v.Int()))
}
b = wire.AppendVarint(b, uint64(n))
for i := 0; i < llen; i++ {
v := list.Get(i)
b = wire.AppendVarint(b, uint64(v.Int()))
}
return b, nil
}
var coderInt64PackedSliceValue = valueCoderFuncs{
size: sizeInt64PackedSliceValue,
marshal: appendInt64PackedSliceValue,
unmarshal: consumeInt64SliceValue,
}
// sizeSint64 returns the size of wire encoding a int64 pointer as a Sint64.
func sizeSint64(p pointer, tagsize int, _ marshalOptions) (size int) {
v := *p.Int64()
return tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
}
// appendSint64 wire encodes a int64 pointer as a Sint64.
func appendSint64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.Int64()
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, wire.EncodeZigZag(v))
return b, nil
}
// consumeSint64 wire decodes a int64 pointer as a Sint64.
func consumeSint64(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.VarintType {
return 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return 0, wire.ParseError(n)
}
*p.Int64() = wire.DecodeZigZag(v)
return n, nil
}
var coderSint64 = pointerCoderFuncs{
size: sizeSint64,
marshal: appendSint64,
unmarshal: consumeSint64,
}
// sizeSint64NoZero returns the size of wire encoding a int64 pointer as a Sint64.
// The zero value is not encoded.
func sizeSint64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
v := *p.Int64()
if v == 0 {
return 0
}
return tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
}
// appendSint64NoZero wire encodes a int64 pointer as a Sint64.
// The zero value is not encoded.
func appendSint64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.Int64()
if v == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, wire.EncodeZigZag(v))
return b, nil
}
var coderSint64NoZero = pointerCoderFuncs{
size: sizeSint64NoZero,
marshal: appendSint64NoZero,
unmarshal: consumeSint64,
}
// sizeSint64Ptr returns the size of wire encoding a *int64 pointer as a Sint64.
// It panics if the pointer is nil.
func sizeSint64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
v := **p.Int64Ptr()
return tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
}
// appendSint64Ptr wire encodes a *int64 pointer as a Sint64.
// It panics if the pointer is nil.
func appendSint64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := **p.Int64Ptr()
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, wire.EncodeZigZag(v))
return b, nil
}
// consumeSint64Ptr wire decodes a *int64 pointer as a Sint64.
func consumeSint64Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.VarintType {
return 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return 0, wire.ParseError(n)
}
vp := p.Int64Ptr()
if *vp == nil {
*vp = new(int64)
}
**vp = wire.DecodeZigZag(v)
return n, nil
}
var coderSint64Ptr = pointerCoderFuncs{
size: sizeSint64Ptr,
marshal: appendSint64Ptr,
unmarshal: consumeSint64Ptr,
}
// sizeSint64Slice returns the size of wire encoding a []int64 pointer as a repeated Sint64.
func sizeSint64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
s := *p.Int64Slice()
for _, v := range s {
size += tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
}
return size
}
// appendSint64Slice encodes a []int64 pointer as a repeated Sint64.
func appendSint64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
s := *p.Int64Slice()
for _, v := range s {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, wire.EncodeZigZag(v))
}
return b, nil
}
// consumeSint64Slice wire decodes a []int64 pointer as a repeated Sint64.
func consumeSint64Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
sp := p.Int64Slice()
if wtyp == wire.BytesType {
s := *sp
b, n = wire.ConsumeBytes(b)
if n < 0 {
return 0, wire.ParseError(n)
}
for len(b) > 0 {
v, n := wire.ConsumeVarint(b)
if n < 0 {
return 0, wire.ParseError(n)
}
s = append(s, wire.DecodeZigZag(v))
b = b[n:]
}
*sp = s
return n, nil
}
if wtyp != wire.VarintType {
return 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return 0, wire.ParseError(n)
}
*sp = append(*sp, wire.DecodeZigZag(v))
return n, nil
}
var coderSint64Slice = pointerCoderFuncs{
size: sizeSint64Slice,
marshal: appendSint64Slice,
unmarshal: consumeSint64Slice,
}
// sizeSint64PackedSlice returns the size of wire encoding a []int64 pointer as a packed repeated Sint64.
func sizeSint64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
s := *p.Int64Slice()
if len(s) == 0 {
return 0
}
n := 0
for _, v := range s {
n += wire.SizeVarint(wire.EncodeZigZag(v))
}
return tagsize + wire.SizeBytes(n)
}
// appendSint64PackedSlice encodes a []int64 pointer as a packed repeated Sint64.
func appendSint64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
s := *p.Int64Slice()
if len(s) == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
n := 0
for _, v := range s {
n += wire.SizeVarint(wire.EncodeZigZag(v))
}
b = wire.AppendVarint(b, uint64(n))
for _, v := range s {
b = wire.AppendVarint(b, wire.EncodeZigZag(v))
}
return b, nil
}
var coderSint64PackedSlice = pointerCoderFuncs{
size: sizeSint64PackedSlice,
marshal: appendSint64PackedSlice,
unmarshal: consumeSint64Slice,
}
// sizeSint64Value returns the size of wire encoding a int64 value as a Sint64.
func sizeSint64Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
return tagsize + wire.SizeVarint(wire.EncodeZigZag(v.Int()))
}
// appendSint64Value encodes a int64 value as a Sint64.
func appendSint64Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, wire.EncodeZigZag(v.Int()))
return b, nil
}
// consumeSint64Value decodes a int64 value as a Sint64.
func consumeSint64Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
if wtyp != wire.VarintType {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
return protoreflect.ValueOfInt64(wire.DecodeZigZag(v)), n, nil
}
var coderSint64Value = valueCoderFuncs{
size: sizeSint64Value,
marshal: appendSint64Value,
unmarshal: consumeSint64Value,
}
// sizeSint64SliceValue returns the size of wire encoding a []int64 value as a repeated Sint64.
func sizeSint64SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
list := listv.List()
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
size += tagsize + wire.SizeVarint(wire.EncodeZigZag(v.Int()))
}
return size
}
// appendSint64SliceValue encodes a []int64 value as a repeated Sint64.
func appendSint64SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
list := listv.List()
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, wire.EncodeZigZag(v.Int()))
}
return b, nil
}
// consumeSint64SliceValue wire decodes a []int64 value as a repeated Sint64.
func consumeSint64SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
list := listv.List()
if wtyp == wire.BytesType {
b, n = wire.ConsumeBytes(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
for len(b) > 0 {
v, n := wire.ConsumeVarint(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
list.Append(protoreflect.ValueOfInt64(wire.DecodeZigZag(v)))
b = b[n:]
}
return listv, n, nil
}
if wtyp != wire.VarintType {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
list.Append(protoreflect.ValueOfInt64(wire.DecodeZigZag(v)))
return listv, n, nil
}
var coderSint64SliceValue = valueCoderFuncs{
size: sizeSint64SliceValue,
marshal: appendSint64SliceValue,
unmarshal: consumeSint64SliceValue,
}
// sizeSint64PackedSliceValue returns the size of wire encoding a []int64 value as a packed repeated Sint64.
func sizeSint64PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
list := listv.List()
n := 0
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
n += wire.SizeVarint(wire.EncodeZigZag(v.Int()))
}
return tagsize + wire.SizeBytes(n)
}
// appendSint64PackedSliceValue encodes a []int64 value as a packed repeated Sint64.
func appendSint64PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
list := listv.List()
llen := list.Len()
if llen == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
n := 0
for i := 0; i < llen; i++ {
v := list.Get(i)
n += wire.SizeVarint(wire.EncodeZigZag(v.Int()))
}
b = wire.AppendVarint(b, uint64(n))
for i := 0; i < llen; i++ {
v := list.Get(i)
b = wire.AppendVarint(b, wire.EncodeZigZag(v.Int()))
}
return b, nil
}
var coderSint64PackedSliceValue = valueCoderFuncs{
size: sizeSint64PackedSliceValue,
marshal: appendSint64PackedSliceValue,
unmarshal: consumeSint64SliceValue,
}
// sizeUint64 returns the size of wire encoding a uint64 pointer as a Uint64.
func sizeUint64(p pointer, tagsize int, _ marshalOptions) (size int) {
v := *p.Uint64()
return tagsize + wire.SizeVarint(v)
}
// appendUint64 wire encodes a uint64 pointer as a Uint64.
func appendUint64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.Uint64()
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, v)
return b, nil
}
// consumeUint64 wire decodes a uint64 pointer as a Uint64.
func consumeUint64(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.VarintType {
return 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return 0, wire.ParseError(n)
}
*p.Uint64() = v
return n, nil
}
var coderUint64 = pointerCoderFuncs{
size: sizeUint64,
marshal: appendUint64,
unmarshal: consumeUint64,
}
// sizeUint64NoZero returns the size of wire encoding a uint64 pointer as a Uint64.
// The zero value is not encoded.
func sizeUint64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
v := *p.Uint64()
if v == 0 {
return 0
}
return tagsize + wire.SizeVarint(v)
}
// appendUint64NoZero wire encodes a uint64 pointer as a Uint64.
// The zero value is not encoded.
func appendUint64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.Uint64()
if v == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, v)
return b, nil
}
var coderUint64NoZero = pointerCoderFuncs{
size: sizeUint64NoZero,
marshal: appendUint64NoZero,
unmarshal: consumeUint64,
}
// sizeUint64Ptr returns the size of wire encoding a *uint64 pointer as a Uint64.
// It panics if the pointer is nil.
func sizeUint64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
v := **p.Uint64Ptr()
return tagsize + wire.SizeVarint(v)
}
// appendUint64Ptr wire encodes a *uint64 pointer as a Uint64.
// It panics if the pointer is nil.
func appendUint64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := **p.Uint64Ptr()
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, v)
return b, nil
}
// consumeUint64Ptr wire decodes a *uint64 pointer as a Uint64.
func consumeUint64Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.VarintType {
return 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return 0, wire.ParseError(n)
}
vp := p.Uint64Ptr()
if *vp == nil {
*vp = new(uint64)
}
**vp = v
return n, nil
}
var coderUint64Ptr = pointerCoderFuncs{
size: sizeUint64Ptr,
marshal: appendUint64Ptr,
unmarshal: consumeUint64Ptr,
}
// sizeUint64Slice returns the size of wire encoding a []uint64 pointer as a repeated Uint64.
func sizeUint64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
s := *p.Uint64Slice()
for _, v := range s {
size += tagsize + wire.SizeVarint(v)
}
return size
}
// appendUint64Slice encodes a []uint64 pointer as a repeated Uint64.
func appendUint64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
s := *p.Uint64Slice()
for _, v := range s {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, v)
}
return b, nil
}
// consumeUint64Slice wire decodes a []uint64 pointer as a repeated Uint64.
func consumeUint64Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
sp := p.Uint64Slice()
if wtyp == wire.BytesType {
s := *sp
b, n = wire.ConsumeBytes(b)
if n < 0 {
return 0, wire.ParseError(n)
}
for len(b) > 0 {
v, n := wire.ConsumeVarint(b)
if n < 0 {
return 0, wire.ParseError(n)
}
s = append(s, v)
b = b[n:]
}
*sp = s
return n, nil
}
if wtyp != wire.VarintType {
return 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return 0, wire.ParseError(n)
}
*sp = append(*sp, v)
return n, nil
}
var coderUint64Slice = pointerCoderFuncs{
size: sizeUint64Slice,
marshal: appendUint64Slice,
unmarshal: consumeUint64Slice,
}
// sizeUint64PackedSlice returns the size of wire encoding a []uint64 pointer as a packed repeated Uint64.
func sizeUint64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
s := *p.Uint64Slice()
if len(s) == 0 {
return 0
}
n := 0
for _, v := range s {
n += wire.SizeVarint(v)
}
return tagsize + wire.SizeBytes(n)
}
// appendUint64PackedSlice encodes a []uint64 pointer as a packed repeated Uint64.
func appendUint64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
s := *p.Uint64Slice()
if len(s) == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
n := 0
for _, v := range s {
n += wire.SizeVarint(v)
}
b = wire.AppendVarint(b, uint64(n))
for _, v := range s {
b = wire.AppendVarint(b, v)
}
return b, nil
}
var coderUint64PackedSlice = pointerCoderFuncs{
size: sizeUint64PackedSlice,
marshal: appendUint64PackedSlice,
unmarshal: consumeUint64Slice,
}
// sizeUint64Value returns the size of wire encoding a uint64 value as a Uint64.
func sizeUint64Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
return tagsize + wire.SizeVarint(v.Uint())
}
// appendUint64Value encodes a uint64 value as a Uint64.
func appendUint64Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, v.Uint())
return b, nil
}
// consumeUint64Value decodes a uint64 value as a Uint64.
func consumeUint64Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
if wtyp != wire.VarintType {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
return protoreflect.ValueOfUint64(v), n, nil
}
var coderUint64Value = valueCoderFuncs{
size: sizeUint64Value,
marshal: appendUint64Value,
unmarshal: consumeUint64Value,
}
// sizeUint64SliceValue returns the size of wire encoding a []uint64 value as a repeated Uint64.
func sizeUint64SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
list := listv.List()
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
size += tagsize + wire.SizeVarint(v.Uint())
}
return size
}
// appendUint64SliceValue encodes a []uint64 value as a repeated Uint64.
func appendUint64SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
list := listv.List()
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
b = wire.AppendVarint(b, wiretag)
b = wire.AppendVarint(b, v.Uint())
}
return b, nil
}
// consumeUint64SliceValue wire decodes a []uint64 value as a repeated Uint64.
func consumeUint64SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
list := listv.List()
if wtyp == wire.BytesType {
b, n = wire.ConsumeBytes(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
for len(b) > 0 {
v, n := wire.ConsumeVarint(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
list.Append(protoreflect.ValueOfUint64(v))
b = b[n:]
}
return listv, n, nil
}
if wtyp != wire.VarintType {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeVarint(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
list.Append(protoreflect.ValueOfUint64(v))
return listv, n, nil
}
var coderUint64SliceValue = valueCoderFuncs{
size: sizeUint64SliceValue,
marshal: appendUint64SliceValue,
unmarshal: consumeUint64SliceValue,
}
// sizeUint64PackedSliceValue returns the size of wire encoding a []uint64 value as a packed repeated Uint64.
func sizeUint64PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
list := listv.List()
n := 0
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
n += wire.SizeVarint(v.Uint())
}
return tagsize + wire.SizeBytes(n)
}
// appendUint64PackedSliceValue encodes a []uint64 value as a packed repeated Uint64.
func appendUint64PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
list := listv.List()
llen := list.Len()
if llen == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
n := 0
for i := 0; i < llen; i++ {
v := list.Get(i)
n += wire.SizeVarint(v.Uint())
}
b = wire.AppendVarint(b, uint64(n))
for i := 0; i < llen; i++ {
v := list.Get(i)
b = wire.AppendVarint(b, v.Uint())
}
return b, nil
}
var coderUint64PackedSliceValue = valueCoderFuncs{
size: sizeUint64PackedSliceValue,
marshal: appendUint64PackedSliceValue,
unmarshal: consumeUint64SliceValue,
}
// sizeSfixed32 returns the size of wire encoding a int32 pointer as a Sfixed32.
func sizeSfixed32(p pointer, tagsize int, _ marshalOptions) (size int) {
return tagsize + wire.SizeFixed32()
}
// appendSfixed32 wire encodes a int32 pointer as a Sfixed32.
func appendSfixed32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.Int32()
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed32(b, uint32(v))
return b, nil
}
// consumeSfixed32 wire decodes a int32 pointer as a Sfixed32.
func consumeSfixed32(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.Fixed32Type {
return 0, errUnknown
}
v, n := wire.ConsumeFixed32(b)
if n < 0 {
return 0, wire.ParseError(n)
}
*p.Int32() = int32(v)
return n, nil
}
var coderSfixed32 = pointerCoderFuncs{
size: sizeSfixed32,
marshal: appendSfixed32,
unmarshal: consumeSfixed32,
}
// sizeSfixed32NoZero returns the size of wire encoding a int32 pointer as a Sfixed32.
// The zero value is not encoded.
func sizeSfixed32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
v := *p.Int32()
if v == 0 {
return 0
}
return tagsize + wire.SizeFixed32()
}
// appendSfixed32NoZero wire encodes a int32 pointer as a Sfixed32.
// The zero value is not encoded.
func appendSfixed32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.Int32()
if v == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed32(b, uint32(v))
return b, nil
}
var coderSfixed32NoZero = pointerCoderFuncs{
size: sizeSfixed32NoZero,
marshal: appendSfixed32NoZero,
unmarshal: consumeSfixed32,
}
// sizeSfixed32Ptr returns the size of wire encoding a *int32 pointer as a Sfixed32.
// It panics if the pointer is nil.
func sizeSfixed32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
return tagsize + wire.SizeFixed32()
}
// appendSfixed32Ptr wire encodes a *int32 pointer as a Sfixed32.
// It panics if the pointer is nil.
func appendSfixed32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := **p.Int32Ptr()
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed32(b, uint32(v))
return b, nil
}
// consumeSfixed32Ptr wire decodes a *int32 pointer as a Sfixed32.
func consumeSfixed32Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.Fixed32Type {
return 0, errUnknown
}
v, n := wire.ConsumeFixed32(b)
if n < 0 {
return 0, wire.ParseError(n)
}
vp := p.Int32Ptr()
if *vp == nil {
*vp = new(int32)
}
**vp = int32(v)
return n, nil
}
var coderSfixed32Ptr = pointerCoderFuncs{
size: sizeSfixed32Ptr,
marshal: appendSfixed32Ptr,
unmarshal: consumeSfixed32Ptr,
}
// sizeSfixed32Slice returns the size of wire encoding a []int32 pointer as a repeated Sfixed32.
func sizeSfixed32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
s := *p.Int32Slice()
size = len(s) * (tagsize + wire.SizeFixed32())
return size
}
// appendSfixed32Slice encodes a []int32 pointer as a repeated Sfixed32.
func appendSfixed32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
s := *p.Int32Slice()
for _, v := range s {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed32(b, uint32(v))
}
return b, nil
}
// consumeSfixed32Slice wire decodes a []int32 pointer as a repeated Sfixed32.
func consumeSfixed32Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
sp := p.Int32Slice()
if wtyp == wire.BytesType {
s := *sp
b, n = wire.ConsumeBytes(b)
if n < 0 {
return 0, wire.ParseError(n)
}
for len(b) > 0 {
v, n := wire.ConsumeFixed32(b)
if n < 0 {
return 0, wire.ParseError(n)
}
s = append(s, int32(v))
b = b[n:]
}
*sp = s
return n, nil
}
if wtyp != wire.Fixed32Type {
return 0, errUnknown
}
v, n := wire.ConsumeFixed32(b)
if n < 0 {
return 0, wire.ParseError(n)
}
*sp = append(*sp, int32(v))
return n, nil
}
var coderSfixed32Slice = pointerCoderFuncs{
size: sizeSfixed32Slice,
marshal: appendSfixed32Slice,
unmarshal: consumeSfixed32Slice,
}
// sizeSfixed32PackedSlice returns the size of wire encoding a []int32 pointer as a packed repeated Sfixed32.
func sizeSfixed32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
s := *p.Int32Slice()
if len(s) == 0 {
return 0
}
n := len(s) * wire.SizeFixed32()
return tagsize + wire.SizeBytes(n)
}
// appendSfixed32PackedSlice encodes a []int32 pointer as a packed repeated Sfixed32.
func appendSfixed32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
s := *p.Int32Slice()
if len(s) == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
n := len(s) * wire.SizeFixed32()
b = wire.AppendVarint(b, uint64(n))
for _, v := range s {
b = wire.AppendFixed32(b, uint32(v))
}
return b, nil
}
var coderSfixed32PackedSlice = pointerCoderFuncs{
size: sizeSfixed32PackedSlice,
marshal: appendSfixed32PackedSlice,
unmarshal: consumeSfixed32Slice,
}
// sizeSfixed32Value returns the size of wire encoding a int32 value as a Sfixed32.
func sizeSfixed32Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
return tagsize + wire.SizeFixed32()
}
// appendSfixed32Value encodes a int32 value as a Sfixed32.
func appendSfixed32Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed32(b, uint32(v.Int()))
return b, nil
}
// consumeSfixed32Value decodes a int32 value as a Sfixed32.
func consumeSfixed32Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
if wtyp != wire.Fixed32Type {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeFixed32(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
return protoreflect.ValueOfInt32(int32(v)), n, nil
}
var coderSfixed32Value = valueCoderFuncs{
size: sizeSfixed32Value,
marshal: appendSfixed32Value,
unmarshal: consumeSfixed32Value,
}
// sizeSfixed32SliceValue returns the size of wire encoding a []int32 value as a repeated Sfixed32.
func sizeSfixed32SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
list := listv.List()
size = list.Len() * (tagsize + wire.SizeFixed32())
return size
}
// appendSfixed32SliceValue encodes a []int32 value as a repeated Sfixed32.
func appendSfixed32SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
list := listv.List()
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed32(b, uint32(v.Int()))
}
return b, nil
}
// consumeSfixed32SliceValue wire decodes a []int32 value as a repeated Sfixed32.
func consumeSfixed32SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
list := listv.List()
if wtyp == wire.BytesType {
b, n = wire.ConsumeBytes(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
for len(b) > 0 {
v, n := wire.ConsumeFixed32(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
list.Append(protoreflect.ValueOfInt32(int32(v)))
b = b[n:]
}
return listv, n, nil
}
if wtyp != wire.Fixed32Type {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeFixed32(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
list.Append(protoreflect.ValueOfInt32(int32(v)))
return listv, n, nil
}
var coderSfixed32SliceValue = valueCoderFuncs{
size: sizeSfixed32SliceValue,
marshal: appendSfixed32SliceValue,
unmarshal: consumeSfixed32SliceValue,
}
// sizeSfixed32PackedSliceValue returns the size of wire encoding a []int32 value as a packed repeated Sfixed32.
func sizeSfixed32PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
list := listv.List()
n := list.Len() * wire.SizeFixed32()
return tagsize + wire.SizeBytes(n)
}
// appendSfixed32PackedSliceValue encodes a []int32 value as a packed repeated Sfixed32.
func appendSfixed32PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
list := listv.List()
llen := list.Len()
if llen == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
n := llen * wire.SizeFixed32()
b = wire.AppendVarint(b, uint64(n))
for i := 0; i < llen; i++ {
v := list.Get(i)
b = wire.AppendFixed32(b, uint32(v.Int()))
}
return b, nil
}
var coderSfixed32PackedSliceValue = valueCoderFuncs{
size: sizeSfixed32PackedSliceValue,
marshal: appendSfixed32PackedSliceValue,
unmarshal: consumeSfixed32SliceValue,
}
// sizeFixed32 returns the size of wire encoding a uint32 pointer as a Fixed32.
func sizeFixed32(p pointer, tagsize int, _ marshalOptions) (size int) {
return tagsize + wire.SizeFixed32()
}
// appendFixed32 wire encodes a uint32 pointer as a Fixed32.
func appendFixed32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.Uint32()
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed32(b, v)
return b, nil
}
// consumeFixed32 wire decodes a uint32 pointer as a Fixed32.
func consumeFixed32(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.Fixed32Type {
return 0, errUnknown
}
v, n := wire.ConsumeFixed32(b)
if n < 0 {
return 0, wire.ParseError(n)
}
*p.Uint32() = v
return n, nil
}
var coderFixed32 = pointerCoderFuncs{
size: sizeFixed32,
marshal: appendFixed32,
unmarshal: consumeFixed32,
}
// sizeFixed32NoZero returns the size of wire encoding a uint32 pointer as a Fixed32.
// The zero value is not encoded.
func sizeFixed32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
v := *p.Uint32()
if v == 0 {
return 0
}
return tagsize + wire.SizeFixed32()
}
// appendFixed32NoZero wire encodes a uint32 pointer as a Fixed32.
// The zero value is not encoded.
func appendFixed32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.Uint32()
if v == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed32(b, v)
return b, nil
}
var coderFixed32NoZero = pointerCoderFuncs{
size: sizeFixed32NoZero,
marshal: appendFixed32NoZero,
unmarshal: consumeFixed32,
}
// sizeFixed32Ptr returns the size of wire encoding a *uint32 pointer as a Fixed32.
// It panics if the pointer is nil.
func sizeFixed32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
return tagsize + wire.SizeFixed32()
}
// appendFixed32Ptr wire encodes a *uint32 pointer as a Fixed32.
// It panics if the pointer is nil.
func appendFixed32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := **p.Uint32Ptr()
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed32(b, v)
return b, nil
}
// consumeFixed32Ptr wire decodes a *uint32 pointer as a Fixed32.
func consumeFixed32Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.Fixed32Type {
return 0, errUnknown
}
v, n := wire.ConsumeFixed32(b)
if n < 0 {
return 0, wire.ParseError(n)
}
vp := p.Uint32Ptr()
if *vp == nil {
*vp = new(uint32)
}
**vp = v
return n, nil
}
var coderFixed32Ptr = pointerCoderFuncs{
size: sizeFixed32Ptr,
marshal: appendFixed32Ptr,
unmarshal: consumeFixed32Ptr,
}
// sizeFixed32Slice returns the size of wire encoding a []uint32 pointer as a repeated Fixed32.
func sizeFixed32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
s := *p.Uint32Slice()
size = len(s) * (tagsize + wire.SizeFixed32())
return size
}
// appendFixed32Slice encodes a []uint32 pointer as a repeated Fixed32.
func appendFixed32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
s := *p.Uint32Slice()
for _, v := range s {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed32(b, v)
}
return b, nil
}
// consumeFixed32Slice wire decodes a []uint32 pointer as a repeated Fixed32.
func consumeFixed32Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
sp := p.Uint32Slice()
if wtyp == wire.BytesType {
s := *sp
b, n = wire.ConsumeBytes(b)
if n < 0 {
return 0, wire.ParseError(n)
}
for len(b) > 0 {
v, n := wire.ConsumeFixed32(b)
if n < 0 {
return 0, wire.ParseError(n)
}
s = append(s, v)
b = b[n:]
}
*sp = s
return n, nil
}
if wtyp != wire.Fixed32Type {
return 0, errUnknown
}
v, n := wire.ConsumeFixed32(b)
if n < 0 {
return 0, wire.ParseError(n)
}
*sp = append(*sp, v)
return n, nil
}
var coderFixed32Slice = pointerCoderFuncs{
size: sizeFixed32Slice,
marshal: appendFixed32Slice,
unmarshal: consumeFixed32Slice,
}
// sizeFixed32PackedSlice returns the size of wire encoding a []uint32 pointer as a packed repeated Fixed32.
func sizeFixed32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
s := *p.Uint32Slice()
if len(s) == 0 {
return 0
}
n := len(s) * wire.SizeFixed32()
return tagsize + wire.SizeBytes(n)
}
// appendFixed32PackedSlice encodes a []uint32 pointer as a packed repeated Fixed32.
func appendFixed32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
s := *p.Uint32Slice()
if len(s) == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
n := len(s) * wire.SizeFixed32()
b = wire.AppendVarint(b, uint64(n))
for _, v := range s {
b = wire.AppendFixed32(b, v)
}
return b, nil
}
var coderFixed32PackedSlice = pointerCoderFuncs{
size: sizeFixed32PackedSlice,
marshal: appendFixed32PackedSlice,
unmarshal: consumeFixed32Slice,
}
// sizeFixed32Value returns the size of wire encoding a uint32 value as a Fixed32.
func sizeFixed32Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
return tagsize + wire.SizeFixed32()
}
// appendFixed32Value encodes a uint32 value as a Fixed32.
func appendFixed32Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed32(b, uint32(v.Uint()))
return b, nil
}
// consumeFixed32Value decodes a uint32 value as a Fixed32.
func consumeFixed32Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
if wtyp != wire.Fixed32Type {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeFixed32(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
return protoreflect.ValueOfUint32(uint32(v)), n, nil
}
var coderFixed32Value = valueCoderFuncs{
size: sizeFixed32Value,
marshal: appendFixed32Value,
unmarshal: consumeFixed32Value,
}
// sizeFixed32SliceValue returns the size of wire encoding a []uint32 value as a repeated Fixed32.
func sizeFixed32SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
list := listv.List()
size = list.Len() * (tagsize + wire.SizeFixed32())
return size
}
// appendFixed32SliceValue encodes a []uint32 value as a repeated Fixed32.
func appendFixed32SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
list := listv.List()
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed32(b, uint32(v.Uint()))
}
return b, nil
}
// consumeFixed32SliceValue wire decodes a []uint32 value as a repeated Fixed32.
func consumeFixed32SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
list := listv.List()
if wtyp == wire.BytesType {
b, n = wire.ConsumeBytes(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
for len(b) > 0 {
v, n := wire.ConsumeFixed32(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
list.Append(protoreflect.ValueOfUint32(uint32(v)))
b = b[n:]
}
return listv, n, nil
}
if wtyp != wire.Fixed32Type {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeFixed32(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
list.Append(protoreflect.ValueOfUint32(uint32(v)))
return listv, n, nil
}
var coderFixed32SliceValue = valueCoderFuncs{
size: sizeFixed32SliceValue,
marshal: appendFixed32SliceValue,
unmarshal: consumeFixed32SliceValue,
}
// sizeFixed32PackedSliceValue returns the size of wire encoding a []uint32 value as a packed repeated Fixed32.
func sizeFixed32PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
list := listv.List()
n := list.Len() * wire.SizeFixed32()
return tagsize + wire.SizeBytes(n)
}
// appendFixed32PackedSliceValue encodes a []uint32 value as a packed repeated Fixed32.
func appendFixed32PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
list := listv.List()
llen := list.Len()
if llen == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
n := llen * wire.SizeFixed32()
b = wire.AppendVarint(b, uint64(n))
for i := 0; i < llen; i++ {
v := list.Get(i)
b = wire.AppendFixed32(b, uint32(v.Uint()))
}
return b, nil
}
var coderFixed32PackedSliceValue = valueCoderFuncs{
size: sizeFixed32PackedSliceValue,
marshal: appendFixed32PackedSliceValue,
unmarshal: consumeFixed32SliceValue,
}
// sizeFloat returns the size of wire encoding a float32 pointer as a Float.
func sizeFloat(p pointer, tagsize int, _ marshalOptions) (size int) {
return tagsize + wire.SizeFixed32()
}
// appendFloat wire encodes a float32 pointer as a Float.
func appendFloat(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.Float32()
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed32(b, math.Float32bits(v))
return b, nil
}
// consumeFloat wire decodes a float32 pointer as a Float.
func consumeFloat(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.Fixed32Type {
return 0, errUnknown
}
v, n := wire.ConsumeFixed32(b)
if n < 0 {
return 0, wire.ParseError(n)
}
*p.Float32() = math.Float32frombits(v)
return n, nil
}
var coderFloat = pointerCoderFuncs{
size: sizeFloat,
marshal: appendFloat,
unmarshal: consumeFloat,
}
// sizeFloatNoZero returns the size of wire encoding a float32 pointer as a Float.
// The zero value is not encoded.
func sizeFloatNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
v := *p.Float32()
if v == 0 && !math.Signbit(float64(v)) {
return 0
}
return tagsize + wire.SizeFixed32()
}
// appendFloatNoZero wire encodes a float32 pointer as a Float.
// The zero value is not encoded.
func appendFloatNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.Float32()
if v == 0 && !math.Signbit(float64(v)) {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed32(b, math.Float32bits(v))
return b, nil
}
var coderFloatNoZero = pointerCoderFuncs{
size: sizeFloatNoZero,
marshal: appendFloatNoZero,
unmarshal: consumeFloat,
}
// sizeFloatPtr returns the size of wire encoding a *float32 pointer as a Float.
// It panics if the pointer is nil.
func sizeFloatPtr(p pointer, tagsize int, _ marshalOptions) (size int) {
return tagsize + wire.SizeFixed32()
}
// appendFloatPtr wire encodes a *float32 pointer as a Float.
// It panics if the pointer is nil.
func appendFloatPtr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := **p.Float32Ptr()
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed32(b, math.Float32bits(v))
return b, nil
}
// consumeFloatPtr wire decodes a *float32 pointer as a Float.
func consumeFloatPtr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.Fixed32Type {
return 0, errUnknown
}
v, n := wire.ConsumeFixed32(b)
if n < 0 {
return 0, wire.ParseError(n)
}
vp := p.Float32Ptr()
if *vp == nil {
*vp = new(float32)
}
**vp = math.Float32frombits(v)
return n, nil
}
var coderFloatPtr = pointerCoderFuncs{
size: sizeFloatPtr,
marshal: appendFloatPtr,
unmarshal: consumeFloatPtr,
}
// sizeFloatSlice returns the size of wire encoding a []float32 pointer as a repeated Float.
func sizeFloatSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
s := *p.Float32Slice()
size = len(s) * (tagsize + wire.SizeFixed32())
return size
}
// appendFloatSlice encodes a []float32 pointer as a repeated Float.
func appendFloatSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
s := *p.Float32Slice()
for _, v := range s {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed32(b, math.Float32bits(v))
}
return b, nil
}
// consumeFloatSlice wire decodes a []float32 pointer as a repeated Float.
func consumeFloatSlice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
sp := p.Float32Slice()
if wtyp == wire.BytesType {
s := *sp
b, n = wire.ConsumeBytes(b)
if n < 0 {
return 0, wire.ParseError(n)
}
for len(b) > 0 {
v, n := wire.ConsumeFixed32(b)
if n < 0 {
return 0, wire.ParseError(n)
}
s = append(s, math.Float32frombits(v))
b = b[n:]
}
*sp = s
return n, nil
}
if wtyp != wire.Fixed32Type {
return 0, errUnknown
}
v, n := wire.ConsumeFixed32(b)
if n < 0 {
return 0, wire.ParseError(n)
}
*sp = append(*sp, math.Float32frombits(v))
return n, nil
}
var coderFloatSlice = pointerCoderFuncs{
size: sizeFloatSlice,
marshal: appendFloatSlice,
unmarshal: consumeFloatSlice,
}
// sizeFloatPackedSlice returns the size of wire encoding a []float32 pointer as a packed repeated Float.
func sizeFloatPackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
s := *p.Float32Slice()
if len(s) == 0 {
return 0
}
n := len(s) * wire.SizeFixed32()
return tagsize + wire.SizeBytes(n)
}
// appendFloatPackedSlice encodes a []float32 pointer as a packed repeated Float.
func appendFloatPackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
s := *p.Float32Slice()
if len(s) == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
n := len(s) * wire.SizeFixed32()
b = wire.AppendVarint(b, uint64(n))
for _, v := range s {
b = wire.AppendFixed32(b, math.Float32bits(v))
}
return b, nil
}
var coderFloatPackedSlice = pointerCoderFuncs{
size: sizeFloatPackedSlice,
marshal: appendFloatPackedSlice,
unmarshal: consumeFloatSlice,
}
// sizeFloatValue returns the size of wire encoding a float32 value as a Float.
func sizeFloatValue(v protoreflect.Value, tagsize int, _ marshalOptions) int {
return tagsize + wire.SizeFixed32()
}
// appendFloatValue encodes a float32 value as a Float.
func appendFloatValue(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed32(b, math.Float32bits(float32(v.Float())))
return b, nil
}
// consumeFloatValue decodes a float32 value as a Float.
func consumeFloatValue(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
if wtyp != wire.Fixed32Type {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeFixed32(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
return protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))), n, nil
}
var coderFloatValue = valueCoderFuncs{
size: sizeFloatValue,
marshal: appendFloatValue,
unmarshal: consumeFloatValue,
}
// sizeFloatSliceValue returns the size of wire encoding a []float32 value as a repeated Float.
func sizeFloatSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
list := listv.List()
size = list.Len() * (tagsize + wire.SizeFixed32())
return size
}
// appendFloatSliceValue encodes a []float32 value as a repeated Float.
func appendFloatSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
list := listv.List()
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed32(b, math.Float32bits(float32(v.Float())))
}
return b, nil
}
// consumeFloatSliceValue wire decodes a []float32 value as a repeated Float.
func consumeFloatSliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
list := listv.List()
if wtyp == wire.BytesType {
b, n = wire.ConsumeBytes(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
for len(b) > 0 {
v, n := wire.ConsumeFixed32(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
list.Append(protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))))
b = b[n:]
}
return listv, n, nil
}
if wtyp != wire.Fixed32Type {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeFixed32(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
list.Append(protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))))
return listv, n, nil
}
var coderFloatSliceValue = valueCoderFuncs{
size: sizeFloatSliceValue,
marshal: appendFloatSliceValue,
unmarshal: consumeFloatSliceValue,
}
// sizeFloatPackedSliceValue returns the size of wire encoding a []float32 value as a packed repeated Float.
func sizeFloatPackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
list := listv.List()
n := list.Len() * wire.SizeFixed32()
return tagsize + wire.SizeBytes(n)
}
// appendFloatPackedSliceValue encodes a []float32 value as a packed repeated Float.
func appendFloatPackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
list := listv.List()
llen := list.Len()
if llen == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
n := llen * wire.SizeFixed32()
b = wire.AppendVarint(b, uint64(n))
for i := 0; i < llen; i++ {
v := list.Get(i)
b = wire.AppendFixed32(b, math.Float32bits(float32(v.Float())))
}
return b, nil
}
var coderFloatPackedSliceValue = valueCoderFuncs{
size: sizeFloatPackedSliceValue,
marshal: appendFloatPackedSliceValue,
unmarshal: consumeFloatSliceValue,
}
// sizeSfixed64 returns the size of wire encoding a int64 pointer as a Sfixed64.
func sizeSfixed64(p pointer, tagsize int, _ marshalOptions) (size int) {
return tagsize + wire.SizeFixed64()
}
// appendSfixed64 wire encodes a int64 pointer as a Sfixed64.
func appendSfixed64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.Int64()
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed64(b, uint64(v))
return b, nil
}
// consumeSfixed64 wire decodes a int64 pointer as a Sfixed64.
func consumeSfixed64(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.Fixed64Type {
return 0, errUnknown
}
v, n := wire.ConsumeFixed64(b)
if n < 0 {
return 0, wire.ParseError(n)
}
*p.Int64() = int64(v)
return n, nil
}
var coderSfixed64 = pointerCoderFuncs{
size: sizeSfixed64,
marshal: appendSfixed64,
unmarshal: consumeSfixed64,
}
// sizeSfixed64NoZero returns the size of wire encoding a int64 pointer as a Sfixed64.
// The zero value is not encoded.
func sizeSfixed64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
v := *p.Int64()
if v == 0 {
return 0
}
return tagsize + wire.SizeFixed64()
}
// appendSfixed64NoZero wire encodes a int64 pointer as a Sfixed64.
// The zero value is not encoded.
func appendSfixed64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.Int64()
if v == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed64(b, uint64(v))
return b, nil
}
var coderSfixed64NoZero = pointerCoderFuncs{
size: sizeSfixed64NoZero,
marshal: appendSfixed64NoZero,
unmarshal: consumeSfixed64,
}
// sizeSfixed64Ptr returns the size of wire encoding a *int64 pointer as a Sfixed64.
// It panics if the pointer is nil.
func sizeSfixed64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
return tagsize + wire.SizeFixed64()
}
// appendSfixed64Ptr wire encodes a *int64 pointer as a Sfixed64.
// It panics if the pointer is nil.
func appendSfixed64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := **p.Int64Ptr()
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed64(b, uint64(v))
return b, nil
}
// consumeSfixed64Ptr wire decodes a *int64 pointer as a Sfixed64.
func consumeSfixed64Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.Fixed64Type {
return 0, errUnknown
}
v, n := wire.ConsumeFixed64(b)
if n < 0 {
return 0, wire.ParseError(n)
}
vp := p.Int64Ptr()
if *vp == nil {
*vp = new(int64)
}
**vp = int64(v)
return n, nil
}
var coderSfixed64Ptr = pointerCoderFuncs{
size: sizeSfixed64Ptr,
marshal: appendSfixed64Ptr,
unmarshal: consumeSfixed64Ptr,
}
// sizeSfixed64Slice returns the size of wire encoding a []int64 pointer as a repeated Sfixed64.
func sizeSfixed64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
s := *p.Int64Slice()
size = len(s) * (tagsize + wire.SizeFixed64())
return size
}
// appendSfixed64Slice encodes a []int64 pointer as a repeated Sfixed64.
func appendSfixed64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
s := *p.Int64Slice()
for _, v := range s {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed64(b, uint64(v))
}
return b, nil
}
// consumeSfixed64Slice wire decodes a []int64 pointer as a repeated Sfixed64.
func consumeSfixed64Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
sp := p.Int64Slice()
if wtyp == wire.BytesType {
s := *sp
b, n = wire.ConsumeBytes(b)
if n < 0 {
return 0, wire.ParseError(n)
}
for len(b) > 0 {
v, n := wire.ConsumeFixed64(b)
if n < 0 {
return 0, wire.ParseError(n)
}
s = append(s, int64(v))
b = b[n:]
}
*sp = s
return n, nil
}
if wtyp != wire.Fixed64Type {
return 0, errUnknown
}
v, n := wire.ConsumeFixed64(b)
if n < 0 {
return 0, wire.ParseError(n)
}
*sp = append(*sp, int64(v))
return n, nil
}
var coderSfixed64Slice = pointerCoderFuncs{
size: sizeSfixed64Slice,
marshal: appendSfixed64Slice,
unmarshal: consumeSfixed64Slice,
}
// sizeSfixed64PackedSlice returns the size of wire encoding a []int64 pointer as a packed repeated Sfixed64.
func sizeSfixed64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
s := *p.Int64Slice()
if len(s) == 0 {
return 0
}
n := len(s) * wire.SizeFixed64()
return tagsize + wire.SizeBytes(n)
}
// appendSfixed64PackedSlice encodes a []int64 pointer as a packed repeated Sfixed64.
func appendSfixed64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
s := *p.Int64Slice()
if len(s) == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
n := len(s) * wire.SizeFixed64()
b = wire.AppendVarint(b, uint64(n))
for _, v := range s {
b = wire.AppendFixed64(b, uint64(v))
}
return b, nil
}
var coderSfixed64PackedSlice = pointerCoderFuncs{
size: sizeSfixed64PackedSlice,
marshal: appendSfixed64PackedSlice,
unmarshal: consumeSfixed64Slice,
}
// sizeSfixed64Value returns the size of wire encoding a int64 value as a Sfixed64.
func sizeSfixed64Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
return tagsize + wire.SizeFixed64()
}
// appendSfixed64Value encodes a int64 value as a Sfixed64.
func appendSfixed64Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed64(b, uint64(v.Int()))
return b, nil
}
// consumeSfixed64Value decodes a int64 value as a Sfixed64.
func consumeSfixed64Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
if wtyp != wire.Fixed64Type {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeFixed64(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
return protoreflect.ValueOfInt64(int64(v)), n, nil
}
var coderSfixed64Value = valueCoderFuncs{
size: sizeSfixed64Value,
marshal: appendSfixed64Value,
unmarshal: consumeSfixed64Value,
}
// sizeSfixed64SliceValue returns the size of wire encoding a []int64 value as a repeated Sfixed64.
func sizeSfixed64SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
list := listv.List()
size = list.Len() * (tagsize + wire.SizeFixed64())
return size
}
// appendSfixed64SliceValue encodes a []int64 value as a repeated Sfixed64.
func appendSfixed64SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
list := listv.List()
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed64(b, uint64(v.Int()))
}
return b, nil
}
// consumeSfixed64SliceValue wire decodes a []int64 value as a repeated Sfixed64.
func consumeSfixed64SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
list := listv.List()
if wtyp == wire.BytesType {
b, n = wire.ConsumeBytes(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
for len(b) > 0 {
v, n := wire.ConsumeFixed64(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
list.Append(protoreflect.ValueOfInt64(int64(v)))
b = b[n:]
}
return listv, n, nil
}
if wtyp != wire.Fixed64Type {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeFixed64(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
list.Append(protoreflect.ValueOfInt64(int64(v)))
return listv, n, nil
}
var coderSfixed64SliceValue = valueCoderFuncs{
size: sizeSfixed64SliceValue,
marshal: appendSfixed64SliceValue,
unmarshal: consumeSfixed64SliceValue,
}
// sizeSfixed64PackedSliceValue returns the size of wire encoding a []int64 value as a packed repeated Sfixed64.
func sizeSfixed64PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
list := listv.List()
n := list.Len() * wire.SizeFixed64()
return tagsize + wire.SizeBytes(n)
}
// appendSfixed64PackedSliceValue encodes a []int64 value as a packed repeated Sfixed64.
func appendSfixed64PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
list := listv.List()
llen := list.Len()
if llen == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
n := llen * wire.SizeFixed64()
b = wire.AppendVarint(b, uint64(n))
for i := 0; i < llen; i++ {
v := list.Get(i)
b = wire.AppendFixed64(b, uint64(v.Int()))
}
return b, nil
}
var coderSfixed64PackedSliceValue = valueCoderFuncs{
size: sizeSfixed64PackedSliceValue,
marshal: appendSfixed64PackedSliceValue,
unmarshal: consumeSfixed64SliceValue,
}
// sizeFixed64 returns the size of wire encoding a uint64 pointer as a Fixed64.
func sizeFixed64(p pointer, tagsize int, _ marshalOptions) (size int) {
return tagsize + wire.SizeFixed64()
}
// appendFixed64 wire encodes a uint64 pointer as a Fixed64.
func appendFixed64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.Uint64()
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed64(b, v)
return b, nil
}
// consumeFixed64 wire decodes a uint64 pointer as a Fixed64.
func consumeFixed64(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.Fixed64Type {
return 0, errUnknown
}
v, n := wire.ConsumeFixed64(b)
if n < 0 {
return 0, wire.ParseError(n)
}
*p.Uint64() = v
return n, nil
}
var coderFixed64 = pointerCoderFuncs{
size: sizeFixed64,
marshal: appendFixed64,
unmarshal: consumeFixed64,
}
// sizeFixed64NoZero returns the size of wire encoding a uint64 pointer as a Fixed64.
// The zero value is not encoded.
func sizeFixed64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
v := *p.Uint64()
if v == 0 {
return 0
}
return tagsize + wire.SizeFixed64()
}
// appendFixed64NoZero wire encodes a uint64 pointer as a Fixed64.
// The zero value is not encoded.
func appendFixed64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.Uint64()
if v == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed64(b, v)
return b, nil
}
var coderFixed64NoZero = pointerCoderFuncs{
size: sizeFixed64NoZero,
marshal: appendFixed64NoZero,
unmarshal: consumeFixed64,
}
// sizeFixed64Ptr returns the size of wire encoding a *uint64 pointer as a Fixed64.
// It panics if the pointer is nil.
func sizeFixed64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
return tagsize + wire.SizeFixed64()
}
// appendFixed64Ptr wire encodes a *uint64 pointer as a Fixed64.
// It panics if the pointer is nil.
func appendFixed64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := **p.Uint64Ptr()
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed64(b, v)
return b, nil
}
// consumeFixed64Ptr wire decodes a *uint64 pointer as a Fixed64.
func consumeFixed64Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.Fixed64Type {
return 0, errUnknown
}
v, n := wire.ConsumeFixed64(b)
if n < 0 {
return 0, wire.ParseError(n)
}
vp := p.Uint64Ptr()
if *vp == nil {
*vp = new(uint64)
}
**vp = v
return n, nil
}
var coderFixed64Ptr = pointerCoderFuncs{
size: sizeFixed64Ptr,
marshal: appendFixed64Ptr,
unmarshal: consumeFixed64Ptr,
}
// sizeFixed64Slice returns the size of wire encoding a []uint64 pointer as a repeated Fixed64.
func sizeFixed64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
s := *p.Uint64Slice()
size = len(s) * (tagsize + wire.SizeFixed64())
return size
}
// appendFixed64Slice encodes a []uint64 pointer as a repeated Fixed64.
func appendFixed64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
s := *p.Uint64Slice()
for _, v := range s {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed64(b, v)
}
return b, nil
}
// consumeFixed64Slice wire decodes a []uint64 pointer as a repeated Fixed64.
func consumeFixed64Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
sp := p.Uint64Slice()
if wtyp == wire.BytesType {
s := *sp
b, n = wire.ConsumeBytes(b)
if n < 0 {
return 0, wire.ParseError(n)
}
for len(b) > 0 {
v, n := wire.ConsumeFixed64(b)
if n < 0 {
return 0, wire.ParseError(n)
}
s = append(s, v)
b = b[n:]
}
*sp = s
return n, nil
}
if wtyp != wire.Fixed64Type {
return 0, errUnknown
}
v, n := wire.ConsumeFixed64(b)
if n < 0 {
return 0, wire.ParseError(n)
}
*sp = append(*sp, v)
return n, nil
}
var coderFixed64Slice = pointerCoderFuncs{
size: sizeFixed64Slice,
marshal: appendFixed64Slice,
unmarshal: consumeFixed64Slice,
}
// sizeFixed64PackedSlice returns the size of wire encoding a []uint64 pointer as a packed repeated Fixed64.
func sizeFixed64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
s := *p.Uint64Slice()
if len(s) == 0 {
return 0
}
n := len(s) * wire.SizeFixed64()
return tagsize + wire.SizeBytes(n)
}
// appendFixed64PackedSlice encodes a []uint64 pointer as a packed repeated Fixed64.
func appendFixed64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
s := *p.Uint64Slice()
if len(s) == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
n := len(s) * wire.SizeFixed64()
b = wire.AppendVarint(b, uint64(n))
for _, v := range s {
b = wire.AppendFixed64(b, v)
}
return b, nil
}
var coderFixed64PackedSlice = pointerCoderFuncs{
size: sizeFixed64PackedSlice,
marshal: appendFixed64PackedSlice,
unmarshal: consumeFixed64Slice,
}
// sizeFixed64Value returns the size of wire encoding a uint64 value as a Fixed64.
func sizeFixed64Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
return tagsize + wire.SizeFixed64()
}
// appendFixed64Value encodes a uint64 value as a Fixed64.
func appendFixed64Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed64(b, v.Uint())
return b, nil
}
// consumeFixed64Value decodes a uint64 value as a Fixed64.
func consumeFixed64Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
if wtyp != wire.Fixed64Type {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeFixed64(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
return protoreflect.ValueOfUint64(v), n, nil
}
var coderFixed64Value = valueCoderFuncs{
size: sizeFixed64Value,
marshal: appendFixed64Value,
unmarshal: consumeFixed64Value,
}
// sizeFixed64SliceValue returns the size of wire encoding a []uint64 value as a repeated Fixed64.
func sizeFixed64SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
list := listv.List()
size = list.Len() * (tagsize + wire.SizeFixed64())
return size
}
// appendFixed64SliceValue encodes a []uint64 value as a repeated Fixed64.
func appendFixed64SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
list := listv.List()
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed64(b, v.Uint())
}
return b, nil
}
// consumeFixed64SliceValue wire decodes a []uint64 value as a repeated Fixed64.
func consumeFixed64SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
list := listv.List()
if wtyp == wire.BytesType {
b, n = wire.ConsumeBytes(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
for len(b) > 0 {
v, n := wire.ConsumeFixed64(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
list.Append(protoreflect.ValueOfUint64(v))
b = b[n:]
}
return listv, n, nil
}
if wtyp != wire.Fixed64Type {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeFixed64(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
list.Append(protoreflect.ValueOfUint64(v))
return listv, n, nil
}
var coderFixed64SliceValue = valueCoderFuncs{
size: sizeFixed64SliceValue,
marshal: appendFixed64SliceValue,
unmarshal: consumeFixed64SliceValue,
}
// sizeFixed64PackedSliceValue returns the size of wire encoding a []uint64 value as a packed repeated Fixed64.
func sizeFixed64PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
list := listv.List()
n := list.Len() * wire.SizeFixed64()
return tagsize + wire.SizeBytes(n)
}
// appendFixed64PackedSliceValue encodes a []uint64 value as a packed repeated Fixed64.
func appendFixed64PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
list := listv.List()
llen := list.Len()
if llen == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
n := llen * wire.SizeFixed64()
b = wire.AppendVarint(b, uint64(n))
for i := 0; i < llen; i++ {
v := list.Get(i)
b = wire.AppendFixed64(b, v.Uint())
}
return b, nil
}
var coderFixed64PackedSliceValue = valueCoderFuncs{
size: sizeFixed64PackedSliceValue,
marshal: appendFixed64PackedSliceValue,
unmarshal: consumeFixed64SliceValue,
}
// sizeDouble returns the size of wire encoding a float64 pointer as a Double.
func sizeDouble(p pointer, tagsize int, _ marshalOptions) (size int) {
return tagsize + wire.SizeFixed64()
}
// appendDouble wire encodes a float64 pointer as a Double.
func appendDouble(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.Float64()
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed64(b, math.Float64bits(v))
return b, nil
}
// consumeDouble wire decodes a float64 pointer as a Double.
func consumeDouble(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.Fixed64Type {
return 0, errUnknown
}
v, n := wire.ConsumeFixed64(b)
if n < 0 {
return 0, wire.ParseError(n)
}
*p.Float64() = math.Float64frombits(v)
return n, nil
}
var coderDouble = pointerCoderFuncs{
size: sizeDouble,
marshal: appendDouble,
unmarshal: consumeDouble,
}
// sizeDoubleNoZero returns the size of wire encoding a float64 pointer as a Double.
// The zero value is not encoded.
func sizeDoubleNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
v := *p.Float64()
if v == 0 && !math.Signbit(float64(v)) {
return 0
}
return tagsize + wire.SizeFixed64()
}
// appendDoubleNoZero wire encodes a float64 pointer as a Double.
// The zero value is not encoded.
func appendDoubleNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.Float64()
if v == 0 && !math.Signbit(float64(v)) {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed64(b, math.Float64bits(v))
return b, nil
}
var coderDoubleNoZero = pointerCoderFuncs{
size: sizeDoubleNoZero,
marshal: appendDoubleNoZero,
unmarshal: consumeDouble,
}
// sizeDoublePtr returns the size of wire encoding a *float64 pointer as a Double.
// It panics if the pointer is nil.
func sizeDoublePtr(p pointer, tagsize int, _ marshalOptions) (size int) {
return tagsize + wire.SizeFixed64()
}
// appendDoublePtr wire encodes a *float64 pointer as a Double.
// It panics if the pointer is nil.
func appendDoublePtr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := **p.Float64Ptr()
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed64(b, math.Float64bits(v))
return b, nil
}
// consumeDoublePtr wire decodes a *float64 pointer as a Double.
func consumeDoublePtr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.Fixed64Type {
return 0, errUnknown
}
v, n := wire.ConsumeFixed64(b)
if n < 0 {
return 0, wire.ParseError(n)
}
vp := p.Float64Ptr()
if *vp == nil {
*vp = new(float64)
}
**vp = math.Float64frombits(v)
return n, nil
}
var coderDoublePtr = pointerCoderFuncs{
size: sizeDoublePtr,
marshal: appendDoublePtr,
unmarshal: consumeDoublePtr,
}
// sizeDoubleSlice returns the size of wire encoding a []float64 pointer as a repeated Double.
func sizeDoubleSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
s := *p.Float64Slice()
size = len(s) * (tagsize + wire.SizeFixed64())
return size
}
// appendDoubleSlice encodes a []float64 pointer as a repeated Double.
func appendDoubleSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
s := *p.Float64Slice()
for _, v := range s {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed64(b, math.Float64bits(v))
}
return b, nil
}
// consumeDoubleSlice wire decodes a []float64 pointer as a repeated Double.
func consumeDoubleSlice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
sp := p.Float64Slice()
if wtyp == wire.BytesType {
s := *sp
b, n = wire.ConsumeBytes(b)
if n < 0 {
return 0, wire.ParseError(n)
}
for len(b) > 0 {
v, n := wire.ConsumeFixed64(b)
if n < 0 {
return 0, wire.ParseError(n)
}
s = append(s, math.Float64frombits(v))
b = b[n:]
}
*sp = s
return n, nil
}
if wtyp != wire.Fixed64Type {
return 0, errUnknown
}
v, n := wire.ConsumeFixed64(b)
if n < 0 {
return 0, wire.ParseError(n)
}
*sp = append(*sp, math.Float64frombits(v))
return n, nil
}
var coderDoubleSlice = pointerCoderFuncs{
size: sizeDoubleSlice,
marshal: appendDoubleSlice,
unmarshal: consumeDoubleSlice,
}
// sizeDoublePackedSlice returns the size of wire encoding a []float64 pointer as a packed repeated Double.
func sizeDoublePackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
s := *p.Float64Slice()
if len(s) == 0 {
return 0
}
n := len(s) * wire.SizeFixed64()
return tagsize + wire.SizeBytes(n)
}
// appendDoublePackedSlice encodes a []float64 pointer as a packed repeated Double.
func appendDoublePackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
s := *p.Float64Slice()
if len(s) == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
n := len(s) * wire.SizeFixed64()
b = wire.AppendVarint(b, uint64(n))
for _, v := range s {
b = wire.AppendFixed64(b, math.Float64bits(v))
}
return b, nil
}
var coderDoublePackedSlice = pointerCoderFuncs{
size: sizeDoublePackedSlice,
marshal: appendDoublePackedSlice,
unmarshal: consumeDoubleSlice,
}
// sizeDoubleValue returns the size of wire encoding a float64 value as a Double.
func sizeDoubleValue(v protoreflect.Value, tagsize int, _ marshalOptions) int {
return tagsize + wire.SizeFixed64()
}
// appendDoubleValue encodes a float64 value as a Double.
func appendDoubleValue(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed64(b, math.Float64bits(v.Float()))
return b, nil
}
// consumeDoubleValue decodes a float64 value as a Double.
func consumeDoubleValue(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
if wtyp != wire.Fixed64Type {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeFixed64(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
return protoreflect.ValueOfFloat64(math.Float64frombits(v)), n, nil
}
var coderDoubleValue = valueCoderFuncs{
size: sizeDoubleValue,
marshal: appendDoubleValue,
unmarshal: consumeDoubleValue,
}
// sizeDoubleSliceValue returns the size of wire encoding a []float64 value as a repeated Double.
func sizeDoubleSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
list := listv.List()
size = list.Len() * (tagsize + wire.SizeFixed64())
return size
}
// appendDoubleSliceValue encodes a []float64 value as a repeated Double.
func appendDoubleSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
list := listv.List()
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
b = wire.AppendVarint(b, wiretag)
b = wire.AppendFixed64(b, math.Float64bits(v.Float()))
}
return b, nil
}
// consumeDoubleSliceValue wire decodes a []float64 value as a repeated Double.
func consumeDoubleSliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
list := listv.List()
if wtyp == wire.BytesType {
b, n = wire.ConsumeBytes(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
for len(b) > 0 {
v, n := wire.ConsumeFixed64(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
list.Append(protoreflect.ValueOfFloat64(math.Float64frombits(v)))
b = b[n:]
}
return listv, n, nil
}
if wtyp != wire.Fixed64Type {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeFixed64(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
list.Append(protoreflect.ValueOfFloat64(math.Float64frombits(v)))
return listv, n, nil
}
var coderDoubleSliceValue = valueCoderFuncs{
size: sizeDoubleSliceValue,
marshal: appendDoubleSliceValue,
unmarshal: consumeDoubleSliceValue,
}
// sizeDoublePackedSliceValue returns the size of wire encoding a []float64 value as a packed repeated Double.
func sizeDoublePackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
list := listv.List()
n := list.Len() * wire.SizeFixed64()
return tagsize + wire.SizeBytes(n)
}
// appendDoublePackedSliceValue encodes a []float64 value as a packed repeated Double.
func appendDoublePackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
list := listv.List()
llen := list.Len()
if llen == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
n := llen * wire.SizeFixed64()
b = wire.AppendVarint(b, uint64(n))
for i := 0; i < llen; i++ {
v := list.Get(i)
b = wire.AppendFixed64(b, math.Float64bits(v.Float()))
}
return b, nil
}
var coderDoublePackedSliceValue = valueCoderFuncs{
size: sizeDoublePackedSliceValue,
marshal: appendDoublePackedSliceValue,
unmarshal: consumeDoubleSliceValue,
}
// sizeString returns the size of wire encoding a string pointer as a String.
func sizeString(p pointer, tagsize int, _ marshalOptions) (size int) {
v := *p.String()
return tagsize + wire.SizeBytes(len(v))
}
// appendString wire encodes a string pointer as a String.
func appendString(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.String()
b = wire.AppendVarint(b, wiretag)
b = wire.AppendString(b, v)
return b, nil
}
// consumeString wire decodes a string pointer as a String.
func consumeString(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.BytesType {
return 0, errUnknown
}
v, n := wire.ConsumeString(b)
if n < 0 {
return 0, wire.ParseError(n)
}
*p.String() = v
return n, nil
}
var coderString = pointerCoderFuncs{
size: sizeString,
marshal: appendString,
unmarshal: consumeString,
}
// appendStringValidateUTF8 wire encodes a string pointer as a String.
func appendStringValidateUTF8(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.String()
b = wire.AppendVarint(b, wiretag)
b = wire.AppendString(b, v)
if !utf8.ValidString(v) {
return b, errInvalidUTF8{}
}
return b, nil
}
// consumeStringValidateUTF8 wire decodes a string pointer as a String.
func consumeStringValidateUTF8(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.BytesType {
return 0, errUnknown
}
v, n := wire.ConsumeString(b)
if n < 0 {
return 0, wire.ParseError(n)
}
if !utf8.ValidString(v) {
return 0, errInvalidUTF8{}
}
*p.String() = v
return n, nil
}
var coderStringValidateUTF8 = pointerCoderFuncs{
size: sizeString,
marshal: appendStringValidateUTF8,
unmarshal: consumeStringValidateUTF8,
}
// sizeStringNoZero returns the size of wire encoding a string pointer as a String.
// The zero value is not encoded.
func sizeStringNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
v := *p.String()
if len(v) == 0 {
return 0
}
return tagsize + wire.SizeBytes(len(v))
}
// appendStringNoZero wire encodes a string pointer as a String.
// The zero value is not encoded.
func appendStringNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.String()
if len(v) == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
b = wire.AppendString(b, v)
return b, nil
}
var coderStringNoZero = pointerCoderFuncs{
size: sizeStringNoZero,
marshal: appendStringNoZero,
unmarshal: consumeString,
}
// appendStringNoZeroValidateUTF8 wire encodes a string pointer as a String.
// The zero value is not encoded.
func appendStringNoZeroValidateUTF8(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.String()
if len(v) == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
b = wire.AppendString(b, v)
if !utf8.ValidString(v) {
return b, errInvalidUTF8{}
}
return b, nil
}
var coderStringNoZeroValidateUTF8 = pointerCoderFuncs{
size: sizeStringNoZero,
marshal: appendStringNoZeroValidateUTF8,
unmarshal: consumeStringValidateUTF8,
}
// sizeStringPtr returns the size of wire encoding a *string pointer as a String.
// It panics if the pointer is nil.
func sizeStringPtr(p pointer, tagsize int, _ marshalOptions) (size int) {
v := **p.StringPtr()
return tagsize + wire.SizeBytes(len(v))
}
// appendStringPtr wire encodes a *string pointer as a String.
// It panics if the pointer is nil.
func appendStringPtr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := **p.StringPtr()
b = wire.AppendVarint(b, wiretag)
b = wire.AppendString(b, v)
return b, nil
}
// consumeStringPtr wire decodes a *string pointer as a String.
func consumeStringPtr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.BytesType {
return 0, errUnknown
}
v, n := wire.ConsumeString(b)
if n < 0 {
return 0, wire.ParseError(n)
}
vp := p.StringPtr()
if *vp == nil {
*vp = new(string)
}
**vp = v
return n, nil
}
var coderStringPtr = pointerCoderFuncs{
size: sizeStringPtr,
marshal: appendStringPtr,
unmarshal: consumeStringPtr,
}
// sizeStringSlice returns the size of wire encoding a []string pointer as a repeated String.
func sizeStringSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
s := *p.StringSlice()
for _, v := range s {
size += tagsize + wire.SizeBytes(len(v))
}
return size
}
// appendStringSlice encodes a []string pointer as a repeated String.
func appendStringSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
s := *p.StringSlice()
for _, v := range s {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendString(b, v)
}
return b, nil
}
// consumeStringSlice wire decodes a []string pointer as a repeated String.
func consumeStringSlice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
sp := p.StringSlice()
if wtyp != wire.BytesType {
return 0, errUnknown
}
v, n := wire.ConsumeString(b)
if n < 0 {
return 0, wire.ParseError(n)
}
*sp = append(*sp, v)
return n, nil
}
var coderStringSlice = pointerCoderFuncs{
size: sizeStringSlice,
marshal: appendStringSlice,
unmarshal: consumeStringSlice,
}
// appendStringSliceValidateUTF8 encodes a []string pointer as a repeated String.
func appendStringSliceValidateUTF8(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
s := *p.StringSlice()
for _, v := range s {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendString(b, v)
if !utf8.ValidString(v) {
return b, errInvalidUTF8{}
}
}
return b, nil
}
// consumeStringSliceValidateUTF8 wire decodes a []string pointer as a repeated String.
func consumeStringSliceValidateUTF8(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
sp := p.StringSlice()
if wtyp != wire.BytesType {
return 0, errUnknown
}
v, n := wire.ConsumeString(b)
if n < 0 {
return 0, wire.ParseError(n)
}
if !utf8.ValidString(v) {
return 0, errInvalidUTF8{}
}
*sp = append(*sp, v)
return n, nil
}
var coderStringSliceValidateUTF8 = pointerCoderFuncs{
size: sizeStringSlice,
marshal: appendStringSliceValidateUTF8,
unmarshal: consumeStringSliceValidateUTF8,
}
// sizeStringValue returns the size of wire encoding a string value as a String.
func sizeStringValue(v protoreflect.Value, tagsize int, _ marshalOptions) int {
return tagsize + wire.SizeBytes(len(v.String()))
}
// appendStringValue encodes a string value as a String.
func appendStringValue(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendString(b, v.String())
return b, nil
}
// consumeStringValue decodes a string value as a String.
func consumeStringValue(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
if wtyp != wire.BytesType {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeString(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
return protoreflect.ValueOfString(string(v)), n, nil
}
var coderStringValue = valueCoderFuncs{
size: sizeStringValue,
marshal: appendStringValue,
unmarshal: consumeStringValue,
}
// appendStringValueValidateUTF8 encodes a string value as a String.
func appendStringValueValidateUTF8(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendString(b, v.String())
if !utf8.ValidString(v.String()) {
return b, errInvalidUTF8{}
}
return b, nil
}
// consumeStringValueValidateUTF8 decodes a string value as a String.
func consumeStringValueValidateUTF8(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
if wtyp != wire.BytesType {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeString(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
if !utf8.ValidString(v) {
return protoreflect.Value{}, 0, errInvalidUTF8{}
}
return protoreflect.ValueOfString(string(v)), n, nil
}
var coderStringValueValidateUTF8 = valueCoderFuncs{
size: sizeStringValue,
marshal: appendStringValueValidateUTF8,
unmarshal: consumeStringValueValidateUTF8,
}
// sizeStringSliceValue returns the size of wire encoding a []string value as a repeated String.
func sizeStringSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
list := listv.List()
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
size += tagsize + wire.SizeBytes(len(v.String()))
}
return size
}
// appendStringSliceValue encodes a []string value as a repeated String.
func appendStringSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
list := listv.List()
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
b = wire.AppendVarint(b, wiretag)
b = wire.AppendString(b, v.String())
}
return b, nil
}
// consumeStringSliceValue wire decodes a []string value as a repeated String.
func consumeStringSliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
list := listv.List()
if wtyp != wire.BytesType {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeString(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
list.Append(protoreflect.ValueOfString(string(v)))
return listv, n, nil
}
var coderStringSliceValue = valueCoderFuncs{
size: sizeStringSliceValue,
marshal: appendStringSliceValue,
unmarshal: consumeStringSliceValue,
}
// sizeBytes returns the size of wire encoding a []byte pointer as a Bytes.
func sizeBytes(p pointer, tagsize int, _ marshalOptions) (size int) {
v := *p.Bytes()
return tagsize + wire.SizeBytes(len(v))
}
// appendBytes wire encodes a []byte pointer as a Bytes.
func appendBytes(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.Bytes()
b = wire.AppendVarint(b, wiretag)
b = wire.AppendBytes(b, v)
return b, nil
}
// consumeBytes wire decodes a []byte pointer as a Bytes.
func consumeBytes(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.BytesType {
return 0, errUnknown
}
v, n := wire.ConsumeBytes(b)
if n < 0 {
return 0, wire.ParseError(n)
}
*p.Bytes() = append(emptyBuf[:], v...)
return n, nil
}
var coderBytes = pointerCoderFuncs{
size: sizeBytes,
marshal: appendBytes,
unmarshal: consumeBytes,
}
// appendBytesValidateUTF8 wire encodes a []byte pointer as a Bytes.
func appendBytesValidateUTF8(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.Bytes()
b = wire.AppendVarint(b, wiretag)
b = wire.AppendBytes(b, v)
if !utf8.Valid(v) {
return b, errInvalidUTF8{}
}
return b, nil
}
// consumeBytesValidateUTF8 wire decodes a []byte pointer as a Bytes.
func consumeBytesValidateUTF8(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.BytesType {
return 0, errUnknown
}
v, n := wire.ConsumeBytes(b)
if n < 0 {
return 0, wire.ParseError(n)
}
if !utf8.Valid(v) {
return 0, errInvalidUTF8{}
}
*p.Bytes() = append(emptyBuf[:], v...)
return n, nil
}
var coderBytesValidateUTF8 = pointerCoderFuncs{
size: sizeBytes,
marshal: appendBytesValidateUTF8,
unmarshal: consumeBytesValidateUTF8,
}
// sizeBytesNoZero returns the size of wire encoding a []byte pointer as a Bytes.
// The zero value is not encoded.
func sizeBytesNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
v := *p.Bytes()
if len(v) == 0 {
return 0
}
return tagsize + wire.SizeBytes(len(v))
}
// appendBytesNoZero wire encodes a []byte pointer as a Bytes.
// The zero value is not encoded.
func appendBytesNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.Bytes()
if len(v) == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
b = wire.AppendBytes(b, v)
return b, nil
}
// consumeBytesNoZero wire decodes a []byte pointer as a Bytes.
// The zero value is not decoded.
func consumeBytesNoZero(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.BytesType {
return 0, errUnknown
}
v, n := wire.ConsumeBytes(b)
if n < 0 {
return 0, wire.ParseError(n)
}
*p.Bytes() = append(([]byte)(nil), v...)
return n, nil
}
var coderBytesNoZero = pointerCoderFuncs{
size: sizeBytesNoZero,
marshal: appendBytesNoZero,
unmarshal: consumeBytesNoZero,
}
// appendBytesNoZeroValidateUTF8 wire encodes a []byte pointer as a Bytes.
// The zero value is not encoded.
func appendBytesNoZeroValidateUTF8(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
v := *p.Bytes()
if len(v) == 0 {
return b, nil
}
b = wire.AppendVarint(b, wiretag)
b = wire.AppendBytes(b, v)
if !utf8.Valid(v) {
return b, errInvalidUTF8{}
}
return b, nil
}
// consumeBytesNoZeroValidateUTF8 wire decodes a []byte pointer as a Bytes.
func consumeBytesNoZeroValidateUTF8(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
if wtyp != wire.BytesType {
return 0, errUnknown
}
v, n := wire.ConsumeBytes(b)
if n < 0 {
return 0, wire.ParseError(n)
}
if !utf8.Valid(v) {
return 0, errInvalidUTF8{}
}
*p.Bytes() = append(([]byte)(nil), v...)
return n, nil
}
var coderBytesNoZeroValidateUTF8 = pointerCoderFuncs{
size: sizeBytesNoZero,
marshal: appendBytesNoZeroValidateUTF8,
unmarshal: consumeBytesNoZeroValidateUTF8,
}
// sizeBytesSlice returns the size of wire encoding a [][]byte pointer as a repeated Bytes.
func sizeBytesSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
s := *p.BytesSlice()
for _, v := range s {
size += tagsize + wire.SizeBytes(len(v))
}
return size
}
// appendBytesSlice encodes a [][]byte pointer as a repeated Bytes.
func appendBytesSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
s := *p.BytesSlice()
for _, v := range s {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendBytes(b, v)
}
return b, nil
}
// consumeBytesSlice wire decodes a [][]byte pointer as a repeated Bytes.
func consumeBytesSlice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
sp := p.BytesSlice()
if wtyp != wire.BytesType {
return 0, errUnknown
}
v, n := wire.ConsumeBytes(b)
if n < 0 {
return 0, wire.ParseError(n)
}
*sp = append(*sp, append(emptyBuf[:], v...))
return n, nil
}
var coderBytesSlice = pointerCoderFuncs{
size: sizeBytesSlice,
marshal: appendBytesSlice,
unmarshal: consumeBytesSlice,
}
// appendBytesSliceValidateUTF8 encodes a [][]byte pointer as a repeated Bytes.
func appendBytesSliceValidateUTF8(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
s := *p.BytesSlice()
for _, v := range s {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendBytes(b, v)
if !utf8.Valid(v) {
return b, errInvalidUTF8{}
}
}
return b, nil
}
// consumeBytesSliceValidateUTF8 wire decodes a [][]byte pointer as a repeated Bytes.
func consumeBytesSliceValidateUTF8(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
sp := p.BytesSlice()
if wtyp != wire.BytesType {
return 0, errUnknown
}
v, n := wire.ConsumeBytes(b)
if n < 0 {
return 0, wire.ParseError(n)
}
if !utf8.Valid(v) {
return 0, errInvalidUTF8{}
}
*sp = append(*sp, append(emptyBuf[:], v...))
return n, nil
}
var coderBytesSliceValidateUTF8 = pointerCoderFuncs{
size: sizeBytesSlice,
marshal: appendBytesSliceValidateUTF8,
unmarshal: consumeBytesSliceValidateUTF8,
}
// sizeBytesValue returns the size of wire encoding a []byte value as a Bytes.
func sizeBytesValue(v protoreflect.Value, tagsize int, _ marshalOptions) int {
return tagsize + wire.SizeBytes(len(v.Bytes()))
}
// appendBytesValue encodes a []byte value as a Bytes.
func appendBytesValue(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
b = wire.AppendVarint(b, wiretag)
b = wire.AppendBytes(b, v.Bytes())
return b, nil
}
// consumeBytesValue decodes a []byte value as a Bytes.
func consumeBytesValue(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
if wtyp != wire.BytesType {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeBytes(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
return protoreflect.ValueOfBytes(append(([]byte)(nil), v...)), n, nil
}
var coderBytesValue = valueCoderFuncs{
size: sizeBytesValue,
marshal: appendBytesValue,
unmarshal: consumeBytesValue,
}
// sizeBytesSliceValue returns the size of wire encoding a [][]byte value as a repeated Bytes.
func sizeBytesSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
list := listv.List()
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
size += tagsize + wire.SizeBytes(len(v.Bytes()))
}
return size
}
// appendBytesSliceValue encodes a [][]byte value as a repeated Bytes.
func appendBytesSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
list := listv.List()
for i, llen := 0, list.Len(); i < llen; i++ {
v := list.Get(i)
b = wire.AppendVarint(b, wiretag)
b = wire.AppendBytes(b, v.Bytes())
}
return b, nil
}
// consumeBytesSliceValue wire decodes a [][]byte value as a repeated Bytes.
func consumeBytesSliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
list := listv.List()
if wtyp != wire.BytesType {
return protoreflect.Value{}, 0, errUnknown
}
v, n := wire.ConsumeBytes(b)
if n < 0 {
return protoreflect.Value{}, 0, wire.ParseError(n)
}
list.Append(protoreflect.ValueOfBytes(append(([]byte)(nil), v...)))
return listv, n, nil
}
var coderBytesSliceValue = valueCoderFuncs{
size: sizeBytesSliceValue,
marshal: appendBytesSliceValue,
unmarshal: consumeBytesSliceValue,
}
// We append to an empty array rather than a nil []byte to get non-nil zero-length byte slices.
var emptyBuf [0]byte
var wireTypes = map[protoreflect.Kind]wire.Type{
protoreflect.BoolKind: wire.VarintType,
protoreflect.EnumKind: wire.VarintType,
protoreflect.Int32Kind: wire.VarintType,
protoreflect.Sint32Kind: wire.VarintType,
protoreflect.Uint32Kind: wire.VarintType,
protoreflect.Int64Kind: wire.VarintType,
protoreflect.Sint64Kind: wire.VarintType,
protoreflect.Uint64Kind: wire.VarintType,
protoreflect.Sfixed32Kind: wire.Fixed32Type,
protoreflect.Fixed32Kind: wire.Fixed32Type,
protoreflect.FloatKind: wire.Fixed32Type,
protoreflect.Sfixed64Kind: wire.Fixed64Type,
protoreflect.Fixed64Kind: wire.Fixed64Type,
protoreflect.DoubleKind: wire.Fixed64Type,
protoreflect.StringKind: wire.BytesType,
protoreflect.BytesKind: wire.BytesType,
protoreflect.MessageKind: wire.BytesType,
protoreflect.GroupKind: wire.StartGroupType,
}