-
Notifications
You must be signed in to change notification settings - Fork 77
/
enum_value.go
69 lines (52 loc) · 2.16 KB
/
enum_value.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package pgs
import (
"google.golang.org/protobuf/runtime/protoimpl"
descriptor "google.golang.org/protobuf/types/descriptorpb"
)
// An EnumValue describes a name-value pair for an entry in an enum.
type EnumValue interface {
Entity
// Descriptor returns the proto descriptor for this Enum Value
Descriptor() *descriptor.EnumValueDescriptorProto
// Enum returns the parent Enum for this value
Enum() Enum
// Value returns the numeric enum value associated with this type
Value() int32
setEnum(e Enum)
}
type enumVal struct {
desc *descriptor.EnumValueDescriptorProto
enum Enum
fqn string
info SourceCodeInfo
}
func (ev *enumVal) Name() Name { return Name(ev.desc.GetName()) }
func (ev *enumVal) FullyQualifiedName() string { return ev.fqn }
func (ev *enumVal) Syntax() Syntax { return ev.enum.Syntax() }
func (ev *enumVal) Package() Package { return ev.enum.Package() }
func (ev *enumVal) File() File { return ev.enum.File() }
func (ev *enumVal) BuildTarget() bool { return ev.enum.BuildTarget() }
func (ev *enumVal) SourceCodeInfo() SourceCodeInfo { return ev.info }
func (ev *enumVal) Descriptor() *descriptor.EnumValueDescriptorProto { return ev.desc }
func (ev *enumVal) Enum() Enum { return ev.enum }
func (ev *enumVal) Value() int32 { return ev.desc.GetNumber() }
func (ev *enumVal) Imports() []File { return nil }
func (ev *enumVal) Extension(desc *protoimpl.ExtensionInfo, ext interface{}) (bool, error) {
return extension(ev.desc.GetOptions(), desc, &ext)
}
func (ev *enumVal) accept(v Visitor) (err error) {
if v == nil {
return nil
}
_, err = v.VisitEnumValue(ev)
return
}
func (ev *enumVal) setEnum(e Enum) { ev.enum = e }
func (ev *enumVal) childAtPath(path []int32) Entity {
if len(path) == 0 {
return ev
}
return nil
}
func (ev *enumVal) addSourceCodeInfo(info SourceCodeInfo) { ev.info = info }
var _ EnumValue = (*enumVal)(nil)