go.mod: runc v1.0.0
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
		 Akihiro Suda
					Akihiro Suda
				
			
				
					committed by
					
						 Davanum Srinivas
						Davanum Srinivas
					
				
			
			
				
	
			
			
			 Davanum Srinivas
						Davanum Srinivas
					
				
			
						parent
						
							28bb59c080
						
					
				
				
					commit
					f913a42755
				
			
							
								
								
									
										2
									
								
								vendor/google.golang.org/protobuf/internal/impl/api_export.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/google.golang.org/protobuf/internal/impl/api_export.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -167,7 +167,7 @@ func (Export) MessageTypeOf(m message) pref.MessageType { | ||||
| 	if mv := (Export{}).protoMessageV2Of(m); mv != nil { | ||||
| 		return mv.ProtoReflect().Type() | ||||
| 	} | ||||
| 	return legacyLoadMessageInfo(reflect.TypeOf(m), "") | ||||
| 	return legacyLoadMessageType(reflect.TypeOf(m), "") | ||||
| } | ||||
|  | ||||
| // MessageStringOf returns the message value as a string, | ||||
|   | ||||
							
								
								
									
										18
									
								
								vendor/google.golang.org/protobuf/internal/impl/codec_field.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										18
									
								
								vendor/google.golang.org/protobuf/internal/impl/codec_field.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -10,6 +10,7 @@ import ( | ||||
| 	"sync" | ||||
|  | ||||
| 	"google.golang.org/protobuf/encoding/protowire" | ||||
| 	"google.golang.org/protobuf/internal/errors" | ||||
| 	"google.golang.org/protobuf/proto" | ||||
| 	pref "google.golang.org/protobuf/reflect/protoreflect" | ||||
| 	preg "google.golang.org/protobuf/reflect/protoregistry" | ||||
| @@ -20,6 +21,7 @@ type errInvalidUTF8 struct{} | ||||
|  | ||||
| func (errInvalidUTF8) Error() string     { return "string field contains invalid UTF-8" } | ||||
| func (errInvalidUTF8) InvalidUTF8() bool { return true } | ||||
| func (errInvalidUTF8) Unwrap() error     { return errors.Error } | ||||
|  | ||||
| // initOneofFieldCoders initializes the fast-path functions for the fields in a oneof. | ||||
| // | ||||
| @@ -242,7 +244,7 @@ func consumeMessageInfo(b []byte, p pointer, wtyp protowire.Type, f *coderFieldI | ||||
| 	} | ||||
| 	v, n := protowire.ConsumeBytes(b) | ||||
| 	if n < 0 { | ||||
| 		return out, protowire.ParseError(n) | ||||
| 		return out, errDecode | ||||
| 	} | ||||
| 	if p.Elem().IsNil() { | ||||
| 		p.SetPointer(pointerOfValue(reflect.New(f.mi.GoReflectType.Elem()))) | ||||
| @@ -276,7 +278,7 @@ func consumeMessage(b []byte, m proto.Message, wtyp protowire.Type, opts unmarsh | ||||
| 	} | ||||
| 	v, n := protowire.ConsumeBytes(b) | ||||
| 	if n < 0 { | ||||
| 		return out, protowire.ParseError(n) | ||||
| 		return out, errDecode | ||||
| 	} | ||||
| 	o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{ | ||||
| 		Buf:     v, | ||||
| @@ -420,7 +422,7 @@ func consumeGroup(b []byte, m proto.Message, num protowire.Number, wtyp protowir | ||||
| 	} | ||||
| 	b, n := protowire.ConsumeGroup(num, b) | ||||
| 	if n < 0 { | ||||
| 		return out, protowire.ParseError(n) | ||||
| 		return out, errDecode | ||||
| 	} | ||||
| 	o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{ | ||||
| 		Buf:     b, | ||||
| @@ -494,7 +496,7 @@ func consumeMessageSliceInfo(b []byte, p pointer, wtyp protowire.Type, f *coderF | ||||
| 	} | ||||
| 	v, n := protowire.ConsumeBytes(b) | ||||
| 	if n < 0 { | ||||
| 		return out, protowire.ParseError(n) | ||||
| 		return out, errDecode | ||||
| 	} | ||||
| 	m := reflect.New(f.mi.GoReflectType.Elem()).Interface() | ||||
| 	mp := pointerOfIface(m) | ||||
| @@ -550,7 +552,7 @@ func consumeMessageSlice(b []byte, p pointer, goType reflect.Type, wtyp protowir | ||||
| 	} | ||||
| 	v, n := protowire.ConsumeBytes(b) | ||||
| 	if n < 0 { | ||||
| 		return out, protowire.ParseError(n) | ||||
| 		return out, errDecode | ||||
| 	} | ||||
| 	mp := reflect.New(goType.Elem()) | ||||
| 	o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{ | ||||
| @@ -613,7 +615,7 @@ func consumeMessageSliceValue(b []byte, listv pref.Value, _ protowire.Number, wt | ||||
| 	} | ||||
| 	v, n := protowire.ConsumeBytes(b) | ||||
| 	if n < 0 { | ||||
| 		return pref.Value{}, out, protowire.ParseError(n) | ||||
| 		return pref.Value{}, out, errDecode | ||||
| 	} | ||||
| 	m := list.NewElement() | ||||
| 	o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{ | ||||
| @@ -681,7 +683,7 @@ func consumeGroupSliceValue(b []byte, listv pref.Value, num protowire.Number, wt | ||||
| 	} | ||||
| 	b, n := protowire.ConsumeGroup(num, b) | ||||
| 	if n < 0 { | ||||
| 		return pref.Value{}, out, protowire.ParseError(n) | ||||
| 		return pref.Value{}, out, errDecode | ||||
| 	} | ||||
| 	m := list.NewElement() | ||||
| 	o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{ | ||||
| @@ -767,7 +769,7 @@ func consumeGroupSlice(b []byte, p pointer, num protowire.Number, wtyp protowire | ||||
| 	} | ||||
| 	b, n := protowire.ConsumeGroup(num, b) | ||||
| 	if n < 0 { | ||||
| 		return out, protowire.ParseError(n) | ||||
| 		return out, errDecode | ||||
| 	} | ||||
| 	mp := reflect.New(goType.Elem()) | ||||
| 	o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{ | ||||
|   | ||||
							
								
								
									
										974
									
								
								vendor/google.golang.org/protobuf/internal/impl/codec_gen.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										974
									
								
								vendor/google.golang.org/protobuf/internal/impl/codec_gen.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										19
									
								
								vendor/google.golang.org/protobuf/internal/impl/codec_map.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										19
									
								
								vendor/google.golang.org/protobuf/internal/impl/codec_map.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -5,7 +5,6 @@ | ||||
| package impl | ||||
|  | ||||
| import ( | ||||
| 	"errors" | ||||
| 	"reflect" | ||||
| 	"sort" | ||||
|  | ||||
| @@ -118,7 +117,7 @@ func consumeMap(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi *mapInfo | ||||
| 	} | ||||
| 	b, n := protowire.ConsumeBytes(b) | ||||
| 	if n < 0 { | ||||
| 		return out, protowire.ParseError(n) | ||||
| 		return out, errDecode | ||||
| 	} | ||||
| 	var ( | ||||
| 		key = mapi.keyZero | ||||
| @@ -127,10 +126,10 @@ func consumeMap(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi *mapInfo | ||||
| 	for len(b) > 0 { | ||||
| 		num, wtyp, n := protowire.ConsumeTag(b) | ||||
| 		if n < 0 { | ||||
| 			return out, protowire.ParseError(n) | ||||
| 			return out, errDecode | ||||
| 		} | ||||
| 		if num > protowire.MaxValidNumber { | ||||
| 			return out, errors.New("invalid field number") | ||||
| 			return out, errDecode | ||||
| 		} | ||||
| 		b = b[n:] | ||||
| 		err := errUnknown | ||||
| @@ -157,7 +156,7 @@ func consumeMap(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi *mapInfo | ||||
| 		if err == errUnknown { | ||||
| 			n = protowire.ConsumeFieldValue(num, wtyp, b) | ||||
| 			if n < 0 { | ||||
| 				return out, protowire.ParseError(n) | ||||
| 				return out, errDecode | ||||
| 			} | ||||
| 		} else if err != nil { | ||||
| 			return out, err | ||||
| @@ -175,7 +174,7 @@ func consumeMapOfMessage(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi | ||||
| 	} | ||||
| 	b, n := protowire.ConsumeBytes(b) | ||||
| 	if n < 0 { | ||||
| 		return out, protowire.ParseError(n) | ||||
| 		return out, errDecode | ||||
| 	} | ||||
| 	var ( | ||||
| 		key = mapi.keyZero | ||||
| @@ -184,10 +183,10 @@ func consumeMapOfMessage(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi | ||||
| 	for len(b) > 0 { | ||||
| 		num, wtyp, n := protowire.ConsumeTag(b) | ||||
| 		if n < 0 { | ||||
| 			return out, protowire.ParseError(n) | ||||
| 			return out, errDecode | ||||
| 		} | ||||
| 		if num > protowire.MaxValidNumber { | ||||
| 			return out, errors.New("invalid field number") | ||||
| 			return out, errDecode | ||||
| 		} | ||||
| 		b = b[n:] | ||||
| 		err := errUnknown | ||||
| @@ -208,7 +207,7 @@ func consumeMapOfMessage(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi | ||||
| 			var v []byte | ||||
| 			v, n = protowire.ConsumeBytes(b) | ||||
| 			if n < 0 { | ||||
| 				return out, protowire.ParseError(n) | ||||
| 				return out, errDecode | ||||
| 			} | ||||
| 			var o unmarshalOutput | ||||
| 			o, err = f.mi.unmarshalPointer(v, pointerOfValue(val), 0, opts) | ||||
| @@ -221,7 +220,7 @@ func consumeMapOfMessage(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi | ||||
| 		if err == errUnknown { | ||||
| 			n = protowire.ConsumeFieldValue(num, wtyp, b) | ||||
| 			if n < 0 { | ||||
| 				return out, protowire.ParseError(n) | ||||
| 				return out, errDecode | ||||
| 			} | ||||
| 		} else if err != nil { | ||||
| 			return out, err | ||||
|   | ||||
							
								
								
									
										68
									
								
								vendor/google.golang.org/protobuf/internal/impl/codec_message.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										68
									
								
								vendor/google.golang.org/protobuf/internal/impl/codec_message.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -11,7 +11,7 @@ import ( | ||||
|  | ||||
| 	"google.golang.org/protobuf/encoding/protowire" | ||||
| 	"google.golang.org/protobuf/internal/encoding/messageset" | ||||
| 	"google.golang.org/protobuf/internal/fieldsort" | ||||
| 	"google.golang.org/protobuf/internal/order" | ||||
| 	pref "google.golang.org/protobuf/reflect/protoreflect" | ||||
| 	piface "google.golang.org/protobuf/runtime/protoiface" | ||||
| ) | ||||
| @@ -27,6 +27,7 @@ type coderMessageInfo struct { | ||||
| 	coderFields        map[protowire.Number]*coderFieldInfo | ||||
| 	sizecacheOffset    offset | ||||
| 	unknownOffset      offset | ||||
| 	unknownPtrKind     bool | ||||
| 	extensionOffset    offset | ||||
| 	needsInitCheck     bool | ||||
| 	isMessageSet       bool | ||||
| @@ -47,9 +48,20 @@ type coderFieldInfo struct { | ||||
| } | ||||
|  | ||||
| func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) { | ||||
| 	mi.sizecacheOffset = si.sizecacheOffset | ||||
| 	mi.unknownOffset = si.unknownOffset | ||||
| 	mi.extensionOffset = si.extensionOffset | ||||
| 	mi.sizecacheOffset = invalidOffset | ||||
| 	mi.unknownOffset = invalidOffset | ||||
| 	mi.extensionOffset = invalidOffset | ||||
|  | ||||
| 	if si.sizecacheOffset.IsValid() && si.sizecacheType == sizecacheType { | ||||
| 		mi.sizecacheOffset = si.sizecacheOffset | ||||
| 	} | ||||
| 	if si.unknownOffset.IsValid() && (si.unknownType == unknownFieldsAType || si.unknownType == unknownFieldsBType) { | ||||
| 		mi.unknownOffset = si.unknownOffset | ||||
| 		mi.unknownPtrKind = si.unknownType.Kind() == reflect.Ptr | ||||
| 	} | ||||
| 	if si.extensionOffset.IsValid() && si.extensionType == extensionFieldsType { | ||||
| 		mi.extensionOffset = si.extensionOffset | ||||
| 	} | ||||
|  | ||||
| 	mi.coderFields = make(map[protowire.Number]*coderFieldInfo) | ||||
| 	fields := mi.Desc.Fields() | ||||
| @@ -73,6 +85,27 @@ func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) { | ||||
| 		var funcs pointerCoderFuncs | ||||
| 		var childMessage *MessageInfo | ||||
| 		switch { | ||||
| 		case ft == nil: | ||||
| 			// This never occurs for generated message types. | ||||
| 			// It implies that a hand-crafted type has missing Go fields | ||||
| 			// for specific protobuf message fields. | ||||
| 			funcs = pointerCoderFuncs{ | ||||
| 				size: func(p pointer, f *coderFieldInfo, opts marshalOptions) int { | ||||
| 					return 0 | ||||
| 				}, | ||||
| 				marshal: func(b []byte, p pointer, f *coderFieldInfo, opts marshalOptions) ([]byte, error) { | ||||
| 					return nil, nil | ||||
| 				}, | ||||
| 				unmarshal: func(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, opts unmarshalOptions) (unmarshalOutput, error) { | ||||
| 					panic("missing Go struct field for " + string(fd.FullName())) | ||||
| 				}, | ||||
| 				isInit: func(p pointer, f *coderFieldInfo) error { | ||||
| 					panic("missing Go struct field for " + string(fd.FullName())) | ||||
| 				}, | ||||
| 				merge: func(dst, src pointer, f *coderFieldInfo, opts mergeOptions) { | ||||
| 					panic("missing Go struct field for " + string(fd.FullName())) | ||||
| 				}, | ||||
| 			} | ||||
| 		case isOneof: | ||||
| 			fieldOffset = offsetOf(fs, mi.Exporter) | ||||
| 		case fd.IsWeak(): | ||||
| @@ -136,7 +169,7 @@ func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) { | ||||
| 		sort.Slice(mi.orderedCoderFields, func(i, j int) bool { | ||||
| 			fi := fields.ByNumber(mi.orderedCoderFields[i].num) | ||||
| 			fj := fields.ByNumber(mi.orderedCoderFields[j].num) | ||||
| 			return fieldsort.Less(fi, fj) | ||||
| 			return order.LegacyFieldOrder(fi, fj) | ||||
| 		}) | ||||
| 	} | ||||
|  | ||||
| @@ -157,3 +190,28 @@ func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) { | ||||
| 		mi.methods.Merge = mi.merge | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // getUnknownBytes returns a *[]byte for the unknown fields. | ||||
| // It is the caller's responsibility to check whether the pointer is nil. | ||||
| // This function is specially designed to be inlineable. | ||||
| func (mi *MessageInfo) getUnknownBytes(p pointer) *[]byte { | ||||
| 	if mi.unknownPtrKind { | ||||
| 		return *p.Apply(mi.unknownOffset).BytesPtr() | ||||
| 	} else { | ||||
| 		return p.Apply(mi.unknownOffset).Bytes() | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // mutableUnknownBytes returns a *[]byte for the unknown fields. | ||||
| // The returned pointer is guaranteed to not be nil. | ||||
| func (mi *MessageInfo) mutableUnknownBytes(p pointer) *[]byte { | ||||
| 	if mi.unknownPtrKind { | ||||
| 		bp := p.Apply(mi.unknownOffset).BytesPtr() | ||||
| 		if *bp == nil { | ||||
| 			*bp = new([]byte) | ||||
| 		} | ||||
| 		return *bp | ||||
| 	} else { | ||||
| 		return p.Apply(mi.unknownOffset).Bytes() | ||||
| 	} | ||||
| } | ||||
|   | ||||
							
								
								
									
										21
									
								
								vendor/google.golang.org/protobuf/internal/impl/codec_messageset.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										21
									
								
								vendor/google.golang.org/protobuf/internal/impl/codec_messageset.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -29,8 +29,9 @@ func sizeMessageSet(mi *MessageInfo, p pointer, opts marshalOptions) (size int) | ||||
| 		size += xi.funcs.size(x.Value(), protowire.SizeTag(messageset.FieldMessage), opts) | ||||
| 	} | ||||
|  | ||||
| 	unknown := *p.Apply(mi.unknownOffset).Bytes() | ||||
| 	size += messageset.SizeUnknown(unknown) | ||||
| 	if u := mi.getUnknownBytes(p); u != nil { | ||||
| 		size += messageset.SizeUnknown(*u) | ||||
| 	} | ||||
|  | ||||
| 	return size | ||||
| } | ||||
| @@ -69,10 +70,12 @@ func marshalMessageSet(mi *MessageInfo, b []byte, p pointer, opts marshalOptions | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	unknown := *p.Apply(mi.unknownOffset).Bytes() | ||||
| 	b, err := messageset.AppendUnknown(b, unknown) | ||||
| 	if err != nil { | ||||
| 		return b, err | ||||
| 	if u := mi.getUnknownBytes(p); u != nil { | ||||
| 		var err error | ||||
| 		b, err = messageset.AppendUnknown(b, *u) | ||||
| 		if err != nil { | ||||
| 			return b, err | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return b, nil | ||||
| @@ -100,13 +103,13 @@ func unmarshalMessageSet(mi *MessageInfo, b []byte, p pointer, opts unmarshalOpt | ||||
| 		*ep = make(map[int32]ExtensionField) | ||||
| 	} | ||||
| 	ext := *ep | ||||
| 	unknown := p.Apply(mi.unknownOffset).Bytes() | ||||
| 	initialized := true | ||||
| 	err = messageset.Unmarshal(b, true, func(num protowire.Number, v []byte) error { | ||||
| 		o, err := mi.unmarshalExtension(v, num, protowire.BytesType, ext, opts) | ||||
| 		if err == errUnknown { | ||||
| 			*unknown = protowire.AppendTag(*unknown, num, protowire.BytesType) | ||||
| 			*unknown = append(*unknown, v...) | ||||
| 			u := mi.mutableUnknownBytes(p) | ||||
| 			*u = protowire.AppendTag(*u, num, protowire.BytesType) | ||||
| 			*u = append(*u, v...) | ||||
| 			return nil | ||||
| 		} | ||||
| 		if !o.initialized { | ||||
|   | ||||
							
								
								
									
										8
									
								
								vendor/google.golang.org/protobuf/internal/impl/codec_reflect.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								vendor/google.golang.org/protobuf/internal/impl/codec_reflect.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -30,7 +30,7 @@ func consumeEnum(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, _ | ||||
| 	} | ||||
| 	v, n := protowire.ConsumeVarint(b) | ||||
| 	if n < 0 { | ||||
| 		return out, protowire.ParseError(n) | ||||
| 		return out, errDecode | ||||
| 	} | ||||
| 	p.v.Elem().SetInt(int64(v)) | ||||
| 	out.n = n | ||||
| @@ -130,12 +130,12 @@ func consumeEnumSlice(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInf | ||||
| 	if wtyp == protowire.BytesType { | ||||
| 		b, n := protowire.ConsumeBytes(b) | ||||
| 		if n < 0 { | ||||
| 			return out, protowire.ParseError(n) | ||||
| 			return out, errDecode | ||||
| 		} | ||||
| 		for len(b) > 0 { | ||||
| 			v, n := protowire.ConsumeVarint(b) | ||||
| 			if n < 0 { | ||||
| 				return out, protowire.ParseError(n) | ||||
| 				return out, errDecode | ||||
| 			} | ||||
| 			rv := reflect.New(s.Type().Elem()).Elem() | ||||
| 			rv.SetInt(int64(v)) | ||||
| @@ -150,7 +150,7 @@ func consumeEnumSlice(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInf | ||||
| 	} | ||||
| 	v, n := protowire.ConsumeVarint(b) | ||||
| 	if n < 0 { | ||||
| 		return out, protowire.ParseError(n) | ||||
| 		return out, errDecode | ||||
| 	} | ||||
| 	rv := reflect.New(s.Type().Elem()).Elem() | ||||
| 	rv.SetInt(int64(v)) | ||||
|   | ||||
							
								
								
									
										29
									
								
								vendor/google.golang.org/protobuf/internal/impl/convert.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										29
									
								
								vendor/google.golang.org/protobuf/internal/impl/convert.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -423,6 +423,13 @@ func (c *messageConverter) PBValueOf(v reflect.Value) pref.Value { | ||||
| 	if v.Type() != c.goType { | ||||
| 		panic(fmt.Sprintf("invalid type: got %v, want %v", v.Type(), c.goType)) | ||||
| 	} | ||||
| 	if c.isNonPointer() { | ||||
| 		if v.CanAddr() { | ||||
| 			v = v.Addr() // T => *T | ||||
| 		} else { | ||||
| 			v = reflect.Zero(reflect.PtrTo(v.Type())) | ||||
| 		} | ||||
| 	} | ||||
| 	if m, ok := v.Interface().(pref.ProtoMessage); ok { | ||||
| 		return pref.ValueOfMessage(m.ProtoReflect()) | ||||
| 	} | ||||
| @@ -437,6 +444,16 @@ func (c *messageConverter) GoValueOf(v pref.Value) reflect.Value { | ||||
| 	} else { | ||||
| 		rv = reflect.ValueOf(m.Interface()) | ||||
| 	} | ||||
| 	if c.isNonPointer() { | ||||
| 		if rv.Type() != reflect.PtrTo(c.goType) { | ||||
| 			panic(fmt.Sprintf("invalid type: got %v, want %v", rv.Type(), reflect.PtrTo(c.goType))) | ||||
| 		} | ||||
| 		if !rv.IsNil() { | ||||
| 			rv = rv.Elem() // *T => T | ||||
| 		} else { | ||||
| 			rv = reflect.Zero(rv.Type().Elem()) | ||||
| 		} | ||||
| 	} | ||||
| 	if rv.Type() != c.goType { | ||||
| 		panic(fmt.Sprintf("invalid type: got %v, want %v", rv.Type(), c.goType)) | ||||
| 	} | ||||
| @@ -451,6 +468,9 @@ func (c *messageConverter) IsValidPB(v pref.Value) bool { | ||||
| 	} else { | ||||
| 		rv = reflect.ValueOf(m.Interface()) | ||||
| 	} | ||||
| 	if c.isNonPointer() { | ||||
| 		return rv.Type() == reflect.PtrTo(c.goType) | ||||
| 	} | ||||
| 	return rv.Type() == c.goType | ||||
| } | ||||
|  | ||||
| @@ -459,9 +479,18 @@ func (c *messageConverter) IsValidGo(v reflect.Value) bool { | ||||
| } | ||||
|  | ||||
| func (c *messageConverter) New() pref.Value { | ||||
| 	if c.isNonPointer() { | ||||
| 		return c.PBValueOf(reflect.New(c.goType).Elem()) | ||||
| 	} | ||||
| 	return c.PBValueOf(reflect.New(c.goType.Elem())) | ||||
| } | ||||
|  | ||||
| func (c *messageConverter) Zero() pref.Value { | ||||
| 	return c.PBValueOf(reflect.Zero(c.goType)) | ||||
| } | ||||
|  | ||||
| // isNonPointer reports whether the type is a non-pointer type. | ||||
| // This never occurs for generated message types. | ||||
| func (c *messageConverter) isNonPointer() bool { | ||||
| 	return c.goType.Kind() != reflect.Ptr | ||||
| } | ||||
|   | ||||
							
								
								
									
										16
									
								
								vendor/google.golang.org/protobuf/internal/impl/decode.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										16
									
								
								vendor/google.golang.org/protobuf/internal/impl/decode.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -17,6 +17,8 @@ import ( | ||||
| 	piface "google.golang.org/protobuf/runtime/protoiface" | ||||
| ) | ||||
|  | ||||
| var errDecode = errors.New("cannot parse invalid wire-format data") | ||||
|  | ||||
| type unmarshalOptions struct { | ||||
| 	flags    protoiface.UnmarshalInputFlags | ||||
| 	resolver interface { | ||||
| @@ -100,13 +102,13 @@ func (mi *MessageInfo) unmarshalPointer(b []byte, p pointer, groupTag protowire. | ||||
| 			var n int | ||||
| 			tag, n = protowire.ConsumeVarint(b) | ||||
| 			if n < 0 { | ||||
| 				return out, protowire.ParseError(n) | ||||
| 				return out, errDecode | ||||
| 			} | ||||
| 			b = b[n:] | ||||
| 		} | ||||
| 		var num protowire.Number | ||||
| 		if n := tag >> 3; n < uint64(protowire.MinValidNumber) || n > uint64(protowire.MaxValidNumber) { | ||||
| 			return out, errors.New("invalid field number") | ||||
| 			return out, errDecode | ||||
| 		} else { | ||||
| 			num = protowire.Number(n) | ||||
| 		} | ||||
| @@ -114,7 +116,7 @@ func (mi *MessageInfo) unmarshalPointer(b []byte, p pointer, groupTag protowire. | ||||
|  | ||||
| 		if wtyp == protowire.EndGroupType { | ||||
| 			if num != groupTag { | ||||
| 				return out, errors.New("mismatching end group marker") | ||||
| 				return out, errDecode | ||||
| 			} | ||||
| 			groupTag = 0 | ||||
| 			break | ||||
| @@ -170,10 +172,10 @@ func (mi *MessageInfo) unmarshalPointer(b []byte, p pointer, groupTag protowire. | ||||
| 			} | ||||
| 			n = protowire.ConsumeFieldValue(num, wtyp, b) | ||||
| 			if n < 0 { | ||||
| 				return out, protowire.ParseError(n) | ||||
| 				return out, errDecode | ||||
| 			} | ||||
| 			if !opts.DiscardUnknown() && mi.unknownOffset.IsValid() { | ||||
| 				u := p.Apply(mi.unknownOffset).Bytes() | ||||
| 				u := mi.mutableUnknownBytes(p) | ||||
| 				*u = protowire.AppendTag(*u, num, wtyp) | ||||
| 				*u = append(*u, b[:n]...) | ||||
| 			} | ||||
| @@ -181,7 +183,7 @@ func (mi *MessageInfo) unmarshalPointer(b []byte, p pointer, groupTag protowire. | ||||
| 		b = b[n:] | ||||
| 	} | ||||
| 	if groupTag != 0 { | ||||
| 		return out, errors.New("missing end group marker") | ||||
| 		return out, errDecode | ||||
| 	} | ||||
| 	if mi.numRequiredFields > 0 && bits.OnesCount64(requiredMask) != int(mi.numRequiredFields) { | ||||
| 		initialized = false | ||||
| @@ -221,7 +223,7 @@ func (mi *MessageInfo) unmarshalExtension(b []byte, num protowire.Number, wtyp p | ||||
| 					return out, nil | ||||
| 				} | ||||
| 			case ValidationInvalid: | ||||
| 				return out, errors.New("invalid wire format") | ||||
| 				return out, errDecode | ||||
| 			case ValidationUnknown: | ||||
| 			} | ||||
| 		} | ||||
|   | ||||
							
								
								
									
										10
									
								
								vendor/google.golang.org/protobuf/internal/impl/encode.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										10
									
								
								vendor/google.golang.org/protobuf/internal/impl/encode.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -79,8 +79,9 @@ func (mi *MessageInfo) sizePointerSlow(p pointer, opts marshalOptions) (size int | ||||
| 		size += f.funcs.size(fptr, f, opts) | ||||
| 	} | ||||
| 	if mi.unknownOffset.IsValid() { | ||||
| 		u := *p.Apply(mi.unknownOffset).Bytes() | ||||
| 		size += len(u) | ||||
| 		if u := mi.getUnknownBytes(p); u != nil { | ||||
| 			size += len(*u) | ||||
| 		} | ||||
| 	} | ||||
| 	if mi.sizecacheOffset.IsValid() { | ||||
| 		if size > math.MaxInt32 { | ||||
| @@ -141,8 +142,9 @@ func (mi *MessageInfo) marshalAppendPointer(b []byte, p pointer, opts marshalOpt | ||||
| 		} | ||||
| 	} | ||||
| 	if mi.unknownOffset.IsValid() && !mi.isMessageSet { | ||||
| 		u := *p.Apply(mi.unknownOffset).Bytes() | ||||
| 		b = append(b, u...) | ||||
| 		if u := mi.getUnknownBytes(p); u != nil { | ||||
| 			b = append(b, (*u)...) | ||||
| 		} | ||||
| 	} | ||||
| 	return b, nil | ||||
| } | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/google.golang.org/protobuf/internal/impl/legacy_export.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/google.golang.org/protobuf/internal/impl/legacy_export.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -30,7 +30,7 @@ func (Export) LegacyMessageTypeOf(m piface.MessageV1, name pref.FullName) pref.M | ||||
| 	if mv := (Export{}).protoMessageV2Of(m); mv != nil { | ||||
| 		return mv.ProtoReflect().Type() | ||||
| 	} | ||||
| 	return legacyLoadMessageInfo(reflect.TypeOf(m), name) | ||||
| 	return legacyLoadMessageType(reflect.TypeOf(m), name) | ||||
| } | ||||
|  | ||||
| // UnmarshalJSONEnum unmarshals an enum from a JSON-encoded input. | ||||
|   | ||||
							
								
								
									
										3
									
								
								vendor/google.golang.org/protobuf/internal/impl/legacy_extension.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/google.golang.org/protobuf/internal/impl/legacy_extension.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -154,7 +154,8 @@ func (x placeholderExtension) Number() pref.FieldNumber                   { retu | ||||
| func (x placeholderExtension) Cardinality() pref.Cardinality              { return 0 } | ||||
| func (x placeholderExtension) Kind() pref.Kind                            { return 0 } | ||||
| func (x placeholderExtension) HasJSONName() bool                          { return false } | ||||
| func (x placeholderExtension) JSONName() string                           { return "" } | ||||
| func (x placeholderExtension) JSONName() string                           { return "[" + string(x.name) + "]" } | ||||
| func (x placeholderExtension) TextName() string                           { return "[" + string(x.name) + "]" } | ||||
| func (x placeholderExtension) HasPresence() bool                          { return false } | ||||
| func (x placeholderExtension) HasOptionalKeyword() bool                   { return false } | ||||
| func (x placeholderExtension) IsExtension() bool                          { return true } | ||||
|   | ||||
							
								
								
									
										122
									
								
								vendor/google.golang.org/protobuf/internal/impl/legacy_message.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										122
									
								
								vendor/google.golang.org/protobuf/internal/impl/legacy_message.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -24,14 +24,24 @@ import ( | ||||
| // legacyWrapMessage wraps v as a protoreflect.Message, | ||||
| // where v must be a *struct kind and not implement the v2 API already. | ||||
| func legacyWrapMessage(v reflect.Value) pref.Message { | ||||
| 	typ := v.Type() | ||||
| 	if typ.Kind() != reflect.Ptr || typ.Elem().Kind() != reflect.Struct { | ||||
| 	t := v.Type() | ||||
| 	if t.Kind() != reflect.Ptr || t.Elem().Kind() != reflect.Struct { | ||||
| 		return aberrantMessage{v: v} | ||||
| 	} | ||||
| 	mt := legacyLoadMessageInfo(typ, "") | ||||
| 	mt := legacyLoadMessageInfo(t, "") | ||||
| 	return mt.MessageOf(v.Interface()) | ||||
| } | ||||
|  | ||||
| // legacyLoadMessageType dynamically loads a protoreflect.Type for t, | ||||
| // where t must be not implement the v2 API already. | ||||
| // The provided name is used if it cannot be determined from the message. | ||||
| func legacyLoadMessageType(t reflect.Type, name pref.FullName) protoreflect.MessageType { | ||||
| 	if t.Kind() != reflect.Ptr || t.Elem().Kind() != reflect.Struct { | ||||
| 		return aberrantMessageType{t} | ||||
| 	} | ||||
| 	return legacyLoadMessageInfo(t, name) | ||||
| } | ||||
|  | ||||
| var legacyMessageTypeCache sync.Map // map[reflect.Type]*MessageInfo | ||||
|  | ||||
| // legacyLoadMessageInfo dynamically loads a *MessageInfo for t, | ||||
| @@ -49,8 +59,9 @@ func legacyLoadMessageInfo(t reflect.Type, name pref.FullName) *MessageInfo { | ||||
| 		GoReflectType: t, | ||||
| 	} | ||||
|  | ||||
| 	var hasMarshal, hasUnmarshal bool | ||||
| 	v := reflect.Zero(t).Interface() | ||||
| 	if _, ok := v.(legacyMarshaler); ok { | ||||
| 	if _, hasMarshal = v.(legacyMarshaler); hasMarshal { | ||||
| 		mi.methods.Marshal = legacyMarshal | ||||
|  | ||||
| 		// We have no way to tell whether the type's Marshal method | ||||
| @@ -59,10 +70,10 @@ func legacyLoadMessageInfo(t reflect.Type, name pref.FullName) *MessageInfo { | ||||
| 		// calling Marshal methods when present. | ||||
| 		mi.methods.Flags |= piface.SupportMarshalDeterministic | ||||
| 	} | ||||
| 	if _, ok := v.(legacyUnmarshaler); ok { | ||||
| 	if _, hasUnmarshal = v.(legacyUnmarshaler); hasUnmarshal { | ||||
| 		mi.methods.Unmarshal = legacyUnmarshal | ||||
| 	} | ||||
| 	if _, ok := v.(legacyMerger); ok { | ||||
| 	if _, hasMerge := v.(legacyMerger); hasMerge || (hasMarshal && hasUnmarshal) { | ||||
| 		mi.methods.Merge = legacyMerge | ||||
| 	} | ||||
|  | ||||
| @@ -75,7 +86,7 @@ func legacyLoadMessageInfo(t reflect.Type, name pref.FullName) *MessageInfo { | ||||
| var legacyMessageDescCache sync.Map // map[reflect.Type]protoreflect.MessageDescriptor | ||||
|  | ||||
| // LegacyLoadMessageDesc returns an MessageDescriptor derived from the Go type, | ||||
| // which must be a *struct kind and not implement the v2 API already. | ||||
| // which should be a *struct kind and must not implement the v2 API already. | ||||
| // | ||||
| // This is exported for testing purposes. | ||||
| func LegacyLoadMessageDesc(t reflect.Type) pref.MessageDescriptor { | ||||
| @@ -114,17 +125,19 @@ func legacyLoadMessageDesc(t reflect.Type, name pref.FullName) pref.MessageDescr | ||||
| 	// If the Go type has no fields, then this might be a proto3 empty message | ||||
| 	// from before the size cache was added. If there are any fields, check to | ||||
| 	// see that at least one of them looks like something we generated. | ||||
| 	if nfield := t.Elem().NumField(); nfield > 0 { | ||||
| 		hasProtoField := false | ||||
| 		for i := 0; i < nfield; i++ { | ||||
| 			f := t.Elem().Field(i) | ||||
| 			if f.Tag.Get("protobuf") != "" || f.Tag.Get("protobuf_oneof") != "" || strings.HasPrefix(f.Name, "XXX_") { | ||||
| 				hasProtoField = true | ||||
| 				break | ||||
| 	if t.Elem().Kind() == reflect.Struct { | ||||
| 		if nfield := t.Elem().NumField(); nfield > 0 { | ||||
| 			hasProtoField := false | ||||
| 			for i := 0; i < nfield; i++ { | ||||
| 				f := t.Elem().Field(i) | ||||
| 				if f.Tag.Get("protobuf") != "" || f.Tag.Get("protobuf_oneof") != "" || strings.HasPrefix(f.Name, "XXX_") { | ||||
| 					hasProtoField = true | ||||
| 					break | ||||
| 				} | ||||
| 			} | ||||
| 			if !hasProtoField { | ||||
| 				return aberrantLoadMessageDesc(t, name) | ||||
| 			} | ||||
| 		} | ||||
| 		if !hasProtoField { | ||||
| 			return aberrantLoadMessageDesc(t, name) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| @@ -370,7 +383,7 @@ type legacyMerger interface { | ||||
| 	Merge(protoiface.MessageV1) | ||||
| } | ||||
|  | ||||
| var legacyProtoMethods = &piface.Methods{ | ||||
| var aberrantProtoMethods = &piface.Methods{ | ||||
| 	Marshal:   legacyMarshal, | ||||
| 	Unmarshal: legacyUnmarshal, | ||||
| 	Merge:     legacyMerge, | ||||
| @@ -401,18 +414,40 @@ func legacyUnmarshal(in piface.UnmarshalInput) (piface.UnmarshalOutput, error) { | ||||
| 	v := in.Message.(unwrapper).protoUnwrap() | ||||
| 	unmarshaler, ok := v.(legacyUnmarshaler) | ||||
| 	if !ok { | ||||
| 		return piface.UnmarshalOutput{}, errors.New("%T does not implement Marshal", v) | ||||
| 		return piface.UnmarshalOutput{}, errors.New("%T does not implement Unmarshal", v) | ||||
| 	} | ||||
| 	return piface.UnmarshalOutput{}, unmarshaler.Unmarshal(in.Buf) | ||||
| } | ||||
|  | ||||
| func legacyMerge(in piface.MergeInput) piface.MergeOutput { | ||||
| 	// Check whether this supports the legacy merger. | ||||
| 	dstv := in.Destination.(unwrapper).protoUnwrap() | ||||
| 	merger, ok := dstv.(legacyMerger) | ||||
| 	if ok { | ||||
| 		merger.Merge(Export{}.ProtoMessageV1Of(in.Source)) | ||||
| 		return piface.MergeOutput{Flags: piface.MergeComplete} | ||||
| 	} | ||||
|  | ||||
| 	// If legacy merger is unavailable, implement merge in terms of | ||||
| 	// a marshal and unmarshal operation. | ||||
| 	srcv := in.Source.(unwrapper).protoUnwrap() | ||||
| 	marshaler, ok := srcv.(legacyMarshaler) | ||||
| 	if !ok { | ||||
| 		return piface.MergeOutput{} | ||||
| 	} | ||||
| 	merger.Merge(Export{}.ProtoMessageV1Of(in.Source)) | ||||
| 	dstv = in.Destination.(unwrapper).protoUnwrap() | ||||
| 	unmarshaler, ok := dstv.(legacyUnmarshaler) | ||||
| 	if !ok { | ||||
| 		return piface.MergeOutput{} | ||||
| 	} | ||||
| 	b, err := marshaler.Marshal() | ||||
| 	if err != nil { | ||||
| 		return piface.MergeOutput{} | ||||
| 	} | ||||
| 	err = unmarshaler.Unmarshal(b) | ||||
| 	if err != nil { | ||||
| 		return piface.MergeOutput{} | ||||
| 	} | ||||
| 	return piface.MergeOutput{Flags: piface.MergeComplete} | ||||
| } | ||||
|  | ||||
| @@ -422,6 +457,9 @@ type aberrantMessageType struct { | ||||
| } | ||||
|  | ||||
| func (mt aberrantMessageType) New() pref.Message { | ||||
| 	if mt.t.Kind() == reflect.Ptr { | ||||
| 		return aberrantMessage{reflect.New(mt.t.Elem())} | ||||
| 	} | ||||
| 	return aberrantMessage{reflect.Zero(mt.t)} | ||||
| } | ||||
| func (mt aberrantMessageType) Zero() pref.Message { | ||||
| @@ -443,6 +481,17 @@ type aberrantMessage struct { | ||||
| 	v reflect.Value | ||||
| } | ||||
|  | ||||
| // Reset implements the v1 proto.Message.Reset method. | ||||
| func (m aberrantMessage) Reset() { | ||||
| 	if mr, ok := m.v.Interface().(interface{ Reset() }); ok { | ||||
| 		mr.Reset() | ||||
| 		return | ||||
| 	} | ||||
| 	if m.v.Kind() == reflect.Ptr && !m.v.IsNil() { | ||||
| 		m.v.Elem().Set(reflect.Zero(m.v.Type().Elem())) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (m aberrantMessage) ProtoReflect() pref.Message { | ||||
| 	return m | ||||
| } | ||||
| @@ -454,33 +503,40 @@ func (m aberrantMessage) Type() pref.MessageType { | ||||
| 	return aberrantMessageType{m.v.Type()} | ||||
| } | ||||
| func (m aberrantMessage) New() pref.Message { | ||||
| 	if m.v.Type().Kind() == reflect.Ptr { | ||||
| 		return aberrantMessage{reflect.New(m.v.Type().Elem())} | ||||
| 	} | ||||
| 	return aberrantMessage{reflect.Zero(m.v.Type())} | ||||
| } | ||||
| func (m aberrantMessage) Interface() pref.ProtoMessage { | ||||
| 	return m | ||||
| } | ||||
| func (m aberrantMessage) Range(f func(pref.FieldDescriptor, pref.Value) bool) { | ||||
| 	return | ||||
| } | ||||
| func (m aberrantMessage) Has(pref.FieldDescriptor) bool { | ||||
| 	panic("invalid field descriptor") | ||||
| 	return false | ||||
| } | ||||
| func (m aberrantMessage) Clear(pref.FieldDescriptor) { | ||||
| 	panic("invalid field descriptor") | ||||
| 	panic("invalid Message.Clear on " + string(m.Descriptor().FullName())) | ||||
| } | ||||
| func (m aberrantMessage) Get(pref.FieldDescriptor) pref.Value { | ||||
| 	panic("invalid field descriptor") | ||||
| func (m aberrantMessage) Get(fd pref.FieldDescriptor) pref.Value { | ||||
| 	if fd.Default().IsValid() { | ||||
| 		return fd.Default() | ||||
| 	} | ||||
| 	panic("invalid Message.Get on " + string(m.Descriptor().FullName())) | ||||
| } | ||||
| func (m aberrantMessage) Set(pref.FieldDescriptor, pref.Value) { | ||||
| 	panic("invalid field descriptor") | ||||
| 	panic("invalid Message.Set on " + string(m.Descriptor().FullName())) | ||||
| } | ||||
| func (m aberrantMessage) Mutable(pref.FieldDescriptor) pref.Value { | ||||
| 	panic("invalid field descriptor") | ||||
| 	panic("invalid Message.Mutable on " + string(m.Descriptor().FullName())) | ||||
| } | ||||
| func (m aberrantMessage) NewField(pref.FieldDescriptor) pref.Value { | ||||
| 	panic("invalid field descriptor") | ||||
| 	panic("invalid Message.NewField on " + string(m.Descriptor().FullName())) | ||||
| } | ||||
| func (m aberrantMessage) WhichOneof(pref.OneofDescriptor) pref.FieldDescriptor { | ||||
| 	panic("invalid oneof descriptor") | ||||
| 	panic("invalid Message.WhichOneof descriptor on " + string(m.Descriptor().FullName())) | ||||
| } | ||||
| func (m aberrantMessage) GetUnknown() pref.RawFields { | ||||
| 	return nil | ||||
| @@ -489,13 +545,13 @@ func (m aberrantMessage) SetUnknown(pref.RawFields) { | ||||
| 	// SetUnknown discards its input on messages which don't support unknown field storage. | ||||
| } | ||||
| func (m aberrantMessage) IsValid() bool { | ||||
| 	// An invalid message is a read-only, empty message. Since we don't know anything | ||||
| 	// about the alleged contents of this message, we can't say with confidence that | ||||
| 	// it is invalid in this sense. Therefore, report it as valid. | ||||
| 	return true | ||||
| 	if m.v.Kind() == reflect.Ptr { | ||||
| 		return !m.v.IsNil() | ||||
| 	} | ||||
| 	return false | ||||
| } | ||||
| func (m aberrantMessage) ProtoMethods() *piface.Methods { | ||||
| 	return legacyProtoMethods | ||||
| 	return aberrantProtoMethods | ||||
| } | ||||
| func (m aberrantMessage) protoUnwrap() interface{} { | ||||
| 	return m.v.Interface() | ||||
|   | ||||
							
								
								
									
										6
									
								
								vendor/google.golang.org/protobuf/internal/impl/merge.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								vendor/google.golang.org/protobuf/internal/impl/merge.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -77,9 +77,9 @@ func (mi *MessageInfo) mergePointer(dst, src pointer, opts mergeOptions) { | ||||
| 		} | ||||
| 	} | ||||
| 	if mi.unknownOffset.IsValid() { | ||||
| 		du := dst.Apply(mi.unknownOffset).Bytes() | ||||
| 		su := src.Apply(mi.unknownOffset).Bytes() | ||||
| 		if len(*su) > 0 { | ||||
| 		su := mi.getUnknownBytes(src) | ||||
| 		if su != nil && len(*su) > 0 { | ||||
| 			du := mi.mutableUnknownBytes(dst) | ||||
| 			*du = append(*du, *su...) | ||||
| 		} | ||||
| 	} | ||||
|   | ||||
							
								
								
									
										69
									
								
								vendor/google.golang.org/protobuf/internal/impl/message.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										69
									
								
								vendor/google.golang.org/protobuf/internal/impl/message.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -15,6 +15,7 @@ import ( | ||||
| 	"google.golang.org/protobuf/internal/genid" | ||||
| 	"google.golang.org/protobuf/reflect/protoreflect" | ||||
| 	pref "google.golang.org/protobuf/reflect/protoreflect" | ||||
| 	preg "google.golang.org/protobuf/reflect/protoregistry" | ||||
| ) | ||||
|  | ||||
| // MessageInfo provides protobuf related functionality for a given Go type | ||||
| @@ -109,22 +110,29 @@ func (mi *MessageInfo) getPointer(m pref.Message) (p pointer, ok bool) { | ||||
| type ( | ||||
| 	SizeCache       = int32 | ||||
| 	WeakFields      = map[int32]protoreflect.ProtoMessage | ||||
| 	UnknownFields   = []byte | ||||
| 	UnknownFields   = unknownFieldsA // TODO: switch to unknownFieldsB | ||||
| 	unknownFieldsA  = []byte | ||||
| 	unknownFieldsB  = *[]byte | ||||
| 	ExtensionFields = map[int32]ExtensionField | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| 	sizecacheType       = reflect.TypeOf(SizeCache(0)) | ||||
| 	weakFieldsType      = reflect.TypeOf(WeakFields(nil)) | ||||
| 	unknownFieldsType   = reflect.TypeOf(UnknownFields(nil)) | ||||
| 	unknownFieldsAType  = reflect.TypeOf(unknownFieldsA(nil)) | ||||
| 	unknownFieldsBType  = reflect.TypeOf(unknownFieldsB(nil)) | ||||
| 	extensionFieldsType = reflect.TypeOf(ExtensionFields(nil)) | ||||
| ) | ||||
|  | ||||
| type structInfo struct { | ||||
| 	sizecacheOffset offset | ||||
| 	sizecacheType   reflect.Type | ||||
| 	weakOffset      offset | ||||
| 	weakType        reflect.Type | ||||
| 	unknownOffset   offset | ||||
| 	unknownType     reflect.Type | ||||
| 	extensionOffset offset | ||||
| 	extensionType   reflect.Type | ||||
|  | ||||
| 	fieldsByNumber        map[pref.FieldNumber]reflect.StructField | ||||
| 	oneofsByName          map[pref.Name]reflect.StructField | ||||
| @@ -151,18 +159,22 @@ fieldLoop: | ||||
| 		case genid.SizeCache_goname, genid.SizeCacheA_goname: | ||||
| 			if f.Type == sizecacheType { | ||||
| 				si.sizecacheOffset = offsetOf(f, mi.Exporter) | ||||
| 				si.sizecacheType = f.Type | ||||
| 			} | ||||
| 		case genid.WeakFields_goname, genid.WeakFieldsA_goname: | ||||
| 			if f.Type == weakFieldsType { | ||||
| 				si.weakOffset = offsetOf(f, mi.Exporter) | ||||
| 				si.weakType = f.Type | ||||
| 			} | ||||
| 		case genid.UnknownFields_goname, genid.UnknownFieldsA_goname: | ||||
| 			if f.Type == unknownFieldsType { | ||||
| 			if f.Type == unknownFieldsAType || f.Type == unknownFieldsBType { | ||||
| 				si.unknownOffset = offsetOf(f, mi.Exporter) | ||||
| 				si.unknownType = f.Type | ||||
| 			} | ||||
| 		case genid.ExtensionFields_goname, genid.ExtensionFieldsA_goname, genid.ExtensionFieldsB_goname: | ||||
| 			if f.Type == extensionFieldsType { | ||||
| 				si.extensionOffset = offsetOf(f, mi.Exporter) | ||||
| 				si.extensionType = f.Type | ||||
| 			} | ||||
| 		default: | ||||
| 			for _, s := range strings.Split(f.Tag.Get("protobuf"), ",") { | ||||
| @@ -212,4 +224,53 @@ func (mi *MessageInfo) New() protoreflect.Message { | ||||
| func (mi *MessageInfo) Zero() protoreflect.Message { | ||||
| 	return mi.MessageOf(reflect.Zero(mi.GoReflectType).Interface()) | ||||
| } | ||||
| func (mi *MessageInfo) Descriptor() protoreflect.MessageDescriptor { return mi.Desc } | ||||
| func (mi *MessageInfo) Descriptor() protoreflect.MessageDescriptor { | ||||
| 	return mi.Desc | ||||
| } | ||||
| func (mi *MessageInfo) Enum(i int) protoreflect.EnumType { | ||||
| 	mi.init() | ||||
| 	fd := mi.Desc.Fields().Get(i) | ||||
| 	return Export{}.EnumTypeOf(mi.fieldTypes[fd.Number()]) | ||||
| } | ||||
| func (mi *MessageInfo) Message(i int) protoreflect.MessageType { | ||||
| 	mi.init() | ||||
| 	fd := mi.Desc.Fields().Get(i) | ||||
| 	switch { | ||||
| 	case fd.IsWeak(): | ||||
| 		mt, _ := preg.GlobalTypes.FindMessageByName(fd.Message().FullName()) | ||||
| 		return mt | ||||
| 	case fd.IsMap(): | ||||
| 		return mapEntryType{fd.Message(), mi.fieldTypes[fd.Number()]} | ||||
| 	default: | ||||
| 		return Export{}.MessageTypeOf(mi.fieldTypes[fd.Number()]) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| type mapEntryType struct { | ||||
| 	desc    protoreflect.MessageDescriptor | ||||
| 	valType interface{} // zero value of enum or message type | ||||
| } | ||||
|  | ||||
| func (mt mapEntryType) New() protoreflect.Message { | ||||
| 	return nil | ||||
| } | ||||
| func (mt mapEntryType) Zero() protoreflect.Message { | ||||
| 	return nil | ||||
| } | ||||
| func (mt mapEntryType) Descriptor() protoreflect.MessageDescriptor { | ||||
| 	return mt.desc | ||||
| } | ||||
| func (mt mapEntryType) Enum(i int) protoreflect.EnumType { | ||||
| 	fd := mt.desc.Fields().Get(i) | ||||
| 	if fd.Enum() == nil { | ||||
| 		return nil | ||||
| 	} | ||||
| 	return Export{}.EnumTypeOf(mt.valType) | ||||
| } | ||||
| func (mt mapEntryType) Message(i int) protoreflect.MessageType { | ||||
| 	fd := mt.desc.Fields().Get(i) | ||||
| 	if fd.Message() == nil { | ||||
| 		return nil | ||||
| 	} | ||||
| 	return Export{}.MessageTypeOf(mt.valType) | ||||
| } | ||||
|   | ||||
							
								
								
									
										125
									
								
								vendor/google.golang.org/protobuf/internal/impl/message_reflect.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										125
									
								
								vendor/google.golang.org/protobuf/internal/impl/message_reflect.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -8,6 +8,7 @@ import ( | ||||
| 	"fmt" | ||||
| 	"reflect" | ||||
|  | ||||
| 	"google.golang.org/protobuf/internal/detrand" | ||||
| 	"google.golang.org/protobuf/internal/pragma" | ||||
| 	pref "google.golang.org/protobuf/reflect/protoreflect" | ||||
| ) | ||||
| @@ -16,6 +17,11 @@ type reflectMessageInfo struct { | ||||
| 	fields map[pref.FieldNumber]*fieldInfo | ||||
| 	oneofs map[pref.Name]*oneofInfo | ||||
|  | ||||
| 	// fieldTypes contains the zero value of an enum or message field. | ||||
| 	// For lists, it contains the element type. | ||||
| 	// For maps, it contains the entry value type. | ||||
| 	fieldTypes map[pref.FieldNumber]interface{} | ||||
|  | ||||
| 	// denseFields is a subset of fields where: | ||||
| 	//	0 < fieldDesc.Number() < len(denseFields) | ||||
| 	// It provides faster access to the fieldInfo, but may be incomplete. | ||||
| @@ -36,6 +42,7 @@ func (mi *MessageInfo) makeReflectFuncs(t reflect.Type, si structInfo) { | ||||
| 	mi.makeKnownFieldsFunc(si) | ||||
| 	mi.makeUnknownFieldsFunc(t, si) | ||||
| 	mi.makeExtensionFieldsFunc(t, si) | ||||
| 	mi.makeFieldTypes(si) | ||||
| } | ||||
|  | ||||
| // makeKnownFieldsFunc generates functions for operations that can be performed | ||||
| @@ -51,17 +58,23 @@ func (mi *MessageInfo) makeKnownFieldsFunc(si structInfo) { | ||||
| 	for i := 0; i < fds.Len(); i++ { | ||||
| 		fd := fds.Get(i) | ||||
| 		fs := si.fieldsByNumber[fd.Number()] | ||||
| 		isOneof := fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic() | ||||
| 		if isOneof { | ||||
| 			fs = si.oneofsByName[fd.ContainingOneof().Name()] | ||||
| 		} | ||||
| 		var fi fieldInfo | ||||
| 		switch { | ||||
| 		case fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic(): | ||||
| 			fi = fieldInfoForOneof(fd, si.oneofsByName[fd.ContainingOneof().Name()], mi.Exporter, si.oneofWrappersByNumber[fd.Number()]) | ||||
| 		case fs.Type == nil: | ||||
| 			fi = fieldInfoForMissing(fd) // never occurs for officially generated message types | ||||
| 		case isOneof: | ||||
| 			fi = fieldInfoForOneof(fd, fs, mi.Exporter, si.oneofWrappersByNumber[fd.Number()]) | ||||
| 		case fd.IsMap(): | ||||
| 			fi = fieldInfoForMap(fd, fs, mi.Exporter) | ||||
| 		case fd.IsList(): | ||||
| 			fi = fieldInfoForList(fd, fs, mi.Exporter) | ||||
| 		case fd.IsWeak(): | ||||
| 			fi = fieldInfoForWeakMessage(fd, si.weakOffset) | ||||
| 		case fd.Kind() == pref.MessageKind || fd.Kind() == pref.GroupKind: | ||||
| 		case fd.Message() != nil: | ||||
| 			fi = fieldInfoForMessage(fd, fs, mi.Exporter) | ||||
| 		default: | ||||
| 			fi = fieldInfoForScalar(fd, fs, mi.Exporter) | ||||
| @@ -92,27 +105,53 @@ func (mi *MessageInfo) makeKnownFieldsFunc(si structInfo) { | ||||
| 			i++ | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	// Introduce instability to iteration order, but keep it deterministic. | ||||
| 	if len(mi.rangeInfos) > 1 && detrand.Bool() { | ||||
| 		i := detrand.Intn(len(mi.rangeInfos) - 1) | ||||
| 		mi.rangeInfos[i], mi.rangeInfos[i+1] = mi.rangeInfos[i+1], mi.rangeInfos[i] | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (mi *MessageInfo) makeUnknownFieldsFunc(t reflect.Type, si structInfo) { | ||||
| 	mi.getUnknown = func(pointer) pref.RawFields { return nil } | ||||
| 	mi.setUnknown = func(pointer, pref.RawFields) { return } | ||||
| 	if si.unknownOffset.IsValid() { | ||||
| 	switch { | ||||
| 	case si.unknownOffset.IsValid() && si.unknownType == unknownFieldsAType: | ||||
| 		// Handle as []byte. | ||||
| 		mi.getUnknown = func(p pointer) pref.RawFields { | ||||
| 			if p.IsNil() { | ||||
| 				return nil | ||||
| 			} | ||||
| 			rv := p.Apply(si.unknownOffset).AsValueOf(unknownFieldsType) | ||||
| 			return pref.RawFields(*rv.Interface().(*[]byte)) | ||||
| 			return *p.Apply(mi.unknownOffset).Bytes() | ||||
| 		} | ||||
| 		mi.setUnknown = func(p pointer, b pref.RawFields) { | ||||
| 			if p.IsNil() { | ||||
| 				panic("invalid SetUnknown on nil Message") | ||||
| 			} | ||||
| 			rv := p.Apply(si.unknownOffset).AsValueOf(unknownFieldsType) | ||||
| 			*rv.Interface().(*[]byte) = []byte(b) | ||||
| 			*p.Apply(mi.unknownOffset).Bytes() = b | ||||
| 		} | ||||
| 	} else { | ||||
| 	case si.unknownOffset.IsValid() && si.unknownType == unknownFieldsBType: | ||||
| 		// Handle as *[]byte. | ||||
| 		mi.getUnknown = func(p pointer) pref.RawFields { | ||||
| 			if p.IsNil() { | ||||
| 				return nil | ||||
| 			} | ||||
| 			bp := p.Apply(mi.unknownOffset).BytesPtr() | ||||
| 			if *bp == nil { | ||||
| 				return nil | ||||
| 			} | ||||
| 			return **bp | ||||
| 		} | ||||
| 		mi.setUnknown = func(p pointer, b pref.RawFields) { | ||||
| 			if p.IsNil() { | ||||
| 				panic("invalid SetUnknown on nil Message") | ||||
| 			} | ||||
| 			bp := p.Apply(mi.unknownOffset).BytesPtr() | ||||
| 			if *bp == nil { | ||||
| 				*bp = new([]byte) | ||||
| 			} | ||||
| 			**bp = b | ||||
| 		} | ||||
| 	default: | ||||
| 		mi.getUnknown = func(pointer) pref.RawFields { | ||||
| 			return nil | ||||
| 		} | ||||
| @@ -139,6 +178,58 @@ func (mi *MessageInfo) makeExtensionFieldsFunc(t reflect.Type, si structInfo) { | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| func (mi *MessageInfo) makeFieldTypes(si structInfo) { | ||||
| 	md := mi.Desc | ||||
| 	fds := md.Fields() | ||||
| 	for i := 0; i < fds.Len(); i++ { | ||||
| 		var ft reflect.Type | ||||
| 		fd := fds.Get(i) | ||||
| 		fs := si.fieldsByNumber[fd.Number()] | ||||
| 		isOneof := fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic() | ||||
| 		if isOneof { | ||||
| 			fs = si.oneofsByName[fd.ContainingOneof().Name()] | ||||
| 		} | ||||
| 		var isMessage bool | ||||
| 		switch { | ||||
| 		case fs.Type == nil: | ||||
| 			continue // never occurs for officially generated message types | ||||
| 		case isOneof: | ||||
| 			if fd.Enum() != nil || fd.Message() != nil { | ||||
| 				ft = si.oneofWrappersByNumber[fd.Number()].Field(0).Type | ||||
| 			} | ||||
| 		case fd.IsMap(): | ||||
| 			if fd.MapValue().Enum() != nil || fd.MapValue().Message() != nil { | ||||
| 				ft = fs.Type.Elem() | ||||
| 			} | ||||
| 			isMessage = fd.MapValue().Message() != nil | ||||
| 		case fd.IsList(): | ||||
| 			if fd.Enum() != nil || fd.Message() != nil { | ||||
| 				ft = fs.Type.Elem() | ||||
| 			} | ||||
| 			isMessage = fd.Message() != nil | ||||
| 		case fd.Enum() != nil: | ||||
| 			ft = fs.Type | ||||
| 			if fd.HasPresence() && ft.Kind() == reflect.Ptr { | ||||
| 				ft = ft.Elem() | ||||
| 			} | ||||
| 		case fd.Message() != nil: | ||||
| 			ft = fs.Type | ||||
| 			if fd.IsWeak() { | ||||
| 				ft = nil | ||||
| 			} | ||||
| 			isMessage = true | ||||
| 		} | ||||
| 		if isMessage && ft != nil && ft.Kind() != reflect.Ptr { | ||||
| 			ft = reflect.PtrTo(ft) // never occurs for officially generated message types | ||||
| 		} | ||||
| 		if ft != nil { | ||||
| 			if mi.fieldTypes == nil { | ||||
| 				mi.fieldTypes = make(map[pref.FieldNumber]interface{}) | ||||
| 			} | ||||
| 			mi.fieldTypes[fd.Number()] = reflect.Zero(ft).Interface() | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| type extensionMap map[int32]ExtensionField | ||||
|  | ||||
| @@ -306,7 +397,6 @@ var ( | ||||
| // pointer to a named Go struct. If the provided type has a ProtoReflect method, | ||||
| // it must be implemented by calling this method. | ||||
| func (mi *MessageInfo) MessageOf(m interface{}) pref.Message { | ||||
| 	// TODO: Switch the input to be an opaque Pointer. | ||||
| 	if reflect.TypeOf(m) != mi.GoReflectType { | ||||
| 		panic(fmt.Sprintf("type mismatch: got %T, want %v", m, mi.GoReflectType)) | ||||
| 	} | ||||
| @@ -320,6 +410,17 @@ func (mi *MessageInfo) MessageOf(m interface{}) pref.Message { | ||||
| func (m *messageReflectWrapper) pointer() pointer          { return m.p } | ||||
| func (m *messageReflectWrapper) messageInfo() *MessageInfo { return m.mi } | ||||
|  | ||||
| // Reset implements the v1 proto.Message.Reset method. | ||||
| func (m *messageIfaceWrapper) Reset() { | ||||
| 	if mr, ok := m.protoUnwrap().(interface{ Reset() }); ok { | ||||
| 		mr.Reset() | ||||
| 		return | ||||
| 	} | ||||
| 	rv := reflect.ValueOf(m.protoUnwrap()) | ||||
| 	if rv.Kind() == reflect.Ptr && !rv.IsNil() { | ||||
| 		rv.Elem().Set(reflect.Zero(rv.Type().Elem())) | ||||
| 	} | ||||
| } | ||||
| func (m *messageIfaceWrapper) ProtoReflect() pref.Message { | ||||
| 	return (*messageReflectWrapper)(m) | ||||
| } | ||||
|   | ||||
							
								
								
									
										85
									
								
								vendor/google.golang.org/protobuf/internal/impl/message_reflect_field.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										85
									
								
								vendor/google.golang.org/protobuf/internal/impl/message_reflect_field.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -28,6 +28,39 @@ type fieldInfo struct { | ||||
| 	newField   func() pref.Value | ||||
| } | ||||
|  | ||||
| func fieldInfoForMissing(fd pref.FieldDescriptor) fieldInfo { | ||||
| 	// This never occurs for generated message types. | ||||
| 	// It implies that a hand-crafted type has missing Go fields | ||||
| 	// for specific protobuf message fields. | ||||
| 	return fieldInfo{ | ||||
| 		fieldDesc: fd, | ||||
| 		has: func(p pointer) bool { | ||||
| 			return false | ||||
| 		}, | ||||
| 		clear: func(p pointer) { | ||||
| 			panic("missing Go struct field for " + string(fd.FullName())) | ||||
| 		}, | ||||
| 		get: func(p pointer) pref.Value { | ||||
| 			return fd.Default() | ||||
| 		}, | ||||
| 		set: func(p pointer, v pref.Value) { | ||||
| 			panic("missing Go struct field for " + string(fd.FullName())) | ||||
| 		}, | ||||
| 		mutable: func(p pointer) pref.Value { | ||||
| 			panic("missing Go struct field for " + string(fd.FullName())) | ||||
| 		}, | ||||
| 		newMessage: func() pref.Message { | ||||
| 			panic("missing Go struct field for " + string(fd.FullName())) | ||||
| 		}, | ||||
| 		newField: func() pref.Value { | ||||
| 			if v := fd.Default(); v.IsValid() { | ||||
| 				return v | ||||
| 			} | ||||
| 			panic("missing Go struct field for " + string(fd.FullName())) | ||||
| 		}, | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func fieldInfoForOneof(fd pref.FieldDescriptor, fs reflect.StructField, x exporter, ot reflect.Type) fieldInfo { | ||||
| 	ft := fs.Type | ||||
| 	if ft.Kind() != reflect.Interface { | ||||
| @@ -97,7 +130,7 @@ func fieldInfoForOneof(fd pref.FieldDescriptor, fs reflect.StructField, x export | ||||
| 				rv.Set(reflect.New(ot)) | ||||
| 			} | ||||
| 			rv = rv.Elem().Elem().Field(0) | ||||
| 			if rv.IsNil() { | ||||
| 			if rv.Kind() == reflect.Ptr && rv.IsNil() { | ||||
| 				rv.Set(conv.GoValueOf(pref.ValueOfMessage(conv.New().Message()))) | ||||
| 			} | ||||
| 			return conv.PBValueOf(rv) | ||||
| @@ -225,7 +258,10 @@ func fieldInfoForScalar(fd pref.FieldDescriptor, fs reflect.StructField, x expor | ||||
| 	isBytes := ft.Kind() == reflect.Slice && ft.Elem().Kind() == reflect.Uint8 | ||||
| 	if nullable { | ||||
| 		if ft.Kind() != reflect.Ptr && ft.Kind() != reflect.Slice { | ||||
| 			panic(fmt.Sprintf("field %v has invalid type: got %v, want pointer", fd.FullName(), ft)) | ||||
| 			// This never occurs for generated message types. | ||||
| 			// Despite the protobuf type system specifying presence, | ||||
| 			// the Go field type cannot represent it. | ||||
| 			nullable = false | ||||
| 		} | ||||
| 		if ft.Kind() == reflect.Ptr { | ||||
| 			ft = ft.Elem() | ||||
| @@ -388,6 +424,9 @@ func fieldInfoForMessage(fd pref.FieldDescriptor, fs reflect.StructField, x expo | ||||
| 				return false | ||||
| 			} | ||||
| 			rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem() | ||||
| 			if fs.Type.Kind() != reflect.Ptr { | ||||
| 				return !isZero(rv) | ||||
| 			} | ||||
| 			return !rv.IsNil() | ||||
| 		}, | ||||
| 		clear: func(p pointer) { | ||||
| @@ -404,13 +443,13 @@ func fieldInfoForMessage(fd pref.FieldDescriptor, fs reflect.StructField, x expo | ||||
| 		set: func(p pointer, v pref.Value) { | ||||
| 			rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem() | ||||
| 			rv.Set(conv.GoValueOf(v)) | ||||
| 			if rv.IsNil() { | ||||
| 			if fs.Type.Kind() == reflect.Ptr && rv.IsNil() { | ||||
| 				panic(fmt.Sprintf("field %v has invalid nil pointer", fd.FullName())) | ||||
| 			} | ||||
| 		}, | ||||
| 		mutable: func(p pointer) pref.Value { | ||||
| 			rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem() | ||||
| 			if rv.IsNil() { | ||||
| 			if fs.Type.Kind() == reflect.Ptr && rv.IsNil() { | ||||
| 				rv.Set(conv.GoValueOf(conv.New())) | ||||
| 			} | ||||
| 			return conv.PBValueOf(rv) | ||||
| @@ -464,3 +503,41 @@ func makeOneofInfo(od pref.OneofDescriptor, si structInfo, x exporter) *oneofInf | ||||
| 	} | ||||
| 	return oi | ||||
| } | ||||
|  | ||||
| // isZero is identical to reflect.Value.IsZero. | ||||
| // TODO: Remove this when Go1.13 is the minimally supported Go version. | ||||
| func isZero(v reflect.Value) bool { | ||||
| 	switch v.Kind() { | ||||
| 	case reflect.Bool: | ||||
| 		return !v.Bool() | ||||
| 	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: | ||||
| 		return v.Int() == 0 | ||||
| 	case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: | ||||
| 		return v.Uint() == 0 | ||||
| 	case reflect.Float32, reflect.Float64: | ||||
| 		return math.Float64bits(v.Float()) == 0 | ||||
| 	case reflect.Complex64, reflect.Complex128: | ||||
| 		c := v.Complex() | ||||
| 		return math.Float64bits(real(c)) == 0 && math.Float64bits(imag(c)) == 0 | ||||
| 	case reflect.Array: | ||||
| 		for i := 0; i < v.Len(); i++ { | ||||
| 			if !isZero(v.Index(i)) { | ||||
| 				return false | ||||
| 			} | ||||
| 		} | ||||
| 		return true | ||||
| 	case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice, reflect.UnsafePointer: | ||||
| 		return v.IsNil() | ||||
| 	case reflect.String: | ||||
| 		return v.Len() == 0 | ||||
| 	case reflect.Struct: | ||||
| 		for i := 0; i < v.NumField(); i++ { | ||||
| 			if !isZero(v.Field(i)) { | ||||
| 				return false | ||||
| 			} | ||||
| 		} | ||||
| 		return true | ||||
| 	default: | ||||
| 		panic(&reflect.ValueError{"reflect.Value.IsZero", v.Kind()}) | ||||
| 	} | ||||
| } | ||||
|   | ||||
							
								
								
									
										1
									
								
								vendor/google.golang.org/protobuf/internal/impl/pointer_reflect.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								vendor/google.golang.org/protobuf/internal/impl/pointer_reflect.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -121,6 +121,7 @@ func (p pointer) String() *string          { return p.v.Interface().(*string) } | ||||
| func (p pointer) StringPtr() **string      { return p.v.Interface().(**string) } | ||||
| func (p pointer) StringSlice() *[]string   { return p.v.Interface().(*[]string) } | ||||
| func (p pointer) Bytes() *[]byte           { return p.v.Interface().(*[]byte) } | ||||
| func (p pointer) BytesPtr() **[]byte       { return p.v.Interface().(**[]byte) } | ||||
| func (p pointer) BytesSlice() *[][]byte    { return p.v.Interface().(*[][]byte) } | ||||
| func (p pointer) WeakFields() *weakFields  { return (*weakFields)(p.v.Interface().(*WeakFields)) } | ||||
| func (p pointer) Extensions() *map[int32]ExtensionField { | ||||
|   | ||||
							
								
								
									
										1
									
								
								vendor/google.golang.org/protobuf/internal/impl/pointer_unsafe.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								vendor/google.golang.org/protobuf/internal/impl/pointer_unsafe.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -109,6 +109,7 @@ func (p pointer) String() *string                       { return (*string)(p.p) | ||||
| func (p pointer) StringPtr() **string                   { return (**string)(p.p) } | ||||
| func (p pointer) StringSlice() *[]string                { return (*[]string)(p.p) } | ||||
| func (p pointer) Bytes() *[]byte                        { return (*[]byte)(p.p) } | ||||
| func (p pointer) BytesPtr() **[]byte                    { return (**[]byte)(p.p) } | ||||
| func (p pointer) BytesSlice() *[][]byte                 { return (*[][]byte)(p.p) } | ||||
| func (p pointer) WeakFields() *weakFields               { return (*weakFields)(p.p) } | ||||
| func (p pointer) Extensions() *map[int32]ExtensionField { return (*map[int32]ExtensionField)(p.p) } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user