xref: /aosp_15_r20/external/golang-protobuf/internal/filedesc/placeholder.go (revision 1c12ee1efe575feb122dbf939ff15148a3b3e8f2)
1// Copyright 2019 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
5package filedesc
6
7import (
8	"google.golang.org/protobuf/internal/descopts"
9	"google.golang.org/protobuf/internal/pragma"
10	"google.golang.org/protobuf/reflect/protoreflect"
11)
12
13var (
14	emptyNames           = new(Names)
15	emptyEnumRanges      = new(EnumRanges)
16	emptyFieldRanges     = new(FieldRanges)
17	emptyFieldNumbers    = new(FieldNumbers)
18	emptySourceLocations = new(SourceLocations)
19
20	emptyFiles      = new(FileImports)
21	emptyMessages   = new(Messages)
22	emptyFields     = new(Fields)
23	emptyOneofs     = new(Oneofs)
24	emptyEnums      = new(Enums)
25	emptyEnumValues = new(EnumValues)
26	emptyExtensions = new(Extensions)
27	emptyServices   = new(Services)
28)
29
30// PlaceholderFile is a placeholder, representing only the file path.
31type PlaceholderFile string
32
33func (f PlaceholderFile) ParentFile() protoreflect.FileDescriptor       { return f }
34func (f PlaceholderFile) Parent() protoreflect.Descriptor               { return nil }
35func (f PlaceholderFile) Index() int                                    { return 0 }
36func (f PlaceholderFile) Syntax() protoreflect.Syntax                   { return 0 }
37func (f PlaceholderFile) Name() protoreflect.Name                       { return "" }
38func (f PlaceholderFile) FullName() protoreflect.FullName               { return "" }
39func (f PlaceholderFile) IsPlaceholder() bool                           { return true }
40func (f PlaceholderFile) Options() protoreflect.ProtoMessage            { return descopts.File }
41func (f PlaceholderFile) Path() string                                  { return string(f) }
42func (f PlaceholderFile) Package() protoreflect.FullName                { return "" }
43func (f PlaceholderFile) Imports() protoreflect.FileImports             { return emptyFiles }
44func (f PlaceholderFile) Messages() protoreflect.MessageDescriptors     { return emptyMessages }
45func (f PlaceholderFile) Enums() protoreflect.EnumDescriptors           { return emptyEnums }
46func (f PlaceholderFile) Extensions() protoreflect.ExtensionDescriptors { return emptyExtensions }
47func (f PlaceholderFile) Services() protoreflect.ServiceDescriptors     { return emptyServices }
48func (f PlaceholderFile) SourceLocations() protoreflect.SourceLocations { return emptySourceLocations }
49func (f PlaceholderFile) ProtoType(protoreflect.FileDescriptor)         { return }
50func (f PlaceholderFile) ProtoInternal(pragma.DoNotImplement)           { return }
51
52// PlaceholderEnum is a placeholder, representing only the full name.
53type PlaceholderEnum protoreflect.FullName
54
55func (e PlaceholderEnum) ParentFile() protoreflect.FileDescriptor   { return nil }
56func (e PlaceholderEnum) Parent() protoreflect.Descriptor           { return nil }
57func (e PlaceholderEnum) Index() int                                { return 0 }
58func (e PlaceholderEnum) Syntax() protoreflect.Syntax               { return 0 }
59func (e PlaceholderEnum) Name() protoreflect.Name                   { return protoreflect.FullName(e).Name() }
60func (e PlaceholderEnum) FullName() protoreflect.FullName           { return protoreflect.FullName(e) }
61func (e PlaceholderEnum) IsPlaceholder() bool                       { return true }
62func (e PlaceholderEnum) Options() protoreflect.ProtoMessage        { return descopts.Enum }
63func (e PlaceholderEnum) Values() protoreflect.EnumValueDescriptors { return emptyEnumValues }
64func (e PlaceholderEnum) ReservedNames() protoreflect.Names         { return emptyNames }
65func (e PlaceholderEnum) ReservedRanges() protoreflect.EnumRanges   { return emptyEnumRanges }
66func (e PlaceholderEnum) ProtoType(protoreflect.EnumDescriptor)     { return }
67func (e PlaceholderEnum) ProtoInternal(pragma.DoNotImplement)       { return }
68
69// PlaceholderEnumValue is a placeholder, representing only the full name.
70type PlaceholderEnumValue protoreflect.FullName
71
72func (e PlaceholderEnumValue) ParentFile() protoreflect.FileDescriptor    { return nil }
73func (e PlaceholderEnumValue) Parent() protoreflect.Descriptor            { return nil }
74func (e PlaceholderEnumValue) Index() int                                 { return 0 }
75func (e PlaceholderEnumValue) Syntax() protoreflect.Syntax                { return 0 }
76func (e PlaceholderEnumValue) Name() protoreflect.Name                    { return protoreflect.FullName(e).Name() }
77func (e PlaceholderEnumValue) FullName() protoreflect.FullName            { return protoreflect.FullName(e) }
78func (e PlaceholderEnumValue) IsPlaceholder() bool                        { return true }
79func (e PlaceholderEnumValue) Options() protoreflect.ProtoMessage         { return descopts.EnumValue }
80func (e PlaceholderEnumValue) Number() protoreflect.EnumNumber            { return 0 }
81func (e PlaceholderEnumValue) ProtoType(protoreflect.EnumValueDescriptor) { return }
82func (e PlaceholderEnumValue) ProtoInternal(pragma.DoNotImplement)        { return }
83
84// PlaceholderMessage is a placeholder, representing only the full name.
85type PlaceholderMessage protoreflect.FullName
86
87func (m PlaceholderMessage) ParentFile() protoreflect.FileDescriptor    { return nil }
88func (m PlaceholderMessage) Parent() protoreflect.Descriptor            { return nil }
89func (m PlaceholderMessage) Index() int                                 { return 0 }
90func (m PlaceholderMessage) Syntax() protoreflect.Syntax                { return 0 }
91func (m PlaceholderMessage) Name() protoreflect.Name                    { return protoreflect.FullName(m).Name() }
92func (m PlaceholderMessage) FullName() protoreflect.FullName            { return protoreflect.FullName(m) }
93func (m PlaceholderMessage) IsPlaceholder() bool                        { return true }
94func (m PlaceholderMessage) Options() protoreflect.ProtoMessage         { return descopts.Message }
95func (m PlaceholderMessage) IsMapEntry() bool                           { return false }
96func (m PlaceholderMessage) Fields() protoreflect.FieldDescriptors      { return emptyFields }
97func (m PlaceholderMessage) Oneofs() protoreflect.OneofDescriptors      { return emptyOneofs }
98func (m PlaceholderMessage) ReservedNames() protoreflect.Names          { return emptyNames }
99func (m PlaceholderMessage) ReservedRanges() protoreflect.FieldRanges   { return emptyFieldRanges }
100func (m PlaceholderMessage) RequiredNumbers() protoreflect.FieldNumbers { return emptyFieldNumbers }
101func (m PlaceholderMessage) ExtensionRanges() protoreflect.FieldRanges  { return emptyFieldRanges }
102func (m PlaceholderMessage) ExtensionRangeOptions(int) protoreflect.ProtoMessage {
103	panic("index out of range")
104}
105func (m PlaceholderMessage) Messages() protoreflect.MessageDescriptors     { return emptyMessages }
106func (m PlaceholderMessage) Enums() protoreflect.EnumDescriptors           { return emptyEnums }
107func (m PlaceholderMessage) Extensions() protoreflect.ExtensionDescriptors { return emptyExtensions }
108func (m PlaceholderMessage) ProtoType(protoreflect.MessageDescriptor)      { return }
109func (m PlaceholderMessage) ProtoInternal(pragma.DoNotImplement)           { return }
110