diff --git a/README.md b/README.md index 62625146b6..176d2bf4c8 100644 --- a/README.md +++ b/README.md @@ -571,17 +571,20 @@ 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? public var period: Period? public var unknownFields: Foundation.Data = .init() - public init(configure: (inout Self) -> Void = { _ in }) { + public init(configure: (inout Self) -> Swift.Void = { _ in }) { configure(&self) } @@ -591,17 +594,18 @@ public struct Dinosaur { extension Dinosaur { @_disfavoredOverload + @available(*, deprecated) public init( - name: String? = nil, - picture_urls: [String] = [], - length_meters: Double? = nil, - mass_kilograms: Double? = nil, + name: Swift.String? = nil, + picture_urls: [Swift.String] = [], + length_meters: Swift.Double? = nil, + 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._length_meters.wrappedValue = length_meters + self._mass_kilograms.wrappedValue = mass_kilograms self.period = period } @@ -625,7 +629,7 @@ extension Dinosaur : Sendable { extension Dinosaur : ProtoMessage { - public static func protoMessageTypeURL() -> String { + public static func protoMessageTypeURL() -> Swift.String { return "type.googleapis.com/squareup.dinosaurs.Dinosaur" } @@ -633,40 +637,40 @@ extension Dinosaur : ProtoMessage { extension Dinosaur : Proto2Codable { - public init(from reader: ProtoReader) throws { - var name: String? = nil - var picture_urls: [String] = [] - var length_meters: Double? = nil - var mass_kilograms: Double? = nil + public init(from protoReader: Wire.ProtoReader) throws { + var name: Swift.String? = nil + var picture_urls: [Swift.String] = [] + var length_meters: Swift.Double? = nil + var mass_kilograms: Swift.Double? = nil var period: Period? = nil - let token = try reader.beginMessage() - while let tag = try reader.nextTag(token: token) { + let token = try protoReader.beginMessage() + while let tag = try protoReader.nextTag(token: token) { switch tag { - case 1: name = try reader.decode(String.self) - case 2: try reader.decode(into: &picture_urls) - case 3: length_meters = try reader.decode(Double.self) - case 4: mass_kilograms = try reader.decode(Double.self) - case 5: period = try reader.decode(Period.self) - default: try reader.readUnknownField(tag: tag) + case 1: name = try protoReader.decode(Swift.String.self) + case 2: try protoReader.decode(into: &picture_urls) + case 3: length_meters = try protoReader.decode(Swift.Double.self) + case 4: mass_kilograms = try protoReader.decode(Swift.Double.self) + case 5: period = try protoReader.decode(Period.self) + default: try protoReader.readUnknownField(tag: tag) } } - self.unknownFields = try reader.endMessage(token: token) + 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._length_meters.wrappedValue = length_meters + self._mass_kilograms.wrappedValue = mass_kilograms self.period = period } - public func encode(to writer: ProtoWriter) throws { - try writer.encode(tag: 1, value: self.name) - try writer.encode(tag: 2, value: self.picture_urls) - try writer.encode(tag: 3, value: self.length_meters) - try writer.encode(tag: 4, value: self.mass_kilograms) - try writer.encode(tag: 5, value: self.period) - try writer.writeUnknownFields(unknownFields) + public func encode(to protoWriter: Wire.ProtoWriter) throws { + try protoWriter.encode(tag: 1, value: self.name) + try protoWriter.encode(tag: 2, value: self.picture_urls) + try protoWriter.encode(tag: 3, value: self.length_meters) + try protoWriter.encode(tag: 4, value: self.mass_kilograms) + try protoWriter.encode(tag: 5, value: self.period) + try protoWriter.writeUnknownFields(unknownFields) } } @@ -674,17 +678,17 @@ extension Dinosaur : Proto2Codable { #if !WIRE_REMOVE_CODABLE extension Dinosaur : Codable { - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: StringLiteralCodingKeys.self) - self.name = try container.decodeIfPresent(String.self, forKey: "name") - self.picture_urls = try container.decodeProtoArray(String.self, firstOfKeys: "pictureUrls", "picture_urls") - self.length_meters = try container.decodeIfPresent(Double.self, firstOfKeys: "lengthMeters", "length_meters") - self.mass_kilograms = try container.decodeIfPresent(Double.self, firstOfKeys: "massKilograms", "mass_kilograms") + public init(from decoder: Swift.Decoder) throws { + let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) + 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.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 = try container.decodeIfPresent(Period.self, forKey: "period") } - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: StringLiteralCodingKeys.self) + public func encode(to encoder: Swift.Encoder) throws { + var container = encoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) let preferCamelCase = encoder.protoKeyNameEncodingStrategy == .camelCase let includeDefaults = encoder.protoDefaultValuesEncodingStrategy == .include diff --git a/wire-runtime-swift/src/main/swift/Redactable.swift b/wire-runtime-swift/src/main/swift/Redactable.swift index eec8967531..06f0716ebc 100644 --- a/wire-runtime-swift/src/main/swift/Redactable.swift +++ b/wire-runtime-swift/src/main/swift/Redactable.swift @@ -44,16 +44,20 @@ extension Redactable { guard let label = label else { return "\(value)" } - if RedactedKeys(rawValue: label) != nil { + var strippedLabel = label + if (label.hasPrefix("_")) { + strippedLabel = String(label.dropFirst(1)) + } + if RedactedKeys(rawValue: strippedLabel) != nil { // This is a redacted field, but if it's nil then that's ok to print if "\(value)" != "nil" { - return "\(label): " + return "\(strippedLabel): " } } if value is String { - return "\(label): \"\(value)\"" + return "\(strippedLabel): \"\(value)\"" } - return "\(label): \(value)" + return "\(strippedLabel): \(value)" } if fields.count > 0 { diff --git a/wire-runtime-swift/src/test/swift/sample/Dinosaur.swift b/wire-runtime-swift/src/test/swift/sample/Dinosaur.swift index 385bc3960d..23cfa205ed 100644 --- a/wire-runtime-swift/src/test/swift/sample/Dinosaur.swift +++ b/wire-runtime-swift/src/test/swift/sample/Dinosaur.swift @@ -8,12 +8,15 @@ 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? public var period: Period? public var unknownFields: Foundation.Data = .init() @@ -36,10 +39,10 @@ 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._length_meters.wrappedValue = length_meters + self._mass_kilograms.wrappedValue = mass_kilograms self.period = period } @@ -91,10 +94,10 @@ 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._length_meters.wrappedValue = length_meters + self._mass_kilograms.wrappedValue = mass_kilograms self.period = period } @@ -114,10 +117,10 @@ 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._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 = try container.decodeIfPresent(Period.self, forKey: "period") } 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..9648fe48f8 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,40 @@ 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.isEmpty() || 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.firstOrNull { it.tag == 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()", DATA) + } + } + else -> return defaultFieldInitializer(type!!, default) + } + + return null + } + // see https://protobuf.dev/programming-guides/proto3/#default private val Field.proto3InitialValue: String get() = when { @@ -651,7 +685,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 +865,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 +1180,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 +1206,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 +1258,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 +1311,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-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..19245c70bf 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()) 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()) 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..2d4ed34039 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,21 @@ 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] = [] 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 +46,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.rep = rep - self.more_string = more_string + self._more_string.wrappedValue = more_string } } @@ -122,16 +128,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.rep = rep - self.more_string = more_string + self._more_string.wrappedValue = more_string } public func encode(to protoWriter: Wire.ProtoWriter) throws { @@ -155,16 +161,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.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 { 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/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/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..e9869d2d28 100644 --- a/wire-tests-swift/no-manifest/src/main/swift/VersionOne.swift +++ b/wire-tests-swift/no-manifest/src/main/swift/VersionOne.swift @@ -5,7 +5,9 @@ import Wire public struct VersionOne { + @Defaulted(defaultValue: 0) public var i: Int32? + @Defaulted(defaultValue: NestedVersionOne()) public var obj: NestedVersionOne? public var en: EnumVersionOne? public var unknownFields: Foundation.Data = .init() @@ -26,8 +28,8 @@ extension VersionOne { obj: NestedVersionOne? = nil, en: EnumVersionOne? = nil ) { - self.i = i - self.obj = obj + self._i.wrappedValue = i + self._obj.wrappedValue = obj self.en = en } @@ -75,8 +77,8 @@ extension VersionOne : Proto2Codable { } self.unknownFields = try protoReader.endMessage(token: token) - self.i = i - self.obj = obj + self._i.wrappedValue = i + self._obj.wrappedValue = obj self.en = en } @@ -94,8 +96,8 @@ 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._i.wrappedValue = try container.decodeIfPresent(Swift.Int32.self, forKey: "i") + self._obj.wrappedValue = try container.decodeIfPresent(NestedVersionOne.self, forKey: "obj") self.en = try container.decodeIfPresent(EnumVersionOne.self, forKey: "en") } 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..12fe2d2654 100644 --- a/wire-tests-swift/no-manifest/src/main/swift/VersionTwo.swift +++ b/wire-tests-swift/no-manifest/src/main/swift/VersionTwo.swift @@ -5,12 +5,18 @@ 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? public var en: EnumVersionTwo? public var unknownFields: Foundation.Data = .init() @@ -36,13 +42,13 @@ 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._obj.wrappedValue = obj self.en = en } @@ -100,13 +106,13 @@ 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._obj.wrappedValue = obj self.en = en } @@ -129,13 +135,13 @@ 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._obj.wrappedValue = try container.decodeIfPresent(NestedVersionTwo.self, forKey: "obj") self.en = try container.decodeIfPresent(EnumVersionTwo.self, forKey: "en") } 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 {