33 */
44
55@file:OptIn(ExperimentalRpcApi ::class , kotlinx.rpc.internal.utils.InternalRpcApi ::class )
6-
76package com.google.protobuf.kotlin
87
9- import kotlinx.rpc.internal.utils.ExperimentalRpcApi
8+ import kotlinx.rpc.internal.utils.*
109import kotlinx.rpc.protobuf.input.stream.asInputStream
11- import kotlinx.rpc.protobuf.internal.MsgFieldDelegate
12- import kotlinx.rpc.protobuf.internal.bytes
13- import kotlinx.rpc.protobuf.internal.int32
14- import kotlinx.rpc.protobuf.internal.string
15- import kotlinx.rpc.protobuf.internal.tag
16-
17- public class AnyInternal : com.google.protobuf.kotlin.Any ,
18- kotlinx.rpc.protobuf.internal.InternalMessage (fieldsWithPresence = 0 ) {
10+ import kotlinx.rpc.protobuf.internal.*
11+
12+ public class AnyInternal : com.google.protobuf.kotlin.Any , kotlinx.rpc.protobuf.internal.InternalMessage (fieldsWithPresence = 0 ) {
1913 @kotlinx.rpc.internal.utils.InternalRpcApi
2014 public override val _size : Int by lazy { computeSize() }
2115
2216 public override var typeUrl: String by MsgFieldDelegate { " " }
2317 public override var value: ByteArray by MsgFieldDelegate { byteArrayOf() }
2418
2519 @kotlinx.rpc.internal.utils.InternalRpcApi
26- public object CODEC : kotlinx.rpc.grpc.codec.MessageCodec<com.google.protobuf.kotlin.Any> {
27- public override fun encode (value : com.google.protobuf.kotlin.Any ): kotlinx.rpc.protobuf.input.stream.InputStream {
20+ public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec<com.google.protobuf.kotlin.Any> {
21+ public override fun encode (value : com.google.protobuf.kotlin.Any ): kotlinx.rpc.protobuf.input.stream.InputStream {
2822 val buffer = kotlinx.io.Buffer ()
2923 val encoder = kotlinx.rpc.protobuf.internal.WireEncoder (buffer)
30- kotlinx.rpc.protobuf.internal.checkForPlatformEncodeException {
24+ kotlinx.rpc.protobuf.internal.checkForPlatformEncodeException {
3125 value.asInternal().encodeWith(encoder)
3226 }
3327 encoder.flush()
3428 return buffer.asInputStream()
3529 }
3630
37- public override fun decode (stream : kotlinx.rpc.protobuf.input.stream.InputStream ): com.google.protobuf.kotlin.Any {
38- kotlinx.rpc.protobuf.internal.WireDecoder (stream).use {
31+ public override fun decode (stream : kotlinx.rpc.protobuf.input.stream.InputStream ): com.google.protobuf.kotlin.Any {
32+ kotlinx.rpc.protobuf.internal.WireDecoder (stream).use {
3933 val msg = com.google.protobuf.kotlin.AnyInternal ()
40- kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException {
34+ kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException {
4135 com.google.protobuf.kotlin.AnyInternal .decodeWith(msg, it)
4236 }
4337 msg.checkRequiredFields()
@@ -50,46 +44,43 @@ public class AnyInternal : com.google.protobuf.kotlin.Any,
5044 public companion object
5145}
5246
53- public operator fun com.google.protobuf.kotlin.Any.Companion.invoke (body : com.google.protobuf.kotlin.AnyInternal .() -> Unit ): com.google.protobuf.kotlin.Any {
47+ public operator fun com.google.protobuf.kotlin.Any.Companion.invoke (body : com.google.protobuf.kotlin.AnyInternal .() -> Unit ): com.google.protobuf.kotlin.Any {
5448 val msg = com.google.protobuf.kotlin.AnyInternal ().apply (body)
5549 msg.checkRequiredFields()
5650 return msg
5751}
5852
5953@kotlinx.rpc.internal.utils.InternalRpcApi
60- public fun com.google.protobuf.kotlin.AnyInternal.checkRequiredFields () {
54+ public fun com.google.protobuf.kotlin.AnyInternal.checkRequiredFields () {
6155 // no required fields to check
6256}
6357
6458@kotlinx.rpc.internal.utils.InternalRpcApi
65- public fun com.google.protobuf.kotlin.AnyInternal.encodeWith (encoder : kotlinx.rpc.protobuf.internal.WireEncoder ) {
66- if (typeUrl.isNotEmpty()) {
59+ public fun com.google.protobuf.kotlin.AnyInternal.encodeWith (encoder : kotlinx.rpc.protobuf.internal.WireEncoder ) {
60+ if (typeUrl.isNotEmpty()) {
6761 encoder.writeString(fieldNr = 1 , value = typeUrl)
6862 }
6963
70- if (value.isNotEmpty()) {
64+ if (value.isNotEmpty()) {
7165 encoder.writeBytes(fieldNr = 2 , value = value)
7266 }
7367}
7468
7569@kotlinx.rpc.internal.utils.InternalRpcApi
76- public fun com.google.protobuf.kotlin.AnyInternal.Companion.decodeWith (
77- msg : com.google.protobuf.kotlin.AnyInternal ,
78- decoder : kotlinx.rpc.protobuf.internal.WireDecoder ,
79- ) {
80- while (true ) {
70+ public fun com.google.protobuf.kotlin.AnyInternal.Companion.decodeWith (msg : com.google.protobuf.kotlin.AnyInternal , decoder : kotlinx.rpc.protobuf.internal.WireDecoder ) {
71+ while (true ) {
8172 val tag = decoder.readTag() ? : break // EOF, we read the whole message
82- when {
83- tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType .LENGTH_DELIMITED -> {
73+ when {
74+ tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType .LENGTH_DELIMITED -> {
8475 msg.typeUrl = decoder.readString()
8576 }
8677
87- tag.fieldNr == 2 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType .LENGTH_DELIMITED -> {
78+ tag.fieldNr == 2 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType .LENGTH_DELIMITED -> {
8879 msg.value = decoder.readBytes()
8980 }
9081
91- else -> {
92- if (tag.wireType == kotlinx.rpc.protobuf.internal.WireType .END_GROUP ) {
82+ else -> {
83+ if (tag.wireType == kotlinx.rpc.protobuf.internal.WireType .END_GROUP ) {
9384 throw kotlinx.rpc.protobuf.internal.ProtobufDecodingException (" Unexpected END_GROUP tag." )
9485 }
9586
@@ -100,32 +91,21 @@ public fun com.google.protobuf.kotlin.AnyInternal.Companion.decodeWith(
10091 }
10192}
10293
103- private fun com.google.protobuf.kotlin.AnyInternal.computeSize (): Int {
94+ private fun com.google.protobuf.kotlin.AnyInternal.computeSize (): Int {
10495 var __result = 0
105- if (typeUrl.isNotEmpty()) {
106- __result + = kotlinx.rpc.protobuf.internal.WireSize .string(typeUrl).let {
107- kotlinx.rpc.protobuf.internal.WireSize .tag(
108- 1 ,
109- kotlinx.rpc.protobuf.internal.WireType .LENGTH_DELIMITED
110- ) + kotlinx.rpc.protobuf.internal.WireSize .int32(it) + it
111- }
96+ if (typeUrl.isNotEmpty()) {
97+ __result + = kotlinx.rpc.protobuf.internal.WireSize .string(typeUrl).let { kotlinx.rpc.protobuf.internal.WireSize .tag(1 , kotlinx.rpc.protobuf.internal.WireType .LENGTH_DELIMITED ) + kotlinx.rpc.protobuf.internal.WireSize .int32(it) + it }
11298 }
11399
114- if (value.isNotEmpty()) {
115- __result + = kotlinx.rpc.protobuf.internal.WireSize .bytes(value).let {
116- kotlinx.rpc.protobuf.internal.WireSize .tag(
117- 2 ,
118- kotlinx.rpc.protobuf.internal.WireType .LENGTH_DELIMITED
119- ) + kotlinx.rpc.protobuf.internal.WireSize .int32(it) + it
120- }
100+ if (value.isNotEmpty()) {
101+ __result + = kotlinx.rpc.protobuf.internal.WireSize .bytes(value).let { kotlinx.rpc.protobuf.internal.WireSize .tag(2 , kotlinx.rpc.protobuf.internal.WireType .LENGTH_DELIMITED ) + kotlinx.rpc.protobuf.internal.WireSize .int32(it) + it }
121102 }
122103
123104 return __result
124105}
125106
126107@kotlinx.rpc.internal.utils.InternalRpcApi
127- public fun com.google.protobuf.kotlin.Any.asInternal (): com.google.protobuf.kotlin.AnyInternal {
128- return this as ? com.google.protobuf.kotlin.AnyInternal
129- ? : error(" Message ${this ::class .simpleName} is a non-internal message type." )
108+ public fun com.google.protobuf.kotlin.Any.asInternal (): com.google.protobuf.kotlin.AnyInternal {
109+ return this as ? com.google.protobuf.kotlin.AnyInternal ? : error(" Message ${this ::class .simpleName} is a non-internal message type." )
130110}
131111
0 commit comments