blob: 41cdb7b8db411b8c7891b20338ab68180ae47661 [file] [log] [blame]
Damien Neilc37adef2019-04-01 13:49:56 -07001// Copyright 2018 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style.
3// license that can be found in the LICENSE file.
4
5// Code generated by generate-types. DO NOT EDIT.
6
7package impl
8
9import (
10 "math"
Joe Tsaic51e2e02019-07-13 00:44:41 -070011 "unicode/utf8"
Damien Neilc37adef2019-04-01 13:49:56 -070012
13 "google.golang.org/protobuf/internal/encoding/wire"
14 "google.golang.org/protobuf/reflect/protoreflect"
15)
16
17// sizeBool returns the size of wire encoding a bool pointer as a Bool.
18func sizeBool(p pointer, tagsize int, _ marshalOptions) (size int) {
19 v := *p.Bool()
20 return tagsize + wire.SizeVarint(wire.EncodeBool(v))
21}
22
23// appendBool wire encodes a bool pointer as a Bool.
24func appendBool(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
25 v := *p.Bool()
26 b = wire.AppendVarint(b, wiretag)
27 b = wire.AppendVarint(b, wire.EncodeBool(v))
28 return b, nil
29}
30
Damien Neile91877d2019-06-27 10:54:42 -070031// consumeBool wire decodes a bool pointer as a Bool.
Damien Neilf0831e82020-01-21 14:25:12 -080032func consumeBool(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -070033 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -080034 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -070035 }
36 v, n := wire.ConsumeVarint(b)
37 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -080038 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -070039 }
40 *p.Bool() = wire.DecodeBool(v)
Damien Neilf0831e82020-01-21 14:25:12 -080041 out.n = n
42 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -070043}
44
Damien Neilc37adef2019-04-01 13:49:56 -070045var coderBool = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -070046 size: sizeBool,
47 marshal: appendBool,
48 unmarshal: consumeBool,
Damien Neilc37adef2019-04-01 13:49:56 -070049}
50
Joe Tsaic51e2e02019-07-13 00:44:41 -070051// sizeBoolNoZero returns the size of wire encoding a bool pointer as a Bool.
Damien Neilc37adef2019-04-01 13:49:56 -070052// The zero value is not encoded.
53func sizeBoolNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
54 v := *p.Bool()
55 if v == false {
56 return 0
57 }
58 return tagsize + wire.SizeVarint(wire.EncodeBool(v))
59}
60
Joe Tsaic51e2e02019-07-13 00:44:41 -070061// appendBoolNoZero wire encodes a bool pointer as a Bool.
Damien Neilc37adef2019-04-01 13:49:56 -070062// The zero value is not encoded.
63func appendBoolNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
64 v := *p.Bool()
65 if v == false {
66 return b, nil
67 }
68 b = wire.AppendVarint(b, wiretag)
69 b = wire.AppendVarint(b, wire.EncodeBool(v))
70 return b, nil
71}
72
73var coderBoolNoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -070074 size: sizeBoolNoZero,
75 marshal: appendBoolNoZero,
76 unmarshal: consumeBool,
Damien Neilc37adef2019-04-01 13:49:56 -070077}
78
79// sizeBoolPtr returns the size of wire encoding a *bool pointer as a Bool.
80// It panics if the pointer is nil.
81func sizeBoolPtr(p pointer, tagsize int, _ marshalOptions) (size int) {
82 v := **p.BoolPtr()
83 return tagsize + wire.SizeVarint(wire.EncodeBool(v))
84}
85
Damien Neile91877d2019-06-27 10:54:42 -070086// appendBoolPtr wire encodes a *bool pointer as a Bool.
Damien Neilc37adef2019-04-01 13:49:56 -070087// It panics if the pointer is nil.
88func appendBoolPtr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
89 v := **p.BoolPtr()
90 b = wire.AppendVarint(b, wiretag)
91 b = wire.AppendVarint(b, wire.EncodeBool(v))
92 return b, nil
93}
94
Damien Neile91877d2019-06-27 10:54:42 -070095// consumeBoolPtr wire decodes a *bool pointer as a Bool.
Damien Neilf0831e82020-01-21 14:25:12 -080096func consumeBoolPtr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -070097 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -080098 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -070099 }
100 v, n := wire.ConsumeVarint(b)
101 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -0800102 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -0700103 }
104 vp := p.BoolPtr()
105 if *vp == nil {
106 *vp = new(bool)
107 }
108 **vp = wire.DecodeBool(v)
Damien Neilf0831e82020-01-21 14:25:12 -0800109 out.n = n
110 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -0700111}
112
Damien Neilc37adef2019-04-01 13:49:56 -0700113var coderBoolPtr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700114 size: sizeBoolPtr,
115 marshal: appendBoolPtr,
116 unmarshal: consumeBoolPtr,
Damien Neilc37adef2019-04-01 13:49:56 -0700117}
118
119// sizeBoolSlice returns the size of wire encoding a []bool pointer as a repeated Bool.
120func sizeBoolSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
121 s := *p.BoolSlice()
122 for _, v := range s {
123 size += tagsize + wire.SizeVarint(wire.EncodeBool(v))
124 }
125 return size
126}
127
128// appendBoolSlice encodes a []bool pointer as a repeated Bool.
129func appendBoolSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
130 s := *p.BoolSlice()
131 for _, v := range s {
132 b = wire.AppendVarint(b, wiretag)
133 b = wire.AppendVarint(b, wire.EncodeBool(v))
134 }
135 return b, nil
136}
137
Damien Neile91877d2019-06-27 10:54:42 -0700138// consumeBoolSlice wire decodes a []bool pointer as a repeated Bool.
Damien Neilf0831e82020-01-21 14:25:12 -0800139func consumeBoolSlice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -0700140 sp := p.BoolSlice()
141 if wtyp == wire.BytesType {
142 s := *sp
Damien Neilf0831e82020-01-21 14:25:12 -0800143 b, n := wire.ConsumeBytes(b)
Damien Neile91877d2019-06-27 10:54:42 -0700144 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -0800145 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -0700146 }
147 for len(b) > 0 {
148 v, n := wire.ConsumeVarint(b)
149 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -0800150 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -0700151 }
152 s = append(s, wire.DecodeBool(v))
153 b = b[n:]
154 }
155 *sp = s
Damien Neilf0831e82020-01-21 14:25:12 -0800156 out.n = n
157 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -0700158 }
159 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -0800160 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -0700161 }
162 v, n := wire.ConsumeVarint(b)
163 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -0800164 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -0700165 }
166 *sp = append(*sp, wire.DecodeBool(v))
Damien Neilf0831e82020-01-21 14:25:12 -0800167 out.n = n
168 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -0700169}
170
Damien Neilc37adef2019-04-01 13:49:56 -0700171var coderBoolSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700172 size: sizeBoolSlice,
173 marshal: appendBoolSlice,
174 unmarshal: consumeBoolSlice,
Damien Neilc37adef2019-04-01 13:49:56 -0700175}
176
177// sizeBoolPackedSlice returns the size of wire encoding a []bool pointer as a packed repeated Bool.
178func sizeBoolPackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
179 s := *p.BoolSlice()
180 if len(s) == 0 {
181 return 0
182 }
183 n := 0
184 for _, v := range s {
185 n += wire.SizeVarint(wire.EncodeBool(v))
186 }
187 return tagsize + wire.SizeBytes(n)
188}
189
190// appendBoolPackedSlice encodes a []bool pointer as a packed repeated Bool.
191func appendBoolPackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
192 s := *p.BoolSlice()
193 if len(s) == 0 {
194 return b, nil
195 }
196 b = wire.AppendVarint(b, wiretag)
197 n := 0
198 for _, v := range s {
199 n += wire.SizeVarint(wire.EncodeBool(v))
200 }
201 b = wire.AppendVarint(b, uint64(n))
202 for _, v := range s {
203 b = wire.AppendVarint(b, wire.EncodeBool(v))
204 }
205 return b, nil
206}
207
208var coderBoolPackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700209 size: sizeBoolPackedSlice,
210 marshal: appendBoolPackedSlice,
211 unmarshal: consumeBoolSlice,
Damien Neilc37adef2019-04-01 13:49:56 -0700212}
213
Damien Neil68b81c32019-08-22 11:41:32 -0700214// sizeBoolValue returns the size of wire encoding a bool value as a Bool.
215func sizeBoolValue(v protoreflect.Value, tagsize int, _ marshalOptions) int {
216 return tagsize + wire.SizeVarint(wire.EncodeBool(v.Bool()))
Damien Neilc37adef2019-04-01 13:49:56 -0700217}
218
Damien Neil68b81c32019-08-22 11:41:32 -0700219// appendBoolValue encodes a bool value as a Bool.
220func appendBoolValue(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
Damien Neilc37adef2019-04-01 13:49:56 -0700221 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -0700222 b = wire.AppendVarint(b, wire.EncodeBool(v.Bool()))
Damien Neilc37adef2019-04-01 13:49:56 -0700223 return b, nil
224}
225
Damien Neil68b81c32019-08-22 11:41:32 -0700226// consumeBoolValue decodes a bool value as a Bool.
Damien Neilf0831e82020-01-21 14:25:12 -0800227func consumeBoolValue(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -0700228 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -0800229 return protoreflect.Value{}, out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -0700230 }
231 v, n := wire.ConsumeVarint(b)
232 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -0800233 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -0700234 }
Damien Neilf0831e82020-01-21 14:25:12 -0800235 out.n = n
236 return protoreflect.ValueOfBool(wire.DecodeBool(v)), out, nil
Damien Neile91877d2019-06-27 10:54:42 -0700237}
238
Damien Neil68b81c32019-08-22 11:41:32 -0700239var coderBoolValue = valueCoderFuncs{
240 size: sizeBoolValue,
241 marshal: appendBoolValue,
242 unmarshal: consumeBoolValue,
Damien Neilc37adef2019-04-01 13:49:56 -0700243}
244
Damien Neil68b81c32019-08-22 11:41:32 -0700245// sizeBoolSliceValue returns the size of wire encoding a []bool value as a repeated Bool.
246func sizeBoolSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
247 list := listv.List()
248 for i, llen := 0, list.Len(); i < llen; i++ {
249 v := list.Get(i)
250 size += tagsize + wire.SizeVarint(wire.EncodeBool(v.Bool()))
Damien Neilc37adef2019-04-01 13:49:56 -0700251 }
252 return size
253}
254
Damien Neil68b81c32019-08-22 11:41:32 -0700255// appendBoolSliceValue encodes a []bool value as a repeated Bool.
256func appendBoolSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
257 list := listv.List()
258 for i, llen := 0, list.Len(); i < llen; i++ {
259 v := list.Get(i)
Damien Neilc37adef2019-04-01 13:49:56 -0700260 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -0700261 b = wire.AppendVarint(b, wire.EncodeBool(v.Bool()))
Damien Neilc37adef2019-04-01 13:49:56 -0700262 }
263 return b, nil
264}
265
Damien Neil68b81c32019-08-22 11:41:32 -0700266// consumeBoolSliceValue wire decodes a []bool value as a repeated Bool.
Damien Neilf0831e82020-01-21 14:25:12 -0800267func consumeBoolSliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neil68b81c32019-08-22 11:41:32 -0700268 list := listv.List()
Damien Neile91877d2019-06-27 10:54:42 -0700269 if wtyp == wire.BytesType {
Damien Neilf0831e82020-01-21 14:25:12 -0800270 b, n := wire.ConsumeBytes(b)
Damien Neile91877d2019-06-27 10:54:42 -0700271 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -0800272 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -0700273 }
274 for len(b) > 0 {
275 v, n := wire.ConsumeVarint(b)
276 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -0800277 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -0700278 }
Damien Neil68b81c32019-08-22 11:41:32 -0700279 list.Append(protoreflect.ValueOfBool(wire.DecodeBool(v)))
Damien Neile91877d2019-06-27 10:54:42 -0700280 b = b[n:]
281 }
Damien Neilf0831e82020-01-21 14:25:12 -0800282 out.n = n
283 return listv, out, nil
Damien Neile91877d2019-06-27 10:54:42 -0700284 }
285 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -0800286 return protoreflect.Value{}, out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -0700287 }
288 v, n := wire.ConsumeVarint(b)
289 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -0800290 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -0700291 }
Damien Neil68b81c32019-08-22 11:41:32 -0700292 list.Append(protoreflect.ValueOfBool(wire.DecodeBool(v)))
Damien Neilf0831e82020-01-21 14:25:12 -0800293 out.n = n
294 return listv, out, nil
Damien Neile91877d2019-06-27 10:54:42 -0700295}
296
Damien Neil68b81c32019-08-22 11:41:32 -0700297var coderBoolSliceValue = valueCoderFuncs{
298 size: sizeBoolSliceValue,
299 marshal: appendBoolSliceValue,
300 unmarshal: consumeBoolSliceValue,
Damien Neilc37adef2019-04-01 13:49:56 -0700301}
302
Damien Neil68b81c32019-08-22 11:41:32 -0700303// sizeBoolPackedSliceValue returns the size of wire encoding a []bool value as a packed repeated Bool.
304func sizeBoolPackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
305 list := listv.List()
Damien Neil2c0824b2019-12-20 12:21:25 -0800306 llen := list.Len()
307 if llen == 0 {
308 return 0
309 }
Damien Neil7492a092019-07-10 15:23:29 -0700310 n := 0
Damien Neil2c0824b2019-12-20 12:21:25 -0800311 for i, llen := 0, llen; i < llen; i++ {
Damien Neil68b81c32019-08-22 11:41:32 -0700312 v := list.Get(i)
313 n += wire.SizeVarint(wire.EncodeBool(v.Bool()))
Damien Neil7492a092019-07-10 15:23:29 -0700314 }
315 return tagsize + wire.SizeBytes(n)
316}
317
Damien Neil68b81c32019-08-22 11:41:32 -0700318// appendBoolPackedSliceValue encodes a []bool value as a packed repeated Bool.
319func appendBoolPackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
320 list := listv.List()
321 llen := list.Len()
322 if llen == 0 {
Damien Neil7492a092019-07-10 15:23:29 -0700323 return b, nil
324 }
325 b = wire.AppendVarint(b, wiretag)
326 n := 0
Damien Neil68b81c32019-08-22 11:41:32 -0700327 for i := 0; i < llen; i++ {
328 v := list.Get(i)
329 n += wire.SizeVarint(wire.EncodeBool(v.Bool()))
Damien Neil7492a092019-07-10 15:23:29 -0700330 }
331 b = wire.AppendVarint(b, uint64(n))
Damien Neil68b81c32019-08-22 11:41:32 -0700332 for i := 0; i < llen; i++ {
333 v := list.Get(i)
334 b = wire.AppendVarint(b, wire.EncodeBool(v.Bool()))
Damien Neil7492a092019-07-10 15:23:29 -0700335 }
336 return b, nil
337}
338
Damien Neil68b81c32019-08-22 11:41:32 -0700339var coderBoolPackedSliceValue = valueCoderFuncs{
340 size: sizeBoolPackedSliceValue,
341 marshal: appendBoolPackedSliceValue,
342 unmarshal: consumeBoolSliceValue,
343}
344
345// sizeEnumValue returns the size of wire encoding a value as a Enum.
346func sizeEnumValue(v protoreflect.Value, tagsize int, _ marshalOptions) int {
347 return tagsize + wire.SizeVarint(uint64(v.Enum()))
348}
349
350// appendEnumValue encodes a value as a Enum.
351func appendEnumValue(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
352 b = wire.AppendVarint(b, wiretag)
353 b = wire.AppendVarint(b, uint64(v.Enum()))
354 return b, nil
355}
356
357// consumeEnumValue decodes a value as a Enum.
Damien Neilf0831e82020-01-21 14:25:12 -0800358func consumeEnumValue(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neil68b81c32019-08-22 11:41:32 -0700359 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -0800360 return protoreflect.Value{}, out, errUnknown
Damien Neil68b81c32019-08-22 11:41:32 -0700361 }
362 v, n := wire.ConsumeVarint(b)
363 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -0800364 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neil68b81c32019-08-22 11:41:32 -0700365 }
Damien Neilf0831e82020-01-21 14:25:12 -0800366 out.n = n
367 return protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)), out, nil
Damien Neil68b81c32019-08-22 11:41:32 -0700368}
369
370var coderEnumValue = valueCoderFuncs{
371 size: sizeEnumValue,
372 marshal: appendEnumValue,
373 unmarshal: consumeEnumValue,
374}
375
376// sizeEnumSliceValue returns the size of wire encoding a [] value as a repeated Enum.
377func sizeEnumSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
378 list := listv.List()
379 for i, llen := 0, list.Len(); i < llen; i++ {
380 v := list.Get(i)
381 size += tagsize + wire.SizeVarint(uint64(v.Enum()))
382 }
383 return size
384}
385
386// appendEnumSliceValue encodes a [] value as a repeated Enum.
387func appendEnumSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
388 list := listv.List()
389 for i, llen := 0, list.Len(); i < llen; i++ {
390 v := list.Get(i)
391 b = wire.AppendVarint(b, wiretag)
392 b = wire.AppendVarint(b, uint64(v.Enum()))
393 }
394 return b, nil
395}
396
397// consumeEnumSliceValue wire decodes a [] value as a repeated Enum.
Damien Neilf0831e82020-01-21 14:25:12 -0800398func consumeEnumSliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neil68b81c32019-08-22 11:41:32 -0700399 list := listv.List()
400 if wtyp == wire.BytesType {
Damien Neilf0831e82020-01-21 14:25:12 -0800401 b, n := wire.ConsumeBytes(b)
Damien Neil68b81c32019-08-22 11:41:32 -0700402 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -0800403 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neil68b81c32019-08-22 11:41:32 -0700404 }
405 for len(b) > 0 {
406 v, n := wire.ConsumeVarint(b)
407 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -0800408 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neil68b81c32019-08-22 11:41:32 -0700409 }
410 list.Append(protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)))
411 b = b[n:]
412 }
Damien Neilf0831e82020-01-21 14:25:12 -0800413 out.n = n
414 return listv, out, nil
Damien Neil68b81c32019-08-22 11:41:32 -0700415 }
416 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -0800417 return protoreflect.Value{}, out, errUnknown
Damien Neil68b81c32019-08-22 11:41:32 -0700418 }
419 v, n := wire.ConsumeVarint(b)
420 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -0800421 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neil68b81c32019-08-22 11:41:32 -0700422 }
423 list.Append(protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)))
Damien Neilf0831e82020-01-21 14:25:12 -0800424 out.n = n
425 return listv, out, nil
Damien Neil68b81c32019-08-22 11:41:32 -0700426}
427
428var coderEnumSliceValue = valueCoderFuncs{
429 size: sizeEnumSliceValue,
430 marshal: appendEnumSliceValue,
431 unmarshal: consumeEnumSliceValue,
432}
433
434// sizeEnumPackedSliceValue returns the size of wire encoding a [] value as a packed repeated Enum.
435func sizeEnumPackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
436 list := listv.List()
Damien Neil2c0824b2019-12-20 12:21:25 -0800437 llen := list.Len()
438 if llen == 0 {
439 return 0
440 }
Damien Neil68b81c32019-08-22 11:41:32 -0700441 n := 0
Damien Neil2c0824b2019-12-20 12:21:25 -0800442 for i, llen := 0, llen; i < llen; i++ {
Damien Neil68b81c32019-08-22 11:41:32 -0700443 v := list.Get(i)
444 n += wire.SizeVarint(uint64(v.Enum()))
445 }
446 return tagsize + wire.SizeBytes(n)
447}
448
449// appendEnumPackedSliceValue encodes a [] value as a packed repeated Enum.
450func appendEnumPackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
451 list := listv.List()
452 llen := list.Len()
453 if llen == 0 {
454 return b, nil
455 }
456 b = wire.AppendVarint(b, wiretag)
457 n := 0
458 for i := 0; i < llen; i++ {
459 v := list.Get(i)
460 n += wire.SizeVarint(uint64(v.Enum()))
461 }
462 b = wire.AppendVarint(b, uint64(n))
463 for i := 0; i < llen; i++ {
464 v := list.Get(i)
465 b = wire.AppendVarint(b, uint64(v.Enum()))
466 }
467 return b, nil
468}
469
470var coderEnumPackedSliceValue = valueCoderFuncs{
471 size: sizeEnumPackedSliceValue,
472 marshal: appendEnumPackedSliceValue,
473 unmarshal: consumeEnumSliceValue,
Damien Neil7492a092019-07-10 15:23:29 -0700474}
475
Damien Neilc37adef2019-04-01 13:49:56 -0700476// sizeInt32 returns the size of wire encoding a int32 pointer as a Int32.
477func sizeInt32(p pointer, tagsize int, _ marshalOptions) (size int) {
478 v := *p.Int32()
479 return tagsize + wire.SizeVarint(uint64(v))
480}
481
482// appendInt32 wire encodes a int32 pointer as a Int32.
483func appendInt32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
484 v := *p.Int32()
485 b = wire.AppendVarint(b, wiretag)
486 b = wire.AppendVarint(b, uint64(v))
487 return b, nil
488}
489
Damien Neile91877d2019-06-27 10:54:42 -0700490// consumeInt32 wire decodes a int32 pointer as a Int32.
Damien Neilf0831e82020-01-21 14:25:12 -0800491func consumeInt32(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -0700492 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -0800493 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -0700494 }
495 v, n := wire.ConsumeVarint(b)
496 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -0800497 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -0700498 }
499 *p.Int32() = int32(v)
Damien Neilf0831e82020-01-21 14:25:12 -0800500 out.n = n
501 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -0700502}
503
Damien Neilc37adef2019-04-01 13:49:56 -0700504var coderInt32 = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700505 size: sizeInt32,
506 marshal: appendInt32,
507 unmarshal: consumeInt32,
Damien Neilc37adef2019-04-01 13:49:56 -0700508}
509
Joe Tsaic51e2e02019-07-13 00:44:41 -0700510// sizeInt32NoZero returns the size of wire encoding a int32 pointer as a Int32.
Damien Neilc37adef2019-04-01 13:49:56 -0700511// The zero value is not encoded.
512func sizeInt32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
513 v := *p.Int32()
514 if v == 0 {
515 return 0
516 }
517 return tagsize + wire.SizeVarint(uint64(v))
518}
519
Joe Tsaic51e2e02019-07-13 00:44:41 -0700520// appendInt32NoZero wire encodes a int32 pointer as a Int32.
Damien Neilc37adef2019-04-01 13:49:56 -0700521// The zero value is not encoded.
522func appendInt32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
523 v := *p.Int32()
524 if v == 0 {
525 return b, nil
526 }
527 b = wire.AppendVarint(b, wiretag)
528 b = wire.AppendVarint(b, uint64(v))
529 return b, nil
530}
531
532var coderInt32NoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700533 size: sizeInt32NoZero,
534 marshal: appendInt32NoZero,
535 unmarshal: consumeInt32,
Damien Neilc37adef2019-04-01 13:49:56 -0700536}
537
538// sizeInt32Ptr returns the size of wire encoding a *int32 pointer as a Int32.
539// It panics if the pointer is nil.
540func sizeInt32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
541 v := **p.Int32Ptr()
542 return tagsize + wire.SizeVarint(uint64(v))
543}
544
Damien Neile91877d2019-06-27 10:54:42 -0700545// appendInt32Ptr wire encodes a *int32 pointer as a Int32.
Damien Neilc37adef2019-04-01 13:49:56 -0700546// It panics if the pointer is nil.
547func appendInt32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
548 v := **p.Int32Ptr()
549 b = wire.AppendVarint(b, wiretag)
550 b = wire.AppendVarint(b, uint64(v))
551 return b, nil
552}
553
Damien Neile91877d2019-06-27 10:54:42 -0700554// consumeInt32Ptr wire decodes a *int32 pointer as a Int32.
Damien Neilf0831e82020-01-21 14:25:12 -0800555func consumeInt32Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -0700556 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -0800557 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -0700558 }
559 v, n := wire.ConsumeVarint(b)
560 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -0800561 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -0700562 }
563 vp := p.Int32Ptr()
564 if *vp == nil {
565 *vp = new(int32)
566 }
567 **vp = int32(v)
Damien Neilf0831e82020-01-21 14:25:12 -0800568 out.n = n
569 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -0700570}
571
Damien Neilc37adef2019-04-01 13:49:56 -0700572var coderInt32Ptr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700573 size: sizeInt32Ptr,
574 marshal: appendInt32Ptr,
575 unmarshal: consumeInt32Ptr,
Damien Neilc37adef2019-04-01 13:49:56 -0700576}
577
578// sizeInt32Slice returns the size of wire encoding a []int32 pointer as a repeated Int32.
579func sizeInt32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
580 s := *p.Int32Slice()
581 for _, v := range s {
582 size += tagsize + wire.SizeVarint(uint64(v))
583 }
584 return size
585}
586
587// appendInt32Slice encodes a []int32 pointer as a repeated Int32.
588func appendInt32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
589 s := *p.Int32Slice()
590 for _, v := range s {
591 b = wire.AppendVarint(b, wiretag)
592 b = wire.AppendVarint(b, uint64(v))
593 }
594 return b, nil
595}
596
Damien Neile91877d2019-06-27 10:54:42 -0700597// consumeInt32Slice wire decodes a []int32 pointer as a repeated Int32.
Damien Neilf0831e82020-01-21 14:25:12 -0800598func consumeInt32Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -0700599 sp := p.Int32Slice()
600 if wtyp == wire.BytesType {
601 s := *sp
Damien Neilf0831e82020-01-21 14:25:12 -0800602 b, n := wire.ConsumeBytes(b)
Damien Neile91877d2019-06-27 10:54:42 -0700603 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -0800604 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -0700605 }
606 for len(b) > 0 {
607 v, n := wire.ConsumeVarint(b)
608 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -0800609 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -0700610 }
611 s = append(s, int32(v))
612 b = b[n:]
613 }
614 *sp = s
Damien Neilf0831e82020-01-21 14:25:12 -0800615 out.n = n
616 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -0700617 }
618 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -0800619 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -0700620 }
621 v, n := wire.ConsumeVarint(b)
622 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -0800623 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -0700624 }
625 *sp = append(*sp, int32(v))
Damien Neilf0831e82020-01-21 14:25:12 -0800626 out.n = n
627 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -0700628}
629
Damien Neilc37adef2019-04-01 13:49:56 -0700630var coderInt32Slice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700631 size: sizeInt32Slice,
632 marshal: appendInt32Slice,
633 unmarshal: consumeInt32Slice,
Damien Neilc37adef2019-04-01 13:49:56 -0700634}
635
636// sizeInt32PackedSlice returns the size of wire encoding a []int32 pointer as a packed repeated Int32.
637func sizeInt32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
638 s := *p.Int32Slice()
639 if len(s) == 0 {
640 return 0
641 }
642 n := 0
643 for _, v := range s {
644 n += wire.SizeVarint(uint64(v))
645 }
646 return tagsize + wire.SizeBytes(n)
647}
648
649// appendInt32PackedSlice encodes a []int32 pointer as a packed repeated Int32.
650func appendInt32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
651 s := *p.Int32Slice()
652 if len(s) == 0 {
653 return b, nil
654 }
655 b = wire.AppendVarint(b, wiretag)
656 n := 0
657 for _, v := range s {
658 n += wire.SizeVarint(uint64(v))
659 }
660 b = wire.AppendVarint(b, uint64(n))
661 for _, v := range s {
662 b = wire.AppendVarint(b, uint64(v))
663 }
664 return b, nil
665}
666
667var coderInt32PackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700668 size: sizeInt32PackedSlice,
669 marshal: appendInt32PackedSlice,
670 unmarshal: consumeInt32Slice,
Damien Neilc37adef2019-04-01 13:49:56 -0700671}
672
Damien Neil68b81c32019-08-22 11:41:32 -0700673// sizeInt32Value returns the size of wire encoding a int32 value as a Int32.
674func sizeInt32Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
675 return tagsize + wire.SizeVarint(uint64(int32(v.Int())))
Damien Neilc37adef2019-04-01 13:49:56 -0700676}
677
Damien Neil68b81c32019-08-22 11:41:32 -0700678// appendInt32Value encodes a int32 value as a Int32.
679func appendInt32Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
Damien Neilc37adef2019-04-01 13:49:56 -0700680 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -0700681 b = wire.AppendVarint(b, uint64(int32(v.Int())))
Damien Neilc37adef2019-04-01 13:49:56 -0700682 return b, nil
683}
684
Damien Neil68b81c32019-08-22 11:41:32 -0700685// consumeInt32Value decodes a int32 value as a Int32.
Damien Neilf0831e82020-01-21 14:25:12 -0800686func consumeInt32Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -0700687 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -0800688 return protoreflect.Value{}, out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -0700689 }
690 v, n := wire.ConsumeVarint(b)
691 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -0800692 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -0700693 }
Damien Neilf0831e82020-01-21 14:25:12 -0800694 out.n = n
695 return protoreflect.ValueOfInt32(int32(v)), out, nil
Damien Neile91877d2019-06-27 10:54:42 -0700696}
697
Damien Neil68b81c32019-08-22 11:41:32 -0700698var coderInt32Value = valueCoderFuncs{
699 size: sizeInt32Value,
700 marshal: appendInt32Value,
701 unmarshal: consumeInt32Value,
Damien Neilc37adef2019-04-01 13:49:56 -0700702}
703
Damien Neil68b81c32019-08-22 11:41:32 -0700704// sizeInt32SliceValue returns the size of wire encoding a []int32 value as a repeated Int32.
705func sizeInt32SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
706 list := listv.List()
707 for i, llen := 0, list.Len(); i < llen; i++ {
708 v := list.Get(i)
709 size += tagsize + wire.SizeVarint(uint64(int32(v.Int())))
Damien Neilc37adef2019-04-01 13:49:56 -0700710 }
711 return size
712}
713
Damien Neil68b81c32019-08-22 11:41:32 -0700714// appendInt32SliceValue encodes a []int32 value as a repeated Int32.
715func appendInt32SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
716 list := listv.List()
717 for i, llen := 0, list.Len(); i < llen; i++ {
718 v := list.Get(i)
Damien Neilc37adef2019-04-01 13:49:56 -0700719 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -0700720 b = wire.AppendVarint(b, uint64(int32(v.Int())))
Damien Neilc37adef2019-04-01 13:49:56 -0700721 }
722 return b, nil
723}
724
Damien Neil68b81c32019-08-22 11:41:32 -0700725// consumeInt32SliceValue wire decodes a []int32 value as a repeated Int32.
Damien Neilf0831e82020-01-21 14:25:12 -0800726func consumeInt32SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neil68b81c32019-08-22 11:41:32 -0700727 list := listv.List()
Damien Neile91877d2019-06-27 10:54:42 -0700728 if wtyp == wire.BytesType {
Damien Neilf0831e82020-01-21 14:25:12 -0800729 b, n := wire.ConsumeBytes(b)
Damien Neile91877d2019-06-27 10:54:42 -0700730 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -0800731 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -0700732 }
733 for len(b) > 0 {
734 v, n := wire.ConsumeVarint(b)
735 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -0800736 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -0700737 }
Damien Neil68b81c32019-08-22 11:41:32 -0700738 list.Append(protoreflect.ValueOfInt32(int32(v)))
Damien Neile91877d2019-06-27 10:54:42 -0700739 b = b[n:]
740 }
Damien Neilf0831e82020-01-21 14:25:12 -0800741 out.n = n
742 return listv, out, nil
Damien Neile91877d2019-06-27 10:54:42 -0700743 }
744 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -0800745 return protoreflect.Value{}, out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -0700746 }
747 v, n := wire.ConsumeVarint(b)
748 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -0800749 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -0700750 }
Damien Neil68b81c32019-08-22 11:41:32 -0700751 list.Append(protoreflect.ValueOfInt32(int32(v)))
Damien Neilf0831e82020-01-21 14:25:12 -0800752 out.n = n
753 return listv, out, nil
Damien Neile91877d2019-06-27 10:54:42 -0700754}
755
Damien Neil68b81c32019-08-22 11:41:32 -0700756var coderInt32SliceValue = valueCoderFuncs{
757 size: sizeInt32SliceValue,
758 marshal: appendInt32SliceValue,
759 unmarshal: consumeInt32SliceValue,
Damien Neilc37adef2019-04-01 13:49:56 -0700760}
761
Damien Neil68b81c32019-08-22 11:41:32 -0700762// sizeInt32PackedSliceValue returns the size of wire encoding a []int32 value as a packed repeated Int32.
763func sizeInt32PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
764 list := listv.List()
Damien Neil2c0824b2019-12-20 12:21:25 -0800765 llen := list.Len()
766 if llen == 0 {
767 return 0
768 }
Damien Neil7492a092019-07-10 15:23:29 -0700769 n := 0
Damien Neil2c0824b2019-12-20 12:21:25 -0800770 for i, llen := 0, llen; i < llen; i++ {
Damien Neil68b81c32019-08-22 11:41:32 -0700771 v := list.Get(i)
772 n += wire.SizeVarint(uint64(int32(v.Int())))
Damien Neil7492a092019-07-10 15:23:29 -0700773 }
774 return tagsize + wire.SizeBytes(n)
775}
776
Damien Neil68b81c32019-08-22 11:41:32 -0700777// appendInt32PackedSliceValue encodes a []int32 value as a packed repeated Int32.
778func appendInt32PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
779 list := listv.List()
780 llen := list.Len()
781 if llen == 0 {
Damien Neil7492a092019-07-10 15:23:29 -0700782 return b, nil
783 }
784 b = wire.AppendVarint(b, wiretag)
785 n := 0
Damien Neil68b81c32019-08-22 11:41:32 -0700786 for i := 0; i < llen; i++ {
787 v := list.Get(i)
788 n += wire.SizeVarint(uint64(int32(v.Int())))
Damien Neil7492a092019-07-10 15:23:29 -0700789 }
790 b = wire.AppendVarint(b, uint64(n))
Damien Neil68b81c32019-08-22 11:41:32 -0700791 for i := 0; i < llen; i++ {
792 v := list.Get(i)
793 b = wire.AppendVarint(b, uint64(int32(v.Int())))
Damien Neil7492a092019-07-10 15:23:29 -0700794 }
795 return b, nil
796}
797
Damien Neil68b81c32019-08-22 11:41:32 -0700798var coderInt32PackedSliceValue = valueCoderFuncs{
799 size: sizeInt32PackedSliceValue,
800 marshal: appendInt32PackedSliceValue,
801 unmarshal: consumeInt32SliceValue,
Damien Neil7492a092019-07-10 15:23:29 -0700802}
803
Damien Neilc37adef2019-04-01 13:49:56 -0700804// sizeSint32 returns the size of wire encoding a int32 pointer as a Sint32.
805func sizeSint32(p pointer, tagsize int, _ marshalOptions) (size int) {
806 v := *p.Int32()
807 return tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
808}
809
810// appendSint32 wire encodes a int32 pointer as a Sint32.
811func appendSint32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
812 v := *p.Int32()
813 b = wire.AppendVarint(b, wiretag)
814 b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
815 return b, nil
816}
817
Damien Neile91877d2019-06-27 10:54:42 -0700818// consumeSint32 wire decodes a int32 pointer as a Sint32.
Damien Neilf0831e82020-01-21 14:25:12 -0800819func consumeSint32(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -0700820 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -0800821 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -0700822 }
823 v, n := wire.ConsumeVarint(b)
824 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -0800825 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -0700826 }
827 *p.Int32() = int32(wire.DecodeZigZag(v & math.MaxUint32))
Damien Neilf0831e82020-01-21 14:25:12 -0800828 out.n = n
829 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -0700830}
831
Damien Neilc37adef2019-04-01 13:49:56 -0700832var coderSint32 = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700833 size: sizeSint32,
834 marshal: appendSint32,
835 unmarshal: consumeSint32,
Damien Neilc37adef2019-04-01 13:49:56 -0700836}
837
Joe Tsaic51e2e02019-07-13 00:44:41 -0700838// sizeSint32NoZero returns the size of wire encoding a int32 pointer as a Sint32.
Damien Neilc37adef2019-04-01 13:49:56 -0700839// The zero value is not encoded.
840func sizeSint32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
841 v := *p.Int32()
842 if v == 0 {
843 return 0
844 }
845 return tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
846}
847
Joe Tsaic51e2e02019-07-13 00:44:41 -0700848// appendSint32NoZero wire encodes a int32 pointer as a Sint32.
Damien Neilc37adef2019-04-01 13:49:56 -0700849// The zero value is not encoded.
850func appendSint32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
851 v := *p.Int32()
852 if v == 0 {
853 return b, nil
854 }
855 b = wire.AppendVarint(b, wiretag)
856 b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
857 return b, nil
858}
859
860var coderSint32NoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700861 size: sizeSint32NoZero,
862 marshal: appendSint32NoZero,
863 unmarshal: consumeSint32,
Damien Neilc37adef2019-04-01 13:49:56 -0700864}
865
866// sizeSint32Ptr returns the size of wire encoding a *int32 pointer as a Sint32.
867// It panics if the pointer is nil.
868func sizeSint32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
869 v := **p.Int32Ptr()
870 return tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
871}
872
Damien Neile91877d2019-06-27 10:54:42 -0700873// appendSint32Ptr wire encodes a *int32 pointer as a Sint32.
Damien Neilc37adef2019-04-01 13:49:56 -0700874// It panics if the pointer is nil.
875func appendSint32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
876 v := **p.Int32Ptr()
877 b = wire.AppendVarint(b, wiretag)
878 b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
879 return b, nil
880}
881
Damien Neile91877d2019-06-27 10:54:42 -0700882// consumeSint32Ptr wire decodes a *int32 pointer as a Sint32.
Damien Neilf0831e82020-01-21 14:25:12 -0800883func consumeSint32Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -0700884 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -0800885 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -0700886 }
887 v, n := wire.ConsumeVarint(b)
888 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -0800889 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -0700890 }
891 vp := p.Int32Ptr()
892 if *vp == nil {
893 *vp = new(int32)
894 }
895 **vp = int32(wire.DecodeZigZag(v & math.MaxUint32))
Damien Neilf0831e82020-01-21 14:25:12 -0800896 out.n = n
897 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -0700898}
899
Damien Neilc37adef2019-04-01 13:49:56 -0700900var coderSint32Ptr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700901 size: sizeSint32Ptr,
902 marshal: appendSint32Ptr,
903 unmarshal: consumeSint32Ptr,
Damien Neilc37adef2019-04-01 13:49:56 -0700904}
905
906// sizeSint32Slice returns the size of wire encoding a []int32 pointer as a repeated Sint32.
907func sizeSint32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
908 s := *p.Int32Slice()
909 for _, v := range s {
910 size += tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
911 }
912 return size
913}
914
915// appendSint32Slice encodes a []int32 pointer as a repeated Sint32.
916func appendSint32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
917 s := *p.Int32Slice()
918 for _, v := range s {
919 b = wire.AppendVarint(b, wiretag)
920 b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
921 }
922 return b, nil
923}
924
Damien Neile91877d2019-06-27 10:54:42 -0700925// consumeSint32Slice wire decodes a []int32 pointer as a repeated Sint32.
Damien Neilf0831e82020-01-21 14:25:12 -0800926func consumeSint32Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -0700927 sp := p.Int32Slice()
928 if wtyp == wire.BytesType {
929 s := *sp
Damien Neilf0831e82020-01-21 14:25:12 -0800930 b, n := wire.ConsumeBytes(b)
Damien Neile91877d2019-06-27 10:54:42 -0700931 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -0800932 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -0700933 }
934 for len(b) > 0 {
935 v, n := wire.ConsumeVarint(b)
936 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -0800937 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -0700938 }
939 s = append(s, int32(wire.DecodeZigZag(v&math.MaxUint32)))
940 b = b[n:]
941 }
942 *sp = s
Damien Neilf0831e82020-01-21 14:25:12 -0800943 out.n = n
944 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -0700945 }
946 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -0800947 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -0700948 }
949 v, n := wire.ConsumeVarint(b)
950 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -0800951 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -0700952 }
953 *sp = append(*sp, int32(wire.DecodeZigZag(v&math.MaxUint32)))
Damien Neilf0831e82020-01-21 14:25:12 -0800954 out.n = n
955 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -0700956}
957
Damien Neilc37adef2019-04-01 13:49:56 -0700958var coderSint32Slice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700959 size: sizeSint32Slice,
960 marshal: appendSint32Slice,
961 unmarshal: consumeSint32Slice,
Damien Neilc37adef2019-04-01 13:49:56 -0700962}
963
964// sizeSint32PackedSlice returns the size of wire encoding a []int32 pointer as a packed repeated Sint32.
965func sizeSint32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
966 s := *p.Int32Slice()
967 if len(s) == 0 {
968 return 0
969 }
970 n := 0
971 for _, v := range s {
972 n += wire.SizeVarint(wire.EncodeZigZag(int64(v)))
973 }
974 return tagsize + wire.SizeBytes(n)
975}
976
977// appendSint32PackedSlice encodes a []int32 pointer as a packed repeated Sint32.
978func appendSint32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
979 s := *p.Int32Slice()
980 if len(s) == 0 {
981 return b, nil
982 }
983 b = wire.AppendVarint(b, wiretag)
984 n := 0
985 for _, v := range s {
986 n += wire.SizeVarint(wire.EncodeZigZag(int64(v)))
987 }
988 b = wire.AppendVarint(b, uint64(n))
989 for _, v := range s {
990 b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
991 }
992 return b, nil
993}
994
995var coderSint32PackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -0700996 size: sizeSint32PackedSlice,
997 marshal: appendSint32PackedSlice,
998 unmarshal: consumeSint32Slice,
Damien Neilc37adef2019-04-01 13:49:56 -0700999}
1000
Damien Neil68b81c32019-08-22 11:41:32 -07001001// sizeSint32Value returns the size of wire encoding a int32 value as a Sint32.
1002func sizeSint32Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
1003 return tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(int32(v.Int()))))
Damien Neilc37adef2019-04-01 13:49:56 -07001004}
1005
Damien Neil68b81c32019-08-22 11:41:32 -07001006// appendSint32Value encodes a int32 value as a Sint32.
1007func appendSint32Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
Damien Neilc37adef2019-04-01 13:49:56 -07001008 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07001009 b = wire.AppendVarint(b, wire.EncodeZigZag(int64(int32(v.Int()))))
Damien Neilc37adef2019-04-01 13:49:56 -07001010 return b, nil
1011}
1012
Damien Neil68b81c32019-08-22 11:41:32 -07001013// consumeSint32Value decodes a int32 value as a Sint32.
Damien Neilf0831e82020-01-21 14:25:12 -08001014func consumeSint32Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07001015 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -08001016 return protoreflect.Value{}, out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07001017 }
1018 v, n := wire.ConsumeVarint(b)
1019 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08001020 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07001021 }
Damien Neilf0831e82020-01-21 14:25:12 -08001022 out.n = n
1023 return protoreflect.ValueOfInt32(int32(wire.DecodeZigZag(v & math.MaxUint32))), out, nil
Damien Neile91877d2019-06-27 10:54:42 -07001024}
1025
Damien Neil68b81c32019-08-22 11:41:32 -07001026var coderSint32Value = valueCoderFuncs{
1027 size: sizeSint32Value,
1028 marshal: appendSint32Value,
1029 unmarshal: consumeSint32Value,
Damien Neilc37adef2019-04-01 13:49:56 -07001030}
1031
Damien Neil68b81c32019-08-22 11:41:32 -07001032// sizeSint32SliceValue returns the size of wire encoding a []int32 value as a repeated Sint32.
1033func sizeSint32SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
1034 list := listv.List()
1035 for i, llen := 0, list.Len(); i < llen; i++ {
1036 v := list.Get(i)
1037 size += tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(int32(v.Int()))))
Damien Neilc37adef2019-04-01 13:49:56 -07001038 }
1039 return size
1040}
1041
Damien Neil68b81c32019-08-22 11:41:32 -07001042// appendSint32SliceValue encodes a []int32 value as a repeated Sint32.
1043func appendSint32SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
1044 list := listv.List()
1045 for i, llen := 0, list.Len(); i < llen; i++ {
1046 v := list.Get(i)
Damien Neilc37adef2019-04-01 13:49:56 -07001047 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07001048 b = wire.AppendVarint(b, wire.EncodeZigZag(int64(int32(v.Int()))))
Damien Neilc37adef2019-04-01 13:49:56 -07001049 }
1050 return b, nil
1051}
1052
Damien Neil68b81c32019-08-22 11:41:32 -07001053// consumeSint32SliceValue wire decodes a []int32 value as a repeated Sint32.
Damien Neilf0831e82020-01-21 14:25:12 -08001054func consumeSint32SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neil68b81c32019-08-22 11:41:32 -07001055 list := listv.List()
Damien Neile91877d2019-06-27 10:54:42 -07001056 if wtyp == wire.BytesType {
Damien Neilf0831e82020-01-21 14:25:12 -08001057 b, n := wire.ConsumeBytes(b)
Damien Neile91877d2019-06-27 10:54:42 -07001058 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08001059 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07001060 }
1061 for len(b) > 0 {
1062 v, n := wire.ConsumeVarint(b)
1063 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08001064 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07001065 }
Damien Neil68b81c32019-08-22 11:41:32 -07001066 list.Append(protoreflect.ValueOfInt32(int32(wire.DecodeZigZag(v & math.MaxUint32))))
Damien Neile91877d2019-06-27 10:54:42 -07001067 b = b[n:]
1068 }
Damien Neilf0831e82020-01-21 14:25:12 -08001069 out.n = n
1070 return listv, out, nil
Damien Neile91877d2019-06-27 10:54:42 -07001071 }
1072 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -08001073 return protoreflect.Value{}, out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07001074 }
1075 v, n := wire.ConsumeVarint(b)
1076 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08001077 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07001078 }
Damien Neil68b81c32019-08-22 11:41:32 -07001079 list.Append(protoreflect.ValueOfInt32(int32(wire.DecodeZigZag(v & math.MaxUint32))))
Damien Neilf0831e82020-01-21 14:25:12 -08001080 out.n = n
1081 return listv, out, nil
Damien Neile91877d2019-06-27 10:54:42 -07001082}
1083
Damien Neil68b81c32019-08-22 11:41:32 -07001084var coderSint32SliceValue = valueCoderFuncs{
1085 size: sizeSint32SliceValue,
1086 marshal: appendSint32SliceValue,
1087 unmarshal: consumeSint32SliceValue,
Damien Neilc37adef2019-04-01 13:49:56 -07001088}
1089
Damien Neil68b81c32019-08-22 11:41:32 -07001090// sizeSint32PackedSliceValue returns the size of wire encoding a []int32 value as a packed repeated Sint32.
1091func sizeSint32PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
1092 list := listv.List()
Damien Neil2c0824b2019-12-20 12:21:25 -08001093 llen := list.Len()
1094 if llen == 0 {
1095 return 0
1096 }
Damien Neil7492a092019-07-10 15:23:29 -07001097 n := 0
Damien Neil2c0824b2019-12-20 12:21:25 -08001098 for i, llen := 0, llen; i < llen; i++ {
Damien Neil68b81c32019-08-22 11:41:32 -07001099 v := list.Get(i)
1100 n += wire.SizeVarint(wire.EncodeZigZag(int64(int32(v.Int()))))
Damien Neil7492a092019-07-10 15:23:29 -07001101 }
1102 return tagsize + wire.SizeBytes(n)
1103}
1104
Damien Neil68b81c32019-08-22 11:41:32 -07001105// appendSint32PackedSliceValue encodes a []int32 value as a packed repeated Sint32.
1106func appendSint32PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
1107 list := listv.List()
1108 llen := list.Len()
1109 if llen == 0 {
Damien Neil7492a092019-07-10 15:23:29 -07001110 return b, nil
1111 }
1112 b = wire.AppendVarint(b, wiretag)
1113 n := 0
Damien Neil68b81c32019-08-22 11:41:32 -07001114 for i := 0; i < llen; i++ {
1115 v := list.Get(i)
1116 n += wire.SizeVarint(wire.EncodeZigZag(int64(int32(v.Int()))))
Damien Neil7492a092019-07-10 15:23:29 -07001117 }
1118 b = wire.AppendVarint(b, uint64(n))
Damien Neil68b81c32019-08-22 11:41:32 -07001119 for i := 0; i < llen; i++ {
1120 v := list.Get(i)
1121 b = wire.AppendVarint(b, wire.EncodeZigZag(int64(int32(v.Int()))))
Damien Neil7492a092019-07-10 15:23:29 -07001122 }
1123 return b, nil
1124}
1125
Damien Neil68b81c32019-08-22 11:41:32 -07001126var coderSint32PackedSliceValue = valueCoderFuncs{
1127 size: sizeSint32PackedSliceValue,
1128 marshal: appendSint32PackedSliceValue,
1129 unmarshal: consumeSint32SliceValue,
Damien Neil7492a092019-07-10 15:23:29 -07001130}
1131
Damien Neilc37adef2019-04-01 13:49:56 -07001132// sizeUint32 returns the size of wire encoding a uint32 pointer as a Uint32.
1133func sizeUint32(p pointer, tagsize int, _ marshalOptions) (size int) {
1134 v := *p.Uint32()
1135 return tagsize + wire.SizeVarint(uint64(v))
1136}
1137
1138// appendUint32 wire encodes a uint32 pointer as a Uint32.
1139func appendUint32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1140 v := *p.Uint32()
1141 b = wire.AppendVarint(b, wiretag)
1142 b = wire.AppendVarint(b, uint64(v))
1143 return b, nil
1144}
1145
Damien Neile91877d2019-06-27 10:54:42 -07001146// consumeUint32 wire decodes a uint32 pointer as a Uint32.
Damien Neilf0831e82020-01-21 14:25:12 -08001147func consumeUint32(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07001148 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -08001149 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07001150 }
1151 v, n := wire.ConsumeVarint(b)
1152 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08001153 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07001154 }
1155 *p.Uint32() = uint32(v)
Damien Neilf0831e82020-01-21 14:25:12 -08001156 out.n = n
1157 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07001158}
1159
Damien Neilc37adef2019-04-01 13:49:56 -07001160var coderUint32 = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001161 size: sizeUint32,
1162 marshal: appendUint32,
1163 unmarshal: consumeUint32,
Damien Neilc37adef2019-04-01 13:49:56 -07001164}
1165
Joe Tsaic51e2e02019-07-13 00:44:41 -07001166// sizeUint32NoZero returns the size of wire encoding a uint32 pointer as a Uint32.
Damien Neilc37adef2019-04-01 13:49:56 -07001167// The zero value is not encoded.
1168func sizeUint32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
1169 v := *p.Uint32()
1170 if v == 0 {
1171 return 0
1172 }
1173 return tagsize + wire.SizeVarint(uint64(v))
1174}
1175
Joe Tsaic51e2e02019-07-13 00:44:41 -07001176// appendUint32NoZero wire encodes a uint32 pointer as a Uint32.
Damien Neilc37adef2019-04-01 13:49:56 -07001177// The zero value is not encoded.
1178func appendUint32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1179 v := *p.Uint32()
1180 if v == 0 {
1181 return b, nil
1182 }
1183 b = wire.AppendVarint(b, wiretag)
1184 b = wire.AppendVarint(b, uint64(v))
1185 return b, nil
1186}
1187
1188var coderUint32NoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001189 size: sizeUint32NoZero,
1190 marshal: appendUint32NoZero,
1191 unmarshal: consumeUint32,
Damien Neilc37adef2019-04-01 13:49:56 -07001192}
1193
1194// sizeUint32Ptr returns the size of wire encoding a *uint32 pointer as a Uint32.
1195// It panics if the pointer is nil.
1196func sizeUint32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
1197 v := **p.Uint32Ptr()
1198 return tagsize + wire.SizeVarint(uint64(v))
1199}
1200
Damien Neile91877d2019-06-27 10:54:42 -07001201// appendUint32Ptr wire encodes a *uint32 pointer as a Uint32.
Damien Neilc37adef2019-04-01 13:49:56 -07001202// It panics if the pointer is nil.
1203func appendUint32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1204 v := **p.Uint32Ptr()
1205 b = wire.AppendVarint(b, wiretag)
1206 b = wire.AppendVarint(b, uint64(v))
1207 return b, nil
1208}
1209
Damien Neile91877d2019-06-27 10:54:42 -07001210// consumeUint32Ptr wire decodes a *uint32 pointer as a Uint32.
Damien Neilf0831e82020-01-21 14:25:12 -08001211func consumeUint32Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07001212 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -08001213 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07001214 }
1215 v, n := wire.ConsumeVarint(b)
1216 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08001217 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07001218 }
1219 vp := p.Uint32Ptr()
1220 if *vp == nil {
1221 *vp = new(uint32)
1222 }
1223 **vp = uint32(v)
Damien Neilf0831e82020-01-21 14:25:12 -08001224 out.n = n
1225 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07001226}
1227
Damien Neilc37adef2019-04-01 13:49:56 -07001228var coderUint32Ptr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001229 size: sizeUint32Ptr,
1230 marshal: appendUint32Ptr,
1231 unmarshal: consumeUint32Ptr,
Damien Neilc37adef2019-04-01 13:49:56 -07001232}
1233
1234// sizeUint32Slice returns the size of wire encoding a []uint32 pointer as a repeated Uint32.
1235func sizeUint32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
1236 s := *p.Uint32Slice()
1237 for _, v := range s {
1238 size += tagsize + wire.SizeVarint(uint64(v))
1239 }
1240 return size
1241}
1242
1243// appendUint32Slice encodes a []uint32 pointer as a repeated Uint32.
1244func appendUint32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1245 s := *p.Uint32Slice()
1246 for _, v := range s {
1247 b = wire.AppendVarint(b, wiretag)
1248 b = wire.AppendVarint(b, uint64(v))
1249 }
1250 return b, nil
1251}
1252
Damien Neile91877d2019-06-27 10:54:42 -07001253// consumeUint32Slice wire decodes a []uint32 pointer as a repeated Uint32.
Damien Neilf0831e82020-01-21 14:25:12 -08001254func consumeUint32Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07001255 sp := p.Uint32Slice()
1256 if wtyp == wire.BytesType {
1257 s := *sp
Damien Neilf0831e82020-01-21 14:25:12 -08001258 b, n := wire.ConsumeBytes(b)
Damien Neile91877d2019-06-27 10:54:42 -07001259 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08001260 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07001261 }
1262 for len(b) > 0 {
1263 v, n := wire.ConsumeVarint(b)
1264 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08001265 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07001266 }
1267 s = append(s, uint32(v))
1268 b = b[n:]
1269 }
1270 *sp = s
Damien Neilf0831e82020-01-21 14:25:12 -08001271 out.n = n
1272 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07001273 }
1274 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -08001275 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07001276 }
1277 v, n := wire.ConsumeVarint(b)
1278 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08001279 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07001280 }
1281 *sp = append(*sp, uint32(v))
Damien Neilf0831e82020-01-21 14:25:12 -08001282 out.n = n
1283 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07001284}
1285
Damien Neilc37adef2019-04-01 13:49:56 -07001286var coderUint32Slice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001287 size: sizeUint32Slice,
1288 marshal: appendUint32Slice,
1289 unmarshal: consumeUint32Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07001290}
1291
1292// sizeUint32PackedSlice returns the size of wire encoding a []uint32 pointer as a packed repeated Uint32.
1293func sizeUint32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
1294 s := *p.Uint32Slice()
1295 if len(s) == 0 {
1296 return 0
1297 }
1298 n := 0
1299 for _, v := range s {
1300 n += wire.SizeVarint(uint64(v))
1301 }
1302 return tagsize + wire.SizeBytes(n)
1303}
1304
1305// appendUint32PackedSlice encodes a []uint32 pointer as a packed repeated Uint32.
1306func appendUint32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1307 s := *p.Uint32Slice()
1308 if len(s) == 0 {
1309 return b, nil
1310 }
1311 b = wire.AppendVarint(b, wiretag)
1312 n := 0
1313 for _, v := range s {
1314 n += wire.SizeVarint(uint64(v))
1315 }
1316 b = wire.AppendVarint(b, uint64(n))
1317 for _, v := range s {
1318 b = wire.AppendVarint(b, uint64(v))
1319 }
1320 return b, nil
1321}
1322
1323var coderUint32PackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001324 size: sizeUint32PackedSlice,
1325 marshal: appendUint32PackedSlice,
1326 unmarshal: consumeUint32Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07001327}
1328
Damien Neil68b81c32019-08-22 11:41:32 -07001329// sizeUint32Value returns the size of wire encoding a uint32 value as a Uint32.
1330func sizeUint32Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
1331 return tagsize + wire.SizeVarint(uint64(uint32(v.Uint())))
Damien Neilc37adef2019-04-01 13:49:56 -07001332}
1333
Damien Neil68b81c32019-08-22 11:41:32 -07001334// appendUint32Value encodes a uint32 value as a Uint32.
1335func appendUint32Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
Damien Neilc37adef2019-04-01 13:49:56 -07001336 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07001337 b = wire.AppendVarint(b, uint64(uint32(v.Uint())))
Damien Neilc37adef2019-04-01 13:49:56 -07001338 return b, nil
1339}
1340
Damien Neil68b81c32019-08-22 11:41:32 -07001341// consumeUint32Value decodes a uint32 value as a Uint32.
Damien Neilf0831e82020-01-21 14:25:12 -08001342func consumeUint32Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07001343 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -08001344 return protoreflect.Value{}, out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07001345 }
1346 v, n := wire.ConsumeVarint(b)
1347 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08001348 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07001349 }
Damien Neilf0831e82020-01-21 14:25:12 -08001350 out.n = n
1351 return protoreflect.ValueOfUint32(uint32(v)), out, nil
Damien Neile91877d2019-06-27 10:54:42 -07001352}
1353
Damien Neil68b81c32019-08-22 11:41:32 -07001354var coderUint32Value = valueCoderFuncs{
1355 size: sizeUint32Value,
1356 marshal: appendUint32Value,
1357 unmarshal: consumeUint32Value,
Damien Neilc37adef2019-04-01 13:49:56 -07001358}
1359
Damien Neil68b81c32019-08-22 11:41:32 -07001360// sizeUint32SliceValue returns the size of wire encoding a []uint32 value as a repeated Uint32.
1361func sizeUint32SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
1362 list := listv.List()
1363 for i, llen := 0, list.Len(); i < llen; i++ {
1364 v := list.Get(i)
1365 size += tagsize + wire.SizeVarint(uint64(uint32(v.Uint())))
Damien Neilc37adef2019-04-01 13:49:56 -07001366 }
1367 return size
1368}
1369
Damien Neil68b81c32019-08-22 11:41:32 -07001370// appendUint32SliceValue encodes a []uint32 value as a repeated Uint32.
1371func appendUint32SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
1372 list := listv.List()
1373 for i, llen := 0, list.Len(); i < llen; i++ {
1374 v := list.Get(i)
Damien Neilc37adef2019-04-01 13:49:56 -07001375 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07001376 b = wire.AppendVarint(b, uint64(uint32(v.Uint())))
Damien Neilc37adef2019-04-01 13:49:56 -07001377 }
1378 return b, nil
1379}
1380
Damien Neil68b81c32019-08-22 11:41:32 -07001381// consumeUint32SliceValue wire decodes a []uint32 value as a repeated Uint32.
Damien Neilf0831e82020-01-21 14:25:12 -08001382func consumeUint32SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neil68b81c32019-08-22 11:41:32 -07001383 list := listv.List()
Damien Neile91877d2019-06-27 10:54:42 -07001384 if wtyp == wire.BytesType {
Damien Neilf0831e82020-01-21 14:25:12 -08001385 b, n := wire.ConsumeBytes(b)
Damien Neile91877d2019-06-27 10:54:42 -07001386 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08001387 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07001388 }
1389 for len(b) > 0 {
1390 v, n := wire.ConsumeVarint(b)
1391 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08001392 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07001393 }
Damien Neil68b81c32019-08-22 11:41:32 -07001394 list.Append(protoreflect.ValueOfUint32(uint32(v)))
Damien Neile91877d2019-06-27 10:54:42 -07001395 b = b[n:]
1396 }
Damien Neilf0831e82020-01-21 14:25:12 -08001397 out.n = n
1398 return listv, out, nil
Damien Neile91877d2019-06-27 10:54:42 -07001399 }
1400 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -08001401 return protoreflect.Value{}, out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07001402 }
1403 v, n := wire.ConsumeVarint(b)
1404 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08001405 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07001406 }
Damien Neil68b81c32019-08-22 11:41:32 -07001407 list.Append(protoreflect.ValueOfUint32(uint32(v)))
Damien Neilf0831e82020-01-21 14:25:12 -08001408 out.n = n
1409 return listv, out, nil
Damien Neile91877d2019-06-27 10:54:42 -07001410}
1411
Damien Neil68b81c32019-08-22 11:41:32 -07001412var coderUint32SliceValue = valueCoderFuncs{
1413 size: sizeUint32SliceValue,
1414 marshal: appendUint32SliceValue,
1415 unmarshal: consumeUint32SliceValue,
Damien Neilc37adef2019-04-01 13:49:56 -07001416}
1417
Damien Neil68b81c32019-08-22 11:41:32 -07001418// sizeUint32PackedSliceValue returns the size of wire encoding a []uint32 value as a packed repeated Uint32.
1419func sizeUint32PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
1420 list := listv.List()
Damien Neil2c0824b2019-12-20 12:21:25 -08001421 llen := list.Len()
1422 if llen == 0 {
1423 return 0
1424 }
Damien Neil7492a092019-07-10 15:23:29 -07001425 n := 0
Damien Neil2c0824b2019-12-20 12:21:25 -08001426 for i, llen := 0, llen; i < llen; i++ {
Damien Neil68b81c32019-08-22 11:41:32 -07001427 v := list.Get(i)
1428 n += wire.SizeVarint(uint64(uint32(v.Uint())))
Damien Neil7492a092019-07-10 15:23:29 -07001429 }
1430 return tagsize + wire.SizeBytes(n)
1431}
1432
Damien Neil68b81c32019-08-22 11:41:32 -07001433// appendUint32PackedSliceValue encodes a []uint32 value as a packed repeated Uint32.
1434func appendUint32PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
1435 list := listv.List()
1436 llen := list.Len()
1437 if llen == 0 {
Damien Neil7492a092019-07-10 15:23:29 -07001438 return b, nil
1439 }
1440 b = wire.AppendVarint(b, wiretag)
1441 n := 0
Damien Neil68b81c32019-08-22 11:41:32 -07001442 for i := 0; i < llen; i++ {
1443 v := list.Get(i)
1444 n += wire.SizeVarint(uint64(uint32(v.Uint())))
Damien Neil7492a092019-07-10 15:23:29 -07001445 }
1446 b = wire.AppendVarint(b, uint64(n))
Damien Neil68b81c32019-08-22 11:41:32 -07001447 for i := 0; i < llen; i++ {
1448 v := list.Get(i)
1449 b = wire.AppendVarint(b, uint64(uint32(v.Uint())))
Damien Neil7492a092019-07-10 15:23:29 -07001450 }
1451 return b, nil
1452}
1453
Damien Neil68b81c32019-08-22 11:41:32 -07001454var coderUint32PackedSliceValue = valueCoderFuncs{
1455 size: sizeUint32PackedSliceValue,
1456 marshal: appendUint32PackedSliceValue,
1457 unmarshal: consumeUint32SliceValue,
Damien Neil7492a092019-07-10 15:23:29 -07001458}
1459
Damien Neilc37adef2019-04-01 13:49:56 -07001460// sizeInt64 returns the size of wire encoding a int64 pointer as a Int64.
1461func sizeInt64(p pointer, tagsize int, _ marshalOptions) (size int) {
1462 v := *p.Int64()
1463 return tagsize + wire.SizeVarint(uint64(v))
1464}
1465
1466// appendInt64 wire encodes a int64 pointer as a Int64.
1467func appendInt64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1468 v := *p.Int64()
1469 b = wire.AppendVarint(b, wiretag)
1470 b = wire.AppendVarint(b, uint64(v))
1471 return b, nil
1472}
1473
Damien Neile91877d2019-06-27 10:54:42 -07001474// consumeInt64 wire decodes a int64 pointer as a Int64.
Damien Neilf0831e82020-01-21 14:25:12 -08001475func consumeInt64(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07001476 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -08001477 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07001478 }
1479 v, n := wire.ConsumeVarint(b)
1480 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08001481 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07001482 }
1483 *p.Int64() = int64(v)
Damien Neilf0831e82020-01-21 14:25:12 -08001484 out.n = n
1485 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07001486}
1487
Damien Neilc37adef2019-04-01 13:49:56 -07001488var coderInt64 = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001489 size: sizeInt64,
1490 marshal: appendInt64,
1491 unmarshal: consumeInt64,
Damien Neilc37adef2019-04-01 13:49:56 -07001492}
1493
Joe Tsaic51e2e02019-07-13 00:44:41 -07001494// sizeInt64NoZero returns the size of wire encoding a int64 pointer as a Int64.
Damien Neilc37adef2019-04-01 13:49:56 -07001495// The zero value is not encoded.
1496func sizeInt64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
1497 v := *p.Int64()
1498 if v == 0 {
1499 return 0
1500 }
1501 return tagsize + wire.SizeVarint(uint64(v))
1502}
1503
Joe Tsaic51e2e02019-07-13 00:44:41 -07001504// appendInt64NoZero wire encodes a int64 pointer as a Int64.
Damien Neilc37adef2019-04-01 13:49:56 -07001505// The zero value is not encoded.
1506func appendInt64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1507 v := *p.Int64()
1508 if v == 0 {
1509 return b, nil
1510 }
1511 b = wire.AppendVarint(b, wiretag)
1512 b = wire.AppendVarint(b, uint64(v))
1513 return b, nil
1514}
1515
1516var coderInt64NoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001517 size: sizeInt64NoZero,
1518 marshal: appendInt64NoZero,
1519 unmarshal: consumeInt64,
Damien Neilc37adef2019-04-01 13:49:56 -07001520}
1521
1522// sizeInt64Ptr returns the size of wire encoding a *int64 pointer as a Int64.
1523// It panics if the pointer is nil.
1524func sizeInt64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
1525 v := **p.Int64Ptr()
1526 return tagsize + wire.SizeVarint(uint64(v))
1527}
1528
Damien Neile91877d2019-06-27 10:54:42 -07001529// appendInt64Ptr wire encodes a *int64 pointer as a Int64.
Damien Neilc37adef2019-04-01 13:49:56 -07001530// It panics if the pointer is nil.
1531func appendInt64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1532 v := **p.Int64Ptr()
1533 b = wire.AppendVarint(b, wiretag)
1534 b = wire.AppendVarint(b, uint64(v))
1535 return b, nil
1536}
1537
Damien Neile91877d2019-06-27 10:54:42 -07001538// consumeInt64Ptr wire decodes a *int64 pointer as a Int64.
Damien Neilf0831e82020-01-21 14:25:12 -08001539func consumeInt64Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07001540 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -08001541 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07001542 }
1543 v, n := wire.ConsumeVarint(b)
1544 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08001545 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07001546 }
1547 vp := p.Int64Ptr()
1548 if *vp == nil {
1549 *vp = new(int64)
1550 }
1551 **vp = int64(v)
Damien Neilf0831e82020-01-21 14:25:12 -08001552 out.n = n
1553 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07001554}
1555
Damien Neilc37adef2019-04-01 13:49:56 -07001556var coderInt64Ptr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001557 size: sizeInt64Ptr,
1558 marshal: appendInt64Ptr,
1559 unmarshal: consumeInt64Ptr,
Damien Neilc37adef2019-04-01 13:49:56 -07001560}
1561
1562// sizeInt64Slice returns the size of wire encoding a []int64 pointer as a repeated Int64.
1563func sizeInt64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
1564 s := *p.Int64Slice()
1565 for _, v := range s {
1566 size += tagsize + wire.SizeVarint(uint64(v))
1567 }
1568 return size
1569}
1570
1571// appendInt64Slice encodes a []int64 pointer as a repeated Int64.
1572func appendInt64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1573 s := *p.Int64Slice()
1574 for _, v := range s {
1575 b = wire.AppendVarint(b, wiretag)
1576 b = wire.AppendVarint(b, uint64(v))
1577 }
1578 return b, nil
1579}
1580
Damien Neile91877d2019-06-27 10:54:42 -07001581// consumeInt64Slice wire decodes a []int64 pointer as a repeated Int64.
Damien Neilf0831e82020-01-21 14:25:12 -08001582func consumeInt64Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07001583 sp := p.Int64Slice()
1584 if wtyp == wire.BytesType {
1585 s := *sp
Damien Neilf0831e82020-01-21 14:25:12 -08001586 b, n := wire.ConsumeBytes(b)
Damien Neile91877d2019-06-27 10:54:42 -07001587 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08001588 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07001589 }
1590 for len(b) > 0 {
1591 v, n := wire.ConsumeVarint(b)
1592 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08001593 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07001594 }
1595 s = append(s, int64(v))
1596 b = b[n:]
1597 }
1598 *sp = s
Damien Neilf0831e82020-01-21 14:25:12 -08001599 out.n = n
1600 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07001601 }
1602 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -08001603 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07001604 }
1605 v, n := wire.ConsumeVarint(b)
1606 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08001607 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07001608 }
1609 *sp = append(*sp, int64(v))
Damien Neilf0831e82020-01-21 14:25:12 -08001610 out.n = n
1611 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07001612}
1613
Damien Neilc37adef2019-04-01 13:49:56 -07001614var coderInt64Slice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001615 size: sizeInt64Slice,
1616 marshal: appendInt64Slice,
1617 unmarshal: consumeInt64Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07001618}
1619
1620// sizeInt64PackedSlice returns the size of wire encoding a []int64 pointer as a packed repeated Int64.
1621func sizeInt64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
1622 s := *p.Int64Slice()
1623 if len(s) == 0 {
1624 return 0
1625 }
1626 n := 0
1627 for _, v := range s {
1628 n += wire.SizeVarint(uint64(v))
1629 }
1630 return tagsize + wire.SizeBytes(n)
1631}
1632
1633// appendInt64PackedSlice encodes a []int64 pointer as a packed repeated Int64.
1634func appendInt64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1635 s := *p.Int64Slice()
1636 if len(s) == 0 {
1637 return b, nil
1638 }
1639 b = wire.AppendVarint(b, wiretag)
1640 n := 0
1641 for _, v := range s {
1642 n += wire.SizeVarint(uint64(v))
1643 }
1644 b = wire.AppendVarint(b, uint64(n))
1645 for _, v := range s {
1646 b = wire.AppendVarint(b, uint64(v))
1647 }
1648 return b, nil
1649}
1650
1651var coderInt64PackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001652 size: sizeInt64PackedSlice,
1653 marshal: appendInt64PackedSlice,
1654 unmarshal: consumeInt64Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07001655}
1656
Damien Neil68b81c32019-08-22 11:41:32 -07001657// sizeInt64Value returns the size of wire encoding a int64 value as a Int64.
1658func sizeInt64Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
1659 return tagsize + wire.SizeVarint(uint64(v.Int()))
Damien Neilc37adef2019-04-01 13:49:56 -07001660}
1661
Damien Neil68b81c32019-08-22 11:41:32 -07001662// appendInt64Value encodes a int64 value as a Int64.
1663func appendInt64Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
Damien Neilc37adef2019-04-01 13:49:56 -07001664 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07001665 b = wire.AppendVarint(b, uint64(v.Int()))
Damien Neilc37adef2019-04-01 13:49:56 -07001666 return b, nil
1667}
1668
Damien Neil68b81c32019-08-22 11:41:32 -07001669// consumeInt64Value decodes a int64 value as a Int64.
Damien Neilf0831e82020-01-21 14:25:12 -08001670func consumeInt64Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07001671 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -08001672 return protoreflect.Value{}, out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07001673 }
1674 v, n := wire.ConsumeVarint(b)
1675 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08001676 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07001677 }
Damien Neilf0831e82020-01-21 14:25:12 -08001678 out.n = n
1679 return protoreflect.ValueOfInt64(int64(v)), out, nil
Damien Neile91877d2019-06-27 10:54:42 -07001680}
1681
Damien Neil68b81c32019-08-22 11:41:32 -07001682var coderInt64Value = valueCoderFuncs{
1683 size: sizeInt64Value,
1684 marshal: appendInt64Value,
1685 unmarshal: consumeInt64Value,
Damien Neilc37adef2019-04-01 13:49:56 -07001686}
1687
Damien Neil68b81c32019-08-22 11:41:32 -07001688// sizeInt64SliceValue returns the size of wire encoding a []int64 value as a repeated Int64.
1689func sizeInt64SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
1690 list := listv.List()
1691 for i, llen := 0, list.Len(); i < llen; i++ {
1692 v := list.Get(i)
1693 size += tagsize + wire.SizeVarint(uint64(v.Int()))
Damien Neilc37adef2019-04-01 13:49:56 -07001694 }
1695 return size
1696}
1697
Damien Neil68b81c32019-08-22 11:41:32 -07001698// appendInt64SliceValue encodes a []int64 value as a repeated Int64.
1699func appendInt64SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
1700 list := listv.List()
1701 for i, llen := 0, list.Len(); i < llen; i++ {
1702 v := list.Get(i)
Damien Neilc37adef2019-04-01 13:49:56 -07001703 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07001704 b = wire.AppendVarint(b, uint64(v.Int()))
Damien Neilc37adef2019-04-01 13:49:56 -07001705 }
1706 return b, nil
1707}
1708
Damien Neil68b81c32019-08-22 11:41:32 -07001709// consumeInt64SliceValue wire decodes a []int64 value as a repeated Int64.
Damien Neilf0831e82020-01-21 14:25:12 -08001710func consumeInt64SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neil68b81c32019-08-22 11:41:32 -07001711 list := listv.List()
Damien Neile91877d2019-06-27 10:54:42 -07001712 if wtyp == wire.BytesType {
Damien Neilf0831e82020-01-21 14:25:12 -08001713 b, n := wire.ConsumeBytes(b)
Damien Neile91877d2019-06-27 10:54:42 -07001714 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08001715 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07001716 }
1717 for len(b) > 0 {
1718 v, n := wire.ConsumeVarint(b)
1719 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08001720 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07001721 }
Damien Neil68b81c32019-08-22 11:41:32 -07001722 list.Append(protoreflect.ValueOfInt64(int64(v)))
Damien Neile91877d2019-06-27 10:54:42 -07001723 b = b[n:]
1724 }
Damien Neilf0831e82020-01-21 14:25:12 -08001725 out.n = n
1726 return listv, out, nil
Damien Neile91877d2019-06-27 10:54:42 -07001727 }
1728 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -08001729 return protoreflect.Value{}, out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07001730 }
1731 v, n := wire.ConsumeVarint(b)
1732 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08001733 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07001734 }
Damien Neil68b81c32019-08-22 11:41:32 -07001735 list.Append(protoreflect.ValueOfInt64(int64(v)))
Damien Neilf0831e82020-01-21 14:25:12 -08001736 out.n = n
1737 return listv, out, nil
Damien Neile91877d2019-06-27 10:54:42 -07001738}
1739
Damien Neil68b81c32019-08-22 11:41:32 -07001740var coderInt64SliceValue = valueCoderFuncs{
1741 size: sizeInt64SliceValue,
1742 marshal: appendInt64SliceValue,
1743 unmarshal: consumeInt64SliceValue,
Damien Neilc37adef2019-04-01 13:49:56 -07001744}
1745
Damien Neil68b81c32019-08-22 11:41:32 -07001746// sizeInt64PackedSliceValue returns the size of wire encoding a []int64 value as a packed repeated Int64.
1747func sizeInt64PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
1748 list := listv.List()
Damien Neil2c0824b2019-12-20 12:21:25 -08001749 llen := list.Len()
1750 if llen == 0 {
1751 return 0
1752 }
Damien Neil7492a092019-07-10 15:23:29 -07001753 n := 0
Damien Neil2c0824b2019-12-20 12:21:25 -08001754 for i, llen := 0, llen; i < llen; i++ {
Damien Neil68b81c32019-08-22 11:41:32 -07001755 v := list.Get(i)
1756 n += wire.SizeVarint(uint64(v.Int()))
Damien Neil7492a092019-07-10 15:23:29 -07001757 }
1758 return tagsize + wire.SizeBytes(n)
1759}
1760
Damien Neil68b81c32019-08-22 11:41:32 -07001761// appendInt64PackedSliceValue encodes a []int64 value as a packed repeated Int64.
1762func appendInt64PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
1763 list := listv.List()
1764 llen := list.Len()
1765 if llen == 0 {
Damien Neil7492a092019-07-10 15:23:29 -07001766 return b, nil
1767 }
1768 b = wire.AppendVarint(b, wiretag)
1769 n := 0
Damien Neil68b81c32019-08-22 11:41:32 -07001770 for i := 0; i < llen; i++ {
1771 v := list.Get(i)
1772 n += wire.SizeVarint(uint64(v.Int()))
Damien Neil7492a092019-07-10 15:23:29 -07001773 }
1774 b = wire.AppendVarint(b, uint64(n))
Damien Neil68b81c32019-08-22 11:41:32 -07001775 for i := 0; i < llen; i++ {
1776 v := list.Get(i)
1777 b = wire.AppendVarint(b, uint64(v.Int()))
Damien Neil7492a092019-07-10 15:23:29 -07001778 }
1779 return b, nil
1780}
1781
Damien Neil68b81c32019-08-22 11:41:32 -07001782var coderInt64PackedSliceValue = valueCoderFuncs{
1783 size: sizeInt64PackedSliceValue,
1784 marshal: appendInt64PackedSliceValue,
1785 unmarshal: consumeInt64SliceValue,
Damien Neil7492a092019-07-10 15:23:29 -07001786}
1787
Damien Neilc37adef2019-04-01 13:49:56 -07001788// sizeSint64 returns the size of wire encoding a int64 pointer as a Sint64.
1789func sizeSint64(p pointer, tagsize int, _ marshalOptions) (size int) {
1790 v := *p.Int64()
1791 return tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
1792}
1793
1794// appendSint64 wire encodes a int64 pointer as a Sint64.
1795func appendSint64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1796 v := *p.Int64()
1797 b = wire.AppendVarint(b, wiretag)
1798 b = wire.AppendVarint(b, wire.EncodeZigZag(v))
1799 return b, nil
1800}
1801
Damien Neile91877d2019-06-27 10:54:42 -07001802// consumeSint64 wire decodes a int64 pointer as a Sint64.
Damien Neilf0831e82020-01-21 14:25:12 -08001803func consumeSint64(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07001804 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -08001805 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07001806 }
1807 v, n := wire.ConsumeVarint(b)
1808 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08001809 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07001810 }
1811 *p.Int64() = wire.DecodeZigZag(v)
Damien Neilf0831e82020-01-21 14:25:12 -08001812 out.n = n
1813 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07001814}
1815
Damien Neilc37adef2019-04-01 13:49:56 -07001816var coderSint64 = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001817 size: sizeSint64,
1818 marshal: appendSint64,
1819 unmarshal: consumeSint64,
Damien Neilc37adef2019-04-01 13:49:56 -07001820}
1821
Joe Tsaic51e2e02019-07-13 00:44:41 -07001822// sizeSint64NoZero returns the size of wire encoding a int64 pointer as a Sint64.
Damien Neilc37adef2019-04-01 13:49:56 -07001823// The zero value is not encoded.
1824func sizeSint64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
1825 v := *p.Int64()
1826 if v == 0 {
1827 return 0
1828 }
1829 return tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
1830}
1831
Joe Tsaic51e2e02019-07-13 00:44:41 -07001832// appendSint64NoZero wire encodes a int64 pointer as a Sint64.
Damien Neilc37adef2019-04-01 13:49:56 -07001833// The zero value is not encoded.
1834func appendSint64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1835 v := *p.Int64()
1836 if v == 0 {
1837 return b, nil
1838 }
1839 b = wire.AppendVarint(b, wiretag)
1840 b = wire.AppendVarint(b, wire.EncodeZigZag(v))
1841 return b, nil
1842}
1843
1844var coderSint64NoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001845 size: sizeSint64NoZero,
1846 marshal: appendSint64NoZero,
1847 unmarshal: consumeSint64,
Damien Neilc37adef2019-04-01 13:49:56 -07001848}
1849
1850// sizeSint64Ptr returns the size of wire encoding a *int64 pointer as a Sint64.
1851// It panics if the pointer is nil.
1852func sizeSint64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
1853 v := **p.Int64Ptr()
1854 return tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
1855}
1856
Damien Neile91877d2019-06-27 10:54:42 -07001857// appendSint64Ptr wire encodes a *int64 pointer as a Sint64.
Damien Neilc37adef2019-04-01 13:49:56 -07001858// It panics if the pointer is nil.
1859func appendSint64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1860 v := **p.Int64Ptr()
1861 b = wire.AppendVarint(b, wiretag)
1862 b = wire.AppendVarint(b, wire.EncodeZigZag(v))
1863 return b, nil
1864}
1865
Damien Neile91877d2019-06-27 10:54:42 -07001866// consumeSint64Ptr wire decodes a *int64 pointer as a Sint64.
Damien Neilf0831e82020-01-21 14:25:12 -08001867func consumeSint64Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07001868 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -08001869 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07001870 }
1871 v, n := wire.ConsumeVarint(b)
1872 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08001873 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07001874 }
1875 vp := p.Int64Ptr()
1876 if *vp == nil {
1877 *vp = new(int64)
1878 }
1879 **vp = wire.DecodeZigZag(v)
Damien Neilf0831e82020-01-21 14:25:12 -08001880 out.n = n
1881 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07001882}
1883
Damien Neilc37adef2019-04-01 13:49:56 -07001884var coderSint64Ptr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001885 size: sizeSint64Ptr,
1886 marshal: appendSint64Ptr,
1887 unmarshal: consumeSint64Ptr,
Damien Neilc37adef2019-04-01 13:49:56 -07001888}
1889
1890// sizeSint64Slice returns the size of wire encoding a []int64 pointer as a repeated Sint64.
1891func sizeSint64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
1892 s := *p.Int64Slice()
1893 for _, v := range s {
1894 size += tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
1895 }
1896 return size
1897}
1898
1899// appendSint64Slice encodes a []int64 pointer as a repeated Sint64.
1900func appendSint64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1901 s := *p.Int64Slice()
1902 for _, v := range s {
1903 b = wire.AppendVarint(b, wiretag)
1904 b = wire.AppendVarint(b, wire.EncodeZigZag(v))
1905 }
1906 return b, nil
1907}
1908
Damien Neile91877d2019-06-27 10:54:42 -07001909// consumeSint64Slice wire decodes a []int64 pointer as a repeated Sint64.
Damien Neilf0831e82020-01-21 14:25:12 -08001910func consumeSint64Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07001911 sp := p.Int64Slice()
1912 if wtyp == wire.BytesType {
1913 s := *sp
Damien Neilf0831e82020-01-21 14:25:12 -08001914 b, n := wire.ConsumeBytes(b)
Damien Neile91877d2019-06-27 10:54:42 -07001915 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08001916 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07001917 }
1918 for len(b) > 0 {
1919 v, n := wire.ConsumeVarint(b)
1920 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08001921 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07001922 }
1923 s = append(s, wire.DecodeZigZag(v))
1924 b = b[n:]
1925 }
1926 *sp = s
Damien Neilf0831e82020-01-21 14:25:12 -08001927 out.n = n
1928 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07001929 }
1930 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -08001931 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07001932 }
1933 v, n := wire.ConsumeVarint(b)
1934 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08001935 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07001936 }
1937 *sp = append(*sp, wire.DecodeZigZag(v))
Damien Neilf0831e82020-01-21 14:25:12 -08001938 out.n = n
1939 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07001940}
1941
Damien Neilc37adef2019-04-01 13:49:56 -07001942var coderSint64Slice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001943 size: sizeSint64Slice,
1944 marshal: appendSint64Slice,
1945 unmarshal: consumeSint64Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07001946}
1947
1948// sizeSint64PackedSlice returns the size of wire encoding a []int64 pointer as a packed repeated Sint64.
1949func sizeSint64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
1950 s := *p.Int64Slice()
1951 if len(s) == 0 {
1952 return 0
1953 }
1954 n := 0
1955 for _, v := range s {
1956 n += wire.SizeVarint(wire.EncodeZigZag(v))
1957 }
1958 return tagsize + wire.SizeBytes(n)
1959}
1960
1961// appendSint64PackedSlice encodes a []int64 pointer as a packed repeated Sint64.
1962func appendSint64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
1963 s := *p.Int64Slice()
1964 if len(s) == 0 {
1965 return b, nil
1966 }
1967 b = wire.AppendVarint(b, wiretag)
1968 n := 0
1969 for _, v := range s {
1970 n += wire.SizeVarint(wire.EncodeZigZag(v))
1971 }
1972 b = wire.AppendVarint(b, uint64(n))
1973 for _, v := range s {
1974 b = wire.AppendVarint(b, wire.EncodeZigZag(v))
1975 }
1976 return b, nil
1977}
1978
1979var coderSint64PackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07001980 size: sizeSint64PackedSlice,
1981 marshal: appendSint64PackedSlice,
1982 unmarshal: consumeSint64Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07001983}
1984
Damien Neil68b81c32019-08-22 11:41:32 -07001985// sizeSint64Value returns the size of wire encoding a int64 value as a Sint64.
1986func sizeSint64Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
1987 return tagsize + wire.SizeVarint(wire.EncodeZigZag(v.Int()))
Damien Neilc37adef2019-04-01 13:49:56 -07001988}
1989
Damien Neil68b81c32019-08-22 11:41:32 -07001990// appendSint64Value encodes a int64 value as a Sint64.
1991func appendSint64Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
Damien Neilc37adef2019-04-01 13:49:56 -07001992 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07001993 b = wire.AppendVarint(b, wire.EncodeZigZag(v.Int()))
Damien Neilc37adef2019-04-01 13:49:56 -07001994 return b, nil
1995}
1996
Damien Neil68b81c32019-08-22 11:41:32 -07001997// consumeSint64Value decodes a int64 value as a Sint64.
Damien Neilf0831e82020-01-21 14:25:12 -08001998func consumeSint64Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07001999 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -08002000 return protoreflect.Value{}, out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07002001 }
2002 v, n := wire.ConsumeVarint(b)
2003 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08002004 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07002005 }
Damien Neilf0831e82020-01-21 14:25:12 -08002006 out.n = n
2007 return protoreflect.ValueOfInt64(wire.DecodeZigZag(v)), out, nil
Damien Neile91877d2019-06-27 10:54:42 -07002008}
2009
Damien Neil68b81c32019-08-22 11:41:32 -07002010var coderSint64Value = valueCoderFuncs{
2011 size: sizeSint64Value,
2012 marshal: appendSint64Value,
2013 unmarshal: consumeSint64Value,
Damien Neilc37adef2019-04-01 13:49:56 -07002014}
2015
Damien Neil68b81c32019-08-22 11:41:32 -07002016// sizeSint64SliceValue returns the size of wire encoding a []int64 value as a repeated Sint64.
2017func sizeSint64SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
2018 list := listv.List()
2019 for i, llen := 0, list.Len(); i < llen; i++ {
2020 v := list.Get(i)
2021 size += tagsize + wire.SizeVarint(wire.EncodeZigZag(v.Int()))
Damien Neilc37adef2019-04-01 13:49:56 -07002022 }
2023 return size
2024}
2025
Damien Neil68b81c32019-08-22 11:41:32 -07002026// appendSint64SliceValue encodes a []int64 value as a repeated Sint64.
2027func appendSint64SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
2028 list := listv.List()
2029 for i, llen := 0, list.Len(); i < llen; i++ {
2030 v := list.Get(i)
Damien Neilc37adef2019-04-01 13:49:56 -07002031 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07002032 b = wire.AppendVarint(b, wire.EncodeZigZag(v.Int()))
Damien Neilc37adef2019-04-01 13:49:56 -07002033 }
2034 return b, nil
2035}
2036
Damien Neil68b81c32019-08-22 11:41:32 -07002037// consumeSint64SliceValue wire decodes a []int64 value as a repeated Sint64.
Damien Neilf0831e82020-01-21 14:25:12 -08002038func consumeSint64SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neil68b81c32019-08-22 11:41:32 -07002039 list := listv.List()
Damien Neile91877d2019-06-27 10:54:42 -07002040 if wtyp == wire.BytesType {
Damien Neilf0831e82020-01-21 14:25:12 -08002041 b, n := wire.ConsumeBytes(b)
Damien Neile91877d2019-06-27 10:54:42 -07002042 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08002043 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07002044 }
2045 for len(b) > 0 {
2046 v, n := wire.ConsumeVarint(b)
2047 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08002048 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07002049 }
Damien Neil68b81c32019-08-22 11:41:32 -07002050 list.Append(protoreflect.ValueOfInt64(wire.DecodeZigZag(v)))
Damien Neile91877d2019-06-27 10:54:42 -07002051 b = b[n:]
2052 }
Damien Neilf0831e82020-01-21 14:25:12 -08002053 out.n = n
2054 return listv, out, nil
Damien Neile91877d2019-06-27 10:54:42 -07002055 }
2056 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -08002057 return protoreflect.Value{}, out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07002058 }
2059 v, n := wire.ConsumeVarint(b)
2060 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08002061 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07002062 }
Damien Neil68b81c32019-08-22 11:41:32 -07002063 list.Append(protoreflect.ValueOfInt64(wire.DecodeZigZag(v)))
Damien Neilf0831e82020-01-21 14:25:12 -08002064 out.n = n
2065 return listv, out, nil
Damien Neile91877d2019-06-27 10:54:42 -07002066}
2067
Damien Neil68b81c32019-08-22 11:41:32 -07002068var coderSint64SliceValue = valueCoderFuncs{
2069 size: sizeSint64SliceValue,
2070 marshal: appendSint64SliceValue,
2071 unmarshal: consumeSint64SliceValue,
Damien Neilc37adef2019-04-01 13:49:56 -07002072}
2073
Damien Neil68b81c32019-08-22 11:41:32 -07002074// sizeSint64PackedSliceValue returns the size of wire encoding a []int64 value as a packed repeated Sint64.
2075func sizeSint64PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
2076 list := listv.List()
Damien Neil2c0824b2019-12-20 12:21:25 -08002077 llen := list.Len()
2078 if llen == 0 {
2079 return 0
2080 }
Damien Neil7492a092019-07-10 15:23:29 -07002081 n := 0
Damien Neil2c0824b2019-12-20 12:21:25 -08002082 for i, llen := 0, llen; i < llen; i++ {
Damien Neil68b81c32019-08-22 11:41:32 -07002083 v := list.Get(i)
2084 n += wire.SizeVarint(wire.EncodeZigZag(v.Int()))
Damien Neil7492a092019-07-10 15:23:29 -07002085 }
2086 return tagsize + wire.SizeBytes(n)
2087}
2088
Damien Neil68b81c32019-08-22 11:41:32 -07002089// appendSint64PackedSliceValue encodes a []int64 value as a packed repeated Sint64.
2090func appendSint64PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
2091 list := listv.List()
2092 llen := list.Len()
2093 if llen == 0 {
Damien Neil7492a092019-07-10 15:23:29 -07002094 return b, nil
2095 }
2096 b = wire.AppendVarint(b, wiretag)
2097 n := 0
Damien Neil68b81c32019-08-22 11:41:32 -07002098 for i := 0; i < llen; i++ {
2099 v := list.Get(i)
2100 n += wire.SizeVarint(wire.EncodeZigZag(v.Int()))
Damien Neil7492a092019-07-10 15:23:29 -07002101 }
2102 b = wire.AppendVarint(b, uint64(n))
Damien Neil68b81c32019-08-22 11:41:32 -07002103 for i := 0; i < llen; i++ {
2104 v := list.Get(i)
2105 b = wire.AppendVarint(b, wire.EncodeZigZag(v.Int()))
Damien Neil7492a092019-07-10 15:23:29 -07002106 }
2107 return b, nil
2108}
2109
Damien Neil68b81c32019-08-22 11:41:32 -07002110var coderSint64PackedSliceValue = valueCoderFuncs{
2111 size: sizeSint64PackedSliceValue,
2112 marshal: appendSint64PackedSliceValue,
2113 unmarshal: consumeSint64SliceValue,
Damien Neil7492a092019-07-10 15:23:29 -07002114}
2115
Damien Neilc37adef2019-04-01 13:49:56 -07002116// sizeUint64 returns the size of wire encoding a uint64 pointer as a Uint64.
2117func sizeUint64(p pointer, tagsize int, _ marshalOptions) (size int) {
2118 v := *p.Uint64()
2119 return tagsize + wire.SizeVarint(v)
2120}
2121
2122// appendUint64 wire encodes a uint64 pointer as a Uint64.
2123func appendUint64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2124 v := *p.Uint64()
2125 b = wire.AppendVarint(b, wiretag)
2126 b = wire.AppendVarint(b, v)
2127 return b, nil
2128}
2129
Damien Neile91877d2019-06-27 10:54:42 -07002130// consumeUint64 wire decodes a uint64 pointer as a Uint64.
Damien Neilf0831e82020-01-21 14:25:12 -08002131func consumeUint64(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07002132 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -08002133 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07002134 }
2135 v, n := wire.ConsumeVarint(b)
2136 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08002137 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07002138 }
2139 *p.Uint64() = v
Damien Neilf0831e82020-01-21 14:25:12 -08002140 out.n = n
2141 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07002142}
2143
Damien Neilc37adef2019-04-01 13:49:56 -07002144var coderUint64 = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002145 size: sizeUint64,
2146 marshal: appendUint64,
2147 unmarshal: consumeUint64,
Damien Neilc37adef2019-04-01 13:49:56 -07002148}
2149
Joe Tsaic51e2e02019-07-13 00:44:41 -07002150// sizeUint64NoZero returns the size of wire encoding a uint64 pointer as a Uint64.
Damien Neilc37adef2019-04-01 13:49:56 -07002151// The zero value is not encoded.
2152func sizeUint64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
2153 v := *p.Uint64()
2154 if v == 0 {
2155 return 0
2156 }
2157 return tagsize + wire.SizeVarint(v)
2158}
2159
Joe Tsaic51e2e02019-07-13 00:44:41 -07002160// appendUint64NoZero wire encodes a uint64 pointer as a Uint64.
Damien Neilc37adef2019-04-01 13:49:56 -07002161// The zero value is not encoded.
2162func appendUint64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2163 v := *p.Uint64()
2164 if v == 0 {
2165 return b, nil
2166 }
2167 b = wire.AppendVarint(b, wiretag)
2168 b = wire.AppendVarint(b, v)
2169 return b, nil
2170}
2171
2172var coderUint64NoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002173 size: sizeUint64NoZero,
2174 marshal: appendUint64NoZero,
2175 unmarshal: consumeUint64,
Damien Neilc37adef2019-04-01 13:49:56 -07002176}
2177
2178// sizeUint64Ptr returns the size of wire encoding a *uint64 pointer as a Uint64.
2179// It panics if the pointer is nil.
2180func sizeUint64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
2181 v := **p.Uint64Ptr()
2182 return tagsize + wire.SizeVarint(v)
2183}
2184
Damien Neile91877d2019-06-27 10:54:42 -07002185// appendUint64Ptr wire encodes a *uint64 pointer as a Uint64.
Damien Neilc37adef2019-04-01 13:49:56 -07002186// It panics if the pointer is nil.
2187func appendUint64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2188 v := **p.Uint64Ptr()
2189 b = wire.AppendVarint(b, wiretag)
2190 b = wire.AppendVarint(b, v)
2191 return b, nil
2192}
2193
Damien Neile91877d2019-06-27 10:54:42 -07002194// consumeUint64Ptr wire decodes a *uint64 pointer as a Uint64.
Damien Neilf0831e82020-01-21 14:25:12 -08002195func consumeUint64Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07002196 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -08002197 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07002198 }
2199 v, n := wire.ConsumeVarint(b)
2200 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08002201 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07002202 }
2203 vp := p.Uint64Ptr()
2204 if *vp == nil {
2205 *vp = new(uint64)
2206 }
2207 **vp = v
Damien Neilf0831e82020-01-21 14:25:12 -08002208 out.n = n
2209 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07002210}
2211
Damien Neilc37adef2019-04-01 13:49:56 -07002212var coderUint64Ptr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002213 size: sizeUint64Ptr,
2214 marshal: appendUint64Ptr,
2215 unmarshal: consumeUint64Ptr,
Damien Neilc37adef2019-04-01 13:49:56 -07002216}
2217
2218// sizeUint64Slice returns the size of wire encoding a []uint64 pointer as a repeated Uint64.
2219func sizeUint64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
2220 s := *p.Uint64Slice()
2221 for _, v := range s {
2222 size += tagsize + wire.SizeVarint(v)
2223 }
2224 return size
2225}
2226
2227// appendUint64Slice encodes a []uint64 pointer as a repeated Uint64.
2228func appendUint64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2229 s := *p.Uint64Slice()
2230 for _, v := range s {
2231 b = wire.AppendVarint(b, wiretag)
2232 b = wire.AppendVarint(b, v)
2233 }
2234 return b, nil
2235}
2236
Damien Neile91877d2019-06-27 10:54:42 -07002237// consumeUint64Slice wire decodes a []uint64 pointer as a repeated Uint64.
Damien Neilf0831e82020-01-21 14:25:12 -08002238func consumeUint64Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07002239 sp := p.Uint64Slice()
2240 if wtyp == wire.BytesType {
2241 s := *sp
Damien Neilf0831e82020-01-21 14:25:12 -08002242 b, n := wire.ConsumeBytes(b)
Damien Neile91877d2019-06-27 10:54:42 -07002243 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08002244 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07002245 }
2246 for len(b) > 0 {
2247 v, n := wire.ConsumeVarint(b)
2248 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08002249 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07002250 }
2251 s = append(s, v)
2252 b = b[n:]
2253 }
2254 *sp = s
Damien Neilf0831e82020-01-21 14:25:12 -08002255 out.n = n
2256 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07002257 }
2258 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -08002259 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07002260 }
2261 v, n := wire.ConsumeVarint(b)
2262 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08002263 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07002264 }
2265 *sp = append(*sp, v)
Damien Neilf0831e82020-01-21 14:25:12 -08002266 out.n = n
2267 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07002268}
2269
Damien Neilc37adef2019-04-01 13:49:56 -07002270var coderUint64Slice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002271 size: sizeUint64Slice,
2272 marshal: appendUint64Slice,
2273 unmarshal: consumeUint64Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07002274}
2275
2276// sizeUint64PackedSlice returns the size of wire encoding a []uint64 pointer as a packed repeated Uint64.
2277func sizeUint64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
2278 s := *p.Uint64Slice()
2279 if len(s) == 0 {
2280 return 0
2281 }
2282 n := 0
2283 for _, v := range s {
2284 n += wire.SizeVarint(v)
2285 }
2286 return tagsize + wire.SizeBytes(n)
2287}
2288
2289// appendUint64PackedSlice encodes a []uint64 pointer as a packed repeated Uint64.
2290func appendUint64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2291 s := *p.Uint64Slice()
2292 if len(s) == 0 {
2293 return b, nil
2294 }
2295 b = wire.AppendVarint(b, wiretag)
2296 n := 0
2297 for _, v := range s {
2298 n += wire.SizeVarint(v)
2299 }
2300 b = wire.AppendVarint(b, uint64(n))
2301 for _, v := range s {
2302 b = wire.AppendVarint(b, v)
2303 }
2304 return b, nil
2305}
2306
2307var coderUint64PackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002308 size: sizeUint64PackedSlice,
2309 marshal: appendUint64PackedSlice,
2310 unmarshal: consumeUint64Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07002311}
2312
Damien Neil68b81c32019-08-22 11:41:32 -07002313// sizeUint64Value returns the size of wire encoding a uint64 value as a Uint64.
2314func sizeUint64Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
2315 return tagsize + wire.SizeVarint(v.Uint())
Damien Neilc37adef2019-04-01 13:49:56 -07002316}
2317
Damien Neil68b81c32019-08-22 11:41:32 -07002318// appendUint64Value encodes a uint64 value as a Uint64.
2319func appendUint64Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
Damien Neilc37adef2019-04-01 13:49:56 -07002320 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07002321 b = wire.AppendVarint(b, v.Uint())
Damien Neilc37adef2019-04-01 13:49:56 -07002322 return b, nil
2323}
2324
Damien Neil68b81c32019-08-22 11:41:32 -07002325// consumeUint64Value decodes a uint64 value as a Uint64.
Damien Neilf0831e82020-01-21 14:25:12 -08002326func consumeUint64Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07002327 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -08002328 return protoreflect.Value{}, out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07002329 }
2330 v, n := wire.ConsumeVarint(b)
2331 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08002332 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07002333 }
Damien Neilf0831e82020-01-21 14:25:12 -08002334 out.n = n
2335 return protoreflect.ValueOfUint64(v), out, nil
Damien Neile91877d2019-06-27 10:54:42 -07002336}
2337
Damien Neil68b81c32019-08-22 11:41:32 -07002338var coderUint64Value = valueCoderFuncs{
2339 size: sizeUint64Value,
2340 marshal: appendUint64Value,
2341 unmarshal: consumeUint64Value,
Damien Neilc37adef2019-04-01 13:49:56 -07002342}
2343
Damien Neil68b81c32019-08-22 11:41:32 -07002344// sizeUint64SliceValue returns the size of wire encoding a []uint64 value as a repeated Uint64.
2345func sizeUint64SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
2346 list := listv.List()
2347 for i, llen := 0, list.Len(); i < llen; i++ {
2348 v := list.Get(i)
2349 size += tagsize + wire.SizeVarint(v.Uint())
Damien Neilc37adef2019-04-01 13:49:56 -07002350 }
2351 return size
2352}
2353
Damien Neil68b81c32019-08-22 11:41:32 -07002354// appendUint64SliceValue encodes a []uint64 value as a repeated Uint64.
2355func appendUint64SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
2356 list := listv.List()
2357 for i, llen := 0, list.Len(); i < llen; i++ {
2358 v := list.Get(i)
Damien Neilc37adef2019-04-01 13:49:56 -07002359 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07002360 b = wire.AppendVarint(b, v.Uint())
Damien Neilc37adef2019-04-01 13:49:56 -07002361 }
2362 return b, nil
2363}
2364
Damien Neil68b81c32019-08-22 11:41:32 -07002365// consumeUint64SliceValue wire decodes a []uint64 value as a repeated Uint64.
Damien Neilf0831e82020-01-21 14:25:12 -08002366func consumeUint64SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neil68b81c32019-08-22 11:41:32 -07002367 list := listv.List()
Damien Neile91877d2019-06-27 10:54:42 -07002368 if wtyp == wire.BytesType {
Damien Neilf0831e82020-01-21 14:25:12 -08002369 b, n := wire.ConsumeBytes(b)
Damien Neile91877d2019-06-27 10:54:42 -07002370 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08002371 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07002372 }
2373 for len(b) > 0 {
2374 v, n := wire.ConsumeVarint(b)
2375 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08002376 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07002377 }
Damien Neil68b81c32019-08-22 11:41:32 -07002378 list.Append(protoreflect.ValueOfUint64(v))
Damien Neile91877d2019-06-27 10:54:42 -07002379 b = b[n:]
2380 }
Damien Neilf0831e82020-01-21 14:25:12 -08002381 out.n = n
2382 return listv, out, nil
Damien Neile91877d2019-06-27 10:54:42 -07002383 }
2384 if wtyp != wire.VarintType {
Damien Neilf0831e82020-01-21 14:25:12 -08002385 return protoreflect.Value{}, out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07002386 }
2387 v, n := wire.ConsumeVarint(b)
2388 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08002389 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07002390 }
Damien Neil68b81c32019-08-22 11:41:32 -07002391 list.Append(protoreflect.ValueOfUint64(v))
Damien Neilf0831e82020-01-21 14:25:12 -08002392 out.n = n
2393 return listv, out, nil
Damien Neile91877d2019-06-27 10:54:42 -07002394}
2395
Damien Neil68b81c32019-08-22 11:41:32 -07002396var coderUint64SliceValue = valueCoderFuncs{
2397 size: sizeUint64SliceValue,
2398 marshal: appendUint64SliceValue,
2399 unmarshal: consumeUint64SliceValue,
Damien Neilc37adef2019-04-01 13:49:56 -07002400}
2401
Damien Neil68b81c32019-08-22 11:41:32 -07002402// sizeUint64PackedSliceValue returns the size of wire encoding a []uint64 value as a packed repeated Uint64.
2403func sizeUint64PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
2404 list := listv.List()
Damien Neil2c0824b2019-12-20 12:21:25 -08002405 llen := list.Len()
2406 if llen == 0 {
2407 return 0
2408 }
Damien Neil7492a092019-07-10 15:23:29 -07002409 n := 0
Damien Neil2c0824b2019-12-20 12:21:25 -08002410 for i, llen := 0, llen; i < llen; i++ {
Damien Neil68b81c32019-08-22 11:41:32 -07002411 v := list.Get(i)
2412 n += wire.SizeVarint(v.Uint())
Damien Neil7492a092019-07-10 15:23:29 -07002413 }
2414 return tagsize + wire.SizeBytes(n)
2415}
2416
Damien Neil68b81c32019-08-22 11:41:32 -07002417// appendUint64PackedSliceValue encodes a []uint64 value as a packed repeated Uint64.
2418func appendUint64PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
2419 list := listv.List()
2420 llen := list.Len()
2421 if llen == 0 {
Damien Neil7492a092019-07-10 15:23:29 -07002422 return b, nil
2423 }
2424 b = wire.AppendVarint(b, wiretag)
2425 n := 0
Damien Neil68b81c32019-08-22 11:41:32 -07002426 for i := 0; i < llen; i++ {
2427 v := list.Get(i)
2428 n += wire.SizeVarint(v.Uint())
Damien Neil7492a092019-07-10 15:23:29 -07002429 }
2430 b = wire.AppendVarint(b, uint64(n))
Damien Neil68b81c32019-08-22 11:41:32 -07002431 for i := 0; i < llen; i++ {
2432 v := list.Get(i)
2433 b = wire.AppendVarint(b, v.Uint())
Damien Neil7492a092019-07-10 15:23:29 -07002434 }
2435 return b, nil
2436}
2437
Damien Neil68b81c32019-08-22 11:41:32 -07002438var coderUint64PackedSliceValue = valueCoderFuncs{
2439 size: sizeUint64PackedSliceValue,
2440 marshal: appendUint64PackedSliceValue,
2441 unmarshal: consumeUint64SliceValue,
Damien Neil7492a092019-07-10 15:23:29 -07002442}
2443
Damien Neilc37adef2019-04-01 13:49:56 -07002444// sizeSfixed32 returns the size of wire encoding a int32 pointer as a Sfixed32.
2445func sizeSfixed32(p pointer, tagsize int, _ marshalOptions) (size int) {
2446
2447 return tagsize + wire.SizeFixed32()
2448}
2449
2450// appendSfixed32 wire encodes a int32 pointer as a Sfixed32.
2451func appendSfixed32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2452 v := *p.Int32()
2453 b = wire.AppendVarint(b, wiretag)
2454 b = wire.AppendFixed32(b, uint32(v))
2455 return b, nil
2456}
2457
Damien Neile91877d2019-06-27 10:54:42 -07002458// consumeSfixed32 wire decodes a int32 pointer as a Sfixed32.
Damien Neilf0831e82020-01-21 14:25:12 -08002459func consumeSfixed32(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07002460 if wtyp != wire.Fixed32Type {
Damien Neilf0831e82020-01-21 14:25:12 -08002461 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07002462 }
2463 v, n := wire.ConsumeFixed32(b)
2464 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08002465 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07002466 }
2467 *p.Int32() = int32(v)
Damien Neilf0831e82020-01-21 14:25:12 -08002468 out.n = n
2469 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07002470}
2471
Damien Neilc37adef2019-04-01 13:49:56 -07002472var coderSfixed32 = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002473 size: sizeSfixed32,
2474 marshal: appendSfixed32,
2475 unmarshal: consumeSfixed32,
Damien Neilc37adef2019-04-01 13:49:56 -07002476}
2477
Joe Tsaic51e2e02019-07-13 00:44:41 -07002478// sizeSfixed32NoZero returns the size of wire encoding a int32 pointer as a Sfixed32.
Damien Neilc37adef2019-04-01 13:49:56 -07002479// The zero value is not encoded.
2480func sizeSfixed32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
2481 v := *p.Int32()
2482 if v == 0 {
2483 return 0
2484 }
2485 return tagsize + wire.SizeFixed32()
2486}
2487
Joe Tsaic51e2e02019-07-13 00:44:41 -07002488// appendSfixed32NoZero wire encodes a int32 pointer as a Sfixed32.
Damien Neilc37adef2019-04-01 13:49:56 -07002489// The zero value is not encoded.
2490func appendSfixed32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2491 v := *p.Int32()
2492 if v == 0 {
2493 return b, nil
2494 }
2495 b = wire.AppendVarint(b, wiretag)
2496 b = wire.AppendFixed32(b, uint32(v))
2497 return b, nil
2498}
2499
2500var coderSfixed32NoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002501 size: sizeSfixed32NoZero,
2502 marshal: appendSfixed32NoZero,
2503 unmarshal: consumeSfixed32,
Damien Neilc37adef2019-04-01 13:49:56 -07002504}
2505
2506// sizeSfixed32Ptr returns the size of wire encoding a *int32 pointer as a Sfixed32.
2507// It panics if the pointer is nil.
2508func sizeSfixed32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
2509 return tagsize + wire.SizeFixed32()
2510}
2511
Damien Neile91877d2019-06-27 10:54:42 -07002512// appendSfixed32Ptr wire encodes a *int32 pointer as a Sfixed32.
Damien Neilc37adef2019-04-01 13:49:56 -07002513// It panics if the pointer is nil.
2514func appendSfixed32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2515 v := **p.Int32Ptr()
2516 b = wire.AppendVarint(b, wiretag)
2517 b = wire.AppendFixed32(b, uint32(v))
2518 return b, nil
2519}
2520
Damien Neile91877d2019-06-27 10:54:42 -07002521// consumeSfixed32Ptr wire decodes a *int32 pointer as a Sfixed32.
Damien Neilf0831e82020-01-21 14:25:12 -08002522func consumeSfixed32Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07002523 if wtyp != wire.Fixed32Type {
Damien Neilf0831e82020-01-21 14:25:12 -08002524 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07002525 }
2526 v, n := wire.ConsumeFixed32(b)
2527 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08002528 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07002529 }
2530 vp := p.Int32Ptr()
2531 if *vp == nil {
2532 *vp = new(int32)
2533 }
2534 **vp = int32(v)
Damien Neilf0831e82020-01-21 14:25:12 -08002535 out.n = n
2536 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07002537}
2538
Damien Neilc37adef2019-04-01 13:49:56 -07002539var coderSfixed32Ptr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002540 size: sizeSfixed32Ptr,
2541 marshal: appendSfixed32Ptr,
2542 unmarshal: consumeSfixed32Ptr,
Damien Neilc37adef2019-04-01 13:49:56 -07002543}
2544
2545// sizeSfixed32Slice returns the size of wire encoding a []int32 pointer as a repeated Sfixed32.
2546func sizeSfixed32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
2547 s := *p.Int32Slice()
2548 size = len(s) * (tagsize + wire.SizeFixed32())
2549 return size
2550}
2551
2552// appendSfixed32Slice encodes a []int32 pointer as a repeated Sfixed32.
2553func appendSfixed32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2554 s := *p.Int32Slice()
2555 for _, v := range s {
2556 b = wire.AppendVarint(b, wiretag)
2557 b = wire.AppendFixed32(b, uint32(v))
2558 }
2559 return b, nil
2560}
2561
Damien Neile91877d2019-06-27 10:54:42 -07002562// consumeSfixed32Slice wire decodes a []int32 pointer as a repeated Sfixed32.
Damien Neilf0831e82020-01-21 14:25:12 -08002563func consumeSfixed32Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07002564 sp := p.Int32Slice()
2565 if wtyp == wire.BytesType {
2566 s := *sp
Damien Neilf0831e82020-01-21 14:25:12 -08002567 b, n := wire.ConsumeBytes(b)
Damien Neile91877d2019-06-27 10:54:42 -07002568 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08002569 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07002570 }
2571 for len(b) > 0 {
2572 v, n := wire.ConsumeFixed32(b)
2573 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08002574 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07002575 }
2576 s = append(s, int32(v))
2577 b = b[n:]
2578 }
2579 *sp = s
Damien Neilf0831e82020-01-21 14:25:12 -08002580 out.n = n
2581 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07002582 }
2583 if wtyp != wire.Fixed32Type {
Damien Neilf0831e82020-01-21 14:25:12 -08002584 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07002585 }
2586 v, n := wire.ConsumeFixed32(b)
2587 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08002588 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07002589 }
2590 *sp = append(*sp, int32(v))
Damien Neilf0831e82020-01-21 14:25:12 -08002591 out.n = n
2592 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07002593}
2594
Damien Neilc37adef2019-04-01 13:49:56 -07002595var coderSfixed32Slice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002596 size: sizeSfixed32Slice,
2597 marshal: appendSfixed32Slice,
2598 unmarshal: consumeSfixed32Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07002599}
2600
2601// sizeSfixed32PackedSlice returns the size of wire encoding a []int32 pointer as a packed repeated Sfixed32.
2602func sizeSfixed32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
2603 s := *p.Int32Slice()
2604 if len(s) == 0 {
2605 return 0
2606 }
2607 n := len(s) * wire.SizeFixed32()
2608 return tagsize + wire.SizeBytes(n)
2609}
2610
2611// appendSfixed32PackedSlice encodes a []int32 pointer as a packed repeated Sfixed32.
2612func appendSfixed32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2613 s := *p.Int32Slice()
2614 if len(s) == 0 {
2615 return b, nil
2616 }
2617 b = wire.AppendVarint(b, wiretag)
2618 n := len(s) * wire.SizeFixed32()
2619 b = wire.AppendVarint(b, uint64(n))
2620 for _, v := range s {
2621 b = wire.AppendFixed32(b, uint32(v))
2622 }
2623 return b, nil
2624}
2625
2626var coderSfixed32PackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002627 size: sizeSfixed32PackedSlice,
2628 marshal: appendSfixed32PackedSlice,
2629 unmarshal: consumeSfixed32Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07002630}
2631
Damien Neil68b81c32019-08-22 11:41:32 -07002632// sizeSfixed32Value returns the size of wire encoding a int32 value as a Sfixed32.
2633func sizeSfixed32Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
Damien Neilc37adef2019-04-01 13:49:56 -07002634 return tagsize + wire.SizeFixed32()
2635}
2636
Damien Neil68b81c32019-08-22 11:41:32 -07002637// appendSfixed32Value encodes a int32 value as a Sfixed32.
2638func appendSfixed32Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
Damien Neilc37adef2019-04-01 13:49:56 -07002639 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07002640 b = wire.AppendFixed32(b, uint32(v.Int()))
Damien Neilc37adef2019-04-01 13:49:56 -07002641 return b, nil
2642}
2643
Damien Neil68b81c32019-08-22 11:41:32 -07002644// consumeSfixed32Value decodes a int32 value as a Sfixed32.
Damien Neilf0831e82020-01-21 14:25:12 -08002645func consumeSfixed32Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07002646 if wtyp != wire.Fixed32Type {
Damien Neilf0831e82020-01-21 14:25:12 -08002647 return protoreflect.Value{}, out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07002648 }
2649 v, n := wire.ConsumeFixed32(b)
2650 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08002651 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07002652 }
Damien Neilf0831e82020-01-21 14:25:12 -08002653 out.n = n
2654 return protoreflect.ValueOfInt32(int32(v)), out, nil
Damien Neile91877d2019-06-27 10:54:42 -07002655}
2656
Damien Neil68b81c32019-08-22 11:41:32 -07002657var coderSfixed32Value = valueCoderFuncs{
2658 size: sizeSfixed32Value,
2659 marshal: appendSfixed32Value,
2660 unmarshal: consumeSfixed32Value,
Damien Neilc37adef2019-04-01 13:49:56 -07002661}
2662
Damien Neil68b81c32019-08-22 11:41:32 -07002663// sizeSfixed32SliceValue returns the size of wire encoding a []int32 value as a repeated Sfixed32.
2664func sizeSfixed32SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
2665 list := listv.List()
2666 size = list.Len() * (tagsize + wire.SizeFixed32())
Damien Neilc37adef2019-04-01 13:49:56 -07002667 return size
2668}
2669
Damien Neil68b81c32019-08-22 11:41:32 -07002670// appendSfixed32SliceValue encodes a []int32 value as a repeated Sfixed32.
2671func appendSfixed32SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
2672 list := listv.List()
2673 for i, llen := 0, list.Len(); i < llen; i++ {
2674 v := list.Get(i)
Damien Neilc37adef2019-04-01 13:49:56 -07002675 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07002676 b = wire.AppendFixed32(b, uint32(v.Int()))
Damien Neilc37adef2019-04-01 13:49:56 -07002677 }
2678 return b, nil
2679}
2680
Damien Neil68b81c32019-08-22 11:41:32 -07002681// consumeSfixed32SliceValue wire decodes a []int32 value as a repeated Sfixed32.
Damien Neilf0831e82020-01-21 14:25:12 -08002682func consumeSfixed32SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neil68b81c32019-08-22 11:41:32 -07002683 list := listv.List()
Damien Neile91877d2019-06-27 10:54:42 -07002684 if wtyp == wire.BytesType {
Damien Neilf0831e82020-01-21 14:25:12 -08002685 b, n := wire.ConsumeBytes(b)
Damien Neile91877d2019-06-27 10:54:42 -07002686 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08002687 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07002688 }
2689 for len(b) > 0 {
2690 v, n := wire.ConsumeFixed32(b)
2691 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08002692 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07002693 }
Damien Neil68b81c32019-08-22 11:41:32 -07002694 list.Append(protoreflect.ValueOfInt32(int32(v)))
Damien Neile91877d2019-06-27 10:54:42 -07002695 b = b[n:]
2696 }
Damien Neilf0831e82020-01-21 14:25:12 -08002697 out.n = n
2698 return listv, out, nil
Damien Neile91877d2019-06-27 10:54:42 -07002699 }
2700 if wtyp != wire.Fixed32Type {
Damien Neilf0831e82020-01-21 14:25:12 -08002701 return protoreflect.Value{}, out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07002702 }
2703 v, n := wire.ConsumeFixed32(b)
2704 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08002705 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07002706 }
Damien Neil68b81c32019-08-22 11:41:32 -07002707 list.Append(protoreflect.ValueOfInt32(int32(v)))
Damien Neilf0831e82020-01-21 14:25:12 -08002708 out.n = n
2709 return listv, out, nil
Damien Neile91877d2019-06-27 10:54:42 -07002710}
2711
Damien Neil68b81c32019-08-22 11:41:32 -07002712var coderSfixed32SliceValue = valueCoderFuncs{
2713 size: sizeSfixed32SliceValue,
2714 marshal: appendSfixed32SliceValue,
2715 unmarshal: consumeSfixed32SliceValue,
Damien Neilc37adef2019-04-01 13:49:56 -07002716}
2717
Damien Neil68b81c32019-08-22 11:41:32 -07002718// sizeSfixed32PackedSliceValue returns the size of wire encoding a []int32 value as a packed repeated Sfixed32.
2719func sizeSfixed32PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
2720 list := listv.List()
Damien Neil2c0824b2019-12-20 12:21:25 -08002721 llen := list.Len()
2722 if llen == 0 {
2723 return 0
2724 }
2725 n := llen * wire.SizeFixed32()
Damien Neil7492a092019-07-10 15:23:29 -07002726 return tagsize + wire.SizeBytes(n)
2727}
2728
Damien Neil68b81c32019-08-22 11:41:32 -07002729// appendSfixed32PackedSliceValue encodes a []int32 value as a packed repeated Sfixed32.
2730func appendSfixed32PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
2731 list := listv.List()
2732 llen := list.Len()
2733 if llen == 0 {
Damien Neil7492a092019-07-10 15:23:29 -07002734 return b, nil
2735 }
2736 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07002737 n := llen * wire.SizeFixed32()
Damien Neil7492a092019-07-10 15:23:29 -07002738 b = wire.AppendVarint(b, uint64(n))
Damien Neil68b81c32019-08-22 11:41:32 -07002739 for i := 0; i < llen; i++ {
2740 v := list.Get(i)
2741 b = wire.AppendFixed32(b, uint32(v.Int()))
Damien Neil7492a092019-07-10 15:23:29 -07002742 }
2743 return b, nil
2744}
2745
Damien Neil68b81c32019-08-22 11:41:32 -07002746var coderSfixed32PackedSliceValue = valueCoderFuncs{
2747 size: sizeSfixed32PackedSliceValue,
2748 marshal: appendSfixed32PackedSliceValue,
2749 unmarshal: consumeSfixed32SliceValue,
Damien Neil7492a092019-07-10 15:23:29 -07002750}
2751
Damien Neilc37adef2019-04-01 13:49:56 -07002752// sizeFixed32 returns the size of wire encoding a uint32 pointer as a Fixed32.
2753func sizeFixed32(p pointer, tagsize int, _ marshalOptions) (size int) {
2754
2755 return tagsize + wire.SizeFixed32()
2756}
2757
2758// appendFixed32 wire encodes a uint32 pointer as a Fixed32.
2759func appendFixed32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2760 v := *p.Uint32()
2761 b = wire.AppendVarint(b, wiretag)
2762 b = wire.AppendFixed32(b, v)
2763 return b, nil
2764}
2765
Damien Neile91877d2019-06-27 10:54:42 -07002766// consumeFixed32 wire decodes a uint32 pointer as a Fixed32.
Damien Neilf0831e82020-01-21 14:25:12 -08002767func consumeFixed32(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07002768 if wtyp != wire.Fixed32Type {
Damien Neilf0831e82020-01-21 14:25:12 -08002769 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07002770 }
2771 v, n := wire.ConsumeFixed32(b)
2772 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08002773 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07002774 }
2775 *p.Uint32() = v
Damien Neilf0831e82020-01-21 14:25:12 -08002776 out.n = n
2777 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07002778}
2779
Damien Neilc37adef2019-04-01 13:49:56 -07002780var coderFixed32 = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002781 size: sizeFixed32,
2782 marshal: appendFixed32,
2783 unmarshal: consumeFixed32,
Damien Neilc37adef2019-04-01 13:49:56 -07002784}
2785
Joe Tsaic51e2e02019-07-13 00:44:41 -07002786// sizeFixed32NoZero returns the size of wire encoding a uint32 pointer as a Fixed32.
Damien Neilc37adef2019-04-01 13:49:56 -07002787// The zero value is not encoded.
2788func sizeFixed32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
2789 v := *p.Uint32()
2790 if v == 0 {
2791 return 0
2792 }
2793 return tagsize + wire.SizeFixed32()
2794}
2795
Joe Tsaic51e2e02019-07-13 00:44:41 -07002796// appendFixed32NoZero wire encodes a uint32 pointer as a Fixed32.
Damien Neilc37adef2019-04-01 13:49:56 -07002797// The zero value is not encoded.
2798func appendFixed32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2799 v := *p.Uint32()
2800 if v == 0 {
2801 return b, nil
2802 }
2803 b = wire.AppendVarint(b, wiretag)
2804 b = wire.AppendFixed32(b, v)
2805 return b, nil
2806}
2807
2808var coderFixed32NoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002809 size: sizeFixed32NoZero,
2810 marshal: appendFixed32NoZero,
2811 unmarshal: consumeFixed32,
Damien Neilc37adef2019-04-01 13:49:56 -07002812}
2813
2814// sizeFixed32Ptr returns the size of wire encoding a *uint32 pointer as a Fixed32.
2815// It panics if the pointer is nil.
2816func sizeFixed32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
2817 return tagsize + wire.SizeFixed32()
2818}
2819
Damien Neile91877d2019-06-27 10:54:42 -07002820// appendFixed32Ptr wire encodes a *uint32 pointer as a Fixed32.
Damien Neilc37adef2019-04-01 13:49:56 -07002821// It panics if the pointer is nil.
2822func appendFixed32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2823 v := **p.Uint32Ptr()
2824 b = wire.AppendVarint(b, wiretag)
2825 b = wire.AppendFixed32(b, v)
2826 return b, nil
2827}
2828
Damien Neile91877d2019-06-27 10:54:42 -07002829// consumeFixed32Ptr wire decodes a *uint32 pointer as a Fixed32.
Damien Neilf0831e82020-01-21 14:25:12 -08002830func consumeFixed32Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07002831 if wtyp != wire.Fixed32Type {
Damien Neilf0831e82020-01-21 14:25:12 -08002832 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07002833 }
2834 v, n := wire.ConsumeFixed32(b)
2835 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08002836 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07002837 }
2838 vp := p.Uint32Ptr()
2839 if *vp == nil {
2840 *vp = new(uint32)
2841 }
2842 **vp = v
Damien Neilf0831e82020-01-21 14:25:12 -08002843 out.n = n
2844 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07002845}
2846
Damien Neilc37adef2019-04-01 13:49:56 -07002847var coderFixed32Ptr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002848 size: sizeFixed32Ptr,
2849 marshal: appendFixed32Ptr,
2850 unmarshal: consumeFixed32Ptr,
Damien Neilc37adef2019-04-01 13:49:56 -07002851}
2852
2853// sizeFixed32Slice returns the size of wire encoding a []uint32 pointer as a repeated Fixed32.
2854func sizeFixed32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
2855 s := *p.Uint32Slice()
2856 size = len(s) * (tagsize + wire.SizeFixed32())
2857 return size
2858}
2859
2860// appendFixed32Slice encodes a []uint32 pointer as a repeated Fixed32.
2861func appendFixed32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2862 s := *p.Uint32Slice()
2863 for _, v := range s {
2864 b = wire.AppendVarint(b, wiretag)
2865 b = wire.AppendFixed32(b, v)
2866 }
2867 return b, nil
2868}
2869
Damien Neile91877d2019-06-27 10:54:42 -07002870// consumeFixed32Slice wire decodes a []uint32 pointer as a repeated Fixed32.
Damien Neilf0831e82020-01-21 14:25:12 -08002871func consumeFixed32Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07002872 sp := p.Uint32Slice()
2873 if wtyp == wire.BytesType {
2874 s := *sp
Damien Neilf0831e82020-01-21 14:25:12 -08002875 b, n := wire.ConsumeBytes(b)
Damien Neile91877d2019-06-27 10:54:42 -07002876 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08002877 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07002878 }
2879 for len(b) > 0 {
2880 v, n := wire.ConsumeFixed32(b)
2881 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08002882 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07002883 }
2884 s = append(s, v)
2885 b = b[n:]
2886 }
2887 *sp = s
Damien Neilf0831e82020-01-21 14:25:12 -08002888 out.n = n
2889 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07002890 }
2891 if wtyp != wire.Fixed32Type {
Damien Neilf0831e82020-01-21 14:25:12 -08002892 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07002893 }
2894 v, n := wire.ConsumeFixed32(b)
2895 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08002896 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07002897 }
2898 *sp = append(*sp, v)
Damien Neilf0831e82020-01-21 14:25:12 -08002899 out.n = n
2900 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07002901}
2902
Damien Neilc37adef2019-04-01 13:49:56 -07002903var coderFixed32Slice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002904 size: sizeFixed32Slice,
2905 marshal: appendFixed32Slice,
2906 unmarshal: consumeFixed32Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07002907}
2908
2909// sizeFixed32PackedSlice returns the size of wire encoding a []uint32 pointer as a packed repeated Fixed32.
2910func sizeFixed32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
2911 s := *p.Uint32Slice()
2912 if len(s) == 0 {
2913 return 0
2914 }
2915 n := len(s) * wire.SizeFixed32()
2916 return tagsize + wire.SizeBytes(n)
2917}
2918
2919// appendFixed32PackedSlice encodes a []uint32 pointer as a packed repeated Fixed32.
2920func appendFixed32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
2921 s := *p.Uint32Slice()
2922 if len(s) == 0 {
2923 return b, nil
2924 }
2925 b = wire.AppendVarint(b, wiretag)
2926 n := len(s) * wire.SizeFixed32()
2927 b = wire.AppendVarint(b, uint64(n))
2928 for _, v := range s {
2929 b = wire.AppendFixed32(b, v)
2930 }
2931 return b, nil
2932}
2933
2934var coderFixed32PackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07002935 size: sizeFixed32PackedSlice,
2936 marshal: appendFixed32PackedSlice,
2937 unmarshal: consumeFixed32Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07002938}
2939
Damien Neil68b81c32019-08-22 11:41:32 -07002940// sizeFixed32Value returns the size of wire encoding a uint32 value as a Fixed32.
2941func sizeFixed32Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
Damien Neilc37adef2019-04-01 13:49:56 -07002942 return tagsize + wire.SizeFixed32()
2943}
2944
Damien Neil68b81c32019-08-22 11:41:32 -07002945// appendFixed32Value encodes a uint32 value as a Fixed32.
2946func appendFixed32Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
Damien Neilc37adef2019-04-01 13:49:56 -07002947 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07002948 b = wire.AppendFixed32(b, uint32(v.Uint()))
Damien Neilc37adef2019-04-01 13:49:56 -07002949 return b, nil
2950}
2951
Damien Neil68b81c32019-08-22 11:41:32 -07002952// consumeFixed32Value decodes a uint32 value as a Fixed32.
Damien Neilf0831e82020-01-21 14:25:12 -08002953func consumeFixed32Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07002954 if wtyp != wire.Fixed32Type {
Damien Neilf0831e82020-01-21 14:25:12 -08002955 return protoreflect.Value{}, out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07002956 }
2957 v, n := wire.ConsumeFixed32(b)
2958 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08002959 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07002960 }
Damien Neilf0831e82020-01-21 14:25:12 -08002961 out.n = n
2962 return protoreflect.ValueOfUint32(uint32(v)), out, nil
Damien Neile91877d2019-06-27 10:54:42 -07002963}
2964
Damien Neil68b81c32019-08-22 11:41:32 -07002965var coderFixed32Value = valueCoderFuncs{
2966 size: sizeFixed32Value,
2967 marshal: appendFixed32Value,
2968 unmarshal: consumeFixed32Value,
Damien Neilc37adef2019-04-01 13:49:56 -07002969}
2970
Damien Neil68b81c32019-08-22 11:41:32 -07002971// sizeFixed32SliceValue returns the size of wire encoding a []uint32 value as a repeated Fixed32.
2972func sizeFixed32SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
2973 list := listv.List()
2974 size = list.Len() * (tagsize + wire.SizeFixed32())
Damien Neilc37adef2019-04-01 13:49:56 -07002975 return size
2976}
2977
Damien Neil68b81c32019-08-22 11:41:32 -07002978// appendFixed32SliceValue encodes a []uint32 value as a repeated Fixed32.
2979func appendFixed32SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
2980 list := listv.List()
2981 for i, llen := 0, list.Len(); i < llen; i++ {
2982 v := list.Get(i)
Damien Neilc37adef2019-04-01 13:49:56 -07002983 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07002984 b = wire.AppendFixed32(b, uint32(v.Uint()))
Damien Neilc37adef2019-04-01 13:49:56 -07002985 }
2986 return b, nil
2987}
2988
Damien Neil68b81c32019-08-22 11:41:32 -07002989// consumeFixed32SliceValue wire decodes a []uint32 value as a repeated Fixed32.
Damien Neilf0831e82020-01-21 14:25:12 -08002990func consumeFixed32SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neil68b81c32019-08-22 11:41:32 -07002991 list := listv.List()
Damien Neile91877d2019-06-27 10:54:42 -07002992 if wtyp == wire.BytesType {
Damien Neilf0831e82020-01-21 14:25:12 -08002993 b, n := wire.ConsumeBytes(b)
Damien Neile91877d2019-06-27 10:54:42 -07002994 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08002995 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07002996 }
2997 for len(b) > 0 {
2998 v, n := wire.ConsumeFixed32(b)
2999 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08003000 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07003001 }
Damien Neil68b81c32019-08-22 11:41:32 -07003002 list.Append(protoreflect.ValueOfUint32(uint32(v)))
Damien Neile91877d2019-06-27 10:54:42 -07003003 b = b[n:]
3004 }
Damien Neilf0831e82020-01-21 14:25:12 -08003005 out.n = n
3006 return listv, out, nil
Damien Neile91877d2019-06-27 10:54:42 -07003007 }
3008 if wtyp != wire.Fixed32Type {
Damien Neilf0831e82020-01-21 14:25:12 -08003009 return protoreflect.Value{}, out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07003010 }
3011 v, n := wire.ConsumeFixed32(b)
3012 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08003013 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07003014 }
Damien Neil68b81c32019-08-22 11:41:32 -07003015 list.Append(protoreflect.ValueOfUint32(uint32(v)))
Damien Neilf0831e82020-01-21 14:25:12 -08003016 out.n = n
3017 return listv, out, nil
Damien Neile91877d2019-06-27 10:54:42 -07003018}
3019
Damien Neil68b81c32019-08-22 11:41:32 -07003020var coderFixed32SliceValue = valueCoderFuncs{
3021 size: sizeFixed32SliceValue,
3022 marshal: appendFixed32SliceValue,
3023 unmarshal: consumeFixed32SliceValue,
Damien Neilc37adef2019-04-01 13:49:56 -07003024}
3025
Damien Neil68b81c32019-08-22 11:41:32 -07003026// sizeFixed32PackedSliceValue returns the size of wire encoding a []uint32 value as a packed repeated Fixed32.
3027func sizeFixed32PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
3028 list := listv.List()
Damien Neil2c0824b2019-12-20 12:21:25 -08003029 llen := list.Len()
3030 if llen == 0 {
3031 return 0
3032 }
3033 n := llen * wire.SizeFixed32()
Damien Neil7492a092019-07-10 15:23:29 -07003034 return tagsize + wire.SizeBytes(n)
3035}
3036
Damien Neil68b81c32019-08-22 11:41:32 -07003037// appendFixed32PackedSliceValue encodes a []uint32 value as a packed repeated Fixed32.
3038func appendFixed32PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
3039 list := listv.List()
3040 llen := list.Len()
3041 if llen == 0 {
Damien Neil7492a092019-07-10 15:23:29 -07003042 return b, nil
3043 }
3044 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07003045 n := llen * wire.SizeFixed32()
Damien Neil7492a092019-07-10 15:23:29 -07003046 b = wire.AppendVarint(b, uint64(n))
Damien Neil68b81c32019-08-22 11:41:32 -07003047 for i := 0; i < llen; i++ {
3048 v := list.Get(i)
3049 b = wire.AppendFixed32(b, uint32(v.Uint()))
Damien Neil7492a092019-07-10 15:23:29 -07003050 }
3051 return b, nil
3052}
3053
Damien Neil68b81c32019-08-22 11:41:32 -07003054var coderFixed32PackedSliceValue = valueCoderFuncs{
3055 size: sizeFixed32PackedSliceValue,
3056 marshal: appendFixed32PackedSliceValue,
3057 unmarshal: consumeFixed32SliceValue,
Damien Neil7492a092019-07-10 15:23:29 -07003058}
3059
Damien Neilc37adef2019-04-01 13:49:56 -07003060// sizeFloat returns the size of wire encoding a float32 pointer as a Float.
3061func sizeFloat(p pointer, tagsize int, _ marshalOptions) (size int) {
3062
3063 return tagsize + wire.SizeFixed32()
3064}
3065
3066// appendFloat wire encodes a float32 pointer as a Float.
3067func appendFloat(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3068 v := *p.Float32()
3069 b = wire.AppendVarint(b, wiretag)
3070 b = wire.AppendFixed32(b, math.Float32bits(v))
3071 return b, nil
3072}
3073
Damien Neile91877d2019-06-27 10:54:42 -07003074// consumeFloat wire decodes a float32 pointer as a Float.
Damien Neilf0831e82020-01-21 14:25:12 -08003075func consumeFloat(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07003076 if wtyp != wire.Fixed32Type {
Damien Neilf0831e82020-01-21 14:25:12 -08003077 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07003078 }
3079 v, n := wire.ConsumeFixed32(b)
3080 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08003081 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07003082 }
3083 *p.Float32() = math.Float32frombits(v)
Damien Neilf0831e82020-01-21 14:25:12 -08003084 out.n = n
3085 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07003086}
3087
Damien Neilc37adef2019-04-01 13:49:56 -07003088var coderFloat = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003089 size: sizeFloat,
3090 marshal: appendFloat,
3091 unmarshal: consumeFloat,
Damien Neilc37adef2019-04-01 13:49:56 -07003092}
3093
Joe Tsaic51e2e02019-07-13 00:44:41 -07003094// sizeFloatNoZero returns the size of wire encoding a float32 pointer as a Float.
Damien Neilc37adef2019-04-01 13:49:56 -07003095// The zero value is not encoded.
3096func sizeFloatNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
3097 v := *p.Float32()
3098 if v == 0 && !math.Signbit(float64(v)) {
3099 return 0
3100 }
3101 return tagsize + wire.SizeFixed32()
3102}
3103
Joe Tsaic51e2e02019-07-13 00:44:41 -07003104// appendFloatNoZero wire encodes a float32 pointer as a Float.
Damien Neilc37adef2019-04-01 13:49:56 -07003105// The zero value is not encoded.
3106func appendFloatNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3107 v := *p.Float32()
3108 if v == 0 && !math.Signbit(float64(v)) {
3109 return b, nil
3110 }
3111 b = wire.AppendVarint(b, wiretag)
3112 b = wire.AppendFixed32(b, math.Float32bits(v))
3113 return b, nil
3114}
3115
3116var coderFloatNoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003117 size: sizeFloatNoZero,
3118 marshal: appendFloatNoZero,
3119 unmarshal: consumeFloat,
Damien Neilc37adef2019-04-01 13:49:56 -07003120}
3121
3122// sizeFloatPtr returns the size of wire encoding a *float32 pointer as a Float.
3123// It panics if the pointer is nil.
3124func sizeFloatPtr(p pointer, tagsize int, _ marshalOptions) (size int) {
3125 return tagsize + wire.SizeFixed32()
3126}
3127
Damien Neile91877d2019-06-27 10:54:42 -07003128// appendFloatPtr wire encodes a *float32 pointer as a Float.
Damien Neilc37adef2019-04-01 13:49:56 -07003129// It panics if the pointer is nil.
3130func appendFloatPtr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3131 v := **p.Float32Ptr()
3132 b = wire.AppendVarint(b, wiretag)
3133 b = wire.AppendFixed32(b, math.Float32bits(v))
3134 return b, nil
3135}
3136
Damien Neile91877d2019-06-27 10:54:42 -07003137// consumeFloatPtr wire decodes a *float32 pointer as a Float.
Damien Neilf0831e82020-01-21 14:25:12 -08003138func consumeFloatPtr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07003139 if wtyp != wire.Fixed32Type {
Damien Neilf0831e82020-01-21 14:25:12 -08003140 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07003141 }
3142 v, n := wire.ConsumeFixed32(b)
3143 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08003144 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07003145 }
3146 vp := p.Float32Ptr()
3147 if *vp == nil {
3148 *vp = new(float32)
3149 }
3150 **vp = math.Float32frombits(v)
Damien Neilf0831e82020-01-21 14:25:12 -08003151 out.n = n
3152 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07003153}
3154
Damien Neilc37adef2019-04-01 13:49:56 -07003155var coderFloatPtr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003156 size: sizeFloatPtr,
3157 marshal: appendFloatPtr,
3158 unmarshal: consumeFloatPtr,
Damien Neilc37adef2019-04-01 13:49:56 -07003159}
3160
3161// sizeFloatSlice returns the size of wire encoding a []float32 pointer as a repeated Float.
3162func sizeFloatSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
3163 s := *p.Float32Slice()
3164 size = len(s) * (tagsize + wire.SizeFixed32())
3165 return size
3166}
3167
3168// appendFloatSlice encodes a []float32 pointer as a repeated Float.
3169func appendFloatSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3170 s := *p.Float32Slice()
3171 for _, v := range s {
3172 b = wire.AppendVarint(b, wiretag)
3173 b = wire.AppendFixed32(b, math.Float32bits(v))
3174 }
3175 return b, nil
3176}
3177
Damien Neile91877d2019-06-27 10:54:42 -07003178// consumeFloatSlice wire decodes a []float32 pointer as a repeated Float.
Damien Neilf0831e82020-01-21 14:25:12 -08003179func consumeFloatSlice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07003180 sp := p.Float32Slice()
3181 if wtyp == wire.BytesType {
3182 s := *sp
Damien Neilf0831e82020-01-21 14:25:12 -08003183 b, n := wire.ConsumeBytes(b)
Damien Neile91877d2019-06-27 10:54:42 -07003184 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08003185 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07003186 }
3187 for len(b) > 0 {
3188 v, n := wire.ConsumeFixed32(b)
3189 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08003190 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07003191 }
3192 s = append(s, math.Float32frombits(v))
3193 b = b[n:]
3194 }
3195 *sp = s
Damien Neilf0831e82020-01-21 14:25:12 -08003196 out.n = n
3197 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07003198 }
3199 if wtyp != wire.Fixed32Type {
Damien Neilf0831e82020-01-21 14:25:12 -08003200 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07003201 }
3202 v, n := wire.ConsumeFixed32(b)
3203 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08003204 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07003205 }
3206 *sp = append(*sp, math.Float32frombits(v))
Damien Neilf0831e82020-01-21 14:25:12 -08003207 out.n = n
3208 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07003209}
3210
Damien Neilc37adef2019-04-01 13:49:56 -07003211var coderFloatSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003212 size: sizeFloatSlice,
3213 marshal: appendFloatSlice,
3214 unmarshal: consumeFloatSlice,
Damien Neilc37adef2019-04-01 13:49:56 -07003215}
3216
3217// sizeFloatPackedSlice returns the size of wire encoding a []float32 pointer as a packed repeated Float.
3218func sizeFloatPackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
3219 s := *p.Float32Slice()
3220 if len(s) == 0 {
3221 return 0
3222 }
3223 n := len(s) * wire.SizeFixed32()
3224 return tagsize + wire.SizeBytes(n)
3225}
3226
3227// appendFloatPackedSlice encodes a []float32 pointer as a packed repeated Float.
3228func appendFloatPackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3229 s := *p.Float32Slice()
3230 if len(s) == 0 {
3231 return b, nil
3232 }
3233 b = wire.AppendVarint(b, wiretag)
3234 n := len(s) * wire.SizeFixed32()
3235 b = wire.AppendVarint(b, uint64(n))
3236 for _, v := range s {
3237 b = wire.AppendFixed32(b, math.Float32bits(v))
3238 }
3239 return b, nil
3240}
3241
3242var coderFloatPackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003243 size: sizeFloatPackedSlice,
3244 marshal: appendFloatPackedSlice,
3245 unmarshal: consumeFloatSlice,
Damien Neilc37adef2019-04-01 13:49:56 -07003246}
3247
Damien Neil68b81c32019-08-22 11:41:32 -07003248// sizeFloatValue returns the size of wire encoding a float32 value as a Float.
3249func sizeFloatValue(v protoreflect.Value, tagsize int, _ marshalOptions) int {
Damien Neilc37adef2019-04-01 13:49:56 -07003250 return tagsize + wire.SizeFixed32()
3251}
3252
Damien Neil68b81c32019-08-22 11:41:32 -07003253// appendFloatValue encodes a float32 value as a Float.
3254func appendFloatValue(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
Damien Neilc37adef2019-04-01 13:49:56 -07003255 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07003256 b = wire.AppendFixed32(b, math.Float32bits(float32(v.Float())))
Damien Neilc37adef2019-04-01 13:49:56 -07003257 return b, nil
3258}
3259
Damien Neil68b81c32019-08-22 11:41:32 -07003260// consumeFloatValue decodes a float32 value as a Float.
Damien Neilf0831e82020-01-21 14:25:12 -08003261func consumeFloatValue(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07003262 if wtyp != wire.Fixed32Type {
Damien Neilf0831e82020-01-21 14:25:12 -08003263 return protoreflect.Value{}, out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07003264 }
3265 v, n := wire.ConsumeFixed32(b)
3266 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08003267 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07003268 }
Damien Neilf0831e82020-01-21 14:25:12 -08003269 out.n = n
3270 return protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))), out, nil
Damien Neile91877d2019-06-27 10:54:42 -07003271}
3272
Damien Neil68b81c32019-08-22 11:41:32 -07003273var coderFloatValue = valueCoderFuncs{
3274 size: sizeFloatValue,
3275 marshal: appendFloatValue,
3276 unmarshal: consumeFloatValue,
Damien Neilc37adef2019-04-01 13:49:56 -07003277}
3278
Damien Neil68b81c32019-08-22 11:41:32 -07003279// sizeFloatSliceValue returns the size of wire encoding a []float32 value as a repeated Float.
3280func sizeFloatSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
3281 list := listv.List()
3282 size = list.Len() * (tagsize + wire.SizeFixed32())
Damien Neilc37adef2019-04-01 13:49:56 -07003283 return size
3284}
3285
Damien Neil68b81c32019-08-22 11:41:32 -07003286// appendFloatSliceValue encodes a []float32 value as a repeated Float.
3287func appendFloatSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
3288 list := listv.List()
3289 for i, llen := 0, list.Len(); i < llen; i++ {
3290 v := list.Get(i)
Damien Neilc37adef2019-04-01 13:49:56 -07003291 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07003292 b = wire.AppendFixed32(b, math.Float32bits(float32(v.Float())))
Damien Neilc37adef2019-04-01 13:49:56 -07003293 }
3294 return b, nil
3295}
3296
Damien Neil68b81c32019-08-22 11:41:32 -07003297// consumeFloatSliceValue wire decodes a []float32 value as a repeated Float.
Damien Neilf0831e82020-01-21 14:25:12 -08003298func consumeFloatSliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neil68b81c32019-08-22 11:41:32 -07003299 list := listv.List()
Damien Neile91877d2019-06-27 10:54:42 -07003300 if wtyp == wire.BytesType {
Damien Neilf0831e82020-01-21 14:25:12 -08003301 b, n := wire.ConsumeBytes(b)
Damien Neile91877d2019-06-27 10:54:42 -07003302 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08003303 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07003304 }
3305 for len(b) > 0 {
3306 v, n := wire.ConsumeFixed32(b)
3307 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08003308 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07003309 }
Damien Neil68b81c32019-08-22 11:41:32 -07003310 list.Append(protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))))
Damien Neile91877d2019-06-27 10:54:42 -07003311 b = b[n:]
3312 }
Damien Neilf0831e82020-01-21 14:25:12 -08003313 out.n = n
3314 return listv, out, nil
Damien Neile91877d2019-06-27 10:54:42 -07003315 }
3316 if wtyp != wire.Fixed32Type {
Damien Neilf0831e82020-01-21 14:25:12 -08003317 return protoreflect.Value{}, out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07003318 }
3319 v, n := wire.ConsumeFixed32(b)
3320 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08003321 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07003322 }
Damien Neil68b81c32019-08-22 11:41:32 -07003323 list.Append(protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))))
Damien Neilf0831e82020-01-21 14:25:12 -08003324 out.n = n
3325 return listv, out, nil
Damien Neile91877d2019-06-27 10:54:42 -07003326}
3327
Damien Neil68b81c32019-08-22 11:41:32 -07003328var coderFloatSliceValue = valueCoderFuncs{
3329 size: sizeFloatSliceValue,
3330 marshal: appendFloatSliceValue,
3331 unmarshal: consumeFloatSliceValue,
Damien Neilc37adef2019-04-01 13:49:56 -07003332}
3333
Damien Neil68b81c32019-08-22 11:41:32 -07003334// sizeFloatPackedSliceValue returns the size of wire encoding a []float32 value as a packed repeated Float.
3335func sizeFloatPackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
3336 list := listv.List()
Damien Neil2c0824b2019-12-20 12:21:25 -08003337 llen := list.Len()
3338 if llen == 0 {
3339 return 0
3340 }
3341 n := llen * wire.SizeFixed32()
Damien Neil7492a092019-07-10 15:23:29 -07003342 return tagsize + wire.SizeBytes(n)
3343}
3344
Damien Neil68b81c32019-08-22 11:41:32 -07003345// appendFloatPackedSliceValue encodes a []float32 value as a packed repeated Float.
3346func appendFloatPackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
3347 list := listv.List()
3348 llen := list.Len()
3349 if llen == 0 {
Damien Neil7492a092019-07-10 15:23:29 -07003350 return b, nil
3351 }
3352 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07003353 n := llen * wire.SizeFixed32()
Damien Neil7492a092019-07-10 15:23:29 -07003354 b = wire.AppendVarint(b, uint64(n))
Damien Neil68b81c32019-08-22 11:41:32 -07003355 for i := 0; i < llen; i++ {
3356 v := list.Get(i)
3357 b = wire.AppendFixed32(b, math.Float32bits(float32(v.Float())))
Damien Neil7492a092019-07-10 15:23:29 -07003358 }
3359 return b, nil
3360}
3361
Damien Neil68b81c32019-08-22 11:41:32 -07003362var coderFloatPackedSliceValue = valueCoderFuncs{
3363 size: sizeFloatPackedSliceValue,
3364 marshal: appendFloatPackedSliceValue,
3365 unmarshal: consumeFloatSliceValue,
Damien Neil7492a092019-07-10 15:23:29 -07003366}
3367
Damien Neilc37adef2019-04-01 13:49:56 -07003368// sizeSfixed64 returns the size of wire encoding a int64 pointer as a Sfixed64.
3369func sizeSfixed64(p pointer, tagsize int, _ marshalOptions) (size int) {
3370
3371 return tagsize + wire.SizeFixed64()
3372}
3373
3374// appendSfixed64 wire encodes a int64 pointer as a Sfixed64.
3375func appendSfixed64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3376 v := *p.Int64()
3377 b = wire.AppendVarint(b, wiretag)
3378 b = wire.AppendFixed64(b, uint64(v))
3379 return b, nil
3380}
3381
Damien Neile91877d2019-06-27 10:54:42 -07003382// consumeSfixed64 wire decodes a int64 pointer as a Sfixed64.
Damien Neilf0831e82020-01-21 14:25:12 -08003383func consumeSfixed64(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07003384 if wtyp != wire.Fixed64Type {
Damien Neilf0831e82020-01-21 14:25:12 -08003385 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07003386 }
3387 v, n := wire.ConsumeFixed64(b)
3388 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08003389 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07003390 }
3391 *p.Int64() = int64(v)
Damien Neilf0831e82020-01-21 14:25:12 -08003392 out.n = n
3393 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07003394}
3395
Damien Neilc37adef2019-04-01 13:49:56 -07003396var coderSfixed64 = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003397 size: sizeSfixed64,
3398 marshal: appendSfixed64,
3399 unmarshal: consumeSfixed64,
Damien Neilc37adef2019-04-01 13:49:56 -07003400}
3401
Joe Tsaic51e2e02019-07-13 00:44:41 -07003402// sizeSfixed64NoZero returns the size of wire encoding a int64 pointer as a Sfixed64.
Damien Neilc37adef2019-04-01 13:49:56 -07003403// The zero value is not encoded.
3404func sizeSfixed64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
3405 v := *p.Int64()
3406 if v == 0 {
3407 return 0
3408 }
3409 return tagsize + wire.SizeFixed64()
3410}
3411
Joe Tsaic51e2e02019-07-13 00:44:41 -07003412// appendSfixed64NoZero wire encodes a int64 pointer as a Sfixed64.
Damien Neilc37adef2019-04-01 13:49:56 -07003413// The zero value is not encoded.
3414func appendSfixed64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3415 v := *p.Int64()
3416 if v == 0 {
3417 return b, nil
3418 }
3419 b = wire.AppendVarint(b, wiretag)
3420 b = wire.AppendFixed64(b, uint64(v))
3421 return b, nil
3422}
3423
3424var coderSfixed64NoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003425 size: sizeSfixed64NoZero,
3426 marshal: appendSfixed64NoZero,
3427 unmarshal: consumeSfixed64,
Damien Neilc37adef2019-04-01 13:49:56 -07003428}
3429
3430// sizeSfixed64Ptr returns the size of wire encoding a *int64 pointer as a Sfixed64.
3431// It panics if the pointer is nil.
3432func sizeSfixed64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
3433 return tagsize + wire.SizeFixed64()
3434}
3435
Damien Neile91877d2019-06-27 10:54:42 -07003436// appendSfixed64Ptr wire encodes a *int64 pointer as a Sfixed64.
Damien Neilc37adef2019-04-01 13:49:56 -07003437// It panics if the pointer is nil.
3438func appendSfixed64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3439 v := **p.Int64Ptr()
3440 b = wire.AppendVarint(b, wiretag)
3441 b = wire.AppendFixed64(b, uint64(v))
3442 return b, nil
3443}
3444
Damien Neile91877d2019-06-27 10:54:42 -07003445// consumeSfixed64Ptr wire decodes a *int64 pointer as a Sfixed64.
Damien Neilf0831e82020-01-21 14:25:12 -08003446func consumeSfixed64Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07003447 if wtyp != wire.Fixed64Type {
Damien Neilf0831e82020-01-21 14:25:12 -08003448 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07003449 }
3450 v, n := wire.ConsumeFixed64(b)
3451 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08003452 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07003453 }
3454 vp := p.Int64Ptr()
3455 if *vp == nil {
3456 *vp = new(int64)
3457 }
3458 **vp = int64(v)
Damien Neilf0831e82020-01-21 14:25:12 -08003459 out.n = n
3460 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07003461}
3462
Damien Neilc37adef2019-04-01 13:49:56 -07003463var coderSfixed64Ptr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003464 size: sizeSfixed64Ptr,
3465 marshal: appendSfixed64Ptr,
3466 unmarshal: consumeSfixed64Ptr,
Damien Neilc37adef2019-04-01 13:49:56 -07003467}
3468
3469// sizeSfixed64Slice returns the size of wire encoding a []int64 pointer as a repeated Sfixed64.
3470func sizeSfixed64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
3471 s := *p.Int64Slice()
3472 size = len(s) * (tagsize + wire.SizeFixed64())
3473 return size
3474}
3475
3476// appendSfixed64Slice encodes a []int64 pointer as a repeated Sfixed64.
3477func appendSfixed64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3478 s := *p.Int64Slice()
3479 for _, v := range s {
3480 b = wire.AppendVarint(b, wiretag)
3481 b = wire.AppendFixed64(b, uint64(v))
3482 }
3483 return b, nil
3484}
3485
Damien Neile91877d2019-06-27 10:54:42 -07003486// consumeSfixed64Slice wire decodes a []int64 pointer as a repeated Sfixed64.
Damien Neilf0831e82020-01-21 14:25:12 -08003487func consumeSfixed64Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07003488 sp := p.Int64Slice()
3489 if wtyp == wire.BytesType {
3490 s := *sp
Damien Neilf0831e82020-01-21 14:25:12 -08003491 b, n := wire.ConsumeBytes(b)
Damien Neile91877d2019-06-27 10:54:42 -07003492 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08003493 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07003494 }
3495 for len(b) > 0 {
3496 v, n := wire.ConsumeFixed64(b)
3497 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08003498 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07003499 }
3500 s = append(s, int64(v))
3501 b = b[n:]
3502 }
3503 *sp = s
Damien Neilf0831e82020-01-21 14:25:12 -08003504 out.n = n
3505 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07003506 }
3507 if wtyp != wire.Fixed64Type {
Damien Neilf0831e82020-01-21 14:25:12 -08003508 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07003509 }
3510 v, n := wire.ConsumeFixed64(b)
3511 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08003512 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07003513 }
3514 *sp = append(*sp, int64(v))
Damien Neilf0831e82020-01-21 14:25:12 -08003515 out.n = n
3516 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07003517}
3518
Damien Neilc37adef2019-04-01 13:49:56 -07003519var coderSfixed64Slice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003520 size: sizeSfixed64Slice,
3521 marshal: appendSfixed64Slice,
3522 unmarshal: consumeSfixed64Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07003523}
3524
3525// sizeSfixed64PackedSlice returns the size of wire encoding a []int64 pointer as a packed repeated Sfixed64.
3526func sizeSfixed64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
3527 s := *p.Int64Slice()
3528 if len(s) == 0 {
3529 return 0
3530 }
3531 n := len(s) * wire.SizeFixed64()
3532 return tagsize + wire.SizeBytes(n)
3533}
3534
3535// appendSfixed64PackedSlice encodes a []int64 pointer as a packed repeated Sfixed64.
3536func appendSfixed64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3537 s := *p.Int64Slice()
3538 if len(s) == 0 {
3539 return b, nil
3540 }
3541 b = wire.AppendVarint(b, wiretag)
3542 n := len(s) * wire.SizeFixed64()
3543 b = wire.AppendVarint(b, uint64(n))
3544 for _, v := range s {
3545 b = wire.AppendFixed64(b, uint64(v))
3546 }
3547 return b, nil
3548}
3549
3550var coderSfixed64PackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003551 size: sizeSfixed64PackedSlice,
3552 marshal: appendSfixed64PackedSlice,
3553 unmarshal: consumeSfixed64Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07003554}
3555
Damien Neil68b81c32019-08-22 11:41:32 -07003556// sizeSfixed64Value returns the size of wire encoding a int64 value as a Sfixed64.
3557func sizeSfixed64Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
Damien Neilc37adef2019-04-01 13:49:56 -07003558 return tagsize + wire.SizeFixed64()
3559}
3560
Damien Neil68b81c32019-08-22 11:41:32 -07003561// appendSfixed64Value encodes a int64 value as a Sfixed64.
3562func appendSfixed64Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
Damien Neilc37adef2019-04-01 13:49:56 -07003563 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07003564 b = wire.AppendFixed64(b, uint64(v.Int()))
Damien Neilc37adef2019-04-01 13:49:56 -07003565 return b, nil
3566}
3567
Damien Neil68b81c32019-08-22 11:41:32 -07003568// consumeSfixed64Value decodes a int64 value as a Sfixed64.
Damien Neilf0831e82020-01-21 14:25:12 -08003569func consumeSfixed64Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07003570 if wtyp != wire.Fixed64Type {
Damien Neilf0831e82020-01-21 14:25:12 -08003571 return protoreflect.Value{}, out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07003572 }
3573 v, n := wire.ConsumeFixed64(b)
3574 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08003575 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07003576 }
Damien Neilf0831e82020-01-21 14:25:12 -08003577 out.n = n
3578 return protoreflect.ValueOfInt64(int64(v)), out, nil
Damien Neile91877d2019-06-27 10:54:42 -07003579}
3580
Damien Neil68b81c32019-08-22 11:41:32 -07003581var coderSfixed64Value = valueCoderFuncs{
3582 size: sizeSfixed64Value,
3583 marshal: appendSfixed64Value,
3584 unmarshal: consumeSfixed64Value,
Damien Neilc37adef2019-04-01 13:49:56 -07003585}
3586
Damien Neil68b81c32019-08-22 11:41:32 -07003587// sizeSfixed64SliceValue returns the size of wire encoding a []int64 value as a repeated Sfixed64.
3588func sizeSfixed64SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
3589 list := listv.List()
3590 size = list.Len() * (tagsize + wire.SizeFixed64())
Damien Neilc37adef2019-04-01 13:49:56 -07003591 return size
3592}
3593
Damien Neil68b81c32019-08-22 11:41:32 -07003594// appendSfixed64SliceValue encodes a []int64 value as a repeated Sfixed64.
3595func appendSfixed64SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
3596 list := listv.List()
3597 for i, llen := 0, list.Len(); i < llen; i++ {
3598 v := list.Get(i)
Damien Neilc37adef2019-04-01 13:49:56 -07003599 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07003600 b = wire.AppendFixed64(b, uint64(v.Int()))
Damien Neilc37adef2019-04-01 13:49:56 -07003601 }
3602 return b, nil
3603}
3604
Damien Neil68b81c32019-08-22 11:41:32 -07003605// consumeSfixed64SliceValue wire decodes a []int64 value as a repeated Sfixed64.
Damien Neilf0831e82020-01-21 14:25:12 -08003606func consumeSfixed64SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neil68b81c32019-08-22 11:41:32 -07003607 list := listv.List()
Damien Neile91877d2019-06-27 10:54:42 -07003608 if wtyp == wire.BytesType {
Damien Neilf0831e82020-01-21 14:25:12 -08003609 b, n := wire.ConsumeBytes(b)
Damien Neile91877d2019-06-27 10:54:42 -07003610 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08003611 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07003612 }
3613 for len(b) > 0 {
3614 v, n := wire.ConsumeFixed64(b)
3615 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08003616 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07003617 }
Damien Neil68b81c32019-08-22 11:41:32 -07003618 list.Append(protoreflect.ValueOfInt64(int64(v)))
Damien Neile91877d2019-06-27 10:54:42 -07003619 b = b[n:]
3620 }
Damien Neilf0831e82020-01-21 14:25:12 -08003621 out.n = n
3622 return listv, out, nil
Damien Neile91877d2019-06-27 10:54:42 -07003623 }
3624 if wtyp != wire.Fixed64Type {
Damien Neilf0831e82020-01-21 14:25:12 -08003625 return protoreflect.Value{}, out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07003626 }
3627 v, n := wire.ConsumeFixed64(b)
3628 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08003629 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07003630 }
Damien Neil68b81c32019-08-22 11:41:32 -07003631 list.Append(protoreflect.ValueOfInt64(int64(v)))
Damien Neilf0831e82020-01-21 14:25:12 -08003632 out.n = n
3633 return listv, out, nil
Damien Neile91877d2019-06-27 10:54:42 -07003634}
3635
Damien Neil68b81c32019-08-22 11:41:32 -07003636var coderSfixed64SliceValue = valueCoderFuncs{
3637 size: sizeSfixed64SliceValue,
3638 marshal: appendSfixed64SliceValue,
3639 unmarshal: consumeSfixed64SliceValue,
Damien Neilc37adef2019-04-01 13:49:56 -07003640}
3641
Damien Neil68b81c32019-08-22 11:41:32 -07003642// sizeSfixed64PackedSliceValue returns the size of wire encoding a []int64 value as a packed repeated Sfixed64.
3643func sizeSfixed64PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
3644 list := listv.List()
Damien Neil2c0824b2019-12-20 12:21:25 -08003645 llen := list.Len()
3646 if llen == 0 {
3647 return 0
3648 }
3649 n := llen * wire.SizeFixed64()
Damien Neil7492a092019-07-10 15:23:29 -07003650 return tagsize + wire.SizeBytes(n)
3651}
3652
Damien Neil68b81c32019-08-22 11:41:32 -07003653// appendSfixed64PackedSliceValue encodes a []int64 value as a packed repeated Sfixed64.
3654func appendSfixed64PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
3655 list := listv.List()
3656 llen := list.Len()
3657 if llen == 0 {
Damien Neil7492a092019-07-10 15:23:29 -07003658 return b, nil
3659 }
3660 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07003661 n := llen * wire.SizeFixed64()
Damien Neil7492a092019-07-10 15:23:29 -07003662 b = wire.AppendVarint(b, uint64(n))
Damien Neil68b81c32019-08-22 11:41:32 -07003663 for i := 0; i < llen; i++ {
3664 v := list.Get(i)
3665 b = wire.AppendFixed64(b, uint64(v.Int()))
Damien Neil7492a092019-07-10 15:23:29 -07003666 }
3667 return b, nil
3668}
3669
Damien Neil68b81c32019-08-22 11:41:32 -07003670var coderSfixed64PackedSliceValue = valueCoderFuncs{
3671 size: sizeSfixed64PackedSliceValue,
3672 marshal: appendSfixed64PackedSliceValue,
3673 unmarshal: consumeSfixed64SliceValue,
Damien Neil7492a092019-07-10 15:23:29 -07003674}
3675
Damien Neilc37adef2019-04-01 13:49:56 -07003676// sizeFixed64 returns the size of wire encoding a uint64 pointer as a Fixed64.
3677func sizeFixed64(p pointer, tagsize int, _ marshalOptions) (size int) {
3678
3679 return tagsize + wire.SizeFixed64()
3680}
3681
3682// appendFixed64 wire encodes a uint64 pointer as a Fixed64.
3683func appendFixed64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3684 v := *p.Uint64()
3685 b = wire.AppendVarint(b, wiretag)
3686 b = wire.AppendFixed64(b, v)
3687 return b, nil
3688}
3689
Damien Neile91877d2019-06-27 10:54:42 -07003690// consumeFixed64 wire decodes a uint64 pointer as a Fixed64.
Damien Neilf0831e82020-01-21 14:25:12 -08003691func consumeFixed64(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07003692 if wtyp != wire.Fixed64Type {
Damien Neilf0831e82020-01-21 14:25:12 -08003693 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07003694 }
3695 v, n := wire.ConsumeFixed64(b)
3696 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08003697 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07003698 }
3699 *p.Uint64() = v
Damien Neilf0831e82020-01-21 14:25:12 -08003700 out.n = n
3701 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07003702}
3703
Damien Neilc37adef2019-04-01 13:49:56 -07003704var coderFixed64 = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003705 size: sizeFixed64,
3706 marshal: appendFixed64,
3707 unmarshal: consumeFixed64,
Damien Neilc37adef2019-04-01 13:49:56 -07003708}
3709
Joe Tsaic51e2e02019-07-13 00:44:41 -07003710// sizeFixed64NoZero returns the size of wire encoding a uint64 pointer as a Fixed64.
Damien Neilc37adef2019-04-01 13:49:56 -07003711// The zero value is not encoded.
3712func sizeFixed64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
3713 v := *p.Uint64()
3714 if v == 0 {
3715 return 0
3716 }
3717 return tagsize + wire.SizeFixed64()
3718}
3719
Joe Tsaic51e2e02019-07-13 00:44:41 -07003720// appendFixed64NoZero wire encodes a uint64 pointer as a Fixed64.
Damien Neilc37adef2019-04-01 13:49:56 -07003721// The zero value is not encoded.
3722func appendFixed64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3723 v := *p.Uint64()
3724 if v == 0 {
3725 return b, nil
3726 }
3727 b = wire.AppendVarint(b, wiretag)
3728 b = wire.AppendFixed64(b, v)
3729 return b, nil
3730}
3731
3732var coderFixed64NoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003733 size: sizeFixed64NoZero,
3734 marshal: appendFixed64NoZero,
3735 unmarshal: consumeFixed64,
Damien Neilc37adef2019-04-01 13:49:56 -07003736}
3737
3738// sizeFixed64Ptr returns the size of wire encoding a *uint64 pointer as a Fixed64.
3739// It panics if the pointer is nil.
3740func sizeFixed64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
3741 return tagsize + wire.SizeFixed64()
3742}
3743
Damien Neile91877d2019-06-27 10:54:42 -07003744// appendFixed64Ptr wire encodes a *uint64 pointer as a Fixed64.
Damien Neilc37adef2019-04-01 13:49:56 -07003745// It panics if the pointer is nil.
3746func appendFixed64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3747 v := **p.Uint64Ptr()
3748 b = wire.AppendVarint(b, wiretag)
3749 b = wire.AppendFixed64(b, v)
3750 return b, nil
3751}
3752
Damien Neile91877d2019-06-27 10:54:42 -07003753// consumeFixed64Ptr wire decodes a *uint64 pointer as a Fixed64.
Damien Neilf0831e82020-01-21 14:25:12 -08003754func consumeFixed64Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07003755 if wtyp != wire.Fixed64Type {
Damien Neilf0831e82020-01-21 14:25:12 -08003756 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07003757 }
3758 v, n := wire.ConsumeFixed64(b)
3759 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08003760 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07003761 }
3762 vp := p.Uint64Ptr()
3763 if *vp == nil {
3764 *vp = new(uint64)
3765 }
3766 **vp = v
Damien Neilf0831e82020-01-21 14:25:12 -08003767 out.n = n
3768 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07003769}
3770
Damien Neilc37adef2019-04-01 13:49:56 -07003771var coderFixed64Ptr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003772 size: sizeFixed64Ptr,
3773 marshal: appendFixed64Ptr,
3774 unmarshal: consumeFixed64Ptr,
Damien Neilc37adef2019-04-01 13:49:56 -07003775}
3776
3777// sizeFixed64Slice returns the size of wire encoding a []uint64 pointer as a repeated Fixed64.
3778func sizeFixed64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
3779 s := *p.Uint64Slice()
3780 size = len(s) * (tagsize + wire.SizeFixed64())
3781 return size
3782}
3783
3784// appendFixed64Slice encodes a []uint64 pointer as a repeated Fixed64.
3785func appendFixed64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3786 s := *p.Uint64Slice()
3787 for _, v := range s {
3788 b = wire.AppendVarint(b, wiretag)
3789 b = wire.AppendFixed64(b, v)
3790 }
3791 return b, nil
3792}
3793
Damien Neile91877d2019-06-27 10:54:42 -07003794// consumeFixed64Slice wire decodes a []uint64 pointer as a repeated Fixed64.
Damien Neilf0831e82020-01-21 14:25:12 -08003795func consumeFixed64Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07003796 sp := p.Uint64Slice()
3797 if wtyp == wire.BytesType {
3798 s := *sp
Damien Neilf0831e82020-01-21 14:25:12 -08003799 b, n := wire.ConsumeBytes(b)
Damien Neile91877d2019-06-27 10:54:42 -07003800 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08003801 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07003802 }
3803 for len(b) > 0 {
3804 v, n := wire.ConsumeFixed64(b)
3805 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08003806 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07003807 }
3808 s = append(s, v)
3809 b = b[n:]
3810 }
3811 *sp = s
Damien Neilf0831e82020-01-21 14:25:12 -08003812 out.n = n
3813 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07003814 }
3815 if wtyp != wire.Fixed64Type {
Damien Neilf0831e82020-01-21 14:25:12 -08003816 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07003817 }
3818 v, n := wire.ConsumeFixed64(b)
3819 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08003820 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07003821 }
3822 *sp = append(*sp, v)
Damien Neilf0831e82020-01-21 14:25:12 -08003823 out.n = n
3824 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07003825}
3826
Damien Neilc37adef2019-04-01 13:49:56 -07003827var coderFixed64Slice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003828 size: sizeFixed64Slice,
3829 marshal: appendFixed64Slice,
3830 unmarshal: consumeFixed64Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07003831}
3832
3833// sizeFixed64PackedSlice returns the size of wire encoding a []uint64 pointer as a packed repeated Fixed64.
3834func sizeFixed64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
3835 s := *p.Uint64Slice()
3836 if len(s) == 0 {
3837 return 0
3838 }
3839 n := len(s) * wire.SizeFixed64()
3840 return tagsize + wire.SizeBytes(n)
3841}
3842
3843// appendFixed64PackedSlice encodes a []uint64 pointer as a packed repeated Fixed64.
3844func appendFixed64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3845 s := *p.Uint64Slice()
3846 if len(s) == 0 {
3847 return b, nil
3848 }
3849 b = wire.AppendVarint(b, wiretag)
3850 n := len(s) * wire.SizeFixed64()
3851 b = wire.AppendVarint(b, uint64(n))
3852 for _, v := range s {
3853 b = wire.AppendFixed64(b, v)
3854 }
3855 return b, nil
3856}
3857
3858var coderFixed64PackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07003859 size: sizeFixed64PackedSlice,
3860 marshal: appendFixed64PackedSlice,
3861 unmarshal: consumeFixed64Slice,
Damien Neilc37adef2019-04-01 13:49:56 -07003862}
3863
Damien Neil68b81c32019-08-22 11:41:32 -07003864// sizeFixed64Value returns the size of wire encoding a uint64 value as a Fixed64.
3865func sizeFixed64Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
Damien Neilc37adef2019-04-01 13:49:56 -07003866 return tagsize + wire.SizeFixed64()
3867}
3868
Damien Neil68b81c32019-08-22 11:41:32 -07003869// appendFixed64Value encodes a uint64 value as a Fixed64.
3870func appendFixed64Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
Damien Neilc37adef2019-04-01 13:49:56 -07003871 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07003872 b = wire.AppendFixed64(b, v.Uint())
Damien Neilc37adef2019-04-01 13:49:56 -07003873 return b, nil
3874}
3875
Damien Neil68b81c32019-08-22 11:41:32 -07003876// consumeFixed64Value decodes a uint64 value as a Fixed64.
Damien Neilf0831e82020-01-21 14:25:12 -08003877func consumeFixed64Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07003878 if wtyp != wire.Fixed64Type {
Damien Neilf0831e82020-01-21 14:25:12 -08003879 return protoreflect.Value{}, out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07003880 }
3881 v, n := wire.ConsumeFixed64(b)
3882 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08003883 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07003884 }
Damien Neilf0831e82020-01-21 14:25:12 -08003885 out.n = n
3886 return protoreflect.ValueOfUint64(v), out, nil
Damien Neile91877d2019-06-27 10:54:42 -07003887}
3888
Damien Neil68b81c32019-08-22 11:41:32 -07003889var coderFixed64Value = valueCoderFuncs{
3890 size: sizeFixed64Value,
3891 marshal: appendFixed64Value,
3892 unmarshal: consumeFixed64Value,
Damien Neilc37adef2019-04-01 13:49:56 -07003893}
3894
Damien Neil68b81c32019-08-22 11:41:32 -07003895// sizeFixed64SliceValue returns the size of wire encoding a []uint64 value as a repeated Fixed64.
3896func sizeFixed64SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
3897 list := listv.List()
3898 size = list.Len() * (tagsize + wire.SizeFixed64())
Damien Neilc37adef2019-04-01 13:49:56 -07003899 return size
3900}
3901
Damien Neil68b81c32019-08-22 11:41:32 -07003902// appendFixed64SliceValue encodes a []uint64 value as a repeated Fixed64.
3903func appendFixed64SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
3904 list := listv.List()
3905 for i, llen := 0, list.Len(); i < llen; i++ {
3906 v := list.Get(i)
Damien Neilc37adef2019-04-01 13:49:56 -07003907 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07003908 b = wire.AppendFixed64(b, v.Uint())
Damien Neilc37adef2019-04-01 13:49:56 -07003909 }
3910 return b, nil
3911}
3912
Damien Neil68b81c32019-08-22 11:41:32 -07003913// consumeFixed64SliceValue wire decodes a []uint64 value as a repeated Fixed64.
Damien Neilf0831e82020-01-21 14:25:12 -08003914func consumeFixed64SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neil68b81c32019-08-22 11:41:32 -07003915 list := listv.List()
Damien Neile91877d2019-06-27 10:54:42 -07003916 if wtyp == wire.BytesType {
Damien Neilf0831e82020-01-21 14:25:12 -08003917 b, n := wire.ConsumeBytes(b)
Damien Neile91877d2019-06-27 10:54:42 -07003918 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08003919 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07003920 }
3921 for len(b) > 0 {
3922 v, n := wire.ConsumeFixed64(b)
3923 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08003924 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07003925 }
Damien Neil68b81c32019-08-22 11:41:32 -07003926 list.Append(protoreflect.ValueOfUint64(v))
Damien Neile91877d2019-06-27 10:54:42 -07003927 b = b[n:]
3928 }
Damien Neilf0831e82020-01-21 14:25:12 -08003929 out.n = n
3930 return listv, out, nil
Damien Neile91877d2019-06-27 10:54:42 -07003931 }
3932 if wtyp != wire.Fixed64Type {
Damien Neilf0831e82020-01-21 14:25:12 -08003933 return protoreflect.Value{}, out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07003934 }
3935 v, n := wire.ConsumeFixed64(b)
3936 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08003937 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07003938 }
Damien Neil68b81c32019-08-22 11:41:32 -07003939 list.Append(protoreflect.ValueOfUint64(v))
Damien Neilf0831e82020-01-21 14:25:12 -08003940 out.n = n
3941 return listv, out, nil
Damien Neile91877d2019-06-27 10:54:42 -07003942}
3943
Damien Neil68b81c32019-08-22 11:41:32 -07003944var coderFixed64SliceValue = valueCoderFuncs{
3945 size: sizeFixed64SliceValue,
3946 marshal: appendFixed64SliceValue,
3947 unmarshal: consumeFixed64SliceValue,
Damien Neilc37adef2019-04-01 13:49:56 -07003948}
3949
Damien Neil68b81c32019-08-22 11:41:32 -07003950// sizeFixed64PackedSliceValue returns the size of wire encoding a []uint64 value as a packed repeated Fixed64.
3951func sizeFixed64PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
3952 list := listv.List()
Damien Neil2c0824b2019-12-20 12:21:25 -08003953 llen := list.Len()
3954 if llen == 0 {
3955 return 0
3956 }
3957 n := llen * wire.SizeFixed64()
Damien Neil7492a092019-07-10 15:23:29 -07003958 return tagsize + wire.SizeBytes(n)
3959}
3960
Damien Neil68b81c32019-08-22 11:41:32 -07003961// appendFixed64PackedSliceValue encodes a []uint64 value as a packed repeated Fixed64.
3962func appendFixed64PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
3963 list := listv.List()
3964 llen := list.Len()
3965 if llen == 0 {
Damien Neil7492a092019-07-10 15:23:29 -07003966 return b, nil
3967 }
3968 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07003969 n := llen * wire.SizeFixed64()
Damien Neil7492a092019-07-10 15:23:29 -07003970 b = wire.AppendVarint(b, uint64(n))
Damien Neil68b81c32019-08-22 11:41:32 -07003971 for i := 0; i < llen; i++ {
3972 v := list.Get(i)
3973 b = wire.AppendFixed64(b, v.Uint())
Damien Neil7492a092019-07-10 15:23:29 -07003974 }
3975 return b, nil
3976}
3977
Damien Neil68b81c32019-08-22 11:41:32 -07003978var coderFixed64PackedSliceValue = valueCoderFuncs{
3979 size: sizeFixed64PackedSliceValue,
3980 marshal: appendFixed64PackedSliceValue,
3981 unmarshal: consumeFixed64SliceValue,
Damien Neil7492a092019-07-10 15:23:29 -07003982}
3983
Damien Neilc37adef2019-04-01 13:49:56 -07003984// sizeDouble returns the size of wire encoding a float64 pointer as a Double.
3985func sizeDouble(p pointer, tagsize int, _ marshalOptions) (size int) {
3986
3987 return tagsize + wire.SizeFixed64()
3988}
3989
3990// appendDouble wire encodes a float64 pointer as a Double.
3991func appendDouble(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
3992 v := *p.Float64()
3993 b = wire.AppendVarint(b, wiretag)
3994 b = wire.AppendFixed64(b, math.Float64bits(v))
3995 return b, nil
3996}
3997
Damien Neile91877d2019-06-27 10:54:42 -07003998// consumeDouble wire decodes a float64 pointer as a Double.
Damien Neilf0831e82020-01-21 14:25:12 -08003999func consumeDouble(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07004000 if wtyp != wire.Fixed64Type {
Damien Neilf0831e82020-01-21 14:25:12 -08004001 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07004002 }
4003 v, n := wire.ConsumeFixed64(b)
4004 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08004005 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07004006 }
4007 *p.Float64() = math.Float64frombits(v)
Damien Neilf0831e82020-01-21 14:25:12 -08004008 out.n = n
4009 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07004010}
4011
Damien Neilc37adef2019-04-01 13:49:56 -07004012var coderDouble = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07004013 size: sizeDouble,
4014 marshal: appendDouble,
4015 unmarshal: consumeDouble,
Damien Neilc37adef2019-04-01 13:49:56 -07004016}
4017
Joe Tsaic51e2e02019-07-13 00:44:41 -07004018// sizeDoubleNoZero returns the size of wire encoding a float64 pointer as a Double.
Damien Neilc37adef2019-04-01 13:49:56 -07004019// The zero value is not encoded.
4020func sizeDoubleNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
4021 v := *p.Float64()
4022 if v == 0 && !math.Signbit(float64(v)) {
4023 return 0
4024 }
4025 return tagsize + wire.SizeFixed64()
4026}
4027
Joe Tsaic51e2e02019-07-13 00:44:41 -07004028// appendDoubleNoZero wire encodes a float64 pointer as a Double.
Damien Neilc37adef2019-04-01 13:49:56 -07004029// The zero value is not encoded.
4030func appendDoubleNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
4031 v := *p.Float64()
4032 if v == 0 && !math.Signbit(float64(v)) {
4033 return b, nil
4034 }
4035 b = wire.AppendVarint(b, wiretag)
4036 b = wire.AppendFixed64(b, math.Float64bits(v))
4037 return b, nil
4038}
4039
4040var coderDoubleNoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07004041 size: sizeDoubleNoZero,
4042 marshal: appendDoubleNoZero,
4043 unmarshal: consumeDouble,
Damien Neilc37adef2019-04-01 13:49:56 -07004044}
4045
4046// sizeDoublePtr returns the size of wire encoding a *float64 pointer as a Double.
4047// It panics if the pointer is nil.
4048func sizeDoublePtr(p pointer, tagsize int, _ marshalOptions) (size int) {
4049 return tagsize + wire.SizeFixed64()
4050}
4051
Damien Neile91877d2019-06-27 10:54:42 -07004052// appendDoublePtr wire encodes a *float64 pointer as a Double.
Damien Neilc37adef2019-04-01 13:49:56 -07004053// It panics if the pointer is nil.
4054func appendDoublePtr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
4055 v := **p.Float64Ptr()
4056 b = wire.AppendVarint(b, wiretag)
4057 b = wire.AppendFixed64(b, math.Float64bits(v))
4058 return b, nil
4059}
4060
Damien Neile91877d2019-06-27 10:54:42 -07004061// consumeDoublePtr wire decodes a *float64 pointer as a Double.
Damien Neilf0831e82020-01-21 14:25:12 -08004062func consumeDoublePtr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07004063 if wtyp != wire.Fixed64Type {
Damien Neilf0831e82020-01-21 14:25:12 -08004064 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07004065 }
4066 v, n := wire.ConsumeFixed64(b)
4067 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08004068 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07004069 }
4070 vp := p.Float64Ptr()
4071 if *vp == nil {
4072 *vp = new(float64)
4073 }
4074 **vp = math.Float64frombits(v)
Damien Neilf0831e82020-01-21 14:25:12 -08004075 out.n = n
4076 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07004077}
4078
Damien Neilc37adef2019-04-01 13:49:56 -07004079var coderDoublePtr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07004080 size: sizeDoublePtr,
4081 marshal: appendDoublePtr,
4082 unmarshal: consumeDoublePtr,
Damien Neilc37adef2019-04-01 13:49:56 -07004083}
4084
4085// sizeDoubleSlice returns the size of wire encoding a []float64 pointer as a repeated Double.
4086func sizeDoubleSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
4087 s := *p.Float64Slice()
4088 size = len(s) * (tagsize + wire.SizeFixed64())
4089 return size
4090}
4091
4092// appendDoubleSlice encodes a []float64 pointer as a repeated Double.
4093func appendDoubleSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
4094 s := *p.Float64Slice()
4095 for _, v := range s {
4096 b = wire.AppendVarint(b, wiretag)
4097 b = wire.AppendFixed64(b, math.Float64bits(v))
4098 }
4099 return b, nil
4100}
4101
Damien Neile91877d2019-06-27 10:54:42 -07004102// consumeDoubleSlice wire decodes a []float64 pointer as a repeated Double.
Damien Neilf0831e82020-01-21 14:25:12 -08004103func consumeDoubleSlice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07004104 sp := p.Float64Slice()
4105 if wtyp == wire.BytesType {
4106 s := *sp
Damien Neilf0831e82020-01-21 14:25:12 -08004107 b, n := wire.ConsumeBytes(b)
Damien Neile91877d2019-06-27 10:54:42 -07004108 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08004109 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07004110 }
4111 for len(b) > 0 {
4112 v, n := wire.ConsumeFixed64(b)
4113 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08004114 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07004115 }
4116 s = append(s, math.Float64frombits(v))
4117 b = b[n:]
4118 }
4119 *sp = s
Damien Neilf0831e82020-01-21 14:25:12 -08004120 out.n = n
4121 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07004122 }
4123 if wtyp != wire.Fixed64Type {
Damien Neilf0831e82020-01-21 14:25:12 -08004124 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07004125 }
4126 v, n := wire.ConsumeFixed64(b)
4127 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08004128 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07004129 }
4130 *sp = append(*sp, math.Float64frombits(v))
Damien Neilf0831e82020-01-21 14:25:12 -08004131 out.n = n
4132 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07004133}
4134
Damien Neilc37adef2019-04-01 13:49:56 -07004135var coderDoubleSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07004136 size: sizeDoubleSlice,
4137 marshal: appendDoubleSlice,
4138 unmarshal: consumeDoubleSlice,
Damien Neilc37adef2019-04-01 13:49:56 -07004139}
4140
4141// sizeDoublePackedSlice returns the size of wire encoding a []float64 pointer as a packed repeated Double.
4142func sizeDoublePackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
4143 s := *p.Float64Slice()
4144 if len(s) == 0 {
4145 return 0
4146 }
4147 n := len(s) * wire.SizeFixed64()
4148 return tagsize + wire.SizeBytes(n)
4149}
4150
4151// appendDoublePackedSlice encodes a []float64 pointer as a packed repeated Double.
4152func appendDoublePackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
4153 s := *p.Float64Slice()
4154 if len(s) == 0 {
4155 return b, nil
4156 }
4157 b = wire.AppendVarint(b, wiretag)
4158 n := len(s) * wire.SizeFixed64()
4159 b = wire.AppendVarint(b, uint64(n))
4160 for _, v := range s {
4161 b = wire.AppendFixed64(b, math.Float64bits(v))
4162 }
4163 return b, nil
4164}
4165
4166var coderDoublePackedSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07004167 size: sizeDoublePackedSlice,
4168 marshal: appendDoublePackedSlice,
4169 unmarshal: consumeDoubleSlice,
Damien Neilc37adef2019-04-01 13:49:56 -07004170}
4171
Damien Neil68b81c32019-08-22 11:41:32 -07004172// sizeDoubleValue returns the size of wire encoding a float64 value as a Double.
4173func sizeDoubleValue(v protoreflect.Value, tagsize int, _ marshalOptions) int {
Damien Neilc37adef2019-04-01 13:49:56 -07004174 return tagsize + wire.SizeFixed64()
4175}
4176
Damien Neil68b81c32019-08-22 11:41:32 -07004177// appendDoubleValue encodes a float64 value as a Double.
4178func appendDoubleValue(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
Damien Neilc37adef2019-04-01 13:49:56 -07004179 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07004180 b = wire.AppendFixed64(b, math.Float64bits(v.Float()))
Damien Neilc37adef2019-04-01 13:49:56 -07004181 return b, nil
4182}
4183
Damien Neil68b81c32019-08-22 11:41:32 -07004184// consumeDoubleValue decodes a float64 value as a Double.
Damien Neilf0831e82020-01-21 14:25:12 -08004185func consumeDoubleValue(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07004186 if wtyp != wire.Fixed64Type {
Damien Neilf0831e82020-01-21 14:25:12 -08004187 return protoreflect.Value{}, out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07004188 }
4189 v, n := wire.ConsumeFixed64(b)
4190 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08004191 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07004192 }
Damien Neilf0831e82020-01-21 14:25:12 -08004193 out.n = n
4194 return protoreflect.ValueOfFloat64(math.Float64frombits(v)), out, nil
Damien Neile91877d2019-06-27 10:54:42 -07004195}
4196
Damien Neil68b81c32019-08-22 11:41:32 -07004197var coderDoubleValue = valueCoderFuncs{
4198 size: sizeDoubleValue,
4199 marshal: appendDoubleValue,
4200 unmarshal: consumeDoubleValue,
Damien Neilc37adef2019-04-01 13:49:56 -07004201}
4202
Damien Neil68b81c32019-08-22 11:41:32 -07004203// sizeDoubleSliceValue returns the size of wire encoding a []float64 value as a repeated Double.
4204func sizeDoubleSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
4205 list := listv.List()
4206 size = list.Len() * (tagsize + wire.SizeFixed64())
Damien Neilc37adef2019-04-01 13:49:56 -07004207 return size
4208}
4209
Damien Neil68b81c32019-08-22 11:41:32 -07004210// appendDoubleSliceValue encodes a []float64 value as a repeated Double.
4211func appendDoubleSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
4212 list := listv.List()
4213 for i, llen := 0, list.Len(); i < llen; i++ {
4214 v := list.Get(i)
Damien Neilc37adef2019-04-01 13:49:56 -07004215 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07004216 b = wire.AppendFixed64(b, math.Float64bits(v.Float()))
Damien Neilc37adef2019-04-01 13:49:56 -07004217 }
4218 return b, nil
4219}
4220
Damien Neil68b81c32019-08-22 11:41:32 -07004221// consumeDoubleSliceValue wire decodes a []float64 value as a repeated Double.
Damien Neilf0831e82020-01-21 14:25:12 -08004222func consumeDoubleSliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neil68b81c32019-08-22 11:41:32 -07004223 list := listv.List()
Damien Neile91877d2019-06-27 10:54:42 -07004224 if wtyp == wire.BytesType {
Damien Neilf0831e82020-01-21 14:25:12 -08004225 b, n := wire.ConsumeBytes(b)
Damien Neile91877d2019-06-27 10:54:42 -07004226 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08004227 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07004228 }
4229 for len(b) > 0 {
4230 v, n := wire.ConsumeFixed64(b)
4231 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08004232 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07004233 }
Damien Neil68b81c32019-08-22 11:41:32 -07004234 list.Append(protoreflect.ValueOfFloat64(math.Float64frombits(v)))
Damien Neile91877d2019-06-27 10:54:42 -07004235 b = b[n:]
4236 }
Damien Neilf0831e82020-01-21 14:25:12 -08004237 out.n = n
4238 return listv, out, nil
Damien Neile91877d2019-06-27 10:54:42 -07004239 }
4240 if wtyp != wire.Fixed64Type {
Damien Neilf0831e82020-01-21 14:25:12 -08004241 return protoreflect.Value{}, out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07004242 }
4243 v, n := wire.ConsumeFixed64(b)
4244 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08004245 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07004246 }
Damien Neil68b81c32019-08-22 11:41:32 -07004247 list.Append(protoreflect.ValueOfFloat64(math.Float64frombits(v)))
Damien Neilf0831e82020-01-21 14:25:12 -08004248 out.n = n
4249 return listv, out, nil
Damien Neile91877d2019-06-27 10:54:42 -07004250}
4251
Damien Neil68b81c32019-08-22 11:41:32 -07004252var coderDoubleSliceValue = valueCoderFuncs{
4253 size: sizeDoubleSliceValue,
4254 marshal: appendDoubleSliceValue,
4255 unmarshal: consumeDoubleSliceValue,
Damien Neilc37adef2019-04-01 13:49:56 -07004256}
4257
Damien Neil68b81c32019-08-22 11:41:32 -07004258// sizeDoublePackedSliceValue returns the size of wire encoding a []float64 value as a packed repeated Double.
4259func sizeDoublePackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
4260 list := listv.List()
Damien Neil2c0824b2019-12-20 12:21:25 -08004261 llen := list.Len()
4262 if llen == 0 {
4263 return 0
4264 }
4265 n := llen * wire.SizeFixed64()
Damien Neil7492a092019-07-10 15:23:29 -07004266 return tagsize + wire.SizeBytes(n)
4267}
4268
Damien Neil68b81c32019-08-22 11:41:32 -07004269// appendDoublePackedSliceValue encodes a []float64 value as a packed repeated Double.
4270func appendDoublePackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
4271 list := listv.List()
4272 llen := list.Len()
4273 if llen == 0 {
Damien Neil7492a092019-07-10 15:23:29 -07004274 return b, nil
4275 }
4276 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07004277 n := llen * wire.SizeFixed64()
Damien Neil7492a092019-07-10 15:23:29 -07004278 b = wire.AppendVarint(b, uint64(n))
Damien Neil68b81c32019-08-22 11:41:32 -07004279 for i := 0; i < llen; i++ {
4280 v := list.Get(i)
4281 b = wire.AppendFixed64(b, math.Float64bits(v.Float()))
Damien Neil7492a092019-07-10 15:23:29 -07004282 }
4283 return b, nil
4284}
4285
Damien Neil68b81c32019-08-22 11:41:32 -07004286var coderDoublePackedSliceValue = valueCoderFuncs{
4287 size: sizeDoublePackedSliceValue,
4288 marshal: appendDoublePackedSliceValue,
4289 unmarshal: consumeDoubleSliceValue,
Damien Neil7492a092019-07-10 15:23:29 -07004290}
4291
Damien Neilc37adef2019-04-01 13:49:56 -07004292// sizeString returns the size of wire encoding a string pointer as a String.
4293func sizeString(p pointer, tagsize int, _ marshalOptions) (size int) {
4294 v := *p.String()
Damien Neilcedb5952019-06-21 12:04:07 -07004295 return tagsize + wire.SizeBytes(len(v))
Damien Neilc37adef2019-04-01 13:49:56 -07004296}
4297
4298// appendString wire encodes a string pointer as a String.
4299func appendString(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
4300 v := *p.String()
4301 b = wire.AppendVarint(b, wiretag)
Damien Neilcedb5952019-06-21 12:04:07 -07004302 b = wire.AppendString(b, v)
Damien Neilc37adef2019-04-01 13:49:56 -07004303 return b, nil
4304}
4305
Damien Neile91877d2019-06-27 10:54:42 -07004306// consumeString wire decodes a string pointer as a String.
Damien Neilf0831e82020-01-21 14:25:12 -08004307func consumeString(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07004308 if wtyp != wire.BytesType {
Damien Neilf0831e82020-01-21 14:25:12 -08004309 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07004310 }
4311 v, n := wire.ConsumeString(b)
4312 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08004313 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07004314 }
4315 *p.String() = v
Damien Neilf0831e82020-01-21 14:25:12 -08004316 out.n = n
4317 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07004318}
4319
Damien Neilc37adef2019-04-01 13:49:56 -07004320var coderString = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07004321 size: sizeString,
4322 marshal: appendString,
4323 unmarshal: consumeString,
Damien Neilc37adef2019-04-01 13:49:56 -07004324}
4325
Joe Tsaic51e2e02019-07-13 00:44:41 -07004326// appendStringValidateUTF8 wire encodes a string pointer as a String.
4327func appendStringValidateUTF8(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
4328 v := *p.String()
4329 b = wire.AppendVarint(b, wiretag)
4330 b = wire.AppendString(b, v)
4331 if !utf8.ValidString(v) {
4332 return b, errInvalidUTF8{}
4333 }
4334 return b, nil
4335}
4336
4337// consumeStringValidateUTF8 wire decodes a string pointer as a String.
Damien Neilf0831e82020-01-21 14:25:12 -08004338func consumeStringValidateUTF8(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Joe Tsaic51e2e02019-07-13 00:44:41 -07004339 if wtyp != wire.BytesType {
Damien Neilf0831e82020-01-21 14:25:12 -08004340 return out, errUnknown
Joe Tsaic51e2e02019-07-13 00:44:41 -07004341 }
4342 v, n := wire.ConsumeString(b)
4343 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08004344 return out, wire.ParseError(n)
Joe Tsaic51e2e02019-07-13 00:44:41 -07004345 }
4346 if !utf8.ValidString(v) {
Damien Neilf0831e82020-01-21 14:25:12 -08004347 return out, errInvalidUTF8{}
Joe Tsaic51e2e02019-07-13 00:44:41 -07004348 }
4349 *p.String() = v
Damien Neilf0831e82020-01-21 14:25:12 -08004350 out.n = n
4351 return out, nil
Joe Tsaic51e2e02019-07-13 00:44:41 -07004352}
4353
4354var coderStringValidateUTF8 = pointerCoderFuncs{
4355 size: sizeString,
4356 marshal: appendStringValidateUTF8,
4357 unmarshal: consumeStringValidateUTF8,
4358}
4359
4360// sizeStringNoZero returns the size of wire encoding a string pointer as a String.
Damien Neilc37adef2019-04-01 13:49:56 -07004361// The zero value is not encoded.
4362func sizeStringNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
4363 v := *p.String()
4364 if len(v) == 0 {
4365 return 0
4366 }
Damien Neilcedb5952019-06-21 12:04:07 -07004367 return tagsize + wire.SizeBytes(len(v))
Damien Neilc37adef2019-04-01 13:49:56 -07004368}
4369
Joe Tsaic51e2e02019-07-13 00:44:41 -07004370// appendStringNoZero wire encodes a string pointer as a String.
Damien Neilc37adef2019-04-01 13:49:56 -07004371// The zero value is not encoded.
4372func appendStringNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
4373 v := *p.String()
4374 if len(v) == 0 {
4375 return b, nil
4376 }
4377 b = wire.AppendVarint(b, wiretag)
Damien Neilcedb5952019-06-21 12:04:07 -07004378 b = wire.AppendString(b, v)
Damien Neilc37adef2019-04-01 13:49:56 -07004379 return b, nil
4380}
4381
4382var coderStringNoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07004383 size: sizeStringNoZero,
4384 marshal: appendStringNoZero,
4385 unmarshal: consumeString,
Damien Neilc37adef2019-04-01 13:49:56 -07004386}
4387
Joe Tsaic51e2e02019-07-13 00:44:41 -07004388// appendStringNoZeroValidateUTF8 wire encodes a string pointer as a String.
4389// The zero value is not encoded.
4390func appendStringNoZeroValidateUTF8(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
4391 v := *p.String()
4392 if len(v) == 0 {
4393 return b, nil
4394 }
4395 b = wire.AppendVarint(b, wiretag)
4396 b = wire.AppendString(b, v)
4397 if !utf8.ValidString(v) {
4398 return b, errInvalidUTF8{}
4399 }
4400 return b, nil
4401}
4402
4403var coderStringNoZeroValidateUTF8 = pointerCoderFuncs{
4404 size: sizeStringNoZero,
4405 marshal: appendStringNoZeroValidateUTF8,
4406 unmarshal: consumeStringValidateUTF8,
4407}
4408
Damien Neilc37adef2019-04-01 13:49:56 -07004409// sizeStringPtr returns the size of wire encoding a *string pointer as a String.
4410// It panics if the pointer is nil.
4411func sizeStringPtr(p pointer, tagsize int, _ marshalOptions) (size int) {
4412 v := **p.StringPtr()
Damien Neilcedb5952019-06-21 12:04:07 -07004413 return tagsize + wire.SizeBytes(len(v))
Damien Neilc37adef2019-04-01 13:49:56 -07004414}
4415
Damien Neile91877d2019-06-27 10:54:42 -07004416// appendStringPtr wire encodes a *string pointer as a String.
Damien Neilc37adef2019-04-01 13:49:56 -07004417// It panics if the pointer is nil.
4418func appendStringPtr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
4419 v := **p.StringPtr()
4420 b = wire.AppendVarint(b, wiretag)
Damien Neilcedb5952019-06-21 12:04:07 -07004421 b = wire.AppendString(b, v)
Damien Neilc37adef2019-04-01 13:49:56 -07004422 return b, nil
4423}
4424
Damien Neile91877d2019-06-27 10:54:42 -07004425// consumeStringPtr wire decodes a *string pointer as a String.
Damien Neilf0831e82020-01-21 14:25:12 -08004426func consumeStringPtr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07004427 if wtyp != wire.BytesType {
Damien Neilf0831e82020-01-21 14:25:12 -08004428 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07004429 }
4430 v, n := wire.ConsumeString(b)
4431 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08004432 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07004433 }
4434 vp := p.StringPtr()
4435 if *vp == nil {
4436 *vp = new(string)
4437 }
4438 **vp = v
Damien Neilf0831e82020-01-21 14:25:12 -08004439 out.n = n
4440 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07004441}
4442
Damien Neilc37adef2019-04-01 13:49:56 -07004443var coderStringPtr = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07004444 size: sizeStringPtr,
4445 marshal: appendStringPtr,
4446 unmarshal: consumeStringPtr,
Damien Neilc37adef2019-04-01 13:49:56 -07004447}
4448
4449// sizeStringSlice returns the size of wire encoding a []string pointer as a repeated String.
4450func sizeStringSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
4451 s := *p.StringSlice()
4452 for _, v := range s {
Damien Neilcedb5952019-06-21 12:04:07 -07004453 size += tagsize + wire.SizeBytes(len(v))
Damien Neilc37adef2019-04-01 13:49:56 -07004454 }
4455 return size
4456}
4457
4458// appendStringSlice encodes a []string pointer as a repeated String.
4459func appendStringSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
4460 s := *p.StringSlice()
4461 for _, v := range s {
4462 b = wire.AppendVarint(b, wiretag)
Damien Neilcedb5952019-06-21 12:04:07 -07004463 b = wire.AppendString(b, v)
Damien Neilc37adef2019-04-01 13:49:56 -07004464 }
4465 return b, nil
4466}
4467
Damien Neile91877d2019-06-27 10:54:42 -07004468// consumeStringSlice wire decodes a []string pointer as a repeated String.
Damien Neilf0831e82020-01-21 14:25:12 -08004469func consumeStringSlice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07004470 sp := p.StringSlice()
4471 if wtyp != wire.BytesType {
Damien Neilf0831e82020-01-21 14:25:12 -08004472 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07004473 }
4474 v, n := wire.ConsumeString(b)
4475 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08004476 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07004477 }
4478 *sp = append(*sp, v)
Damien Neilf0831e82020-01-21 14:25:12 -08004479 out.n = n
4480 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07004481}
4482
Damien Neilc37adef2019-04-01 13:49:56 -07004483var coderStringSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07004484 size: sizeStringSlice,
4485 marshal: appendStringSlice,
4486 unmarshal: consumeStringSlice,
Damien Neilc37adef2019-04-01 13:49:56 -07004487}
4488
Joe Tsaic51e2e02019-07-13 00:44:41 -07004489// appendStringSliceValidateUTF8 encodes a []string pointer as a repeated String.
4490func appendStringSliceValidateUTF8(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
4491 s := *p.StringSlice()
4492 for _, v := range s {
4493 b = wire.AppendVarint(b, wiretag)
4494 b = wire.AppendString(b, v)
4495 if !utf8.ValidString(v) {
4496 return b, errInvalidUTF8{}
4497 }
4498 }
4499 return b, nil
4500}
4501
4502// consumeStringSliceValidateUTF8 wire decodes a []string pointer as a repeated String.
Damien Neilf0831e82020-01-21 14:25:12 -08004503func consumeStringSliceValidateUTF8(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Joe Tsaic51e2e02019-07-13 00:44:41 -07004504 sp := p.StringSlice()
4505 if wtyp != wire.BytesType {
Damien Neilf0831e82020-01-21 14:25:12 -08004506 return out, errUnknown
Joe Tsaic51e2e02019-07-13 00:44:41 -07004507 }
4508 v, n := wire.ConsumeString(b)
4509 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08004510 return out, wire.ParseError(n)
Joe Tsaic51e2e02019-07-13 00:44:41 -07004511 }
4512 if !utf8.ValidString(v) {
Damien Neilf0831e82020-01-21 14:25:12 -08004513 return out, errInvalidUTF8{}
Joe Tsaic51e2e02019-07-13 00:44:41 -07004514 }
4515 *sp = append(*sp, v)
Damien Neilf0831e82020-01-21 14:25:12 -08004516 out.n = n
4517 return out, nil
Joe Tsaic51e2e02019-07-13 00:44:41 -07004518}
4519
4520var coderStringSliceValidateUTF8 = pointerCoderFuncs{
4521 size: sizeStringSlice,
4522 marshal: appendStringSliceValidateUTF8,
4523 unmarshal: consumeStringSliceValidateUTF8,
4524}
4525
Damien Neil68b81c32019-08-22 11:41:32 -07004526// sizeStringValue returns the size of wire encoding a string value as a String.
4527func sizeStringValue(v protoreflect.Value, tagsize int, _ marshalOptions) int {
4528 return tagsize + wire.SizeBytes(len(v.String()))
Damien Neilc37adef2019-04-01 13:49:56 -07004529}
4530
Damien Neil68b81c32019-08-22 11:41:32 -07004531// appendStringValue encodes a string value as a String.
4532func appendStringValue(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
Damien Neilc37adef2019-04-01 13:49:56 -07004533 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07004534 b = wire.AppendString(b, v.String())
Damien Neilc37adef2019-04-01 13:49:56 -07004535 return b, nil
4536}
4537
Damien Neil68b81c32019-08-22 11:41:32 -07004538// consumeStringValue decodes a string value as a String.
Damien Neilf0831e82020-01-21 14:25:12 -08004539func consumeStringValue(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07004540 if wtyp != wire.BytesType {
Damien Neilf0831e82020-01-21 14:25:12 -08004541 return protoreflect.Value{}, out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07004542 }
4543 v, n := wire.ConsumeString(b)
4544 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08004545 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07004546 }
Damien Neilf0831e82020-01-21 14:25:12 -08004547 out.n = n
4548 return protoreflect.ValueOfString(string(v)), out, nil
Damien Neile91877d2019-06-27 10:54:42 -07004549}
4550
Damien Neil68b81c32019-08-22 11:41:32 -07004551var coderStringValue = valueCoderFuncs{
4552 size: sizeStringValue,
4553 marshal: appendStringValue,
4554 unmarshal: consumeStringValue,
Damien Neilc37adef2019-04-01 13:49:56 -07004555}
4556
Damien Neil68b81c32019-08-22 11:41:32 -07004557// appendStringValueValidateUTF8 encodes a string value as a String.
4558func appendStringValueValidateUTF8(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
Joe Tsaic51e2e02019-07-13 00:44:41 -07004559 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07004560 b = wire.AppendString(b, v.String())
4561 if !utf8.ValidString(v.String()) {
Joe Tsaic51e2e02019-07-13 00:44:41 -07004562 return b, errInvalidUTF8{}
4563 }
4564 return b, nil
4565}
4566
Damien Neil68b81c32019-08-22 11:41:32 -07004567// consumeStringValueValidateUTF8 decodes a string value as a String.
Damien Neilf0831e82020-01-21 14:25:12 -08004568func consumeStringValueValidateUTF8(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Joe Tsaic51e2e02019-07-13 00:44:41 -07004569 if wtyp != wire.BytesType {
Damien Neilf0831e82020-01-21 14:25:12 -08004570 return protoreflect.Value{}, out, errUnknown
Joe Tsaic51e2e02019-07-13 00:44:41 -07004571 }
4572 v, n := wire.ConsumeString(b)
4573 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08004574 return protoreflect.Value{}, out, wire.ParseError(n)
Joe Tsaic51e2e02019-07-13 00:44:41 -07004575 }
4576 if !utf8.ValidString(v) {
Damien Neilf0831e82020-01-21 14:25:12 -08004577 return protoreflect.Value{}, out, errInvalidUTF8{}
Joe Tsaic51e2e02019-07-13 00:44:41 -07004578 }
Damien Neilf0831e82020-01-21 14:25:12 -08004579 out.n = n
4580 return protoreflect.ValueOfString(string(v)), out, nil
Joe Tsaic51e2e02019-07-13 00:44:41 -07004581}
4582
Damien Neil68b81c32019-08-22 11:41:32 -07004583var coderStringValueValidateUTF8 = valueCoderFuncs{
4584 size: sizeStringValue,
4585 marshal: appendStringValueValidateUTF8,
4586 unmarshal: consumeStringValueValidateUTF8,
Joe Tsaic51e2e02019-07-13 00:44:41 -07004587}
4588
Damien Neil68b81c32019-08-22 11:41:32 -07004589// sizeStringSliceValue returns the size of wire encoding a []string value as a repeated String.
4590func sizeStringSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
4591 list := listv.List()
4592 for i, llen := 0, list.Len(); i < llen; i++ {
4593 v := list.Get(i)
4594 size += tagsize + wire.SizeBytes(len(v.String()))
Damien Neilc37adef2019-04-01 13:49:56 -07004595 }
4596 return size
4597}
4598
Damien Neil68b81c32019-08-22 11:41:32 -07004599// appendStringSliceValue encodes a []string value as a repeated String.
4600func appendStringSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
4601 list := listv.List()
4602 for i, llen := 0, list.Len(); i < llen; i++ {
4603 v := list.Get(i)
Damien Neilc37adef2019-04-01 13:49:56 -07004604 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07004605 b = wire.AppendString(b, v.String())
Damien Neilc37adef2019-04-01 13:49:56 -07004606 }
4607 return b, nil
4608}
4609
Damien Neil68b81c32019-08-22 11:41:32 -07004610// consumeStringSliceValue wire decodes a []string value as a repeated String.
Damien Neilf0831e82020-01-21 14:25:12 -08004611func consumeStringSliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neil68b81c32019-08-22 11:41:32 -07004612 list := listv.List()
Damien Neile91877d2019-06-27 10:54:42 -07004613 if wtyp != wire.BytesType {
Damien Neilf0831e82020-01-21 14:25:12 -08004614 return protoreflect.Value{}, out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07004615 }
4616 v, n := wire.ConsumeString(b)
4617 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08004618 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07004619 }
Damien Neil68b81c32019-08-22 11:41:32 -07004620 list.Append(protoreflect.ValueOfString(string(v)))
Damien Neilf0831e82020-01-21 14:25:12 -08004621 out.n = n
4622 return listv, out, nil
Damien Neile91877d2019-06-27 10:54:42 -07004623}
4624
Damien Neil68b81c32019-08-22 11:41:32 -07004625var coderStringSliceValue = valueCoderFuncs{
4626 size: sizeStringSliceValue,
4627 marshal: appendStringSliceValue,
4628 unmarshal: consumeStringSliceValue,
Damien Neilc37adef2019-04-01 13:49:56 -07004629}
4630
4631// sizeBytes returns the size of wire encoding a []byte pointer as a Bytes.
4632func sizeBytes(p pointer, tagsize int, _ marshalOptions) (size int) {
4633 v := *p.Bytes()
4634 return tagsize + wire.SizeBytes(len(v))
4635}
4636
4637// appendBytes wire encodes a []byte pointer as a Bytes.
4638func appendBytes(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
4639 v := *p.Bytes()
4640 b = wire.AppendVarint(b, wiretag)
4641 b = wire.AppendBytes(b, v)
4642 return b, nil
4643}
4644
Damien Neile91877d2019-06-27 10:54:42 -07004645// consumeBytes wire decodes a []byte pointer as a Bytes.
Damien Neilf0831e82020-01-21 14:25:12 -08004646func consumeBytes(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07004647 if wtyp != wire.BytesType {
Damien Neilf0831e82020-01-21 14:25:12 -08004648 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07004649 }
4650 v, n := wire.ConsumeBytes(b)
4651 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08004652 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07004653 }
Damien Neil8003f082019-08-02 15:13:00 -07004654 *p.Bytes() = append(emptyBuf[:], v...)
Damien Neilf0831e82020-01-21 14:25:12 -08004655 out.n = n
4656 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07004657}
4658
Damien Neilc37adef2019-04-01 13:49:56 -07004659var coderBytes = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07004660 size: sizeBytes,
4661 marshal: appendBytes,
4662 unmarshal: consumeBytes,
Damien Neilc37adef2019-04-01 13:49:56 -07004663}
4664
Joe Tsaic51e2e02019-07-13 00:44:41 -07004665// appendBytesValidateUTF8 wire encodes a []byte pointer as a Bytes.
4666func appendBytesValidateUTF8(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
4667 v := *p.Bytes()
4668 b = wire.AppendVarint(b, wiretag)
4669 b = wire.AppendBytes(b, v)
4670 if !utf8.Valid(v) {
4671 return b, errInvalidUTF8{}
4672 }
4673 return b, nil
4674}
4675
4676// consumeBytesValidateUTF8 wire decodes a []byte pointer as a Bytes.
Damien Neilf0831e82020-01-21 14:25:12 -08004677func consumeBytesValidateUTF8(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Joe Tsaic51e2e02019-07-13 00:44:41 -07004678 if wtyp != wire.BytesType {
Damien Neilf0831e82020-01-21 14:25:12 -08004679 return out, errUnknown
Joe Tsaic51e2e02019-07-13 00:44:41 -07004680 }
4681 v, n := wire.ConsumeBytes(b)
4682 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08004683 return out, wire.ParseError(n)
Joe Tsaic51e2e02019-07-13 00:44:41 -07004684 }
4685 if !utf8.Valid(v) {
Damien Neilf0831e82020-01-21 14:25:12 -08004686 return out, errInvalidUTF8{}
Joe Tsaic51e2e02019-07-13 00:44:41 -07004687 }
Damien Neil8003f082019-08-02 15:13:00 -07004688 *p.Bytes() = append(emptyBuf[:], v...)
Damien Neilf0831e82020-01-21 14:25:12 -08004689 out.n = n
4690 return out, nil
Joe Tsaic51e2e02019-07-13 00:44:41 -07004691}
4692
4693var coderBytesValidateUTF8 = pointerCoderFuncs{
4694 size: sizeBytes,
4695 marshal: appendBytesValidateUTF8,
4696 unmarshal: consumeBytesValidateUTF8,
4697}
4698
4699// sizeBytesNoZero returns the size of wire encoding a []byte pointer as a Bytes.
Damien Neilc37adef2019-04-01 13:49:56 -07004700// The zero value is not encoded.
4701func sizeBytesNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
4702 v := *p.Bytes()
4703 if len(v) == 0 {
4704 return 0
4705 }
4706 return tagsize + wire.SizeBytes(len(v))
4707}
4708
Joe Tsaic51e2e02019-07-13 00:44:41 -07004709// appendBytesNoZero wire encodes a []byte pointer as a Bytes.
Damien Neilc37adef2019-04-01 13:49:56 -07004710// The zero value is not encoded.
4711func appendBytesNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
4712 v := *p.Bytes()
4713 if len(v) == 0 {
4714 return b, nil
4715 }
4716 b = wire.AppendVarint(b, wiretag)
4717 b = wire.AppendBytes(b, v)
4718 return b, nil
4719}
4720
Damien Neil8003f082019-08-02 15:13:00 -07004721// consumeBytesNoZero wire decodes a []byte pointer as a Bytes.
4722// The zero value is not decoded.
Damien Neilf0831e82020-01-21 14:25:12 -08004723func consumeBytesNoZero(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neil8003f082019-08-02 15:13:00 -07004724 if wtyp != wire.BytesType {
Damien Neilf0831e82020-01-21 14:25:12 -08004725 return out, errUnknown
Damien Neil8003f082019-08-02 15:13:00 -07004726 }
4727 v, n := wire.ConsumeBytes(b)
4728 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08004729 return out, wire.ParseError(n)
Damien Neil8003f082019-08-02 15:13:00 -07004730 }
4731 *p.Bytes() = append(([]byte)(nil), v...)
Damien Neilf0831e82020-01-21 14:25:12 -08004732 out.n = n
4733 return out, nil
Damien Neil8003f082019-08-02 15:13:00 -07004734}
4735
Damien Neilc37adef2019-04-01 13:49:56 -07004736var coderBytesNoZero = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07004737 size: sizeBytesNoZero,
4738 marshal: appendBytesNoZero,
Damien Neil8003f082019-08-02 15:13:00 -07004739 unmarshal: consumeBytesNoZero,
Damien Neilc37adef2019-04-01 13:49:56 -07004740}
4741
Joe Tsaic51e2e02019-07-13 00:44:41 -07004742// appendBytesNoZeroValidateUTF8 wire encodes a []byte pointer as a Bytes.
4743// The zero value is not encoded.
4744func appendBytesNoZeroValidateUTF8(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
4745 v := *p.Bytes()
4746 if len(v) == 0 {
4747 return b, nil
4748 }
4749 b = wire.AppendVarint(b, wiretag)
4750 b = wire.AppendBytes(b, v)
4751 if !utf8.Valid(v) {
4752 return b, errInvalidUTF8{}
4753 }
4754 return b, nil
4755}
4756
Damien Neil8003f082019-08-02 15:13:00 -07004757// consumeBytesNoZeroValidateUTF8 wire decodes a []byte pointer as a Bytes.
Damien Neilf0831e82020-01-21 14:25:12 -08004758func consumeBytesNoZeroValidateUTF8(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neil8003f082019-08-02 15:13:00 -07004759 if wtyp != wire.BytesType {
Damien Neilf0831e82020-01-21 14:25:12 -08004760 return out, errUnknown
Damien Neil8003f082019-08-02 15:13:00 -07004761 }
4762 v, n := wire.ConsumeBytes(b)
4763 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08004764 return out, wire.ParseError(n)
Damien Neil8003f082019-08-02 15:13:00 -07004765 }
4766 if !utf8.Valid(v) {
Damien Neilf0831e82020-01-21 14:25:12 -08004767 return out, errInvalidUTF8{}
Damien Neil8003f082019-08-02 15:13:00 -07004768 }
4769 *p.Bytes() = append(([]byte)(nil), v...)
Damien Neilf0831e82020-01-21 14:25:12 -08004770 out.n = n
4771 return out, nil
Damien Neil8003f082019-08-02 15:13:00 -07004772}
4773
Joe Tsaic51e2e02019-07-13 00:44:41 -07004774var coderBytesNoZeroValidateUTF8 = pointerCoderFuncs{
4775 size: sizeBytesNoZero,
4776 marshal: appendBytesNoZeroValidateUTF8,
Damien Neil8003f082019-08-02 15:13:00 -07004777 unmarshal: consumeBytesNoZeroValidateUTF8,
Joe Tsaic51e2e02019-07-13 00:44:41 -07004778}
4779
Damien Neilc37adef2019-04-01 13:49:56 -07004780// sizeBytesSlice returns the size of wire encoding a [][]byte pointer as a repeated Bytes.
4781func sizeBytesSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
4782 s := *p.BytesSlice()
4783 for _, v := range s {
4784 size += tagsize + wire.SizeBytes(len(v))
4785 }
4786 return size
4787}
4788
4789// appendBytesSlice encodes a [][]byte pointer as a repeated Bytes.
4790func appendBytesSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
4791 s := *p.BytesSlice()
4792 for _, v := range s {
4793 b = wire.AppendVarint(b, wiretag)
4794 b = wire.AppendBytes(b, v)
4795 }
4796 return b, nil
4797}
4798
Damien Neile91877d2019-06-27 10:54:42 -07004799// consumeBytesSlice wire decodes a [][]byte pointer as a repeated Bytes.
Damien Neilf0831e82020-01-21 14:25:12 -08004800func consumeBytesSlice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07004801 sp := p.BytesSlice()
4802 if wtyp != wire.BytesType {
Damien Neilf0831e82020-01-21 14:25:12 -08004803 return out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07004804 }
4805 v, n := wire.ConsumeBytes(b)
4806 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08004807 return out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07004808 }
Damien Neil8003f082019-08-02 15:13:00 -07004809 *sp = append(*sp, append(emptyBuf[:], v...))
Damien Neilf0831e82020-01-21 14:25:12 -08004810 out.n = n
4811 return out, nil
Damien Neile91877d2019-06-27 10:54:42 -07004812}
4813
Damien Neilc37adef2019-04-01 13:49:56 -07004814var coderBytesSlice = pointerCoderFuncs{
Damien Neile91877d2019-06-27 10:54:42 -07004815 size: sizeBytesSlice,
4816 marshal: appendBytesSlice,
4817 unmarshal: consumeBytesSlice,
Damien Neilc37adef2019-04-01 13:49:56 -07004818}
4819
Joe Tsaic51e2e02019-07-13 00:44:41 -07004820// appendBytesSliceValidateUTF8 encodes a [][]byte pointer as a repeated Bytes.
4821func appendBytesSliceValidateUTF8(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
4822 s := *p.BytesSlice()
4823 for _, v := range s {
4824 b = wire.AppendVarint(b, wiretag)
4825 b = wire.AppendBytes(b, v)
4826 if !utf8.Valid(v) {
4827 return b, errInvalidUTF8{}
4828 }
4829 }
4830 return b, nil
4831}
4832
4833// consumeBytesSliceValidateUTF8 wire decodes a [][]byte pointer as a repeated Bytes.
Damien Neilf0831e82020-01-21 14:25:12 -08004834func consumeBytesSliceValidateUTF8(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (out unmarshalOutput, err error) {
Joe Tsaic51e2e02019-07-13 00:44:41 -07004835 sp := p.BytesSlice()
4836 if wtyp != wire.BytesType {
Damien Neilf0831e82020-01-21 14:25:12 -08004837 return out, errUnknown
Joe Tsaic51e2e02019-07-13 00:44:41 -07004838 }
4839 v, n := wire.ConsumeBytes(b)
4840 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08004841 return out, wire.ParseError(n)
Joe Tsaic51e2e02019-07-13 00:44:41 -07004842 }
4843 if !utf8.Valid(v) {
Damien Neilf0831e82020-01-21 14:25:12 -08004844 return out, errInvalidUTF8{}
Joe Tsaic51e2e02019-07-13 00:44:41 -07004845 }
Damien Neil8003f082019-08-02 15:13:00 -07004846 *sp = append(*sp, append(emptyBuf[:], v...))
Damien Neilf0831e82020-01-21 14:25:12 -08004847 out.n = n
4848 return out, nil
Joe Tsaic51e2e02019-07-13 00:44:41 -07004849}
4850
4851var coderBytesSliceValidateUTF8 = pointerCoderFuncs{
4852 size: sizeBytesSlice,
4853 marshal: appendBytesSliceValidateUTF8,
4854 unmarshal: consumeBytesSliceValidateUTF8,
4855}
4856
Damien Neil68b81c32019-08-22 11:41:32 -07004857// sizeBytesValue returns the size of wire encoding a []byte value as a Bytes.
4858func sizeBytesValue(v protoreflect.Value, tagsize int, _ marshalOptions) int {
4859 return tagsize + wire.SizeBytes(len(v.Bytes()))
Damien Neilc37adef2019-04-01 13:49:56 -07004860}
4861
Damien Neil68b81c32019-08-22 11:41:32 -07004862// appendBytesValue encodes a []byte value as a Bytes.
4863func appendBytesValue(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
Damien Neilc37adef2019-04-01 13:49:56 -07004864 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07004865 b = wire.AppendBytes(b, v.Bytes())
Damien Neilc37adef2019-04-01 13:49:56 -07004866 return b, nil
4867}
4868
Damien Neil68b81c32019-08-22 11:41:32 -07004869// consumeBytesValue decodes a []byte value as a Bytes.
Damien Neilf0831e82020-01-21 14:25:12 -08004870func consumeBytesValue(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neile91877d2019-06-27 10:54:42 -07004871 if wtyp != wire.BytesType {
Damien Neilf0831e82020-01-21 14:25:12 -08004872 return protoreflect.Value{}, out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07004873 }
4874 v, n := wire.ConsumeBytes(b)
4875 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08004876 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07004877 }
Damien Neilf0831e82020-01-21 14:25:12 -08004878 out.n = n
4879 return protoreflect.ValueOfBytes(append(emptyBuf[:], v...)), out, nil
Damien Neile91877d2019-06-27 10:54:42 -07004880}
4881
Damien Neil68b81c32019-08-22 11:41:32 -07004882var coderBytesValue = valueCoderFuncs{
4883 size: sizeBytesValue,
4884 marshal: appendBytesValue,
4885 unmarshal: consumeBytesValue,
Damien Neilc37adef2019-04-01 13:49:56 -07004886}
4887
Damien Neil68b81c32019-08-22 11:41:32 -07004888// sizeBytesSliceValue returns the size of wire encoding a [][]byte value as a repeated Bytes.
4889func sizeBytesSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
4890 list := listv.List()
4891 for i, llen := 0, list.Len(); i < llen; i++ {
4892 v := list.Get(i)
4893 size += tagsize + wire.SizeBytes(len(v.Bytes()))
Damien Neilc37adef2019-04-01 13:49:56 -07004894 }
4895 return size
4896}
4897
Damien Neil68b81c32019-08-22 11:41:32 -07004898// appendBytesSliceValue encodes a [][]byte value as a repeated Bytes.
4899func appendBytesSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
4900 list := listv.List()
4901 for i, llen := 0, list.Len(); i < llen; i++ {
4902 v := list.Get(i)
Damien Neilc37adef2019-04-01 13:49:56 -07004903 b = wire.AppendVarint(b, wiretag)
Damien Neil68b81c32019-08-22 11:41:32 -07004904 b = wire.AppendBytes(b, v.Bytes())
Damien Neilc37adef2019-04-01 13:49:56 -07004905 }
4906 return b, nil
4907}
4908
Damien Neil68b81c32019-08-22 11:41:32 -07004909// consumeBytesSliceValue wire decodes a [][]byte value as a repeated Bytes.
Damien Neilf0831e82020-01-21 14:25:12 -08004910func consumeBytesSliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
Damien Neil68b81c32019-08-22 11:41:32 -07004911 list := listv.List()
Damien Neile91877d2019-06-27 10:54:42 -07004912 if wtyp != wire.BytesType {
Damien Neilf0831e82020-01-21 14:25:12 -08004913 return protoreflect.Value{}, out, errUnknown
Damien Neile91877d2019-06-27 10:54:42 -07004914 }
4915 v, n := wire.ConsumeBytes(b)
4916 if n < 0 {
Damien Neilf0831e82020-01-21 14:25:12 -08004917 return protoreflect.Value{}, out, wire.ParseError(n)
Damien Neile91877d2019-06-27 10:54:42 -07004918 }
Damien Neil5366f822019-12-05 14:54:35 -08004919 list.Append(protoreflect.ValueOfBytes(append(emptyBuf[:], v...)))
Damien Neilf0831e82020-01-21 14:25:12 -08004920 out.n = n
4921 return listv, out, nil
Damien Neile91877d2019-06-27 10:54:42 -07004922}
4923
Damien Neil68b81c32019-08-22 11:41:32 -07004924var coderBytesSliceValue = valueCoderFuncs{
4925 size: sizeBytesSliceValue,
4926 marshal: appendBytesSliceValue,
4927 unmarshal: consumeBytesSliceValue,
Damien Neilc37adef2019-04-01 13:49:56 -07004928}
4929
Damien Neil8003f082019-08-02 15:13:00 -07004930// We append to an empty array rather than a nil []byte to get non-nil zero-length byte slices.
4931var emptyBuf [0]byte
4932
Damien Neilc37adef2019-04-01 13:49:56 -07004933var wireTypes = map[protoreflect.Kind]wire.Type{
4934 protoreflect.BoolKind: wire.VarintType,
4935 protoreflect.EnumKind: wire.VarintType,
4936 protoreflect.Int32Kind: wire.VarintType,
4937 protoreflect.Sint32Kind: wire.VarintType,
4938 protoreflect.Uint32Kind: wire.VarintType,
4939 protoreflect.Int64Kind: wire.VarintType,
4940 protoreflect.Sint64Kind: wire.VarintType,
4941 protoreflect.Uint64Kind: wire.VarintType,
4942 protoreflect.Sfixed32Kind: wire.Fixed32Type,
4943 protoreflect.Fixed32Kind: wire.Fixed32Type,
4944 protoreflect.FloatKind: wire.Fixed32Type,
4945 protoreflect.Sfixed64Kind: wire.Fixed64Type,
4946 protoreflect.Fixed64Kind: wire.Fixed64Type,
4947 protoreflect.DoubleKind: wire.Fixed64Type,
4948 protoreflect.StringKind: wire.BytesType,
4949 protoreflect.BytesKind: wire.BytesType,
4950 protoreflect.MessageKind: wire.BytesType,
4951 protoreflect.GroupKind: wire.StartGroupType,
4952}