diff options
Diffstat (limited to 'vendor/google.golang.org/protobuf/reflect')
5 files changed, 186 insertions, 4 deletions
| diff --git a/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go b/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go index b03c1223c..54ce326df 100644 --- a/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go +++ b/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go @@ -35,6 +35,8 @@ func (p *SourcePath) appendFileDescriptorProto(b []byte) []byte {  		b = p.appendSingularField(b, "source_code_info", (*SourcePath).appendSourceCodeInfo)  	case 12:  		b = p.appendSingularField(b, "syntax", nil) +	case 13: +		b = p.appendSingularField(b, "edition", nil)  	}  	return b  } @@ -236,6 +238,8 @@ func (p *SourcePath) appendMessageOptions(b []byte) []byte {  		b = p.appendSingularField(b, "deprecated", nil)  	case 7:  		b = p.appendSingularField(b, "map_entry", nil) +	case 11: +		b = p.appendSingularField(b, "deprecated_legacy_json_field_conflicts", nil)  	case 999:  		b = p.appendRepeatedField(b, "uninterpreted_option", (*SourcePath).appendUninterpretedOption)  	} @@ -279,6 +283,8 @@ func (p *SourcePath) appendEnumOptions(b []byte) []byte {  		b = p.appendSingularField(b, "allow_alias", nil)  	case 3:  		b = p.appendSingularField(b, "deprecated", nil) +	case 6: +		b = p.appendSingularField(b, "deprecated_legacy_json_field_conflicts", nil)  	case 999:  		b = p.appendRepeatedField(b, "uninterpreted_option", (*SourcePath).appendUninterpretedOption)  	} @@ -345,10 +351,18 @@ func (p *SourcePath) appendFieldOptions(b []byte) []byte {  		b = p.appendSingularField(b, "jstype", nil)  	case 5:  		b = p.appendSingularField(b, "lazy", nil) +	case 15: +		b = p.appendSingularField(b, "unverified_lazy", nil)  	case 3:  		b = p.appendSingularField(b, "deprecated", nil)  	case 10:  		b = p.appendSingularField(b, "weak", nil) +	case 16: +		b = p.appendSingularField(b, "debug_redact", nil) +	case 17: +		b = p.appendSingularField(b, "retention", nil) +	case 18: +		b = p.appendSingularField(b, "target", nil)  	case 999:  		b = p.appendRepeatedField(b, "uninterpreted_option", (*SourcePath).appendUninterpretedOption)  	} diff --git a/vendor/google.golang.org/protobuf/reflect/protoreflect/value.go b/vendor/google.golang.org/protobuf/reflect/protoreflect/value.go index f31981077..37601b781 100644 --- a/vendor/google.golang.org/protobuf/reflect/protoreflect/value.go +++ b/vendor/google.golang.org/protobuf/reflect/protoreflect/value.go @@ -148,7 +148,7 @@ type Message interface {  	// be preserved in marshaling or other operations.  	IsValid() bool -	// ProtoMethods returns optional fast-path implementions of various operations. +	// ProtoMethods returns optional fast-path implementations of various operations.  	// This method may return nil.  	//  	// The returned methods type is identical to diff --git a/vendor/google.golang.org/protobuf/reflect/protoreflect/value_equal.go b/vendor/google.golang.org/protobuf/reflect/protoreflect/value_equal.go new file mode 100644 index 000000000..591652541 --- /dev/null +++ b/vendor/google.golang.org/protobuf/reflect/protoreflect/value_equal.go @@ -0,0 +1,168 @@ +// Copyright 2022 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 protoreflect + +import ( +	"bytes" +	"fmt" +	"math" +	"reflect" + +	"google.golang.org/protobuf/encoding/protowire" +) + +// Equal reports whether v1 and v2 are recursively equal. +// +//   - Values of different types are always unequal. +// +//   - Bytes values are equal if they contain identical bytes. +//     Empty bytes (regardless of nil-ness) are considered equal. +// +//   - Floating point values are equal if they contain the same value. +//     Unlike the == operator, a NaN is equal to another NaN. +// +//   - Enums are equal if they contain the same number. +//     Since Value does not contain an enum descriptor, +//     enum values do not consider the type of the enum. +// +//   - Other scalar values are equal if they contain the same value. +// +//   - Message values are equal if they belong to the same message descriptor, +//     have the same set of populated known and extension field values, +//     and the same set of unknown fields values. +// +//   - Lists are equal if they are the same length and +//     each corresponding element is equal. +// +//   - Maps are equal if they have the same set of keys and +//     the corresponding value for each key is equal. +func (v1 Value) Equal(v2 Value) bool { +	return equalValue(v1, v2) +} + +func equalValue(x, y Value) bool { +	eqType := x.typ == y.typ +	switch x.typ { +	case nilType: +		return eqType +	case boolType: +		return eqType && x.Bool() == y.Bool() +	case int32Type, int64Type: +		return eqType && x.Int() == y.Int() +	case uint32Type, uint64Type: +		return eqType && x.Uint() == y.Uint() +	case float32Type, float64Type: +		return eqType && equalFloat(x.Float(), y.Float()) +	case stringType: +		return eqType && x.String() == y.String() +	case bytesType: +		return eqType && bytes.Equal(x.Bytes(), y.Bytes()) +	case enumType: +		return eqType && x.Enum() == y.Enum() +	default: +		switch x := x.Interface().(type) { +		case Message: +			y, ok := y.Interface().(Message) +			return ok && equalMessage(x, y) +		case List: +			y, ok := y.Interface().(List) +			return ok && equalList(x, y) +		case Map: +			y, ok := y.Interface().(Map) +			return ok && equalMap(x, y) +		default: +			panic(fmt.Sprintf("unknown type: %T", x)) +		} +	} +} + +// equalFloat compares two floats, where NaNs are treated as equal. +func equalFloat(x, y float64) bool { +	if math.IsNaN(x) || math.IsNaN(y) { +		return math.IsNaN(x) && math.IsNaN(y) +	} +	return x == y +} + +// equalMessage compares two messages. +func equalMessage(mx, my Message) bool { +	if mx.Descriptor() != my.Descriptor() { +		return false +	} + +	nx := 0 +	equal := true +	mx.Range(func(fd FieldDescriptor, vx Value) bool { +		nx++ +		vy := my.Get(fd) +		equal = my.Has(fd) && equalValue(vx, vy) +		return equal +	}) +	if !equal { +		return false +	} +	ny := 0 +	my.Range(func(fd FieldDescriptor, vx Value) bool { +		ny++ +		return true +	}) +	if nx != ny { +		return false +	} + +	return equalUnknown(mx.GetUnknown(), my.GetUnknown()) +} + +// equalList compares two lists. +func equalList(x, y List) bool { +	if x.Len() != y.Len() { +		return false +	} +	for i := x.Len() - 1; i >= 0; i-- { +		if !equalValue(x.Get(i), y.Get(i)) { +			return false +		} +	} +	return true +} + +// equalMap compares two maps. +func equalMap(x, y Map) bool { +	if x.Len() != y.Len() { +		return false +	} +	equal := true +	x.Range(func(k MapKey, vx Value) bool { +		vy := y.Get(k) +		equal = y.Has(k) && equalValue(vx, vy) +		return equal +	}) +	return equal +} + +// equalUnknown compares unknown fields by direct comparison on the raw bytes +// of each individual field number. +func equalUnknown(x, y RawFields) bool { +	if len(x) != len(y) { +		return false +	} +	if bytes.Equal([]byte(x), []byte(y)) { +		return true +	} + +	mx := make(map[FieldNumber]RawFields) +	my := make(map[FieldNumber]RawFields) +	for len(x) > 0 { +		fnum, _, n := protowire.ConsumeField(x) +		mx[fnum] = append(mx[fnum], x[:n]...) +		x = x[n:] +	} +	for len(y) > 0 { +		fnum, _, n := protowire.ConsumeField(y) +		my[fnum] = append(my[fnum], y[:n]...) +		y = y[n:] +	} +	return reflect.DeepEqual(mx, my) +} diff --git a/vendor/google.golang.org/protobuf/reflect/protoreflect/value_union.go b/vendor/google.golang.org/protobuf/reflect/protoreflect/value_union.go index ca8e28c5b..08e5ef73f 100644 --- a/vendor/google.golang.org/protobuf/reflect/protoreflect/value_union.go +++ b/vendor/google.golang.org/protobuf/reflect/protoreflect/value_union.go @@ -54,11 +54,11 @@ import (  //	// Append a 0 to a "repeated int32" field.  //	// Since the Value returned by Mutable is guaranteed to alias  //	// the source message, modifying the Value modifies the message. -//	message.Mutable(fieldDesc).(List).Append(protoreflect.ValueOfInt32(0)) +//	message.Mutable(fieldDesc).List().Append(protoreflect.ValueOfInt32(0))  //  //	// Assign [0] to a "repeated int32" field by creating a new Value,  //	// modifying it, and assigning it. -//	list := message.NewField(fieldDesc).(List) +//	list := message.NewField(fieldDesc).List()  //	list.Append(protoreflect.ValueOfInt32(0))  //	message.Set(fieldDesc, list)  //	// ERROR: Since it is not defined whether Set aliases the source, diff --git a/vendor/google.golang.org/protobuf/reflect/protoregistry/registry.go b/vendor/google.golang.org/protobuf/reflect/protoregistry/registry.go index 58352a697..aeb559774 100644 --- a/vendor/google.golang.org/protobuf/reflect/protoregistry/registry.go +++ b/vendor/google.golang.org/protobuf/reflect/protoregistry/registry.go @@ -46,7 +46,7 @@ var conflictPolicy = "panic" // "panic" | "warn" | "ignore"  // It is a variable so that the behavior is easily overridden in another file.  var ignoreConflict = func(d protoreflect.Descriptor, err error) bool {  	const env = "GOLANG_PROTOBUF_REGISTRATION_CONFLICT" -	const faq = "https://developers.google.com/protocol-buffers/docs/reference/go/faq#namespace-conflict" +	const faq = "https://protobuf.dev/reference/go/faq#namespace-conflict"  	policy := conflictPolicy  	if v := os.Getenv(env); v != "" {  		policy = v | 
