mirror of https://github.com/docker/buildx.git
vendor: google.golang.org/protobuf v1.31.0
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
9efaa2793d
commit
ab58333311
2
go.mod
2
go.mod
|
@ -152,7 +152,7 @@ require (
|
|||
golang.org/x/tools v0.10.0 // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect
|
||||
google.golang.org/protobuf v1.30.0 // indirect
|
||||
google.golang.org/protobuf v1.31.0 // indirect
|
||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
k8s.io/klog/v2 v2.90.1 // indirect
|
||||
|
|
4
go.sum
4
go.sum
|
@ -866,8 +866,8 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba
|
|||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
|
||||
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
|
||||
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/cenkalti/backoff.v2 v2.2.1 h1:eJ9UAg01/HIHG987TwxvnzK2MgxXq97YY6rYDpY9aII=
|
||||
|
|
|
@ -614,7 +614,10 @@ func genMessageSetterMethods(g *protogen.GeneratedFile, f *fileInfo, m *messageI
|
|||
|
||||
genNoInterfacePragma(g, m.isTracked)
|
||||
|
||||
g.Annotate(m.GoIdent.GoName+".Set"+field.GoName, field.Location)
|
||||
g.AnnotateSymbol(m.GoIdent.GoName+".Set"+field.GoName, protogen.Annotation{
|
||||
Location: field.Location,
|
||||
Semantic: descriptorpb.GeneratedCodeInfo_Annotation_SET.Enum(),
|
||||
})
|
||||
leadingComments := appendDeprecationSuffix("",
|
||||
field.Desc.ParentFile(),
|
||||
field.Desc.Options().(*descriptorpb.FieldOptions).GetDeprecated())
|
||||
|
|
|
@ -920,7 +920,7 @@ type GeneratedFile struct {
|
|||
packageNames map[GoImportPath]GoPackageName
|
||||
usedPackageNames map[GoPackageName]bool
|
||||
manualImports map[GoImportPath]bool
|
||||
annotations map[string][]Location
|
||||
annotations map[string][]Annotation
|
||||
}
|
||||
|
||||
// NewGeneratedFile creates a new generated file with the given filename
|
||||
|
@ -933,7 +933,7 @@ func (gen *Plugin) NewGeneratedFile(filename string, goImportPath GoImportPath)
|
|||
packageNames: make(map[GoImportPath]GoPackageName),
|
||||
usedPackageNames: make(map[GoPackageName]bool),
|
||||
manualImports: make(map[GoImportPath]bool),
|
||||
annotations: make(map[string][]Location),
|
||||
annotations: make(map[string][]Annotation),
|
||||
}
|
||||
|
||||
// All predeclared identifiers in Go are already used.
|
||||
|
@ -1012,8 +1012,32 @@ func (g *GeneratedFile) Unskip() {
|
|||
// The symbol may refer to a type, constant, variable, function, method, or
|
||||
// struct field. The "T.sel" syntax is used to identify the method or field
|
||||
// 'sel' on type 'T'.
|
||||
//
|
||||
// Deprecated: Use the AnnotateSymbol method instead.
|
||||
func (g *GeneratedFile) Annotate(symbol string, loc Location) {
|
||||
g.annotations[symbol] = append(g.annotations[symbol], loc)
|
||||
g.AnnotateSymbol(symbol, Annotation{Location: loc})
|
||||
}
|
||||
|
||||
// An Annotation provides semantic detail for a generated proto element.
|
||||
//
|
||||
// See the google.protobuf.GeneratedCodeInfo.Annotation documentation in
|
||||
// descriptor.proto for details.
|
||||
type Annotation struct {
|
||||
// Location is the source .proto file for the element.
|
||||
Location Location
|
||||
|
||||
// Semantic is the symbol's effect on the element in the original .proto file.
|
||||
Semantic *descriptorpb.GeneratedCodeInfo_Annotation_Semantic
|
||||
}
|
||||
|
||||
// AnnotateSymbol associates a symbol in a generated Go file with a location
|
||||
// in a source .proto file and a semantic type.
|
||||
//
|
||||
// The symbol may refer to a type, constant, variable, function, method, or
|
||||
// struct field. The "T.sel" syntax is used to identify the method or field
|
||||
// 'sel' on type 'T'.
|
||||
func (g *GeneratedFile) AnnotateSymbol(symbol string, info Annotation) {
|
||||
g.annotations[symbol] = append(g.annotations[symbol], info)
|
||||
}
|
||||
|
||||
// Content returns the contents of the generated file.
|
||||
|
@ -1106,25 +1130,24 @@ func (g *GeneratedFile) Content() ([]byte, error) {
|
|||
return out.Bytes(), nil
|
||||
}
|
||||
|
||||
// metaFile returns the contents of the file's metadata file, which is a
|
||||
// text formatted string of the google.protobuf.GeneratedCodeInfo.
|
||||
func (g *GeneratedFile) metaFile(content []byte) (string, error) {
|
||||
func (g *GeneratedFile) generatedCodeInfo(content []byte) (*descriptorpb.GeneratedCodeInfo, error) {
|
||||
fset := token.NewFileSet()
|
||||
astFile, err := parser.ParseFile(fset, "", content, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return nil, err
|
||||
}
|
||||
info := &descriptorpb.GeneratedCodeInfo{}
|
||||
|
||||
seenAnnotations := make(map[string]bool)
|
||||
annotate := func(s string, ident *ast.Ident) {
|
||||
seenAnnotations[s] = true
|
||||
for _, loc := range g.annotations[s] {
|
||||
for _, a := range g.annotations[s] {
|
||||
info.Annotation = append(info.Annotation, &descriptorpb.GeneratedCodeInfo_Annotation{
|
||||
SourceFile: proto.String(loc.SourceFile),
|
||||
Path: loc.Path,
|
||||
SourceFile: proto.String(a.Location.SourceFile),
|
||||
Path: a.Location.Path,
|
||||
Begin: proto.Int32(int32(fset.Position(ident.Pos()).Offset)),
|
||||
End: proto.Int32(int32(fset.Position(ident.End()).Offset)),
|
||||
Semantic: a.Semantic,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1171,10 +1194,21 @@ func (g *GeneratedFile) metaFile(content []byte) (string, error) {
|
|||
}
|
||||
for a := range g.annotations {
|
||||
if !seenAnnotations[a] {
|
||||
return "", fmt.Errorf("%v: no symbol matching annotation %q", g.filename, a)
|
||||
return nil, fmt.Errorf("%v: no symbol matching annotation %q", g.filename, a)
|
||||
}
|
||||
}
|
||||
|
||||
return info, nil
|
||||
}
|
||||
|
||||
// metaFile returns the contents of the file's metadata file, which is a
|
||||
// text formatted string of the google.protobuf.GeneratedCodeInfo.
|
||||
func (g *GeneratedFile) metaFile(content []byte) (string, error) {
|
||||
info, err := g.generatedCodeInfo(content)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
b, err := prototext.Marshal(info)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
|
|
@ -106,13 +106,19 @@ func (o MarshalOptions) Format(m proto.Message) string {
|
|||
// MarshalOptions. Do not depend on the output being stable. It may change over
|
||||
// time across different versions of the program.
|
||||
func (o MarshalOptions) Marshal(m proto.Message) ([]byte, error) {
|
||||
return o.marshal(m)
|
||||
return o.marshal(nil, m)
|
||||
}
|
||||
|
||||
// MarshalAppend appends the JSON format encoding of m to b,
|
||||
// returning the result.
|
||||
func (o MarshalOptions) MarshalAppend(b []byte, m proto.Message) ([]byte, error) {
|
||||
return o.marshal(b, m)
|
||||
}
|
||||
|
||||
// marshal is a centralized function that all marshal operations go through.
|
||||
// For profiling purposes, avoid changing the name of this function or
|
||||
// introducing other code paths for marshal that do not go through this.
|
||||
func (o MarshalOptions) marshal(m proto.Message) ([]byte, error) {
|
||||
func (o MarshalOptions) marshal(b []byte, m proto.Message) ([]byte, error) {
|
||||
if o.Multiline && o.Indent == "" {
|
||||
o.Indent = defaultIndent
|
||||
}
|
||||
|
@ -120,7 +126,7 @@ func (o MarshalOptions) marshal(m proto.Message) ([]byte, error) {
|
|||
o.Resolver = protoregistry.GlobalTypes
|
||||
}
|
||||
|
||||
internalEnc, err := json.NewEncoder(o.Indent)
|
||||
internalEnc, err := json.NewEncoder(b, o.Indent)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -128,7 +134,7 @@ func (o MarshalOptions) marshal(m proto.Message) ([]byte, error) {
|
|||
// Treat nil message interface as an empty message,
|
||||
// in which case the output in an empty JSON object.
|
||||
if m == nil {
|
||||
return []byte("{}"), nil
|
||||
return append(b, '{', '}'), nil
|
||||
}
|
||||
|
||||
enc := encoder{internalEnc, o}
|
||||
|
|
|
@ -101,13 +101,19 @@ func (o MarshalOptions) Format(m proto.Message) string {
|
|||
// MarshalOptions object. Do not depend on the output being stable. It may
|
||||
// change over time across different versions of the program.
|
||||
func (o MarshalOptions) Marshal(m proto.Message) ([]byte, error) {
|
||||
return o.marshal(m)
|
||||
return o.marshal(nil, m)
|
||||
}
|
||||
|
||||
// MarshalAppend appends the textproto format encoding of m to b,
|
||||
// returning the result.
|
||||
func (o MarshalOptions) MarshalAppend(b []byte, m proto.Message) ([]byte, error) {
|
||||
return o.marshal(b, m)
|
||||
}
|
||||
|
||||
// marshal is a centralized function that all marshal operations go through.
|
||||
// For profiling purposes, avoid changing the name of this function or
|
||||
// introducing other code paths for marshal that do not go through this.
|
||||
func (o MarshalOptions) marshal(m proto.Message) ([]byte, error) {
|
||||
func (o MarshalOptions) marshal(b []byte, m proto.Message) ([]byte, error) {
|
||||
var delims = [2]byte{'{', '}'}
|
||||
|
||||
if o.Multiline && o.Indent == "" {
|
||||
|
@ -117,7 +123,7 @@ func (o MarshalOptions) marshal(m proto.Message) ([]byte, error) {
|
|||
o.Resolver = protoregistry.GlobalTypes
|
||||
}
|
||||
|
||||
internalEnc, err := text.NewEncoder(o.Indent, delims, o.EmitASCII)
|
||||
internalEnc, err := text.NewEncoder(b, o.Indent, delims, o.EmitASCII)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -125,7 +131,7 @@ func (o MarshalOptions) marshal(m proto.Message) ([]byte, error) {
|
|||
// Treat nil message interface as an empty message,
|
||||
// in which case there is nothing to output.
|
||||
if m == nil {
|
||||
return []byte{}, nil
|
||||
return b, nil
|
||||
}
|
||||
|
||||
enc := encoder{internalEnc, o}
|
||||
|
|
|
@ -41,8 +41,10 @@ type Encoder struct {
|
|||
//
|
||||
// If indent is a non-empty string, it causes every entry for an Array or Object
|
||||
// to be preceded by the indent and trailed by a newline.
|
||||
func NewEncoder(indent string) (*Encoder, error) {
|
||||
e := &Encoder{}
|
||||
func NewEncoder(buf []byte, indent string) (*Encoder, error) {
|
||||
e := &Encoder{
|
||||
out: buf,
|
||||
}
|
||||
if len(indent) > 0 {
|
||||
if strings.Trim(indent, " \t") != "" {
|
||||
return nil, errors.New("indent may only be composed of space or tab characters")
|
||||
|
@ -176,13 +178,13 @@ func appendFloat(out []byte, n float64, bitSize int) []byte {
|
|||
// WriteInt writes out the given signed integer in JSON number value.
|
||||
func (e *Encoder) WriteInt(n int64) {
|
||||
e.prepareNext(scalar)
|
||||
e.out = append(e.out, strconv.FormatInt(n, 10)...)
|
||||
e.out = strconv.AppendInt(e.out, n, 10)
|
||||
}
|
||||
|
||||
// WriteUint writes out the given unsigned integer in JSON number value.
|
||||
func (e *Encoder) WriteUint(n uint64) {
|
||||
e.prepareNext(scalar)
|
||||
e.out = append(e.out, strconv.FormatUint(n, 10)...)
|
||||
e.out = strconv.AppendUint(e.out, n, 10)
|
||||
}
|
||||
|
||||
// StartObject writes out the '{' symbol.
|
||||
|
|
|
@ -53,8 +53,10 @@ type encoderState struct {
|
|||
// If outputASCII is true, strings will be serialized in such a way that
|
||||
// multi-byte UTF-8 sequences are escaped. This property ensures that the
|
||||
// overall output is ASCII (as opposed to UTF-8).
|
||||
func NewEncoder(indent string, delims [2]byte, outputASCII bool) (*Encoder, error) {
|
||||
e := &Encoder{}
|
||||
func NewEncoder(buf []byte, indent string, delims [2]byte, outputASCII bool) (*Encoder, error) {
|
||||
e := &Encoder{
|
||||
encoderState: encoderState{out: buf},
|
||||
}
|
||||
if len(indent) > 0 {
|
||||
if strings.Trim(indent, " \t") != "" {
|
||||
return nil, errors.New("indent may only be composed of space and tab characters")
|
||||
|
@ -195,13 +197,13 @@ func appendFloat(out []byte, n float64, bitSize int) []byte {
|
|||
// WriteInt writes out the given signed integer value.
|
||||
func (e *Encoder) WriteInt(n int64) {
|
||||
e.prepareNext(scalar)
|
||||
e.out = append(e.out, strconv.FormatInt(n, 10)...)
|
||||
e.out = strconv.AppendInt(e.out, n, 10)
|
||||
}
|
||||
|
||||
// WriteUint writes out the given unsigned integer value.
|
||||
func (e *Encoder) WriteUint(n uint64) {
|
||||
e.prepareNext(scalar)
|
||||
e.out = append(e.out, strconv.FormatUint(n, 10)...)
|
||||
e.out = strconv.AppendUint(e.out, n, 10)
|
||||
}
|
||||
|
||||
// WriteLiteral writes out the given string as a literal value without quotes.
|
||||
|
|
|
@ -183,13 +183,58 @@ const (
|
|||
// Field names for google.protobuf.ExtensionRangeOptions.
|
||||
const (
|
||||
ExtensionRangeOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
|
||||
ExtensionRangeOptions_Declaration_field_name protoreflect.Name = "declaration"
|
||||
ExtensionRangeOptions_Verification_field_name protoreflect.Name = "verification"
|
||||
|
||||
ExtensionRangeOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.ExtensionRangeOptions.uninterpreted_option"
|
||||
ExtensionRangeOptions_Declaration_field_fullname protoreflect.FullName = "google.protobuf.ExtensionRangeOptions.declaration"
|
||||
ExtensionRangeOptions_Verification_field_fullname protoreflect.FullName = "google.protobuf.ExtensionRangeOptions.verification"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.ExtensionRangeOptions.
|
||||
const (
|
||||
ExtensionRangeOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
|
||||
ExtensionRangeOptions_Declaration_field_number protoreflect.FieldNumber = 2
|
||||
ExtensionRangeOptions_Verification_field_number protoreflect.FieldNumber = 3
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.ExtensionRangeOptions.VerificationState.
|
||||
const (
|
||||
ExtensionRangeOptions_VerificationState_enum_fullname = "google.protobuf.ExtensionRangeOptions.VerificationState"
|
||||
ExtensionRangeOptions_VerificationState_enum_name = "VerificationState"
|
||||
)
|
||||
|
||||
// Names for google.protobuf.ExtensionRangeOptions.Declaration.
|
||||
const (
|
||||
ExtensionRangeOptions_Declaration_message_name protoreflect.Name = "Declaration"
|
||||
ExtensionRangeOptions_Declaration_message_fullname protoreflect.FullName = "google.protobuf.ExtensionRangeOptions.Declaration"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.ExtensionRangeOptions.Declaration.
|
||||
const (
|
||||
ExtensionRangeOptions_Declaration_Number_field_name protoreflect.Name = "number"
|
||||
ExtensionRangeOptions_Declaration_FullName_field_name protoreflect.Name = "full_name"
|
||||
ExtensionRangeOptions_Declaration_Type_field_name protoreflect.Name = "type"
|
||||
ExtensionRangeOptions_Declaration_IsRepeated_field_name protoreflect.Name = "is_repeated"
|
||||
ExtensionRangeOptions_Declaration_Reserved_field_name protoreflect.Name = "reserved"
|
||||
ExtensionRangeOptions_Declaration_Repeated_field_name protoreflect.Name = "repeated"
|
||||
|
||||
ExtensionRangeOptions_Declaration_Number_field_fullname protoreflect.FullName = "google.protobuf.ExtensionRangeOptions.Declaration.number"
|
||||
ExtensionRangeOptions_Declaration_FullName_field_fullname protoreflect.FullName = "google.protobuf.ExtensionRangeOptions.Declaration.full_name"
|
||||
ExtensionRangeOptions_Declaration_Type_field_fullname protoreflect.FullName = "google.protobuf.ExtensionRangeOptions.Declaration.type"
|
||||
ExtensionRangeOptions_Declaration_IsRepeated_field_fullname protoreflect.FullName = "google.protobuf.ExtensionRangeOptions.Declaration.is_repeated"
|
||||
ExtensionRangeOptions_Declaration_Reserved_field_fullname protoreflect.FullName = "google.protobuf.ExtensionRangeOptions.Declaration.reserved"
|
||||
ExtensionRangeOptions_Declaration_Repeated_field_fullname protoreflect.FullName = "google.protobuf.ExtensionRangeOptions.Declaration.repeated"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.ExtensionRangeOptions.Declaration.
|
||||
const (
|
||||
ExtensionRangeOptions_Declaration_Number_field_number protoreflect.FieldNumber = 1
|
||||
ExtensionRangeOptions_Declaration_FullName_field_number protoreflect.FieldNumber = 2
|
||||
ExtensionRangeOptions_Declaration_Type_field_number protoreflect.FieldNumber = 3
|
||||
ExtensionRangeOptions_Declaration_IsRepeated_field_number protoreflect.FieldNumber = 4
|
||||
ExtensionRangeOptions_Declaration_Reserved_field_number protoreflect.FieldNumber = 5
|
||||
ExtensionRangeOptions_Declaration_Repeated_field_number protoreflect.FieldNumber = 6
|
||||
)
|
||||
|
||||
// Names for google.protobuf.FieldDescriptorProto.
|
||||
|
@ -540,6 +585,7 @@ const (
|
|||
FieldOptions_DebugRedact_field_name protoreflect.Name = "debug_redact"
|
||||
FieldOptions_Retention_field_name protoreflect.Name = "retention"
|
||||
FieldOptions_Target_field_name protoreflect.Name = "target"
|
||||
FieldOptions_Targets_field_name protoreflect.Name = "targets"
|
||||
FieldOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
|
||||
|
||||
FieldOptions_Ctype_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.ctype"
|
||||
|
@ -552,6 +598,7 @@ const (
|
|||
FieldOptions_DebugRedact_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.debug_redact"
|
||||
FieldOptions_Retention_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.retention"
|
||||
FieldOptions_Target_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.target"
|
||||
FieldOptions_Targets_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.targets"
|
||||
FieldOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.uninterpreted_option"
|
||||
)
|
||||
|
||||
|
@ -567,6 +614,7 @@ const (
|
|||
FieldOptions_DebugRedact_field_number protoreflect.FieldNumber = 16
|
||||
FieldOptions_Retention_field_number protoreflect.FieldNumber = 17
|
||||
FieldOptions_Target_field_number protoreflect.FieldNumber = 18
|
||||
FieldOptions_Targets_field_number protoreflect.FieldNumber = 19
|
||||
FieldOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
|
||||
)
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ const (
|
|||
Type_Options_field_name protoreflect.Name = "options"
|
||||
Type_SourceContext_field_name protoreflect.Name = "source_context"
|
||||
Type_Syntax_field_name protoreflect.Name = "syntax"
|
||||
Type_Edition_field_name protoreflect.Name = "edition"
|
||||
|
||||
Type_Name_field_fullname protoreflect.FullName = "google.protobuf.Type.name"
|
||||
Type_Fields_field_fullname protoreflect.FullName = "google.protobuf.Type.fields"
|
||||
|
@ -39,6 +40,7 @@ const (
|
|||
Type_Options_field_fullname protoreflect.FullName = "google.protobuf.Type.options"
|
||||
Type_SourceContext_field_fullname protoreflect.FullName = "google.protobuf.Type.source_context"
|
||||
Type_Syntax_field_fullname protoreflect.FullName = "google.protobuf.Type.syntax"
|
||||
Type_Edition_field_fullname protoreflect.FullName = "google.protobuf.Type.edition"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.Type.
|
||||
|
@ -49,6 +51,7 @@ const (
|
|||
Type_Options_field_number protoreflect.FieldNumber = 4
|
||||
Type_SourceContext_field_number protoreflect.FieldNumber = 5
|
||||
Type_Syntax_field_number protoreflect.FieldNumber = 6
|
||||
Type_Edition_field_number protoreflect.FieldNumber = 7
|
||||
)
|
||||
|
||||
// Names for google.protobuf.Field.
|
||||
|
@ -121,12 +124,14 @@ const (
|
|||
Enum_Options_field_name protoreflect.Name = "options"
|
||||
Enum_SourceContext_field_name protoreflect.Name = "source_context"
|
||||
Enum_Syntax_field_name protoreflect.Name = "syntax"
|
||||
Enum_Edition_field_name protoreflect.Name = "edition"
|
||||
|
||||
Enum_Name_field_fullname protoreflect.FullName = "google.protobuf.Enum.name"
|
||||
Enum_Enumvalue_field_fullname protoreflect.FullName = "google.protobuf.Enum.enumvalue"
|
||||
Enum_Options_field_fullname protoreflect.FullName = "google.protobuf.Enum.options"
|
||||
Enum_SourceContext_field_fullname protoreflect.FullName = "google.protobuf.Enum.source_context"
|
||||
Enum_Syntax_field_fullname protoreflect.FullName = "google.protobuf.Enum.syntax"
|
||||
Enum_Edition_field_fullname protoreflect.FullName = "google.protobuf.Enum.edition"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.Enum.
|
||||
|
@ -136,6 +141,7 @@ const (
|
|||
Enum_Options_field_number protoreflect.FieldNumber = 3
|
||||
Enum_SourceContext_field_number protoreflect.FieldNumber = 4
|
||||
Enum_Syntax_field_number protoreflect.FieldNumber = 5
|
||||
Enum_Edition_field_number protoreflect.FieldNumber = 6
|
||||
)
|
||||
|
||||
// Names for google.protobuf.EnumValue.
|
||||
|
|
|
@ -33,7 +33,7 @@ var (
|
|||
return !inOneof(ox) && inOneof(oy)
|
||||
}
|
||||
// Fields in disjoint oneof sets are sorted by declaration index.
|
||||
if ox != nil && oy != nil && ox != oy {
|
||||
if inOneof(ox) && inOneof(oy) && ox != oy {
|
||||
return ox.Index() < oy.Index()
|
||||
}
|
||||
// Fields sorted by field number.
|
||||
|
|
|
@ -51,7 +51,7 @@ import (
|
|||
// 10. Send out the CL for review and submit it.
|
||||
const (
|
||||
Major = 1
|
||||
Minor = 30
|
||||
Minor = 31
|
||||
Patch = 0
|
||||
PreRelease = ""
|
||||
)
|
||||
|
|
|
@ -73,23 +73,27 @@ func (o MarshalOptions) sizeField(fd protoreflect.FieldDescriptor, value protore
|
|||
}
|
||||
|
||||
func (o MarshalOptions) sizeList(num protowire.Number, fd protoreflect.FieldDescriptor, list protoreflect.List) (size int) {
|
||||
sizeTag := protowire.SizeTag(num)
|
||||
|
||||
if fd.IsPacked() && list.Len() > 0 {
|
||||
content := 0
|
||||
for i, llen := 0, list.Len(); i < llen; i++ {
|
||||
content += o.sizeSingular(num, fd.Kind(), list.Get(i))
|
||||
}
|
||||
return protowire.SizeTag(num) + protowire.SizeBytes(content)
|
||||
return sizeTag + protowire.SizeBytes(content)
|
||||
}
|
||||
|
||||
for i, llen := 0, list.Len(); i < llen; i++ {
|
||||
size += protowire.SizeTag(num) + o.sizeSingular(num, fd.Kind(), list.Get(i))
|
||||
size += sizeTag + o.sizeSingular(num, fd.Kind(), list.Get(i))
|
||||
}
|
||||
return size
|
||||
}
|
||||
|
||||
func (o MarshalOptions) sizeMap(num protowire.Number, fd protoreflect.FieldDescriptor, mapv protoreflect.Map) (size int) {
|
||||
sizeTag := protowire.SizeTag(num)
|
||||
|
||||
mapv.Range(func(key protoreflect.MapKey, value protoreflect.Value) bool {
|
||||
size += protowire.SizeTag(num)
|
||||
size += sizeTag
|
||||
size += protowire.SizeBytes(o.sizeField(fd.MapKey(), key.Value()) + o.sizeField(fd.MapValue(), value))
|
||||
return true
|
||||
})
|
||||
|
|
|
@ -363,6 +363,8 @@ func (p *SourcePath) appendFieldOptions(b []byte) []byte {
|
|||
b = p.appendSingularField(b, "retention", nil)
|
||||
case 18:
|
||||
b = p.appendSingularField(b, "target", nil)
|
||||
case 19:
|
||||
b = p.appendRepeatedField(b, "targets", nil)
|
||||
case 999:
|
||||
b = p.appendRepeatedField(b, "uninterpreted_option", (*SourcePath).appendUninterpretedOption)
|
||||
}
|
||||
|
@ -418,6 +420,10 @@ func (p *SourcePath) appendExtensionRangeOptions(b []byte) []byte {
|
|||
switch (*p)[0] {
|
||||
case 999:
|
||||
b = p.appendRepeatedField(b, "uninterpreted_option", (*SourcePath).appendUninterpretedOption)
|
||||
case 2:
|
||||
b = p.appendRepeatedField(b, "declaration", (*SourcePath).appendExtensionRangeOptions_Declaration)
|
||||
case 3:
|
||||
b = p.appendSingularField(b, "verification", nil)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
@ -473,3 +479,24 @@ func (p *SourcePath) appendUninterpretedOption_NamePart(b []byte) []byte {
|
|||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (p *SourcePath) appendExtensionRangeOptions_Declaration(b []byte) []byte {
|
||||
if len(*p) == 0 {
|
||||
return b
|
||||
}
|
||||
switch (*p)[0] {
|
||||
case 1:
|
||||
b = p.appendSingularField(b, "number", nil)
|
||||
case 2:
|
||||
b = p.appendSingularField(b, "full_name", nil)
|
||||
case 3:
|
||||
b = p.appendSingularField(b, "type", nil)
|
||||
case 4:
|
||||
b = p.appendSingularField(b, "is_repeated", nil)
|
||||
case 5:
|
||||
b = p.appendSingularField(b, "reserved", nil)
|
||||
case 6:
|
||||
b = p.appendSingularField(b, "repeated", nil)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,177 @@
|
|||
// Copyright 2023 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package dynamicpb
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
)
|
||||
|
||||
type extField struct {
|
||||
name protoreflect.FullName
|
||||
number protoreflect.FieldNumber
|
||||
}
|
||||
|
||||
// A Types is a collection of dynamically constructed descriptors.
|
||||
// Its methods are safe for concurrent use.
|
||||
//
|
||||
// Types implements protoregistry.MessageTypeResolver and protoregistry.ExtensionTypeResolver.
|
||||
// A Types may be used as a proto.UnmarshalOptions.Resolver.
|
||||
type Types struct {
|
||||
files *protoregistry.Files
|
||||
|
||||
extMu sync.Mutex
|
||||
atomicExtFiles uint64
|
||||
extensionsByMessage map[extField]protoreflect.ExtensionDescriptor
|
||||
}
|
||||
|
||||
// NewTypes creates a new Types registry with the provided files.
|
||||
// The Files registry is retained, and changes to Files will be reflected in Types.
|
||||
// It is not safe to concurrently change the Files while calling Types methods.
|
||||
func NewTypes(f *protoregistry.Files) *Types {
|
||||
return &Types{
|
||||
files: f,
|
||||
}
|
||||
}
|
||||
|
||||
// FindEnumByName looks up an enum by its full name;
|
||||
// e.g., "google.protobuf.Field.Kind".
|
||||
//
|
||||
// This returns (nil, protoregistry.NotFound) if not found.
|
||||
func (t *Types) FindEnumByName(name protoreflect.FullName) (protoreflect.EnumType, error) {
|
||||
d, err := t.files.FindDescriptorByName(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ed, ok := d.(protoreflect.EnumDescriptor)
|
||||
if !ok {
|
||||
return nil, errors.New("found wrong type: got %v, want enum", descName(d))
|
||||
}
|
||||
return NewEnumType(ed), nil
|
||||
}
|
||||
|
||||
// FindExtensionByName looks up an extension field by the field's full name.
|
||||
// Note that this is the full name of the field as determined by
|
||||
// where the extension is declared and is unrelated to the full name of the
|
||||
// message being extended.
|
||||
//
|
||||
// This returns (nil, protoregistry.NotFound) if not found.
|
||||
func (t *Types) FindExtensionByName(name protoreflect.FullName) (protoreflect.ExtensionType, error) {
|
||||
d, err := t.files.FindDescriptorByName(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
xd, ok := d.(protoreflect.ExtensionDescriptor)
|
||||
if !ok {
|
||||
return nil, errors.New("found wrong type: got %v, want extension", descName(d))
|
||||
}
|
||||
return NewExtensionType(xd), nil
|
||||
}
|
||||
|
||||
// FindExtensionByNumber looks up an extension field by the field number
|
||||
// within some parent message, identified by full name.
|
||||
//
|
||||
// This returns (nil, protoregistry.NotFound) if not found.
|
||||
func (t *Types) FindExtensionByNumber(message protoreflect.FullName, field protoreflect.FieldNumber) (protoreflect.ExtensionType, error) {
|
||||
// Construct the extension number map lazily, since not every user will need it.
|
||||
// Update the map if new files are added to the registry.
|
||||
if atomic.LoadUint64(&t.atomicExtFiles) != uint64(t.files.NumFiles()) {
|
||||
t.updateExtensions()
|
||||
}
|
||||
xd := t.extensionsByMessage[extField{message, field}]
|
||||
if xd == nil {
|
||||
return nil, protoregistry.NotFound
|
||||
}
|
||||
return NewExtensionType(xd), nil
|
||||
}
|
||||
|
||||
// FindMessageByName looks up a message by its full name;
|
||||
// e.g. "google.protobuf.Any".
|
||||
//
|
||||
// This returns (nil, protoregistry.NotFound) if not found.
|
||||
func (t *Types) FindMessageByName(name protoreflect.FullName) (protoreflect.MessageType, error) {
|
||||
d, err := t.files.FindDescriptorByName(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
md, ok := d.(protoreflect.MessageDescriptor)
|
||||
if !ok {
|
||||
return nil, errors.New("found wrong type: got %v, want message", descName(d))
|
||||
}
|
||||
return NewMessageType(md), nil
|
||||
}
|
||||
|
||||
// FindMessageByURL looks up a message by a URL identifier.
|
||||
// See documentation on google.protobuf.Any.type_url for the URL format.
|
||||
//
|
||||
// This returns (nil, protoregistry.NotFound) if not found.
|
||||
func (t *Types) FindMessageByURL(url string) (protoreflect.MessageType, error) {
|
||||
// This function is similar to FindMessageByName but
|
||||
// truncates anything before and including '/' in the URL.
|
||||
message := protoreflect.FullName(url)
|
||||
if i := strings.LastIndexByte(url, '/'); i >= 0 {
|
||||
message = message[i+len("/"):]
|
||||
}
|
||||
return t.FindMessageByName(message)
|
||||
}
|
||||
|
||||
func (t *Types) updateExtensions() {
|
||||
t.extMu.Lock()
|
||||
defer t.extMu.Unlock()
|
||||
if atomic.LoadUint64(&t.atomicExtFiles) == uint64(t.files.NumFiles()) {
|
||||
return
|
||||
}
|
||||
defer atomic.StoreUint64(&t.atomicExtFiles, uint64(t.files.NumFiles()))
|
||||
t.files.RangeFiles(func(fd protoreflect.FileDescriptor) bool {
|
||||
t.registerExtensions(fd.Extensions())
|
||||
t.registerExtensionsInMessages(fd.Messages())
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
func (t *Types) registerExtensionsInMessages(mds protoreflect.MessageDescriptors) {
|
||||
count := mds.Len()
|
||||
for i := 0; i < count; i++ {
|
||||
md := mds.Get(i)
|
||||
t.registerExtensions(md.Extensions())
|
||||
t.registerExtensionsInMessages(md.Messages())
|
||||
}
|
||||
}
|
||||
|
||||
func (t *Types) registerExtensions(xds protoreflect.ExtensionDescriptors) {
|
||||
count := xds.Len()
|
||||
for i := 0; i < count; i++ {
|
||||
xd := xds.Get(i)
|
||||
field := xd.Number()
|
||||
message := xd.ContainingMessage().FullName()
|
||||
if t.extensionsByMessage == nil {
|
||||
t.extensionsByMessage = make(map[extField]protoreflect.ExtensionDescriptor)
|
||||
}
|
||||
t.extensionsByMessage[extField{message, field}] = xd
|
||||
}
|
||||
}
|
||||
|
||||
func descName(d protoreflect.Descriptor) string {
|
||||
switch d.(type) {
|
||||
case protoreflect.EnumDescriptor:
|
||||
return "enum"
|
||||
case protoreflect.EnumValueDescriptor:
|
||||
return "enum value"
|
||||
case protoreflect.MessageDescriptor:
|
||||
return "message"
|
||||
case protoreflect.ExtensionDescriptor:
|
||||
return "extension"
|
||||
case protoreflect.ServiceDescriptor:
|
||||
return "service"
|
||||
default:
|
||||
return fmt.Sprintf("%T", d)
|
||||
}
|
||||
}
|
|
@ -142,39 +142,39 @@ import (
|
|||
//
|
||||
// Example 2: Pack and unpack a message in Java.
|
||||
//
|
||||
// Foo foo = ...;
|
||||
// Any any = Any.pack(foo);
|
||||
// ...
|
||||
// if (any.is(Foo.class)) {
|
||||
// foo = any.unpack(Foo.class);
|
||||
// }
|
||||
// // or ...
|
||||
// if (any.isSameTypeAs(Foo.getDefaultInstance())) {
|
||||
// foo = any.unpack(Foo.getDefaultInstance());
|
||||
// }
|
||||
// Foo foo = ...;
|
||||
// Any any = Any.pack(foo);
|
||||
// ...
|
||||
// if (any.is(Foo.class)) {
|
||||
// foo = any.unpack(Foo.class);
|
||||
// }
|
||||
// // or ...
|
||||
// if (any.isSameTypeAs(Foo.getDefaultInstance())) {
|
||||
// foo = any.unpack(Foo.getDefaultInstance());
|
||||
// }
|
||||
//
|
||||
// Example 3: Pack and unpack a message in Python.
|
||||
// Example 3: Pack and unpack a message in Python.
|
||||
//
|
||||
// foo = Foo(...)
|
||||
// any = Any()
|
||||
// any.Pack(foo)
|
||||
// ...
|
||||
// if any.Is(Foo.DESCRIPTOR):
|
||||
// any.Unpack(foo)
|
||||
// ...
|
||||
// foo = Foo(...)
|
||||
// any = Any()
|
||||
// any.Pack(foo)
|
||||
// ...
|
||||
// if any.Is(Foo.DESCRIPTOR):
|
||||
// any.Unpack(foo)
|
||||
// ...
|
||||
//
|
||||
// Example 4: Pack and unpack a message in Go
|
||||
// Example 4: Pack and unpack a message in Go
|
||||
//
|
||||
// foo := &pb.Foo{...}
|
||||
// any, err := anypb.New(foo)
|
||||
// if err != nil {
|
||||
// ...
|
||||
// }
|
||||
// ...
|
||||
// foo := &pb.Foo{}
|
||||
// if err := any.UnmarshalTo(foo); err != nil {
|
||||
// ...
|
||||
// }
|
||||
// foo := &pb.Foo{...}
|
||||
// any, err := anypb.New(foo)
|
||||
// if err != nil {
|
||||
// ...
|
||||
// }
|
||||
// ...
|
||||
// foo := &pb.Foo{}
|
||||
// if err := any.UnmarshalTo(foo); err != nil {
|
||||
// ...
|
||||
// }
|
||||
//
|
||||
// The pack methods provided by protobuf library will by default use
|
||||
// 'type.googleapis.com/full.type.name' as the type URL and the unpack
|
||||
|
@ -182,8 +182,8 @@ import (
|
|||
// in the type URL, for example "foo.bar.com/x/y.z" will yield type
|
||||
// name "y.z".
|
||||
//
|
||||
// # JSON
|
||||
//
|
||||
// JSON
|
||||
// ====
|
||||
// The JSON representation of an `Any` value uses the regular
|
||||
// representation of the deserialized, embedded message, with an
|
||||
// additional field `@type` which contains the type URL. Example:
|
||||
|
|
|
@ -132,7 +132,7 @@ import (
|
|||
// `NullValue` is a singleton enumeration to represent the null value for the
|
||||
// `Value` type union.
|
||||
//
|
||||
// The JSON representation for `NullValue` is JSON `null`.
|
||||
// The JSON representation for `NullValue` is JSON `null`.
|
||||
type NullValue int32
|
||||
|
||||
const (
|
||||
|
|
|
@ -167,7 +167,7 @@ import (
|
|||
// [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
|
||||
// the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
|
||||
// the Joda Time's [`ISODateTimeFormat.dateTime()`](
|
||||
// http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D
|
||||
// http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()
|
||||
// ) to obtain a formatter capable of generating timestamps in this format.
|
||||
type Timestamp struct {
|
||||
state protoimpl.MessageState
|
||||
|
|
|
@ -905,7 +905,7 @@ google.golang.org/grpc/serviceconfig
|
|||
google.golang.org/grpc/stats
|
||||
google.golang.org/grpc/status
|
||||
google.golang.org/grpc/tap
|
||||
# google.golang.org/protobuf v1.30.0
|
||||
# google.golang.org/protobuf v1.31.0
|
||||
## explicit; go 1.11
|
||||
google.golang.org/protobuf/cmd/protoc-gen-go/internal_gengo
|
||||
google.golang.org/protobuf/compiler/protogen
|
||||
|
|
Loading…
Reference in New Issue