diff --git a/README.md b/README.md index a8f3909d87..4da21ae600 100644 --- a/README.md +++ b/README.md @@ -551,6 +551,7 @@ Swift is a pragmatic and expressive programming language with rich support for v Here's how we used Swift to model Protocol Buffers messages: * Messages are structs that conform to `Equatable`, `Codable` and `Sendable`. All Messages have value semantics. + * Messages have a memberwise initializer to populate fields. * Fields are generated as properties. * The nullability of each field's type depends on its label: `required`, `repeated` and `map` fields get non-nullable types, whereas `optional` fields are of nullable types. @@ -575,22 +576,12 @@ public struct Dinosaur { /** * URLs with images of this dinosaur. */ - public var picture_urls: [String] = [] + public var picture_urls: [String] public var length_meters: Double? public var mass_kilograms: Double? public var period: Period? - public var unknownFields: Foundation.Data = .init() + public var unknownFields: Data = .init() - public init(configure: (inout Self) -> Void = { _ in }) { - configure(&self) - } - -} - -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension Dinosaur { - - @_disfavoredOverload public init( name: String? = nil, picture_urls: [String] = [], @@ -606,7 +597,6 @@ extension Dinosaur { } } -#endif #if !WIRE_REMOVE_EQUATABLE extension Dinosaur : Equatable { @@ -624,15 +614,12 @@ extension Dinosaur : Sendable { #endif extension Dinosaur : ProtoMessage { - public static func protoMessageTypeURL() -> String { return "type.googleapis.com/squareup.dinosaurs.Dinosaur" } - } extension Dinosaur : Proto2Codable { - public init(from reader: ProtoReader) throws { var name: String? = nil var picture_urls: [String] = [] @@ -668,12 +655,10 @@ extension Dinosaur : Proto2Codable { try writer.encode(tag: 5, value: self.period) try writer.writeUnknownFields(unknownFields) } - } #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") @@ -696,7 +681,6 @@ extension Dinosaur : Codable { try container.encodeIfPresent(self.mass_kilograms, forKey: preferCamelCase ? "massKilograms" : "mass_kilograms") try container.encodeIfPresent(self.period, forKey: "period") } - } #endif ``` @@ -704,10 +688,10 @@ extension Dinosaur : Codable { Creating and accessing proto models is easy: ```swift -let stegosaurus = Dinosaur { - $0.name = "Stegosaurus" - $0.period = .JURASSIC -} +let stegosaurus = Dinosaur( + name: "Stegosaurus", + period: .JURASSIC +) print("My favorite dinosaur existed in the \(stegosaurus.period) period.") ``` diff --git a/wire-runtime-swift/src/test/swift/CodableTests.swift b/wire-runtime-swift/src/test/swift/CodableTests.swift index 02c797f18f..23f8739282 100644 --- a/wire-runtime-swift/src/test/swift/CodableTests.swift +++ b/wire-runtime-swift/src/test/swift/CodableTests.swift @@ -44,20 +44,20 @@ extension CodableTests { } """ - let expected = SimpleOptional2 { - $0.opt_int32 = 1 - $0.opt_int64 = 2 - $0.opt_uint32 = 3 - $0.opt_uint64 = 4 - $0.opt_float = 5 - $0.opt_double = 6 - $0.opt_bytes = Foundation.Data(hexEncoded: "0123456") - $0.opt_string = "foo" - $0.opt_enum = .UNKNOWN - $0.repeated_int32 = [1, 2, 3] - $0.repeated_string = ["foo", "bar", "baz"] - $0.map_int32_string = [1: "foo", 2: "bar"] - } + let expected = SimpleOptional2( + opt_int32: 1, + opt_int64: 2, + opt_uint32: 3, + opt_uint64: 4, + opt_float: 5, + opt_double: 6, + opt_bytes: Foundation.Data(hexEncoded: "0123456"), + opt_string: "foo", + opt_enum: .UNKNOWN, + repeated_int32: [1, 2, 3], + repeated_string: ["foo", "bar", "baz"], + map_int32_string: [1: "foo", 2: "bar"] + ) try assertDecode(json: json, expected: expected) } @@ -92,12 +92,11 @@ extension CodableTests { req_double: 6, req_bytes: Foundation.Data(hexEncoded: "0123456")!, req_string: "foo", - req_enum: .UNKNOWN - ) { - $0.repeated_int32 = [1, 2, 3] - $0.repeated_string = ["foo", "bar", "baz"] - $0.map_int32_string = [1: "foo", 2: "bar"] - } + req_enum: .UNKNOWN, + repeated_int32: [1, 2, 3], + repeated_string: ["foo", "bar", "baz"], + map_int32_string: [1: "foo", 2: "bar"] + ) try assertDecode(json: json, expected: expected) } @@ -108,20 +107,20 @@ extension CodableTests { extension CodableTests { func testEncodeOptional() throws { // Only include one value in maps until https://bugs.swift.org/browse/SR-13414 is fixed. - let proto = SimpleOptional2 { - $0.opt_int32 = 1 - $0.opt_int64 = 2 - $0.opt_uint32 = 3 - $0.opt_uint64 = 4 - $0.opt_float = 5 - $0.opt_double = 6 - $0.opt_bytes = Foundation.Data(hexEncoded: "0123456") - $0.opt_string = "foo" - $0.opt_enum = .UNKNOWN - $0.repeated_int32 = [1, 2, 3] - $0.repeated_string = ["foo", "bar", "baz"] - $0.map_int32_string = [1: "foo"] - } + let proto = SimpleOptional2( + opt_int32: 1, + opt_int64: 2, + opt_uint32: 3, + opt_uint64: 4, + opt_float: 5, + opt_double: 6, + opt_bytes: Foundation.Data(hexEncoded: "0123456"), + opt_string: "foo", + opt_enum: .UNKNOWN, + repeated_int32: [1, 2, 3], + repeated_string: ["foo", "bar", "baz"], + map_int32_string: [1: "foo"] + ) let expected = """ { @@ -156,12 +155,11 @@ extension CodableTests { req_double: 6, req_bytes: Foundation.Data(hexEncoded: "0123456")!, req_string: "foo", - req_enum: .UNKNOWN - ) { - $0.repeated_int32 = [1, 2, 3] - $0.repeated_string = ["foo", "bar", "baz"] - $0.map_int32_string = [1: "foo"] - } + req_enum: .UNKNOWN, + repeated_int32: [1, 2, 3], + repeated_string: ["foo", "bar", "baz"], + map_int32_string: [1: "foo"] + ) let expected = """ { @@ -246,12 +244,12 @@ extension CodableTests { } """ - let proto = SimpleOptional2 { - $0.opt_double = 6 - $0.opt_enum = .A - $0.repeated_string = ["B"] - $0.map_int32_string = [1 : "foo"] - } + let proto = SimpleOptional2( + opt_double: 6, + opt_enum: .A, + repeated_string: ["B"], + map_int32_string: [1 : "foo"] + ) try assertEncode(proto: proto, expected: json) } @@ -271,13 +269,13 @@ extension CodableTests { } """ - let proto = SimpleOptional2 { - $0.opt_int64 = 5 - $0.opt_double = 6 - $0.opt_enum = .A - $0.repeated_string = ["B"] - $0.map_int32_string = [1 : "foo"] - } + let proto = SimpleOptional2( + opt_int64: 5, + opt_double: 6, + opt_enum: .A, + repeated_string: ["B"], + map_int32_string: [1 : "foo"] + ) try assertDecode(json: json, expected: proto) } @@ -287,10 +285,7 @@ extension CodableTests { extension CodableTests { func testHeapRoundtrip() throws { - let proto = SwiftStackOverflow { - $0.value3 = "hello" - } - + let proto = SwiftStackOverflow(value3: "hello") let json = """ { "value3":"hello" diff --git a/wire-runtime-swift/src/test/swift/DefaultedTests.swift b/wire-runtime-swift/src/test/swift/DefaultedTests.swift index c628c3479c..ddc2f42904 100644 --- a/wire-runtime-swift/src/test/swift/DefaultedTests.swift +++ b/wire-runtime-swift/src/test/swift/DefaultedTests.swift @@ -25,17 +25,13 @@ final class DefaultedTests: XCTestCase { } func testProjectedValueIsWrappedValue() throws { - let phoneNumber = Person.PhoneNumber(number: "1234567890") { - $0.type = .WORK - } + let phoneNumber = Person.PhoneNumber(number: "1234567890", type: Person.PhoneType.WORK) XCTAssertEqual(phoneNumber.type, Person.PhoneType.WORK) XCTAssertEqual(phoneNumber.$type, Person.PhoneType.WORK) } func testProjectedValueWhenResettingWrappedValue() throws { - var phoneNumber = Person.PhoneNumber(number: "1234567890") { - $0.type = .WORK - } + var phoneNumber = Person.PhoneNumber(number: "1234567890", type: Person.PhoneType.WORK) XCTAssertEqual(phoneNumber.type, Person.PhoneType.WORK) XCTAssertEqual(phoneNumber.$type, Person.PhoneType.WORK) phoneNumber.type = nil diff --git a/wire-runtime-swift/src/test/swift/ProtoReaderTests.swift b/wire-runtime-swift/src/test/swift/ProtoReaderTests.swift index 48437e76fe..5f1185f6d8 100644 --- a/wire-runtime-swift/src/test/swift/ProtoReaderTests.swift +++ b/wire-runtime-swift/src/test/swift/ProtoReaderTests.swift @@ -159,10 +159,7 @@ final class ProtoReaderTests: XCTestCase { 00 // Length 0 """)! try test(data: data) { reader in - let expected = Parent { - $0.name = "Bob" - $0.child = .init() - } + let expected = Parent(name: "Bob", child: .init()) XCTAssertEqual(try reader.decode(Parent.self), expected) } } @@ -330,10 +327,7 @@ final class ProtoReaderTests: XCTestCase { 01 // Value 1 """)! try test(data: data, enumStrategy: .returnNil) { reader in - let message = OneOfs { - $0.standalone_enum = .A - $0.choice = .similar_enum_option(.A) - } + let message = OneOfs(standalone_enum: OneOfs.NestedEnum.A, choice: OneOfs.Choice.similar_enum_option(OneOfs.NestedEnum.A)) XCTAssertEqual(try reader.decode(OneOfs.self), message) } } @@ -346,9 +340,7 @@ final class ProtoReaderTests: XCTestCase { 02 // Value 2 """)! try test(data: data, enumStrategy: .returnNil) { reader in - let message = OneOfs { - $0.standalone_enum = .A - } + let message = OneOfs(standalone_enum: OneOfs.NestedEnum.A, choice: nil) XCTAssertEqual(try reader.decode(OneOfs.self), message) } } diff --git a/wire-runtime-swift/src/test/swift/ProtoWriterTests.swift b/wire-runtime-swift/src/test/swift/ProtoWriterTests.swift index 677375ad5b..a86644e7c8 100644 --- a/wire-runtime-swift/src/test/swift/ProtoWriterTests.swift +++ b/wire-runtime-swift/src/test/swift/ProtoWriterTests.swift @@ -123,20 +123,20 @@ final class ProtoWriterTests: XCTestCase { func testEncodeDefaultProto2Values() throws { let writer = ProtoWriter() - let proto = SimpleOptional2 { - $0.opt_int32 = 0 - $0.opt_int64 = 0 - $0.opt_uint32 = 0 - $0.opt_uint64 = 0 - $0.opt_float = 0 - $0.opt_double = 0 - $0.opt_bytes = .init() - $0.opt_string = "" - $0.opt_enum = .UNKNOWN - $0.repeated_int32 = [] - $0.repeated_string = [] - $0.map_int32_string = [:] - } + let proto = SimpleOptional2( + opt_int32: 0, + opt_int64: 0, + opt_uint32: 0, + opt_uint64: 0, + opt_float: 0, + opt_double: 0, + opt_bytes: .init(), + opt_string: "", + opt_enum: .UNKNOWN, + repeated_int32: [], + repeated_string: [], + map_int32_string: [:] + ) try writer.encode(tag: 1, value: proto) // All values are encoded in proto2, including defaults. @@ -191,12 +191,11 @@ final class ProtoWriterTests: XCTestCase { req_double: 0, req_bytes: .init(), req_string: "", - req_enum: .UNKNOWN - ) { - $0.repeated_int32 = [] - $0.repeated_string = [] - $0.map_int32_string = [:] - } + req_enum: .UNKNOWN, + repeated_int32: [], + repeated_string: [], + map_int32_string: [:] + ) try writer.encode(tag: 1, value: proto) // No data should be encoded. Just the top-level message tag with a length of zero. @@ -552,10 +551,7 @@ final class ProtoWriterTests: XCTestCase { func testEncodePackedRepeatedProto2Default() throws { let writer = ProtoWriter() let data = Data(json_data: "12") - let person = Person(name: "name", id: 1, data: data) { - $0.email = "email" - $0.ids = [1, 2, 3] - } + let person = Person(name: "name", id: 1, email: "email", ids: [1, 2, 3], data: data) try writer.encode(tag: 1, value: person) // Proto2 should used "packed: false" by default. @@ -587,10 +583,7 @@ final class ProtoWriterTests: XCTestCase { func testEncodePackedRepeatedProto3Default() throws { let writer = ProtoWriter() - let person = Person3(name: "name", id: 1) { - $0.email = "email" - $0.ids = [1, 2, 3] - } + let person = Person3(name: "name", id: 1, email: "email", ids: [1, 2, 3]) try writer.encode(tag: 1, value: person) // Proto3 should used "packed: true" by default. diff --git a/wire-runtime-swift/src/test/swift/RedactableTests.swift b/wire-runtime-swift/src/test/swift/RedactableTests.swift index fa788db356..dc0ee2a397 100644 --- a/wire-runtime-swift/src/test/swift/RedactableTests.swift +++ b/wire-runtime-swift/src/test/swift/RedactableTests.swift @@ -28,16 +28,12 @@ final class RedactableTests: XCTestCase { } func testRedactedOneOf() { - let redacted1 = Redacted(name: "Foo") { - $0.choice = .yes("yes") - } + let redacted1 = Redacted(name: "Foo", choice: .yes("yes")) XCTAssertEqual( redacted1.description, "Redacted(name: , nested: nil, choice: Optional(Choice(yes: \"yes\")), unknownFields: 0 bytes)" ) - let redacted2 = Redacted(name: "Foo") { - $0.choice = .no("no") - } + let redacted2 = Redacted(name: "Foo", choice: .no("no")) XCTAssertEqual( redacted2.description, "Redacted(name: , nested: nil, choice: Optional(Choice(no: )), unknownFields: 0 bytes)" @@ -55,11 +51,13 @@ final class RedactableTests: XCTestCase { } func testNestedRedactedField() { - let redacted = Redacted2(name: "foo") { - $0.partially_redacted = Redacted3(name: "bar") { - $0.enabled = true - } - } + let redacted = Redacted2( + name: "foo", + partially_redacted: .init( + name: "bar", + enabled: true + ) + ) XCTAssertEqual( redacted.description, "Redacted2(name: \"foo\", fully_redacted: nil, partially_redacted: Optional(Redacted3(name: \"bar\", enabled: , unknownFields: 0 bytes)), unknownFields: 0 bytes)" diff --git a/wire-runtime-swift/src/test/swift/RoundTripTests.swift b/wire-runtime-swift/src/test/swift/RoundTripTests.swift index 892e723127..18afee0823 100644 --- a/wire-runtime-swift/src/test/swift/RoundTripTests.swift +++ b/wire-runtime-swift/src/test/swift/RoundTripTests.swift @@ -21,13 +21,14 @@ final class RoundTripTests: XCTestCase { func testPersonEncodeDecode() throws { let personData = Data(json_data: "") - let person = Person(name: "Luke Skywalker", id: 42, data: personData) { - $0.email = "luke@skywalker.net" - $0.phone = [ - Person.PhoneNumber(number: "800-555-1234") { $0.type = .WORK }, - ] - $0.aliases = ["Nerfherder"] - } + let person = Person( + name: "Luke Skywalker", + id: 42, + email: "luke@skywalker.net", + phone: [.init(number: "800-555-1234", type: .WORK)], + aliases: ["Nerfherder"], + data: personData + ) let encoder = ProtoEncoder() let data = try encoder.encode(person) @@ -45,12 +46,11 @@ final class RoundTripTests: XCTestCase { string_value: "", bytes_value: Foundation.Data(), bool_value: false, - enum_value: .UNKNOWN - ) { - $0.message_value = nil - $0.repeated_value = [] - $0.map_value = [:] - } + enum_value: .UNKNOWN, + message_value: nil, + repeated_value: [], + map_value: [:] + ) let encoder = ProtoEncoder() let data = try encoder.encode(empty) diff --git a/wire-runtime-swift/src/test/swift/sample/Dinosaur.swift b/wire-runtime-swift/src/test/swift/sample/Dinosaur.swift index 9502d06acf..e42fe05147 100644 --- a/wire-runtime-swift/src/test/swift/sample/Dinosaur.swift +++ b/wire-runtime-swift/src/test/swift/sample/Dinosaur.swift @@ -12,28 +12,17 @@ public struct Dinosaur { /** * URLs with images of this dinosaur. */ - public var picture_urls: [String] = [] + public var picture_urls: [String] public var length_meters: Double? public var mass_kilograms: Double? public var period: Period? public var unknownFields: Foundation.Data = .init() - public init(configure: (inout Self) -> Void = { _ in }) { - configure(&self) - } - -} - -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension Dinosaur { - - @_disfavoredOverload - @available(*, deprecated) public init( - name: Swift.String? = nil, - picture_urls: [Swift.String] = [], - length_meters: Swift.Double? = nil, - mass_kilograms: Swift.Double? = nil, + name: String? = nil, + picture_urls: [String] = [], + length_meters: Double? = nil, + mass_kilograms: Double? = nil, period: Period? = nil ) { self.name = name @@ -44,7 +33,6 @@ extension Dinosaur { } } -#endif #if !WIRE_REMOVE_EQUATABLE extension Dinosaur : Equatable { 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 832fef9c00..0d74ee065c 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 @@ -46,7 +46,6 @@ import io.outfoxx.swiftpoet.FileMemberSpec import io.outfoxx.swiftpoet.FileSpec import io.outfoxx.swiftpoet.FunctionSignatureSpec import io.outfoxx.swiftpoet.FunctionSpec -import io.outfoxx.swiftpoet.FunctionTypeName import io.outfoxx.swiftpoet.INT import io.outfoxx.swiftpoet.INT32 import io.outfoxx.swiftpoet.INT64 @@ -66,9 +65,9 @@ import io.outfoxx.swiftpoet.TypeSpec import io.outfoxx.swiftpoet.TypeVariableName import io.outfoxx.swiftpoet.UINT32 import io.outfoxx.swiftpoet.UINT64 -import io.outfoxx.swiftpoet.VOID import io.outfoxx.swiftpoet.joinToCode import io.outfoxx.swiftpoet.parameterizedBy +import java.util.Locale.US import okio.ByteString.Companion.encode class SwiftGenerator private constructor( @@ -138,9 +137,6 @@ class SwiftGenerator private constructor( internal val Field.valueType: ProtoType get() = type!!.valueType!! - private val Field.isRequiredParameter: Boolean - get() = !isOptional && !isRepeated && !isMap - private val Field.isCollection: Boolean get() = when (typeName.makeNonOptional()) { DATA, STRING -> true @@ -259,7 +255,7 @@ class SwiftGenerator private constructor( fileMembers: MutableList, ): List { val structType = type.typeName - val oneOfEnumNames = type.oneOfs.associateWith { structType.nestedType(it.name.replaceFirstChar(Char::uppercase)) } + val oneOfEnumNames = type.oneOfs.associateWith { structType.nestedType(it.name.capitalize(US)) } // TODO use a NameAllocator val propertyNames = type.fields.map { it.name } + type.oneOfs.map { it.name } @@ -290,7 +286,28 @@ class SwiftGenerator private constructor( ) generateMessageStoragePropertyDelegates(type, storageName, storageType) - generateMessageStorageDelegateConstructor(type, storageName, structType, storageType, oneOfEnumNames, fileMembers) + + addFunction( + FunctionSpec.constructorBuilder() + .addModifiers(PUBLIC) + .addParameters(type, oneOfEnumNames, includeDefaults = true) + .apply { + val storageParams = mutableListOf() + type.fields.forEach { field -> + storageParams += CodeBlock.of("%1N: %1N", field.name) + } + type.oneOfs.forEach { oneOf -> + storageParams += CodeBlock.of("%1N: %1N", oneOf.name) + } + addStatement( + "self.%N = %T(%L)", + storageName, + storageType, + storageParams.joinToCode(separator = ",%W"), + ) + } + .build(), + ) addFunction( FunctionSpec.builder("copyStorage") @@ -302,7 +319,7 @@ class SwiftGenerator private constructor( ) } else { generateMessageProperties(type, oneOfEnumNames) - generateMessageConstructor(type, structType, oneOfEnumNames, fileMembers) + generateMessageConstructor(type, oneOfEnumNames) } generateMessageOneOfs(type, oneOfEnumNames, fileMembers) @@ -369,7 +386,7 @@ class SwiftGenerator private constructor( .addModifiers(PUBLIC) .apply { generateMessageProperties(type, oneOfEnumNames, forStorageType = true) - generateMessageConstructor(type, storageType, oneOfEnumNames, fileMembers, includeMemberwiseDefaults = false) + generateMessageConstructor(type, oneOfEnumNames, includeDefaults = false) } .build(), ) @@ -936,10 +953,8 @@ class SwiftGenerator private constructor( type: MessageType, oneOfEnumNames: Map, includeDefaults: Boolean = true, - includeOneOfs: Boolean = true, - fieldsFilter: (Field) -> Boolean = { true }, ) = apply { - type.fields.filter(fieldsFilter).forEach { field -> + type.fields.forEach { field -> addParameter( ParameterSpec.builder(field.name, field.typeName) .apply { @@ -950,185 +965,38 @@ class SwiftGenerator private constructor( .build(), ) } - if (includeOneOfs) { - type.oneOfs.forEach { oneOf -> - val enumName = oneOfEnumNames.getValue(oneOf).makeOptional() - addParameter( - ParameterSpec.builder(oneOf.name, enumName) - .defaultValue("nil") - .build(), - ) - } - } - } - - private fun TypeSpec.Builder.generateMessageStorageDelegateConstructor( - type: MessageType, - storageName: String, - structType: DeclaredTypeName, - storageType: DeclaredTypeName, - oneOfEnumNames: Map, - fileMembers: MutableList, - ) { - val needsConfigure = type.fields.any { !it.isRequiredParameter } || type.oneOfs.isNotEmpty() - - addFunction( - FunctionSpec.constructorBuilder() - .addModifiers(PUBLIC) - .addParameters( - type, - oneOfEnumNames, - includeDefaults = false, - includeOneOfs = false, - fieldsFilter = { it.isRequiredParameter }, - ) - .apply { - if (needsConfigure) { - val closureType = FunctionTypeName.get( - TypeVariableName.typeVariable("inout Self.${storageType.simpleName}"), - returnType = VOID, - ) - - addParameter( - ParameterSpec.builder("configure", closureType) - .defaultValue("{ _ in }") - .build(), - ) - } - } - .apply { - val storageParams = mutableListOf() - type.fields.filter { it.isRequiredParameter }.forEach { field -> - storageParams += CodeBlock.of("%1N: %1N", field.name) - } - - if (needsConfigure) { - storageParams += CodeBlock.of("%1N: %1N", "configure") - } - - addStatement( - "self.%N = %T(\n%L\n)", - storageName, - storageType, - storageParams.joinToCode(separator = ",\n"), - ) - } - .build(), - ) - - if (!needsConfigure) { - return - } - - // These will be removed in November 2023 - val memberwiseExtension = ExtensionSpec.builder(structType) - .addFunction( - FunctionSpec.constructorBuilder() - .addModifiers(PUBLIC) - .addParameters(type, oneOfEnumNames, includeDefaults = true) - .addAttribute(AttributeSpec.builder("_disfavoredOverload").build()) - .addAttribute(deprecated) - .apply { - val storageParams = mutableListOf() - type.fields.forEach { field -> - storageParams += CodeBlock.of("%1N: %1N", field.name) - } - type.oneOfs.forEach { oneOf -> - storageParams += CodeBlock.of("%1N: %1N", oneOf.name) - } - addStatement( - "self.%N = %T(\n%L\n)", - storageName, - storageType, - storageParams.joinToCode(separator = ",\n"), - ) - } + type.oneOfs.forEach { oneOf -> + val enumName = oneOfEnumNames.getValue(oneOf).makeOptional() + addParameter( + ParameterSpec.builder(oneOf.name, enumName) + .defaultValue("nil") .build(), ) - .build() - - fileMembers += FileMemberSpec.builder(memberwiseExtension) - .addGuard("$FLAG_INCLUDE_MEMBERWISE_INITIALIZER") - .build() + } } private fun TypeSpec.Builder.generateMessageConstructor( type: MessageType, - structType: DeclaredTypeName, oneOfEnumNames: Map, - fileMembers: MutableList, - includeMemberwiseDefaults: Boolean = true, + includeDefaults: Boolean = true, ) { - val needsConfigure = type.fields.any { !it.isRequiredParameter } || type.oneOfs.isNotEmpty() - addFunction( FunctionSpec.constructorBuilder() .addModifiers(PUBLIC) - .addParameters( - type, - oneOfEnumNames, - includeDefaults = false, - includeOneOfs = false, - fieldsFilter = { it.isRequiredParameter }, - ) + .addParameters(type, oneOfEnumNames, includeDefaults) .apply { - if (needsConfigure) { - val closureType = FunctionTypeName.get( - TypeVariableName.typeVariable("inout Self"), - returnType = VOID, - ) - - addParameter( - ParameterSpec.builder("configure", closureType) - .defaultValue("{ _ in }") - .build(), - ) - } - } - .apply { - type.fields.filter { it.isRequiredParameter }.forEach { field -> + type.fields.forEach { field -> addStatement( if (field.default != null) "_%1N.wrappedValue = %1N" else { "self.%1N = %1N" }, field.name, ) } - if (needsConfigure) { - addStatement("configure(&self)") + type.oneOfs.forEach { oneOf -> + addStatement("self.%1N = %1N", oneOf.name) } } .build(), ) - - if (!needsConfigure) { - return - } - - // These will be removed in November 2023 - val memberwiseExtension = ExtensionSpec.builder(structType) - .addFunction( - FunctionSpec.constructorBuilder() - .addModifiers(PUBLIC) - .addParameters(type, oneOfEnumNames, includeDefaults = includeMemberwiseDefaults) - .addAttribute(AttributeSpec.builder("_disfavoredOverload").build()) - .addAttribute(deprecated) - .apply { - type.fields.forEach { field -> - addStatement( - if (field.default != null) "_%1N.wrappedValue = %1N" else { "self.%1N = %1N" }, - field.name, - ) - } - type.oneOfs.forEach { oneOf -> - addStatement("self.%1N = %1N", oneOf.name) - } - } - .build(), - ) - .build() - - fileMembers += FileMemberSpec.builder(memberwiseExtension) - .addGuard("$FLAG_INCLUDE_MEMBERWISE_INITIALIZER") - .build() } private fun TypeSpec.Builder.generateMessageProperties( @@ -1153,12 +1021,6 @@ class SwiftGenerator private constructor( property.addAttribute(AttributeSpec.builder(defaulted).addArgument("defaultValue: $defaultValue").build()) } - if (field.isMap) { - property.initializer("[:]") - } else if (field.isRepeated) { - property.initializer("[]") - } - addProperty(property.build()) } @@ -1528,7 +1390,6 @@ class SwiftGenerator private constructor( private const val FLAG_REMOVE_EQUATABLE = "WIRE_REMOVE_EQUATABLE" private const val FLAG_REMOVE_HASHABLE = "WIRE_REMOVE_HASHABLE" private const val FLAG_REMOVE_REDACTABLE = "WIRE_REMOVE_REDACTABLE" - private const val FLAG_INCLUDE_MEMBERWISE_INITIALIZER = "WIRE_INCLUDE_MEMBERWISE_INITIALIZER" private val NEEDS_CUSTOM_CODABLE = setOf("Duration", "Timestamp") diff --git a/wire-tests-proto3-swift/src/main/swift/ContainsDuration.swift b/wire-tests-proto3-swift/src/main/swift/ContainsDuration.swift index c6c229d170..73b9426198 100644 --- a/wire-tests-proto3-swift/src/main/swift/ContainsDuration.swift +++ b/wire-tests-proto3-swift/src/main/swift/ContainsDuration.swift @@ -8,23 +8,11 @@ public struct ContainsDuration { public var duration: Duration? public var unknownFields: Foundation.Data = .init() - public init(configure: (inout Self) -> Void = { _ in }) { - configure(&self) - } - -} - -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension ContainsDuration { - - @_disfavoredOverload - @available(*, deprecated) public init(duration: Duration? = nil) { self.duration = duration } } -#endif #if !WIRE_REMOVE_EQUATABLE extension ContainsDuration : Equatable { diff --git a/wire-tests-proto3-swift/src/main/swift/ContainsTimestamp.swift b/wire-tests-proto3-swift/src/main/swift/ContainsTimestamp.swift index 9485261df4..d11e8f64a7 100644 --- a/wire-tests-proto3-swift/src/main/swift/ContainsTimestamp.swift +++ b/wire-tests-proto3-swift/src/main/swift/ContainsTimestamp.swift @@ -8,23 +8,11 @@ public struct ContainsTimestamp { public var timestamp: Timestamp? public var unknownFields: Foundation.Data = .init() - public init(configure: (inout Self) -> Void = { _ in }) { - configure(&self) - } - -} - -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension ContainsTimestamp { - - @_disfavoredOverload - @available(*, deprecated) public init(timestamp: Timestamp? = nil) { self.timestamp = timestamp } } -#endif #if !WIRE_REMOVE_EQUATABLE extension ContainsTimestamp : Equatable { diff --git a/wire-tests-swift/src/main/swift/AllTypes.swift b/wire-tests-swift/src/main/swift/AllTypes.swift index bc4bdd4af4..79b36fc077 100644 --- a/wire-tests-swift/src/main/swift/AllTypes.swift +++ b/wire-tests-swift/src/main/swift/AllTypes.swift @@ -19,6 +19,23 @@ public struct AllTypes { } public init( + opt_int32: Int32? = nil, + opt_uint32: UInt32? = nil, + opt_sint32: Int32? = nil, + opt_fixed32: UInt32? = nil, + opt_sfixed32: Int32? = nil, + opt_int64: Int64? = nil, + opt_uint64: UInt64? = nil, + opt_sint64: Int64? = nil, + opt_fixed64: UInt64? = nil, + opt_sfixed64: Int64? = nil, + opt_bool: Bool? = nil, + opt_float: Float? = nil, + opt_double: Double? = nil, + opt_string: String? = nil, + opt_bytes: Foundation.Data? = nil, + opt_nested_enum: AllTypes.NestedEnum? = nil, + opt_nested_message: AllTypes.NestedMessage? = nil, req_int32: Int32, req_uint32: UInt32, req_sint32: Int32, @@ -36,28 +53,182 @@ public struct AllTypes { req_bytes: Foundation.Data, req_nested_enum: AllTypes.NestedEnum, req_nested_message: AllTypes.NestedMessage, - configure: (inout Self.Storage) -> Void = { _ in } + rep_int32: [Int32] = [], + rep_uint32: [UInt32] = [], + rep_sint32: [Int32] = [], + rep_fixed32: [UInt32] = [], + rep_sfixed32: [Int32] = [], + rep_int64: [Int64] = [], + rep_uint64: [UInt64] = [], + rep_sint64: [Int64] = [], + rep_fixed64: [UInt64] = [], + rep_sfixed64: [Int64] = [], + rep_bool: [Bool] = [], + rep_float: [Float] = [], + rep_double: [Double] = [], + rep_string: [String] = [], + rep_bytes: [Foundation.Data] = [], + rep_nested_enum: [AllTypes.NestedEnum] = [], + rep_nested_message: [AllTypes.NestedMessage] = [], + pack_int32: [Int32] = [], + pack_uint32: [UInt32] = [], + pack_sint32: [Int32] = [], + pack_fixed32: [UInt32] = [], + pack_sfixed32: [Int32] = [], + pack_int64: [Int64] = [], + pack_uint64: [UInt64] = [], + pack_sint64: [Int64] = [], + pack_fixed64: [UInt64] = [], + pack_sfixed64: [Int64] = [], + pack_bool: [Bool] = [], + pack_float: [Float] = [], + pack_double: [Double] = [], + pack_nested_enum: [AllTypes.NestedEnum] = [], + default_int32: Int32? = nil, + default_uint32: UInt32? = nil, + default_sint32: Int32? = nil, + default_fixed32: UInt32? = nil, + default_sfixed32: Int32? = nil, + default_int64: Int64? = nil, + default_uint64: UInt64? = nil, + default_sint64: Int64? = nil, + default_fixed64: UInt64? = nil, + default_sfixed64: Int64? = nil, + default_bool: Bool? = nil, + default_float: Float? = nil, + default_double: Double? = nil, + default_string: String? = nil, + default_bytes: Foundation.Data? = nil, + default_nested_enum: AllTypes.NestedEnum? = nil, + map_int32_int32: [Int32 : Int32] = [:], + map_string_string: [String : String] = [:], + map_string_message: [String : AllTypes.NestedMessage] = [:], + map_string_enum: [String : AllTypes.NestedEnum] = [:], + array_int32: [Int32] = [], + array_uint32: [UInt32] = [], + array_sint32: [Int32] = [], + array_fixed32: [UInt32] = [], + array_sfixed32: [Int32] = [], + array_int64: [Int64] = [], + array_uint64: [UInt64] = [], + array_sint64: [Int64] = [], + array_fixed64: [UInt64] = [], + array_sfixed64: [Int64] = [], + array_float: [Float] = [], + array_double: [Double] = [], + ext_opt_int32: Int32? = nil, + ext_opt_uint32: UInt32? = nil, + ext_opt_sint32: Int32? = nil, + ext_opt_fixed32: UInt32? = nil, + ext_opt_sfixed32: Int32? = nil, + ext_opt_int64: Int64? = nil, + ext_opt_uint64: UInt64? = nil, + ext_opt_sint64: Int64? = nil, + ext_opt_fixed64: UInt64? = nil, + ext_opt_sfixed64: Int64? = nil, + ext_opt_bool: Bool? = nil, + ext_opt_float: Float? = nil, + ext_opt_double: Double? = nil, + ext_opt_string: String? = nil, + ext_opt_bytes: Foundation.Data? = nil, + ext_opt_nested_enum: AllTypes.NestedEnum? = nil, + ext_opt_nested_message: AllTypes.NestedMessage? = nil, + ext_rep_int32: [Int32] = [], + ext_rep_uint32: [UInt32] = [], + ext_rep_sint32: [Int32] = [], + ext_rep_fixed32: [UInt32] = [], + ext_rep_sfixed32: [Int32] = [], + ext_rep_int64: [Int64] = [], + ext_rep_uint64: [UInt64] = [], + ext_rep_sint64: [Int64] = [], + ext_rep_fixed64: [UInt64] = [], + ext_rep_sfixed64: [Int64] = [], + ext_rep_bool: [Bool] = [], + ext_rep_float: [Float] = [], + ext_rep_double: [Double] = [], + ext_rep_string: [String] = [], + ext_rep_bytes: [Foundation.Data] = [], + ext_rep_nested_enum: [AllTypes.NestedEnum] = [], + ext_rep_nested_message: [AllTypes.NestedMessage] = [], + ext_pack_int32: [Int32] = [], + ext_pack_uint32: [UInt32] = [], + ext_pack_sint32: [Int32] = [], + ext_pack_fixed32: [UInt32] = [], + ext_pack_sfixed32: [Int32] = [], + ext_pack_int64: [Int64] = [], + ext_pack_uint64: [UInt64] = [], + ext_pack_sint64: [Int64] = [], + ext_pack_fixed64: [UInt64] = [], + ext_pack_sfixed64: [Int64] = [], + ext_pack_bool: [Bool] = [], + ext_pack_float: [Float] = [], + ext_pack_double: [Double] = [], + ext_pack_nested_enum: [AllTypes.NestedEnum] = [] ) { - self.storage = AllTypes.Storage( - req_int32: req_int32, - req_uint32: req_uint32, - req_sint32: req_sint32, - req_fixed32: req_fixed32, - req_sfixed32: req_sfixed32, - req_int64: req_int64, - req_uint64: req_uint64, - req_sint64: req_sint64, - req_fixed64: req_fixed64, - req_sfixed64: req_sfixed64, - req_bool: req_bool, - req_float: req_float, - req_double: req_double, - req_string: req_string, - req_bytes: req_bytes, - req_nested_enum: req_nested_enum, - req_nested_message: req_nested_message, - configure: configure - ) + self.storage = AllTypes.Storage(opt_int32: opt_int32, opt_uint32: opt_uint32, + opt_sint32: opt_sint32, opt_fixed32: opt_fixed32, opt_sfixed32: opt_sfixed32, + opt_int64: opt_int64, opt_uint64: opt_uint64, opt_sint64: opt_sint64, + opt_fixed64: opt_fixed64, opt_sfixed64: opt_sfixed64, opt_bool: opt_bool, + opt_float: opt_float, opt_double: opt_double, opt_string: opt_string, + opt_bytes: opt_bytes, opt_nested_enum: opt_nested_enum, + opt_nested_message: opt_nested_message, req_int32: req_int32, + req_uint32: req_uint32, req_sint32: req_sint32, req_fixed32: req_fixed32, + req_sfixed32: req_sfixed32, req_int64: req_int64, req_uint64: req_uint64, + req_sint64: req_sint64, req_fixed64: req_fixed64, req_sfixed64: req_sfixed64, + req_bool: req_bool, req_float: req_float, req_double: req_double, + req_string: req_string, req_bytes: req_bytes, req_nested_enum: req_nested_enum, + req_nested_message: req_nested_message, rep_int32: rep_int32, + rep_uint32: rep_uint32, rep_sint32: rep_sint32, rep_fixed32: rep_fixed32, + rep_sfixed32: rep_sfixed32, rep_int64: rep_int64, rep_uint64: rep_uint64, + rep_sint64: rep_sint64, rep_fixed64: rep_fixed64, rep_sfixed64: rep_sfixed64, + rep_bool: rep_bool, rep_float: rep_float, rep_double: rep_double, + rep_string: rep_string, rep_bytes: rep_bytes, rep_nested_enum: rep_nested_enum, + rep_nested_message: rep_nested_message, pack_int32: pack_int32, + pack_uint32: pack_uint32, pack_sint32: pack_sint32, pack_fixed32: pack_fixed32, + pack_sfixed32: pack_sfixed32, pack_int64: pack_int64, pack_uint64: pack_uint64, + pack_sint64: pack_sint64, pack_fixed64: pack_fixed64, pack_sfixed64: pack_sfixed64, + pack_bool: pack_bool, pack_float: pack_float, pack_double: pack_double, + pack_nested_enum: pack_nested_enum, default_int32: default_int32, + default_uint32: default_uint32, default_sint32: default_sint32, + default_fixed32: default_fixed32, default_sfixed32: default_sfixed32, + default_int64: default_int64, default_uint64: default_uint64, + default_sint64: default_sint64, default_fixed64: default_fixed64, + default_sfixed64: default_sfixed64, default_bool: default_bool, + default_float: default_float, default_double: default_double, + default_string: default_string, default_bytes: default_bytes, + default_nested_enum: default_nested_enum, map_int32_int32: map_int32_int32, + map_string_string: map_string_string, map_string_message: map_string_message, + map_string_enum: map_string_enum, array_int32: array_int32, + array_uint32: array_uint32, array_sint32: array_sint32, + array_fixed32: array_fixed32, array_sfixed32: array_sfixed32, + array_int64: array_int64, array_uint64: array_uint64, array_sint64: array_sint64, + array_fixed64: array_fixed64, array_sfixed64: array_sfixed64, + array_float: array_float, array_double: array_double, ext_opt_int32: ext_opt_int32, + ext_opt_uint32: ext_opt_uint32, ext_opt_sint32: ext_opt_sint32, + ext_opt_fixed32: ext_opt_fixed32, ext_opt_sfixed32: ext_opt_sfixed32, + ext_opt_int64: ext_opt_int64, ext_opt_uint64: ext_opt_uint64, + ext_opt_sint64: ext_opt_sint64, ext_opt_fixed64: ext_opt_fixed64, + ext_opt_sfixed64: ext_opt_sfixed64, ext_opt_bool: ext_opt_bool, + ext_opt_float: ext_opt_float, ext_opt_double: ext_opt_double, + ext_opt_string: ext_opt_string, ext_opt_bytes: ext_opt_bytes, + ext_opt_nested_enum: ext_opt_nested_enum, + ext_opt_nested_message: ext_opt_nested_message, ext_rep_int32: ext_rep_int32, + ext_rep_uint32: ext_rep_uint32, ext_rep_sint32: ext_rep_sint32, + ext_rep_fixed32: ext_rep_fixed32, ext_rep_sfixed32: ext_rep_sfixed32, + ext_rep_int64: ext_rep_int64, ext_rep_uint64: ext_rep_uint64, + ext_rep_sint64: ext_rep_sint64, ext_rep_fixed64: ext_rep_fixed64, + ext_rep_sfixed64: ext_rep_sfixed64, ext_rep_bool: ext_rep_bool, + ext_rep_float: ext_rep_float, ext_rep_double: ext_rep_double, + ext_rep_string: ext_rep_string, ext_rep_bytes: ext_rep_bytes, + ext_rep_nested_enum: ext_rep_nested_enum, + ext_rep_nested_message: ext_rep_nested_message, ext_pack_int32: ext_pack_int32, + ext_pack_uint32: ext_pack_uint32, ext_pack_sint32: ext_pack_sint32, + ext_pack_fixed32: ext_pack_fixed32, ext_pack_sfixed32: ext_pack_sfixed32, + ext_pack_int64: ext_pack_int64, ext_pack_uint64: ext_pack_uint64, + ext_pack_sint64: ext_pack_sint64, ext_pack_fixed64: ext_pack_fixed64, + ext_pack_sfixed64: ext_pack_sfixed64, ext_pack_bool: ext_pack_bool, + ext_pack_float: ext_pack_float, ext_pack_double: ext_pack_double, + ext_pack_nested_enum: ext_pack_nested_enum) } private mutating func copyStorage() { @@ -85,335 +256,19 @@ public struct AllTypes { public var a: Int32? public var unknownFields: Foundation.Data = .init() - public init(configure: (inout Self) -> Void = { _ in }) { - configure(&self) + public init(a: Int32? = nil) { + self.a = a } } } -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension AllTypes { - - @_disfavoredOverload - @available(*, deprecated) - public init( - opt_int32: Swift.Int32? = nil, - opt_uint32: Swift.UInt32? = nil, - opt_sint32: Swift.Int32? = nil, - opt_fixed32: Swift.UInt32? = nil, - opt_sfixed32: Swift.Int32? = nil, - opt_int64: Swift.Int64? = nil, - opt_uint64: Swift.UInt64? = nil, - opt_sint64: Swift.Int64? = nil, - opt_fixed64: Swift.UInt64? = nil, - opt_sfixed64: Swift.Int64? = nil, - opt_bool: Swift.Bool? = nil, - opt_float: Swift.Float? = nil, - opt_double: Swift.Double? = nil, - opt_string: Swift.String? = nil, - opt_bytes: Foundation.Data? = nil, - opt_nested_enum: AllTypes.NestedEnum? = nil, - opt_nested_message: AllTypes.NestedMessage? = nil, - req_int32: Swift.Int32, - req_uint32: Swift.UInt32, - req_sint32: Swift.Int32, - req_fixed32: Swift.UInt32, - req_sfixed32: Swift.Int32, - req_int64: Swift.Int64, - req_uint64: Swift.UInt64, - req_sint64: Swift.Int64, - req_fixed64: Swift.UInt64, - req_sfixed64: Swift.Int64, - req_bool: Swift.Bool, - req_float: Swift.Float, - req_double: Swift.Double, - req_string: Swift.String, - req_bytes: Foundation.Data, - req_nested_enum: AllTypes.NestedEnum, - req_nested_message: AllTypes.NestedMessage, - rep_int32: [Swift.Int32] = [], - rep_uint32: [Swift.UInt32] = [], - rep_sint32: [Swift.Int32] = [], - rep_fixed32: [Swift.UInt32] = [], - rep_sfixed32: [Swift.Int32] = [], - rep_int64: [Swift.Int64] = [], - rep_uint64: [Swift.UInt64] = [], - rep_sint64: [Swift.Int64] = [], - rep_fixed64: [Swift.UInt64] = [], - rep_sfixed64: [Swift.Int64] = [], - rep_bool: [Swift.Bool] = [], - rep_float: [Swift.Float] = [], - rep_double: [Swift.Double] = [], - rep_string: [Swift.String] = [], - rep_bytes: [Foundation.Data] = [], - rep_nested_enum: [AllTypes.NestedEnum] = [], - rep_nested_message: [AllTypes.NestedMessage] = [], - pack_int32: [Swift.Int32] = [], - pack_uint32: [Swift.UInt32] = [], - pack_sint32: [Swift.Int32] = [], - pack_fixed32: [Swift.UInt32] = [], - pack_sfixed32: [Swift.Int32] = [], - pack_int64: [Swift.Int64] = [], - pack_uint64: [Swift.UInt64] = [], - pack_sint64: [Swift.Int64] = [], - pack_fixed64: [Swift.UInt64] = [], - pack_sfixed64: [Swift.Int64] = [], - pack_bool: [Swift.Bool] = [], - pack_float: [Swift.Float] = [], - pack_double: [Swift.Double] = [], - pack_nested_enum: [AllTypes.NestedEnum] = [], - default_int32: Swift.Int32? = nil, - default_uint32: Swift.UInt32? = nil, - default_sint32: Swift.Int32? = nil, - default_fixed32: Swift.UInt32? = nil, - default_sfixed32: Swift.Int32? = nil, - default_int64: Swift.Int64? = nil, - default_uint64: Swift.UInt64? = nil, - default_sint64: Swift.Int64? = nil, - default_fixed64: Swift.UInt64? = nil, - default_sfixed64: Swift.Int64? = nil, - default_bool: Swift.Bool? = nil, - default_float: Swift.Float? = nil, - default_double: Swift.Double? = nil, - default_string: Swift.String? = nil, - default_bytes: Foundation.Data? = nil, - default_nested_enum: AllTypes.NestedEnum? = nil, - map_int32_int32: [Swift.Int32 : Swift.Int32] = [:], - map_string_string: [Swift.String : Swift.String] = [:], - map_string_message: [Swift.String : AllTypes.NestedMessage] = [:], - map_string_enum: [Swift.String : AllTypes.NestedEnum] = [:], - array_int32: [Swift.Int32] = [], - array_uint32: [Swift.UInt32] = [], - array_sint32: [Swift.Int32] = [], - array_fixed32: [Swift.UInt32] = [], - array_sfixed32: [Swift.Int32] = [], - array_int64: [Swift.Int64] = [], - array_uint64: [Swift.UInt64] = [], - array_sint64: [Swift.Int64] = [], - array_fixed64: [Swift.UInt64] = [], - array_sfixed64: [Swift.Int64] = [], - array_float: [Swift.Float] = [], - array_double: [Swift.Double] = [], - ext_opt_int32: Swift.Int32? = nil, - ext_opt_uint32: Swift.UInt32? = nil, - ext_opt_sint32: Swift.Int32? = nil, - ext_opt_fixed32: Swift.UInt32? = nil, - ext_opt_sfixed32: Swift.Int32? = nil, - ext_opt_int64: Swift.Int64? = nil, - ext_opt_uint64: Swift.UInt64? = nil, - ext_opt_sint64: Swift.Int64? = nil, - ext_opt_fixed64: Swift.UInt64? = nil, - ext_opt_sfixed64: Swift.Int64? = nil, - ext_opt_bool: Swift.Bool? = nil, - ext_opt_float: Swift.Float? = nil, - ext_opt_double: Swift.Double? = nil, - ext_opt_string: Swift.String? = nil, - ext_opt_bytes: Foundation.Data? = nil, - ext_opt_nested_enum: AllTypes.NestedEnum? = nil, - ext_opt_nested_message: AllTypes.NestedMessage? = nil, - ext_rep_int32: [Swift.Int32] = [], - ext_rep_uint32: [Swift.UInt32] = [], - ext_rep_sint32: [Swift.Int32] = [], - ext_rep_fixed32: [Swift.UInt32] = [], - ext_rep_sfixed32: [Swift.Int32] = [], - ext_rep_int64: [Swift.Int64] = [], - ext_rep_uint64: [Swift.UInt64] = [], - ext_rep_sint64: [Swift.Int64] = [], - ext_rep_fixed64: [Swift.UInt64] = [], - ext_rep_sfixed64: [Swift.Int64] = [], - ext_rep_bool: [Swift.Bool] = [], - ext_rep_float: [Swift.Float] = [], - ext_rep_double: [Swift.Double] = [], - ext_rep_string: [Swift.String] = [], - ext_rep_bytes: [Foundation.Data] = [], - ext_rep_nested_enum: [AllTypes.NestedEnum] = [], - ext_rep_nested_message: [AllTypes.NestedMessage] = [], - ext_pack_int32: [Swift.Int32] = [], - ext_pack_uint32: [Swift.UInt32] = [], - ext_pack_sint32: [Swift.Int32] = [], - ext_pack_fixed32: [Swift.UInt32] = [], - ext_pack_sfixed32: [Swift.Int32] = [], - ext_pack_int64: [Swift.Int64] = [], - ext_pack_uint64: [Swift.UInt64] = [], - ext_pack_sint64: [Swift.Int64] = [], - ext_pack_fixed64: [Swift.UInt64] = [], - ext_pack_sfixed64: [Swift.Int64] = [], - ext_pack_bool: [Swift.Bool] = [], - ext_pack_float: [Swift.Float] = [], - ext_pack_double: [Swift.Double] = [], - ext_pack_nested_enum: [AllTypes.NestedEnum] = [] - ) { - self.storage = Storage( - opt_int32: opt_int32, - opt_uint32: opt_uint32, - opt_sint32: opt_sint32, - opt_fixed32: opt_fixed32, - opt_sfixed32: opt_sfixed32, - opt_int64: opt_int64, - opt_uint64: opt_uint64, - opt_sint64: opt_sint64, - opt_fixed64: opt_fixed64, - opt_sfixed64: opt_sfixed64, - opt_bool: opt_bool, - opt_float: opt_float, - opt_double: opt_double, - opt_string: opt_string, - opt_bytes: opt_bytes, - opt_nested_enum: opt_nested_enum, - opt_nested_message: opt_nested_message, - req_int32: req_int32, - req_uint32: req_uint32, - req_sint32: req_sint32, - req_fixed32: req_fixed32, - req_sfixed32: req_sfixed32, - req_int64: req_int64, - req_uint64: req_uint64, - req_sint64: req_sint64, - req_fixed64: req_fixed64, - req_sfixed64: req_sfixed64, - req_bool: req_bool, - req_float: req_float, - req_double: req_double, - req_string: req_string, - req_bytes: req_bytes, - req_nested_enum: req_nested_enum, - req_nested_message: req_nested_message, - rep_int32: rep_int32, - rep_uint32: rep_uint32, - rep_sint32: rep_sint32, - rep_fixed32: rep_fixed32, - rep_sfixed32: rep_sfixed32, - rep_int64: rep_int64, - rep_uint64: rep_uint64, - rep_sint64: rep_sint64, - rep_fixed64: rep_fixed64, - rep_sfixed64: rep_sfixed64, - rep_bool: rep_bool, - rep_float: rep_float, - rep_double: rep_double, - rep_string: rep_string, - rep_bytes: rep_bytes, - rep_nested_enum: rep_nested_enum, - rep_nested_message: rep_nested_message, - pack_int32: pack_int32, - pack_uint32: pack_uint32, - pack_sint32: pack_sint32, - pack_fixed32: pack_fixed32, - pack_sfixed32: pack_sfixed32, - pack_int64: pack_int64, - pack_uint64: pack_uint64, - pack_sint64: pack_sint64, - pack_fixed64: pack_fixed64, - pack_sfixed64: pack_sfixed64, - pack_bool: pack_bool, - pack_float: pack_float, - pack_double: pack_double, - pack_nested_enum: pack_nested_enum, - default_int32: default_int32, - default_uint32: default_uint32, - default_sint32: default_sint32, - default_fixed32: default_fixed32, - default_sfixed32: default_sfixed32, - default_int64: default_int64, - default_uint64: default_uint64, - default_sint64: default_sint64, - default_fixed64: default_fixed64, - default_sfixed64: default_sfixed64, - default_bool: default_bool, - default_float: default_float, - default_double: default_double, - default_string: default_string, - default_bytes: default_bytes, - default_nested_enum: default_nested_enum, - map_int32_int32: map_int32_int32, - map_string_string: map_string_string, - map_string_message: map_string_message, - map_string_enum: map_string_enum, - array_int32: array_int32, - array_uint32: array_uint32, - array_sint32: array_sint32, - array_fixed32: array_fixed32, - array_sfixed32: array_sfixed32, - array_int64: array_int64, - array_uint64: array_uint64, - array_sint64: array_sint64, - array_fixed64: array_fixed64, - array_sfixed64: array_sfixed64, - array_float: array_float, - array_double: array_double, - ext_opt_int32: ext_opt_int32, - ext_opt_uint32: ext_opt_uint32, - ext_opt_sint32: ext_opt_sint32, - ext_opt_fixed32: ext_opt_fixed32, - ext_opt_sfixed32: ext_opt_sfixed32, - ext_opt_int64: ext_opt_int64, - ext_opt_uint64: ext_opt_uint64, - ext_opt_sint64: ext_opt_sint64, - ext_opt_fixed64: ext_opt_fixed64, - ext_opt_sfixed64: ext_opt_sfixed64, - ext_opt_bool: ext_opt_bool, - ext_opt_float: ext_opt_float, - ext_opt_double: ext_opt_double, - ext_opt_string: ext_opt_string, - ext_opt_bytes: ext_opt_bytes, - ext_opt_nested_enum: ext_opt_nested_enum, - ext_opt_nested_message: ext_opt_nested_message, - ext_rep_int32: ext_rep_int32, - ext_rep_uint32: ext_rep_uint32, - ext_rep_sint32: ext_rep_sint32, - ext_rep_fixed32: ext_rep_fixed32, - ext_rep_sfixed32: ext_rep_sfixed32, - ext_rep_int64: ext_rep_int64, - ext_rep_uint64: ext_rep_uint64, - ext_rep_sint64: ext_rep_sint64, - ext_rep_fixed64: ext_rep_fixed64, - ext_rep_sfixed64: ext_rep_sfixed64, - ext_rep_bool: ext_rep_bool, - ext_rep_float: ext_rep_float, - ext_rep_double: ext_rep_double, - ext_rep_string: ext_rep_string, - ext_rep_bytes: ext_rep_bytes, - ext_rep_nested_enum: ext_rep_nested_enum, - ext_rep_nested_message: ext_rep_nested_message, - ext_pack_int32: ext_pack_int32, - ext_pack_uint32: ext_pack_uint32, - ext_pack_sint32: ext_pack_sint32, - ext_pack_fixed32: ext_pack_fixed32, - ext_pack_sfixed32: ext_pack_sfixed32, - ext_pack_int64: ext_pack_int64, - ext_pack_uint64: ext_pack_uint64, - ext_pack_sint64: ext_pack_sint64, - ext_pack_fixed64: ext_pack_fixed64, - ext_pack_sfixed64: ext_pack_sfixed64, - ext_pack_bool: ext_pack_bool, - ext_pack_float: ext_pack_float, - ext_pack_double: ext_pack_double, - ext_pack_nested_enum: ext_pack_nested_enum - ) - } - -} -#endif - #if swift(>=5.5) extension AllTypes.NestedEnum : Sendable { } #endif -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension AllTypes.NestedMessage { - - @_disfavoredOverload - @available(*, deprecated) - public init(a: Swift.Int32? = nil) { - self.a = a - } - -} -#endif - #if !WIRE_REMOVE_EQUATABLE extension AllTypes.NestedMessage : Equatable { } @@ -493,308 +348,6 @@ extension AllTypes : @unchecked Sendable { } #endif -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension AllTypes.Storage { - - @_disfavoredOverload - @available(*, deprecated) - public init( - opt_int32: Swift.Int32?, - opt_uint32: Swift.UInt32?, - opt_sint32: Swift.Int32?, - opt_fixed32: Swift.UInt32?, - opt_sfixed32: Swift.Int32?, - opt_int64: Swift.Int64?, - opt_uint64: Swift.UInt64?, - opt_sint64: Swift.Int64?, - opt_fixed64: Swift.UInt64?, - opt_sfixed64: Swift.Int64?, - opt_bool: Swift.Bool?, - opt_float: Swift.Float?, - opt_double: Swift.Double?, - opt_string: Swift.String?, - opt_bytes: Foundation.Data?, - opt_nested_enum: AllTypes.NestedEnum?, - opt_nested_message: AllTypes.NestedMessage?, - req_int32: Swift.Int32, - req_uint32: Swift.UInt32, - req_sint32: Swift.Int32, - req_fixed32: Swift.UInt32, - req_sfixed32: Swift.Int32, - req_int64: Swift.Int64, - req_uint64: Swift.UInt64, - req_sint64: Swift.Int64, - req_fixed64: Swift.UInt64, - req_sfixed64: Swift.Int64, - req_bool: Swift.Bool, - req_float: Swift.Float, - req_double: Swift.Double, - req_string: Swift.String, - req_bytes: Foundation.Data, - req_nested_enum: AllTypes.NestedEnum, - req_nested_message: AllTypes.NestedMessage, - rep_int32: [Swift.Int32], - rep_uint32: [Swift.UInt32], - rep_sint32: [Swift.Int32], - rep_fixed32: [Swift.UInt32], - rep_sfixed32: [Swift.Int32], - rep_int64: [Swift.Int64], - rep_uint64: [Swift.UInt64], - rep_sint64: [Swift.Int64], - rep_fixed64: [Swift.UInt64], - rep_sfixed64: [Swift.Int64], - rep_bool: [Swift.Bool], - rep_float: [Swift.Float], - rep_double: [Swift.Double], - rep_string: [Swift.String], - rep_bytes: [Foundation.Data], - rep_nested_enum: [AllTypes.NestedEnum], - rep_nested_message: [AllTypes.NestedMessage], - pack_int32: [Swift.Int32], - pack_uint32: [Swift.UInt32], - pack_sint32: [Swift.Int32], - pack_fixed32: [Swift.UInt32], - pack_sfixed32: [Swift.Int32], - pack_int64: [Swift.Int64], - pack_uint64: [Swift.UInt64], - pack_sint64: [Swift.Int64], - pack_fixed64: [Swift.UInt64], - pack_sfixed64: [Swift.Int64], - pack_bool: [Swift.Bool], - pack_float: [Swift.Float], - pack_double: [Swift.Double], - pack_nested_enum: [AllTypes.NestedEnum], - default_int32: Swift.Int32?, - default_uint32: Swift.UInt32?, - default_sint32: Swift.Int32?, - default_fixed32: Swift.UInt32?, - default_sfixed32: Swift.Int32?, - default_int64: Swift.Int64?, - default_uint64: Swift.UInt64?, - default_sint64: Swift.Int64?, - default_fixed64: Swift.UInt64?, - default_sfixed64: Swift.Int64?, - default_bool: Swift.Bool?, - default_float: Swift.Float?, - default_double: Swift.Double?, - default_string: Swift.String?, - default_bytes: Foundation.Data?, - default_nested_enum: AllTypes.NestedEnum?, - map_int32_int32: [Swift.Int32 : Swift.Int32], - map_string_string: [Swift.String : Swift.String], - map_string_message: [Swift.String : AllTypes.NestedMessage], - map_string_enum: [Swift.String : AllTypes.NestedEnum], - array_int32: [Swift.Int32], - array_uint32: [Swift.UInt32], - array_sint32: [Swift.Int32], - array_fixed32: [Swift.UInt32], - array_sfixed32: [Swift.Int32], - array_int64: [Swift.Int64], - array_uint64: [Swift.UInt64], - array_sint64: [Swift.Int64], - array_fixed64: [Swift.UInt64], - array_sfixed64: [Swift.Int64], - array_float: [Swift.Float], - array_double: [Swift.Double], - ext_opt_int32: Swift.Int32?, - ext_opt_uint32: Swift.UInt32?, - ext_opt_sint32: Swift.Int32?, - ext_opt_fixed32: Swift.UInt32?, - ext_opt_sfixed32: Swift.Int32?, - ext_opt_int64: Swift.Int64?, - ext_opt_uint64: Swift.UInt64?, - ext_opt_sint64: Swift.Int64?, - ext_opt_fixed64: Swift.UInt64?, - ext_opt_sfixed64: Swift.Int64?, - ext_opt_bool: Swift.Bool?, - ext_opt_float: Swift.Float?, - ext_opt_double: Swift.Double?, - ext_opt_string: Swift.String?, - ext_opt_bytes: Foundation.Data?, - ext_opt_nested_enum: AllTypes.NestedEnum?, - ext_opt_nested_message: AllTypes.NestedMessage?, - ext_rep_int32: [Swift.Int32], - ext_rep_uint32: [Swift.UInt32], - ext_rep_sint32: [Swift.Int32], - ext_rep_fixed32: [Swift.UInt32], - ext_rep_sfixed32: [Swift.Int32], - ext_rep_int64: [Swift.Int64], - ext_rep_uint64: [Swift.UInt64], - ext_rep_sint64: [Swift.Int64], - ext_rep_fixed64: [Swift.UInt64], - ext_rep_sfixed64: [Swift.Int64], - ext_rep_bool: [Swift.Bool], - ext_rep_float: [Swift.Float], - ext_rep_double: [Swift.Double], - ext_rep_string: [Swift.String], - ext_rep_bytes: [Foundation.Data], - ext_rep_nested_enum: [AllTypes.NestedEnum], - ext_rep_nested_message: [AllTypes.NestedMessage], - ext_pack_int32: [Swift.Int32], - ext_pack_uint32: [Swift.UInt32], - ext_pack_sint32: [Swift.Int32], - ext_pack_fixed32: [Swift.UInt32], - ext_pack_sfixed32: [Swift.Int32], - ext_pack_int64: [Swift.Int64], - ext_pack_uint64: [Swift.UInt64], - ext_pack_sint64: [Swift.Int64], - ext_pack_fixed64: [Swift.UInt64], - ext_pack_sfixed64: [Swift.Int64], - ext_pack_bool: [Swift.Bool], - ext_pack_float: [Swift.Float], - 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.req_int32 = req_int32 - self.req_uint32 = req_uint32 - self.req_sint32 = req_sint32 - self.req_fixed32 = req_fixed32 - self.req_sfixed32 = req_sfixed32 - self.req_int64 = req_int64 - self.req_uint64 = req_uint64 - self.req_sint64 = req_sint64 - self.req_fixed64 = req_fixed64 - self.req_sfixed64 = req_sfixed64 - self.req_bool = req_bool - self.req_float = req_float - self.req_double = req_double - self.req_string = req_string - self.req_bytes = req_bytes - self.req_nested_enum = req_nested_enum - self.req_nested_message = req_nested_message - self.rep_int32 = rep_int32 - self.rep_uint32 = rep_uint32 - self.rep_sint32 = rep_sint32 - self.rep_fixed32 = rep_fixed32 - self.rep_sfixed32 = rep_sfixed32 - self.rep_int64 = rep_int64 - self.rep_uint64 = rep_uint64 - self.rep_sint64 = rep_sint64 - self.rep_fixed64 = rep_fixed64 - self.rep_sfixed64 = rep_sfixed64 - self.rep_bool = rep_bool - self.rep_float = rep_float - self.rep_double = rep_double - self.rep_string = rep_string - self.rep_bytes = rep_bytes - self.rep_nested_enum = rep_nested_enum - self.rep_nested_message = rep_nested_message - self.pack_int32 = pack_int32 - self.pack_uint32 = pack_uint32 - self.pack_sint32 = pack_sint32 - self.pack_fixed32 = pack_fixed32 - self.pack_sfixed32 = pack_sfixed32 - self.pack_int64 = pack_int64 - self.pack_uint64 = pack_uint64 - self.pack_sint64 = pack_sint64 - self.pack_fixed64 = pack_fixed64 - self.pack_sfixed64 = pack_sfixed64 - self.pack_bool = pack_bool - 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.map_int32_int32 = map_int32_int32 - self.map_string_string = map_string_string - self.map_string_message = map_string_message - self.map_string_enum = map_string_enum - self.array_int32 = array_int32 - self.array_uint32 = array_uint32 - self.array_sint32 = array_sint32 - self.array_fixed32 = array_fixed32 - self.array_sfixed32 = array_sfixed32 - self.array_int64 = array_int64 - self.array_uint64 = array_uint64 - self.array_sint64 = array_sint64 - self.array_fixed64 = array_fixed64 - 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_rep_int32 = ext_rep_int32 - self.ext_rep_uint32 = ext_rep_uint32 - self.ext_rep_sint32 = ext_rep_sint32 - self.ext_rep_fixed32 = ext_rep_fixed32 - self.ext_rep_sfixed32 = ext_rep_sfixed32 - self.ext_rep_int64 = ext_rep_int64 - self.ext_rep_uint64 = ext_rep_uint64 - self.ext_rep_sint64 = ext_rep_sint64 - self.ext_rep_fixed64 = ext_rep_fixed64 - self.ext_rep_sfixed64 = ext_rep_sfixed64 - self.ext_rep_bool = ext_rep_bool - self.ext_rep_float = ext_rep_float - self.ext_rep_double = ext_rep_double - self.ext_rep_string = ext_rep_string - self.ext_rep_bytes = ext_rep_bytes - self.ext_rep_nested_enum = ext_rep_nested_enum - self.ext_rep_nested_message = ext_rep_nested_message - self.ext_pack_int32 = ext_pack_int32 - self.ext_pack_uint32 = ext_pack_uint32 - self.ext_pack_sint32 = ext_pack_sint32 - self.ext_pack_fixed32 = ext_pack_fixed32 - self.ext_pack_sfixed32 = ext_pack_sfixed32 - self.ext_pack_int64 = ext_pack_int64 - self.ext_pack_uint64 = ext_pack_uint64 - self.ext_pack_sint64 = ext_pack_sint64 - self.ext_pack_fixed64 = ext_pack_fixed64 - self.ext_pack_sfixed64 = ext_pack_sfixed64 - self.ext_pack_bool = ext_pack_bool - self.ext_pack_float = ext_pack_float - self.ext_pack_double = ext_pack_double - self.ext_pack_nested_enum = ext_pack_nested_enum - } - -} -#endif - extension AllTypes { public struct Storage { @@ -833,37 +386,37 @@ extension AllTypes { public var req_bytes: Foundation.Data public var req_nested_enum: AllTypes.NestedEnum public var req_nested_message: AllTypes.NestedMessage - public var rep_int32: [Swift.Int32] = [] - public var rep_uint32: [Swift.UInt32] = [] - public var rep_sint32: [Swift.Int32] = [] - public var rep_fixed32: [Swift.UInt32] = [] - public var rep_sfixed32: [Swift.Int32] = [] - public var rep_int64: [Swift.Int64] = [] - public var rep_uint64: [Swift.UInt64] = [] - public var rep_sint64: [Swift.Int64] = [] - public var rep_fixed64: [Swift.UInt64] = [] - public var rep_sfixed64: [Swift.Int64] = [] - public var rep_bool: [Swift.Bool] = [] - public var rep_float: [Swift.Float] = [] - public var rep_double: [Swift.Double] = [] - public var rep_string: [Swift.String] = [] - public var rep_bytes: [Foundation.Data] = [] - public var rep_nested_enum: [AllTypes.NestedEnum] = [] - public var rep_nested_message: [AllTypes.NestedMessage] = [] - public var pack_int32: [Swift.Int32] = [] - public var pack_uint32: [Swift.UInt32] = [] - public var pack_sint32: [Swift.Int32] = [] - public var pack_fixed32: [Swift.UInt32] = [] - public var pack_sfixed32: [Swift.Int32] = [] - public var pack_int64: [Swift.Int64] = [] - public var pack_uint64: [Swift.UInt64] = [] - public var pack_sint64: [Swift.Int64] = [] - public var pack_fixed64: [Swift.UInt64] = [] - public var pack_sfixed64: [Swift.Int64] = [] - public var pack_bool: [Swift.Bool] = [] - public var pack_float: [Swift.Float] = [] - public var pack_double: [Swift.Double] = [] - public var pack_nested_enum: [AllTypes.NestedEnum] = [] + public var rep_int32: [Swift.Int32] + public var rep_uint32: [Swift.UInt32] + public var rep_sint32: [Swift.Int32] + public var rep_fixed32: [Swift.UInt32] + public var rep_sfixed32: [Swift.Int32] + public var rep_int64: [Swift.Int64] + public var rep_uint64: [Swift.UInt64] + public var rep_sint64: [Swift.Int64] + public var rep_fixed64: [Swift.UInt64] + public var rep_sfixed64: [Swift.Int64] + public var rep_bool: [Swift.Bool] + public var rep_float: [Swift.Float] + public var rep_double: [Swift.Double] + public var rep_string: [Swift.String] + public var rep_bytes: [Foundation.Data] + public var rep_nested_enum: [AllTypes.NestedEnum] + public var rep_nested_message: [AllTypes.NestedMessage] + public var pack_int32: [Swift.Int32] + public var pack_uint32: [Swift.UInt32] + public var pack_sint32: [Swift.Int32] + public var pack_fixed32: [Swift.UInt32] + public var pack_sfixed32: [Swift.Int32] + public var pack_int64: [Swift.Int64] + public var pack_uint64: [Swift.UInt64] + public var pack_sint64: [Swift.Int64] + public var pack_fixed64: [Swift.UInt64] + public var pack_sfixed64: [Swift.Int64] + public var pack_bool: [Swift.Bool] + public var pack_float: [Swift.Float] + public var pack_double: [Swift.Double] + public var pack_nested_enum: [AllTypes.NestedEnum] @Wire.Defaulted(defaultValue: Swift.Int32.max) public var default_int32: Swift.Int32? @Wire.Defaulted(defaultValue: Swift.UInt32.max) @@ -896,22 +449,22 @@ extension AllTypes { public var default_bytes: Foundation.Data? @Wire.Defaulted(defaultValue: AllTypes.NestedEnum.A) public var default_nested_enum: AllTypes.NestedEnum? - public var map_int32_int32: [Swift.Int32 : Swift.Int32] = [:] - public var map_string_string: [Swift.String : Swift.String] = [:] - public var map_string_message: [Swift.String : AllTypes.NestedMessage] = [:] - public var map_string_enum: [Swift.String : AllTypes.NestedEnum] = [:] - public var array_int32: [Swift.Int32] = [] - public var array_uint32: [Swift.UInt32] = [] - public var array_sint32: [Swift.Int32] = [] - public var array_fixed32: [Swift.UInt32] = [] - public var array_sfixed32: [Swift.Int32] = [] - public var array_int64: [Swift.Int64] = [] - public var array_uint64: [Swift.UInt64] = [] - public var array_sint64: [Swift.Int64] = [] - public var array_fixed64: [Swift.UInt64] = [] - public var array_sfixed64: [Swift.Int64] = [] - public var array_float: [Swift.Float] = [] - public var array_double: [Swift.Double] = [] + public var map_int32_int32: [Swift.Int32 : Swift.Int32] + public var map_string_string: [Swift.String : Swift.String] + public var map_string_message: [Swift.String : AllTypes.NestedMessage] + public var map_string_enum: [Swift.String : AllTypes.NestedEnum] + public var array_int32: [Swift.Int32] + public var array_uint32: [Swift.UInt32] + public var array_sint32: [Swift.Int32] + public var array_fixed32: [Swift.UInt32] + public var array_sfixed32: [Swift.Int32] + public var array_int64: [Swift.Int64] + public var array_uint64: [Swift.UInt64] + public var array_sint64: [Swift.Int64] + public var array_fixed64: [Swift.UInt64] + public var array_sfixed64: [Swift.Int64] + public var array_float: [Swift.Float] + public var array_double: [Swift.Double] public var ext_opt_int32: Swift.Int32? public var ext_opt_uint32: Swift.UInt32? public var ext_opt_sint32: Swift.Int32? @@ -929,40 +482,57 @@ extension AllTypes { public var ext_opt_bytes: Foundation.Data? public var ext_opt_nested_enum: AllTypes.NestedEnum? public var ext_opt_nested_message: AllTypes.NestedMessage? - public var ext_rep_int32: [Swift.Int32] = [] - public var ext_rep_uint32: [Swift.UInt32] = [] - public var ext_rep_sint32: [Swift.Int32] = [] - public var ext_rep_fixed32: [Swift.UInt32] = [] - public var ext_rep_sfixed32: [Swift.Int32] = [] - public var ext_rep_int64: [Swift.Int64] = [] - public var ext_rep_uint64: [Swift.UInt64] = [] - public var ext_rep_sint64: [Swift.Int64] = [] - public var ext_rep_fixed64: [Swift.UInt64] = [] - public var ext_rep_sfixed64: [Swift.Int64] = [] - public var ext_rep_bool: [Swift.Bool] = [] - public var ext_rep_float: [Swift.Float] = [] - public var ext_rep_double: [Swift.Double] = [] - public var ext_rep_string: [Swift.String] = [] - public var ext_rep_bytes: [Foundation.Data] = [] - public var ext_rep_nested_enum: [AllTypes.NestedEnum] = [] - public var ext_rep_nested_message: [AllTypes.NestedMessage] = [] - public var ext_pack_int32: [Swift.Int32] = [] - public var ext_pack_uint32: [Swift.UInt32] = [] - public var ext_pack_sint32: [Swift.Int32] = [] - public var ext_pack_fixed32: [Swift.UInt32] = [] - public var ext_pack_sfixed32: [Swift.Int32] = [] - public var ext_pack_int64: [Swift.Int64] = [] - public var ext_pack_uint64: [Swift.UInt64] = [] - public var ext_pack_sint64: [Swift.Int64] = [] - public var ext_pack_fixed64: [Swift.UInt64] = [] - public var ext_pack_sfixed64: [Swift.Int64] = [] - public var ext_pack_bool: [Swift.Bool] = [] - public var ext_pack_float: [Swift.Float] = [] - public var ext_pack_double: [Swift.Double] = [] - public var ext_pack_nested_enum: [AllTypes.NestedEnum] = [] + public var ext_rep_int32: [Swift.Int32] + public var ext_rep_uint32: [Swift.UInt32] + public var ext_rep_sint32: [Swift.Int32] + public var ext_rep_fixed32: [Swift.UInt32] + public var ext_rep_sfixed32: [Swift.Int32] + public var ext_rep_int64: [Swift.Int64] + public var ext_rep_uint64: [Swift.UInt64] + public var ext_rep_sint64: [Swift.Int64] + public var ext_rep_fixed64: [Swift.UInt64] + public var ext_rep_sfixed64: [Swift.Int64] + public var ext_rep_bool: [Swift.Bool] + public var ext_rep_float: [Swift.Float] + public var ext_rep_double: [Swift.Double] + public var ext_rep_string: [Swift.String] + public var ext_rep_bytes: [Foundation.Data] + public var ext_rep_nested_enum: [AllTypes.NestedEnum] + public var ext_rep_nested_message: [AllTypes.NestedMessage] + public var ext_pack_int32: [Swift.Int32] + public var ext_pack_uint32: [Swift.UInt32] + public var ext_pack_sint32: [Swift.Int32] + public var ext_pack_fixed32: [Swift.UInt32] + public var ext_pack_sfixed32: [Swift.Int32] + public var ext_pack_int64: [Swift.Int64] + public var ext_pack_uint64: [Swift.UInt64] + public var ext_pack_sint64: [Swift.Int64] + public var ext_pack_fixed64: [Swift.UInt64] + public var ext_pack_sfixed64: [Swift.Int64] + public var ext_pack_bool: [Swift.Bool] + public var ext_pack_float: [Swift.Float] + public var ext_pack_double: [Swift.Double] + public var ext_pack_nested_enum: [AllTypes.NestedEnum] public var unknownFields: Foundation.Data = .init() public init( + opt_int32: Swift.Int32?, + opt_uint32: Swift.UInt32?, + opt_sint32: Swift.Int32?, + opt_fixed32: Swift.UInt32?, + opt_sfixed32: Swift.Int32?, + opt_int64: Swift.Int64?, + opt_uint64: Swift.UInt64?, + opt_sint64: Swift.Int64?, + opt_fixed64: Swift.UInt64?, + opt_sfixed64: Swift.Int64?, + opt_bool: Swift.Bool?, + opt_float: Swift.Float?, + opt_double: Swift.Double?, + opt_string: Swift.String?, + opt_bytes: Foundation.Data?, + opt_nested_enum: AllTypes.NestedEnum?, + opt_nested_message: AllTypes.NestedMessage?, req_int32: Swift.Int32, req_uint32: Swift.UInt32, req_sint32: Swift.Int32, @@ -980,8 +550,135 @@ extension AllTypes { req_bytes: Foundation.Data, req_nested_enum: AllTypes.NestedEnum, req_nested_message: AllTypes.NestedMessage, - configure: (inout Self) -> Swift.Void = { _ in } + rep_int32: [Swift.Int32], + rep_uint32: [Swift.UInt32], + rep_sint32: [Swift.Int32], + rep_fixed32: [Swift.UInt32], + rep_sfixed32: [Swift.Int32], + rep_int64: [Swift.Int64], + rep_uint64: [Swift.UInt64], + rep_sint64: [Swift.Int64], + rep_fixed64: [Swift.UInt64], + rep_sfixed64: [Swift.Int64], + rep_bool: [Swift.Bool], + rep_float: [Swift.Float], + rep_double: [Swift.Double], + rep_string: [Swift.String], + rep_bytes: [Foundation.Data], + rep_nested_enum: [AllTypes.NestedEnum], + rep_nested_message: [AllTypes.NestedMessage], + pack_int32: [Swift.Int32], + pack_uint32: [Swift.UInt32], + pack_sint32: [Swift.Int32], + pack_fixed32: [Swift.UInt32], + pack_sfixed32: [Swift.Int32], + pack_int64: [Swift.Int64], + pack_uint64: [Swift.UInt64], + pack_sint64: [Swift.Int64], + pack_fixed64: [Swift.UInt64], + pack_sfixed64: [Swift.Int64], + pack_bool: [Swift.Bool], + pack_float: [Swift.Float], + pack_double: [Swift.Double], + pack_nested_enum: [AllTypes.NestedEnum], + default_int32: Swift.Int32?, + default_uint32: Swift.UInt32?, + default_sint32: Swift.Int32?, + default_fixed32: Swift.UInt32?, + default_sfixed32: Swift.Int32?, + default_int64: Swift.Int64?, + default_uint64: Swift.UInt64?, + default_sint64: Swift.Int64?, + default_fixed64: Swift.UInt64?, + default_sfixed64: Swift.Int64?, + default_bool: Swift.Bool?, + default_float: Swift.Float?, + default_double: Swift.Double?, + default_string: Swift.String?, + default_bytes: Foundation.Data?, + default_nested_enum: AllTypes.NestedEnum?, + map_int32_int32: [Swift.Int32 : Swift.Int32], + map_string_string: [Swift.String : Swift.String], + map_string_message: [Swift.String : AllTypes.NestedMessage], + map_string_enum: [Swift.String : AllTypes.NestedEnum], + array_int32: [Swift.Int32], + array_uint32: [Swift.UInt32], + array_sint32: [Swift.Int32], + array_fixed32: [Swift.UInt32], + array_sfixed32: [Swift.Int32], + array_int64: [Swift.Int64], + array_uint64: [Swift.UInt64], + array_sint64: [Swift.Int64], + array_fixed64: [Swift.UInt64], + array_sfixed64: [Swift.Int64], + array_float: [Swift.Float], + array_double: [Swift.Double], + ext_opt_int32: Swift.Int32?, + ext_opt_uint32: Swift.UInt32?, + ext_opt_sint32: Swift.Int32?, + ext_opt_fixed32: Swift.UInt32?, + ext_opt_sfixed32: Swift.Int32?, + ext_opt_int64: Swift.Int64?, + ext_opt_uint64: Swift.UInt64?, + ext_opt_sint64: Swift.Int64?, + ext_opt_fixed64: Swift.UInt64?, + ext_opt_sfixed64: Swift.Int64?, + ext_opt_bool: Swift.Bool?, + ext_opt_float: Swift.Float?, + ext_opt_double: Swift.Double?, + ext_opt_string: Swift.String?, + ext_opt_bytes: Foundation.Data?, + ext_opt_nested_enum: AllTypes.NestedEnum?, + ext_opt_nested_message: AllTypes.NestedMessage?, + ext_rep_int32: [Swift.Int32], + ext_rep_uint32: [Swift.UInt32], + ext_rep_sint32: [Swift.Int32], + ext_rep_fixed32: [Swift.UInt32], + ext_rep_sfixed32: [Swift.Int32], + ext_rep_int64: [Swift.Int64], + ext_rep_uint64: [Swift.UInt64], + ext_rep_sint64: [Swift.Int64], + ext_rep_fixed64: [Swift.UInt64], + ext_rep_sfixed64: [Swift.Int64], + ext_rep_bool: [Swift.Bool], + ext_rep_float: [Swift.Float], + ext_rep_double: [Swift.Double], + ext_rep_string: [Swift.String], + ext_rep_bytes: [Foundation.Data], + ext_rep_nested_enum: [AllTypes.NestedEnum], + ext_rep_nested_message: [AllTypes.NestedMessage], + ext_pack_int32: [Swift.Int32], + ext_pack_uint32: [Swift.UInt32], + ext_pack_sint32: [Swift.Int32], + ext_pack_fixed32: [Swift.UInt32], + ext_pack_sfixed32: [Swift.Int32], + ext_pack_int64: [Swift.Int64], + ext_pack_uint64: [Swift.UInt64], + ext_pack_sint64: [Swift.Int64], + ext_pack_fixed64: [Swift.UInt64], + ext_pack_sfixed64: [Swift.Int64], + ext_pack_bool: [Swift.Bool], + ext_pack_float: [Swift.Float], + 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.req_int32 = req_int32 self.req_uint32 = req_uint32 self.req_sint32 = req_sint32 @@ -999,7 +696,117 @@ extension AllTypes { self.req_bytes = req_bytes self.req_nested_enum = req_nested_enum self.req_nested_message = req_nested_message - configure(&self) + self.rep_int32 = rep_int32 + self.rep_uint32 = rep_uint32 + self.rep_sint32 = rep_sint32 + self.rep_fixed32 = rep_fixed32 + self.rep_sfixed32 = rep_sfixed32 + self.rep_int64 = rep_int64 + self.rep_uint64 = rep_uint64 + self.rep_sint64 = rep_sint64 + self.rep_fixed64 = rep_fixed64 + self.rep_sfixed64 = rep_sfixed64 + self.rep_bool = rep_bool + self.rep_float = rep_float + self.rep_double = rep_double + self.rep_string = rep_string + self.rep_bytes = rep_bytes + self.rep_nested_enum = rep_nested_enum + self.rep_nested_message = rep_nested_message + self.pack_int32 = pack_int32 + self.pack_uint32 = pack_uint32 + self.pack_sint32 = pack_sint32 + self.pack_fixed32 = pack_fixed32 + self.pack_sfixed32 = pack_sfixed32 + self.pack_int64 = pack_int64 + self.pack_uint64 = pack_uint64 + self.pack_sint64 = pack_sint64 + self.pack_fixed64 = pack_fixed64 + self.pack_sfixed64 = pack_sfixed64 + self.pack_bool = pack_bool + 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.map_int32_int32 = map_int32_int32 + self.map_string_string = map_string_string + self.map_string_message = map_string_message + self.map_string_enum = map_string_enum + self.array_int32 = array_int32 + self.array_uint32 = array_uint32 + self.array_sint32 = array_sint32 + self.array_fixed32 = array_fixed32 + self.array_sfixed32 = array_sfixed32 + self.array_int64 = array_int64 + self.array_uint64 = array_uint64 + self.array_sint64 = array_sint64 + self.array_fixed64 = array_fixed64 + 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_rep_int32 = ext_rep_int32 + self.ext_rep_uint32 = ext_rep_uint32 + self.ext_rep_sint32 = ext_rep_sint32 + self.ext_rep_fixed32 = ext_rep_fixed32 + self.ext_rep_sfixed32 = ext_rep_sfixed32 + self.ext_rep_int64 = ext_rep_int64 + self.ext_rep_uint64 = ext_rep_uint64 + self.ext_rep_sint64 = ext_rep_sint64 + self.ext_rep_fixed64 = ext_rep_fixed64 + self.ext_rep_sfixed64 = ext_rep_sfixed64 + self.ext_rep_bool = ext_rep_bool + self.ext_rep_float = ext_rep_float + self.ext_rep_double = ext_rep_double + self.ext_rep_string = ext_rep_string + self.ext_rep_bytes = ext_rep_bytes + self.ext_rep_nested_enum = ext_rep_nested_enum + self.ext_rep_nested_message = ext_rep_nested_message + self.ext_pack_int32 = ext_pack_int32 + self.ext_pack_uint32 = ext_pack_uint32 + self.ext_pack_sint32 = ext_pack_sint32 + self.ext_pack_fixed32 = ext_pack_fixed32 + self.ext_pack_sfixed32 = ext_pack_sfixed32 + self.ext_pack_int64 = ext_pack_int64 + self.ext_pack_uint64 = ext_pack_uint64 + self.ext_pack_sint64 = ext_pack_sint64 + self.ext_pack_fixed64 = ext_pack_fixed64 + self.ext_pack_sfixed64 = ext_pack_sfixed64 + self.ext_pack_bool = ext_pack_bool + self.ext_pack_float = ext_pack_float + self.ext_pack_double = ext_pack_double + self.ext_pack_nested_enum = ext_pack_nested_enum } } diff --git a/wire-tests-swift/src/main/swift/DeprecatedProto.swift b/wire-tests-swift/src/main/swift/DeprecatedProto.swift index bebe746285..73cfe54d74 100644 --- a/wire-tests-swift/src/main/swift/DeprecatedProto.swift +++ b/wire-tests-swift/src/main/swift/DeprecatedProto.swift @@ -9,23 +9,11 @@ public struct DeprecatedProto { public var foo: String? public var unknownFields: Foundation.Data = .init() - public init(configure: (inout Self) -> Void = { _ in }) { - configure(&self) - } - -} - -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension DeprecatedProto { - - @_disfavoredOverload - @available(*, deprecated) - public init(foo: Swift.String? = nil) { + public init(foo: String? = nil) { self.foo = foo } } -#endif #if !WIRE_REMOVE_EQUATABLE extension DeprecatedProto : Equatable { diff --git a/wire-tests-swift/src/main/swift/EmbeddedMessage.swift b/wire-tests-swift/src/main/swift/EmbeddedMessage.swift index fdae982b8f..ebd0dcda8e 100644 --- a/wire-tests-swift/src/main/swift/EmbeddedMessage.swift +++ b/wire-tests-swift/src/main/swift/EmbeddedMessage.swift @@ -5,28 +5,16 @@ import Wire public struct EmbeddedMessage { - public var inner_repeated_number: [Int32] = [] + public var inner_repeated_number: [Int32] public var inner_number_after: Int32? public var unknownFields: Foundation.Data = .init() - public init(configure: (inout Self) -> Void = { _ in }) { - configure(&self) - } - -} - -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension EmbeddedMessage { - - @_disfavoredOverload - @available(*, deprecated) - public init(inner_repeated_number: [Swift.Int32] = [], inner_number_after: Swift.Int32? = nil) { + public init(inner_repeated_number: [Int32] = [], inner_number_after: Int32? = nil) { self.inner_repeated_number = inner_repeated_number self.inner_number_after = inner_number_after } } -#endif #if !WIRE_REMOVE_EQUATABLE extension EmbeddedMessage : Equatable { diff --git a/wire-tests-swift/src/main/swift/ExternalMessage.swift b/wire-tests-swift/src/main/swift/ExternalMessage.swift index d8f32a2857..dfbdea2400 100644 --- a/wire-tests-swift/src/main/swift/ExternalMessage.swift +++ b/wire-tests-swift/src/main/swift/ExternalMessage.swift @@ -9,23 +9,11 @@ public struct ExternalMessage { public var f: Float? public var unknownFields: Foundation.Data = .init() - public init(configure: (inout Self) -> Void = { _ in }) { - configure(&self) - } - -} - -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension ExternalMessage { - - @_disfavoredOverload - @available(*, deprecated) - public init(f: Swift.Float? = nil) { + public init(f: Float? = nil) { _f.wrappedValue = f } } -#endif #if !WIRE_REMOVE_EQUATABLE extension ExternalMessage : Equatable { diff --git a/wire-tests-swift/src/main/swift/FooBar.swift b/wire-tests-swift/src/main/swift/FooBar.swift index 0a2fe93fab..ece497cb82 100644 --- a/wire-tests-swift/src/main/swift/FooBar.swift +++ b/wire-tests-swift/src/main/swift/FooBar.swift @@ -9,16 +9,36 @@ public struct FooBar { public var bar: String? public var baz: FooBar.Nested? public var qux: UInt64? - public var fred: [Float] = [] + public var fred: [Float] public var daisy: Double? - public var nested: [FooBar] = [] + public var nested: [FooBar] public var ext: FooBar.FooBarBazEnum? - public var rep: [FooBar.FooBarBazEnum] = [] + public var rep: [FooBar.FooBarBazEnum] public var more_string: String? public var unknownFields: Foundation.Data = .init() - public init(configure: (inout Self) -> Void = { _ in }) { - configure(&self) + public init( + foo: Int32? = nil, + bar: String? = nil, + baz: FooBar.Nested? = nil, + qux: UInt64? = nil, + fred: [Float] = [], + daisy: Double? = nil, + nested: [FooBar] = [], + ext: FooBar.FooBarBazEnum? = nil, + rep: [FooBar.FooBarBazEnum] = [], + more_string: String? = nil + ) { + self.foo = foo + self.bar = bar + self.baz = baz + self.qux = qux + self.fred = fred + self.daisy = daisy + self.nested = nested + self.ext = ext + self.rep = rep + self.more_string = more_string } public struct Nested { @@ -26,19 +46,19 @@ public struct FooBar { public var value: FooBar.FooBarBazEnum? public var unknownFields: Foundation.Data = .init() - public init(configure: (inout Self) -> Void = { _ in }) { - configure(&self) + public init(value: FooBar.FooBarBazEnum? = nil) { + self.value = value } } public struct More { - public var serial: [Int32] = [] + public var serial: [Int32] public var unknownFields: Foundation.Data = .init() - public init(configure: (inout Self) -> Void = { _ in }) { - configure(&self) + public init(serial: [Int32] = []) { + self.serial = serial } } @@ -61,50 +81,6 @@ public struct FooBar { } -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension FooBar { - - @_disfavoredOverload - @available(*, deprecated) - public init( - foo: Swift.Int32? = nil, - bar: Swift.String? = nil, - baz: FooBar.Nested? = nil, - qux: Swift.UInt64? = nil, - fred: [Swift.Float] = [], - daisy: Swift.Double? = nil, - nested: [FooBar] = [], - ext: FooBar.FooBarBazEnum? = nil, - rep: [FooBar.FooBarBazEnum] = [], - more_string: Swift.String? = nil - ) { - self.foo = foo - self.bar = bar - self.baz = baz - self.qux = qux - self.fred = fred - self.daisy = daisy - self.nested = nested - self.ext = ext - self.rep = rep - self.more_string = more_string - } - -} -#endif - -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension FooBar.Nested { - - @_disfavoredOverload - @available(*, deprecated) - public init(value: FooBar.FooBarBazEnum? = nil) { - self.value = value - } - -} -#endif - #if !WIRE_REMOVE_EQUATABLE extension FooBar.Nested : Equatable { } @@ -169,18 +145,6 @@ extension FooBar.Nested : Codable { } #endif -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension FooBar.More { - - @_disfavoredOverload - @available(*, deprecated) - public init(serial: [Swift.Int32] = []) { - self.serial = serial - } - -} -#endif - #if !WIRE_REMOVE_EQUATABLE extension FooBar.More : Equatable { } diff --git a/wire-tests-swift/src/main/swift/ForeignMessage.swift b/wire-tests-swift/src/main/swift/ForeignMessage.swift index f0ef281b2e..f25034ca3e 100644 --- a/wire-tests-swift/src/main/swift/ForeignMessage.swift +++ b/wire-tests-swift/src/main/swift/ForeignMessage.swift @@ -8,23 +8,11 @@ public struct ForeignMessage { public var i: Int32? public var unknownFields: Foundation.Data = .init() - public init(configure: (inout Self) -> Void = { _ in }) { - configure(&self) - } - -} - -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension ForeignMessage { - - @_disfavoredOverload - @available(*, deprecated) - public init(i: Swift.Int32? = nil) { + public init(i: Int32? = nil) { self.i = i } } -#endif #if !WIRE_REMOVE_EQUATABLE extension ForeignMessage : Equatable { diff --git a/wire-tests-swift/src/main/swift/Form.swift b/wire-tests-swift/src/main/swift/Form.swift index 96efc8f95e..3cbed2916c 100644 --- a/wire-tests-swift/src/main/swift/Form.swift +++ b/wire-tests-swift/src/main/swift/Form.swift @@ -9,8 +9,9 @@ public struct Form { public var decision: Decision? public var unknownFields: Foundation.Data = .init() - public init(configure: (inout Self) -> Void = { _ in }) { - configure(&self) + public init(choice: Choice? = nil, decision: Decision? = nil) { + self.choice = choice + self.decision = decision } public enum Choice { @@ -124,8 +125,8 @@ public struct Form { public var text: String? public var unknownFields: Foundation.Data = .init() - public init(configure: (inout Self) -> Void = { _ in }) { - configure(&self) + public init(text: String? = nil) { + self.text = text } } @@ -186,19 +187,6 @@ public struct Form { } -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension Form { - - @_disfavoredOverload - @available(*, deprecated) - public init(choice: Choice? = nil, decision: Decision? = nil) { - self.choice = choice - self.decision = decision - } - -} -#endif - #if !WIRE_REMOVE_EQUATABLE extension Form.Choice : Equatable { } @@ -496,18 +484,6 @@ extension Form.SpacerElement : Codable { } #endif -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension Form.TextElement { - - @_disfavoredOverload - @available(*, deprecated) - public init(text: Swift.String? = nil) { - self.text = text - } - -} -#endif - #if !WIRE_REMOVE_EQUATABLE extension Form.TextElement : Equatable { } diff --git a/wire-tests-swift/src/main/swift/Mappy.swift b/wire-tests-swift/src/main/swift/Mappy.swift index 260c302623..d9662b3ae4 100644 --- a/wire-tests-swift/src/main/swift/Mappy.swift +++ b/wire-tests-swift/src/main/swift/Mappy.swift @@ -5,26 +5,14 @@ import Wire public struct Mappy { - public var things: [String : Thing] = [:] + public var things: [String : Thing] public var unknownFields: Foundation.Data = .init() - public init(configure: (inout Self) -> Void = { _ in }) { - configure(&self) - } - -} - -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension Mappy { - - @_disfavoredOverload - @available(*, deprecated) - public init(things: [Swift.String : Thing] = [:]) { + public init(things: [String : Thing] = [:]) { self.things = things } } -#endif #if !WIRE_REMOVE_EQUATABLE extension Mappy : Equatable { diff --git a/wire-tests-swift/src/main/swift/MappyTwo.swift b/wire-tests-swift/src/main/swift/MappyTwo.swift index 05abd21582..ef9dc04f08 100644 --- a/wire-tests-swift/src/main/swift/MappyTwo.swift +++ b/wire-tests-swift/src/main/swift/MappyTwo.swift @@ -5,14 +5,22 @@ import Wire public struct MappyTwo { - public var string_enums: [String : MappyTwo.ValueEnum] = [:] - public var int_things: [Int64 : Thing] = [:] - public var string_ints: [String : Int64] = [:] - public var int_things_two: [Int32 : Thing] = [:] + public var string_enums: [String : MappyTwo.ValueEnum] + public var int_things: [Int64 : Thing] + public var string_ints: [String : Int64] + public var int_things_two: [Int32 : Thing] public var unknownFields: Foundation.Data = .init() - public init(configure: (inout Self) -> Void = { _ in }) { - configure(&self) + public init( + string_enums: [String : MappyTwo.ValueEnum] = [:], + int_things: [Int64 : Thing] = [:], + string_ints: [String : Int64] = [:], + int_things_two: [Int32 : Thing] = [:] + ) { + self.string_enums = string_enums + self.int_things = int_things + self.string_ints = string_ints + self.int_things_two = int_things_two } public enum ValueEnum : UInt32, CaseIterable, ProtoEnum { @@ -33,26 +41,6 @@ public struct MappyTwo { } -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension MappyTwo { - - @_disfavoredOverload - @available(*, deprecated) - public init( - string_enums: [Swift.String : MappyTwo.ValueEnum] = [:], - int_things: [Swift.Int64 : Thing] = [:], - string_ints: [Swift.String : Swift.Int64] = [:], - int_things_two: [Swift.Int32 : Thing] = [:] - ) { - self.string_enums = string_enums - self.int_things = int_things - self.string_ints = string_ints - self.int_things_two = int_things_two - } - -} -#endif - #if swift(>=5.5) extension MappyTwo.ValueEnum : Sendable { } diff --git a/wire-tests-swift/src/main/swift/MessageUsingMultipleEnums.swift b/wire-tests-swift/src/main/swift/MessageUsingMultipleEnums.swift index 3c166c9c95..5e894f127b 100644 --- a/wire-tests-swift/src/main/swift/MessageUsingMultipleEnums.swift +++ b/wire-tests-swift/src/main/swift/MessageUsingMultipleEnums.swift @@ -12,24 +12,12 @@ public struct MessageUsingMultipleEnums { public var b: OtherMessageWithStatus.Status? public var unknownFields: Foundation.Data = .init() - public init(configure: (inout Self) -> Void = { _ in }) { - configure(&self) - } - -} - -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension MessageUsingMultipleEnums { - - @_disfavoredOverload - @available(*, deprecated) public init(a: MessageWithStatus.Status? = nil, b: OtherMessageWithStatus.Status? = nil) { self.a = a self.b = b } } -#endif #if !WIRE_REMOVE_EQUATABLE extension MessageUsingMultipleEnums : Equatable { diff --git a/wire-tests-swift/src/main/swift/ModelEvaluation.swift b/wire-tests-swift/src/main/swift/ModelEvaluation.swift index c94877532e..696625cbd8 100644 --- a/wire-tests-swift/src/main/swift/ModelEvaluation.swift +++ b/wire-tests-swift/src/main/swift/ModelEvaluation.swift @@ -22,24 +22,13 @@ public struct ModelEvaluation { public var name: String? public var score: Double? - public var models: [String : ModelEvaluation] = [:] + public var models: [String : ModelEvaluation] public var unknownFields: Foundation.Data = .init() - public init(configure: (inout Self) -> Void = { _ in }) { - configure(&self) - } - -} - -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension ModelEvaluation { - - @_disfavoredOverload - @available(*, deprecated) public init( - name: Swift.String? = nil, - score: Swift.Double? = nil, - models: [Swift.String : ModelEvaluation] = [:] + name: String? = nil, + score: Double? = nil, + models: [String : ModelEvaluation] = [:] ) { self.name = name self.score = score @@ -47,7 +36,6 @@ extension ModelEvaluation { } } -#endif #if !WIRE_REMOVE_EQUATABLE extension ModelEvaluation : Equatable { diff --git a/wire-tests-swift/src/main/swift/NestedVersionOne.swift b/wire-tests-swift/src/main/swift/NestedVersionOne.swift index 31e1f1537e..201ca466e9 100644 --- a/wire-tests-swift/src/main/swift/NestedVersionOne.swift +++ b/wire-tests-swift/src/main/swift/NestedVersionOne.swift @@ -8,23 +8,11 @@ public struct NestedVersionOne { public var i: Int32? public var unknownFields: Foundation.Data = .init() - public init(configure: (inout Self) -> Void = { _ in }) { - configure(&self) - } - -} - -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension NestedVersionOne { - - @_disfavoredOverload - @available(*, deprecated) - public init(i: Swift.Int32? = nil) { + public init(i: Int32? = nil) { self.i = i } } -#endif #if !WIRE_REMOVE_EQUATABLE extension NestedVersionOne : Equatable { diff --git a/wire-tests-swift/src/main/swift/NestedVersionTwo.swift b/wire-tests-swift/src/main/swift/NestedVersionTwo.swift index 37425df8c1..61c62b62f5 100644 --- a/wire-tests-swift/src/main/swift/NestedVersionTwo.swift +++ b/wire-tests-swift/src/main/swift/NestedVersionTwo.swift @@ -10,27 +10,16 @@ public struct NestedVersionTwo { public var v2_s: String? public var v2_f32: UInt32? public var v2_f64: UInt64? - public var v2_rs: [String] = [] + public var v2_rs: [String] public var unknownFields: Foundation.Data = .init() - public init(configure: (inout Self) -> Void = { _ in }) { - configure(&self) - } - -} - -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension NestedVersionTwo { - - @_disfavoredOverload - @available(*, deprecated) public init( - i: Swift.Int32? = nil, - v2_i: Swift.Int32? = nil, - v2_s: Swift.String? = nil, - v2_f32: Swift.UInt32? = nil, - v2_f64: Swift.UInt64? = nil, - v2_rs: [Swift.String] = [] + i: Int32? = nil, + v2_i: Int32? = nil, + v2_s: String? = nil, + v2_f32: UInt32? = nil, + v2_f64: UInt64? = nil, + v2_rs: [String] = [] ) { self.i = i self.v2_i = v2_i @@ -41,7 +30,6 @@ extension NestedVersionTwo { } } -#endif #if !WIRE_REMOVE_EQUATABLE extension NestedVersionTwo : Equatable { diff --git a/wire-tests-swift/src/main/swift/OneOfMessage.swift b/wire-tests-swift/src/main/swift/OneOfMessage.swift index bcd5b43880..98bf621407 100644 --- a/wire-tests-swift/src/main/swift/OneOfMessage.swift +++ b/wire-tests-swift/src/main/swift/OneOfMessage.swift @@ -14,8 +14,8 @@ public struct OneOfMessage { public var choice: Choice? public var unknownFields: Foundation.Data = .init() - public init(configure: (inout Self) -> Void = { _ in }) { - configure(&self) + public init(choice: Choice? = nil) { + self.choice = choice } public enum Choice { @@ -45,18 +45,6 @@ public struct OneOfMessage { } -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension OneOfMessage { - - @_disfavoredOverload - @available(*, deprecated) - public init(choice: Choice? = nil) { - self.choice = choice - } - -} -#endif - #if !WIRE_REMOVE_EQUATABLE extension OneOfMessage.Choice : Equatable { } diff --git a/wire-tests-swift/src/main/swift/OptionalEnumUser.swift b/wire-tests-swift/src/main/swift/OptionalEnumUser.swift index 388808ae82..f175e673e0 100644 --- a/wire-tests-swift/src/main/swift/OptionalEnumUser.swift +++ b/wire-tests-swift/src/main/swift/OptionalEnumUser.swift @@ -8,8 +8,8 @@ public struct OptionalEnumUser { public var optional_enum: OptionalEnumUser.OptionalEnum? public var unknownFields: Foundation.Data = .init() - public init(configure: (inout Self) -> Void = { _ in }) { - configure(&self) + public init(optional_enum: OptionalEnumUser.OptionalEnum? = nil) { + self.optional_enum = optional_enum } public enum OptionalEnum : UInt32, CaseIterable, ProtoEnum { @@ -28,18 +28,6 @@ public struct OptionalEnumUser { } -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension OptionalEnumUser { - - @_disfavoredOverload - @available(*, deprecated) - public init(optional_enum: OptionalEnumUser.OptionalEnum? = nil) { - self.optional_enum = optional_enum - } - -} -#endif - #if swift(>=5.5) extension OptionalEnumUser.OptionalEnum : Sendable { } diff --git a/wire-tests-swift/src/main/swift/OuterMessage.swift b/wire-tests-swift/src/main/swift/OuterMessage.swift index 1de6729ac9..53192661fe 100644 --- a/wire-tests-swift/src/main/swift/OuterMessage.swift +++ b/wire-tests-swift/src/main/swift/OuterMessage.swift @@ -9,24 +9,12 @@ public struct OuterMessage { public var embedded_message: EmbeddedMessage? public var unknownFields: Foundation.Data = .init() - public init(configure: (inout Self) -> Void = { _ in }) { - configure(&self) - } - -} - -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension OuterMessage { - - @_disfavoredOverload - @available(*, deprecated) - public init(outer_number_before: Swift.Int32? = nil, embedded_message: EmbeddedMessage? = nil) { + public init(outer_number_before: Int32? = nil, embedded_message: EmbeddedMessage? = nil) { self.outer_number_before = outer_number_before self.embedded_message = embedded_message } } -#endif #if !WIRE_REMOVE_EQUATABLE extension OuterMessage : Equatable { diff --git a/wire-tests-swift/src/main/swift/Percents.swift b/wire-tests-swift/src/main/swift/Percents.swift index dd4e8f8664..083e2b9ed7 100644 --- a/wire-tests-swift/src/main/swift/Percents.swift +++ b/wire-tests-swift/src/main/swift/Percents.swift @@ -11,23 +11,11 @@ public struct Percents { public var text: String? public var unknownFields: Foundation.Data = .init() - public init(configure: (inout Self) -> Void = { _ in }) { - configure(&self) - } - -} - -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension Percents { - - @_disfavoredOverload - @available(*, deprecated) - public init(text: Swift.String? = nil) { + public init(text: String? = nil) { self.text = text } } -#endif #if !WIRE_REMOVE_EQUATABLE extension Percents : Equatable { diff --git a/wire-tests-swift/src/main/swift/Person.swift b/wire-tests-swift/src/main/swift/Person.swift index f24212712e..ec187a9339 100644 --- a/wire-tests-swift/src/main/swift/Person.swift +++ b/wire-tests-swift/src/main/swift/Person.swift @@ -23,18 +23,22 @@ public struct Person { /** * A list of the customer's phone numbers. */ - public var phone: [Person.PhoneNumber] = [] - public var aliases: [String] = [] + public var phone: [Person.PhoneNumber] + public var aliases: [String] public var unknownFields: Foundation.Data = .init() public init( id: Int32, name: String, - configure: (inout Self) -> Void = { _ in } + email: String? = nil, + phone: [Person.PhoneNumber] = [], + aliases: [String] = [] ) { self.id = id self.name = name - configure(&self) + self.email = email + self.phone = phone + self.aliases = aliases } /** @@ -72,55 +76,20 @@ public struct Person { public var type: Person.PhoneType? public var unknownFields: Foundation.Data = .init() - public init(number: String, configure: (inout Self) -> Void = { _ in }) { + public init(number: String, type: Person.PhoneType? = nil) { self.number = number - configure(&self) + _type.wrappedValue = type } } } -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension Person { - - @_disfavoredOverload - @available(*, deprecated) - public init( - id: Swift.Int32, - name: Swift.String, - email: Swift.String? = nil, - phone: [Person.PhoneNumber] = [], - aliases: [Swift.String] = [] - ) { - self.id = id - self.name = name - self.email = email - self.phone = phone - self.aliases = aliases - } - -} -#endif - #if swift(>=5.5) extension Person.PhoneType : Sendable { } #endif -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension Person.PhoneNumber { - - @_disfavoredOverload - @available(*, deprecated) - public init(number: Swift.String, type: Person.PhoneType? = nil) { - self.number = number - _type.wrappedValue = type - } - -} -#endif - #if !WIRE_REMOVE_EQUATABLE extension Person.PhoneNumber : Equatable { } diff --git a/wire-tests-swift/src/main/swift/RedactedOneOf.swift b/wire-tests-swift/src/main/swift/RedactedOneOf.swift index 2cd0a63254..ba1cc22430 100644 --- a/wire-tests-swift/src/main/swift/RedactedOneOf.swift +++ b/wire-tests-swift/src/main/swift/RedactedOneOf.swift @@ -8,8 +8,8 @@ public struct RedactedOneOf { public var a: A? public var unknownFields: Foundation.Data = .init() - public init(configure: (inout Self) -> Void = { _ in }) { - configure(&self) + public init(a: A? = nil) { + self.a = a } public enum A { @@ -28,18 +28,6 @@ public struct RedactedOneOf { } -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension RedactedOneOf { - - @_disfavoredOverload - @available(*, deprecated) - public init(a: A? = nil) { - self.a = a - } - -} -#endif - #if !WIRE_REMOVE_EQUATABLE extension RedactedOneOf.A : Equatable { } diff --git a/wire-tests-swift/src/main/swift/Thing.swift b/wire-tests-swift/src/main/swift/Thing.swift index f9e7ef5dc6..d4ecaf7f76 100644 --- a/wire-tests-swift/src/main/swift/Thing.swift +++ b/wire-tests-swift/src/main/swift/Thing.swift @@ -8,23 +8,11 @@ public struct Thing { public var name: String? public var unknownFields: Foundation.Data = .init() - public init(configure: (inout Self) -> Void = { _ in }) { - configure(&self) - } - -} - -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension Thing { - - @_disfavoredOverload - @available(*, deprecated) - public init(name: Swift.String? = nil) { + public init(name: String? = nil) { self.name = name } } -#endif #if !WIRE_REMOVE_EQUATABLE extension Thing : Equatable { diff --git a/wire-tests-swift/src/main/swift/VersionOne.swift b/wire-tests-swift/src/main/swift/VersionOne.swift index a48ad994aa..08f06a29e3 100644 --- a/wire-tests-swift/src/main/swift/VersionOne.swift +++ b/wire-tests-swift/src/main/swift/VersionOne.swift @@ -10,19 +10,8 @@ public struct VersionOne { public var en: EnumVersionOne? public var unknownFields: Foundation.Data = .init() - public init(configure: (inout Self) -> Void = { _ in }) { - configure(&self) - } - -} - -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension VersionOne { - - @_disfavoredOverload - @available(*, deprecated) public init( - i: Swift.Int32? = nil, + i: Int32? = nil, obj: NestedVersionOne? = nil, en: EnumVersionOne? = nil ) { @@ -32,7 +21,6 @@ extension VersionOne { } } -#endif #if !WIRE_REMOVE_EQUATABLE extension VersionOne : Equatable { diff --git a/wire-tests-swift/src/main/swift/VersionTwo.swift b/wire-tests-swift/src/main/swift/VersionTwo.swift index 8f41008929..0409f46976 100644 --- a/wire-tests-swift/src/main/swift/VersionTwo.swift +++ b/wire-tests-swift/src/main/swift/VersionTwo.swift @@ -10,29 +10,18 @@ public struct VersionTwo { public var v2_s: String? public var v2_f32: UInt32? public var v2_f64: UInt64? - public var v2_rs: [String] = [] + public var v2_rs: [String] public var obj: NestedVersionTwo? public var en: EnumVersionTwo? public var unknownFields: Foundation.Data = .init() - public init(configure: (inout Self) -> Void = { _ in }) { - configure(&self) - } - -} - -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension VersionTwo { - - @_disfavoredOverload - @available(*, deprecated) public init( - i: Swift.Int32? = nil, - v2_i: Swift.Int32? = nil, - v2_s: Swift.String? = nil, - v2_f32: Swift.UInt32? = nil, - v2_f64: Swift.UInt64? = nil, - v2_rs: [Swift.String] = [], + i: Int32? = nil, + v2_i: Int32? = nil, + v2_s: String? = nil, + v2_f32: UInt32? = nil, + v2_f64: UInt64? = nil, + v2_rs: [String] = [], obj: NestedVersionTwo? = nil, en: EnumVersionTwo? = nil ) { @@ -47,7 +36,6 @@ extension VersionTwo { } } -#endif #if !WIRE_REMOVE_EQUATABLE extension VersionTwo : Equatable { diff --git a/wire-tests-swift/src/main/swift/VeryLongProtoNameCausingBrokenLineBreaks.swift b/wire-tests-swift/src/main/swift/VeryLongProtoNameCausingBrokenLineBreaks.swift index 12a915c266..27bde1ce7d 100644 --- a/wire-tests-swift/src/main/swift/VeryLongProtoNameCausingBrokenLineBreaks.swift +++ b/wire-tests-swift/src/main/swift/VeryLongProtoNameCausingBrokenLineBreaks.swift @@ -11,23 +11,11 @@ public struct VeryLongProtoNameCausingBrokenLineBreaks { public var foo: String? public var unknownFields: Foundation.Data = .init() - public init(configure: (inout Self) -> Void = { _ in }) { - configure(&self) - } - -} - -#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER -extension VeryLongProtoNameCausingBrokenLineBreaks { - - @_disfavoredOverload - @available(*, deprecated) - public init(foo: Swift.String? = nil) { + public init(foo: String? = nil) { self.foo = foo } } -#endif #if !WIRE_REMOVE_EQUATABLE extension VeryLongProtoNameCausingBrokenLineBreaks : Equatable { diff --git a/wire-tests-swift/src/test/swift/JsonLitmusTest.swift b/wire-tests-swift/src/test/swift/JsonLitmusTest.swift index e284b48137..febdd089eb 100644 --- a/wire-tests-swift/src/test/swift/JsonLitmusTest.swift +++ b/wire-tests-swift/src/test/swift/JsonLitmusTest.swift @@ -22,14 +22,11 @@ final class JsonLitmusTest : XCTestCase { func testSimpleRoundtrip() { let expectedPerson = Person( id: 42, - name: "Luke Skywalker" - ) { - $0.email = "luke@skywalker.net" - $0.phone = [ - Person.PhoneNumber(number: "800-555-1234") { $0.type = .WORK }, - ] - $0.aliases = ["Nerfherder"] - } + name: "Luke Skywalker", + email: "luke@skywalker.net", + phone: [.init(number: "800-555-1234", type: .WORK)], + aliases: ["Nerfherder"] + ) let expectedJson = """ {\ "email":"luke@skywalker.net",\