mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-28 22:39:57 +00:00
TUN-8407: Upgrade go to version 1.22.2
This commit is contained in:
34
vendor/google.golang.org/protobuf/reflect/protodesc/desc.go
generated
vendored
34
vendor/google.golang.org/protobuf/reflect/protodesc/desc.go
generated
vendored
@@ -3,16 +3,17 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package protodesc provides functionality for converting
|
||||
// FileDescriptorProto messages to/from protoreflect.FileDescriptor values.
|
||||
// FileDescriptorProto messages to/from [protoreflect.FileDescriptor] values.
|
||||
//
|
||||
// The google.protobuf.FileDescriptorProto is a protobuf message that describes
|
||||
// the type information for a .proto file in a form that is easily serializable.
|
||||
// The protoreflect.FileDescriptor is a more structured representation of
|
||||
// The [protoreflect.FileDescriptor] is a more structured representation of
|
||||
// the FileDescriptorProto message where references and remote dependencies
|
||||
// can be directly followed.
|
||||
package protodesc
|
||||
|
||||
import (
|
||||
"google.golang.org/protobuf/internal/editionssupport"
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
"google.golang.org/protobuf/internal/filedesc"
|
||||
"google.golang.org/protobuf/internal/pragma"
|
||||
@@ -24,11 +25,11 @@ import (
|
||||
"google.golang.org/protobuf/types/descriptorpb"
|
||||
)
|
||||
|
||||
// Resolver is the resolver used by NewFile to resolve dependencies.
|
||||
// Resolver is the resolver used by [NewFile] to resolve dependencies.
|
||||
// The enums and messages provided must belong to some parent file,
|
||||
// which is also registered.
|
||||
//
|
||||
// It is implemented by protoregistry.Files.
|
||||
// It is implemented by [protoregistry.Files].
|
||||
type Resolver interface {
|
||||
FindFileByPath(string) (protoreflect.FileDescriptor, error)
|
||||
FindDescriptorByName(protoreflect.FullName) (protoreflect.Descriptor, error)
|
||||
@@ -61,19 +62,19 @@ type FileOptions struct {
|
||||
AllowUnresolvable bool
|
||||
}
|
||||
|
||||
// NewFile creates a new protoreflect.FileDescriptor from the provided
|
||||
// file descriptor message. See FileOptions.New for more information.
|
||||
// NewFile creates a new [protoreflect.FileDescriptor] from the provided
|
||||
// file descriptor message. See [FileOptions.New] for more information.
|
||||
func NewFile(fd *descriptorpb.FileDescriptorProto, r Resolver) (protoreflect.FileDescriptor, error) {
|
||||
return FileOptions{}.New(fd, r)
|
||||
}
|
||||
|
||||
// NewFiles creates a new protoregistry.Files from the provided
|
||||
// FileDescriptorSet message. See FileOptions.NewFiles for more information.
|
||||
// NewFiles creates a new [protoregistry.Files] from the provided
|
||||
// FileDescriptorSet message. See [FileOptions.NewFiles] for more information.
|
||||
func NewFiles(fd *descriptorpb.FileDescriptorSet) (*protoregistry.Files, error) {
|
||||
return FileOptions{}.NewFiles(fd)
|
||||
}
|
||||
|
||||
// New creates a new protoreflect.FileDescriptor from the provided
|
||||
// New creates a new [protoreflect.FileDescriptor] from the provided
|
||||
// file descriptor message. The file must represent a valid proto file according
|
||||
// to protobuf semantics. The returned descriptor is a deep copy of the input.
|
||||
//
|
||||
@@ -91,11 +92,19 @@ func (o FileOptions) New(fd *descriptorpb.FileDescriptorProto, r Resolver) (prot
|
||||
switch fd.GetSyntax() {
|
||||
case "proto2", "":
|
||||
f.L1.Syntax = protoreflect.Proto2
|
||||
f.L1.Edition = filedesc.EditionProto2
|
||||
case "proto3":
|
||||
f.L1.Syntax = protoreflect.Proto3
|
||||
f.L1.Edition = filedesc.EditionProto3
|
||||
case "editions":
|
||||
f.L1.Syntax = protoreflect.Editions
|
||||
f.L1.Edition = fromEditionProto(fd.GetEdition())
|
||||
default:
|
||||
return nil, errors.New("invalid syntax: %q", fd.GetSyntax())
|
||||
}
|
||||
if f.L1.Syntax == protoreflect.Editions && (fd.GetEdition() < editionssupport.Minimum || fd.GetEdition() > editionssupport.Maximum) {
|
||||
return nil, errors.New("use of edition %v not yet supported by the Go Protobuf runtime", fd.GetEdition())
|
||||
}
|
||||
f.L1.Path = fd.GetName()
|
||||
if f.L1.Path == "" {
|
||||
return nil, errors.New("file path must be populated")
|
||||
@@ -108,6 +117,7 @@ func (o FileOptions) New(fd *descriptorpb.FileDescriptorProto, r Resolver) (prot
|
||||
opts = proto.Clone(opts).(*descriptorpb.FileOptions)
|
||||
f.L2.Options = func() protoreflect.ProtoMessage { return opts }
|
||||
}
|
||||
initFileDescFromFeatureSet(f, fd.GetOptions().GetFeatures())
|
||||
|
||||
f.L2.Imports = make(filedesc.FileImports, len(fd.GetDependency()))
|
||||
for _, i := range fd.GetPublicDependency() {
|
||||
@@ -210,10 +220,10 @@ func (o FileOptions) New(fd *descriptorpb.FileDescriptorProto, r Resolver) (prot
|
||||
if err := validateEnumDeclarations(f.L1.Enums.List, fd.GetEnumType()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := validateMessageDeclarations(f.L1.Messages.List, fd.GetMessageType()); err != nil {
|
||||
if err := validateMessageDeclarations(f, f.L1.Messages.List, fd.GetMessageType()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := validateExtensionDeclarations(f.L1.Extensions.List, fd.GetExtension()); err != nil {
|
||||
if err := validateExtensionDeclarations(f, f.L1.Extensions.List, fd.GetExtension()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -231,7 +241,7 @@ func (is importSet) importPublic(imps protoreflect.FileImports) {
|
||||
}
|
||||
}
|
||||
|
||||
// NewFiles creates a new protoregistry.Files from the provided
|
||||
// NewFiles creates a new [protoregistry.Files] from the provided
|
||||
// FileDescriptorSet message. The descriptor set must include only
|
||||
// valid files according to protobuf semantics. The returned descriptors
|
||||
// are a deep copy of the input.
|
||||
|
Reference in New Issue
Block a user