diff --git a/wire-runtime-swift/src/main/swift/ProtoCodable/ProtoIntCodable.swift b/wire-runtime-swift/src/main/swift/ProtoCodable/ProtoIntCodable.swift index afe853c442..62ef82aee8 100644 --- a/wire-runtime-swift/src/main/swift/ProtoCodable/ProtoIntCodable.swift +++ b/wire-runtime-swift/src/main/swift/ProtoCodable/ProtoIntCodable.swift @@ -52,3 +52,6 @@ public enum ProtoIntEncoding { case signed case variable } + +extension ProtoIntEncoding : Sendable { +} diff --git a/wire-runtime-swift/src/test/swift/ExtensibleTests.swift b/wire-runtime-swift/src/test/swift/ExtensibleTests.swift index a6f22140fe..a84f5c12f5 100644 --- a/wire-runtime-swift/src/test/swift/ExtensibleTests.swift +++ b/wire-runtime-swift/src/test/swift/ExtensibleTests.swift @@ -133,4 +133,35 @@ final class ExtensibleTests: XCTestCase { XCTAssertEqual(LargeExtensible.default_ext_value17, "my extension default value") XCTAssertEqual(LargeExtensible.default_ext_value18, "") } + + func testExtensionFieldNumberAndEncodingConstants() { + XCTAssertEqual(Extensible.fieldNumber_ext_int32, 1001) + XCTAssertEqual(Extensible.fieldEncoding_ext_int32, .variable) + XCTAssertEqual(Extensible.fieldNumber_ext_sint32, 1003) + XCTAssertEqual(Extensible.fieldEncoding_ext_sint32, .signed) + XCTAssertEqual(Extensible.fieldNumber_ext_fixed32, 1004) + XCTAssertEqual(Extensible.fieldEncoding_ext_fixed32, .fixed) + XCTAssertEqual(Extensible.fieldNumber_ext_string, 1014) + XCTAssertEqual(LargeExtensible.fieldNumber_ext_value17, 17) + XCTAssertEqual(LargeExtensible.fieldNumber_rep_ext_sint32, 21) + XCTAssertEqual(LargeExtensible.fieldEncoding_rep_ext_sint32, .signed) + + // Round-trip a value through the raw APIs using only generated constants. + var message = Extensible() + message.setUnknownField( + fieldNumber: Extensible.fieldNumber_ext_sint32, + newValue: Int32(-42), + encoding: Extensible.fieldEncoding_ext_sint32 + ) + XCTAssertEqual( + message.parseUnknownField( + fieldNumber: Extensible.fieldNumber_ext_sint32, + type: Int32.self, + encoding: Extensible.fieldEncoding_ext_sint32 + ), + -42 + ) + // The generated accessor reads the same field the raw APIs just wrote. + XCTAssertEqual(message.ext_sint32, -42) + } } 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 45a6cb6cdf..a22d5c3401 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 @@ -93,6 +93,7 @@ class SwiftGenerator private constructor( private val unknownFields = DeclaredTypeName.typeName("Wire.UnknownFields") private val extensibleUnknownFields = DeclaredTypeName.typeName("Wire.ExtensibleUnknownFields") private val protoExtensible = DeclaredTypeName.typeName("Wire.ProtoExtensible") + private val protoIntEncoding = DeclaredTypeName.typeName("Wire.ProtoIntEncoding") private val stringLiteralCodingKeys = DeclaredTypeName.typeName("Wire.StringLiteralCodingKeys") @@ -1328,6 +1329,9 @@ class SwiftGenerator private constructor( addProperty(defaultProperty) } + + addProperty(extensionFieldNumberProperty(field)) + extensionFieldEncodingProperty(field)?.let { addProperty(it) } } } .build() @@ -1337,6 +1341,23 @@ class SwiftGenerator private constructor( } } + private fun extensionFieldNumberProperty(field: Field): PropertySpec = PropertySpec.varBuilder("fieldNumber_${field.safeName}", UINT32, PUBLIC, STATIC) + .addDoc("Field number for the %L extension field.\n", field.safeName) + .mutable(false) + .initializer("%L", field.tag) + .build() + + // Emitted whenever the accessor passes `encoding:` to parseUnknownField/setUnknownField, so + // callers of those APIs can source the (fieldNumber, encoding) pair entirely from codegen. + private fun extensionFieldEncodingProperty(field: Field): PropertySpec? { + val encoding = field.type!!.encoding ?: return null + return PropertySpec.varBuilder("fieldEncoding_${field.safeName}", protoIntEncoding, PUBLIC, STATIC) + .addDoc("Integer encoding for the %L extension field.\n", field.safeName) + .mutable(false) + .initializer(".%N", encoding) + .build() + } + private fun generateMessageExtensions( type: MessageType, structType: DeclaredTypeName, @@ -1416,6 +1437,12 @@ class SwiftGenerator private constructor( addProperty(defaultProperty) } + + // The constants belong on the extended type; the storage pass must skip them or they'd be declared twice. + if (!forStorageType) { + addProperty(extensionFieldNumberProperty(field)) + extensionFieldEncodingProperty(field)?.let { addProperty(it) } + } } } .build() diff --git a/wire-swift-generator/src/test/java/com/squareup/wire/swift/SwiftGeneratorTest.kt b/wire-swift-generator/src/test/java/com/squareup/wire/swift/SwiftGeneratorTest.kt index ffbda72d89..56c0006834 100644 --- a/wire-swift-generator/src/test/java/com/squareup/wire/swift/SwiftGeneratorTest.kt +++ b/wire-swift-generator/src/test/java/com/squareup/wire/swift/SwiftGeneratorTest.kt @@ -18,6 +18,7 @@ package com.squareup.wire.swift import assertk.assertThat import assertk.assertions.contains import assertk.assertions.doesNotContain +import assertk.assertions.isEqualTo import com.squareup.wire.buildSchema import com.squareup.wire.schema.Schema import io.outfoxx.swiftpoet.FileSpec @@ -64,6 +65,119 @@ class SwiftGeneratorTest { assertThat(code).contains("self.parseUnknownField(fieldNumber: 50003)") } + @Test fun extensionFieldNumbersAreExposedAsConstants() { + val schema = buildSchema { + add( + "custom_options.proto".toPath(), + """ + |syntax = "proto3"; + | + |package squareup.protos3.kotlin.custom_options; + | + |import "google/protobuf/descriptor.proto"; + | + |extend google.protobuf.MessageOptions { + | string implicit_scalar = 50001; + | repeated string repeated_scalar = 50003; + |} + """.trimMargin(), + ) + } + + val code = schema.generateSwift("google.protobuf.MessageOptions") + + assertThat(code).contains("public static let fieldNumber_implicit_scalar: UInt32 = 50001") + assertThat(code).contains("public static let fieldNumber_repeated_scalar: UInt32 = 50003") + } + + @Test fun extensionFieldEncodingsAreExposedAsConstants() { + val schema = buildSchema { + add( + "extensible_message.proto".toPath(), + """ + |syntax = "proto2"; + | + |package squareup.protos2.kotlin; + | + |message ExtensibleMessage { + | extensions 100 to 200; + |} + | + |extend ExtensibleMessage { + | optional int32 ext_int32 = 100; + | optional sint32 ext_sint32 = 101; + | optional fixed32 ext_fixed32 = 102; + | repeated sint64 rep_ext_sint64 = 103; + | optional string ext_string = 104; + |} + """.trimMargin(), + ) + } + + val code = schema.generateSwift("squareup.protos2.kotlin.ExtensibleMessage") + + assertThat(code).contains("public static let fieldEncoding_ext_int32: ProtoIntEncoding = .variable") + assertThat(code).contains("public static let fieldEncoding_ext_sint32: ProtoIntEncoding = .signed") + assertThat(code).contains("public static let fieldEncoding_ext_fixed32: ProtoIntEncoding = .fixed") + assertThat(code).contains("public static let fieldEncoding_rep_ext_sint64: ProtoIntEncoding = .signed") + // Only integer fields take an explicit encoding in parseUnknownField/setUnknownField. + assertThat(code).doesNotContain("fieldEncoding_ext_string") + } + + @Test fun extensionFieldNumberConstantsAreGeneratedOnceForHeapAllocatedMessages() { + val schema = buildSchema { + add( + "big_message.proto".toPath(), + """ + |syntax = "proto2"; + | + |package squareup.protos2.kotlin; + | + |message BigMessage { + | optional int32 f1 = 1; + | optional int32 f2 = 2; + | optional int32 f3 = 3; + | optional int32 f4 = 4; + | optional int32 f5 = 5; + | optional int32 f6 = 6; + | optional int32 f7 = 7; + | optional int32 f8 = 8; + | optional int32 f9 = 9; + | optional int32 f10 = 10; + | optional int32 f11 = 11; + | optional int32 f12 = 12; + | optional int32 f13 = 13; + | optional int32 f14 = 14; + | optional int32 f15 = 15; + | optional int32 f16 = 16; + | + | extensions 1000 to 1999; + |} + | + |extend BigMessage { + | optional string extra = 1000; + | optional sint32 extra_signed = 1001; + |} + """.trimMargin(), + ) + } + + val code = schema.generateSwift("squareup.protos2.kotlin.BigMessage") + + // Precondition: the message must actually be heap-allocated, or the single-emission + // assertion below passes trivially because only one extension block is generated at all. + assertThat(code).contains("public struct Storage") + + val constant = "public static let fieldNumber_extra: UInt32 = 1000" + assertThat(code).contains(constant) + // The constant belongs on the extended type only, not on its CopyOnWrite storage type. + assertThat(code.indexOf(constant)).isEqualTo(code.lastIndexOf(constant)) + + val encodingConstant = "public static let fieldEncoding_extra_signed: ProtoIntEncoding = .signed" + assertThat(code).contains(encodingConstant) + assertThat(code.indexOf(encodingConstant)).isEqualTo(code.lastIndexOf(encodingConstant)) + } + @Test fun usesFieldMask() { val schema = buildSchema { add( diff --git a/wire-tests-swift/manifest/module_one/SwiftModuleOneMessage.swift b/wire-tests-swift/manifest/module_one/SwiftModuleOneMessage.swift index 37cecfe690..72c0afe4c6 100644 --- a/wire-tests-swift/manifest/module_one/SwiftModuleOneMessage.swift +++ b/wire-tests-swift/manifest/module_one/SwiftModuleOneMessage.swift @@ -38,6 +38,10 @@ extension SwiftModuleOneMessage { * Default value for extension_message extension field. */ public static let default_extension_message: ExtensionMessage = .defaultedValue + /** + * Field number for the extension_message extension field. + */ + public static let fieldNumber_extension_message: UInt32 = 1000 } #if !WIRE_REMOVE_EQUATABLE diff --git a/wire-tests-swift/no-manifest/src/main/swift/AllTypes.swift b/wire-tests-swift/no-manifest/src/main/swift/AllTypes.swift index f9fb25df59..a5cefed926 100644 --- a/wire-tests-swift/no-manifest/src/main/swift/AllTypes.swift +++ b/wire-tests-swift/no-manifest/src/main/swift/AllTypes.swift @@ -1284,6 +1284,14 @@ extension AllTypes : ProtoExtensible { * Default value for ext_opt_int32 extension field. */ public static let default_ext_opt_int32: Int32 = .defaultedValue + /** + * Field number for the ext_opt_int32 extension field. + */ + public static let fieldNumber_ext_opt_int32: UInt32 = 1001 + /** + * Integer encoding for the ext_opt_int32 extension field. + */ + public static let fieldEncoding_ext_opt_int32: ProtoIntEncoding = .variable /** * * Source: all_types.proto @@ -1300,6 +1308,14 @@ extension AllTypes : ProtoExtensible { * Default value for ext_opt_uint32 extension field. */ public static let default_ext_opt_uint32: UInt32 = .defaultedValue + /** + * Field number for the ext_opt_uint32 extension field. + */ + public static let fieldNumber_ext_opt_uint32: UInt32 = 1002 + /** + * Integer encoding for the ext_opt_uint32 extension field. + */ + public static let fieldEncoding_ext_opt_uint32: ProtoIntEncoding = .variable /** * * Source: all_types.proto @@ -1316,6 +1332,14 @@ extension AllTypes : ProtoExtensible { * Default value for ext_opt_sint32 extension field. */ public static let default_ext_opt_sint32: Int32 = .defaultedValue + /** + * Field number for the ext_opt_sint32 extension field. + */ + public static let fieldNumber_ext_opt_sint32: UInt32 = 1003 + /** + * Integer encoding for the ext_opt_sint32 extension field. + */ + public static let fieldEncoding_ext_opt_sint32: ProtoIntEncoding = .signed /** * * Source: all_types.proto @@ -1332,6 +1356,14 @@ extension AllTypes : ProtoExtensible { * Default value for ext_opt_fixed32 extension field. */ public static let default_ext_opt_fixed32: UInt32 = .defaultedValue + /** + * Field number for the ext_opt_fixed32 extension field. + */ + public static let fieldNumber_ext_opt_fixed32: UInt32 = 1004 + /** + * Integer encoding for the ext_opt_fixed32 extension field. + */ + public static let fieldEncoding_ext_opt_fixed32: ProtoIntEncoding = .fixed /** * * Source: all_types.proto @@ -1348,6 +1380,14 @@ extension AllTypes : ProtoExtensible { * Default value for ext_opt_sfixed32 extension field. */ public static let default_ext_opt_sfixed32: Int32 = .defaultedValue + /** + * Field number for the ext_opt_sfixed32 extension field. + */ + public static let fieldNumber_ext_opt_sfixed32: UInt32 = 1005 + /** + * Integer encoding for the ext_opt_sfixed32 extension field. + */ + public static let fieldEncoding_ext_opt_sfixed32: ProtoIntEncoding = .fixed /** * * Source: all_types.proto @@ -1364,6 +1404,14 @@ extension AllTypes : ProtoExtensible { * Default value for ext_opt_int64 extension field. */ public static let default_ext_opt_int64: Int64 = .defaultedValue + /** + * Field number for the ext_opt_int64 extension field. + */ + public static let fieldNumber_ext_opt_int64: UInt32 = 1006 + /** + * Integer encoding for the ext_opt_int64 extension field. + */ + public static let fieldEncoding_ext_opt_int64: ProtoIntEncoding = .variable /** * * Source: all_types.proto @@ -1380,6 +1428,14 @@ extension AllTypes : ProtoExtensible { * Default value for ext_opt_uint64 extension field. */ public static let default_ext_opt_uint64: UInt64 = .defaultedValue + /** + * Field number for the ext_opt_uint64 extension field. + */ + public static let fieldNumber_ext_opt_uint64: UInt32 = 1007 + /** + * Integer encoding for the ext_opt_uint64 extension field. + */ + public static let fieldEncoding_ext_opt_uint64: ProtoIntEncoding = .variable /** * * Source: all_types.proto @@ -1396,6 +1452,14 @@ extension AllTypes : ProtoExtensible { * Default value for ext_opt_sint64 extension field. */ public static let default_ext_opt_sint64: Int64 = .defaultedValue + /** + * Field number for the ext_opt_sint64 extension field. + */ + public static let fieldNumber_ext_opt_sint64: UInt32 = 1008 + /** + * Integer encoding for the ext_opt_sint64 extension field. + */ + public static let fieldEncoding_ext_opt_sint64: ProtoIntEncoding = .signed /** * * Source: all_types.proto @@ -1412,6 +1476,14 @@ extension AllTypes : ProtoExtensible { * Default value for ext_opt_fixed64 extension field. */ public static let default_ext_opt_fixed64: UInt64 = .defaultedValue + /** + * Field number for the ext_opt_fixed64 extension field. + */ + public static let fieldNumber_ext_opt_fixed64: UInt32 = 1009 + /** + * Integer encoding for the ext_opt_fixed64 extension field. + */ + public static let fieldEncoding_ext_opt_fixed64: ProtoIntEncoding = .fixed /** * * Source: all_types.proto @@ -1428,6 +1500,14 @@ extension AllTypes : ProtoExtensible { * Default value for ext_opt_sfixed64 extension field. */ public static let default_ext_opt_sfixed64: Int64 = .defaultedValue + /** + * Field number for the ext_opt_sfixed64 extension field. + */ + public static let fieldNumber_ext_opt_sfixed64: UInt32 = 1010 + /** + * Integer encoding for the ext_opt_sfixed64 extension field. + */ + public static let fieldEncoding_ext_opt_sfixed64: ProtoIntEncoding = .fixed /** * * Source: all_types.proto @@ -1444,6 +1524,10 @@ extension AllTypes : ProtoExtensible { * Default value for ext_opt_bool extension field. */ public static let default_ext_opt_bool: Bool = .defaultedValue + /** + * Field number for the ext_opt_bool extension field. + */ + public static let fieldNumber_ext_opt_bool: UInt32 = 1011 /** * * Source: all_types.proto @@ -1460,6 +1544,10 @@ extension AllTypes : ProtoExtensible { * Default value for ext_opt_float extension field. */ public static let default_ext_opt_float: Float = .defaultedValue + /** + * Field number for the ext_opt_float extension field. + */ + public static let fieldNumber_ext_opt_float: UInt32 = 1012 /** * * Source: all_types.proto @@ -1476,6 +1564,10 @@ extension AllTypes : ProtoExtensible { * Default value for ext_opt_double extension field. */ public static let default_ext_opt_double: Double = .defaultedValue + /** + * Field number for the ext_opt_double extension field. + */ + public static let fieldNumber_ext_opt_double: UInt32 = 1013 /** * * Source: all_types.proto @@ -1492,6 +1584,10 @@ extension AllTypes : ProtoExtensible { * Default value for ext_opt_string extension field. */ public static let default_ext_opt_string: String = .defaultedValue + /** + * Field number for the ext_opt_string extension field. + */ + public static let fieldNumber_ext_opt_string: UInt32 = 1014 /** * * Source: all_types.proto @@ -1508,6 +1604,10 @@ extension AllTypes : ProtoExtensible { * Default value for ext_opt_bytes extension field. */ public static let default_ext_opt_bytes: Foundation.Data = .defaultedValue + /** + * Field number for the ext_opt_bytes extension field. + */ + public static let fieldNumber_ext_opt_bytes: UInt32 = 1015 /** * * Source: all_types.proto @@ -1520,6 +1620,10 @@ extension AllTypes : ProtoExtensible { storage.ext_opt_nested_enum = newValue } } + /** + * Field number for the ext_opt_nested_enum extension field. + */ + public static let fieldNumber_ext_opt_nested_enum: UInt32 = 1016 /** * * Source: all_types.proto @@ -1536,6 +1640,10 @@ extension AllTypes : ProtoExtensible { * Default value for ext_opt_nested_message extension field. */ public static let default_ext_opt_nested_message: AllTypes.NestedMessage = .defaultedValue + /** + * Field number for the ext_opt_nested_message extension field. + */ + public static let fieldNumber_ext_opt_nested_message: UInt32 = 1017 /** * * Source: all_types.proto @@ -1548,6 +1656,14 @@ extension AllTypes : ProtoExtensible { storage.ext_rep_int32 = newValue } } + /** + * Field number for the ext_rep_int32 extension field. + */ + public static let fieldNumber_ext_rep_int32: UInt32 = 1101 + /** + * Integer encoding for the ext_rep_int32 extension field. + */ + public static let fieldEncoding_ext_rep_int32: ProtoIntEncoding = .variable /** * * Source: all_types.proto @@ -1560,6 +1676,14 @@ extension AllTypes : ProtoExtensible { storage.ext_rep_uint32 = newValue } } + /** + * Field number for the ext_rep_uint32 extension field. + */ + public static let fieldNumber_ext_rep_uint32: UInt32 = 1102 + /** + * Integer encoding for the ext_rep_uint32 extension field. + */ + public static let fieldEncoding_ext_rep_uint32: ProtoIntEncoding = .variable /** * * Source: all_types.proto @@ -1572,6 +1696,14 @@ extension AllTypes : ProtoExtensible { storage.ext_rep_sint32 = newValue } } + /** + * Field number for the ext_rep_sint32 extension field. + */ + public static let fieldNumber_ext_rep_sint32: UInt32 = 1103 + /** + * Integer encoding for the ext_rep_sint32 extension field. + */ + public static let fieldEncoding_ext_rep_sint32: ProtoIntEncoding = .signed /** * * Source: all_types.proto @@ -1584,6 +1716,14 @@ extension AllTypes : ProtoExtensible { storage.ext_rep_fixed32 = newValue } } + /** + * Field number for the ext_rep_fixed32 extension field. + */ + public static let fieldNumber_ext_rep_fixed32: UInt32 = 1104 + /** + * Integer encoding for the ext_rep_fixed32 extension field. + */ + public static let fieldEncoding_ext_rep_fixed32: ProtoIntEncoding = .fixed /** * * Source: all_types.proto @@ -1596,6 +1736,14 @@ extension AllTypes : ProtoExtensible { storage.ext_rep_sfixed32 = newValue } } + /** + * Field number for the ext_rep_sfixed32 extension field. + */ + public static let fieldNumber_ext_rep_sfixed32: UInt32 = 1105 + /** + * Integer encoding for the ext_rep_sfixed32 extension field. + */ + public static let fieldEncoding_ext_rep_sfixed32: ProtoIntEncoding = .fixed /** * * Source: all_types.proto @@ -1608,6 +1756,14 @@ extension AllTypes : ProtoExtensible { storage.ext_rep_int64 = newValue } } + /** + * Field number for the ext_rep_int64 extension field. + */ + public static let fieldNumber_ext_rep_int64: UInt32 = 1106 + /** + * Integer encoding for the ext_rep_int64 extension field. + */ + public static let fieldEncoding_ext_rep_int64: ProtoIntEncoding = .variable /** * * Source: all_types.proto @@ -1620,6 +1776,14 @@ extension AllTypes : ProtoExtensible { storage.ext_rep_uint64 = newValue } } + /** + * Field number for the ext_rep_uint64 extension field. + */ + public static let fieldNumber_ext_rep_uint64: UInt32 = 1107 + /** + * Integer encoding for the ext_rep_uint64 extension field. + */ + public static let fieldEncoding_ext_rep_uint64: ProtoIntEncoding = .variable /** * * Source: all_types.proto @@ -1632,6 +1796,14 @@ extension AllTypes : ProtoExtensible { storage.ext_rep_sint64 = newValue } } + /** + * Field number for the ext_rep_sint64 extension field. + */ + public static let fieldNumber_ext_rep_sint64: UInt32 = 1108 + /** + * Integer encoding for the ext_rep_sint64 extension field. + */ + public static let fieldEncoding_ext_rep_sint64: ProtoIntEncoding = .signed /** * * Source: all_types.proto @@ -1644,6 +1816,14 @@ extension AllTypes : ProtoExtensible { storage.ext_rep_fixed64 = newValue } } + /** + * Field number for the ext_rep_fixed64 extension field. + */ + public static let fieldNumber_ext_rep_fixed64: UInt32 = 1109 + /** + * Integer encoding for the ext_rep_fixed64 extension field. + */ + public static let fieldEncoding_ext_rep_fixed64: ProtoIntEncoding = .fixed /** * * Source: all_types.proto @@ -1656,6 +1836,14 @@ extension AllTypes : ProtoExtensible { storage.ext_rep_sfixed64 = newValue } } + /** + * Field number for the ext_rep_sfixed64 extension field. + */ + public static let fieldNumber_ext_rep_sfixed64: UInt32 = 1110 + /** + * Integer encoding for the ext_rep_sfixed64 extension field. + */ + public static let fieldEncoding_ext_rep_sfixed64: ProtoIntEncoding = .fixed /** * * Source: all_types.proto @@ -1668,6 +1856,10 @@ extension AllTypes : ProtoExtensible { storage.ext_rep_bool = newValue } } + /** + * Field number for the ext_rep_bool extension field. + */ + public static let fieldNumber_ext_rep_bool: UInt32 = 1111 /** * * Source: all_types.proto @@ -1680,6 +1872,10 @@ extension AllTypes : ProtoExtensible { storage.ext_rep_float = newValue } } + /** + * Field number for the ext_rep_float extension field. + */ + public static let fieldNumber_ext_rep_float: UInt32 = 1112 /** * * Source: all_types.proto @@ -1692,6 +1888,10 @@ extension AllTypes : ProtoExtensible { storage.ext_rep_double = newValue } } + /** + * Field number for the ext_rep_double extension field. + */ + public static let fieldNumber_ext_rep_double: UInt32 = 1113 /** * * Source: all_types.proto @@ -1704,6 +1904,10 @@ extension AllTypes : ProtoExtensible { storage.ext_rep_string = newValue } } + /** + * Field number for the ext_rep_string extension field. + */ + public static let fieldNumber_ext_rep_string: UInt32 = 1114 /** * * Source: all_types.proto @@ -1716,6 +1920,10 @@ extension AllTypes : ProtoExtensible { storage.ext_rep_bytes = newValue } } + /** + * Field number for the ext_rep_bytes extension field. + */ + public static let fieldNumber_ext_rep_bytes: UInt32 = 1115 /** * * Source: all_types.proto @@ -1728,6 +1936,10 @@ extension AllTypes : ProtoExtensible { storage.ext_rep_nested_enum = newValue } } + /** + * Field number for the ext_rep_nested_enum extension field. + */ + public static let fieldNumber_ext_rep_nested_enum: UInt32 = 1116 /** * * Source: all_types.proto @@ -1740,6 +1952,10 @@ extension AllTypes : ProtoExtensible { storage.ext_rep_nested_message = newValue } } + /** + * Field number for the ext_rep_nested_message extension field. + */ + public static let fieldNumber_ext_rep_nested_message: UInt32 = 1117 /** * * Source: all_types.proto @@ -1752,6 +1968,14 @@ extension AllTypes : ProtoExtensible { storage.ext_pack_int32 = newValue } } + /** + * Field number for the ext_pack_int32 extension field. + */ + public static let fieldNumber_ext_pack_int32: UInt32 = 1201 + /** + * Integer encoding for the ext_pack_int32 extension field. + */ + public static let fieldEncoding_ext_pack_int32: ProtoIntEncoding = .variable /** * * Source: all_types.proto @@ -1764,6 +1988,14 @@ extension AllTypes : ProtoExtensible { storage.ext_pack_uint32 = newValue } } + /** + * Field number for the ext_pack_uint32 extension field. + */ + public static let fieldNumber_ext_pack_uint32: UInt32 = 1202 + /** + * Integer encoding for the ext_pack_uint32 extension field. + */ + public static let fieldEncoding_ext_pack_uint32: ProtoIntEncoding = .variable /** * * Source: all_types.proto @@ -1776,6 +2008,14 @@ extension AllTypes : ProtoExtensible { storage.ext_pack_sint32 = newValue } } + /** + * Field number for the ext_pack_sint32 extension field. + */ + public static let fieldNumber_ext_pack_sint32: UInt32 = 1203 + /** + * Integer encoding for the ext_pack_sint32 extension field. + */ + public static let fieldEncoding_ext_pack_sint32: ProtoIntEncoding = .signed /** * * Source: all_types.proto @@ -1788,6 +2028,14 @@ extension AllTypes : ProtoExtensible { storage.ext_pack_fixed32 = newValue } } + /** + * Field number for the ext_pack_fixed32 extension field. + */ + public static let fieldNumber_ext_pack_fixed32: UInt32 = 1204 + /** + * Integer encoding for the ext_pack_fixed32 extension field. + */ + public static let fieldEncoding_ext_pack_fixed32: ProtoIntEncoding = .fixed /** * * Source: all_types.proto @@ -1800,6 +2048,14 @@ extension AllTypes : ProtoExtensible { storage.ext_pack_sfixed32 = newValue } } + /** + * Field number for the ext_pack_sfixed32 extension field. + */ + public static let fieldNumber_ext_pack_sfixed32: UInt32 = 1205 + /** + * Integer encoding for the ext_pack_sfixed32 extension field. + */ + public static let fieldEncoding_ext_pack_sfixed32: ProtoIntEncoding = .fixed /** * * Source: all_types.proto @@ -1812,6 +2068,14 @@ extension AllTypes : ProtoExtensible { storage.ext_pack_int64 = newValue } } + /** + * Field number for the ext_pack_int64 extension field. + */ + public static let fieldNumber_ext_pack_int64: UInt32 = 1206 + /** + * Integer encoding for the ext_pack_int64 extension field. + */ + public static let fieldEncoding_ext_pack_int64: ProtoIntEncoding = .variable /** * * Source: all_types.proto @@ -1824,6 +2088,14 @@ extension AllTypes : ProtoExtensible { storage.ext_pack_uint64 = newValue } } + /** + * Field number for the ext_pack_uint64 extension field. + */ + public static let fieldNumber_ext_pack_uint64: UInt32 = 1207 + /** + * Integer encoding for the ext_pack_uint64 extension field. + */ + public static let fieldEncoding_ext_pack_uint64: ProtoIntEncoding = .variable /** * * Source: all_types.proto @@ -1836,6 +2108,14 @@ extension AllTypes : ProtoExtensible { storage.ext_pack_sint64 = newValue } } + /** + * Field number for the ext_pack_sint64 extension field. + */ + public static let fieldNumber_ext_pack_sint64: UInt32 = 1208 + /** + * Integer encoding for the ext_pack_sint64 extension field. + */ + public static let fieldEncoding_ext_pack_sint64: ProtoIntEncoding = .signed /** * * Source: all_types.proto @@ -1848,6 +2128,14 @@ extension AllTypes : ProtoExtensible { storage.ext_pack_fixed64 = newValue } } + /** + * Field number for the ext_pack_fixed64 extension field. + */ + public static let fieldNumber_ext_pack_fixed64: UInt32 = 1209 + /** + * Integer encoding for the ext_pack_fixed64 extension field. + */ + public static let fieldEncoding_ext_pack_fixed64: ProtoIntEncoding = .fixed /** * * Source: all_types.proto @@ -1860,6 +2148,14 @@ extension AllTypes : ProtoExtensible { storage.ext_pack_sfixed64 = newValue } } + /** + * Field number for the ext_pack_sfixed64 extension field. + */ + public static let fieldNumber_ext_pack_sfixed64: UInt32 = 1210 + /** + * Integer encoding for the ext_pack_sfixed64 extension field. + */ + public static let fieldEncoding_ext_pack_sfixed64: ProtoIntEncoding = .fixed /** * * Source: all_types.proto @@ -1872,6 +2168,10 @@ extension AllTypes : ProtoExtensible { storage.ext_pack_bool = newValue } } + /** + * Field number for the ext_pack_bool extension field. + */ + public static let fieldNumber_ext_pack_bool: UInt32 = 1211 /** * * Source: all_types.proto @@ -1884,6 +2184,10 @@ extension AllTypes : ProtoExtensible { storage.ext_pack_float = newValue } } + /** + * Field number for the ext_pack_float extension field. + */ + public static let fieldNumber_ext_pack_float: UInt32 = 1212 /** * * Source: all_types.proto @@ -1896,6 +2200,10 @@ extension AllTypes : ProtoExtensible { storage.ext_pack_double = newValue } } + /** + * Field number for the ext_pack_double extension field. + */ + public static let fieldNumber_ext_pack_double: UInt32 = 1213 /** * * Source: all_types.proto @@ -1908,6 +2216,10 @@ extension AllTypes : ProtoExtensible { storage.ext_pack_nested_enum = newValue } } + /** + * Field number for the ext_pack_nested_enum extension field. + */ + public static let fieldNumber_ext_pack_nested_enum: UInt32 = 1216 } #if !WIRE_REMOVE_EQUATABLE diff --git a/wire-tests-swift/no-manifest/src/main/swift/FooBar.swift b/wire-tests-swift/no-manifest/src/main/swift/FooBar.swift index 61b1ee177e..95efa418f6 100644 --- a/wire-tests-swift/no-manifest/src/main/swift/FooBar.swift +++ b/wire-tests-swift/no-manifest/src/main/swift/FooBar.swift @@ -45,6 +45,10 @@ extension FooBar { self.setUnknownField(fieldNumber: 101, newValue: newValue) } } + /** + * Field number for the ext extension field. + */ + public static let fieldNumber_ext: UInt32 = 101 /** * * Source: custom_options.proto @@ -57,6 +61,10 @@ extension FooBar { self.setUnknownField(fieldNumber: 102, newValue: newValue) } } + /** + * Field number for the rep extension field. + */ + public static let fieldNumber_rep: UInt32 = 102 /** * * Source: custom_options.proto @@ -73,6 +81,10 @@ extension FooBar { * Default value for more_string extension field. */ public static let default_more_string: String = .defaultedValue + /** + * Field number for the more_string extension field. + */ + public static let fieldNumber_more_string: UInt32 = 150 } #if !WIRE_REMOVE_EQUATABLE