Skip to content

Commit

Permalink
Implicit isUnset for message fields, and move _fields to _MessageImpl…
Browse files Browse the repository at this point in the history
…ementationBase
  • Loading branch information
mrabiciu committed Dec 1, 2023
1 parent 1c5a664 commit 07aec96
Show file tree
Hide file tree
Showing 39 changed files with 14,805 additions and 15,152 deletions.
426 changes: 213 additions & 213 deletions FuzzTesting/Sources/FuzzCommon/fuzz_testing.pb.swift

Large diffs are not rendered by default.

1,424 changes: 741 additions & 683 deletions Protos/SwiftProtobufTests/generated_swift_names_enum_cases.proto

Large diffs are not rendered by default.

1,424 changes: 741 additions & 683 deletions Protos/SwiftProtobufTests/generated_swift_names_fields.proto

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Sources/Conformance/conformance.pb.swift
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ extension Conformance_ConformanceRequest: SwiftProtobuf.Message, SwiftProtobuf._
.singularEnum({ $0.requestedOutputFormat }, fieldNumber: 3, defaultValue: .unspecified),
.singularString({ $0.messageType }, fieldNumber: 4),
.singularEnum({ $0.testCategory }, fieldNumber: 5, defaultValue: .unspecifiedTest),
.singularMessage({ $0.jspbEncodingOptions }, fieldNumber: 6, isUnset: { $0._jspbEncodingOptions == nil }),
.singularMessage({ $0._jspbEncodingOptions }, fieldNumber: 6),
.oneOf({ $0.payload }) {
switch $0 {
case .jspbPayload:
Expand Down
72 changes: 36 additions & 36 deletions Sources/Conformance/test_messages_proto2.pb.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2749,13 +2749,13 @@ extension ProtobufTestMessages_Proto2_TestAllTypesProto2: SwiftProtobuf.Message,
.singularBool({ $0.optionalBool }, fieldNumber: 13, isUnset: { $0._storage._optionalBool == nil }),
.singularString({ $0.optionalString }, fieldNumber: 14, isUnset: { $0._storage._optionalString == nil }),
.singularBytes({ $0.optionalBytes }, fieldNumber: 15, isUnset: { $0._storage._optionalBytes == nil }),
.singularMessage({ $0.optionalNestedMessage }, fieldNumber: 18, isUnset: { $0._storage._optionalNestedMessage == nil }),
.singularMessage({ $0.optionalForeignMessage }, fieldNumber: 19, isUnset: { $0._storage._optionalForeignMessage == nil }),
.singularMessage({ $0._storage._optionalNestedMessage }, fieldNumber: 18),
.singularMessage({ $0._storage._optionalForeignMessage }, fieldNumber: 19),
.singularEnum({ $0.optionalNestedEnum }, fieldNumber: 21, isUnset: { $0._storage._optionalNestedEnum == nil }),
.singularEnum({ $0.optionalForeignEnum }, fieldNumber: 22, isUnset: { $0._storage._optionalForeignEnum == nil }),
.singularString({ $0.optionalStringPiece }, fieldNumber: 24, isUnset: { $0._storage._optionalStringPiece == nil }),
.singularString({ $0.optionalCord }, fieldNumber: 25, isUnset: { $0._storage._optionalCord == nil }),
.singularMessage({ $0.recursiveMessage }, fieldNumber: 27, isUnset: { $0._storage._recursiveMessage == nil }),
.singularMessage({ $0._storage._recursiveMessage }, fieldNumber: 27),
.repeatedInt32({ $0.repeatedInt32 }, fieldNumber: 31),
.repeatedInt64({ $0.repeatedInt64 }, fieldNumber: 32),
.repeatedUInt32({ $0.repeatedUint32 }, fieldNumber: 33),
Expand All @@ -2771,31 +2771,31 @@ extension ProtobufTestMessages_Proto2_TestAllTypesProto2: SwiftProtobuf.Message,
.repeatedBool({ $0.repeatedBool }, fieldNumber: 43),
.repeatedString({ $0.repeatedString }, fieldNumber: 44),
.repeatedBytes({ $0.repeatedBytes }, fieldNumber: 45),
.repeatedMessage({ $0.repeatedNestedMessage }, fieldNumber: 48),
.repeatedMessage({ $0.repeatedForeignMessage }, fieldNumber: 49),
.repeatedMessage({ $0._storage._repeatedNestedMessage }, fieldNumber: 48),
.repeatedMessage({ $0._storage._repeatedForeignMessage }, fieldNumber: 49),
.repeatedEnum({ $0.repeatedNestedEnum }, fieldNumber: 51),
.repeatedEnum({ $0.repeatedForeignEnum }, fieldNumber: 52),
.repeatedString({ $0.repeatedStringPiece }, fieldNumber: 54),
.repeatedString({ $0.repeatedCord }, fieldNumber: 55),
.map(type: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufInt32,SwiftProtobuf.ProtobufInt32>.self, { $0.mapInt32Int32 }, fieldNumber: 56),
.map(type: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufInt64,SwiftProtobuf.ProtobufInt64>.self, { $0.mapInt64Int64 }, fieldNumber: 57),
.map(type: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufUInt32,SwiftProtobuf.ProtobufUInt32>.self, { $0.mapUint32Uint32 }, fieldNumber: 58),
.map(type: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufUInt64,SwiftProtobuf.ProtobufUInt64>.self, { $0.mapUint64Uint64 }, fieldNumber: 59),
.map(type: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufSInt32,SwiftProtobuf.ProtobufSInt32>.self, { $0.mapSint32Sint32 }, fieldNumber: 60),
.map(type: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufSInt64,SwiftProtobuf.ProtobufSInt64>.self, { $0.mapSint64Sint64 }, fieldNumber: 61),
.map(type: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufFixed32,SwiftProtobuf.ProtobufFixed32>.self, { $0.mapFixed32Fixed32 }, fieldNumber: 62),
.map(type: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufFixed64,SwiftProtobuf.ProtobufFixed64>.self, { $0.mapFixed64Fixed64 }, fieldNumber: 63),
.map(type: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufSFixed32,SwiftProtobuf.ProtobufSFixed32>.self, { $0.mapSfixed32Sfixed32 }, fieldNumber: 64),
.map(type: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufSFixed64,SwiftProtobuf.ProtobufSFixed64>.self, { $0.mapSfixed64Sfixed64 }, fieldNumber: 65),
.map(type: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufInt32,SwiftProtobuf.ProtobufFloat>.self, { $0.mapInt32Float }, fieldNumber: 66),
.map(type: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufInt32,SwiftProtobuf.ProtobufDouble>.self, { $0.mapInt32Double }, fieldNumber: 67),
.map(type: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufBool,SwiftProtobuf.ProtobufBool>.self, { $0.mapBoolBool }, fieldNumber: 68),
.map(type: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufString,SwiftProtobuf.ProtobufString>.self, { $0.mapStringString }, fieldNumber: 69),
.map(type: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufString,SwiftProtobuf.ProtobufBytes>.self, { $0.mapStringBytes }, fieldNumber: 70),
.map(type: SwiftProtobuf._ProtobufMessageMap<SwiftProtobuf.ProtobufString,ProtobufTestMessages_Proto2_TestAllTypesProto2.NestedMessage>.self, { $0.mapStringNestedMessage }, fieldNumber: 71),
.map(type: SwiftProtobuf._ProtobufMessageMap<SwiftProtobuf.ProtobufString,ProtobufTestMessages_Proto2_ForeignMessageProto2>.self, { $0.mapStringForeignMessage }, fieldNumber: 72),
.map(type: SwiftProtobuf._ProtobufEnumMap<SwiftProtobuf.ProtobufString,ProtobufTestMessages_Proto2_TestAllTypesProto2.NestedEnum>.self, { $0.mapStringNestedEnum }, fieldNumber: 73),
.map(type: SwiftProtobuf._ProtobufEnumMap<SwiftProtobuf.ProtobufString,ProtobufTestMessages_Proto2_ForeignEnumProto2>.self, { $0.mapStringForeignEnum }, fieldNumber: 74),
.map(type: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufInt32,SwiftProtobuf.ProtobufInt32>.self, { $0._storage._mapInt32Int32 }, fieldNumber: 56),
.map(type: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufInt64,SwiftProtobuf.ProtobufInt64>.self, { $0._storage._mapInt64Int64 }, fieldNumber: 57),
.map(type: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufUInt32,SwiftProtobuf.ProtobufUInt32>.self, { $0._storage._mapUint32Uint32 }, fieldNumber: 58),
.map(type: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufUInt64,SwiftProtobuf.ProtobufUInt64>.self, { $0._storage._mapUint64Uint64 }, fieldNumber: 59),
.map(type: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufSInt32,SwiftProtobuf.ProtobufSInt32>.self, { $0._storage._mapSint32Sint32 }, fieldNumber: 60),
.map(type: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufSInt64,SwiftProtobuf.ProtobufSInt64>.self, { $0._storage._mapSint64Sint64 }, fieldNumber: 61),
.map(type: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufFixed32,SwiftProtobuf.ProtobufFixed32>.self, { $0._storage._mapFixed32Fixed32 }, fieldNumber: 62),
.map(type: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufFixed64,SwiftProtobuf.ProtobufFixed64>.self, { $0._storage._mapFixed64Fixed64 }, fieldNumber: 63),
.map(type: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufSFixed32,SwiftProtobuf.ProtobufSFixed32>.self, { $0._storage._mapSfixed32Sfixed32 }, fieldNumber: 64),
.map(type: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufSFixed64,SwiftProtobuf.ProtobufSFixed64>.self, { $0._storage._mapSfixed64Sfixed64 }, fieldNumber: 65),
.map(type: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufInt32,SwiftProtobuf.ProtobufFloat>.self, { $0._storage._mapInt32Float }, fieldNumber: 66),
.map(type: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufInt32,SwiftProtobuf.ProtobufDouble>.self, { $0._storage._mapInt32Double }, fieldNumber: 67),
.map(type: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufBool,SwiftProtobuf.ProtobufBool>.self, { $0._storage._mapBoolBool }, fieldNumber: 68),
.map(type: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufString,SwiftProtobuf.ProtobufString>.self, { $0._storage._mapStringString }, fieldNumber: 69),
.map(type: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufString,SwiftProtobuf.ProtobufBytes>.self, { $0._storage._mapStringBytes }, fieldNumber: 70),
.map(type: SwiftProtobuf._ProtobufMessageMap<SwiftProtobuf.ProtobufString,ProtobufTestMessages_Proto2_TestAllTypesProto2.NestedMessage>.self, { $0._storage._mapStringNestedMessage }, fieldNumber: 71),
.map(type: SwiftProtobuf._ProtobufMessageMap<SwiftProtobuf.ProtobufString,ProtobufTestMessages_Proto2_ForeignMessageProto2>.self, { $0._storage._mapStringForeignMessage }, fieldNumber: 72),
.map(type: SwiftProtobuf._ProtobufEnumMap<SwiftProtobuf.ProtobufString,ProtobufTestMessages_Proto2_TestAllTypesProto2.NestedEnum>.self, { $0._storage._mapStringNestedEnum }, fieldNumber: 73),
.map(type: SwiftProtobuf._ProtobufEnumMap<SwiftProtobuf.ProtobufString,ProtobufTestMessages_Proto2_ForeignEnumProto2>.self, { $0._storage._mapStringForeignEnum }, fieldNumber: 74),
.packedInt32({ $0.packedInt32 }, fieldNumber: 75),
.packedInt64({ $0.packedInt64 }, fieldNumber: 76),
.packedUInt32({ $0.packedUint32 }, fieldNumber: 77),
Expand Down Expand Up @@ -2847,7 +2847,7 @@ extension ProtobufTestMessages_Proto2_TestAllTypesProto2: SwiftProtobuf.Message,
}
},
.extensionFields({ $0._protobuf_extensionFieldValues }, start: 120, end: 201),
.singularGroup({ $0.data }, fieldNumber: 201, isUnset: { $0._storage._data == nil }),
.singularGroup({ $0._storage._data }, fieldNumber: 201),
.singularInt32({ $0.defaultInt32 }, fieldNumber: 241, isUnset: { $0._storage._defaultInt32 == nil }),
.singularInt64({ $0.defaultInt64 }, fieldNumber: 242, isUnset: { $0._storage._defaultInt64 == nil }),
.singularUInt32({ $0.defaultUint32 }, fieldNumber: 243, isUnset: { $0._storage._defaultUint32 == nil }),
Expand Down Expand Up @@ -2883,7 +2883,7 @@ extension ProtobufTestMessages_Proto2_TestAllTypesProto2: SwiftProtobuf.Message,
.singularInt32({ $0.fieldName18__ }, fieldNumber: 418, isUnset: { $0._storage._fieldName18__ == nil }),
]
private static let _oneOfField_oneofUint32: Field<Self> = .singularUInt32({ $0.oneofUint32 }, fieldNumber: 111, isUnset: { _ in false })
private static let _oneOfField_oneofNestedMessage: Field<Self> = .singularMessage({ $0.oneofNestedMessage }, fieldNumber: 112, isUnset: { _ in false })
private static let _oneOfField_oneofNestedMessage: Field<Self> = .singularMessage({ $0.oneofNestedMessage }, fieldNumber: 112)
private static let _oneOfField_oneofString: Field<Self> = .singularString({ $0.oneofString }, fieldNumber: 113, isUnset: { _ in false })
private static let _oneOfField_oneofBytes: Field<Self> = .singularBytes({ $0.oneofBytes }, fieldNumber: 114, isUnset: { _ in false })
private static let _oneOfField_oneofBool: Field<Self> = .singularBool({ $0.oneofBool }, fieldNumber: 115, isUnset: { _ in false })
Expand Down Expand Up @@ -3095,7 +3095,7 @@ extension ProtobufTestMessages_Proto2_TestAllTypesProto2.NestedMessage: SwiftPro

static let _fields: [Field<Self>] = [
.singularInt32({ $0.a }, fieldNumber: 1, isUnset: { $0._storage._a == nil }),
.singularMessage({ $0.corecursive }, fieldNumber: 2, isUnset: { $0._storage._corecursive == nil }),
.singularMessage({ $0._storage._corecursive }, fieldNumber: 2),
]


Expand Down Expand Up @@ -3295,8 +3295,8 @@ extension ProtobufTestMessages_Proto2_UnknownToTestAllTypes: SwiftProtobuf.Messa
static let _fields: [Field<Self>] = [
.singularInt32({ $0.optionalInt32 }, fieldNumber: 1001, isUnset: { $0._optionalInt32 == nil }),
.singularString({ $0.optionalString }, fieldNumber: 1002, isUnset: { $0._optionalString == nil }),
.singularMessage({ $0.nestedMessage }, fieldNumber: 1003, isUnset: { $0._nestedMessage == nil }),
.singularGroup({ $0.optionalGroup }, fieldNumber: 1004, isUnset: { $0._optionalGroup == nil }),
.singularMessage({ $0._nestedMessage }, fieldNumber: 1003),
.singularGroup({ $0._optionalGroup }, fieldNumber: 1004),
.singularBool({ $0.optionalBool }, fieldNumber: 1006, isUnset: { $0._optionalBool == nil }),
.repeatedInt32({ $0.repeatedInt32 }, fieldNumber: 1011),
]
Expand Down Expand Up @@ -3716,16 +3716,16 @@ extension ProtobufTestMessages_Proto2_TestAllRequiredTypesProto2: SwiftProtobuf.
.singularBool({ $0.requiredBool }, fieldNumber: 13, isUnset: { $0._storage._requiredBool == nil }),
.singularString({ $0.requiredString }, fieldNumber: 14, isUnset: { $0._storage._requiredString == nil }),
.singularBytes({ $0.requiredBytes }, fieldNumber: 15, isUnset: { $0._storage._requiredBytes == nil }),
.singularMessage({ $0.requiredNestedMessage }, fieldNumber: 18, isUnset: { $0._storage._requiredNestedMessage == nil }),
.singularMessage({ $0.requiredForeignMessage }, fieldNumber: 19, isUnset: { $0._storage._requiredForeignMessage == nil }),
.singularMessage({ $0._storage._requiredNestedMessage }, fieldNumber: 18),
.singularMessage({ $0._storage._requiredForeignMessage }, fieldNumber: 19),
.singularEnum({ $0.requiredNestedEnum }, fieldNumber: 21, isUnset: { $0._storage._requiredNestedEnum == nil }),
.singularEnum({ $0.requiredForeignEnum }, fieldNumber: 22, isUnset: { $0._storage._requiredForeignEnum == nil }),
.singularString({ $0.requiredStringPiece }, fieldNumber: 24, isUnset: { $0._storage._requiredStringPiece == nil }),
.singularString({ $0.requiredCord }, fieldNumber: 25, isUnset: { $0._storage._requiredCord == nil }),
.singularMessage({ $0.recursiveMessage }, fieldNumber: 27, isUnset: { $0._storage._recursiveMessage == nil }),
.singularMessage({ $0.optionalRecursiveMessage }, fieldNumber: 28, isUnset: { $0._storage._optionalRecursiveMessage == nil }),
.singularMessage({ $0._storage._recursiveMessage }, fieldNumber: 27),
.singularMessage({ $0._storage._optionalRecursiveMessage }, fieldNumber: 28),
.extensionFields({ $0._protobuf_extensionFieldValues }, start: 120, end: 201),
.singularGroup({ $0.data }, fieldNumber: 201, isUnset: { $0._storage._data == nil }),
.singularGroup({ $0._storage._data }, fieldNumber: 201),
.singularInt32({ $0.defaultInt32 }, fieldNumber: 241, isUnset: { $0._storage._defaultInt32 == nil }),
.singularInt64({ $0.defaultInt64 }, fieldNumber: 242, isUnset: { $0._storage._defaultInt64 == nil }),
.singularUInt32({ $0.defaultUint32 }, fieldNumber: 243, isUnset: { $0._storage._defaultUint32 == nil }),
Expand Down Expand Up @@ -3867,8 +3867,8 @@ extension ProtobufTestMessages_Proto2_TestAllRequiredTypesProto2.NestedMessage:

static let _fields: [Field<Self>] = [
.singularInt32({ $0.a }, fieldNumber: 1, isUnset: { $0._storage._a == nil }),
.singularMessage({ $0.corecursive }, fieldNumber: 2, isUnset: { $0._storage._corecursive == nil }),
.singularMessage({ $0.optionalCorecursive }, fieldNumber: 3, isUnset: { $0._storage._optionalCorecursive == nil }),
.singularMessage({ $0._storage._corecursive }, fieldNumber: 2),
.singularMessage({ $0._storage._optionalCorecursive }, fieldNumber: 3),
]


Expand Down
Loading

0 comments on commit 07aec96

Please sign in to comment.