mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2025-03-29 13:20:21 +00:00
reflect/protoreflect: replace Mutable with NewMessage
Remove the Mutable methods from KnownFields, List, and Map, replacing them with methods which return a new, empty message value without adding that value to the collection. The new API is simpler, since it clearly applies only to message values, and more orthogonal, since it provides a way to create a value without mutating the collection. This latter point is particularly useful in map deserialization, where the key may be unknown at the time the value is deserialized. Drop the Mutable interface, since it is no longer necessary. Change-Id: Ic5f3d06a2aa331a5d5cd2b4e670a3dba4a74f77c Reviewed-on: https://go-review.googlesource.com/c/153278 Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
This commit is contained in:
parent
c9899da4d5
commit
97e7f57dbb
@ -39,7 +39,6 @@ func (m xxx_Request) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_Request) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_Request) ProtoMutable() {}
|
||||
|
||||
func (m *Request) Reset() { *m = Request{} }
|
||||
func (m *Request) String() string { return proto.CompactTextString(m) }
|
||||
@ -89,7 +88,6 @@ func (m xxx_Response) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_Response) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_Response) ProtoMutable() {}
|
||||
|
||||
func (m *Response) Reset() { *m = Response{} }
|
||||
func (m *Response) String() string { return proto.CompactTextString(m) }
|
||||
|
@ -384,7 +384,6 @@ func genReflectMessage(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileI
|
||||
g.P("func (m ", shadowType, ") Interface() ", protoreflectPackage.Ident("ProtoMessage"), " {")
|
||||
g.P("return m.m")
|
||||
g.P("}")
|
||||
g.P("func (m ", shadowType, ") ProtoMutable() {}")
|
||||
g.P()
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,6 @@ func (m xxx_AnnotationsTestMessage) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_AnnotationsTestMessage) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_AnnotationsTestMessage) ProtoMutable() {}
|
||||
|
||||
func (m *AnnotationsTestMessage) Reset() { *m = AnnotationsTestMessage{} }
|
||||
func (m *AnnotationsTestMessage) String() string { return proto.CompactTextString(m) }
|
||||
|
@ -50,7 +50,6 @@ func (m xxx_Message1) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_Message1) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_Message1) ProtoMutable() {}
|
||||
|
||||
func (m *Message1) Reset() { *m = Message1{} }
|
||||
func (m *Message1) String() string { return proto.CompactTextString(m) }
|
||||
@ -139,7 +138,6 @@ func (m xxx_Message2) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_Message2) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_Message2) ProtoMutable() {}
|
||||
|
||||
func (m *Message2) Reset() { *m = Message2{} }
|
||||
func (m *Message2) String() string { return proto.CompactTextString(m) }
|
||||
@ -190,7 +188,6 @@ func (m xxx_Message1_Message1A) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_Message1_Message1A) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_Message1_Message1A) ProtoMutable() {}
|
||||
|
||||
func (m *Message1_Message1A) Reset() { *m = Message1_Message1A{} }
|
||||
func (m *Message1_Message1A) String() string { return proto.CompactTextString(m) }
|
||||
@ -241,7 +238,6 @@ func (m xxx_Message1_Message1B) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_Message1_Message1B) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_Message1_Message1B) ProtoMutable() {}
|
||||
|
||||
func (m *Message1_Message1B) Reset() { *m = Message1_Message1B{} }
|
||||
func (m *Message1_Message1B) String() string { return proto.CompactTextString(m) }
|
||||
@ -292,7 +288,6 @@ func (m xxx_Message2_Message2A) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_Message2_Message2A) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_Message2_Message2A) ProtoMutable() {}
|
||||
|
||||
func (m *Message2_Message2A) Reset() { *m = Message2_Message2A{} }
|
||||
func (m *Message2_Message2A) String() string { return proto.CompactTextString(m) }
|
||||
@ -343,7 +338,6 @@ func (m xxx_Message2_Message2B) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_Message2_Message2B) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_Message2_Message2B) ProtoMutable() {}
|
||||
|
||||
func (m *Message2_Message2B) Reset() { *m = Message2_Message2B{} }
|
||||
func (m *Message2_Message2B) String() string { return proto.CompactTextString(m) }
|
||||
|
@ -74,7 +74,6 @@ func (m xxx_DeprecatedMessage) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_DeprecatedMessage) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_DeprecatedMessage) ProtoMutable() {}
|
||||
|
||||
func (m *DeprecatedMessage) Reset() { *m = DeprecatedMessage{} }
|
||||
func (m *DeprecatedMessage) String() string { return proto.CompactTextString(m) }
|
||||
|
@ -41,7 +41,6 @@ func (m xxx_BaseMessage) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_BaseMessage) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_BaseMessage) ProtoMutable() {}
|
||||
|
||||
func (m *BaseMessage) Reset() { *m = BaseMessage{} }
|
||||
func (m *BaseMessage) String() string { return proto.CompactTextString(m) }
|
||||
@ -108,7 +107,6 @@ func (m xxx_MessageSetWireFormatMessage) UnknownFields() protoreflect.UnknownFie
|
||||
func (m xxx_MessageSetWireFormatMessage) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_MessageSetWireFormatMessage) ProtoMutable() {}
|
||||
|
||||
func (m *MessageSetWireFormatMessage) Reset() { *m = MessageSetWireFormatMessage{} }
|
||||
func (m *MessageSetWireFormatMessage) String() string { return proto.CompactTextString(m) }
|
||||
|
@ -91,7 +91,6 @@ func (m xxx_Message) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_Message) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_Message) ProtoMutable() {}
|
||||
|
||||
func (m *Message) Reset() { *m = Message{} }
|
||||
func (m *Message) String() string { return proto.CompactTextString(m) }
|
||||
@ -149,7 +148,6 @@ func (m xxx_ExtensionGroup) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_ExtensionGroup) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_ExtensionGroup) ProtoMutable() {}
|
||||
|
||||
func (m *ExtensionGroup) Reset() { *m = ExtensionGroup{} }
|
||||
func (m *ExtensionGroup) String() string { return proto.CompactTextString(m) }
|
||||
@ -207,7 +205,6 @@ func (m xxx_ExtendingMessage) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_ExtendingMessage) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_ExtendingMessage) ProtoMutable() {}
|
||||
|
||||
func (m *ExtendingMessage) Reset() { *m = ExtendingMessage{} }
|
||||
func (m *ExtendingMessage) String() string { return proto.CompactTextString(m) }
|
||||
@ -258,7 +255,6 @@ func (m xxx_RepeatedGroup) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_RepeatedGroup) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_RepeatedGroup) ProtoMutable() {}
|
||||
|
||||
func (m *RepeatedGroup) Reset() { *m = RepeatedGroup{} }
|
||||
func (m *RepeatedGroup) String() string { return proto.CompactTextString(m) }
|
||||
@ -317,7 +313,6 @@ func (m xxx_Extendable) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_Extendable) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_Extendable) ProtoMutable() {}
|
||||
|
||||
func (m *Extendable) Reset() { *m = Extendable{} }
|
||||
func (m *Extendable) String() string { return proto.CompactTextString(m) }
|
||||
@ -378,7 +373,6 @@ func (m xxx_MessageSetWireFormatExtension) UnknownFields() protoreflect.UnknownF
|
||||
func (m xxx_MessageSetWireFormatExtension) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_MessageSetWireFormatExtension) ProtoMutable() {}
|
||||
|
||||
func (m *MessageSetWireFormatExtension) Reset() { *m = MessageSetWireFormatExtension{} }
|
||||
func (m *MessageSetWireFormatExtension) String() string { return proto.CompactTextString(m) }
|
||||
@ -428,7 +422,6 @@ func (m xxx_Message_M) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_Message_M) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_Message_M) ProtoMutable() {}
|
||||
|
||||
func (m *Message_M) Reset() { *m = Message_M{} }
|
||||
func (m *Message_M) String() string { return proto.CompactTextString(m) }
|
||||
@ -480,7 +473,6 @@ func (m xxx_ExtendingMessage_ExtendingMessageSubmessage) UnknownFields() protore
|
||||
func (m xxx_ExtendingMessage_ExtendingMessageSubmessage) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_ExtendingMessage_ExtendingMessageSubmessage) ProtoMutable() {}
|
||||
|
||||
func (m *ExtendingMessage_ExtendingMessageSubmessage) Reset() {
|
||||
*m = ExtendingMessage_ExtendingMessageSubmessage{}
|
||||
|
@ -40,7 +40,6 @@ func (m xxx_ExtraMessage) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_ExtraMessage) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_ExtraMessage) ProtoMutable() {}
|
||||
|
||||
func (m *ExtraMessage) Reset() { *m = ExtraMessage{} }
|
||||
func (m *ExtraMessage) String() string { return proto.CompactTextString(m) }
|
||||
|
@ -74,7 +74,6 @@ func (m xxx_Message) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_Message) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_Message) ProtoMutable() {}
|
||||
|
||||
func (m *Message) Reset() { *m = Message{} }
|
||||
func (m *Message) String() string { return proto.CompactTextString(m) }
|
||||
|
@ -78,7 +78,6 @@ func (m xxx_Message) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_Message) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_Message) ProtoMutable() {}
|
||||
|
||||
func (m *Message) Reset() { *m = Message{} }
|
||||
func (m *Message) String() string { return proto.CompactTextString(m) }
|
||||
@ -321,7 +320,6 @@ func (m xxx_Message_OneofMessageConflict) UnknownFields() protoreflect.UnknownFi
|
||||
func (m xxx_Message_OneofMessageConflict) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_Message_OneofMessageConflict) ProtoMutable() {}
|
||||
|
||||
func (m *Message_OneofMessageConflict) Reset() { *m = Message_OneofMessageConflict{} }
|
||||
func (m *Message_OneofMessageConflict) String() string { return proto.CompactTextString(m) }
|
||||
|
@ -84,7 +84,6 @@ func (m xxx_Public) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_Public) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_Public) ProtoMutable() {}
|
||||
|
||||
func (m *Public) Reset() { *m = Public{} }
|
||||
func (m *Public) String() string { return proto.CompactTextString(m) }
|
||||
|
@ -42,7 +42,6 @@ func (m xxx_Local) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_Local) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_Local) ProtoMutable() {}
|
||||
|
||||
func (m *Local) Reset() { *m = Local{} }
|
||||
func (m *Local) String() string { return proto.CompactTextString(m) }
|
||||
|
@ -197,7 +197,6 @@ func (m xxx_M) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_M) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_M) ProtoMutable() {}
|
||||
|
||||
func (m *M) Reset() { *m = M{} }
|
||||
func (m *M) String() string { return proto.CompactTextString(m) }
|
||||
@ -337,7 +336,6 @@ func (m xxx_M_Submessage) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_M_Submessage) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_M_Submessage) ProtoMutable() {}
|
||||
|
||||
func (m *M_Submessage) Reset() { *m = M_Submessage{} }
|
||||
func (m *M_Submessage) String() string { return proto.CompactTextString(m) }
|
||||
|
@ -39,7 +39,6 @@ func (m xxx_M2) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_M2) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_M2) ProtoMutable() {}
|
||||
|
||||
func (m *M2) Reset() { *m = M2{} }
|
||||
func (m *M2) String() string { return proto.CompactTextString(m) }
|
||||
|
@ -39,7 +39,6 @@ func (m xxx_M) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_M) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_M) ProtoMutable() {}
|
||||
|
||||
func (m *M) Reset() { *m = M{} }
|
||||
func (m *M) String() string { return proto.CompactTextString(m) }
|
||||
|
@ -73,7 +73,6 @@ func (m xxx_M1) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_M1) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_M1) ProtoMutable() {}
|
||||
|
||||
func (m *M1) Reset() { *m = M1{} }
|
||||
func (m *M1) String() string { return proto.CompactTextString(m) }
|
||||
@ -124,7 +123,6 @@ func (m xxx_M1_1) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_M1_1) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_M1_1) ProtoMutable() {}
|
||||
|
||||
func (m *M1_1) Reset() { *m = M1_1{} }
|
||||
func (m *M1_1) String() string { return proto.CompactTextString(m) }
|
||||
|
@ -39,7 +39,6 @@ func (m xxx_M2) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_M2) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_M2) ProtoMutable() {}
|
||||
|
||||
func (m *M2) Reset() { *m = M2{} }
|
||||
func (m *M2) String() string { return proto.CompactTextString(m) }
|
||||
|
@ -39,7 +39,6 @@ func (m xxx_M3) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_M3) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_M3) ProtoMutable() {}
|
||||
|
||||
func (m *M3) Reset() { *m = M3{} }
|
||||
func (m *M3) String() string { return proto.CompactTextString(m) }
|
||||
|
@ -39,7 +39,6 @@ func (m xxx_M4) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_M4) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_M4) ProtoMutable() {}
|
||||
|
||||
func (m *M4) Reset() { *m = M4{} }
|
||||
func (m *M4) String() string { return proto.CompactTextString(m) }
|
||||
|
@ -39,7 +39,6 @@ func (m xxx_M1) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_M1) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_M1) ProtoMutable() {}
|
||||
|
||||
func (m *M1) Reset() { *m = M1{} }
|
||||
func (m *M1) String() string { return proto.CompactTextString(m) }
|
||||
|
@ -39,7 +39,6 @@ func (m xxx_M2) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_M2) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_M2) ProtoMutable() {}
|
||||
|
||||
func (m *M2) Reset() { *m = M2{} }
|
||||
func (m *M2) String() string { return proto.CompactTextString(m) }
|
||||
|
@ -41,7 +41,6 @@ func (m xxx_A1M1) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_A1M1) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_A1M1) ProtoMutable() {}
|
||||
|
||||
func (m *A1M1) Reset() { *m = A1M1{} }
|
||||
func (m *A1M1) String() string { return proto.CompactTextString(m) }
|
||||
|
@ -41,7 +41,6 @@ func (m xxx_A1M2) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_A1M2) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_A1M2) ProtoMutable() {}
|
||||
|
||||
func (m *A1M2) Reset() { *m = A1M2{} }
|
||||
func (m *A1M2) String() string { return proto.CompactTextString(m) }
|
||||
|
@ -48,7 +48,6 @@ func (m xxx_All) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_All) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_All) ProtoMutable() {}
|
||||
|
||||
func (m *All) Reset() { *m = All{} }
|
||||
func (m *All) String() string { return proto.CompactTextString(m) }
|
||||
|
@ -90,7 +90,6 @@ func (m xxx_Message) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_Message) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_Message) ProtoMutable() {}
|
||||
|
||||
func (m *Message) Reset() { *m = Message{} }
|
||||
func (m *Message) String() string { return proto.CompactTextString(m) }
|
||||
|
2
cmd/protoc-gen-go/testdata/proto2/enum.pb.go
vendored
2
cmd/protoc-gen-go/testdata/proto2/enum.pb.go
vendored
@ -348,7 +348,6 @@ func (m xxx_EnumContainerMessage1) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_EnumContainerMessage1) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_EnumContainerMessage1) ProtoMutable() {}
|
||||
|
||||
func (m *EnumContainerMessage1) Reset() { *m = EnumContainerMessage1{} }
|
||||
func (m *EnumContainerMessage1) String() string { return proto.CompactTextString(m) }
|
||||
@ -417,7 +416,6 @@ func (m xxx_EnumContainerMessage1_EnumContainerMessage2) UnknownFields() protore
|
||||
func (m xxx_EnumContainerMessage1_EnumContainerMessage2) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_EnumContainerMessage1_EnumContainerMessage2) ProtoMutable() {}
|
||||
|
||||
func (m *EnumContainerMessage1_EnumContainerMessage2) Reset() {
|
||||
*m = EnumContainerMessage1_EnumContainerMessage2{}
|
||||
|
@ -198,7 +198,6 @@ func (m xxx_FieldTestMessage) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_FieldTestMessage) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_FieldTestMessage) ProtoMutable() {}
|
||||
|
||||
func (m *FieldTestMessage) Reset() { *m = FieldTestMessage{} }
|
||||
func (m *FieldTestMessage) String() string { return proto.CompactTextString(m) }
|
||||
@ -1168,7 +1167,6 @@ func (m xxx_FieldTestMessage_OptionalGroup) UnknownFields() protoreflect.Unknown
|
||||
func (m xxx_FieldTestMessage_OptionalGroup) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_FieldTestMessage_OptionalGroup) ProtoMutable() {}
|
||||
|
||||
func (m *FieldTestMessage_OptionalGroup) Reset() { *m = FieldTestMessage_OptionalGroup{} }
|
||||
func (m *FieldTestMessage_OptionalGroup) String() string { return proto.CompactTextString(m) }
|
||||
@ -1228,7 +1226,6 @@ func (m xxx_FieldTestMessage_RequiredGroup) UnknownFields() protoreflect.Unknown
|
||||
func (m xxx_FieldTestMessage_RequiredGroup) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_FieldTestMessage_RequiredGroup) ProtoMutable() {}
|
||||
|
||||
func (m *FieldTestMessage_RequiredGroup) Reset() { *m = FieldTestMessage_RequiredGroup{} }
|
||||
func (m *FieldTestMessage_RequiredGroup) String() string { return proto.CompactTextString(m) }
|
||||
@ -1288,7 +1285,6 @@ func (m xxx_FieldTestMessage_RepeatedGroup) UnknownFields() protoreflect.Unknown
|
||||
func (m xxx_FieldTestMessage_RepeatedGroup) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_FieldTestMessage_RepeatedGroup) ProtoMutable() {}
|
||||
|
||||
func (m *FieldTestMessage_RepeatedGroup) Reset() { *m = FieldTestMessage_RepeatedGroup{} }
|
||||
func (m *FieldTestMessage_RepeatedGroup) String() string { return proto.CompactTextString(m) }
|
||||
@ -1346,7 +1342,6 @@ func (m xxx_FieldTestMessage_OneofGroup) UnknownFields() protoreflect.UnknownFie
|
||||
func (m xxx_FieldTestMessage_OneofGroup) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_FieldTestMessage_OneofGroup) ProtoMutable() {}
|
||||
|
||||
func (m *FieldTestMessage_OneofGroup) Reset() { *m = FieldTestMessage_OneofGroup{} }
|
||||
func (m *FieldTestMessage_OneofGroup) String() string { return proto.CompactTextString(m) }
|
||||
@ -1403,7 +1398,6 @@ func (m xxx_FieldTestMessage_Message) UnknownFields() protoreflect.UnknownFields
|
||||
func (m xxx_FieldTestMessage_Message) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_FieldTestMessage_Message) ProtoMutable() {}
|
||||
|
||||
func (m *FieldTestMessage_Message) Reset() { *m = FieldTestMessage_Message{} }
|
||||
func (m *FieldTestMessage_Message) String() string { return proto.CompactTextString(m) }
|
||||
|
@ -41,7 +41,6 @@ func (m xxx_Layer1) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_Layer1) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_Layer1) ProtoMutable() {}
|
||||
|
||||
func (m *Layer1) Reset() { *m = Layer1{} }
|
||||
func (m *Layer1) String() string { return proto.CompactTextString(m) }
|
||||
@ -106,7 +105,6 @@ func (m xxx_Layer1_Layer2) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_Layer1_Layer2) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_Layer1_Layer2) ProtoMutable() {}
|
||||
|
||||
func (m *Layer1_Layer2) Reset() { *m = Layer1_Layer2{} }
|
||||
func (m *Layer1_Layer2) String() string { return proto.CompactTextString(m) }
|
||||
@ -163,7 +161,6 @@ func (m xxx_Layer1_Layer2_Layer3) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_Layer1_Layer2_Layer3) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_Layer1_Layer2_Layer3) ProtoMutable() {}
|
||||
|
||||
func (m *Layer1_Layer2_Layer3) Reset() { *m = Layer1_Layer2_Layer3{} }
|
||||
func (m *Layer1_Layer2_Layer3) String() string { return proto.CompactTextString(m) }
|
||||
|
@ -41,7 +41,6 @@ func (m xxx_Message) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_Message) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_Message) ProtoMutable() {}
|
||||
|
||||
func (m *Message) Reset() { *m = Message{} }
|
||||
func (m *Message) String() string { return proto.CompactTextString(m) }
|
||||
|
@ -110,7 +110,6 @@ func (m xxx_FieldTestMessage) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_FieldTestMessage) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_FieldTestMessage) ProtoMutable() {}
|
||||
|
||||
func (m *FieldTestMessage) Reset() { *m = FieldTestMessage{} }
|
||||
func (m *FieldTestMessage) String() string { return proto.CompactTextString(m) }
|
||||
@ -419,7 +418,6 @@ func (m xxx_FieldTestMessage_Message) UnknownFields() protoreflect.UnknownFields
|
||||
func (m xxx_FieldTestMessage_Message) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_FieldTestMessage_Message) ProtoMutable() {}
|
||||
|
||||
func (m *FieldTestMessage_Message) Reset() { *m = FieldTestMessage_Message{} }
|
||||
func (m *FieldTestMessage_Message) String() string { return proto.CompactTextString(m) }
|
||||
|
@ -118,20 +118,6 @@ func (p legacyExtensionFields) Clear(n pref.FieldNumber) {
|
||||
p.x.Set(n, x)
|
||||
}
|
||||
|
||||
func (p legacyExtensionFields) Mutable(n pref.FieldNumber) pref.Mutable {
|
||||
x := p.x.Get(n)
|
||||
if x.Desc == nil {
|
||||
panic("no extension descriptor registered")
|
||||
}
|
||||
t := legacyWrapper.ExtensionTypeFromDesc(x.Desc)
|
||||
if x.Value == nil {
|
||||
v := t.ValueOf(t.New())
|
||||
x.Value = t.InterfaceOf(v)
|
||||
p.x.Set(n, x)
|
||||
}
|
||||
return t.ValueOf(x.Value).Interface().(pref.Mutable)
|
||||
}
|
||||
|
||||
func (p legacyExtensionFields) Range(f func(pref.FieldNumber, pref.Value) bool) {
|
||||
p.x.Range(func(n pref.FieldNumber, x papi.ExtensionField) bool {
|
||||
if p.Has(n) {
|
||||
@ -141,6 +127,15 @@ func (p legacyExtensionFields) Range(f func(pref.FieldNumber, pref.Value) bool)
|
||||
})
|
||||
}
|
||||
|
||||
func (p legacyExtensionFields) NewMessage(n pref.FieldNumber) pref.ProtoMessage {
|
||||
x := p.x.Get(n)
|
||||
if x.Desc == nil {
|
||||
panic("no extension descriptor registered")
|
||||
}
|
||||
xt := legacyWrapper.ExtensionTypeFromDesc(x.Desc)
|
||||
return xt.ValueOf(xt.New()).Message().Interface()
|
||||
}
|
||||
|
||||
func (p legacyExtensionFields) ExtensionTypes() pref.ExtensionFieldTypes {
|
||||
return legacyExtensionTypes(p)
|
||||
}
|
||||
|
@ -265,15 +265,6 @@ func (fs *knownFields) Clear(n pref.FieldNumber) {
|
||||
return
|
||||
}
|
||||
}
|
||||
func (fs *knownFields) Mutable(n pref.FieldNumber) pref.Mutable {
|
||||
if fi := fs.mi.fields[n]; fi != nil {
|
||||
return fi.mutable(fs.p)
|
||||
}
|
||||
if fs.mi.Type.ExtensionRanges().Has(n) {
|
||||
return fs.extensionFields().Mutable(n)
|
||||
}
|
||||
panic(fmt.Sprintf("invalid field: %d", n))
|
||||
}
|
||||
func (fs *knownFields) Range(f func(pref.FieldNumber, pref.Value) bool) {
|
||||
for n, fi := range fs.mi.fields {
|
||||
if fi.has(fs.p) {
|
||||
@ -284,6 +275,15 @@ func (fs *knownFields) Range(f func(pref.FieldNumber, pref.Value) bool) {
|
||||
}
|
||||
fs.extensionFields().Range(f)
|
||||
}
|
||||
func (fs *knownFields) NewMessage(n pref.FieldNumber) pref.ProtoMessage {
|
||||
if fi := fs.mi.fields[n]; fi != nil {
|
||||
return fi.newMessage().Interface()
|
||||
}
|
||||
if fs.mi.Type.ExtensionRanges().Has(n) {
|
||||
return fs.extensionFields().NewMessage(n)
|
||||
}
|
||||
panic(fmt.Sprintf("invalid field: %d", n))
|
||||
}
|
||||
func (fs *knownFields) ExtensionTypes() pref.ExtensionFieldTypes {
|
||||
return fs.extensionFields().ExtensionTypes()
|
||||
}
|
||||
@ -306,9 +306,11 @@ func (emptyExtensionFields) Has(pref.FieldNumber) bool { ret
|
||||
func (emptyExtensionFields) Get(pref.FieldNumber) pref.Value { return pref.Value{} }
|
||||
func (emptyExtensionFields) Set(pref.FieldNumber, pref.Value) { panic("extensions not supported") }
|
||||
func (emptyExtensionFields) Clear(pref.FieldNumber) { return } // noop
|
||||
func (emptyExtensionFields) Mutable(pref.FieldNumber) pref.Mutable { panic("extensions not supported") }
|
||||
func (emptyExtensionFields) Range(func(pref.FieldNumber, pref.Value) bool) { return }
|
||||
func (emptyExtensionFields) ExtensionTypes() pref.ExtensionFieldTypes { return emptyExtensionTypes{} }
|
||||
func (emptyExtensionFields) NewMessage(pref.FieldNumber) pref.ProtoMessage {
|
||||
panic("extensions not supported")
|
||||
}
|
||||
func (emptyExtensionFields) ExtensionTypes() pref.ExtensionFieldTypes { return emptyExtensionTypes{} }
|
||||
|
||||
type emptyExtensionTypes struct{}
|
||||
|
||||
|
@ -16,11 +16,11 @@ import (
|
||||
type fieldInfo struct {
|
||||
// TODO: specialize marshal and unmarshal functions?
|
||||
|
||||
has func(pointer) bool
|
||||
get func(pointer) pref.Value
|
||||
set func(pointer, pref.Value)
|
||||
clear func(pointer)
|
||||
mutable func(pointer) pref.Mutable
|
||||
has func(pointer) bool
|
||||
get func(pointer) pref.Value
|
||||
set func(pointer, pref.Value)
|
||||
clear func(pointer)
|
||||
newMessage func() pref.Message
|
||||
}
|
||||
|
||||
func fieldInfoForWeak(fd pref.FieldDescriptor, fs reflect.StructField) fieldInfo {
|
||||
@ -86,18 +86,9 @@ func fieldInfoForOneof(fd pref.FieldDescriptor, fs reflect.StructField, ot refle
|
||||
}
|
||||
rv.Set(reflect.Zero(rv.Type()))
|
||||
},
|
||||
mutable: func(p pointer) pref.Mutable {
|
||||
// Mutable is only valid for messages and panics for other kinds.
|
||||
rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem()
|
||||
if rv.IsNil() || rv.Elem().Type().Elem() != ot {
|
||||
rv.Set(reflect.New(ot))
|
||||
}
|
||||
rv = rv.Elem().Elem().Field(0)
|
||||
if rv.IsNil() {
|
||||
pv := pref.ValueOf(conv.MessageType.New().ProtoReflect())
|
||||
rv.Set(conv.GoValueOf(pv))
|
||||
}
|
||||
return conv.PBValueOf(rv).Message()
|
||||
newMessage: func() pref.Message {
|
||||
// This is only valid for messages and panics for other kinds.
|
||||
return conv.MessageType.New().ProtoReflect()
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -135,10 +126,6 @@ func fieldInfoForMap(fd pref.FieldDescriptor, fs reflect.StructField) fieldInfo
|
||||
rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem()
|
||||
rv.Set(reflect.Zero(rv.Type()))
|
||||
},
|
||||
mutable: func(p pointer) pref.Mutable {
|
||||
v := p.Apply(fieldOffset).AsIfaceOf(fs.Type)
|
||||
return pvalue.MapOf(v, keyConv, valConv)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -174,10 +161,6 @@ func fieldInfoForList(fd pref.FieldDescriptor, fs reflect.StructField) fieldInfo
|
||||
rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem()
|
||||
rv.Set(reflect.Zero(rv.Type()))
|
||||
},
|
||||
mutable: func(p pointer) pref.Mutable {
|
||||
v := p.Apply(fieldOffset).AsIfaceOf(fs.Type)
|
||||
return pvalue.ListOf(v, conv)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -253,9 +236,6 @@ func fieldInfoForScalar(fd pref.FieldDescriptor, fs reflect.StructField) fieldIn
|
||||
rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem()
|
||||
rv.Set(reflect.Zero(rv.Type()))
|
||||
},
|
||||
mutable: func(p pointer) pref.Mutable {
|
||||
panic("invalid mutable call")
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -293,14 +273,8 @@ func fieldInfoForMessage(fd pref.FieldDescriptor, fs reflect.StructField) fieldI
|
||||
rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem()
|
||||
rv.Set(reflect.Zero(rv.Type()))
|
||||
},
|
||||
mutable: func(p pointer) pref.Mutable {
|
||||
// Mutable is only valid for messages and panics for other kinds.
|
||||
rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem()
|
||||
if rv.IsNil() {
|
||||
pv := pref.ValueOf(conv.MessageType.New().ProtoReflect())
|
||||
rv.Set(conv.GoValueOf(pv))
|
||||
}
|
||||
return conv.PBValueOf(rv).Message()
|
||||
newMessage: func() pref.Message {
|
||||
return conv.MessageType.New().ProtoReflect()
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -229,7 +229,6 @@ func (m *ScalarProto2) KnownFields() pref.KnownFields { return scalarProto2T
|
||||
func (m *ScalarProto2) UnknownFields() pref.UnknownFields { return scalarProto2Type.UnknownFieldsOf(m) }
|
||||
func (m *ScalarProto2) Interface() pref.ProtoMessage { return m }
|
||||
func (m *ScalarProto2) ProtoReflect() pref.Message { return m }
|
||||
func (m *ScalarProto2) ProtoMutable() {}
|
||||
|
||||
func TestScalarProto2(t *testing.T) {
|
||||
testMessage(t, nil, &ScalarProto2{}, messageOps{
|
||||
@ -336,7 +335,6 @@ func (m *ScalarProto3) KnownFields() pref.KnownFields { return scalarProto3T
|
||||
func (m *ScalarProto3) UnknownFields() pref.UnknownFields { return scalarProto3Type.UnknownFieldsOf(m) }
|
||||
func (m *ScalarProto3) Interface() pref.ProtoMessage { return m }
|
||||
func (m *ScalarProto3) ProtoReflect() pref.Message { return m }
|
||||
func (m *ScalarProto3) ProtoMutable() {}
|
||||
|
||||
func TestScalarProto3(t *testing.T) {
|
||||
testMessage(t, nil, &ScalarProto3{}, messageOps{
|
||||
@ -454,7 +452,6 @@ func (m *ListScalars) KnownFields() pref.KnownFields { return listScalarsTyp
|
||||
func (m *ListScalars) UnknownFields() pref.UnknownFields { return listScalarsType.UnknownFieldsOf(m) }
|
||||
func (m *ListScalars) Interface() pref.ProtoMessage { return m }
|
||||
func (m *ListScalars) ProtoReflect() pref.Message { return m }
|
||||
func (m *ListScalars) ProtoMutable() {}
|
||||
|
||||
func TestListScalars(t *testing.T) {
|
||||
empty := &ListScalars{}
|
||||
@ -645,7 +642,6 @@ func (m *MapScalars) KnownFields() pref.KnownFields { return mapScalarsType.
|
||||
func (m *MapScalars) UnknownFields() pref.UnknownFields { return mapScalarsType.UnknownFieldsOf(m) }
|
||||
func (m *MapScalars) Interface() pref.ProtoMessage { return m }
|
||||
func (m *MapScalars) ProtoReflect() pref.Message { return m }
|
||||
func (m *MapScalars) ProtoMutable() {}
|
||||
|
||||
func TestMapScalars(t *testing.T) {
|
||||
empty := &MapScalars{}
|
||||
@ -804,7 +800,6 @@ func (m *OneofScalars) KnownFields() pref.KnownFields { return oneofScalarsT
|
||||
func (m *OneofScalars) UnknownFields() pref.UnknownFields { return oneofScalarsType.UnknownFieldsOf(m) }
|
||||
func (m *OneofScalars) Interface() pref.ProtoMessage { return m }
|
||||
func (m *OneofScalars) ProtoReflect() pref.Message { return m }
|
||||
func (m *OneofScalars) ProtoMutable() {}
|
||||
|
||||
func (*OneofScalars) XXX_OneofWrappers() []interface{} {
|
||||
return []interface{}{
|
||||
@ -1030,7 +1025,6 @@ func (m *EnumMessages) KnownFields() pref.KnownFields { return enumMessagesT
|
||||
func (m *EnumMessages) UnknownFields() pref.UnknownFields { return enumMessagesType.UnknownFieldsOf(m) }
|
||||
func (m *EnumMessages) Interface() pref.ProtoMessage { return m }
|
||||
func (m *EnumMessages) ProtoReflect() pref.Message { return m }
|
||||
func (m *EnumMessages) ProtoMutable() {}
|
||||
|
||||
func (*EnumMessages) XXX_OneofWrappers() []interface{} {
|
||||
return []interface{}{
|
||||
@ -1223,7 +1217,10 @@ func testMessage(t *testing.T, p path, m pref.Message, tt messageOps) {
|
||||
case messageFields:
|
||||
for n, tt := range op {
|
||||
p.Push(int(n))
|
||||
testMessage(t, p, fs.Mutable(n).(pref.Message), tt)
|
||||
if !fs.Has(n) {
|
||||
fs.Set(n, V(fs.NewMessage(n)))
|
||||
}
|
||||
testMessage(t, p, fs.Get(n).Message(), tt)
|
||||
p.Pop()
|
||||
}
|
||||
case listFields:
|
||||
@ -1285,7 +1282,9 @@ func testLists(t *testing.T, p path, v pref.List, tt listOps) {
|
||||
v.Append(e)
|
||||
}
|
||||
case appendMessageList:
|
||||
testMessage(t, p, v.MutableAppend().(pref.Message), messageOps(op))
|
||||
m := v.NewMessage().ProtoReflect()
|
||||
v.Append(V(m))
|
||||
testMessage(t, p, m, messageOps(op))
|
||||
case truncList:
|
||||
v.Truncate(int(op))
|
||||
default:
|
||||
@ -1335,7 +1334,11 @@ func testMaps(t *testing.T, p path, m pref.Map, tt mapOps) {
|
||||
}
|
||||
case messageMap:
|
||||
for k, tt := range op {
|
||||
testMessage(t, p, m.Mutable(V(k).MapKey()).(pref.Message), tt)
|
||||
mk := V(k).MapKey()
|
||||
if !m.Has(mk) {
|
||||
m.Set(mk, V(m.NewMessage()))
|
||||
}
|
||||
testMessage(t, p, m.Get(mk).Message(), tt)
|
||||
}
|
||||
case rangeMap:
|
||||
got := map[interface{}]pref.Value{}
|
||||
|
@ -39,20 +39,12 @@ func (ls listReflect) Set(i int, v pref.Value) {
|
||||
func (ls listReflect) Append(v pref.Value) {
|
||||
ls.v.Elem().Set(reflect.Append(ls.v.Elem(), ls.conv.GoValueOf(v)))
|
||||
}
|
||||
func (ls listReflect) Mutable(i int) pref.Mutable {
|
||||
// Mutable is only valid for messages and panics for other kinds.
|
||||
return ls.conv.PBValueOf(ls.v.Elem().Index(i)).Message()
|
||||
}
|
||||
func (ls listReflect) MutableAppend() pref.Mutable {
|
||||
// MutableAppend is only valid for messages and panics for other kinds.
|
||||
pv := pref.ValueOf(ls.conv.MessageType.New().ProtoReflect())
|
||||
ls.v.Elem().Set(reflect.Append(ls.v.Elem(), ls.conv.GoValueOf(pv)))
|
||||
return pv.Message()
|
||||
}
|
||||
func (ls listReflect) Truncate(i int) {
|
||||
ls.v.Elem().Set(ls.v.Elem().Slice(0, i))
|
||||
}
|
||||
func (ls listReflect) NewMessage() pref.ProtoMessage {
|
||||
return ls.conv.MessageType.New()
|
||||
}
|
||||
func (ls listReflect) ProtoUnwrap() interface{} {
|
||||
return ls.v.Interface()
|
||||
}
|
||||
func (ls listReflect) ProtoMutable() {}
|
||||
|
@ -62,20 +62,6 @@ func (ms mapReflect) Clear(k pref.MapKey) {
|
||||
rk := ms.keyConv.GoValueOf(k.Value())
|
||||
ms.v.Elem().SetMapIndex(rk, reflect.Value{})
|
||||
}
|
||||
func (ms mapReflect) Mutable(k pref.MapKey) pref.Mutable {
|
||||
// Mutable is only valid for messages and panics for other kinds.
|
||||
if ms.v.Elem().IsNil() {
|
||||
ms.v.Elem().Set(reflect.MakeMap(ms.v.Elem().Type()))
|
||||
}
|
||||
rk := ms.keyConv.GoValueOf(k.Value())
|
||||
rv := ms.v.Elem().MapIndex(rk)
|
||||
if !rv.IsValid() {
|
||||
pv := pref.ValueOf(ms.valConv.MessageType.New().ProtoReflect())
|
||||
rv = ms.valConv.GoValueOf(pv)
|
||||
ms.v.Elem().SetMapIndex(rk, rv)
|
||||
}
|
||||
return ms.valConv.PBValueOf(rv).Message()
|
||||
}
|
||||
func (ms mapReflect) Range(f func(pref.MapKey, pref.Value) bool) {
|
||||
if ms.v.IsNil() {
|
||||
return
|
||||
@ -90,7 +76,9 @@ func (ms mapReflect) Range(f func(pref.MapKey, pref.Value) bool) {
|
||||
}
|
||||
}
|
||||
}
|
||||
func (ms mapReflect) NewMessage() pref.ProtoMessage {
|
||||
return ms.valConv.MessageType.New()
|
||||
}
|
||||
func (ms mapReflect) ProtoUnwrap() interface{} {
|
||||
return ms.v.Interface()
|
||||
}
|
||||
func (ms mapReflect) ProtoMutable() {}
|
||||
|
@ -35,9 +35,6 @@ type Message interface {
|
||||
// Interface unwraps the message reflection interface and
|
||||
// returns the underlying proto.Message interface.
|
||||
Interface() ProtoMessage
|
||||
|
||||
// ProtoMutable is a marker method to implement the Mutable interface.
|
||||
ProtoMutable()
|
||||
}
|
||||
|
||||
// KnownFields provides accessor and mutator methods for known fields.
|
||||
@ -95,11 +92,6 @@ type KnownFields interface {
|
||||
// a known field or extension field.
|
||||
Clear(FieldNumber)
|
||||
|
||||
// Mutable returns a reference value for a field with a given field number,
|
||||
// allocating a new instance if necessary.
|
||||
// It panics if the field is not a message, list, or map.
|
||||
Mutable(FieldNumber) Mutable
|
||||
|
||||
// Range iterates over every populated field in an undefined order,
|
||||
// calling f for each field number and value encountered.
|
||||
// Range calls f Len times unless f returns false, which stops iteration.
|
||||
@ -107,6 +99,11 @@ type KnownFields interface {
|
||||
// may only be performed on the current field number.
|
||||
Range(f func(FieldNumber, Value) bool)
|
||||
|
||||
// NewMessage returns a newly allocated empty message assignable to
|
||||
// the field of the given number.
|
||||
// It panics if the field is not a singular message.
|
||||
NewMessage(FieldNumber) ProtoMessage
|
||||
|
||||
// ExtensionTypes are extension field types that are known by this
|
||||
// specific message instance.
|
||||
ExtensionTypes() ExtensionFieldTypes
|
||||
@ -243,22 +240,14 @@ type List interface {
|
||||
// value aliases the source's memory in any way.
|
||||
Append(Value)
|
||||
|
||||
// Mutable returns a Mutable reference for the element with a given index,
|
||||
// allocating a new entry if necessary.
|
||||
// It panics if the element kind is not a message.
|
||||
Mutable(int) Mutable
|
||||
|
||||
// MutableAppend appends a new element and returns a mutable reference.
|
||||
// It panics if the element kind is not a message.
|
||||
MutableAppend() Mutable
|
||||
|
||||
// TODO: Should truncate accept two indexes similar to slicing?M
|
||||
// TODO: Should truncate accept two indexes similar to slicing?
|
||||
|
||||
// Truncate truncates the list to a smaller length.
|
||||
Truncate(int)
|
||||
|
||||
// ProtoMutable is a marker method to implement the Mutable interface.
|
||||
ProtoMutable()
|
||||
// NewMessage returns a newly allocated empty message assignable to a list entry.
|
||||
// It panics if the list entry type is not a message.
|
||||
NewMessage() ProtoMessage
|
||||
}
|
||||
|
||||
// Map is an unordered, associative map. Only elements within the map
|
||||
@ -289,11 +278,6 @@ type Map interface {
|
||||
// The operation does nothing if there is no entry associated with the key.
|
||||
Clear(MapKey)
|
||||
|
||||
// Mutable returns a Mutable reference for the element with a given key,
|
||||
// allocating a new entry if necessary.
|
||||
// It panics if the element kind is not a message.
|
||||
Mutable(MapKey) Mutable
|
||||
|
||||
// Range iterates over every map entry in an undefined order,
|
||||
// calling f for each key and value encountered.
|
||||
// Range calls f Len times unless f returns false, which stops iteration.
|
||||
@ -301,12 +285,7 @@ type Map interface {
|
||||
// may only be performed on the current map key.
|
||||
Range(f func(MapKey, Value) bool)
|
||||
|
||||
// ProtoMutable is a marker method to implement the Mutable interface.
|
||||
ProtoMutable()
|
||||
}
|
||||
|
||||
// Mutable is a mutable reference, where mutate operations also affect
|
||||
// the backing store. Possible Mutable types: Message, List, or Map.
|
||||
type Mutable interface {
|
||||
ProtoMutable()
|
||||
// NewMessage returns a newly allocated empty message assignable to a map value.
|
||||
// It panics if the map value type is not a message.
|
||||
NewMessage() ProtoMessage
|
||||
}
|
||||
|
@ -432,7 +432,6 @@ func (m xxx_FileDescriptorSet) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_FileDescriptorSet) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_FileDescriptorSet) ProtoMutable() {}
|
||||
|
||||
func (m *FileDescriptorSet) Reset() { *m = FileDescriptorSet{} }
|
||||
func (m *FileDescriptorSet) String() string { return protoapi.CompactTextString(m) }
|
||||
@ -495,7 +494,6 @@ func (m xxx_FileDescriptorProto) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_FileDescriptorProto) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_FileDescriptorProto) ProtoMutable() {}
|
||||
|
||||
func (m *FileDescriptorProto) Reset() { *m = FileDescriptorProto{} }
|
||||
func (m *FileDescriptorProto) String() string { return protoapi.CompactTextString(m) }
|
||||
@ -624,7 +622,6 @@ func (m xxx_DescriptorProto) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_DescriptorProto) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_DescriptorProto) ProtoMutable() {}
|
||||
|
||||
func (m *DescriptorProto) Reset() { *m = DescriptorProto{} }
|
||||
func (m *DescriptorProto) String() string { return protoapi.CompactTextString(m) }
|
||||
@ -729,7 +726,6 @@ func (m xxx_ExtensionRangeOptions) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_ExtensionRangeOptions) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_ExtensionRangeOptions) ProtoMutable() {}
|
||||
|
||||
func (m *ExtensionRangeOptions) Reset() { *m = ExtensionRangeOptions{} }
|
||||
func (m *ExtensionRangeOptions) String() string { return protoapi.CompactTextString(m) }
|
||||
@ -807,7 +803,6 @@ func (m xxx_FieldDescriptorProto) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_FieldDescriptorProto) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_FieldDescriptorProto) ProtoMutable() {}
|
||||
|
||||
func (m *FieldDescriptorProto) Reset() { *m = FieldDescriptorProto{} }
|
||||
func (m *FieldDescriptorProto) String() string { return protoapi.CompactTextString(m) }
|
||||
@ -912,7 +907,6 @@ func (m xxx_OneofDescriptorProto) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_OneofDescriptorProto) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_OneofDescriptorProto) ProtoMutable() {}
|
||||
|
||||
func (m *OneofDescriptorProto) Reset() { *m = OneofDescriptorProto{} }
|
||||
func (m *OneofDescriptorProto) String() string { return protoapi.CompactTextString(m) }
|
||||
@ -969,7 +963,6 @@ func (m xxx_EnumDescriptorProto) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_EnumDescriptorProto) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_EnumDescriptorProto) ProtoMutable() {}
|
||||
|
||||
func (m *EnumDescriptorProto) Reset() { *m = EnumDescriptorProto{} }
|
||||
func (m *EnumDescriptorProto) String() string { return protoapi.CompactTextString(m) }
|
||||
@ -1040,7 +1033,6 @@ func (m xxx_EnumValueDescriptorProto) UnknownFields() protoreflect.UnknownFields
|
||||
func (m xxx_EnumValueDescriptorProto) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_EnumValueDescriptorProto) ProtoMutable() {}
|
||||
|
||||
func (m *EnumValueDescriptorProto) Reset() { *m = EnumValueDescriptorProto{} }
|
||||
func (m *EnumValueDescriptorProto) String() string { return protoapi.CompactTextString(m) }
|
||||
@ -1097,7 +1089,6 @@ func (m xxx_ServiceDescriptorProto) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_ServiceDescriptorProto) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_ServiceDescriptorProto) ProtoMutable() {}
|
||||
|
||||
func (m *ServiceDescriptorProto) Reset() { *m = ServiceDescriptorProto{} }
|
||||
func (m *ServiceDescriptorProto) String() string { return protoapi.CompactTextString(m) }
|
||||
@ -1161,7 +1152,6 @@ func (m xxx_MethodDescriptorProto) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_MethodDescriptorProto) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_MethodDescriptorProto) ProtoMutable() {}
|
||||
|
||||
func (m *MethodDescriptorProto) Reset() { *m = MethodDescriptorProto{} }
|
||||
func (m *MethodDescriptorProto) String() string { return protoapi.CompactTextString(m) }
|
||||
@ -1323,7 +1313,6 @@ func (m xxx_FileOptions) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_FileOptions) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_FileOptions) ProtoMutable() {}
|
||||
|
||||
func (m *FileOptions) Reset() { *m = FileOptions{} }
|
||||
func (m *FileOptions) String() string { return protoapi.CompactTextString(m) }
|
||||
@ -1574,7 +1563,6 @@ func (m xxx_MessageOptions) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_MessageOptions) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_MessageOptions) ProtoMutable() {}
|
||||
|
||||
func (m *MessageOptions) Reset() { *m = MessageOptions{} }
|
||||
func (m *MessageOptions) String() string { return protoapi.CompactTextString(m) }
|
||||
@ -1715,7 +1703,6 @@ func (m xxx_FieldOptions) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_FieldOptions) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_FieldOptions) ProtoMutable() {}
|
||||
|
||||
func (m *FieldOptions) Reset() { *m = FieldOptions{} }
|
||||
func (m *FieldOptions) String() string { return protoapi.CompactTextString(m) }
|
||||
@ -1813,7 +1800,6 @@ func (m xxx_OneofOptions) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_OneofOptions) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_OneofOptions) ProtoMutable() {}
|
||||
|
||||
func (m *OneofOptions) Reset() { *m = OneofOptions{} }
|
||||
func (m *OneofOptions) String() string { return protoapi.CompactTextString(m) }
|
||||
@ -1871,7 +1857,6 @@ func (m xxx_EnumOptions) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_EnumOptions) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_EnumOptions) ProtoMutable() {}
|
||||
|
||||
func (m *EnumOptions) Reset() { *m = EnumOptions{} }
|
||||
func (m *EnumOptions) String() string { return protoapi.CompactTextString(m) }
|
||||
@ -1942,7 +1927,6 @@ func (m xxx_EnumValueOptions) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_EnumValueOptions) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_EnumValueOptions) ProtoMutable() {}
|
||||
|
||||
func (m *EnumValueOptions) Reset() { *m = EnumValueOptions{} }
|
||||
func (m *EnumValueOptions) String() string { return protoapi.CompactTextString(m) }
|
||||
@ -2006,7 +1990,6 @@ func (m xxx_ServiceOptions) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_ServiceOptions) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_ServiceOptions) ProtoMutable() {}
|
||||
|
||||
func (m *ServiceOptions) Reset() { *m = ServiceOptions{} }
|
||||
func (m *ServiceOptions) String() string { return protoapi.CompactTextString(m) }
|
||||
@ -2071,7 +2054,6 @@ func (m xxx_MethodOptions) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_MethodOptions) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_MethodOptions) ProtoMutable() {}
|
||||
|
||||
func (m *MethodOptions) Reset() { *m = MethodOptions{} }
|
||||
func (m *MethodOptions) String() string { return protoapi.CompactTextString(m) }
|
||||
@ -2150,7 +2132,6 @@ func (m xxx_UninterpretedOption) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_UninterpretedOption) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_UninterpretedOption) ProtoMutable() {}
|
||||
|
||||
func (m *UninterpretedOption) Reset() { *m = UninterpretedOption{} }
|
||||
func (m *UninterpretedOption) String() string { return protoapi.CompactTextString(m) }
|
||||
@ -2277,7 +2258,6 @@ func (m xxx_SourceCodeInfo) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_SourceCodeInfo) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_SourceCodeInfo) ProtoMutable() {}
|
||||
|
||||
func (m *SourceCodeInfo) Reset() { *m = SourceCodeInfo{} }
|
||||
func (m *SourceCodeInfo) String() string { return protoapi.CompactTextString(m) }
|
||||
@ -2322,7 +2302,6 @@ func (m xxx_GeneratedCodeInfo) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_GeneratedCodeInfo) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_GeneratedCodeInfo) ProtoMutable() {}
|
||||
|
||||
func (m *GeneratedCodeInfo) Reset() { *m = GeneratedCodeInfo{} }
|
||||
func (m *GeneratedCodeInfo) String() string { return protoapi.CompactTextString(m) }
|
||||
@ -2366,7 +2345,6 @@ func (m xxx_DescriptorProto_ExtensionRange) UnknownFields() protoreflect.Unknown
|
||||
func (m xxx_DescriptorProto_ExtensionRange) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_DescriptorProto_ExtensionRange) ProtoMutable() {}
|
||||
|
||||
func (m *DescriptorProto_ExtensionRange) Reset() { *m = DescriptorProto_ExtensionRange{} }
|
||||
func (m *DescriptorProto_ExtensionRange) String() string { return protoapi.CompactTextString(m) }
|
||||
@ -2426,7 +2404,6 @@ func (m xxx_DescriptorProto_ReservedRange) UnknownFields() protoreflect.UnknownF
|
||||
func (m xxx_DescriptorProto_ReservedRange) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_DescriptorProto_ReservedRange) ProtoMutable() {}
|
||||
|
||||
func (m *DescriptorProto_ReservedRange) Reset() { *m = DescriptorProto_ReservedRange{} }
|
||||
func (m *DescriptorProto_ReservedRange) String() string { return protoapi.CompactTextString(m) }
|
||||
@ -2482,7 +2459,6 @@ func (m xxx_EnumDescriptorProto_EnumReservedRange) UnknownFields() protoreflect.
|
||||
func (m xxx_EnumDescriptorProto_EnumReservedRange) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_EnumDescriptorProto_EnumReservedRange) ProtoMutable() {}
|
||||
|
||||
func (m *EnumDescriptorProto_EnumReservedRange) Reset() { *m = EnumDescriptorProto_EnumReservedRange{} }
|
||||
func (m *EnumDescriptorProto_EnumReservedRange) String() string { return protoapi.CompactTextString(m) }
|
||||
@ -2535,7 +2511,6 @@ func (m xxx_UninterpretedOption_NamePart) UnknownFields() protoreflect.UnknownFi
|
||||
func (m xxx_UninterpretedOption_NamePart) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_UninterpretedOption_NamePart) ProtoMutable() {}
|
||||
|
||||
func (m *UninterpretedOption_NamePart) Reset() { *m = UninterpretedOption_NamePart{} }
|
||||
func (m *UninterpretedOption_NamePart) String() string { return protoapi.CompactTextString(m) }
|
||||
@ -2661,7 +2636,6 @@ func (m xxx_SourceCodeInfo_Location) UnknownFields() protoreflect.UnknownFields
|
||||
func (m xxx_SourceCodeInfo_Location) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_SourceCodeInfo_Location) ProtoMutable() {}
|
||||
|
||||
func (m *SourceCodeInfo_Location) Reset() { *m = SourceCodeInfo_Location{} }
|
||||
func (m *SourceCodeInfo_Location) String() string { return protoapi.CompactTextString(m) }
|
||||
@ -2740,7 +2714,6 @@ func (m xxx_GeneratedCodeInfo_Annotation) UnknownFields() protoreflect.UnknownFi
|
||||
func (m xxx_GeneratedCodeInfo_Annotation) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_GeneratedCodeInfo_Annotation) ProtoMutable() {}
|
||||
|
||||
func (m *GeneratedCodeInfo_Annotation) Reset() { *m = GeneratedCodeInfo_Annotation{} }
|
||||
func (m *GeneratedCodeInfo_Annotation) String() string { return protoapi.CompactTextString(m) }
|
||||
|
@ -47,7 +47,6 @@ func (m xxx_Version) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_Version) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_Version) ProtoMutable() {}
|
||||
|
||||
func (m *Version) Reset() { *m = Version{} }
|
||||
func (m *Version) String() string { return proto.CompactTextString(m) }
|
||||
@ -149,7 +148,6 @@ func (m xxx_CodeGeneratorRequest) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_CodeGeneratorRequest) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_CodeGeneratorRequest) ProtoMutable() {}
|
||||
|
||||
func (m *CodeGeneratorRequest) Reset() { *m = CodeGeneratorRequest{} }
|
||||
func (m *CodeGeneratorRequest) String() string { return proto.CompactTextString(m) }
|
||||
@ -238,7 +236,6 @@ func (m xxx_CodeGeneratorResponse) UnknownFields() protoreflect.UnknownFields {
|
||||
func (m xxx_CodeGeneratorResponse) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_CodeGeneratorResponse) ProtoMutable() {}
|
||||
|
||||
func (m *CodeGeneratorResponse) Reset() { *m = CodeGeneratorResponse{} }
|
||||
func (m *CodeGeneratorResponse) String() string { return proto.CompactTextString(m) }
|
||||
@ -355,7 +352,6 @@ func (m xxx_CodeGeneratorResponse_File) UnknownFields() protoreflect.UnknownFiel
|
||||
func (m xxx_CodeGeneratorResponse_File) Interface() protoreflect.ProtoMessage {
|
||||
return m.m
|
||||
}
|
||||
func (m xxx_CodeGeneratorResponse_File) ProtoMutable() {}
|
||||
|
||||
func (m *CodeGeneratorResponse_File) Reset() { *m = CodeGeneratorResponse_File{} }
|
||||
func (m *CodeGeneratorResponse_File) String() string { return proto.CompactTextString(m) }
|
||||
|
Loading…
x
Reference in New Issue
Block a user