MCPcopy
hub / github.com/golang/protobuf / EnumDescriptorProto

Function EnumDescriptorProto

descriptor/descriptor.go:149–164  ·  view source on GitHub ↗

EnumDescriptorProto returns the file descriptor proto representing the enum and the enum descriptor proto for the enum itself. The returned proto messages must not be mutated.

(e proto.GeneratedEnum)

Source from the content-addressed store, hash-verified

147// the enum and the enum descriptor proto for the enum itself.
148// The returned proto messages must not be mutated.
149func EnumDescriptorProto(e proto.GeneratedEnum) (*descriptorpb.FileDescriptorProto, *descriptorpb.EnumDescriptorProto) {
150 rawDesc, idxs := EnumRawDescriptor(e)
151 if rawDesc == nil || idxs == nil {
152 return nil, nil
153 }
154 fd := deriveFileDescriptor(rawDesc)
155 if len(idxs) == 1 {
156 return fd, fd.EnumType[idxs[0]]
157 }
158 md := fd.MessageType[idxs[0]]
159 for _, i := range idxs[1 : len(idxs)-1] {
160 md = md.NestedType[i]
161 }
162 ed := md.EnumType[idxs[len(idxs)-1]]
163 return fd, ed
164}
165
166// MessageDescriptorProto returns the file descriptor proto representing
167// the message and the message descriptor proto for the message itself.

Callers 1

TestEnumDescriptorFunction · 0.85

Calls 2

EnumRawDescriptorFunction · 0.85
deriveFileDescriptorFunction · 0.85

Tested by 1

TestEnumDescriptorFunction · 0.68