1// 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 proto
8
9import (
10	"google.golang.org/protobuf/encoding/protowire"
11	"google.golang.org/protobuf/reflect/protoreflect"
12)
13
14func sizeSingular(num protowire.Number, kind protoreflect.Kind, v protoreflect.Value) int {
15	switch kind {
16	case protoreflect.BoolKind:
17		return protowire.SizeVarint(protowire.EncodeBool(v.Bool()))
18	case protoreflect.EnumKind:
19		return protowire.SizeVarint(uint64(v.Enum()))
20	case protoreflect.Int32Kind:
21		return protowire.SizeVarint(uint64(int32(v.Int())))
22	case protoreflect.Sint32Kind:
23		return protowire.SizeVarint(protowire.EncodeZigZag(int64(int32(v.Int()))))
24	case protoreflect.Uint32Kind:
25		return protowire.SizeVarint(uint64(uint32(v.Uint())))
26	case protoreflect.Int64Kind:
27		return protowire.SizeVarint(uint64(v.Int()))
28	case protoreflect.Sint64Kind:
29		return protowire.SizeVarint(protowire.EncodeZigZag(v.Int()))
30	case protoreflect.Uint64Kind:
31		return protowire.SizeVarint(v.Uint())
32	case protoreflect.Sfixed32Kind:
33		return protowire.SizeFixed32()
34	case protoreflect.Fixed32Kind:
35		return protowire.SizeFixed32()
36	case protoreflect.FloatKind:
37		return protowire.SizeFixed32()
38	case protoreflect.Sfixed64Kind:
39		return protowire.SizeFixed64()
40	case protoreflect.Fixed64Kind:
41		return protowire.SizeFixed64()
42	case protoreflect.DoubleKind:
43		return protowire.SizeFixed64()
44	case protoreflect.StringKind:
45		return protowire.SizeBytes(len(v.String()))
46	case protoreflect.BytesKind:
47		return protowire.SizeBytes(len(v.Bytes()))
48	case protoreflect.MessageKind:
49		return protowire.SizeBytes(sizeMessage(v.Message()))
50	case protoreflect.GroupKind:
51		return protowire.SizeGroup(num, sizeMessage(v.Message()))
52	default:
53		return 0
54	}
55}
56