From a7bdfd8559827238db1e0fd6c1fa1e4de9a10049 Mon Sep 17 00:00:00 2001 From: Dimitris Koutsogiorgas Date: Wed, 30 Aug 2023 16:20:37 -0700 Subject: [PATCH] [swift] Provide a default value for sub fields and common types as per proto spec --- .../src/test/swift/sample/Dinosaur.swift | 28 +- .../com/squareup/wire/swift/SwiftGenerator.kt | 56 ++- .../src/main/swift/ContainsDuration.swift | 7 +- .../src/main/swift/ContainsTimestamp.swift | 7 +- .../SwiftModuleThreeMessage.swift | 7 +- .../module_two/SwiftModuleTwoMessage.swift | 7 +- .../no-manifest/src/main/swift/AllTypes.swift | 341 ++++++++++-------- .../src/main/swift/DeprecatedProto.swift | 7 +- .../src/main/swift/EmbeddedMessage.swift | 7 +- .../src/main/swift/ExternalMessage.swift | 6 +- .../no-manifest/src/main/swift/FooBar.swift | 56 +-- .../src/main/swift/ForeignMessage.swift | 7 +- .../no-manifest/src/main/swift/Form.swift | 7 +- .../swift/MessageUsingMultipleEnums.swift | 14 +- .../src/main/swift/ModelEvaluation.swift | 14 +- .../src/main/swift/NestedVersionOne.swift | 7 +- .../src/main/swift/NestedVersionTwo.swift | 35 +- .../src/main/swift/OptionalEnumUser.swift | 7 +- .../src/main/swift/OuterMessage.swift | 14 +- .../no-manifest/src/main/swift/Percents.swift | 7 +- .../no-manifest/src/main/swift/Person.swift | 13 +- .../no-manifest/src/main/swift/Thing.swift | 7 +- .../src/main/swift/VersionOne.swift | 21 +- .../src/main/swift/VersionTwo.swift | 49 +-- ...LongProtoNameCausingBrokenLineBreaks.swift | 7 +- 25 files changed, 429 insertions(+), 309 deletions(-) diff --git a/wire-runtime-swift/src/test/swift/sample/Dinosaur.swift b/wire-runtime-swift/src/test/swift/sample/Dinosaur.swift index 385bc3960d..7aa69dd827 100644 --- a/wire-runtime-swift/src/test/swift/sample/Dinosaur.swift +++ b/wire-runtime-swift/src/test/swift/sample/Dinosaur.swift @@ -8,13 +8,17 @@ public struct Dinosaur { /** * Common name of this dinosaur, like "Stegosaurus". */ + @Defaulted(defaultValue: "") public var name: String? /** * URLs with images of this dinosaur. */ public var picture_urls: [String] = [] + @Defaulted(defaultValue: 0) public var length_meters: Double? + @Defaulted(defaultValue: 0) public var mass_kilograms: Double? + @Defaulted(defaultValue: Period.CRETACEOUS) public var period: Period? public var unknownFields: Foundation.Data = .init() @@ -36,11 +40,11 @@ extension Dinosaur { mass_kilograms: Swift.Double? = nil, period: Period? = nil ) { - self.name = name + self._name.wrappedValue = name self.picture_urls = picture_urls - self.length_meters = length_meters - self.mass_kilograms = mass_kilograms - self.period = period + self._length_meters.wrappedValue = length_meters + self._mass_kilograms.wrappedValue = mass_kilograms + self._period.wrappedValue = period } } @@ -91,11 +95,11 @@ extension Dinosaur : Proto2Codable { } self.unknownFields = try protoReader.endMessage(token: token) - self.name = name + self._name.wrappedValue = name self.picture_urls = picture_urls - self.length_meters = length_meters - self.mass_kilograms = mass_kilograms - self.period = period + self._length_meters.wrappedValue = length_meters + self._mass_kilograms.wrappedValue = mass_kilograms + self._period.wrappedValue = period } public func encode(to protoWriter: Wire.ProtoWriter) throws { @@ -114,11 +118,11 @@ extension Dinosaur : Codable { public init(from decoder: Swift.Decoder) throws { let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) - self.name = try container.decodeIfPresent(Swift.String.self, forKey: "name") + self._name.wrappedValue = try container.decodeIfPresent(Swift.String.self, forKey: "name") self.picture_urls = try container.decodeProtoArray(Swift.String.self, firstOfKeys: "pictureUrls", "picture_urls") - self.length_meters = try container.decodeIfPresent(Swift.Double.self, firstOfKeys: "lengthMeters", "length_meters") - self.mass_kilograms = try container.decodeIfPresent(Swift.Double.self, firstOfKeys: "massKilograms", "mass_kilograms") - self.period = try container.decodeIfPresent(Period.self, forKey: "period") + self._length_meters.wrappedValue = try container.decodeIfPresent(Swift.Double.self, firstOfKeys: "lengthMeters", "length_meters") + self._mass_kilograms.wrappedValue = try container.decodeIfPresent(Swift.Double.self, firstOfKeys: "massKilograms", "mass_kilograms") + self._period.wrappedValue = try container.decodeIfPresent(Period.self, forKey: "period") } public func encode(to encoder: Swift.Encoder) throws { diff --git a/wire-swift-generator/src/main/java/com/squareup/wire/swift/SwiftGenerator.kt b/wire-swift-generator/src/main/java/com/squareup/wire/swift/SwiftGenerator.kt index dc2ceaedad..6abfc88f93 100644 --- a/wire-swift-generator/src/main/java/com/squareup/wire/swift/SwiftGenerator.kt +++ b/wire-swift-generator/src/main/java/com/squareup/wire/swift/SwiftGenerator.kt @@ -158,6 +158,44 @@ class SwiftGenerator private constructor( else -> null } + private val Field.defaultedValue: CodeBlock? + get() { + when (val default = default) { + // identity values + null -> { + if (!isOptional) return null + if (type == ProtoType.ANY) return null + if (isMessage && !isRequiredParameter && !isCollection) { + val messageType = schema.getType(type!!) as MessageType + return if (messageType.fields.any { it.isRequiredParameter }) null else CodeBlock.of("%T()", messageType.typeName.makeNonOptional()) + } + if (isEnum) { + val enumType = schema.getType(type!!) as EnumType + return if (enumType.constants.getOrNull(0) != null) CodeBlock.of("%T.%L", typeName.makeNonOptional(), enumType.constants[0].name) else null + } + when (typeName.makeNonOptional()) { + BOOL -> return CodeBlock.of("%L", false) + INT -> return CodeBlock.of("%L", 0) + INT32 -> return CodeBlock.of("%L", 0) + INT64 -> return CodeBlock.of("%L", 0) + UINT32 -> return CodeBlock.of("%L", 0) + UINT64 -> return CodeBlock.of("%L", 0) + FLOAT -> return CodeBlock.of("%L", 0) + DOUBLE -> return CodeBlock.of("%L", 0) + STRING -> return CodeBlock.of("%S", "") + DATA -> return CodeBlock.of( + "%T(base64Encoded: %S)!", + FOUNDATION_DATA, + "".encode(charset = Charsets.ISO_8859_1).base64(), + ) + } + } + else -> return defaultFieldInitializer(type!!, default) + } + + return null + } + // see https://protobuf.dev/programming-guides/proto3/#default private val Field.proto3InitialValue: String get() = when { @@ -651,7 +689,7 @@ class SwiftGenerator private constructor( } } addStatement( - if (field.default != null) "_%N.wrappedValue = %L" else { "self.%N = %L" }, + if (!isIndirect(type, field) && field.defaultedValue != null) "self._%N.wrappedValue = %L" else { "self.%N = %L" }, field.name, initializer, ) @@ -831,7 +869,7 @@ class SwiftGenerator private constructor( .map { CodeBlock.of("%S", it) } .joinToCode() - val prefix = if (field.default != null) { "_%1N.wrappedValue" } else { "self.%1N" } + val prefix = if (!isIndirect(type, field) && field.defaultedValue != null) { "self._%1N.wrappedValue" } else { "self.%1N" } addStatement( "$prefix = try container.$decode($typeArg%2T.self, $forKeys: $keys)", field.name, @@ -1146,7 +1184,7 @@ class SwiftGenerator private constructor( .apply { type.fields.filter { it.isRequiredParameter }.forEach { field -> addStatement( - if (field.default != null) "_%1N.wrappedValue = %1N" else { "self.%1N = %1N" }, + if (!isIndirect(type, field) && field.defaultedValue != null) "self._%1N.wrappedValue = %1N" else { "self.%1N = %1N" }, field.name, ) } @@ -1172,7 +1210,7 @@ class SwiftGenerator private constructor( .apply { type.fields.forEach { field -> addStatement( - if (field.default != null) "_%1N.wrappedValue = %1N" else { "self.%1N = %1N" }, + if (!isIndirect(type, field) && field.defaultedValue != null) "self._%1N.wrappedValue = %1N" else { "self.%1N = %1N" }, field.name, ) } @@ -1224,10 +1262,9 @@ class SwiftGenerator private constructor( if (isIndirect(type, field)) { property.addAttribute(AttributeSpec.builder(indirect).build()) } - val default = field.default - if (default != null) { - val defaultValue = defaultFieldInitializer(field.type!!, default) - property.addAttribute(AttributeSpec.builder(defaulted).addArgument("defaultValue: $defaultValue").build()) + val defaultedValue = field.defaultedValue + if (!isIndirect(type, field) && defaultedValue != null) { + property.addAttribute(AttributeSpec.builder(defaulted).addArgument("defaultValue: $defaultedValue").build()) } if (field.isMap) { @@ -1278,7 +1315,8 @@ class SwiftGenerator private constructor( typeName == DOUBLE -> defaultValue.toDoubleFieldInitializer() typeName == STRING -> CodeBlock.of("%S", stringLiteralWithQuotes2(defaultValue.toString())) typeName == DATA -> CodeBlock.of( - "Foundation.Data(base64Encoded: %S)!", + "%T(base64Encoded: %S)!", + FOUNDATION_DATA, defaultValue.toString().encode(charset = Charsets.ISO_8859_1).base64(), ) protoType.isEnum -> CodeBlock.of("%T.%L", typeName, defaultValue) diff --git a/wire-tests-proto3-swift/src/main/swift/ContainsDuration.swift b/wire-tests-proto3-swift/src/main/swift/ContainsDuration.swift index ab4027b43b..ebc90b949e 100644 --- a/wire-tests-proto3-swift/src/main/swift/ContainsDuration.swift +++ b/wire-tests-proto3-swift/src/main/swift/ContainsDuration.swift @@ -5,6 +5,7 @@ import Wire public struct ContainsDuration { + @Defaulted(defaultValue: Duration()) public var duration: Duration? public var unknownFields: Foundation.Data = .init() @@ -20,7 +21,7 @@ extension ContainsDuration { @_disfavoredOverload @available(*, deprecated) public init(duration: Duration? = nil) { - self.duration = duration + self._duration.wrappedValue = duration } } @@ -63,7 +64,7 @@ extension ContainsDuration : Proto3Codable { } self.unknownFields = try protoReader.endMessage(token: token) - self.duration = duration + self._duration.wrappedValue = duration } public func encode(to protoWriter: Wire.ProtoWriter) throws { @@ -78,7 +79,7 @@ extension ContainsDuration : Codable { public init(from decoder: Swift.Decoder) throws { let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) - self.duration = try container.decodeIfPresent(Duration.self, forKey: "duration") + self._duration.wrappedValue = try container.decodeIfPresent(Duration.self, forKey: "duration") } public func encode(to encoder: Swift.Encoder) throws { diff --git a/wire-tests-proto3-swift/src/main/swift/ContainsTimestamp.swift b/wire-tests-proto3-swift/src/main/swift/ContainsTimestamp.swift index f38bd33a8a..351ea10b60 100644 --- a/wire-tests-proto3-swift/src/main/swift/ContainsTimestamp.swift +++ b/wire-tests-proto3-swift/src/main/swift/ContainsTimestamp.swift @@ -5,6 +5,7 @@ import Wire public struct ContainsTimestamp { + @Defaulted(defaultValue: Timestamp()) public var timestamp: Timestamp? public var unknownFields: Foundation.Data = .init() @@ -20,7 +21,7 @@ extension ContainsTimestamp { @_disfavoredOverload @available(*, deprecated) public init(timestamp: Timestamp? = nil) { - self.timestamp = timestamp + self._timestamp.wrappedValue = timestamp } } @@ -63,7 +64,7 @@ extension ContainsTimestamp : Proto3Codable { } self.unknownFields = try protoReader.endMessage(token: token) - self.timestamp = timestamp + self._timestamp.wrappedValue = timestamp } public func encode(to protoWriter: Wire.ProtoWriter) throws { @@ -78,7 +79,7 @@ extension ContainsTimestamp : Codable { public init(from decoder: Swift.Decoder) throws { let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) - self.timestamp = try container.decodeIfPresent(Timestamp.self, forKey: "timestamp") + self._timestamp.wrappedValue = try container.decodeIfPresent(Timestamp.self, forKey: "timestamp") } public func encode(to encoder: Swift.Encoder) throws { diff --git a/wire-tests-swift/manifest/module_three/SwiftModuleThreeMessage.swift b/wire-tests-swift/manifest/module_three/SwiftModuleThreeMessage.swift index 2b4148a284..4b3fbd9208 100644 --- a/wire-tests-swift/manifest/module_three/SwiftModuleThreeMessage.swift +++ b/wire-tests-swift/manifest/module_three/SwiftModuleThreeMessage.swift @@ -6,6 +6,7 @@ import module_one public struct SwiftModuleThreeMessage { + @Defaulted(defaultValue: "") public var name: String? public var unknownFields: Foundation.Data = .init() @@ -21,7 +22,7 @@ extension SwiftModuleThreeMessage { @_disfavoredOverload @available(*, deprecated) public init(name: Swift.String? = nil) { - self.name = name + self._name.wrappedValue = name } } @@ -64,7 +65,7 @@ extension SwiftModuleThreeMessage : Proto2Codable { } self.unknownFields = try protoReader.endMessage(token: token) - self.name = name + self._name.wrappedValue = name } public func encode(to protoWriter: Wire.ProtoWriter) throws { @@ -79,7 +80,7 @@ extension SwiftModuleThreeMessage : Codable { public init(from decoder: Swift.Decoder) throws { let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) - self.name = try container.decodeIfPresent(Swift.String.self, forKey: "name") + self._name.wrappedValue = try container.decodeIfPresent(Swift.String.self, forKey: "name") } public func encode(to encoder: Swift.Encoder) throws { diff --git a/wire-tests-swift/manifest/module_two/SwiftModuleTwoMessage.swift b/wire-tests-swift/manifest/module_two/SwiftModuleTwoMessage.swift index bcf34c5ad6..178fe51c92 100644 --- a/wire-tests-swift/manifest/module_two/SwiftModuleTwoMessage.swift +++ b/wire-tests-swift/manifest/module_two/SwiftModuleTwoMessage.swift @@ -6,6 +6,7 @@ import module_one public struct SwiftModuleTwoMessage { + @Defaulted(defaultValue: "") public var name: String? public var unknownFields: Foundation.Data = .init() @@ -21,7 +22,7 @@ extension SwiftModuleTwoMessage { @_disfavoredOverload @available(*, deprecated) public init(name: Swift.String? = nil) { - self.name = name + self._name.wrappedValue = name } } @@ -64,7 +65,7 @@ extension SwiftModuleTwoMessage : Proto2Codable { } self.unknownFields = try protoReader.endMessage(token: token) - self.name = name + self._name.wrappedValue = name } public func encode(to protoWriter: Wire.ProtoWriter) throws { @@ -79,7 +80,7 @@ extension SwiftModuleTwoMessage : Codable { public init(from decoder: Swift.Decoder) throws { let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) - self.name = try container.decodeIfPresent(Swift.String.self, forKey: "name") + self._name.wrappedValue = try container.decodeIfPresent(Swift.String.self, forKey: "name") } public func encode(to encoder: Swift.Encoder) throws { diff --git a/wire-tests-swift/no-manifest/src/main/swift/AllTypes.swift b/wire-tests-swift/no-manifest/src/main/swift/AllTypes.swift index 600361c18a..92b6c9c3e7 100644 --- a/wire-tests-swift/no-manifest/src/main/swift/AllTypes.swift +++ b/wire-tests-swift/no-manifest/src/main/swift/AllTypes.swift @@ -1600,6 +1600,7 @@ extension AllTypes { public struct NestedMessage { + @Wire.Defaulted(defaultValue: 0) public var a: Swift.Int32? public var unknownFields: Foundation.Data = .init() @@ -1622,7 +1623,7 @@ extension AllTypes.NestedMessage { @_disfavoredOverload @available(*, deprecated) public init(a: Swift.Int32? = nil) { - self.a = a + self._a.wrappedValue = a } } @@ -1665,7 +1666,7 @@ extension AllTypes.NestedMessage : Proto2Codable { } self.unknownFields = try protoReader.endMessage(token: token) - self.a = a + self._a.wrappedValue = a } public func encode(to protoWriter: Wire.ProtoWriter) throws { @@ -1680,7 +1681,7 @@ extension AllTypes.NestedMessage : Codable { public init(from decoder: Swift.Decoder) throws { let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) - self.a = try container.decodeIfPresent(Swift.Int32.self, forKey: "a") + self._a.wrappedValue = try container.decodeIfPresent(Swift.Int32.self, forKey: "a") } public func encode(to encoder: Swift.Encoder) throws { @@ -1844,23 +1845,23 @@ extension AllTypes.Storage { ext_pack_double: [Swift.Double], ext_pack_nested_enum: [AllTypes.NestedEnum] ) { - self.opt_int32 = opt_int32 - self.opt_uint32 = opt_uint32 - self.opt_sint32 = opt_sint32 - self.opt_fixed32 = opt_fixed32 - self.opt_sfixed32 = opt_sfixed32 - self.opt_int64 = opt_int64 - self.opt_uint64 = opt_uint64 - self.opt_sint64 = opt_sint64 - self.opt_fixed64 = opt_fixed64 - self.opt_sfixed64 = opt_sfixed64 - self.opt_bool = opt_bool - self.opt_float = opt_float - self.opt_double = opt_double - self.opt_string = opt_string - self.opt_bytes = opt_bytes - self.opt_nested_enum = opt_nested_enum - self.opt_nested_message = opt_nested_message + self._opt_int32.wrappedValue = opt_int32 + self._opt_uint32.wrappedValue = opt_uint32 + self._opt_sint32.wrappedValue = opt_sint32 + self._opt_fixed32.wrappedValue = opt_fixed32 + self._opt_sfixed32.wrappedValue = opt_sfixed32 + self._opt_int64.wrappedValue = opt_int64 + self._opt_uint64.wrappedValue = opt_uint64 + self._opt_sint64.wrappedValue = opt_sint64 + self._opt_fixed64.wrappedValue = opt_fixed64 + self._opt_sfixed64.wrappedValue = opt_sfixed64 + self._opt_bool.wrappedValue = opt_bool + self._opt_float.wrappedValue = opt_float + self._opt_double.wrappedValue = opt_double + self._opt_string.wrappedValue = opt_string + self._opt_bytes.wrappedValue = opt_bytes + self._opt_nested_enum.wrappedValue = opt_nested_enum + self._opt_nested_message.wrappedValue = opt_nested_message self.req_int32 = req_int32 self.req_uint32 = req_uint32 self.req_sint32 = req_sint32 @@ -1909,22 +1910,22 @@ extension AllTypes.Storage { self.pack_float = pack_float self.pack_double = pack_double self.pack_nested_enum = pack_nested_enum - _default_int32.wrappedValue = default_int32 - _default_uint32.wrappedValue = default_uint32 - _default_sint32.wrappedValue = default_sint32 - _default_fixed32.wrappedValue = default_fixed32 - _default_sfixed32.wrappedValue = default_sfixed32 - _default_int64.wrappedValue = default_int64 - _default_uint64.wrappedValue = default_uint64 - _default_sint64.wrappedValue = default_sint64 - _default_fixed64.wrappedValue = default_fixed64 - _default_sfixed64.wrappedValue = default_sfixed64 - _default_bool.wrappedValue = default_bool - _default_float.wrappedValue = default_float - _default_double.wrappedValue = default_double - _default_string.wrappedValue = default_string - _default_bytes.wrappedValue = default_bytes - _default_nested_enum.wrappedValue = default_nested_enum + self._default_int32.wrappedValue = default_int32 + self._default_uint32.wrappedValue = default_uint32 + self._default_sint32.wrappedValue = default_sint32 + self._default_fixed32.wrappedValue = default_fixed32 + self._default_sfixed32.wrappedValue = default_sfixed32 + self._default_int64.wrappedValue = default_int64 + self._default_uint64.wrappedValue = default_uint64 + self._default_sint64.wrappedValue = default_sint64 + self._default_fixed64.wrappedValue = default_fixed64 + self._default_sfixed64.wrappedValue = default_sfixed64 + self._default_bool.wrappedValue = default_bool + self._default_float.wrappedValue = default_float + self._default_double.wrappedValue = default_double + self._default_string.wrappedValue = default_string + self._default_bytes.wrappedValue = default_bytes + self._default_nested_enum.wrappedValue = default_nested_enum self.map_int32_int32 = map_int32_int32 self.map_string_string = map_string_string self.map_string_message = map_string_message @@ -1941,23 +1942,23 @@ extension AllTypes.Storage { self.array_sfixed64 = array_sfixed64 self.array_float = array_float self.array_double = array_double - self.ext_opt_int32 = ext_opt_int32 - self.ext_opt_uint32 = ext_opt_uint32 - self.ext_opt_sint32 = ext_opt_sint32 - self.ext_opt_fixed32 = ext_opt_fixed32 - self.ext_opt_sfixed32 = ext_opt_sfixed32 - self.ext_opt_int64 = ext_opt_int64 - self.ext_opt_uint64 = ext_opt_uint64 - self.ext_opt_sint64 = ext_opt_sint64 - self.ext_opt_fixed64 = ext_opt_fixed64 - self.ext_opt_sfixed64 = ext_opt_sfixed64 - self.ext_opt_bool = ext_opt_bool - self.ext_opt_float = ext_opt_float - self.ext_opt_double = ext_opt_double - self.ext_opt_string = ext_opt_string - self.ext_opt_bytes = ext_opt_bytes - self.ext_opt_nested_enum = ext_opt_nested_enum - self.ext_opt_nested_message = ext_opt_nested_message + self._ext_opt_int32.wrappedValue = ext_opt_int32 + self._ext_opt_uint32.wrappedValue = ext_opt_uint32 + self._ext_opt_sint32.wrappedValue = ext_opt_sint32 + self._ext_opt_fixed32.wrappedValue = ext_opt_fixed32 + self._ext_opt_sfixed32.wrappedValue = ext_opt_sfixed32 + self._ext_opt_int64.wrappedValue = ext_opt_int64 + self._ext_opt_uint64.wrappedValue = ext_opt_uint64 + self._ext_opt_sint64.wrappedValue = ext_opt_sint64 + self._ext_opt_fixed64.wrappedValue = ext_opt_fixed64 + self._ext_opt_sfixed64.wrappedValue = ext_opt_sfixed64 + self._ext_opt_bool.wrappedValue = ext_opt_bool + self._ext_opt_float.wrappedValue = ext_opt_float + self._ext_opt_double.wrappedValue = ext_opt_double + self._ext_opt_string.wrappedValue = ext_opt_string + self._ext_opt_bytes.wrappedValue = ext_opt_bytes + self._ext_opt_nested_enum.wrappedValue = ext_opt_nested_enum + self._ext_opt_nested_message.wrappedValue = ext_opt_nested_message self.ext_rep_int32 = ext_rep_int32 self.ext_rep_uint32 = ext_rep_uint32 self.ext_rep_sint32 = ext_rep_sint32 @@ -2001,22 +2002,39 @@ extension AllTypes { */ public struct Storage { + @Wire.Defaulted(defaultValue: 0) public var opt_int32: Swift.Int32? + @Wire.Defaulted(defaultValue: 0) public var opt_uint32: Swift.UInt32? + @Wire.Defaulted(defaultValue: 0) public var opt_sint32: Swift.Int32? + @Wire.Defaulted(defaultValue: 0) public var opt_fixed32: Swift.UInt32? + @Wire.Defaulted(defaultValue: 0) public var opt_sfixed32: Swift.Int32? + @Wire.Defaulted(defaultValue: 0) public var opt_int64: Swift.Int64? + @Wire.Defaulted(defaultValue: 0) public var opt_uint64: Swift.UInt64? + @Wire.Defaulted(defaultValue: 0) public var opt_sint64: Swift.Int64? + @Wire.Defaulted(defaultValue: 0) public var opt_fixed64: Swift.UInt64? + @Wire.Defaulted(defaultValue: 0) public var opt_sfixed64: Swift.Int64? + @Wire.Defaulted(defaultValue: false) public var opt_bool: Swift.Bool? + @Wire.Defaulted(defaultValue: 0) public var opt_float: Swift.Float? + @Wire.Defaulted(defaultValue: 0) public var opt_double: Swift.Double? + @Wire.Defaulted(defaultValue: "") public var opt_string: Swift.String? + @Wire.Defaulted(defaultValue: Foundation.Data(base64Encoded: "")!) public var opt_bytes: Foundation.Data? + @Wire.Defaulted(defaultValue: AllTypes.NestedEnum.UNKNOWN) public var opt_nested_enum: AllTypes.NestedEnum? + @Wire.Defaulted(defaultValue: AllTypes.NestedMessage()) public var opt_nested_message: AllTypes.NestedMessage? public var req_int32: Swift.Int32 public var req_uint32: Swift.UInt32 @@ -2114,22 +2132,39 @@ extension AllTypes { public var array_sfixed64: [Swift.Int64] = [] public var array_float: [Swift.Float] = [] public var array_double: [Swift.Double] = [] + @Wire.Defaulted(defaultValue: 0) public var ext_opt_int32: Swift.Int32? + @Wire.Defaulted(defaultValue: 0) public var ext_opt_uint32: Swift.UInt32? + @Wire.Defaulted(defaultValue: 0) public var ext_opt_sint32: Swift.Int32? + @Wire.Defaulted(defaultValue: 0) public var ext_opt_fixed32: Swift.UInt32? + @Wire.Defaulted(defaultValue: 0) public var ext_opt_sfixed32: Swift.Int32? + @Wire.Defaulted(defaultValue: 0) public var ext_opt_int64: Swift.Int64? + @Wire.Defaulted(defaultValue: 0) public var ext_opt_uint64: Swift.UInt64? + @Wire.Defaulted(defaultValue: 0) public var ext_opt_sint64: Swift.Int64? + @Wire.Defaulted(defaultValue: 0) public var ext_opt_fixed64: Swift.UInt64? + @Wire.Defaulted(defaultValue: 0) public var ext_opt_sfixed64: Swift.Int64? + @Wire.Defaulted(defaultValue: false) public var ext_opt_bool: Swift.Bool? + @Wire.Defaulted(defaultValue: 0) public var ext_opt_float: Swift.Float? + @Wire.Defaulted(defaultValue: 0) public var ext_opt_double: Swift.Double? + @Wire.Defaulted(defaultValue: "") public var ext_opt_string: Swift.String? + @Wire.Defaulted(defaultValue: Foundation.Data(base64Encoded: "")!) public var ext_opt_bytes: Foundation.Data? + @Wire.Defaulted(defaultValue: AllTypes.NestedEnum.UNKNOWN) public var ext_opt_nested_enum: AllTypes.NestedEnum? + @Wire.Defaulted(defaultValue: AllTypes.NestedMessage()) public var ext_opt_nested_message: AllTypes.NestedMessage? public var ext_rep_int32: [Swift.Int32] = [] public var ext_rep_uint32: [Swift.UInt32] = [] @@ -2533,23 +2568,23 @@ extension AllTypes.Storage : Proto2Codable { } self.unknownFields = try protoReader.endMessage(token: token) - self.opt_int32 = opt_int32 - self.opt_uint32 = opt_uint32 - self.opt_sint32 = opt_sint32 - self.opt_fixed32 = opt_fixed32 - self.opt_sfixed32 = opt_sfixed32 - self.opt_int64 = opt_int64 - self.opt_uint64 = opt_uint64 - self.opt_sint64 = opt_sint64 - self.opt_fixed64 = opt_fixed64 - self.opt_sfixed64 = opt_sfixed64 - self.opt_bool = opt_bool - self.opt_float = opt_float - self.opt_double = opt_double - self.opt_string = opt_string - self.opt_bytes = opt_bytes - self.opt_nested_enum = opt_nested_enum - self.opt_nested_message = opt_nested_message + self._opt_int32.wrappedValue = opt_int32 + self._opt_uint32.wrappedValue = opt_uint32 + self._opt_sint32.wrappedValue = opt_sint32 + self._opt_fixed32.wrappedValue = opt_fixed32 + self._opt_sfixed32.wrappedValue = opt_sfixed32 + self._opt_int64.wrappedValue = opt_int64 + self._opt_uint64.wrappedValue = opt_uint64 + self._opt_sint64.wrappedValue = opt_sint64 + self._opt_fixed64.wrappedValue = opt_fixed64 + self._opt_sfixed64.wrappedValue = opt_sfixed64 + self._opt_bool.wrappedValue = opt_bool + self._opt_float.wrappedValue = opt_float + self._opt_double.wrappedValue = opt_double + self._opt_string.wrappedValue = opt_string + self._opt_bytes.wrappedValue = opt_bytes + self._opt_nested_enum.wrappedValue = opt_nested_enum + self._opt_nested_message.wrappedValue = opt_nested_message self.req_int32 = try AllTypes.checkIfMissing(req_int32, "req_int32") self.req_uint32 = try AllTypes.checkIfMissing(req_uint32, "req_uint32") self.req_sint32 = try AllTypes.checkIfMissing(req_sint32, "req_sint32") @@ -2598,22 +2633,22 @@ extension AllTypes.Storage : Proto2Codable { self.pack_float = pack_float self.pack_double = pack_double self.pack_nested_enum = pack_nested_enum - _default_int32.wrappedValue = default_int32 - _default_uint32.wrappedValue = default_uint32 - _default_sint32.wrappedValue = default_sint32 - _default_fixed32.wrappedValue = default_fixed32 - _default_sfixed32.wrappedValue = default_sfixed32 - _default_int64.wrappedValue = default_int64 - _default_uint64.wrappedValue = default_uint64 - _default_sint64.wrappedValue = default_sint64 - _default_fixed64.wrappedValue = default_fixed64 - _default_sfixed64.wrappedValue = default_sfixed64 - _default_bool.wrappedValue = default_bool - _default_float.wrappedValue = default_float - _default_double.wrappedValue = default_double - _default_string.wrappedValue = default_string - _default_bytes.wrappedValue = default_bytes - _default_nested_enum.wrappedValue = default_nested_enum + self._default_int32.wrappedValue = default_int32 + self._default_uint32.wrappedValue = default_uint32 + self._default_sint32.wrappedValue = default_sint32 + self._default_fixed32.wrappedValue = default_fixed32 + self._default_sfixed32.wrappedValue = default_sfixed32 + self._default_int64.wrappedValue = default_int64 + self._default_uint64.wrappedValue = default_uint64 + self._default_sint64.wrappedValue = default_sint64 + self._default_fixed64.wrappedValue = default_fixed64 + self._default_sfixed64.wrappedValue = default_sfixed64 + self._default_bool.wrappedValue = default_bool + self._default_float.wrappedValue = default_float + self._default_double.wrappedValue = default_double + self._default_string.wrappedValue = default_string + self._default_bytes.wrappedValue = default_bytes + self._default_nested_enum.wrappedValue = default_nested_enum self.map_int32_int32 = map_int32_int32 self.map_string_string = map_string_string self.map_string_message = map_string_message @@ -2630,23 +2665,23 @@ extension AllTypes.Storage : Proto2Codable { self.array_sfixed64 = array_sfixed64 self.array_float = array_float self.array_double = array_double - self.ext_opt_int32 = ext_opt_int32 - self.ext_opt_uint32 = ext_opt_uint32 - self.ext_opt_sint32 = ext_opt_sint32 - self.ext_opt_fixed32 = ext_opt_fixed32 - self.ext_opt_sfixed32 = ext_opt_sfixed32 - self.ext_opt_int64 = ext_opt_int64 - self.ext_opt_uint64 = ext_opt_uint64 - self.ext_opt_sint64 = ext_opt_sint64 - self.ext_opt_fixed64 = ext_opt_fixed64 - self.ext_opt_sfixed64 = ext_opt_sfixed64 - self.ext_opt_bool = ext_opt_bool - self.ext_opt_float = ext_opt_float - self.ext_opt_double = ext_opt_double - self.ext_opt_string = ext_opt_string - self.ext_opt_bytes = ext_opt_bytes - self.ext_opt_nested_enum = ext_opt_nested_enum - self.ext_opt_nested_message = ext_opt_nested_message + self._ext_opt_int32.wrappedValue = ext_opt_int32 + self._ext_opt_uint32.wrappedValue = ext_opt_uint32 + self._ext_opt_sint32.wrappedValue = ext_opt_sint32 + self._ext_opt_fixed32.wrappedValue = ext_opt_fixed32 + self._ext_opt_sfixed32.wrappedValue = ext_opt_sfixed32 + self._ext_opt_int64.wrappedValue = ext_opt_int64 + self._ext_opt_uint64.wrappedValue = ext_opt_uint64 + self._ext_opt_sint64.wrappedValue = ext_opt_sint64 + self._ext_opt_fixed64.wrappedValue = ext_opt_fixed64 + self._ext_opt_sfixed64.wrappedValue = ext_opt_sfixed64 + self._ext_opt_bool.wrappedValue = ext_opt_bool + self._ext_opt_float.wrappedValue = ext_opt_float + self._ext_opt_double.wrappedValue = ext_opt_double + self._ext_opt_string.wrappedValue = ext_opt_string + self._ext_opt_bytes.wrappedValue = ext_opt_bytes + self._ext_opt_nested_enum.wrappedValue = ext_opt_nested_enum + self._ext_opt_nested_message.wrappedValue = ext_opt_nested_message self.ext_rep_int32 = ext_rep_int32 self.ext_rep_uint32 = ext_rep_uint32 self.ext_rep_sint32 = ext_rep_sint32 @@ -2836,23 +2871,23 @@ extension AllTypes.Storage : Codable { public init(from decoder: Swift.Decoder) throws { let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) - self.opt_int32 = try container.decodeIfPresent(Swift.Int32.self, firstOfKeys: "optInt32", "opt_int32") - self.opt_uint32 = try container.decodeIfPresent(Swift.UInt32.self, firstOfKeys: "optUint32", "opt_uint32") - self.opt_sint32 = try container.decodeIfPresent(Swift.Int32.self, firstOfKeys: "optSint32", "opt_sint32") - self.opt_fixed32 = try container.decodeIfPresent(Swift.UInt32.self, firstOfKeys: "optFixed32", "opt_fixed32") - self.opt_sfixed32 = try container.decodeIfPresent(Swift.Int32.self, firstOfKeys: "optSfixed32", "opt_sfixed32") - self.opt_int64 = try container.decodeIfPresent(stringEncoded: Swift.Int64.self, firstOfKeys: "optInt64", "opt_int64") - self.opt_uint64 = try container.decodeIfPresent(stringEncoded: Swift.UInt64.self, firstOfKeys: "optUint64", "opt_uint64") - self.opt_sint64 = try container.decodeIfPresent(stringEncoded: Swift.Int64.self, firstOfKeys: "optSint64", "opt_sint64") - self.opt_fixed64 = try container.decodeIfPresent(stringEncoded: Swift.UInt64.self, firstOfKeys: "optFixed64", "opt_fixed64") - self.opt_sfixed64 = try container.decodeIfPresent(stringEncoded: Swift.Int64.self, firstOfKeys: "optSfixed64", "opt_sfixed64") - self.opt_bool = try container.decodeIfPresent(Swift.Bool.self, firstOfKeys: "optBool", "opt_bool") - self.opt_float = try container.decodeIfPresent(Swift.Float.self, firstOfKeys: "optFloat", "opt_float") - self.opt_double = try container.decodeIfPresent(Swift.Double.self, firstOfKeys: "optDouble", "opt_double") - self.opt_string = try container.decodeIfPresent(Swift.String.self, firstOfKeys: "optString", "opt_string") - self.opt_bytes = try container.decodeIfPresent(stringEncoded: Foundation.Data.self, firstOfKeys: "optBytes", "opt_bytes") - self.opt_nested_enum = try container.decodeIfPresent(AllTypes.NestedEnum.self, firstOfKeys: "optNestedEnum", "opt_nested_enum") - self.opt_nested_message = try container.decodeIfPresent(AllTypes.NestedMessage.self, firstOfKeys: "optNestedMessage", "opt_nested_message") + self._opt_int32.wrappedValue = try container.decodeIfPresent(Swift.Int32.self, firstOfKeys: "optInt32", "opt_int32") + self._opt_uint32.wrappedValue = try container.decodeIfPresent(Swift.UInt32.self, firstOfKeys: "optUint32", "opt_uint32") + self._opt_sint32.wrappedValue = try container.decodeIfPresent(Swift.Int32.self, firstOfKeys: "optSint32", "opt_sint32") + self._opt_fixed32.wrappedValue = try container.decodeIfPresent(Swift.UInt32.self, firstOfKeys: "optFixed32", "opt_fixed32") + self._opt_sfixed32.wrappedValue = try container.decodeIfPresent(Swift.Int32.self, firstOfKeys: "optSfixed32", "opt_sfixed32") + self._opt_int64.wrappedValue = try container.decodeIfPresent(stringEncoded: Swift.Int64.self, firstOfKeys: "optInt64", "opt_int64") + self._opt_uint64.wrappedValue = try container.decodeIfPresent(stringEncoded: Swift.UInt64.self, firstOfKeys: "optUint64", "opt_uint64") + self._opt_sint64.wrappedValue = try container.decodeIfPresent(stringEncoded: Swift.Int64.self, firstOfKeys: "optSint64", "opt_sint64") + self._opt_fixed64.wrappedValue = try container.decodeIfPresent(stringEncoded: Swift.UInt64.self, firstOfKeys: "optFixed64", "opt_fixed64") + self._opt_sfixed64.wrappedValue = try container.decodeIfPresent(stringEncoded: Swift.Int64.self, firstOfKeys: "optSfixed64", "opt_sfixed64") + self._opt_bool.wrappedValue = try container.decodeIfPresent(Swift.Bool.self, firstOfKeys: "optBool", "opt_bool") + self._opt_float.wrappedValue = try container.decodeIfPresent(Swift.Float.self, firstOfKeys: "optFloat", "opt_float") + self._opt_double.wrappedValue = try container.decodeIfPresent(Swift.Double.self, firstOfKeys: "optDouble", "opt_double") + self._opt_string.wrappedValue = try container.decodeIfPresent(Swift.String.self, firstOfKeys: "optString", "opt_string") + self._opt_bytes.wrappedValue = try container.decodeIfPresent(stringEncoded: Foundation.Data.self, firstOfKeys: "optBytes", "opt_bytes") + self._opt_nested_enum.wrappedValue = try container.decodeIfPresent(AllTypes.NestedEnum.self, firstOfKeys: "optNestedEnum", "opt_nested_enum") + self._opt_nested_message.wrappedValue = try container.decodeIfPresent(AllTypes.NestedMessage.self, firstOfKeys: "optNestedMessage", "opt_nested_message") self.req_int32 = try container.decode(Swift.Int32.self, firstOfKeys: "reqInt32", "req_int32") self.req_uint32 = try container.decode(Swift.UInt32.self, firstOfKeys: "reqUint32", "req_uint32") self.req_sint32 = try container.decode(Swift.Int32.self, firstOfKeys: "reqSint32", "req_sint32") @@ -2901,22 +2936,22 @@ extension AllTypes.Storage : Codable { self.pack_float = try container.decodeProtoArray(Swift.Float.self, firstOfKeys: "packFloat", "pack_float") self.pack_double = try container.decodeProtoArray(Swift.Double.self, firstOfKeys: "packDouble", "pack_double") self.pack_nested_enum = try container.decodeProtoArray(AllTypes.NestedEnum.self, firstOfKeys: "packNestedEnum", "pack_nested_enum") - _default_int32.wrappedValue = try container.decodeIfPresent(Swift.Int32.self, firstOfKeys: "defaultInt32", "default_int32") - _default_uint32.wrappedValue = try container.decodeIfPresent(Swift.UInt32.self, firstOfKeys: "defaultUint32", "default_uint32") - _default_sint32.wrappedValue = try container.decodeIfPresent(Swift.Int32.self, firstOfKeys: "defaultSint32", "default_sint32") - _default_fixed32.wrappedValue = try container.decodeIfPresent(Swift.UInt32.self, firstOfKeys: "defaultFixed32", "default_fixed32") - _default_sfixed32.wrappedValue = try container.decodeIfPresent(Swift.Int32.self, firstOfKeys: "defaultSfixed32", "default_sfixed32") - _default_int64.wrappedValue = try container.decodeIfPresent(stringEncoded: Swift.Int64.self, firstOfKeys: "defaultInt64", "default_int64") - _default_uint64.wrappedValue = try container.decodeIfPresent(stringEncoded: Swift.UInt64.self, firstOfKeys: "defaultUint64", "default_uint64") - _default_sint64.wrappedValue = try container.decodeIfPresent(stringEncoded: Swift.Int64.self, firstOfKeys: "defaultSint64", "default_sint64") - _default_fixed64.wrappedValue = try container.decodeIfPresent(stringEncoded: Swift.UInt64.self, firstOfKeys: "defaultFixed64", "default_fixed64") - _default_sfixed64.wrappedValue = try container.decodeIfPresent(stringEncoded: Swift.Int64.self, firstOfKeys: "defaultSfixed64", "default_sfixed64") - _default_bool.wrappedValue = try container.decodeIfPresent(Swift.Bool.self, firstOfKeys: "defaultBool", "default_bool") - _default_float.wrappedValue = try container.decodeIfPresent(Swift.Float.self, firstOfKeys: "defaultFloat", "default_float") - _default_double.wrappedValue = try container.decodeIfPresent(Swift.Double.self, firstOfKeys: "defaultDouble", "default_double") - _default_string.wrappedValue = try container.decodeIfPresent(Swift.String.self, firstOfKeys: "defaultString", "default_string") - _default_bytes.wrappedValue = try container.decodeIfPresent(stringEncoded: Foundation.Data.self, firstOfKeys: "defaultBytes", "default_bytes") - _default_nested_enum.wrappedValue = try container.decodeIfPresent(AllTypes.NestedEnum.self, firstOfKeys: "defaultNestedEnum", "default_nested_enum") + self._default_int32.wrappedValue = try container.decodeIfPresent(Swift.Int32.self, firstOfKeys: "defaultInt32", "default_int32") + self._default_uint32.wrappedValue = try container.decodeIfPresent(Swift.UInt32.self, firstOfKeys: "defaultUint32", "default_uint32") + self._default_sint32.wrappedValue = try container.decodeIfPresent(Swift.Int32.self, firstOfKeys: "defaultSint32", "default_sint32") + self._default_fixed32.wrappedValue = try container.decodeIfPresent(Swift.UInt32.self, firstOfKeys: "defaultFixed32", "default_fixed32") + self._default_sfixed32.wrappedValue = try container.decodeIfPresent(Swift.Int32.self, firstOfKeys: "defaultSfixed32", "default_sfixed32") + self._default_int64.wrappedValue = try container.decodeIfPresent(stringEncoded: Swift.Int64.self, firstOfKeys: "defaultInt64", "default_int64") + self._default_uint64.wrappedValue = try container.decodeIfPresent(stringEncoded: Swift.UInt64.self, firstOfKeys: "defaultUint64", "default_uint64") + self._default_sint64.wrappedValue = try container.decodeIfPresent(stringEncoded: Swift.Int64.self, firstOfKeys: "defaultSint64", "default_sint64") + self._default_fixed64.wrappedValue = try container.decodeIfPresent(stringEncoded: Swift.UInt64.self, firstOfKeys: "defaultFixed64", "default_fixed64") + self._default_sfixed64.wrappedValue = try container.decodeIfPresent(stringEncoded: Swift.Int64.self, firstOfKeys: "defaultSfixed64", "default_sfixed64") + self._default_bool.wrappedValue = try container.decodeIfPresent(Swift.Bool.self, firstOfKeys: "defaultBool", "default_bool") + self._default_float.wrappedValue = try container.decodeIfPresent(Swift.Float.self, firstOfKeys: "defaultFloat", "default_float") + self._default_double.wrappedValue = try container.decodeIfPresent(Swift.Double.self, firstOfKeys: "defaultDouble", "default_double") + self._default_string.wrappedValue = try container.decodeIfPresent(Swift.String.self, firstOfKeys: "defaultString", "default_string") + self._default_bytes.wrappedValue = try container.decodeIfPresent(stringEncoded: Foundation.Data.self, firstOfKeys: "defaultBytes", "default_bytes") + self._default_nested_enum.wrappedValue = try container.decodeIfPresent(AllTypes.NestedEnum.self, firstOfKeys: "defaultNestedEnum", "default_nested_enum") self.map_int32_int32 = try container.decodeProtoMap([Swift.Int32 : Swift.Int32].self, firstOfKeys: "mapInt32Int32", "map_int32_int32") self.map_string_string = try container.decodeProtoMap([Swift.String : Swift.String].self, firstOfKeys: "mapStringString", "map_string_string") self.map_string_message = try container.decodeProtoMap([Swift.String : AllTypes.NestedMessage].self, firstOfKeys: "mapStringMessage", "map_string_message") @@ -2933,23 +2968,23 @@ extension AllTypes.Storage : Codable { self.array_sfixed64 = try container.decodeProtoArray(Swift.Int64.self, firstOfKeys: "arraySfixed64", "array_sfixed64") self.array_float = try container.decodeProtoArray(Swift.Float.self, firstOfKeys: "arrayFloat", "array_float") self.array_double = try container.decodeProtoArray(Swift.Double.self, firstOfKeys: "arrayDouble", "array_double") - self.ext_opt_int32 = try container.decodeIfPresent(Swift.Int32.self, firstOfKeys: "extOptInt32", "ext_opt_int32") - self.ext_opt_uint32 = try container.decodeIfPresent(Swift.UInt32.self, firstOfKeys: "extOptUint32", "ext_opt_uint32") - self.ext_opt_sint32 = try container.decodeIfPresent(Swift.Int32.self, firstOfKeys: "extOptSint32", "ext_opt_sint32") - self.ext_opt_fixed32 = try container.decodeIfPresent(Swift.UInt32.self, firstOfKeys: "extOptFixed32", "ext_opt_fixed32") - self.ext_opt_sfixed32 = try container.decodeIfPresent(Swift.Int32.self, firstOfKeys: "extOptSfixed32", "ext_opt_sfixed32") - self.ext_opt_int64 = try container.decodeIfPresent(stringEncoded: Swift.Int64.self, firstOfKeys: "extOptInt64", "ext_opt_int64") - self.ext_opt_uint64 = try container.decodeIfPresent(stringEncoded: Swift.UInt64.self, firstOfKeys: "extOptUint64", "ext_opt_uint64") - self.ext_opt_sint64 = try container.decodeIfPresent(stringEncoded: Swift.Int64.self, firstOfKeys: "extOptSint64", "ext_opt_sint64") - self.ext_opt_fixed64 = try container.decodeIfPresent(stringEncoded: Swift.UInt64.self, firstOfKeys: "extOptFixed64", "ext_opt_fixed64") - self.ext_opt_sfixed64 = try container.decodeIfPresent(stringEncoded: Swift.Int64.self, firstOfKeys: "extOptSfixed64", "ext_opt_sfixed64") - self.ext_opt_bool = try container.decodeIfPresent(Swift.Bool.self, firstOfKeys: "extOptBool", "ext_opt_bool") - self.ext_opt_float = try container.decodeIfPresent(Swift.Float.self, firstOfKeys: "extOptFloat", "ext_opt_float") - self.ext_opt_double = try container.decodeIfPresent(Swift.Double.self, firstOfKeys: "extOptDouble", "ext_opt_double") - self.ext_opt_string = try container.decodeIfPresent(Swift.String.self, firstOfKeys: "extOptString", "ext_opt_string") - self.ext_opt_bytes = try container.decodeIfPresent(stringEncoded: Foundation.Data.self, firstOfKeys: "extOptBytes", "ext_opt_bytes") - self.ext_opt_nested_enum = try container.decodeIfPresent(AllTypes.NestedEnum.self, firstOfKeys: "extOptNestedEnum", "ext_opt_nested_enum") - self.ext_opt_nested_message = try container.decodeIfPresent(AllTypes.NestedMessage.self, firstOfKeys: "extOptNestedMessage", "ext_opt_nested_message") + self._ext_opt_int32.wrappedValue = try container.decodeIfPresent(Swift.Int32.self, firstOfKeys: "extOptInt32", "ext_opt_int32") + self._ext_opt_uint32.wrappedValue = try container.decodeIfPresent(Swift.UInt32.self, firstOfKeys: "extOptUint32", "ext_opt_uint32") + self._ext_opt_sint32.wrappedValue = try container.decodeIfPresent(Swift.Int32.self, firstOfKeys: "extOptSint32", "ext_opt_sint32") + self._ext_opt_fixed32.wrappedValue = try container.decodeIfPresent(Swift.UInt32.self, firstOfKeys: "extOptFixed32", "ext_opt_fixed32") + self._ext_opt_sfixed32.wrappedValue = try container.decodeIfPresent(Swift.Int32.self, firstOfKeys: "extOptSfixed32", "ext_opt_sfixed32") + self._ext_opt_int64.wrappedValue = try container.decodeIfPresent(stringEncoded: Swift.Int64.self, firstOfKeys: "extOptInt64", "ext_opt_int64") + self._ext_opt_uint64.wrappedValue = try container.decodeIfPresent(stringEncoded: Swift.UInt64.self, firstOfKeys: "extOptUint64", "ext_opt_uint64") + self._ext_opt_sint64.wrappedValue = try container.decodeIfPresent(stringEncoded: Swift.Int64.self, firstOfKeys: "extOptSint64", "ext_opt_sint64") + self._ext_opt_fixed64.wrappedValue = try container.decodeIfPresent(stringEncoded: Swift.UInt64.self, firstOfKeys: "extOptFixed64", "ext_opt_fixed64") + self._ext_opt_sfixed64.wrappedValue = try container.decodeIfPresent(stringEncoded: Swift.Int64.self, firstOfKeys: "extOptSfixed64", "ext_opt_sfixed64") + self._ext_opt_bool.wrappedValue = try container.decodeIfPresent(Swift.Bool.self, firstOfKeys: "extOptBool", "ext_opt_bool") + self._ext_opt_float.wrappedValue = try container.decodeIfPresent(Swift.Float.self, firstOfKeys: "extOptFloat", "ext_opt_float") + self._ext_opt_double.wrappedValue = try container.decodeIfPresent(Swift.Double.self, firstOfKeys: "extOptDouble", "ext_opt_double") + self._ext_opt_string.wrappedValue = try container.decodeIfPresent(Swift.String.self, firstOfKeys: "extOptString", "ext_opt_string") + self._ext_opt_bytes.wrappedValue = try container.decodeIfPresent(stringEncoded: Foundation.Data.self, firstOfKeys: "extOptBytes", "ext_opt_bytes") + self._ext_opt_nested_enum.wrappedValue = try container.decodeIfPresent(AllTypes.NestedEnum.self, firstOfKeys: "extOptNestedEnum", "ext_opt_nested_enum") + self._ext_opt_nested_message.wrappedValue = try container.decodeIfPresent(AllTypes.NestedMessage.self, firstOfKeys: "extOptNestedMessage", "ext_opt_nested_message") self.ext_rep_int32 = try container.decodeProtoArray(Swift.Int32.self, firstOfKeys: "extRepInt32", "ext_rep_int32") self.ext_rep_uint32 = try container.decodeProtoArray(Swift.UInt32.self, firstOfKeys: "extRepUint32", "ext_rep_uint32") self.ext_rep_sint32 = try container.decodeProtoArray(Swift.Int32.self, firstOfKeys: "extRepSint32", "ext_rep_sint32") diff --git a/wire-tests-swift/no-manifest/src/main/swift/DeprecatedProto.swift b/wire-tests-swift/no-manifest/src/main/swift/DeprecatedProto.swift index 37ed4164e7..5621dcbd4b 100644 --- a/wire-tests-swift/no-manifest/src/main/swift/DeprecatedProto.swift +++ b/wire-tests-swift/no-manifest/src/main/swift/DeprecatedProto.swift @@ -6,6 +6,7 @@ import Wire public struct DeprecatedProto { @available(*, deprecated) + @Defaulted(defaultValue: "") public var foo: String? public var unknownFields: Foundation.Data = .init() @@ -21,7 +22,7 @@ extension DeprecatedProto { @_disfavoredOverload @available(*, deprecated) public init(foo: Swift.String? = nil) { - self.foo = foo + self._foo.wrappedValue = foo } } @@ -64,7 +65,7 @@ extension DeprecatedProto : Proto2Codable { } self.unknownFields = try protoReader.endMessage(token: token) - self.foo = foo + self._foo.wrappedValue = foo } public func encode(to protoWriter: Wire.ProtoWriter) throws { @@ -79,7 +80,7 @@ extension DeprecatedProto : Codable { public init(from decoder: Swift.Decoder) throws { let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) - self.foo = try container.decodeIfPresent(Swift.String.self, forKey: "foo") + self._foo.wrappedValue = try container.decodeIfPresent(Swift.String.self, forKey: "foo") } public func encode(to encoder: Swift.Encoder) throws { diff --git a/wire-tests-swift/no-manifest/src/main/swift/EmbeddedMessage.swift b/wire-tests-swift/no-manifest/src/main/swift/EmbeddedMessage.swift index d1f5e0d533..e99ed802eb 100644 --- a/wire-tests-swift/no-manifest/src/main/swift/EmbeddedMessage.swift +++ b/wire-tests-swift/no-manifest/src/main/swift/EmbeddedMessage.swift @@ -6,6 +6,7 @@ import Wire public struct EmbeddedMessage { public var inner_repeated_number: [Int32] = [] + @Defaulted(defaultValue: 0) public var inner_number_after: Int32? public var unknownFields: Foundation.Data = .init() @@ -22,7 +23,7 @@ extension EmbeddedMessage { @available(*, deprecated) public init(inner_repeated_number: [Swift.Int32] = [], inner_number_after: Swift.Int32? = nil) { self.inner_repeated_number = inner_repeated_number - self.inner_number_after = inner_number_after + self._inner_number_after.wrappedValue = inner_number_after } } @@ -68,7 +69,7 @@ extension EmbeddedMessage : Proto2Codable { self.unknownFields = try protoReader.endMessage(token: token) self.inner_repeated_number = inner_repeated_number - self.inner_number_after = inner_number_after + self._inner_number_after.wrappedValue = inner_number_after } public func encode(to protoWriter: Wire.ProtoWriter) throws { @@ -85,7 +86,7 @@ extension EmbeddedMessage : Codable { public init(from decoder: Swift.Decoder) throws { let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) self.inner_repeated_number = try container.decodeProtoArray(Swift.Int32.self, firstOfKeys: "innerRepeatedNumber", "inner_repeated_number") - self.inner_number_after = try container.decodeIfPresent(Swift.Int32.self, firstOfKeys: "innerNumberAfter", "inner_number_after") + self._inner_number_after.wrappedValue = try container.decodeIfPresent(Swift.Int32.self, firstOfKeys: "innerNumberAfter", "inner_number_after") } public func encode(to encoder: Swift.Encoder) throws { diff --git a/wire-tests-swift/no-manifest/src/main/swift/ExternalMessage.swift b/wire-tests-swift/no-manifest/src/main/swift/ExternalMessage.swift index 1f3aafd7f5..47fc12f531 100644 --- a/wire-tests-swift/no-manifest/src/main/swift/ExternalMessage.swift +++ b/wire-tests-swift/no-manifest/src/main/swift/ExternalMessage.swift @@ -21,7 +21,7 @@ extension ExternalMessage { @_disfavoredOverload @available(*, deprecated) public init(f: Swift.Float? = nil) { - _f.wrappedValue = f + self._f.wrappedValue = f } } @@ -64,7 +64,7 @@ extension ExternalMessage : Proto2Codable { } self.unknownFields = try protoReader.endMessage(token: token) - _f.wrappedValue = f + self._f.wrappedValue = f } public func encode(to protoWriter: Wire.ProtoWriter) throws { @@ -79,7 +79,7 @@ extension ExternalMessage : Codable { public init(from decoder: Swift.Decoder) throws { let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) - _f.wrappedValue = try container.decodeIfPresent(Swift.Float.self, forKey: "f") + self._f.wrappedValue = try container.decodeIfPresent(Swift.Float.self, forKey: "f") } public func encode(to encoder: Swift.Encoder) throws { diff --git a/wire-tests-swift/no-manifest/src/main/swift/FooBar.swift b/wire-tests-swift/no-manifest/src/main/swift/FooBar.swift index 8affc4d7e1..b585e9c406 100644 --- a/wire-tests-swift/no-manifest/src/main/swift/FooBar.swift +++ b/wire-tests-swift/no-manifest/src/main/swift/FooBar.swift @@ -5,15 +5,22 @@ import Wire public struct FooBar { + @Defaulted(defaultValue: 0) public var foo: Int32? + @Defaulted(defaultValue: "") public var bar: String? + @Defaulted(defaultValue: FooBar.Nested()) public var baz: FooBar.Nested? + @Defaulted(defaultValue: 0) public var qux: UInt64? public var fred: [Float] = [] + @Defaulted(defaultValue: 0) public var daisy: Double? public var nested: [FooBar] = [] + @Defaulted(defaultValue: FooBar.FooBarBazEnum.FOO) public var ext: FooBar.FooBarBazEnum? public var rep: [FooBar.FooBarBazEnum] = [] + @Defaulted(defaultValue: "") public var more_string: String? public var unknownFields: Foundation.Data = .init() @@ -40,16 +47,16 @@ extension FooBar { rep: [FooBar.FooBarBazEnum] = [], more_string: Swift.String? = nil ) { - self.foo = foo - self.bar = bar - self.baz = baz - self.qux = qux + self._foo.wrappedValue = foo + self._bar.wrappedValue = bar + self._baz.wrappedValue = baz + self._qux.wrappedValue = qux self.fred = fred - self.daisy = daisy + self._daisy.wrappedValue = daisy self.nested = nested - self.ext = ext + self._ext.wrappedValue = ext self.rep = rep - self.more_string = more_string + self._more_string.wrappedValue = more_string } } @@ -122,16 +129,16 @@ extension FooBar : Proto2Codable { } self.unknownFields = try protoReader.endMessage(token: token) - self.foo = foo - self.bar = bar - self.baz = baz - self.qux = qux + self._foo.wrappedValue = foo + self._bar.wrappedValue = bar + self._baz.wrappedValue = baz + self._qux.wrappedValue = qux self.fred = fred - self.daisy = daisy + self._daisy.wrappedValue = daisy self.nested = nested - self.ext = ext + self._ext.wrappedValue = ext self.rep = rep - self.more_string = more_string + self._more_string.wrappedValue = more_string } public func encode(to protoWriter: Wire.ProtoWriter) throws { @@ -155,16 +162,16 @@ extension FooBar : Codable { public init(from decoder: Swift.Decoder) throws { let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) - self.foo = try container.decodeIfPresent(Swift.Int32.self, forKey: "foo") - self.bar = try container.decodeIfPresent(Swift.String.self, forKey: "bar") - self.baz = try container.decodeIfPresent(FooBar.Nested.self, forKey: "baz") - self.qux = try container.decodeIfPresent(stringEncoded: Swift.UInt64.self, forKey: "qux") + self._foo.wrappedValue = try container.decodeIfPresent(Swift.Int32.self, forKey: "foo") + self._bar.wrappedValue = try container.decodeIfPresent(Swift.String.self, forKey: "bar") + self._baz.wrappedValue = try container.decodeIfPresent(FooBar.Nested.self, forKey: "baz") + self._qux.wrappedValue = try container.decodeIfPresent(stringEncoded: Swift.UInt64.self, forKey: "qux") self.fred = try container.decodeProtoArray(Swift.Float.self, forKey: "fred") - self.daisy = try container.decodeIfPresent(Swift.Double.self, forKey: "daisy") + self._daisy.wrappedValue = try container.decodeIfPresent(Swift.Double.self, forKey: "daisy") self.nested = try container.decodeProtoArray(FooBar.self, forKey: "nested") - self.ext = try container.decodeIfPresent(FooBar.FooBarBazEnum.self, forKey: "ext") + self._ext.wrappedValue = try container.decodeIfPresent(FooBar.FooBarBazEnum.self, forKey: "ext") self.rep = try container.decodeProtoArray(FooBar.FooBarBazEnum.self, forKey: "rep") - self.more_string = try container.decodeIfPresent(Swift.String.self, firstOfKeys: "moreString", "more_string") + self._more_string.wrappedValue = try container.decodeIfPresent(Swift.String.self, firstOfKeys: "moreString", "more_string") } public func encode(to encoder: Swift.Encoder) throws { @@ -200,6 +207,7 @@ extension FooBar { public struct Nested { + @Wire.Defaulted(defaultValue: FooBar.FooBarBazEnum.FOO) public var value: FooBar.FooBarBazEnum? public var unknownFields: Foundation.Data = .init() @@ -244,7 +252,7 @@ extension FooBar.Nested { @_disfavoredOverload @available(*, deprecated) public init(value: FooBar.FooBarBazEnum? = nil) { - self.value = value + self._value.wrappedValue = value } } @@ -287,7 +295,7 @@ extension FooBar.Nested : Proto2Codable { } self.unknownFields = try protoReader.endMessage(token: token) - self.value = value + self._value.wrappedValue = value } public func encode(to protoWriter: Wire.ProtoWriter) throws { @@ -302,7 +310,7 @@ extension FooBar.Nested : Codable { public init(from decoder: Swift.Decoder) throws { let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) - self.value = try container.decodeIfPresent(FooBar.FooBarBazEnum.self, forKey: "value") + self._value.wrappedValue = try container.decodeIfPresent(FooBar.FooBarBazEnum.self, forKey: "value") } public func encode(to encoder: Swift.Encoder) throws { diff --git a/wire-tests-swift/no-manifest/src/main/swift/ForeignMessage.swift b/wire-tests-swift/no-manifest/src/main/swift/ForeignMessage.swift index 3822573d79..aa6de1ea5f 100644 --- a/wire-tests-swift/no-manifest/src/main/swift/ForeignMessage.swift +++ b/wire-tests-swift/no-manifest/src/main/swift/ForeignMessage.swift @@ -5,6 +5,7 @@ import Wire public struct ForeignMessage { + @Defaulted(defaultValue: 0) public var i: Int32? public var unknownFields: Foundation.Data = .init() @@ -20,7 +21,7 @@ extension ForeignMessage { @_disfavoredOverload @available(*, deprecated) public init(i: Swift.Int32? = nil) { - self.i = i + self._i.wrappedValue = i } } @@ -63,7 +64,7 @@ extension ForeignMessage : Proto2Codable { } self.unknownFields = try protoReader.endMessage(token: token) - self.i = i + self._i.wrappedValue = i } public func encode(to protoWriter: Wire.ProtoWriter) throws { @@ -78,7 +79,7 @@ extension ForeignMessage : Codable { public init(from decoder: Swift.Decoder) throws { let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) - self.i = try container.decodeIfPresent(Swift.Int32.self, forKey: "i") + self._i.wrappedValue = try container.decodeIfPresent(Swift.Int32.self, forKey: "i") } public func encode(to encoder: Swift.Encoder) throws { diff --git a/wire-tests-swift/no-manifest/src/main/swift/Form.swift b/wire-tests-swift/no-manifest/src/main/swift/Form.swift index f2a1f3e039..299d211c81 100644 --- a/wire-tests-swift/no-manifest/src/main/swift/Form.swift +++ b/wire-tests-swift/no-manifest/src/main/swift/Form.swift @@ -326,6 +326,7 @@ extension Form { public struct TextElement { + @Wire.Defaulted(defaultValue: "") public var text: Swift.String? public var unknownFields: Foundation.Data = .init() @@ -694,7 +695,7 @@ extension Form.TextElement { @_disfavoredOverload @available(*, deprecated) public init(text: Swift.String? = nil) { - self.text = text + self._text.wrappedValue = text } } @@ -737,7 +738,7 @@ extension Form.TextElement : Proto2Codable { } self.unknownFields = try protoReader.endMessage(token: token) - self.text = text + self._text.wrappedValue = text } public func encode(to protoWriter: Wire.ProtoWriter) throws { @@ -752,7 +753,7 @@ extension Form.TextElement : Codable { public init(from decoder: Swift.Decoder) throws { let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) - self.text = try container.decodeIfPresent(Swift.String.self, forKey: "text") + self._text.wrappedValue = try container.decodeIfPresent(Swift.String.self, forKey: "text") } public func encode(to encoder: Swift.Encoder) throws { diff --git a/wire-tests-swift/no-manifest/src/main/swift/MessageUsingMultipleEnums.swift b/wire-tests-swift/no-manifest/src/main/swift/MessageUsingMultipleEnums.swift index b818f5f0b5..a0740adb4a 100644 --- a/wire-tests-swift/no-manifest/src/main/swift/MessageUsingMultipleEnums.swift +++ b/wire-tests-swift/no-manifest/src/main/swift/MessageUsingMultipleEnums.swift @@ -8,7 +8,9 @@ import Wire */ public struct MessageUsingMultipleEnums { + @Defaulted(defaultValue: MessageWithStatus.Status.A) public var a: MessageWithStatus.Status? + @Defaulted(defaultValue: OtherMessageWithStatus.Status.A) public var b: OtherMessageWithStatus.Status? public var unknownFields: Foundation.Data = .init() @@ -24,8 +26,8 @@ extension MessageUsingMultipleEnums { @_disfavoredOverload @available(*, deprecated) public init(a: MessageWithStatus.Status? = nil, b: OtherMessageWithStatus.Status? = nil) { - self.a = a - self.b = b + self._a.wrappedValue = a + self._b.wrappedValue = b } } @@ -70,8 +72,8 @@ extension MessageUsingMultipleEnums : Proto2Codable { } self.unknownFields = try protoReader.endMessage(token: token) - self.a = a - self.b = b + self._a.wrappedValue = a + self._b.wrappedValue = b } public func encode(to protoWriter: Wire.ProtoWriter) throws { @@ -87,8 +89,8 @@ extension MessageUsingMultipleEnums : Codable { public init(from decoder: Swift.Decoder) throws { let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) - self.a = try container.decodeIfPresent(MessageWithStatus.Status.self, forKey: "a") - self.b = try container.decodeIfPresent(OtherMessageWithStatus.Status.self, forKey: "b") + self._a.wrappedValue = try container.decodeIfPresent(MessageWithStatus.Status.self, forKey: "a") + self._b.wrappedValue = try container.decodeIfPresent(OtherMessageWithStatus.Status.self, forKey: "b") } public func encode(to encoder: Swift.Encoder) throws { diff --git a/wire-tests-swift/no-manifest/src/main/swift/ModelEvaluation.swift b/wire-tests-swift/no-manifest/src/main/swift/ModelEvaluation.swift index 4c4524a1d8..1171a8a860 100644 --- a/wire-tests-swift/no-manifest/src/main/swift/ModelEvaluation.swift +++ b/wire-tests-swift/no-manifest/src/main/swift/ModelEvaluation.swift @@ -20,7 +20,9 @@ import Wire */ public struct ModelEvaluation { + @Defaulted(defaultValue: "") public var name: String? + @Defaulted(defaultValue: 0) public var score: Double? public var models: [String : ModelEvaluation] = [:] public var unknownFields: Foundation.Data = .init() @@ -41,8 +43,8 @@ extension ModelEvaluation { score: Swift.Double? = nil, models: [Swift.String : ModelEvaluation] = [:] ) { - self.name = name - self.score = score + self._name.wrappedValue = name + self._score.wrappedValue = score self.models = models } @@ -90,8 +92,8 @@ extension ModelEvaluation : Proto2Codable { } self.unknownFields = try protoReader.endMessage(token: token) - self.name = name - self.score = score + self._name.wrappedValue = name + self._score.wrappedValue = score self.models = models } @@ -109,8 +111,8 @@ extension ModelEvaluation : Codable { public init(from decoder: Swift.Decoder) throws { let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) - self.name = try container.decodeIfPresent(Swift.String.self, forKey: "name") - self.score = try container.decodeIfPresent(Swift.Double.self, forKey: "score") + self._name.wrappedValue = try container.decodeIfPresent(Swift.String.self, forKey: "name") + self._score.wrappedValue = try container.decodeIfPresent(Swift.Double.self, forKey: "score") self.models = try container.decodeProtoMap([Swift.String : ModelEvaluation].self, forKey: "models") } diff --git a/wire-tests-swift/no-manifest/src/main/swift/NestedVersionOne.swift b/wire-tests-swift/no-manifest/src/main/swift/NestedVersionOne.swift index 0d59f3a917..fbc23e6869 100644 --- a/wire-tests-swift/no-manifest/src/main/swift/NestedVersionOne.swift +++ b/wire-tests-swift/no-manifest/src/main/swift/NestedVersionOne.swift @@ -5,6 +5,7 @@ import Wire public struct NestedVersionOne { + @Defaulted(defaultValue: 0) public var i: Int32? public var unknownFields: Foundation.Data = .init() @@ -20,7 +21,7 @@ extension NestedVersionOne { @_disfavoredOverload @available(*, deprecated) public init(i: Swift.Int32? = nil) { - self.i = i + self._i.wrappedValue = i } } @@ -63,7 +64,7 @@ extension NestedVersionOne : Proto2Codable { } self.unknownFields = try protoReader.endMessage(token: token) - self.i = i + self._i.wrappedValue = i } public func encode(to protoWriter: Wire.ProtoWriter) throws { @@ -78,7 +79,7 @@ extension NestedVersionOne : Codable { public init(from decoder: Swift.Decoder) throws { let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) - self.i = try container.decodeIfPresent(Swift.Int32.self, forKey: "i") + self._i.wrappedValue = try container.decodeIfPresent(Swift.Int32.self, forKey: "i") } public func encode(to encoder: Swift.Encoder) throws { diff --git a/wire-tests-swift/no-manifest/src/main/swift/NestedVersionTwo.swift b/wire-tests-swift/no-manifest/src/main/swift/NestedVersionTwo.swift index 8e4bfbcdfb..6f292ee0aa 100644 --- a/wire-tests-swift/no-manifest/src/main/swift/NestedVersionTwo.swift +++ b/wire-tests-swift/no-manifest/src/main/swift/NestedVersionTwo.swift @@ -5,10 +5,15 @@ import Wire public struct NestedVersionTwo { + @Defaulted(defaultValue: 0) public var i: Int32? + @Defaulted(defaultValue: 0) public var v2_i: Int32? + @Defaulted(defaultValue: "") public var v2_s: String? + @Defaulted(defaultValue: 0) public var v2_f32: UInt32? + @Defaulted(defaultValue: 0) public var v2_f64: UInt64? public var v2_rs: [String] = [] public var unknownFields: Foundation.Data = .init() @@ -32,11 +37,11 @@ extension NestedVersionTwo { v2_f64: Swift.UInt64? = nil, v2_rs: [Swift.String] = [] ) { - self.i = i - self.v2_i = v2_i - self.v2_s = v2_s - self.v2_f32 = v2_f32 - self.v2_f64 = v2_f64 + self._i.wrappedValue = i + self._v2_i.wrappedValue = v2_i + self._v2_s.wrappedValue = v2_s + self._v2_f32.wrappedValue = v2_f32 + self._v2_f64.wrappedValue = v2_f64 self.v2_rs = v2_rs } @@ -90,11 +95,11 @@ extension NestedVersionTwo : Proto2Codable { } self.unknownFields = try protoReader.endMessage(token: token) - self.i = i - self.v2_i = v2_i - self.v2_s = v2_s - self.v2_f32 = v2_f32 - self.v2_f64 = v2_f64 + self._i.wrappedValue = i + self._v2_i.wrappedValue = v2_i + self._v2_s.wrappedValue = v2_s + self._v2_f32.wrappedValue = v2_f32 + self._v2_f64.wrappedValue = v2_f64 self.v2_rs = v2_rs } @@ -115,11 +120,11 @@ extension NestedVersionTwo : Codable { public init(from decoder: Swift.Decoder) throws { let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) - self.i = try container.decodeIfPresent(Swift.Int32.self, forKey: "i") - self.v2_i = try container.decodeIfPresent(Swift.Int32.self, firstOfKeys: "v2I", "v2_i") - self.v2_s = try container.decodeIfPresent(Swift.String.self, firstOfKeys: "v2S", "v2_s") - self.v2_f32 = try container.decodeIfPresent(Swift.UInt32.self, firstOfKeys: "v2F32", "v2_f32") - self.v2_f64 = try container.decodeIfPresent(stringEncoded: Swift.UInt64.self, firstOfKeys: "v2F64", "v2_f64") + self._i.wrappedValue = try container.decodeIfPresent(Swift.Int32.self, forKey: "i") + self._v2_i.wrappedValue = try container.decodeIfPresent(Swift.Int32.self, firstOfKeys: "v2I", "v2_i") + self._v2_s.wrappedValue = try container.decodeIfPresent(Swift.String.self, firstOfKeys: "v2S", "v2_s") + self._v2_f32.wrappedValue = try container.decodeIfPresent(Swift.UInt32.self, firstOfKeys: "v2F32", "v2_f32") + self._v2_f64.wrappedValue = try container.decodeIfPresent(stringEncoded: Swift.UInt64.self, firstOfKeys: "v2F64", "v2_f64") self.v2_rs = try container.decodeProtoArray(Swift.String.self, firstOfKeys: "v2Rs", "v2_rs") } diff --git a/wire-tests-swift/no-manifest/src/main/swift/OptionalEnumUser.swift b/wire-tests-swift/no-manifest/src/main/swift/OptionalEnumUser.swift index cadf2f2e9a..827dea8e44 100644 --- a/wire-tests-swift/no-manifest/src/main/swift/OptionalEnumUser.swift +++ b/wire-tests-swift/no-manifest/src/main/swift/OptionalEnumUser.swift @@ -5,6 +5,7 @@ import Wire public struct OptionalEnumUser { + @Defaulted(defaultValue: OptionalEnumUser.OptionalEnum.FOO) public var optional_enum: OptionalEnumUser.OptionalEnum? public var unknownFields: Foundation.Data = .init() @@ -20,7 +21,7 @@ extension OptionalEnumUser { @_disfavoredOverload @available(*, deprecated) public init(optional_enum: OptionalEnumUser.OptionalEnum? = nil) { - self.optional_enum = optional_enum + self._optional_enum.wrappedValue = optional_enum } } @@ -63,7 +64,7 @@ extension OptionalEnumUser : Proto2Codable { } self.unknownFields = try protoReader.endMessage(token: token) - self.optional_enum = optional_enum + self._optional_enum.wrappedValue = optional_enum } public func encode(to protoWriter: Wire.ProtoWriter) throws { @@ -78,7 +79,7 @@ extension OptionalEnumUser : Codable { public init(from decoder: Swift.Decoder) throws { let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) - self.optional_enum = try container.decodeIfPresent(OptionalEnumUser.OptionalEnum.self, firstOfKeys: "optionalEnum", "optional_enum") + self._optional_enum.wrappedValue = try container.decodeIfPresent(OptionalEnumUser.OptionalEnum.self, firstOfKeys: "optionalEnum", "optional_enum") } public func encode(to encoder: Swift.Encoder) throws { diff --git a/wire-tests-swift/no-manifest/src/main/swift/OuterMessage.swift b/wire-tests-swift/no-manifest/src/main/swift/OuterMessage.swift index 5a1c1d0b73..8bca3c46ce 100644 --- a/wire-tests-swift/no-manifest/src/main/swift/OuterMessage.swift +++ b/wire-tests-swift/no-manifest/src/main/swift/OuterMessage.swift @@ -5,7 +5,9 @@ import Wire public struct OuterMessage { + @Defaulted(defaultValue: 0) public var outer_number_before: Int32? + @Defaulted(defaultValue: EmbeddedMessage()) public var embedded_message: EmbeddedMessage? public var unknownFields: Foundation.Data = .init() @@ -21,8 +23,8 @@ extension OuterMessage { @_disfavoredOverload @available(*, deprecated) public init(outer_number_before: Swift.Int32? = nil, embedded_message: EmbeddedMessage? = nil) { - self.outer_number_before = outer_number_before - self.embedded_message = embedded_message + self._outer_number_before.wrappedValue = outer_number_before + self._embedded_message.wrappedValue = embedded_message } } @@ -67,8 +69,8 @@ extension OuterMessage : Proto2Codable { } self.unknownFields = try protoReader.endMessage(token: token) - self.outer_number_before = outer_number_before - self.embedded_message = embedded_message + self._outer_number_before.wrappedValue = outer_number_before + self._embedded_message.wrappedValue = embedded_message } public func encode(to protoWriter: Wire.ProtoWriter) throws { @@ -84,8 +86,8 @@ extension OuterMessage : Codable { public init(from decoder: Swift.Decoder) throws { let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) - self.outer_number_before = try container.decodeIfPresent(Swift.Int32.self, firstOfKeys: "outerNumberBefore", "outer_number_before") - self.embedded_message = try container.decodeIfPresent(EmbeddedMessage.self, firstOfKeys: "embeddedMessage", "embedded_message") + self._outer_number_before.wrappedValue = try container.decodeIfPresent(Swift.Int32.self, firstOfKeys: "outerNumberBefore", "outer_number_before") + self._embedded_message.wrappedValue = try container.decodeIfPresent(EmbeddedMessage.self, firstOfKeys: "embeddedMessage", "embedded_message") } public func encode(to encoder: Swift.Encoder) throws { diff --git a/wire-tests-swift/no-manifest/src/main/swift/Percents.swift b/wire-tests-swift/no-manifest/src/main/swift/Percents.swift index 187df1117e..184a809464 100644 --- a/wire-tests-swift/no-manifest/src/main/swift/Percents.swift +++ b/wire-tests-swift/no-manifest/src/main/swift/Percents.swift @@ -8,6 +8,7 @@ public struct Percents { /** * e.g. "No limits, free to send and just 2.75% to receive". */ + @Defaulted(defaultValue: "") public var text: String? public var unknownFields: Foundation.Data = .init() @@ -23,7 +24,7 @@ extension Percents { @_disfavoredOverload @available(*, deprecated) public init(text: Swift.String? = nil) { - self.text = text + self._text.wrappedValue = text } } @@ -66,7 +67,7 @@ extension Percents : Proto2Codable { } self.unknownFields = try protoReader.endMessage(token: token) - self.text = text + self._text.wrappedValue = text } public func encode(to protoWriter: Wire.ProtoWriter) throws { @@ -81,7 +82,7 @@ extension Percents : Codable { public init(from decoder: Swift.Decoder) throws { let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) - self.text = try container.decodeIfPresent(Swift.String.self, forKey: "text") + self._text.wrappedValue = try container.decodeIfPresent(Swift.String.self, forKey: "text") } public func encode(to encoder: Swift.Encoder) throws { diff --git a/wire-tests-swift/no-manifest/src/main/swift/Person.swift b/wire-tests-swift/no-manifest/src/main/swift/Person.swift index 08465f8858..1f418f1741 100644 --- a/wire-tests-swift/no-manifest/src/main/swift/Person.swift +++ b/wire-tests-swift/no-manifest/src/main/swift/Person.swift @@ -19,6 +19,7 @@ public struct Person { /** * Email address for the customer. */ + @Defaulted(defaultValue: "") public var email: String? /** * A list of the customer's phone numbers. @@ -53,7 +54,7 @@ extension Person { ) { self.id = id self.name = name - self.email = email + self._email.wrappedValue = email self.phone = phone self.aliases = aliases } @@ -108,7 +109,7 @@ extension Person : Proto2Codable { self.id = try Person.checkIfMissing(id, "id") self.name = try Person.checkIfMissing(name, "name") - self.email = email + self._email.wrappedValue = email self.phone = phone self.aliases = aliases } @@ -131,7 +132,7 @@ extension Person : Codable { let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) self.id = try container.decode(Swift.Int32.self, forKey: "id") self.name = try container.decode(Swift.String.self, forKey: "name") - self.email = try container.decodeIfPresent(Swift.String.self, forKey: "email") + self._email.wrappedValue = try container.decodeIfPresent(Swift.String.self, forKey: "email") self.phone = try container.decodeProtoArray(Person.PhoneNumber.self, forKey: "phone") self.aliases = try container.decodeProtoArray(Swift.String.self, forKey: "aliases") } @@ -219,7 +220,7 @@ extension Person.PhoneNumber { @available(*, deprecated) public init(number: Swift.String, type: Person.PhoneType? = nil) { self.number = number - _type.wrappedValue = type + self._type.wrappedValue = type } } @@ -265,7 +266,7 @@ extension Person.PhoneNumber : Proto2Codable { self.unknownFields = try protoReader.endMessage(token: token) self.number = try Person.PhoneNumber.checkIfMissing(number, "number") - _type.wrappedValue = type + self._type.wrappedValue = type } public func encode(to protoWriter: Wire.ProtoWriter) throws { @@ -282,7 +283,7 @@ extension Person.PhoneNumber : Codable { public init(from decoder: Swift.Decoder) throws { let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) self.number = try container.decode(Swift.String.self, forKey: "number") - _type.wrappedValue = try container.decodeIfPresent(Person.PhoneType.self, forKey: "type") + self._type.wrappedValue = try container.decodeIfPresent(Person.PhoneType.self, forKey: "type") } public func encode(to encoder: Swift.Encoder) throws { diff --git a/wire-tests-swift/no-manifest/src/main/swift/Thing.swift b/wire-tests-swift/no-manifest/src/main/swift/Thing.swift index 2ee456ed1d..26ef3861f2 100644 --- a/wire-tests-swift/no-manifest/src/main/swift/Thing.swift +++ b/wire-tests-swift/no-manifest/src/main/swift/Thing.swift @@ -5,6 +5,7 @@ import Wire public struct Thing { + @Defaulted(defaultValue: "") public var name: String? public var unknownFields: Foundation.Data = .init() @@ -20,7 +21,7 @@ extension Thing { @_disfavoredOverload @available(*, deprecated) public init(name: Swift.String? = nil) { - self.name = name + self._name.wrappedValue = name } } @@ -63,7 +64,7 @@ extension Thing : Proto2Codable { } self.unknownFields = try protoReader.endMessage(token: token) - self.name = name + self._name.wrappedValue = name } public func encode(to protoWriter: Wire.ProtoWriter) throws { @@ -78,7 +79,7 @@ extension Thing : Codable { public init(from decoder: Swift.Decoder) throws { let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) - self.name = try container.decodeIfPresent(Swift.String.self, forKey: "name") + self._name.wrappedValue = try container.decodeIfPresent(Swift.String.self, forKey: "name") } public func encode(to encoder: Swift.Encoder) throws { diff --git a/wire-tests-swift/no-manifest/src/main/swift/VersionOne.swift b/wire-tests-swift/no-manifest/src/main/swift/VersionOne.swift index af553e8109..c851b18e6c 100644 --- a/wire-tests-swift/no-manifest/src/main/swift/VersionOne.swift +++ b/wire-tests-swift/no-manifest/src/main/swift/VersionOne.swift @@ -5,8 +5,11 @@ import Wire public struct VersionOne { + @Defaulted(defaultValue: 0) public var i: Int32? + @Defaulted(defaultValue: NestedVersionOne()) public var obj: NestedVersionOne? + @Defaulted(defaultValue: EnumVersionOne.SHREK_V1) public var en: EnumVersionOne? public var unknownFields: Foundation.Data = .init() @@ -26,9 +29,9 @@ extension VersionOne { obj: NestedVersionOne? = nil, en: EnumVersionOne? = nil ) { - self.i = i - self.obj = obj - self.en = en + self._i.wrappedValue = i + self._obj.wrappedValue = obj + self._en.wrappedValue = en } } @@ -75,9 +78,9 @@ extension VersionOne : Proto2Codable { } self.unknownFields = try protoReader.endMessage(token: token) - self.i = i - self.obj = obj - self.en = en + self._i.wrappedValue = i + self._obj.wrappedValue = obj + self._en.wrappedValue = en } public func encode(to protoWriter: Wire.ProtoWriter) throws { @@ -94,9 +97,9 @@ extension VersionOne : Codable { public init(from decoder: Swift.Decoder) throws { let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) - self.i = try container.decodeIfPresent(Swift.Int32.self, forKey: "i") - self.obj = try container.decodeIfPresent(NestedVersionOne.self, forKey: "obj") - self.en = try container.decodeIfPresent(EnumVersionOne.self, forKey: "en") + self._i.wrappedValue = try container.decodeIfPresent(Swift.Int32.self, forKey: "i") + self._obj.wrappedValue = try container.decodeIfPresent(NestedVersionOne.self, forKey: "obj") + self._en.wrappedValue = try container.decodeIfPresent(EnumVersionOne.self, forKey: "en") } public func encode(to encoder: Swift.Encoder) throws { diff --git a/wire-tests-swift/no-manifest/src/main/swift/VersionTwo.swift b/wire-tests-swift/no-manifest/src/main/swift/VersionTwo.swift index 40347c6af3..cb871ea121 100644 --- a/wire-tests-swift/no-manifest/src/main/swift/VersionTwo.swift +++ b/wire-tests-swift/no-manifest/src/main/swift/VersionTwo.swift @@ -5,13 +5,20 @@ import Wire public struct VersionTwo { + @Defaulted(defaultValue: 0) public var i: Int32? + @Defaulted(defaultValue: 0) public var v2_i: Int32? + @Defaulted(defaultValue: "") public var v2_s: String? + @Defaulted(defaultValue: 0) public var v2_f32: UInt32? + @Defaulted(defaultValue: 0) public var v2_f64: UInt64? public var v2_rs: [String] = [] + @Defaulted(defaultValue: NestedVersionTwo()) public var obj: NestedVersionTwo? + @Defaulted(defaultValue: EnumVersionTwo.SHREK_V2) public var en: EnumVersionTwo? public var unknownFields: Foundation.Data = .init() @@ -36,14 +43,14 @@ extension VersionTwo { obj: NestedVersionTwo? = nil, en: EnumVersionTwo? = nil ) { - self.i = i - self.v2_i = v2_i - self.v2_s = v2_s - self.v2_f32 = v2_f32 - self.v2_f64 = v2_f64 + self._i.wrappedValue = i + self._v2_i.wrappedValue = v2_i + self._v2_s.wrappedValue = v2_s + self._v2_f32.wrappedValue = v2_f32 + self._v2_f64.wrappedValue = v2_f64 self.v2_rs = v2_rs - self.obj = obj - self.en = en + self._obj.wrappedValue = obj + self._en.wrappedValue = en } } @@ -100,14 +107,14 @@ extension VersionTwo : Proto2Codable { } self.unknownFields = try protoReader.endMessage(token: token) - self.i = i - self.v2_i = v2_i - self.v2_s = v2_s - self.v2_f32 = v2_f32 - self.v2_f64 = v2_f64 + self._i.wrappedValue = i + self._v2_i.wrappedValue = v2_i + self._v2_s.wrappedValue = v2_s + self._v2_f32.wrappedValue = v2_f32 + self._v2_f64.wrappedValue = v2_f64 self.v2_rs = v2_rs - self.obj = obj - self.en = en + self._obj.wrappedValue = obj + self._en.wrappedValue = en } public func encode(to protoWriter: Wire.ProtoWriter) throws { @@ -129,14 +136,14 @@ extension VersionTwo : Codable { public init(from decoder: Swift.Decoder) throws { let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) - self.i = try container.decodeIfPresent(Swift.Int32.self, forKey: "i") - self.v2_i = try container.decodeIfPresent(Swift.Int32.self, firstOfKeys: "v2I", "v2_i") - self.v2_s = try container.decodeIfPresent(Swift.String.self, firstOfKeys: "v2S", "v2_s") - self.v2_f32 = try container.decodeIfPresent(Swift.UInt32.self, firstOfKeys: "v2F32", "v2_f32") - self.v2_f64 = try container.decodeIfPresent(stringEncoded: Swift.UInt64.self, firstOfKeys: "v2F64", "v2_f64") + self._i.wrappedValue = try container.decodeIfPresent(Swift.Int32.self, forKey: "i") + self._v2_i.wrappedValue = try container.decodeIfPresent(Swift.Int32.self, firstOfKeys: "v2I", "v2_i") + self._v2_s.wrappedValue = try container.decodeIfPresent(Swift.String.self, firstOfKeys: "v2S", "v2_s") + self._v2_f32.wrappedValue = try container.decodeIfPresent(Swift.UInt32.self, firstOfKeys: "v2F32", "v2_f32") + self._v2_f64.wrappedValue = try container.decodeIfPresent(stringEncoded: Swift.UInt64.self, firstOfKeys: "v2F64", "v2_f64") self.v2_rs = try container.decodeProtoArray(Swift.String.self, firstOfKeys: "v2Rs", "v2_rs") - self.obj = try container.decodeIfPresent(NestedVersionTwo.self, forKey: "obj") - self.en = try container.decodeIfPresent(EnumVersionTwo.self, forKey: "en") + self._obj.wrappedValue = try container.decodeIfPresent(NestedVersionTwo.self, forKey: "obj") + self._en.wrappedValue = try container.decodeIfPresent(EnumVersionTwo.self, forKey: "en") } public func encode(to encoder: Swift.Encoder) throws { diff --git a/wire-tests-swift/no-manifest/src/main/swift/VeryLongProtoNameCausingBrokenLineBreaks.swift b/wire-tests-swift/no-manifest/src/main/swift/VeryLongProtoNameCausingBrokenLineBreaks.swift index 3b28de703a..453c9aabc8 100644 --- a/wire-tests-swift/no-manifest/src/main/swift/VeryLongProtoNameCausingBrokenLineBreaks.swift +++ b/wire-tests-swift/no-manifest/src/main/swift/VeryLongProtoNameCausingBrokenLineBreaks.swift @@ -8,6 +8,7 @@ import Wire */ public struct VeryLongProtoNameCausingBrokenLineBreaks { + @Defaulted(defaultValue: "") public var foo: String? public var unknownFields: Foundation.Data = .init() @@ -23,7 +24,7 @@ extension VeryLongProtoNameCausingBrokenLineBreaks { @_disfavoredOverload @available(*, deprecated) public init(foo: Swift.String? = nil) { - self.foo = foo + self._foo.wrappedValue = foo } } @@ -66,7 +67,7 @@ extension VeryLongProtoNameCausingBrokenLineBreaks : Proto2Codable { } self.unknownFields = try protoReader.endMessage(token: token) - self.foo = foo + self._foo.wrappedValue = foo } public func encode(to protoWriter: Wire.ProtoWriter) throws { @@ -81,7 +82,7 @@ extension VeryLongProtoNameCausingBrokenLineBreaks : Codable { public init(from decoder: Swift.Decoder) throws { let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) - self.foo = try container.decodeIfPresent(Swift.String.self, forKey: "foo") + self._foo.wrappedValue = try container.decodeIfPresent(Swift.String.self, forKey: "foo") } public func encode(to encoder: Swift.Encoder) throws {