diff --git a/gradle-conventions/src/main/kotlin/conventions-protoc-gen.gradle.kts b/gradle-conventions/src/main/kotlin/conventions-protoc-gen.gradle.kts index 8c228ee27..28d339026 100644 --- a/gradle-conventions/src/main/kotlin/conventions-protoc-gen.gradle.kts +++ b/gradle-conventions/src/main/kotlin/conventions-protoc-gen.gradle.kts @@ -18,17 +18,19 @@ dependencies { testImplementation(libs.kotlin.test) } -tasks.jar { - duplicatesStrategy = DuplicatesStrategy.EXCLUDE - archiveClassifier = "all" - - // Protoc plugins are all fat jars basically (the ones built on jvm) - // be really careful of what you put in the classpath here - from( - configurations.runtimeClasspath.map { prop -> - prop.map { if (it.isDirectory()) it else zipTree(it) } - } - ) +if (project.name != "common") { + tasks.jar { + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + archiveClassifier = "all" + + // Protoc plugins are all fat jars basically (the ones built on jvm) + // be really careful of what you put in the classpath here + from( + configurations.runtimeClasspath.map { prop -> + prop.map { if (it.isDirectory()) it else zipTree(it) } + } + ) + } } kotlin { diff --git a/gradle-conventions/src/main/kotlin/util/other/localProperties.kt b/gradle-conventions/src/main/kotlin/util/other/localProperties.kt index 1c41fdf92..20597626f 100644 --- a/gradle-conventions/src/main/kotlin/util/other/localProperties.kt +++ b/gradle-conventions/src/main/kotlin/util/other/localProperties.kt @@ -10,6 +10,7 @@ import org.gradle.kotlin.dsl.provideDelegate import java.util.Properties import java.util.concurrent.atomic.AtomicReference import kotlin.io.path.Path +import kotlin.io.path.exists import kotlin.io.path.inputStream private val ref = AtomicReference() @@ -19,7 +20,13 @@ fun Project.localProperties(): Properties { ref.compareAndSet(null, Properties().apply { val globalRootDir: String by extra - load(Path(globalRootDir, "local.properties").inputStream()) + val filepath = Path(globalRootDir, "local.properties") + + if (!filepath.exists()) { + return@apply + } + + load(filepath.inputStream()) }) } diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Api.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Api.kt index 8fd59f481..66760e11f 100644 --- a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Api.kt +++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Api.kt @@ -194,7 +194,7 @@ public fun com.google.protobuf.kotlin.ApiInternal.encodeWith(encoder: kotlinx.rp } } - if (com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2 != syntax) { + if (syntax != com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2) { encoder.writeEnum(fieldNr = 7, value = syntax.number) } } @@ -257,11 +257,11 @@ private fun com.google.protobuf.kotlin.ApiInternal.computeSize(): Int { } if (methods.isNotEmpty()) { - __result = methods.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += methods.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (options.isNotEmpty()) { - __result = options.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(3, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += options.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(3, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (version.isNotEmpty()) { @@ -273,10 +273,10 @@ private fun com.google.protobuf.kotlin.ApiInternal.computeSize(): Int { } if (mixins.isNotEmpty()) { - __result = mixins.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(6, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += mixins.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(6, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } - if (com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2 != syntax) { + if (syntax != com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(7, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(syntax.number)) } @@ -324,7 +324,7 @@ public fun com.google.protobuf.kotlin.MethodInternal.encodeWith(encoder: kotlinx } } - if (com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2 != syntax) { + if (syntax != com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2) { encoder.writeEnum(fieldNr = 7, value = syntax.number) } } @@ -395,10 +395,10 @@ private fun com.google.protobuf.kotlin.MethodInternal.computeSize(): Int { } if (options.isNotEmpty()) { - __result = options.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(6, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += options.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(6, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } - if (com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2 != syntax) { + if (syntax != com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(7, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(syntax.number)) } diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/FieldMask.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/FieldMask.kt index cb0235951..da3284fca 100644 --- a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/FieldMask.kt +++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/FieldMask.kt @@ -80,7 +80,7 @@ public fun com.google.protobuf.kotlin.FieldMaskInternal.Companion.decodeWith(msg private fun com.google.protobuf.kotlin.FieldMaskInternal.computeSize(): Int { var __result = 0 if (paths.isNotEmpty()) { - __result = paths.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += paths.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } return __result diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Struct.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Struct.kt index b9a7eb645..4f69c5022 100644 --- a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Struct.kt +++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Struct.kt @@ -372,7 +372,7 @@ public fun com.google.protobuf.kotlin.ListValueInternal.Companion.decodeWith(msg private fun com.google.protobuf.kotlin.ListValueInternal.computeSize(): Int { var __result = 0 if (values.isNotEmpty()) { - __result = values.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += values.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } return __result diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Type.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Type.kt index 1b883b0f4..39e19e2d2 100644 --- a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Type.kt +++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Type.kt @@ -284,7 +284,7 @@ public fun com.google.protobuf.kotlin.TypeInternal.encodeWith(encoder: kotlinx.r encoder.writeMessage(fieldNr = 5, value = sourceContext.asInternal()) { encodeWith(it) } } - if (com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2 != syntax) { + if (syntax != com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2) { encoder.writeEnum(fieldNr = 6, value = syntax.number) } @@ -350,22 +350,22 @@ private fun com.google.protobuf.kotlin.TypeInternal.computeSize(): Int { } if (fields.isNotEmpty()) { - __result = fields.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += fields.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (oneofs.isNotEmpty()) { - __result = oneofs.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(3, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += oneofs.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(3, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (options.isNotEmpty()) { - __result = options.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(4, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += options.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(4, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (presenceMask[0]) { __result += sourceContext.asInternal()._size.let { kotlinx.rpc.protobuf.internal.WireSize.tag(5, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it } } - if (com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2 != syntax) { + if (syntax != com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(6, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(syntax.number)) } @@ -391,11 +391,11 @@ public fun com.google.protobuf.kotlin.FieldInternal.checkRequiredFields() { @kotlinx.rpc.internal.utils.InternalRpcApi public fun com.google.protobuf.kotlin.FieldInternal.encodeWith(encoder: kotlinx.rpc.protobuf.internal.WireEncoder) { - if (com.google.protobuf.kotlin.Field.Kind.TYPE_UNKNOWN != kind) { + if (kind != com.google.protobuf.kotlin.Field.Kind.TYPE_UNKNOWN) { encoder.writeEnum(fieldNr = 1, value = kind.number) } - if (com.google.protobuf.kotlin.Field.Cardinality.CARDINALITY_UNKNOWN != cardinality) { + if (cardinality != com.google.protobuf.kotlin.Field.Cardinality.CARDINALITY_UNKNOWN) { encoder.writeEnum(fieldNr = 2, value = cardinality.number) } @@ -491,11 +491,11 @@ public fun com.google.protobuf.kotlin.FieldInternal.Companion.decodeWith(msg: co private fun com.google.protobuf.kotlin.FieldInternal.computeSize(): Int { var __result = 0 - if (com.google.protobuf.kotlin.Field.Kind.TYPE_UNKNOWN != kind) { + if (kind != com.google.protobuf.kotlin.Field.Kind.TYPE_UNKNOWN) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(kind.number)) } - if (com.google.protobuf.kotlin.Field.Cardinality.CARDINALITY_UNKNOWN != cardinality) { + if (cardinality != com.google.protobuf.kotlin.Field.Cardinality.CARDINALITY_UNKNOWN) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(cardinality.number)) } @@ -520,7 +520,7 @@ private fun com.google.protobuf.kotlin.FieldInternal.computeSize(): Int { } if (options.isNotEmpty()) { - __result = options.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(9, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += options.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(9, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (jsonName.isNotEmpty()) { @@ -577,7 +577,7 @@ public fun com.google.protobuf.kotlin.EnumInternal.encodeWith(encoder: kotlinx.r encoder.writeMessage(fieldNr = 4, value = sourceContext.asInternal()) { encodeWith(it) } } - if (com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2 != syntax) { + if (syntax != com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2) { encoder.writeEnum(fieldNr = 5, value = syntax.number) } @@ -638,18 +638,18 @@ private fun com.google.protobuf.kotlin.EnumInternal.computeSize(): Int { } if (enumvalue.isNotEmpty()) { - __result = enumvalue.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += enumvalue.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (options.isNotEmpty()) { - __result = options.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(3, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += options.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(3, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (presenceMask[0]) { __result += sourceContext.asInternal()._size.let { kotlinx.rpc.protobuf.internal.WireSize.tag(4, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it } } - if (com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2 != syntax) { + if (syntax != com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(5, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(syntax.number)) } @@ -728,7 +728,7 @@ private fun com.google.protobuf.kotlin.EnumValueInternal.computeSize(): Int { } if (options.isNotEmpty()) { - __result = options.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(3, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += options.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(3, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } return __result diff --git a/protobuf/protobuf-core/src/commonMain/kotlin/kotlinx/rpc/protobuf/internal/WireDecoder.kt b/protobuf/protobuf-core/src/commonMain/kotlin/kotlinx/rpc/protobuf/internal/WireDecoder.kt index acfffcf4b..79a3324d9 100644 --- a/protobuf/protobuf-core/src/commonMain/kotlin/kotlinx/rpc/protobuf/internal/WireDecoder.kt +++ b/protobuf/protobuf-core/src/commonMain/kotlin/kotlinx/rpc/protobuf/internal/WireDecoder.kt @@ -84,6 +84,10 @@ public interface WireDecoder : AutoCloseable { if (len < 0) throw ProtobufDecodingException.negativeSize() val limit = pushLimit(len) decoder(msg, this) + if (bytesUntilLimit() != 0) { + throw ProtobufDecodingException.truncatedMessage() + } + popLimit(limit) } diff --git a/protobuf/protobuf-core/src/commonMain/kotlin/kotlinx/rpc/protobuf/internal/WireSize.kt b/protobuf/protobuf-core/src/commonMain/kotlin/kotlinx/rpc/protobuf/internal/WireSize.kt index d20491cf1..c9fe8fee2 100644 --- a/protobuf/protobuf-core/src/commonMain/kotlin/kotlinx/rpc/protobuf/internal/WireSize.kt +++ b/protobuf/protobuf-core/src/commonMain/kotlin/kotlinx/rpc/protobuf/internal/WireSize.kt @@ -35,22 +35,22 @@ public expect fun WireSize.sInt32(value: Int): Int public expect fun WireSize.sInt64(value: Long): Int @InternalRpcApi -public fun WireSize.float(value: Float): Int = 32 +public fun WireSize.float(value: Float): Int = 4 @InternalRpcApi -public fun WireSize.double(value: Double): Int = 64 +public fun WireSize.double(value: Double): Int = 8 @InternalRpcApi -public fun WireSize.fixed32(value: UInt): Int = 32 +public fun WireSize.fixed32(value: UInt): Int = 4 @InternalRpcApi -public fun WireSize.fixed64(value: ULong): Int = 64 +public fun WireSize.fixed64(value: ULong): Int = 8 @InternalRpcApi -public fun WireSize.sFixed32(value: Int): Int = 32 +public fun WireSize.sFixed32(value: Int): Int = 4 @InternalRpcApi -public fun WireSize.sFixed64(value: Long): Int = 64 +public fun WireSize.sFixed64(value: Long): Int = 8 @InternalRpcApi public fun WireSize.bool(value: Boolean): Int = int32(if (value) 1 else 0) @@ -86,22 +86,22 @@ public fun WireSize.packedSInt64(value: List): Int = value.sumOf { sInt64( public fun WireSize.packedEnum(value: List): Int = value.sumOf { enum(it) } @InternalRpcApi -public fun WireSize.packedFloat(value: List): Int = value.size * 32 +public fun WireSize.packedFloat(value: List): Int = value.size * 4 @InternalRpcApi -public fun WireSize.packedDouble(value: List): Int = value.size * 64 +public fun WireSize.packedDouble(value: List): Int = value.size * 8 @InternalRpcApi -public fun WireSize.packedFixed32(value: List): Int = value.size * 32 +public fun WireSize.packedFixed32(value: List): Int = value.size * 4 @InternalRpcApi -public fun WireSize.packedFixed64(value: List): Int = value.size * 64 +public fun WireSize.packedFixed64(value: List): Int = value.size * 8 @InternalRpcApi -public fun WireSize.packedSFixed32(value: List): Int = value.size * 32 +public fun WireSize.packedSFixed32(value: List): Int = value.size * 4 @InternalRpcApi -public fun WireSize.packedSFixed64(value: List): Int = value.size * 64 +public fun WireSize.packedSFixed64(value: List): Int = value.size * 8 @InternalRpcApi public fun WireSize.packedBool(value: List): Int = packedSInt32(value.map { if (it) 1 else 0 }) diff --git a/protobuf/protobuf-core/src/commonTest/proto/all_primitives.proto b/protobuf/protobuf-core/src/commonTest/proto/all_primitives.proto index e9afd1266..84c3a9f07 100644 --- a/protobuf/protobuf-core/src/commonTest/proto/all_primitives.proto +++ b/protobuf/protobuf-core/src/commonTest/proto/all_primitives.proto @@ -18,4 +18,6 @@ message AllPrimitives { optional bool bool = 13; optional string string = 14; optional bytes bytes = 15; + string requiredString = 16; + bytes requiredBytes = 17; } diff --git a/protobuf/protobuf-core/src/commonTest/proto/default.proto b/protobuf/protobuf-core/src/commonTest/proto/default.proto new file mode 100644 index 000000000..47748eef0 --- /dev/null +++ b/protobuf/protobuf-core/src/commonTest/proto/default.proto @@ -0,0 +1,32 @@ +syntax = "proto2"; + +// https://protobuf.dev/programming-guides/proto2/#default +message WithDefaults { + optional double double = 1 [default = 2.0]; + optional float float = 2 [default = 2.0]; + optional int32 int32 = 3 [default = 2]; + optional int64 int64 = 4 [default = 2]; + optional uint32 uint32 = 5 [default = 2]; + optional uint64 uint64 = 6 [default = 2]; + optional sint32 sint32 = 7 [default = 2]; + optional sint64 sint64 = 8 [default = 2]; + optional fixed32 fixed32 = 9 [default = 2]; + optional fixed64 fixed64 = 10 [default = 2]; + optional sfixed32 sfixed32 = 11 [default = 2]; + optional sfixed64 sfixed64 = 12 [default = 2]; + optional bool bool = 13 [default = true]; + optional string string = 14 [default = "str"]; + optional bytes bytes = 15 [default = "bytes"]; + + optional Custom1 enum1 = 16; + optional Custom2 enum2 = 17 [default = BAZ]; + + enum Custom1 { + FOO = 1; // default + } + + enum Custom2 { + BAR = 1; // default + BAZ = 2; // default + } +} diff --git a/protobuf/protobuf-core/src/jvmMain/kotlin/kotlinx/rpc/protobuf/internal/WireEncoder.jvm.kt b/protobuf/protobuf-core/src/jvmMain/kotlin/kotlinx/rpc/protobuf/internal/WireEncoder.jvm.kt index a0461a899..6054d5668 100644 --- a/protobuf/protobuf-core/src/jvmMain/kotlin/kotlinx/rpc/protobuf/internal/WireEncoder.jvm.kt +++ b/protobuf/protobuf-core/src/jvmMain/kotlin/kotlinx/rpc/protobuf/internal/WireEncoder.jvm.kt @@ -178,7 +178,7 @@ private class WireEncoderJvm(sink: Sink) : WireEncoder { encode: T.(WireEncoder) -> Unit, ) { codedOutputStream.writeTag(fieldNr, WireType.LENGTH_DELIMITED.ordinal) - codedOutputStream.writeInt32NoTag(value._size) + codedOutputStream.writeUInt32NoTag(value._size) value.encode(this) } @@ -190,7 +190,7 @@ private class WireEncoderJvm(sink: Sink) : WireEncoder { ) { codedOutputStream.writeTag(fieldNr, WireType.LENGTH_DELIMITED.ordinal) // write the field size of the packed field - codedOutputStream.writeInt32NoTag(fieldSize) + codedOutputStream.writeUInt32NoTag(fieldSize) for (v in value) { writer(codedOutputStream, v) } @@ -207,4 +207,4 @@ public actual inline fun checkForPlatformEncodeException(block: () -> Unit) { } catch (e: IOException) { throw ProtobufEncodingException("Failed to encode protobuf message.", e) } -} \ No newline at end of file +} diff --git a/protobuf/protobuf-core/src/nativeMain/kotlin/kotlinx/rpc/protobuf/internal/WireEncoder.native.kt b/protobuf/protobuf-core/src/nativeMain/kotlin/kotlinx/rpc/protobuf/internal/WireEncoder.native.kt index e0321b2db..b8171c74d 100644 --- a/protobuf/protobuf-core/src/nativeMain/kotlin/kotlinx/rpc/protobuf/internal/WireEncoder.native.kt +++ b/protobuf/protobuf-core/src/nativeMain/kotlin/kotlinx/rpc/protobuf/internal/WireEncoder.native.kt @@ -174,7 +174,7 @@ internal class WireEncoderNative(private val sink: Sink) : WireEncoder { encode: T.(WireEncoder) -> Unit, ) { pw_encoder_write_tag(raw, fieldNr, WireType.LENGTH_DELIMITED.ordinal) - pw_encoder_write_int32_no_tag(raw, value._size) + pw_encoder_write_uint32_no_tag(raw, value._size.toUInt()) value.encode(this) } } @@ -193,7 +193,7 @@ private inline fun WireEncoderNative.writePackedInternal( ) = checked { pw_encoder_write_tag(raw, fieldNr, WireType.LENGTH_DELIMITED.ordinal) // write the field size of the packed field - pw_encoder_write_int32_no_tag(raw, fieldSize) + pw_encoder_write_uint32_no_tag(raw, fieldSize.toUInt()) for (v in value) { if (!writer(raw, v)) { return@checked false @@ -213,4 +213,4 @@ private inline fun checked(crossinline block: () -> Boolean) { public actual inline fun checkForPlatformEncodeException(block: () -> Unit) { block() // nothing to check for on native -} \ No newline at end of file +} diff --git a/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/codeRequestToModel.kt b/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/codeRequestToModel.kt index adbcaca1c..820de6631 100644 --- a/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/codeRequestToModel.kt +++ b/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/codeRequestToModel.kt @@ -74,7 +74,7 @@ private fun DescriptorProtos.FileDescriptorProto.toDescriptor( * * @return The fully qualified name represented as an instance of FqName, specific to the descriptor's context. */ -private fun Descriptors.GenericDescriptor.fqName(): FqName { +fun Descriptors.GenericDescriptor.fqName(): FqName { if (nameCache.containsKey(this)) return nameCache[this]!! val nameCapital = name.simpleProtoNameToKotlin(firstLetterUpper = true) val nameLower = name.simpleProtoNameToKotlin() diff --git a/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/model/FieldType.kt b/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/model/FieldType.kt index 296bf640b..2992e373c 100644 --- a/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/model/FieldType.kt +++ b/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/model/FieldType.kt @@ -35,6 +35,7 @@ sealed interface FieldType { data class Enum(val dec: EnumDeclaration) : FieldType { override val defaultValue = dec.defaultEntry().name.fullName() override val wireType: WireType = WireType.VARINT + override val isPackable: Boolean = true } data class Message(val dec: Lazy) : FieldType { @@ -52,8 +53,7 @@ sealed interface FieldType { override val defaultValue: String, override val wireType: WireType, override val isPackable: Boolean = true - ) : - FieldType { + ) : FieldType { STRING("String", "\"\"", WireType.LENGTH_DELIMITED, false), BYTES("ByteArray", "byteArrayOf()", WireType.LENGTH_DELIMITED, false), BOOL("Boolean", "false", WireType.VARINT), @@ -73,3 +73,20 @@ sealed interface FieldType { val fqName: FqName = FqName.Declaration(simpleName, FqName.Package.fromString("kotlin")) } } + +fun FieldType.scalarDefaultSuffix(): String = when (this) { + FieldType.IntegralType.BOOL -> "" + FieldType.IntegralType.FLOAT -> "f" + FieldType.IntegralType.DOUBLE -> "" + FieldType.IntegralType.INT32 -> "" + FieldType.IntegralType.INT64 -> "L" + FieldType.IntegralType.UINT32 -> "u" + FieldType.IntegralType.UINT64 -> "uL" + FieldType.IntegralType.FIXED32 -> "u" + FieldType.IntegralType.FIXED64 -> "uL" + FieldType.IntegralType.SINT32 -> "" + FieldType.IntegralType.SINT64 -> "L" + FieldType.IntegralType.SFIXED32 -> "" + FieldType.IntegralType.SFIXED64 -> "L" + else -> error("Unsupported scalar type: ${this::class}") +} diff --git a/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/model/model.kt b/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/model/model.kt index f60d463a9..9077791ce 100644 --- a/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/model/model.kt +++ b/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/model/model.kt @@ -44,7 +44,11 @@ data class EnumDeclaration( ) { fun defaultEntry(): Entry { - return originalEntries.minBy { it.dec.number } + // In proto3 and editions: + // The first value must be a zero value, so that we can use 0 as a numeric default value + // In proto2: + // We use the first value as the default value + return originalEntries.first() } data class Entry( diff --git a/protoc-gen/protobuf/src/main/kotlin/kotlinx/rpc/protoc/gen/ModelToProtobufKotlinCommonGenerator.kt b/protoc-gen/protobuf/src/main/kotlin/kotlinx/rpc/protoc/gen/ModelToProtobufKotlinCommonGenerator.kt index 4755dcdd1..96c3a9fbc 100644 --- a/protoc-gen/protobuf/src/main/kotlin/kotlinx/rpc/protoc/gen/ModelToProtobufKotlinCommonGenerator.kt +++ b/protoc-gen/protobuf/src/main/kotlin/kotlinx/rpc/protoc/gen/ModelToProtobufKotlinCommonGenerator.kt @@ -6,11 +6,14 @@ package kotlinx.rpc.protoc.gen +import com.google.protobuf.ByteString +import com.google.protobuf.Descriptors import kotlinx.rpc.protoc.gen.core.AModelToKotlinCommonGenerator import kotlinx.rpc.protoc.gen.core.CodeGenerator import kotlinx.rpc.protoc.gen.core.INTERNAL_RPC_API_ANNO import kotlinx.rpc.protoc.gen.core.PB_PKG import kotlinx.rpc.protoc.gen.core.WITH_CODEC_ANNO +import kotlinx.rpc.protoc.gen.core.fqName import kotlinx.rpc.protoc.gen.core.model.EnumDeclaration import kotlinx.rpc.protoc.gen.core.model.FieldDeclaration import kotlinx.rpc.protoc.gen.core.model.FieldType @@ -19,8 +22,8 @@ import kotlinx.rpc.protoc.gen.core.model.MessageDeclaration import kotlinx.rpc.protoc.gen.core.model.Model import kotlinx.rpc.protoc.gen.core.model.OneOfDeclaration import kotlinx.rpc.protoc.gen.core.model.WireType +import kotlinx.rpc.protoc.gen.core.model.scalarDefaultSuffix import org.slf4j.Logger -import kotlin.collections.map class ModelToProtobufKotlinCommonGenerator( model: Model, @@ -120,6 +123,7 @@ class ModelToProtobufKotlinCommonGenerator( ) { generatePresenceIndicesObject(declaration) + generateBytesDefaultsObject(declaration) property( name = "_size", @@ -144,7 +148,7 @@ class ModelToProtobufKotlinCommonGenerator( else -> { val fieldPresence = if (field.presenceIdx != null) "(PresenceIndices.${field.name})" else "" - "MsgFieldDelegate$fieldPresence { ${field.type.defaultValue} }" + "MsgFieldDelegate$fieldPresence { ${field.safeDefaultValue()} }" } } @@ -185,16 +189,50 @@ class ModelToProtobufKotlinCommonGenerator( } clazz("PresenceIndices", "private", declarationType = CodeGenerator.DeclarationType.Object) { - declaration.actualFields.forEachIndexed { i, field -> - if (field.presenceIdx != null) { - property( - field.name, - modifiers = "const", - value = field.presenceIdx.toString(), - type = "Int", - needsNewLineAfterDeclaration = i == declaration.actualFields.lastIndex, - ) + val fieldDeclarations = declaration.actualFields.filter { it.presenceIdx != null } + fieldDeclarations.forEachIndexed { i, field -> + property( + field.name, + modifiers = "const", + value = field.presenceIdx.toString(), + type = "Int", + needsNewLineAfterDeclaration = i == fieldDeclarations.lastIndex, + ) + } + } + } + + private fun CodeGenerator.generateBytesDefaultsObject(declaration: MessageDeclaration) { + val fieldDeclarations = declaration.actualFields + .filter { + it.type == FieldType.IntegralType.BYTES && + it.dec.hasDefaultValue() && + !(it.dec.defaultValue as ByteString).isEmpty + } + + if (fieldDeclarations.isEmpty()) { + return + } + + clazz("BytesDefaults", "private", declarationType = CodeGenerator.DeclarationType.Object) { + fieldDeclarations.forEachIndexed { i, field -> + val value = if (field.dec.hasDefaultValue()) { + val stringValue = (field.dec.defaultValue as ByteString).toString(Charsets.UTF_8) + if (stringValue.isNotEmpty()) { + "\"${stringValue}\".encodeToByteArray()" + } else { + FieldType.IntegralType.BYTES.defaultValue + } + } else { + FieldType.IntegralType.BYTES.defaultValue } + + property( + name = field.name, + value = value, + type = "ByteArray", + needsNewLineAfterDeclaration = i == fieldDeclarations.lastIndex, + ) } } } @@ -286,12 +324,17 @@ class ModelToProtobufKotlinCommonGenerator( generateDecodeFieldValue(fieldType, lvalue, wrapperCtor = wrapperCtor) } - is FieldType.List -> if (field.dec.isPacked) { - whenCase("tag.fieldNr == ${field.number} && tag.wireType == $PB_PKG.WireType.LENGTH_DELIMITED") { - beforeValueDecoding() - generateDecodeFieldValue(fieldType, lvalue, isPacked = true, wrapperCtor = wrapperCtor) + is FieldType.List -> { + // Protocol buffer parsers must be able + // to parse repeated fields that were compiled as packed as if they were not packed, + // and vice versa. + if (fieldType.value.isPackable) { + whenCase("tag.fieldNr == ${field.number} && tag.wireType == $PB_PKG.WireType.LENGTH_DELIMITED") { + beforeValueDecoding() + generateDecodeFieldValue(fieldType, lvalue, isPacked = true, wrapperCtor = wrapperCtor) + } } - } else { + whenCase("tag.fieldNr == ${field.number} && tag.wireType == $PB_PKG.WireType.${fieldType.value.wireType.name}") { beforeValueDecoding() generateDecodeFieldValue(fieldType, lvalue, isPacked = false, wrapperCtor = wrapperCtor) @@ -364,13 +407,17 @@ class ModelToProtobufKotlinCommonGenerator( } is FieldType.List -> if (isPacked) { - val conversion = if (fieldType.value is FieldType.Enum){ + val conversion = if (fieldType.value is FieldType.Enum) { ".map { ${(fieldType.value as FieldType.Enum).dec.name.safeFullName()}.fromNumber(it) }" } else { "" } - code("$lvalue = decoder.readPacked${fieldType.value.decodeEncodeFuncName()}()$conversion") + // Note that although there’s usually no reason + // to encode more than one key-value pair for a packed repeated field, + // parsers must be prepared to accept multiple key-value pairs. + // In this case, the payloads should be concatenated. + code("$lvalue += decoder.readPacked${fieldType.value.decodeEncodeFuncName()}()$conversion") } else { when (val elemType = fieldType.value) { is FieldType.Message -> { @@ -455,7 +502,9 @@ class ModelToProtobufKotlinCommonGenerator( valueVar: String, ) { generateEncodeFieldValue( - valueVar, field.type, number = field.number, + valueVar = valueVar, + type = field.type, + number = field.number, isPacked = field.dec.isPacked, packedWithFixedSize = field.packedFixedSize ) @@ -521,7 +570,9 @@ class ModelToProtobufKotlinCommonGenerator( generateEncodeFieldValue( valueVar = "entry", type = FieldType.Message(lazy { type.entry.dec }), - number = number, isPacked = false, packedWithFixedSize = false + number = number, + isPacked = false, + packedWithFixedSize = false, ) } } @@ -682,7 +733,7 @@ class ModelToProtobufKotlinCommonGenerator( is FieldType.List -> when { // packed fields also have the tag + len field.dec.isPacked -> code("__result += $valueSize.let { $tagSize + ${int32SizeCall("it")} + it }") - else -> code("__result = $valueSize") + else -> code("__result += $valueSize") } is FieldType.Message, @@ -778,17 +829,55 @@ class ModelToProtobufKotlinCommonGenerator( private fun FieldDeclaration.notDefaultCheck(): String { return when (val fieldType = type) { - is FieldType.IntegralType -> when (fieldType) { - FieldType.IntegralType.BYTES, FieldType.IntegralType.STRING -> "$name.isNotEmpty()" - else -> "$name != ${fieldType.defaultValue}" + is FieldType.IntegralType -> { + val defaultValue = safeDefaultValue() + when { + fieldType == FieldType.IntegralType.STRING && + defaultValue == FieldType.IntegralType.STRING.defaultValue -> "$name.isNotEmpty()" + + fieldType == FieldType.IntegralType.STRING -> "!$name.contentEquals($defaultValue)" + + fieldType == FieldType.IntegralType.BYTES && + defaultValue == FieldType.IntegralType.BYTES.defaultValue -> "$name.isNotEmpty()" + + fieldType == FieldType.IntegralType.BYTES -> "!$name.contentEquals($defaultValue)" + + else -> "$name != $defaultValue" + } + } + + is FieldType.List, is FieldType.Map -> "$name.isNotEmpty()" + + is FieldType.Enum -> { + "$name != ${safeDefaultValue()}" } - is FieldType.List -> "$name.isNotEmpty()" is FieldType.Message -> error("Message fields should not be checked for default values.") + is FieldType.OneOf -> "null" + } + } + + private fun FieldDeclaration.safeDefaultValue(): String { + if (!dec.hasDefaultValue()) { + return type.defaultValue ?: error("No default value for field $name") + } - is FieldType.Enum -> "${fieldType.defaultValue} != $name" + return when (val value = dec.defaultValue) { + is String -> { + "\"$value\"" + } + + is ByteString -> { + "BytesDefaults.$name" + } - else -> "$name.isNotEmpty()" + is Descriptors.EnumValueDescriptor -> { + value.fqName().safeFullName() + } + + else -> { + "${value}${type.scalarDefaultSuffix()}" + } } } diff --git a/tests/protobuf-conformance/build.gradle.kts b/tests/protobuf-conformance/build.gradle.kts index f4d723337..37419dd68 100644 --- a/tests/protobuf-conformance/build.gradle.kts +++ b/tests/protobuf-conformance/build.gradle.kts @@ -112,7 +112,6 @@ tasks.register("runConformanceTest") { mainClass.set("kotlinx.rpc.protoc.gen.test.RunConformanceTestKt") val protoscope = localProperties().getProperty("protoscope_path") - ?: throw GradleException("protoscope_path property is not set. Run ./setup_protoscope.sh") environment("PROTOSCOPE_PATH", protoscope) @@ -130,15 +129,8 @@ tasks.register("runConformanceTest") { ) doFirst { - if (!File(protoscope).exists()) { - throw GradleException( - """ - Protoscope is not found. Use the following command to install it: - - $ brew install go - $ go install github.com/protocolbuffers/protoscope/cmd/protoscope...@latest - """.trimIndent() - ) + if (protoscope == null || !File(protoscope).exists()) { + throw GradleException("protoscope_path property is not set. Run ./setup_protoscope.sh") } } } diff --git a/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf/conformance/_rpc_internal/Conformance.kt b/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf/conformance/_rpc_internal/Conformance.kt index 944dec0b7..16a272564 100644 --- a/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf/conformance/_rpc_internal/Conformance.kt +++ b/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf/conformance/_rpc_internal/Conformance.kt @@ -322,7 +322,7 @@ fun com.google.protobuf.conformance.FailureSetInternal.Companion.decodeWith(msg: private fun com.google.protobuf.conformance.FailureSetInternal.computeSize(): Int { var __result = 0 if (test.isNotEmpty()) { - __result = test.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += test.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } return __result @@ -343,7 +343,7 @@ fun com.google.protobuf.conformance.ConformanceRequestInternal.checkRequiredFiel @kotlinx.rpc.internal.utils.InternalRpcApi fun com.google.protobuf.conformance.ConformanceRequestInternal.encodeWith(encoder: kotlinx.rpc.protobuf.internal.WireEncoder) { - if (com.google.protobuf.conformance.WireFormat.UNSPECIFIED != requestedOutputFormat) { + if (requestedOutputFormat != com.google.protobuf.conformance.WireFormat.UNSPECIFIED) { encoder.writeEnum(fieldNr = 3, value = requestedOutputFormat.number) } @@ -351,7 +351,7 @@ fun com.google.protobuf.conformance.ConformanceRequestInternal.encodeWith(encode encoder.writeString(fieldNr = 4, value = messageType) } - if (com.google.protobuf.conformance.TestCategory.UNSPECIFIED_TEST != testCategory) { + if (testCategory != com.google.protobuf.conformance.TestCategory.UNSPECIFIED_TEST) { encoder.writeEnum(fieldNr = 5, value = testCategory.number) } @@ -439,7 +439,7 @@ fun com.google.protobuf.conformance.ConformanceRequestInternal.Companion.decodeW private fun com.google.protobuf.conformance.ConformanceRequestInternal.computeSize(): Int { var __result = 0 - if (com.google.protobuf.conformance.WireFormat.UNSPECIFIED != requestedOutputFormat) { + if (requestedOutputFormat != com.google.protobuf.conformance.WireFormat.UNSPECIFIED) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(3, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(requestedOutputFormat.number)) } @@ -447,7 +447,7 @@ private fun com.google.protobuf.conformance.ConformanceRequestInternal.computeSi __result += kotlinx.rpc.protobuf.internal.WireSize.string(messageType).let { kotlinx.rpc.protobuf.internal.WireSize.tag(4, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it } } - if (com.google.protobuf.conformance.TestCategory.UNSPECIFIED_TEST != testCategory) { + if (testCategory != com.google.protobuf.conformance.TestCategory.UNSPECIFIED_TEST) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(5, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(testCategory.number)) } diff --git a/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/editions/proto3/_rpc_internal/TestMessagesProto3Editions.kt b/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/editions/proto3/_rpc_internal/TestMessagesProto3Editions.kt index f6c06b031..2ccd5e011 100644 --- a/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/editions/proto3/_rpc_internal/TestMessagesProto3Editions.kt +++ b/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/editions/proto3/_rpc_internal/TestMessagesProto3Editions.kt @@ -48,7 +48,7 @@ class TestAllTypesProto3Internal: com.google.protobuf_test_messages.editions.pro override var optionalBytes: ByteArray by MsgFieldDelegate { byteArrayOf() } override var optionalNestedMessage: com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedMessage by MsgFieldDelegate(PresenceIndices.optionalNestedMessage) { com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.NestedMessageInternal() } override var optionalForeignMessage: com.google.protobuf_test_messages.editions.proto3.ForeignMessage by MsgFieldDelegate(PresenceIndices.optionalForeignMessage) { com.google.protobuf_test_messages.editions.proto3.ForeignMessageInternal() } - override var optionalNestedEnum: com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum by MsgFieldDelegate { com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.NEG } + override var optionalNestedEnum: com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum by MsgFieldDelegate { com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.FOO } override var optionalForeignEnum: com.google.protobuf_test_messages.editions.proto3.ForeignEnum by MsgFieldDelegate { com.google.protobuf_test_messages.editions.proto3.ForeignEnum.FOREIGN_FOO } override var optionalAliasedEnum: com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.AliasedEnum by MsgFieldDelegate { com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.AliasedEnum.ALIAS_FOO } override var optionalStringPiece: String by MsgFieldDelegate { "" } @@ -413,7 +413,7 @@ class TestAllTypesProto3Internal: com.google.protobuf_test_messages.editions.pro override val _size: Int by lazy { computeSize() } var key: String by MsgFieldDelegate { "" } - var value: com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum by MsgFieldDelegate { com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.NEG } + var value: com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum by MsgFieldDelegate { com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.FOO } @kotlinx.rpc.internal.utils.InternalRpcApi companion object @@ -820,15 +820,15 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal encoder.writeMessage(fieldNr = 19, value = optionalForeignMessage.asInternal()) { encodeWith(it) } } - if (com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.NEG != optionalNestedEnum) { + if (optionalNestedEnum != com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.FOO) { encoder.writeEnum(fieldNr = 21, value = optionalNestedEnum.number) } - if (com.google.protobuf_test_messages.editions.proto3.ForeignEnum.FOREIGN_FOO != optionalForeignEnum) { + if (optionalForeignEnum != com.google.protobuf_test_messages.editions.proto3.ForeignEnum.FOREIGN_FOO) { encoder.writeEnum(fieldNr = 22, value = optionalForeignEnum.number) } - if (com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.AliasedEnum.ALIAS_FOO != optionalAliasedEnum) { + if (optionalAliasedEnum != com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.AliasedEnum.ALIAS_FOO) { encoder.writeEnum(fieldNr = 23, value = optionalAliasedEnum.number) } @@ -1422,7 +1422,7 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal encoder.writeMessage(fieldNr = 306, value = optionalValue.asInternal()) { encodeWith(it) } } - if (com.google.protobuf.kotlin.NullValue.NULL_VALUE != optionalNullValue) { + if (optionalNullValue != com.google.protobuf.kotlin.NullValue.NULL_VALUE) { encoder.writeEnum(fieldNr = 307, value = optionalNullValue.number) } @@ -1695,55 +1695,120 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } tag.fieldNr == 31 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedInt32 = decoder.readPackedInt32() + msg.repeatedInt32 += decoder.readPackedInt32() + } + + tag.fieldNr == 31 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readInt32() + (msg.repeatedInt32 as MutableList).add(elem) } tag.fieldNr == 32 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedInt64 = decoder.readPackedInt64() + msg.repeatedInt64 += decoder.readPackedInt64() + } + + tag.fieldNr == 32 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readInt64() + (msg.repeatedInt64 as MutableList).add(elem) } tag.fieldNr == 33 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedUint32 = decoder.readPackedUInt32() + msg.repeatedUint32 += decoder.readPackedUInt32() + } + + tag.fieldNr == 33 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readUInt32() + (msg.repeatedUint32 as MutableList).add(elem) } tag.fieldNr == 34 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedUint64 = decoder.readPackedUInt64() + msg.repeatedUint64 += decoder.readPackedUInt64() + } + + tag.fieldNr == 34 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readUInt64() + (msg.repeatedUint64 as MutableList).add(elem) } tag.fieldNr == 35 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedSint32 = decoder.readPackedSInt32() + msg.repeatedSint32 += decoder.readPackedSInt32() + } + + tag.fieldNr == 35 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readSInt32() + (msg.repeatedSint32 as MutableList).add(elem) } tag.fieldNr == 36 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedSint64 = decoder.readPackedSInt64() + msg.repeatedSint64 += decoder.readPackedSInt64() + } + + tag.fieldNr == 36 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readSInt64() + (msg.repeatedSint64 as MutableList).add(elem) } tag.fieldNr == 37 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedFixed32 = decoder.readPackedFixed32() + msg.repeatedFixed32 += decoder.readPackedFixed32() + } + + tag.fieldNr == 37 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { + val elem = decoder.readFixed32() + (msg.repeatedFixed32 as MutableList).add(elem) } tag.fieldNr == 38 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedFixed64 = decoder.readPackedFixed64() + msg.repeatedFixed64 += decoder.readPackedFixed64() + } + + tag.fieldNr == 38 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { + val elem = decoder.readFixed64() + (msg.repeatedFixed64 as MutableList).add(elem) } tag.fieldNr == 39 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedSfixed32 = decoder.readPackedSFixed32() + msg.repeatedSfixed32 += decoder.readPackedSFixed32() + } + + tag.fieldNr == 39 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { + val elem = decoder.readSFixed32() + (msg.repeatedSfixed32 as MutableList).add(elem) } tag.fieldNr == 40 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedSfixed64 = decoder.readPackedSFixed64() + msg.repeatedSfixed64 += decoder.readPackedSFixed64() + } + + tag.fieldNr == 40 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { + val elem = decoder.readSFixed64() + (msg.repeatedSfixed64 as MutableList).add(elem) } tag.fieldNr == 41 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedFloat = decoder.readPackedFloat() + msg.repeatedFloat += decoder.readPackedFloat() + } + + tag.fieldNr == 41 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { + val elem = decoder.readFloat() + (msg.repeatedFloat as MutableList).add(elem) } tag.fieldNr == 42 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedDouble = decoder.readPackedDouble() + msg.repeatedDouble += decoder.readPackedDouble() + } + + tag.fieldNr == 42 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { + val elem = decoder.readDouble() + (msg.repeatedDouble as MutableList).add(elem) } tag.fieldNr == 43 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedBool = decoder.readPackedBool() + msg.repeatedBool += decoder.readPackedBool() + } + + tag.fieldNr == 43 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readBool() + (msg.repeatedBool as MutableList).add(elem) } tag.fieldNr == 44 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { @@ -1769,11 +1834,21 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } tag.fieldNr == 51 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedNestedEnum = decoder.readPackedEnum().map { com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.fromNumber(it) } + msg.repeatedNestedEnum += decoder.readPackedEnum().map { com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.fromNumber(it) } + } + + tag.fieldNr == 51 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.fromNumber(decoder.readEnum()) + (msg.repeatedNestedEnum as MutableList).add(elem) } tag.fieldNr == 52 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedForeignEnum = decoder.readPackedEnum().map { com.google.protobuf_test_messages.editions.proto3.ForeignEnum.fromNumber(it) } + msg.repeatedForeignEnum += decoder.readPackedEnum().map { com.google.protobuf_test_messages.editions.proto3.ForeignEnum.fromNumber(it) } + } + + tag.fieldNr == 52 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = com.google.protobuf_test_messages.editions.proto3.ForeignEnum.fromNumber(decoder.readEnum()) + (msg.repeatedForeignEnum as MutableList).add(elem) } tag.fieldNr == 54 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { @@ -1787,59 +1862,133 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } tag.fieldNr == 75 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedInt32 = decoder.readPackedInt32() + msg.packedInt32 += decoder.readPackedInt32() + } + + tag.fieldNr == 75 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readInt32() + (msg.packedInt32 as MutableList).add(elem) } tag.fieldNr == 76 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedInt64 = decoder.readPackedInt64() + msg.packedInt64 += decoder.readPackedInt64() + } + + tag.fieldNr == 76 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readInt64() + (msg.packedInt64 as MutableList).add(elem) } tag.fieldNr == 77 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedUint32 = decoder.readPackedUInt32() + msg.packedUint32 += decoder.readPackedUInt32() + } + + tag.fieldNr == 77 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readUInt32() + (msg.packedUint32 as MutableList).add(elem) } tag.fieldNr == 78 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedUint64 = decoder.readPackedUInt64() + msg.packedUint64 += decoder.readPackedUInt64() + } + + tag.fieldNr == 78 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readUInt64() + (msg.packedUint64 as MutableList).add(elem) } tag.fieldNr == 79 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedSint32 = decoder.readPackedSInt32() + msg.packedSint32 += decoder.readPackedSInt32() + } + + tag.fieldNr == 79 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readSInt32() + (msg.packedSint32 as MutableList).add(elem) } tag.fieldNr == 80 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedSint64 = decoder.readPackedSInt64() + msg.packedSint64 += decoder.readPackedSInt64() + } + + tag.fieldNr == 80 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readSInt64() + (msg.packedSint64 as MutableList).add(elem) } tag.fieldNr == 81 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedFixed32 = decoder.readPackedFixed32() + msg.packedFixed32 += decoder.readPackedFixed32() + } + + tag.fieldNr == 81 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { + val elem = decoder.readFixed32() + (msg.packedFixed32 as MutableList).add(elem) } tag.fieldNr == 82 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedFixed64 = decoder.readPackedFixed64() + msg.packedFixed64 += decoder.readPackedFixed64() + } + + tag.fieldNr == 82 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { + val elem = decoder.readFixed64() + (msg.packedFixed64 as MutableList).add(elem) } tag.fieldNr == 83 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedSfixed32 = decoder.readPackedSFixed32() + msg.packedSfixed32 += decoder.readPackedSFixed32() + } + + tag.fieldNr == 83 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { + val elem = decoder.readSFixed32() + (msg.packedSfixed32 as MutableList).add(elem) } tag.fieldNr == 84 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedSfixed64 = decoder.readPackedSFixed64() + msg.packedSfixed64 += decoder.readPackedSFixed64() + } + + tag.fieldNr == 84 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { + val elem = decoder.readSFixed64() + (msg.packedSfixed64 as MutableList).add(elem) } tag.fieldNr == 85 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedFloat = decoder.readPackedFloat() + msg.packedFloat += decoder.readPackedFloat() + } + + tag.fieldNr == 85 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { + val elem = decoder.readFloat() + (msg.packedFloat as MutableList).add(elem) } tag.fieldNr == 86 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedDouble = decoder.readPackedDouble() + msg.packedDouble += decoder.readPackedDouble() + } + + tag.fieldNr == 86 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { + val elem = decoder.readDouble() + (msg.packedDouble as MutableList).add(elem) } tag.fieldNr == 87 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedBool = decoder.readPackedBool() + msg.packedBool += decoder.readPackedBool() + } + + tag.fieldNr == 87 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readBool() + (msg.packedBool as MutableList).add(elem) } tag.fieldNr == 88 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedNestedEnum = decoder.readPackedEnum().map { com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.fromNumber(it) } + msg.packedNestedEnum += decoder.readPackedEnum().map { com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.fromNumber(it) } + } + + tag.fieldNr == 88 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.fromNumber(decoder.readEnum()) + (msg.packedNestedEnum as MutableList).add(elem) + } + + tag.fieldNr == 89 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedInt32 += decoder.readPackedInt32() } tag.fieldNr == 89 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { @@ -1847,66 +1996,118 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal (msg.unpackedInt32 as MutableList).add(elem) } + tag.fieldNr == 90 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedInt64 += decoder.readPackedInt64() + } + tag.fieldNr == 90 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { val elem = decoder.readInt64() (msg.unpackedInt64 as MutableList).add(elem) } + tag.fieldNr == 91 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedUint32 += decoder.readPackedUInt32() + } + tag.fieldNr == 91 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { val elem = decoder.readUInt32() (msg.unpackedUint32 as MutableList).add(elem) } + tag.fieldNr == 92 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedUint64 += decoder.readPackedUInt64() + } + tag.fieldNr == 92 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { val elem = decoder.readUInt64() (msg.unpackedUint64 as MutableList).add(elem) } + tag.fieldNr == 93 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedSint32 += decoder.readPackedSInt32() + } + tag.fieldNr == 93 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { val elem = decoder.readSInt32() (msg.unpackedSint32 as MutableList).add(elem) } + tag.fieldNr == 94 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedSint64 += decoder.readPackedSInt64() + } + tag.fieldNr == 94 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { val elem = decoder.readSInt64() (msg.unpackedSint64 as MutableList).add(elem) } + tag.fieldNr == 95 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedFixed32 += decoder.readPackedFixed32() + } + tag.fieldNr == 95 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { val elem = decoder.readFixed32() (msg.unpackedFixed32 as MutableList).add(elem) } + tag.fieldNr == 96 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedFixed64 += decoder.readPackedFixed64() + } + tag.fieldNr == 96 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { val elem = decoder.readFixed64() (msg.unpackedFixed64 as MutableList).add(elem) } + tag.fieldNr == 97 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedSfixed32 += decoder.readPackedSFixed32() + } + tag.fieldNr == 97 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { val elem = decoder.readSFixed32() (msg.unpackedSfixed32 as MutableList).add(elem) } + tag.fieldNr == 98 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedSfixed64 += decoder.readPackedSFixed64() + } + tag.fieldNr == 98 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { val elem = decoder.readSFixed64() (msg.unpackedSfixed64 as MutableList).add(elem) } + tag.fieldNr == 99 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedFloat += decoder.readPackedFloat() + } + tag.fieldNr == 99 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { val elem = decoder.readFloat() (msg.unpackedFloat as MutableList).add(elem) } + tag.fieldNr == 100 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedDouble += decoder.readPackedDouble() + } + tag.fieldNr == 100 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { val elem = decoder.readDouble() (msg.unpackedDouble as MutableList).add(elem) } + tag.fieldNr == 101 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedBool += decoder.readPackedBool() + } + tag.fieldNr == 101 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { val elem = decoder.readBool() (msg.unpackedBool as MutableList).add(elem) } + tag.fieldNr == 102 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedNestedEnum += decoder.readPackedEnum().map { com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.fromNumber(it) } + } + tag.fieldNr == 102 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { val elem = com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.fromNumber(decoder.readEnum()) (msg.unpackedNestedEnum as MutableList).add(elem) @@ -2459,15 +2660,15 @@ private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3 __result += optionalForeignMessage.asInternal()._size.let { kotlinx.rpc.protobuf.internal.WireSize.tag(19, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it } } - if (com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.NEG != optionalNestedEnum) { + if (optionalNestedEnum != com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.FOO) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(21, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(optionalNestedEnum.number)) } - if (com.google.protobuf_test_messages.editions.proto3.ForeignEnum.FOREIGN_FOO != optionalForeignEnum) { + if (optionalForeignEnum != com.google.protobuf_test_messages.editions.proto3.ForeignEnum.FOREIGN_FOO) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(22, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(optionalForeignEnum.number)) } - if (com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.AliasedEnum.ALIAS_FOO != optionalAliasedEnum) { + if (optionalAliasedEnum != com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.AliasedEnum.ALIAS_FOO) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(23, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(optionalAliasedEnum.number)) } @@ -2536,19 +2737,19 @@ private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3 } if (repeatedString.isNotEmpty()) { - __result = repeatedString.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(44, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedString.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(44, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedBytes.isNotEmpty()) { - __result = repeatedBytes.sumOf { kotlinx.rpc.protobuf.internal.WireSize.bytes(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(45, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedBytes.sumOf { kotlinx.rpc.protobuf.internal.WireSize.bytes(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(45, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedNestedMessage.isNotEmpty()) { - __result = repeatedNestedMessage.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(48, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedNestedMessage.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(48, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedForeignMessage.isNotEmpty()) { - __result = repeatedForeignMessage.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(49, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedForeignMessage.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(49, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedNestedEnum.isNotEmpty()) { @@ -2560,11 +2761,11 @@ private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3 } if (repeatedStringPiece.isNotEmpty()) { - __result = repeatedStringPiece.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(54, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedStringPiece.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(54, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedCord.isNotEmpty()) { - __result = repeatedCord.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(55, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedCord.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(55, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (packedInt32.isNotEmpty()) { @@ -2624,59 +2825,59 @@ private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3 } if (unpackedInt32.isNotEmpty()) { - __result = unpackedInt32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.int32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(89, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedInt32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.int32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(89, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (unpackedInt64.isNotEmpty()) { - __result = unpackedInt64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.int64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(90, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedInt64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.int64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(90, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (unpackedUint32.isNotEmpty()) { - __result = unpackedUint32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.uInt32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(91, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedUint32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.uInt32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(91, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (unpackedUint64.isNotEmpty()) { - __result = unpackedUint64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.uInt64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(92, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedUint64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.uInt64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(92, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (unpackedSint32.isNotEmpty()) { - __result = unpackedSint32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sInt32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(93, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedSint32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sInt32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(93, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (unpackedSint64.isNotEmpty()) { - __result = unpackedSint64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sInt64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(94, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedSint64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sInt64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(94, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (unpackedFixed32.isNotEmpty()) { - __result = unpackedFixed32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.fixed32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(95, kotlinx.rpc.protobuf.internal.WireType.FIXED32) } + __result += unpackedFixed32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.fixed32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(95, kotlinx.rpc.protobuf.internal.WireType.FIXED32) } } if (unpackedFixed64.isNotEmpty()) { - __result = unpackedFixed64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.fixed64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(96, kotlinx.rpc.protobuf.internal.WireType.FIXED64) } + __result += unpackedFixed64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.fixed64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(96, kotlinx.rpc.protobuf.internal.WireType.FIXED64) } } if (unpackedSfixed32.isNotEmpty()) { - __result = unpackedSfixed32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sFixed32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(97, kotlinx.rpc.protobuf.internal.WireType.FIXED32) } + __result += unpackedSfixed32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sFixed32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(97, kotlinx.rpc.protobuf.internal.WireType.FIXED32) } } if (unpackedSfixed64.isNotEmpty()) { - __result = unpackedSfixed64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sFixed64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(98, kotlinx.rpc.protobuf.internal.WireType.FIXED64) } + __result += unpackedSfixed64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sFixed64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(98, kotlinx.rpc.protobuf.internal.WireType.FIXED64) } } if (unpackedFloat.isNotEmpty()) { - __result = unpackedFloat.sumOf { kotlinx.rpc.protobuf.internal.WireSize.float(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(99, kotlinx.rpc.protobuf.internal.WireType.FIXED32) } + __result += unpackedFloat.sumOf { kotlinx.rpc.protobuf.internal.WireSize.float(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(99, kotlinx.rpc.protobuf.internal.WireType.FIXED32) } } if (unpackedDouble.isNotEmpty()) { - __result = unpackedDouble.sumOf { kotlinx.rpc.protobuf.internal.WireSize.double(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(100, kotlinx.rpc.protobuf.internal.WireType.FIXED64) } + __result += unpackedDouble.sumOf { kotlinx.rpc.protobuf.internal.WireSize.double(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(100, kotlinx.rpc.protobuf.internal.WireType.FIXED64) } } if (unpackedBool.isNotEmpty()) { - __result = unpackedBool.sumOf { kotlinx.rpc.protobuf.internal.WireSize.bool(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(101, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedBool.sumOf { kotlinx.rpc.protobuf.internal.WireSize.bool(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(101, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (unpackedNestedEnum.isNotEmpty()) { - __result = unpackedNestedEnum.sumOf { kotlinx.rpc.protobuf.internal.WireSize.enum(it.number) + kotlinx.rpc.protobuf.internal.WireSize.tag(102, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedNestedEnum.sumOf { kotlinx.rpc.protobuf.internal.WireSize.enum(it.number) + kotlinx.rpc.protobuf.internal.WireSize.tag(102, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (mapInt32Int32.isNotEmpty()) { @@ -2906,39 +3107,39 @@ private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3 } if (repeatedBoolWrapper.isNotEmpty()) { - __result = repeatedBoolWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(211, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedBoolWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(211, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedInt32Wrapper.isNotEmpty()) { - __result = repeatedInt32Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(212, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedInt32Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(212, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedInt64Wrapper.isNotEmpty()) { - __result = repeatedInt64Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(213, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedInt64Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(213, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedUint32Wrapper.isNotEmpty()) { - __result = repeatedUint32Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(214, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedUint32Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(214, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedUint64Wrapper.isNotEmpty()) { - __result = repeatedUint64Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(215, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedUint64Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(215, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedFloatWrapper.isNotEmpty()) { - __result = repeatedFloatWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(216, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedFloatWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(216, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedDoubleWrapper.isNotEmpty()) { - __result = repeatedDoubleWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(217, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedDoubleWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(217, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedStringWrapper.isNotEmpty()) { - __result = repeatedStringWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(218, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedStringWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(218, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedBytesWrapper.isNotEmpty()) { - __result = repeatedBytesWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(219, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedBytesWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(219, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (presenceMask[12]) { @@ -2965,36 +3166,36 @@ private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3 __result += optionalValue.asInternal()._size.let { kotlinx.rpc.protobuf.internal.WireSize.tag(306, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it } } - if (com.google.protobuf.kotlin.NullValue.NULL_VALUE != optionalNullValue) { + if (optionalNullValue != com.google.protobuf.kotlin.NullValue.NULL_VALUE) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(307, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(optionalNullValue.number)) } if (repeatedDuration.isNotEmpty()) { - __result = repeatedDuration.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(311, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedDuration.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(311, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedTimestamp.isNotEmpty()) { - __result = repeatedTimestamp.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(312, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedTimestamp.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(312, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedFieldmask.isNotEmpty()) { - __result = repeatedFieldmask.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(313, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedFieldmask.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(313, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedStruct.isNotEmpty()) { - __result = repeatedStruct.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(324, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedStruct.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(324, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedAny.isNotEmpty()) { - __result = repeatedAny.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(315, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedAny.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(315, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedValue.isNotEmpty()) { - __result = repeatedValue.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(316, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedValue.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(316, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedListValue.isNotEmpty()) { - __result = repeatedListValue.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(317, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedListValue.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(317, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (fieldname1 != 0) { @@ -4252,7 +4453,7 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal encoder.writeString(fieldNr = 1, value = key) } - if (com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.NEG != value) { + if (value != com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.FOO) { encoder.writeEnum(fieldNr = 2, value = value.number) } } @@ -4284,7 +4485,7 @@ private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3 __result += kotlinx.rpc.protobuf.internal.WireSize.string(key).let { kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it } } - if (com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.NEG != value) { + if (value != com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.FOO) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(value.number)) } @@ -4307,7 +4508,7 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal encoder.writeString(fieldNr = 1, value = key) } - if (com.google.protobuf_test_messages.editions.proto3.ForeignEnum.FOREIGN_FOO != value) { + if (value != com.google.protobuf_test_messages.editions.proto3.ForeignEnum.FOREIGN_FOO) { encoder.writeEnum(fieldNr = 2, value = value.number) } } @@ -4339,7 +4540,7 @@ private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3 __result += kotlinx.rpc.protobuf.internal.WireSize.string(key).let { kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it } } - if (com.google.protobuf_test_messages.editions.proto3.ForeignEnum.FOREIGN_FOO != value) { + if (value != com.google.protobuf_test_messages.editions.proto3.ForeignEnum.FOREIGN_FOO) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(value.number)) } diff --git a/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/proto3/_rpc_internal/TestMessagesProto3.kt b/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/proto3/_rpc_internal/TestMessagesProto3.kt index acaf18379..df9366597 100644 --- a/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/proto3/_rpc_internal/TestMessagesProto3.kt +++ b/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/proto3/_rpc_internal/TestMessagesProto3.kt @@ -48,7 +48,7 @@ class TestAllTypesProto3Internal: com.google.protobuf_test_messages.proto3.TestA override var optionalBytes: ByteArray by MsgFieldDelegate { byteArrayOf() } override var optionalNestedMessage: com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedMessage by MsgFieldDelegate(PresenceIndices.optionalNestedMessage) { com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.NestedMessageInternal() } override var optionalForeignMessage: com.google.protobuf_test_messages.proto3.ForeignMessage by MsgFieldDelegate(PresenceIndices.optionalForeignMessage) { com.google.protobuf_test_messages.proto3.ForeignMessageInternal() } - override var optionalNestedEnum: com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum by MsgFieldDelegate { com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.NEG } + override var optionalNestedEnum: com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum by MsgFieldDelegate { com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.FOO } override var optionalForeignEnum: com.google.protobuf_test_messages.proto3.ForeignEnum by MsgFieldDelegate { com.google.protobuf_test_messages.proto3.ForeignEnum.FOREIGN_FOO } override var optionalAliasedEnum: com.google.protobuf_test_messages.proto3.TestAllTypesProto3.AliasedEnum by MsgFieldDelegate { com.google.protobuf_test_messages.proto3.TestAllTypesProto3.AliasedEnum.ALIAS_FOO } override var optionalStringPiece: String by MsgFieldDelegate { "" } @@ -413,7 +413,7 @@ class TestAllTypesProto3Internal: com.google.protobuf_test_messages.proto3.TestA override val _size: Int by lazy { computeSize() } var key: String by MsgFieldDelegate { "" } - var value: com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum by MsgFieldDelegate { com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.NEG } + var value: com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum by MsgFieldDelegate { com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.FOO } @kotlinx.rpc.internal.utils.InternalRpcApi companion object @@ -820,15 +820,15 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.encodeWi encoder.writeMessage(fieldNr = 19, value = optionalForeignMessage.asInternal()) { encodeWith(it) } } - if (com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.NEG != optionalNestedEnum) { + if (optionalNestedEnum != com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.FOO) { encoder.writeEnum(fieldNr = 21, value = optionalNestedEnum.number) } - if (com.google.protobuf_test_messages.proto3.ForeignEnum.FOREIGN_FOO != optionalForeignEnum) { + if (optionalForeignEnum != com.google.protobuf_test_messages.proto3.ForeignEnum.FOREIGN_FOO) { encoder.writeEnum(fieldNr = 22, value = optionalForeignEnum.number) } - if (com.google.protobuf_test_messages.proto3.TestAllTypesProto3.AliasedEnum.ALIAS_FOO != optionalAliasedEnum) { + if (optionalAliasedEnum != com.google.protobuf_test_messages.proto3.TestAllTypesProto3.AliasedEnum.ALIAS_FOO) { encoder.writeEnum(fieldNr = 23, value = optionalAliasedEnum.number) } @@ -1422,7 +1422,7 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.encodeWi encoder.writeMessage(fieldNr = 306, value = optionalValue.asInternal()) { encodeWith(it) } } - if (com.google.protobuf.kotlin.NullValue.NULL_VALUE != optionalNullValue) { + if (optionalNullValue != com.google.protobuf.kotlin.NullValue.NULL_VALUE) { encoder.writeEnum(fieldNr = 307, value = optionalNullValue.number) } @@ -1695,55 +1695,120 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.Companio } tag.fieldNr == 31 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedInt32 = decoder.readPackedInt32() + msg.repeatedInt32 += decoder.readPackedInt32() + } + + tag.fieldNr == 31 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readInt32() + (msg.repeatedInt32 as MutableList).add(elem) } tag.fieldNr == 32 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedInt64 = decoder.readPackedInt64() + msg.repeatedInt64 += decoder.readPackedInt64() + } + + tag.fieldNr == 32 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readInt64() + (msg.repeatedInt64 as MutableList).add(elem) } tag.fieldNr == 33 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedUint32 = decoder.readPackedUInt32() + msg.repeatedUint32 += decoder.readPackedUInt32() + } + + tag.fieldNr == 33 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readUInt32() + (msg.repeatedUint32 as MutableList).add(elem) } tag.fieldNr == 34 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedUint64 = decoder.readPackedUInt64() + msg.repeatedUint64 += decoder.readPackedUInt64() + } + + tag.fieldNr == 34 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readUInt64() + (msg.repeatedUint64 as MutableList).add(elem) } tag.fieldNr == 35 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedSint32 = decoder.readPackedSInt32() + msg.repeatedSint32 += decoder.readPackedSInt32() + } + + tag.fieldNr == 35 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readSInt32() + (msg.repeatedSint32 as MutableList).add(elem) } tag.fieldNr == 36 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedSint64 = decoder.readPackedSInt64() + msg.repeatedSint64 += decoder.readPackedSInt64() + } + + tag.fieldNr == 36 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readSInt64() + (msg.repeatedSint64 as MutableList).add(elem) } tag.fieldNr == 37 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedFixed32 = decoder.readPackedFixed32() + msg.repeatedFixed32 += decoder.readPackedFixed32() + } + + tag.fieldNr == 37 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { + val elem = decoder.readFixed32() + (msg.repeatedFixed32 as MutableList).add(elem) } tag.fieldNr == 38 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedFixed64 = decoder.readPackedFixed64() + msg.repeatedFixed64 += decoder.readPackedFixed64() + } + + tag.fieldNr == 38 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { + val elem = decoder.readFixed64() + (msg.repeatedFixed64 as MutableList).add(elem) } tag.fieldNr == 39 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedSfixed32 = decoder.readPackedSFixed32() + msg.repeatedSfixed32 += decoder.readPackedSFixed32() + } + + tag.fieldNr == 39 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { + val elem = decoder.readSFixed32() + (msg.repeatedSfixed32 as MutableList).add(elem) } tag.fieldNr == 40 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedSfixed64 = decoder.readPackedSFixed64() + msg.repeatedSfixed64 += decoder.readPackedSFixed64() + } + + tag.fieldNr == 40 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { + val elem = decoder.readSFixed64() + (msg.repeatedSfixed64 as MutableList).add(elem) } tag.fieldNr == 41 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedFloat = decoder.readPackedFloat() + msg.repeatedFloat += decoder.readPackedFloat() + } + + tag.fieldNr == 41 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { + val elem = decoder.readFloat() + (msg.repeatedFloat as MutableList).add(elem) } tag.fieldNr == 42 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedDouble = decoder.readPackedDouble() + msg.repeatedDouble += decoder.readPackedDouble() + } + + tag.fieldNr == 42 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { + val elem = decoder.readDouble() + (msg.repeatedDouble as MutableList).add(elem) } tag.fieldNr == 43 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedBool = decoder.readPackedBool() + msg.repeatedBool += decoder.readPackedBool() + } + + tag.fieldNr == 43 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readBool() + (msg.repeatedBool as MutableList).add(elem) } tag.fieldNr == 44 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { @@ -1769,11 +1834,21 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.Companio } tag.fieldNr == 51 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedNestedEnum = decoder.readPackedEnum().map { com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.fromNumber(it) } + msg.repeatedNestedEnum += decoder.readPackedEnum().map { com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.fromNumber(it) } + } + + tag.fieldNr == 51 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.fromNumber(decoder.readEnum()) + (msg.repeatedNestedEnum as MutableList).add(elem) } tag.fieldNr == 52 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedForeignEnum = decoder.readPackedEnum().map { com.google.protobuf_test_messages.proto3.ForeignEnum.fromNumber(it) } + msg.repeatedForeignEnum += decoder.readPackedEnum().map { com.google.protobuf_test_messages.proto3.ForeignEnum.fromNumber(it) } + } + + tag.fieldNr == 52 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = com.google.protobuf_test_messages.proto3.ForeignEnum.fromNumber(decoder.readEnum()) + (msg.repeatedForeignEnum as MutableList).add(elem) } tag.fieldNr == 54 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { @@ -1787,59 +1862,133 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.Companio } tag.fieldNr == 75 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedInt32 = decoder.readPackedInt32() + msg.packedInt32 += decoder.readPackedInt32() + } + + tag.fieldNr == 75 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readInt32() + (msg.packedInt32 as MutableList).add(elem) } tag.fieldNr == 76 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedInt64 = decoder.readPackedInt64() + msg.packedInt64 += decoder.readPackedInt64() + } + + tag.fieldNr == 76 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readInt64() + (msg.packedInt64 as MutableList).add(elem) } tag.fieldNr == 77 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedUint32 = decoder.readPackedUInt32() + msg.packedUint32 += decoder.readPackedUInt32() + } + + tag.fieldNr == 77 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readUInt32() + (msg.packedUint32 as MutableList).add(elem) } tag.fieldNr == 78 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedUint64 = decoder.readPackedUInt64() + msg.packedUint64 += decoder.readPackedUInt64() + } + + tag.fieldNr == 78 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readUInt64() + (msg.packedUint64 as MutableList).add(elem) } tag.fieldNr == 79 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedSint32 = decoder.readPackedSInt32() + msg.packedSint32 += decoder.readPackedSInt32() + } + + tag.fieldNr == 79 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readSInt32() + (msg.packedSint32 as MutableList).add(elem) } tag.fieldNr == 80 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedSint64 = decoder.readPackedSInt64() + msg.packedSint64 += decoder.readPackedSInt64() + } + + tag.fieldNr == 80 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readSInt64() + (msg.packedSint64 as MutableList).add(elem) } tag.fieldNr == 81 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedFixed32 = decoder.readPackedFixed32() + msg.packedFixed32 += decoder.readPackedFixed32() + } + + tag.fieldNr == 81 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { + val elem = decoder.readFixed32() + (msg.packedFixed32 as MutableList).add(elem) } tag.fieldNr == 82 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedFixed64 = decoder.readPackedFixed64() + msg.packedFixed64 += decoder.readPackedFixed64() + } + + tag.fieldNr == 82 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { + val elem = decoder.readFixed64() + (msg.packedFixed64 as MutableList).add(elem) } tag.fieldNr == 83 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedSfixed32 = decoder.readPackedSFixed32() + msg.packedSfixed32 += decoder.readPackedSFixed32() + } + + tag.fieldNr == 83 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { + val elem = decoder.readSFixed32() + (msg.packedSfixed32 as MutableList).add(elem) } tag.fieldNr == 84 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedSfixed64 = decoder.readPackedSFixed64() + msg.packedSfixed64 += decoder.readPackedSFixed64() + } + + tag.fieldNr == 84 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { + val elem = decoder.readSFixed64() + (msg.packedSfixed64 as MutableList).add(elem) } tag.fieldNr == 85 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedFloat = decoder.readPackedFloat() + msg.packedFloat += decoder.readPackedFloat() + } + + tag.fieldNr == 85 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { + val elem = decoder.readFloat() + (msg.packedFloat as MutableList).add(elem) } tag.fieldNr == 86 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedDouble = decoder.readPackedDouble() + msg.packedDouble += decoder.readPackedDouble() + } + + tag.fieldNr == 86 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { + val elem = decoder.readDouble() + (msg.packedDouble as MutableList).add(elem) } tag.fieldNr == 87 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedBool = decoder.readPackedBool() + msg.packedBool += decoder.readPackedBool() + } + + tag.fieldNr == 87 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readBool() + (msg.packedBool as MutableList).add(elem) } tag.fieldNr == 88 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedNestedEnum = decoder.readPackedEnum().map { com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.fromNumber(it) } + msg.packedNestedEnum += decoder.readPackedEnum().map { com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.fromNumber(it) } + } + + tag.fieldNr == 88 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.fromNumber(decoder.readEnum()) + (msg.packedNestedEnum as MutableList).add(elem) + } + + tag.fieldNr == 89 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedInt32 += decoder.readPackedInt32() } tag.fieldNr == 89 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { @@ -1847,66 +1996,118 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.Companio (msg.unpackedInt32 as MutableList).add(elem) } + tag.fieldNr == 90 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedInt64 += decoder.readPackedInt64() + } + tag.fieldNr == 90 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { val elem = decoder.readInt64() (msg.unpackedInt64 as MutableList).add(elem) } + tag.fieldNr == 91 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedUint32 += decoder.readPackedUInt32() + } + tag.fieldNr == 91 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { val elem = decoder.readUInt32() (msg.unpackedUint32 as MutableList).add(elem) } + tag.fieldNr == 92 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedUint64 += decoder.readPackedUInt64() + } + tag.fieldNr == 92 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { val elem = decoder.readUInt64() (msg.unpackedUint64 as MutableList).add(elem) } + tag.fieldNr == 93 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedSint32 += decoder.readPackedSInt32() + } + tag.fieldNr == 93 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { val elem = decoder.readSInt32() (msg.unpackedSint32 as MutableList).add(elem) } + tag.fieldNr == 94 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedSint64 += decoder.readPackedSInt64() + } + tag.fieldNr == 94 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { val elem = decoder.readSInt64() (msg.unpackedSint64 as MutableList).add(elem) } + tag.fieldNr == 95 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedFixed32 += decoder.readPackedFixed32() + } + tag.fieldNr == 95 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { val elem = decoder.readFixed32() (msg.unpackedFixed32 as MutableList).add(elem) } + tag.fieldNr == 96 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedFixed64 += decoder.readPackedFixed64() + } + tag.fieldNr == 96 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { val elem = decoder.readFixed64() (msg.unpackedFixed64 as MutableList).add(elem) } + tag.fieldNr == 97 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedSfixed32 += decoder.readPackedSFixed32() + } + tag.fieldNr == 97 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { val elem = decoder.readSFixed32() (msg.unpackedSfixed32 as MutableList).add(elem) } + tag.fieldNr == 98 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedSfixed64 += decoder.readPackedSFixed64() + } + tag.fieldNr == 98 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { val elem = decoder.readSFixed64() (msg.unpackedSfixed64 as MutableList).add(elem) } + tag.fieldNr == 99 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedFloat += decoder.readPackedFloat() + } + tag.fieldNr == 99 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { val elem = decoder.readFloat() (msg.unpackedFloat as MutableList).add(elem) } + tag.fieldNr == 100 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedDouble += decoder.readPackedDouble() + } + tag.fieldNr == 100 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { val elem = decoder.readDouble() (msg.unpackedDouble as MutableList).add(elem) } + tag.fieldNr == 101 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedBool += decoder.readPackedBool() + } + tag.fieldNr == 101 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { val elem = decoder.readBool() (msg.unpackedBool as MutableList).add(elem) } + tag.fieldNr == 102 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedNestedEnum += decoder.readPackedEnum().map { com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.fromNumber(it) } + } + tag.fieldNr == 102 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { val elem = com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.fromNumber(decoder.readEnum()) (msg.unpackedNestedEnum as MutableList).add(elem) @@ -2459,15 +2660,15 @@ private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal. __result += optionalForeignMessage.asInternal()._size.let { kotlinx.rpc.protobuf.internal.WireSize.tag(19, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it } } - if (com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.NEG != optionalNestedEnum) { + if (optionalNestedEnum != com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.FOO) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(21, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(optionalNestedEnum.number)) } - if (com.google.protobuf_test_messages.proto3.ForeignEnum.FOREIGN_FOO != optionalForeignEnum) { + if (optionalForeignEnum != com.google.protobuf_test_messages.proto3.ForeignEnum.FOREIGN_FOO) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(22, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(optionalForeignEnum.number)) } - if (com.google.protobuf_test_messages.proto3.TestAllTypesProto3.AliasedEnum.ALIAS_FOO != optionalAliasedEnum) { + if (optionalAliasedEnum != com.google.protobuf_test_messages.proto3.TestAllTypesProto3.AliasedEnum.ALIAS_FOO) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(23, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(optionalAliasedEnum.number)) } @@ -2536,19 +2737,19 @@ private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal. } if (repeatedString.isNotEmpty()) { - __result = repeatedString.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(44, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedString.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(44, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedBytes.isNotEmpty()) { - __result = repeatedBytes.sumOf { kotlinx.rpc.protobuf.internal.WireSize.bytes(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(45, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedBytes.sumOf { kotlinx.rpc.protobuf.internal.WireSize.bytes(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(45, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedNestedMessage.isNotEmpty()) { - __result = repeatedNestedMessage.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(48, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedNestedMessage.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(48, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedForeignMessage.isNotEmpty()) { - __result = repeatedForeignMessage.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(49, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedForeignMessage.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(49, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedNestedEnum.isNotEmpty()) { @@ -2560,11 +2761,11 @@ private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal. } if (repeatedStringPiece.isNotEmpty()) { - __result = repeatedStringPiece.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(54, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedStringPiece.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(54, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedCord.isNotEmpty()) { - __result = repeatedCord.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(55, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedCord.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(55, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (packedInt32.isNotEmpty()) { @@ -2624,59 +2825,59 @@ private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal. } if (unpackedInt32.isNotEmpty()) { - __result = unpackedInt32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.int32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(89, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedInt32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.int32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(89, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (unpackedInt64.isNotEmpty()) { - __result = unpackedInt64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.int64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(90, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedInt64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.int64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(90, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (unpackedUint32.isNotEmpty()) { - __result = unpackedUint32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.uInt32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(91, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedUint32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.uInt32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(91, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (unpackedUint64.isNotEmpty()) { - __result = unpackedUint64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.uInt64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(92, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedUint64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.uInt64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(92, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (unpackedSint32.isNotEmpty()) { - __result = unpackedSint32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sInt32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(93, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedSint32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sInt32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(93, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (unpackedSint64.isNotEmpty()) { - __result = unpackedSint64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sInt64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(94, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedSint64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sInt64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(94, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (unpackedFixed32.isNotEmpty()) { - __result = unpackedFixed32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.fixed32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(95, kotlinx.rpc.protobuf.internal.WireType.FIXED32) } + __result += unpackedFixed32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.fixed32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(95, kotlinx.rpc.protobuf.internal.WireType.FIXED32) } } if (unpackedFixed64.isNotEmpty()) { - __result = unpackedFixed64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.fixed64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(96, kotlinx.rpc.protobuf.internal.WireType.FIXED64) } + __result += unpackedFixed64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.fixed64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(96, kotlinx.rpc.protobuf.internal.WireType.FIXED64) } } if (unpackedSfixed32.isNotEmpty()) { - __result = unpackedSfixed32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sFixed32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(97, kotlinx.rpc.protobuf.internal.WireType.FIXED32) } + __result += unpackedSfixed32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sFixed32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(97, kotlinx.rpc.protobuf.internal.WireType.FIXED32) } } if (unpackedSfixed64.isNotEmpty()) { - __result = unpackedSfixed64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sFixed64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(98, kotlinx.rpc.protobuf.internal.WireType.FIXED64) } + __result += unpackedSfixed64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sFixed64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(98, kotlinx.rpc.protobuf.internal.WireType.FIXED64) } } if (unpackedFloat.isNotEmpty()) { - __result = unpackedFloat.sumOf { kotlinx.rpc.protobuf.internal.WireSize.float(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(99, kotlinx.rpc.protobuf.internal.WireType.FIXED32) } + __result += unpackedFloat.sumOf { kotlinx.rpc.protobuf.internal.WireSize.float(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(99, kotlinx.rpc.protobuf.internal.WireType.FIXED32) } } if (unpackedDouble.isNotEmpty()) { - __result = unpackedDouble.sumOf { kotlinx.rpc.protobuf.internal.WireSize.double(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(100, kotlinx.rpc.protobuf.internal.WireType.FIXED64) } + __result += unpackedDouble.sumOf { kotlinx.rpc.protobuf.internal.WireSize.double(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(100, kotlinx.rpc.protobuf.internal.WireType.FIXED64) } } if (unpackedBool.isNotEmpty()) { - __result = unpackedBool.sumOf { kotlinx.rpc.protobuf.internal.WireSize.bool(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(101, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedBool.sumOf { kotlinx.rpc.protobuf.internal.WireSize.bool(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(101, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (unpackedNestedEnum.isNotEmpty()) { - __result = unpackedNestedEnum.sumOf { kotlinx.rpc.protobuf.internal.WireSize.enum(it.number) + kotlinx.rpc.protobuf.internal.WireSize.tag(102, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedNestedEnum.sumOf { kotlinx.rpc.protobuf.internal.WireSize.enum(it.number) + kotlinx.rpc.protobuf.internal.WireSize.tag(102, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (mapInt32Int32.isNotEmpty()) { @@ -2906,39 +3107,39 @@ private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal. } if (repeatedBoolWrapper.isNotEmpty()) { - __result = repeatedBoolWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(211, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedBoolWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(211, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedInt32Wrapper.isNotEmpty()) { - __result = repeatedInt32Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(212, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedInt32Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(212, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedInt64Wrapper.isNotEmpty()) { - __result = repeatedInt64Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(213, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedInt64Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(213, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedUint32Wrapper.isNotEmpty()) { - __result = repeatedUint32Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(214, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedUint32Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(214, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedUint64Wrapper.isNotEmpty()) { - __result = repeatedUint64Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(215, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedUint64Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(215, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedFloatWrapper.isNotEmpty()) { - __result = repeatedFloatWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(216, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedFloatWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(216, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedDoubleWrapper.isNotEmpty()) { - __result = repeatedDoubleWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(217, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedDoubleWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(217, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedStringWrapper.isNotEmpty()) { - __result = repeatedStringWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(218, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedStringWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(218, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedBytesWrapper.isNotEmpty()) { - __result = repeatedBytesWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(219, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedBytesWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(219, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (presenceMask[12]) { @@ -2965,36 +3166,36 @@ private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal. __result += optionalValue.asInternal()._size.let { kotlinx.rpc.protobuf.internal.WireSize.tag(306, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it } } - if (com.google.protobuf.kotlin.NullValue.NULL_VALUE != optionalNullValue) { + if (optionalNullValue != com.google.protobuf.kotlin.NullValue.NULL_VALUE) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(307, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(optionalNullValue.number)) } if (repeatedDuration.isNotEmpty()) { - __result = repeatedDuration.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(311, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedDuration.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(311, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedTimestamp.isNotEmpty()) { - __result = repeatedTimestamp.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(312, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedTimestamp.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(312, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedFieldmask.isNotEmpty()) { - __result = repeatedFieldmask.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(313, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedFieldmask.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(313, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedStruct.isNotEmpty()) { - __result = repeatedStruct.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(324, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedStruct.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(324, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedAny.isNotEmpty()) { - __result = repeatedAny.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(315, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedAny.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(315, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedValue.isNotEmpty()) { - __result = repeatedValue.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(316, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedValue.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(316, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedListValue.isNotEmpty()) { - __result = repeatedListValue.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(317, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedListValue.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(317, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (fieldname1 != 0) { @@ -4252,7 +4453,7 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapStrin encoder.writeString(fieldNr = 1, value = key) } - if (com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.NEG != value) { + if (value != com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.FOO) { encoder.writeEnum(fieldNr = 2, value = value.number) } } @@ -4284,7 +4485,7 @@ private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal. __result += kotlinx.rpc.protobuf.internal.WireSize.string(key).let { kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it } } - if (com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.NEG != value) { + if (value != com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.FOO) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(value.number)) } @@ -4307,7 +4508,7 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapStrin encoder.writeString(fieldNr = 1, value = key) } - if (com.google.protobuf_test_messages.proto3.ForeignEnum.FOREIGN_FOO != value) { + if (value != com.google.protobuf_test_messages.proto3.ForeignEnum.FOREIGN_FOO) { encoder.writeEnum(fieldNr = 2, value = value.number) } } @@ -4339,7 +4540,7 @@ private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal. __result += kotlinx.rpc.protobuf.internal.WireSize.string(key).let { kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it } } - if (com.google.protobuf_test_messages.proto3.ForeignEnum.FOREIGN_FOO != value) { + if (value != com.google.protobuf_test_messages.proto3.ForeignEnum.FOREIGN_FOO) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(value.number)) } diff --git a/tests/protobuf-conformance/src/main/kotlin/kotlinx/rpc/protoc/gen/test/runner/runner.kt b/tests/protobuf-conformance/src/main/kotlin/kotlinx/rpc/protoc/gen/test/runner/runner.kt index 9c0363fc3..e2146404f 100644 --- a/tests/protobuf-conformance/src/main/kotlin/kotlinx/rpc/protoc/gen/test/runner/runner.kt +++ b/tests/protobuf-conformance/src/main/kotlin/kotlinx/rpc/protoc/gen/test/runner/runner.kt @@ -11,6 +11,7 @@ import kotlin.io.path.createFile import kotlin.io.path.createParentDirectories import kotlin.io.path.deleteIfExists import kotlin.io.path.readLines +import kotlin.properties.Delegates class RunResult( val exitCode: Int, @@ -30,8 +31,9 @@ fun execConformanceTestRunner( val testNameFilter = testName?.let { listOf("--test", it) } ?: emptyList() + var process: Process by Delegates.notNull() return runCatching { - val process = ProcessBuilder( + process = ProcessBuilder( CONFORMANCE_EXECUTABLE_PATH, *testNameFilter.toTypedArray(), "--maximum_edition", "MAX", @@ -43,14 +45,23 @@ fun execConformanceTestRunner( executable, ).redirectError(errorStream.toFile()) .redirectOutput(stdoutStream.toFile()) + .start() - val exitCode = process.start().waitFor() + Runtime.getRuntime().addShutdownHook(Thread { + process.destroy() + }) + + val exitCode = process.waitFor() RunResult( exitCode = exitCode, stdout = stdoutStream.readLines(), stderr = errorStream.readLines(), ) + }.onFailure { + if (process.isAlive) { + process.destroy() + } } }