summaryrefslogtreecommitdiff
path: root/vendor/github.com/gogo/protobuf/protoc-gen-gogo/descriptor/helper.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/gogo/protobuf/protoc-gen-gogo/descriptor/helper.go')
-rw-r--r--vendor/github.com/gogo/protobuf/protoc-gen-gogo/descriptor/helper.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/vendor/github.com/gogo/protobuf/protoc-gen-gogo/descriptor/helper.go b/vendor/github.com/gogo/protobuf/protoc-gen-gogo/descriptor/helper.go
index 861f4d028..e0846a357 100644
--- a/vendor/github.com/gogo/protobuf/protoc-gen-gogo/descriptor/helper.go
+++ b/vendor/github.com/gogo/protobuf/protoc-gen-gogo/descriptor/helper.go
@@ -99,6 +99,17 @@ func (field *FieldDescriptorProto) GetKeyUint64() (x uint64) {
return x
}
+func (field *FieldDescriptorProto) GetKey3Uint64() (x uint64) {
+ packed := field.IsPacked3()
+ wireType := field.WireType()
+ fieldNumber := field.GetNumber()
+ if packed {
+ wireType = 2
+ }
+ x = uint64(uint32(fieldNumber)<<3 | uint32(wireType))
+ return x
+}
+
func (field *FieldDescriptorProto) GetKey() []byte {
x := field.GetKeyUint64()
i := 0
@@ -111,6 +122,18 @@ func (field *FieldDescriptorProto) GetKey() []byte {
return keybuf
}
+func (field *FieldDescriptorProto) GetKey3() []byte {
+ x := field.GetKey3Uint64()
+ i := 0
+ keybuf := make([]byte, 0)
+ for i = 0; x > 127; i++ {
+ keybuf = append(keybuf, 0x80|uint8(x&0x7F))
+ x >>= 7
+ }
+ keybuf = append(keybuf, uint8(x))
+ return keybuf
+}
+
func (desc *FileDescriptorSet) GetField(packageName, messageName, fieldName string) *FieldDescriptorProto {
msg := desc.GetMessage(packageName, messageName)
if msg == nil {
@@ -352,6 +375,16 @@ func (f *FieldDescriptorProto) IsPacked() bool {
return f.Options != nil && f.GetOptions().GetPacked()
}
+func (f *FieldDescriptorProto) IsPacked3() bool {
+ if f.IsRepeated() && f.IsScalar() {
+ if f.Options == nil || f.GetOptions().Packed == nil {
+ return true
+ }
+ return f.Options != nil && f.GetOptions().GetPacked()
+ }
+ return false
+}
+
func (m *DescriptorProto) HasExtension() bool {
return len(m.ExtensionRange) > 0
}