diff --git a/.github/workflows/protobuf-well-known-types.yml b/.github/workflows/protobuf-well-known-types.yml
new file mode 100644
index 00000000..286e2494
--- /dev/null
+++ b/.github/workflows/protobuf-well-known-types.yml
@@ -0,0 +1,27 @@
+name: Verify Protobuf Well-Known Types are Up-to-Date
+
+on:
+ pull_request:
+
+permissions:
+ contents: read
+
+jobs:
+ verify-platforms-table:
+ name: Run Verification
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout Sources
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+ - name: Setup Gradle
+ uses: gradle/actions/setup-gradle@v4
+ - name: Run Protobuf Conformance Test Generation
+ run: ./gradlew :protobuf:protobuf-core:bufGenerateCommonMain --info --stacktrace
+ - name: Check if Well-Known Types are up-to-date
+ run: |
+ if [[ -n "$(git status --porcelain | grep protobuf/protobuf-core/)" ]]; then
+ echo "Well-Known Types are not up-to-date. Please run './gradlew :protobuf:protobuf-core:bufGenerateCommonMain' and commit changes"
+ exit 1
+ fi
diff --git a/gradle-plugin/api/gradle-plugin.api b/gradle-plugin/api/gradle-plugin.api
index 87a07f8f..a53d83ed 100644
--- a/gradle-plugin/api/gradle-plugin.api
+++ b/gradle-plugin/api/gradle-plugin.api
@@ -39,11 +39,7 @@ public class kotlinx/rpc/RpcStrictModeExtension {
public final class kotlinx/rpc/VersionsKt {
public static final field BUF_TOOL_VERSION Ljava/lang/String;
- public static final field GRPC_KOTLIN_VERSION Ljava/lang/String;
- public static final field GRPC_VERSION Ljava/lang/String;
public static final field LIBRARY_VERSION Ljava/lang/String;
- public static final field PLUGIN_VERSION Ljava/lang/String;
- public static final field PROTOBUF_VERSION Ljava/lang/String;
}
public class kotlinx/rpc/buf/BufExtension {
@@ -179,17 +175,15 @@ public final class kotlinx/rpc/protoc/ProcessProtoFilesKt$inlined$sam$i$org_grad
public abstract interface class kotlinx/rpc/protoc/ProtoSourceSet {
public abstract fun getName ()Ljava/lang/String;
+ public abstract fun getPlugins ()Lorg/gradle/api/NamedDomainObjectContainer;
public abstract fun getProto ()Lorg/gradle/api/file/SourceDirectorySet;
+ public abstract fun plugins (Lorg/gradle/api/Action;)V
public fun proto (Lorg/gradle/api/Action;)V
- public abstract fun protocPlugin (Lkotlinx/rpc/protoc/ProtocPlugin;)V
- public abstract fun protocPlugin (Lorg/gradle/api/NamedDomainObjectProvider;)V
}
public abstract interface class kotlinx/rpc/protoc/ProtocExtension {
public abstract fun buf (Lorg/gradle/api/Action;)V
public abstract fun getBuf ()Lkotlinx/rpc/buf/BufExtension;
- public abstract fun getPlugins ()Lorg/gradle/api/NamedDomainObjectContainer;
- public abstract fun plugins (Lorg/gradle/api/Action;)V
}
public class kotlinx/rpc/protoc/ProtocPlugin {
diff --git a/gradle-plugin/src/main/kotlin/kotlinx/rpc/buf/tasks/BufGenerateTask.kt b/gradle-plugin/src/main/kotlin/kotlinx/rpc/buf/tasks/BufGenerateTask.kt
index 84a10147..dc6d6207 100644
--- a/gradle-plugin/src/main/kotlin/kotlinx/rpc/buf/tasks/BufGenerateTask.kt
+++ b/gradle-plugin/src/main/kotlin/kotlinx/rpc/buf/tasks/BufGenerateTask.kt
@@ -56,6 +56,8 @@ public abstract class BufGenerateTask : BufExecTask() {
/**
* Whether to include Well-Known Types.
*
+ * Automatically sets [includeImports] to `true`.
+ *
* @see buf generate --include-wkt
* @see [BufGenerateExtension.includeWkt]
*/
@@ -91,7 +93,7 @@ public abstract class BufGenerateTask : BufExecTask() {
buildList {
add("--output"); add(outputDirectory.get().absolutePath)
- if (includeImports.get()) {
+ if (includeImports.get() || includeWkt.get()) {
add("--include-imports")
}
diff --git a/gradle-plugin/src/main/kotlin/kotlinx/rpc/internal/configureLocalProtocGenDevelopmentDependency.kt b/gradle-plugin/src/main/kotlin/kotlinx/rpc/internal/configureLocalProtocGenDevelopmentDependency.kt
index d13d8223..c742ec39 100644
--- a/gradle-plugin/src/main/kotlin/kotlinx/rpc/internal/configureLocalProtocGenDevelopmentDependency.kt
+++ b/gradle-plugin/src/main/kotlin/kotlinx/rpc/internal/configureLocalProtocGenDevelopmentDependency.kt
@@ -7,6 +7,7 @@ package kotlinx.rpc.internal
import kotlinx.rpc.buf.tasks.BufGenerateTask
import kotlinx.rpc.protoc.grpcKotlinMultiplatform
import kotlinx.rpc.protoc.kotlinMultiplatform
+import kotlinx.rpc.protoc.protoSourceSets
import kotlinx.rpc.rpcExtension
import org.gradle.api.Project
import org.gradle.internal.extensions.core.extra
@@ -14,25 +15,32 @@ import org.gradle.kotlin.dsl.provideDelegate
import org.gradle.kotlin.dsl.withType
@InternalRpcApi
-public fun Project.configureLocalProtocGenDevelopmentDependency() {
+public fun Project.configureLocalProtocGenDevelopmentDependency(
+ vararg sourceSetSuffix: String = arrayOf("Test"),
+) {
val globalRootDir: String by extra
- rpcExtension().protoc.plugins {
- kotlinMultiplatform {
- local {
- javaJar("$globalRootDir/protoc-gen/protobuf/build/libs/protobuf-$version-all.jar")
+ // init
+ rpcExtension().protoc()
+
+ protoSourceSets.all {
+ plugins {
+ kotlinMultiplatform {
+ local {
+ javaJar("$globalRootDir/protoc-gen/protobuf/build/libs/protobuf-$version-all.jar")
+ }
}
- }
- grpcKotlinMultiplatform {
- local {
- javaJar("$globalRootDir/protoc-gen/grpc/build/libs/grpc-$version-all.jar")
+ grpcKotlinMultiplatform {
+ local {
+ javaJar("$globalRootDir/protoc-gen/grpc/build/libs/grpc-$version-all.jar")
+ }
}
}
}
tasks.withType().configureEach {
- if (name.endsWith("Test")) {
+ if (sourceSetSuffix.any { name.endsWith(it) }) {
val includedBuild = gradle.includedBuild("protoc-gen")
dependsOn(includedBuild.task(":grpc:jar"))
dependsOn(includedBuild.task(":protobuf:jar"))
diff --git a/gradle-plugin/src/main/kotlin/kotlinx/rpc/protoc/DefaultProtoSourceSet.kt b/gradle-plugin/src/main/kotlin/kotlinx/rpc/protoc/DefaultProtoSourceSet.kt
index 35107ec4..5c4d0769 100644
--- a/gradle-plugin/src/main/kotlin/kotlinx/rpc/protoc/DefaultProtoSourceSet.kt
+++ b/gradle-plugin/src/main/kotlin/kotlinx/rpc/protoc/DefaultProtoSourceSet.kt
@@ -5,6 +5,8 @@
package kotlinx.rpc.protoc
import kotlinx.rpc.buf.tasks.BufGenerateTask
+import kotlinx.rpc.protoc.ProtocPlugin.Companion.GRPC_KOTLIN_MULTIPLATFORM
+import kotlinx.rpc.protoc.ProtocPlugin.Companion.KOTLIN_MULTIPLATFORM
import kotlinx.rpc.util.findOrCreate
import kotlinx.rpc.util.withKotlinJvmExtension
import kotlinx.rpc.util.withKotlinKmpExtension
@@ -17,6 +19,9 @@ import org.gradle.api.tasks.SourceSetContainer
import org.gradle.kotlin.dsl.add
import org.gradle.kotlin.dsl.listProperty
import org.gradle.kotlin.dsl.property
+import org.gradle.kotlin.dsl.the
+import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode
+import org.jetbrains.kotlin.gradle.dsl.KotlinBaseExtension
import javax.inject.Inject
@Suppress("UNCHECKED_CAST")
@@ -34,18 +39,48 @@ internal open class DefaultProtoSourceSet @Inject constructor(
internal val project: Project,
override val name: String,
) : ProtoSourceSet {
- val languageSourceSets: ListProperty = project.objects.listProperty()
- val protocPlugins: ListProperty = project.objects.listProperty().convention(emptyList())
- val generateTask: Property = project.objects.property()
+ override val plugins: NamedDomainObjectContainer =
+ project.objects.domainObjectContainer(ProtocPlugin::class.java) { name ->
+ ProtocPlugin(name, project)
+ }
- override fun protocPlugin(plugin: NamedDomainObjectProvider) {
- protocPlugins.add(plugin.name)
+ override fun plugins(action: Action>) {
+ action.execute(plugins)
}
- override fun protocPlugin(plugin: ProtocPlugin) {
- protocPlugins.add(plugin.name)
+ init {
+ val explicitApiModeEnabled = project.provider {
+ project.the().explicitApi != ExplicitApiMode.Disabled
+ }
+
+ plugins.create(KOTLIN_MULTIPLATFORM) {
+ local {
+ javaJar(project.kotlinMultiplatformProtocPluginJarPath)
+ }
+
+ options.put("debugOutput", "protoc-gen-kotlin-multiplatform.log")
+
+ if (this@DefaultProtoSourceSet.name.lowercase().endsWith("main")) {
+ options.put("explicitApiModeEnabled", explicitApiModeEnabled)
+ }
+ }
+
+ plugins.create(GRPC_KOTLIN_MULTIPLATFORM) {
+ local {
+ javaJar(project.grpcKotlinMultiplatformProtocPluginJarPath)
+ }
+
+ options.put("debugOutput", "protoc-gen-grpc-kotlin-multiplatform.log")
+
+ if (this@DefaultProtoSourceSet.name.lowercase().endsWith("main")) {
+ options.put("explicitApiModeEnabled", explicitApiModeEnabled)
+ }
+ }
}
+ val languageSourceSets: ListProperty = project.objects.listProperty()
+ val generateTask: Property = project.objects.property()
+
override val proto: SourceDirectorySet = project.objects.sourceDirectorySet(
PROTO_SOURCE_DIRECTORY_NAME,
"Proto sources",
diff --git a/gradle-plugin/src/main/kotlin/kotlinx/rpc/protoc/DefaultProtocExtension.kt b/gradle-plugin/src/main/kotlin/kotlinx/rpc/protoc/DefaultProtocExtension.kt
index f895d888..e2297cb4 100644
--- a/gradle-plugin/src/main/kotlin/kotlinx/rpc/protoc/DefaultProtocExtension.kt
+++ b/gradle-plugin/src/main/kotlin/kotlinx/rpc/protoc/DefaultProtocExtension.kt
@@ -13,12 +13,9 @@ import kotlinx.rpc.buf.tasks.registerBufExecTask
import kotlinx.rpc.buf.tasks.registerBufGenerateTask
import kotlinx.rpc.buf.tasks.registerGenerateBufGenYamlTask
import kotlinx.rpc.buf.tasks.registerGenerateBufYamlTask
-import kotlinx.rpc.protoc.ProtocPlugin.Companion.GRPC_KOTLIN_MULTIPLATFORM
-import kotlinx.rpc.protoc.ProtocPlugin.Companion.KOTLIN_MULTIPLATFORM
import kotlinx.rpc.util.ensureDirectoryExists
import org.gradle.api.Action
import org.gradle.api.GradleException
-import org.gradle.api.NamedDomainObjectContainer
import org.gradle.api.Project
import org.gradle.api.file.ConfigurableFileTree
import org.gradle.api.model.ObjectFactory
@@ -41,15 +38,6 @@ internal open class DefaultProtocExtension @Inject constructor(
objects: ObjectFactory,
private val project: Project,
) : ProtocExtension {
- override val plugins: NamedDomainObjectContainer =
- objects.domainObjectContainer(ProtocPlugin::class.java) { name ->
- ProtocPlugin(name, project)
- }
-
- override fun plugins(action: Action>) {
- action.execute(plugins)
- }
-
override val buf: BufExtension = project.objects.newInstance()
override fun buf(action: Action) {
action.execute(buf)
@@ -60,13 +48,10 @@ internal open class DefaultProtocExtension @Inject constructor(
project.configureKotlinMultiplatformPluginJarConfiguration()
project.configureGrpcKotlinMultiplatformPluginJarConfiguration()
- createDefaultProtocPlugins()
-
- project.protoSourceSets.all {
- protocPlugin(plugins.kotlinMultiplatform)
- protocPlugin(plugins.grpcKotlinMultiplatform)
- }
-
+ // ignore for bufGenerate task caching
+ project.normalization.runtimeClasspath.ignore("**/protoc-gen-kotlin-multiplatform.log")
+ project.normalization.runtimeClasspath.ignore("**/protoc-gen-grpc-kotlin-multiplatform.log")
+ project.normalization.runtimeClasspath.ignore("**/.keep")
project.protoSourceSets.all {
if (this !is DefaultProtoSourceSet) {
@@ -92,16 +77,8 @@ internal open class DefaultProtocExtension @Inject constructor(
val pairSourceSet = protoSourceSet.correspondingMainSourceSetOrNull()
- val mainProtocPlugins = pairSourceSet?.protocPlugins ?: provider { emptyList() }
- val protocPluginNames = protoSourceSet.protocPlugins
- .zip(mainProtocPlugins) { left, right -> left + right }
- .map { it.distinct() }
-
- val includedProtocPlugins = protocPluginNames.map { list ->
- list.map { pluginName ->
- this@DefaultProtocExtension.plugins.findByName(pluginName)
- ?: throw GradleException("Protoc plugin $pluginName not found")
- }
+ val includedProtocPlugins = provider {
+ protoSourceSet.plugins.distinct()
}
val protoFiles = protoSourceSet.proto
@@ -303,35 +280,6 @@ internal open class DefaultProtocExtension @Inject constructor(
}
}
- private fun createDefaultProtocPlugins() {
- val explicitApiModeEnabled = project.provider {
- project.the().explicitApi != ExplicitApiMode.Disabled
- }
-
- plugins.create(KOTLIN_MULTIPLATFORM) {
- local {
- javaJar(project.kotlinMultiplatformProtocPluginJarPath)
- }
-
- options.put("debugOutput", "protoc-gen-kotlin-multiplatform.log")
- options.put("explicitApiModeEnabled", explicitApiModeEnabled)
- }
-
- plugins.create(GRPC_KOTLIN_MULTIPLATFORM) {
- local {
- javaJar(project.grpcKotlinMultiplatformProtocPluginJarPath)
- }
-
- options.put("debugOutput", "protoc-gen-grpc-kotlin-multiplatform.log")
- options.put("explicitApiModeEnabled", explicitApiModeEnabled)
- }
-
- // ignore for bufGenerate task caching
- project.normalization.runtimeClasspath.ignore("**/protoc-gen-kotlin-multiplatform.log")
- project.normalization.runtimeClasspath.ignore("**/protoc-gen-grpc-kotlin-multiplatform.log")
- project.normalization.runtimeClasspath.ignore("**/.keep")
- }
-
private fun DefaultProtoSourceSet.correspondingMainSourceSetOrNull(): DefaultProtoSourceSet? {
return when {
name.lowercase().endsWith("main") -> {
diff --git a/gradle-plugin/src/main/kotlin/kotlinx/rpc/protoc/ProtoSourceSet.kt b/gradle-plugin/src/main/kotlin/kotlinx/rpc/protoc/ProtoSourceSet.kt
index 455e6182..1087d3dd 100644
--- a/gradle-plugin/src/main/kotlin/kotlinx/rpc/protoc/ProtoSourceSet.kt
+++ b/gradle-plugin/src/main/kotlin/kotlinx/rpc/protoc/ProtoSourceSet.kt
@@ -21,24 +21,14 @@ public interface ProtoSourceSet {
public val name: String
/**
- * Adds a new protoc plugin.
- *
- * Example:
- * ```kotlin
- * protocPlugin(rpc.protoc.plugins.myPlugin)
- * ```
+ * Container of protoc plugins to be applied to the source set.
*/
- public fun protocPlugin(plugin: NamedDomainObjectProvider)
+ public val plugins: NamedDomainObjectContainer
/**
- * Adds a new protoc plugin.
- *
- * Example:
- * ```kotlin
- * protocPlugin(rpc.protoc.plugins.myPlugin.get())
- * ```
+ * Configures the protoc plugins.
*/
- public fun protocPlugin(plugin: ProtocPlugin)
+ public fun plugins(action: Action>)
/**
* Default [SourceDirectorySet] for proto files.
diff --git a/gradle-plugin/src/main/kotlin/kotlinx/rpc/protoc/ProtocExtension.kt b/gradle-plugin/src/main/kotlin/kotlinx/rpc/protoc/ProtocExtension.kt
index ff8e843f..b1ed62e3 100644
--- a/gradle-plugin/src/main/kotlin/kotlinx/rpc/protoc/ProtocExtension.kt
+++ b/gradle-plugin/src/main/kotlin/kotlinx/rpc/protoc/ProtocExtension.kt
@@ -6,12 +6,11 @@ package kotlinx.rpc.protoc
import kotlinx.rpc.buf.BufExtension
import org.gradle.api.Action
-import org.gradle.api.NamedDomainObjectContainer
/**
- * Configuration for the gRPC capabilities.
+ * Configuration for the Protoc capabilities.
*
- * To enable the gRPC capabilities, add the following minimal code to your `build.gradle.kts`:
+ * To enable the Protoc capabilities, add the following minimal code to your `build.gradle.kts`:
* ```kotlin
* rpc {
* protoc()
@@ -19,16 +18,6 @@ import org.gradle.api.NamedDomainObjectContainer
* ```
*/
public interface ProtocExtension {
- /**
- * List of protoc plugins to be applied to the project.
- */
- public val plugins: NamedDomainObjectContainer
-
- /**
- * Configures the protoc plugins.
- */
- public fun plugins(action: Action>)
-
/**
* Configuration for the Buf build tool.
*/
diff --git a/gradle-plugin/src/main/kotlin/kotlinx/rpc/protoc/pluginJars.kt b/gradle-plugin/src/main/kotlin/kotlinx/rpc/protoc/pluginJars.kt
index f12033e8..b325146f 100644
--- a/gradle-plugin/src/main/kotlin/kotlinx/rpc/protoc/pluginJars.kt
+++ b/gradle-plugin/src/main/kotlin/kotlinx/rpc/protoc/pluginJars.kt
@@ -52,9 +52,9 @@ internal fun Project.configureGrpcKotlinMultiplatformPluginJarConfiguration() {
)
}
-private fun Project.jarPathAccessor(name: String): Provider =
- project.configurations.named(name)
- .map { it.singleFile.absolutePath }
+private fun Project.jarPathAccessor(name: String): Provider = project.provider {
+ configurations.named(name).get().singleFile.absolutePath
+}
private fun Project.configureJarConfiguration(configurationName: String, pluginArtifactName: String) {
configurations.create(configurationName)
diff --git a/gradle-plugin/src/test/kotlin/kotlinx/rpc/GrpcJvmProjectTest.kt b/gradle-plugin/src/test/kotlin/kotlinx/rpc/GrpcJvmProjectTest.kt
index 66d55d10..4103cfda 100644
--- a/gradle-plugin/src/test/kotlin/kotlinx/rpc/GrpcJvmProjectTest.kt
+++ b/gradle-plugin/src/test/kotlin/kotlinx/rpc/GrpcJvmProjectTest.kt
@@ -135,16 +135,16 @@ class GrpcJvmProjectTest : GrpcBaseTest() {
version: v2
clean: true
plugins:
- - local: [protoc-gen-kotlin-multiplatform]
- out: kotlin-multiplatform
- opt:
- - debugOutput=protoc-gen-kotlin-multiplatform.log
- - explicitApiModeEnabled=true
- local: [protoc-gen-grpc-kotlin-multiplatform]
out: grpc-kotlin-multiplatform
opt:
- debugOutput=protoc-gen-grpc-kotlin-multiplatform.log
- explicitApiModeEnabled=true
+ - local: [protoc-gen-kotlin-multiplatform]
+ out: kotlin-multiplatform
+ opt:
+ - debugOutput=protoc-gen-kotlin-multiplatform.log
+ - explicitApiModeEnabled=true
- local: [path, to, protoc-gen-myplugin.exe]
out: myPlugin
opt:
diff --git a/gradle-plugin/src/test/resources/projects/GrpcJvmProjectTest/can_add_custom_protoc_plugins/build.gradle.kts b/gradle-plugin/src/test/resources/projects/GrpcJvmProjectTest/can_add_custom_protoc_plugins/build.gradle.kts
index 437f5e14..e6e1a3ea 100644
--- a/gradle-plugin/src/test/resources/projects/GrpcJvmProjectTest/can_add_custom_protoc_plugins/build.gradle.kts
+++ b/gradle-plugin/src/test/resources/projects/GrpcJvmProjectTest/can_add_custom_protoc_plugins/build.gradle.kts
@@ -11,7 +11,11 @@ plugins {
}
rpc {
- protoc {
+ protoc()
+}
+
+protoSourceSets {
+ main {
plugins {
create("myPlugin") {
local {
@@ -35,10 +39,3 @@ rpc {
}
}
}
-
-protoSourceSets {
- main {
- protocPlugin(rpc.protoc.plugins.named("myPlugin"))
- protocPlugin(rpc.protoc.plugins.named("myRemotePlugin"))
- }
-}
diff --git a/gradle-plugin/src/test/resources/projects/GrpcJvmProjectTest/custom_protoc_plugins_must_declare_an_artifact/build.gradle.kts b/gradle-plugin/src/test/resources/projects/GrpcJvmProjectTest/custom_protoc_plugins_must_declare_an_artifact/build.gradle.kts
index beec798d..44c4b559 100644
--- a/gradle-plugin/src/test/resources/projects/GrpcJvmProjectTest/custom_protoc_plugins_must_declare_an_artifact/build.gradle.kts
+++ b/gradle-plugin/src/test/resources/projects/GrpcJvmProjectTest/custom_protoc_plugins_must_declare_an_artifact/build.gradle.kts
@@ -11,15 +11,13 @@ plugins {
}
rpc {
- protoc {
- plugins {
- create("myPlugin") {}
- }
- }
+ protoc()
}
protoSourceSets {
main {
- protocPlugin(rpc.protoc.plugins.named("myPlugin"))
+ plugins {
+ create("myPlugin") {}
+ }
}
}
diff --git a/protobuf/protobuf-core/build.gradle.kts b/protobuf/protobuf-core/build.gradle.kts
index a8cf0175..abb946b0 100644
--- a/protobuf/protobuf-core/build.gradle.kts
+++ b/protobuf/protobuf-core/build.gradle.kts
@@ -4,6 +4,8 @@
@file:OptIn(InternalRpcApi::class)
+import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
+import kotlinx.rpc.buf.tasks.BufGenerateTask
import kotlinx.rpc.internal.InternalRpcApi
import kotlinx.rpc.internal.configureLocalProtocGenDevelopmentDependency
import util.configureCLibCInterop
@@ -14,19 +16,23 @@ plugins {
}
kotlin {
+ compilerOptions {
+ apiVersion = KotlinVersion.KOTLIN_2_1
+ }
+
sourceSets {
commonMain {
dependencies {
api(projects.utils)
api(projects.protobuf.protobufInputStream)
+ api(projects.grpc.grpcCodec)
+
api(libs.kotlinx.io.core)
}
}
commonTest {
dependencies {
- implementation(projects.grpc.grpcCodec)
-
implementation(libs.kotlin.test)
implementation(libs.coroutines.test)
}
@@ -66,4 +72,17 @@ protoSourceSets {
}
}
-configureLocalProtocGenDevelopmentDependency()
+configureLocalProtocGenDevelopmentDependency("Main", "Test")
+
+val generatedCodeDir = layout.projectDirectory
+ .dir("src")
+ .dir("commonMain")
+ .dir("generated-code")
+ .asFile
+
+tasks.withType().configureEach {
+ if (name.contains("Main")) {
+ includeWkt = true
+ outputDirectory = generatedCodeDir
+ }
+}
diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/Any.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/Any.kt
new file mode 100644
index 00000000..a34ae132
--- /dev/null
+++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/Any.kt
@@ -0,0 +1,13 @@
+@file:OptIn(ExperimentalRpcApi::class, InternalRpcApi::class)
+package com.google.protobuf.kotlin
+
+import kotlinx.rpc.internal.utils.*
+
+@kotlinx.rpc.grpc.codec.WithCodec(com.google.protobuf.kotlin.AnyInternal.CODEC::class)
+public interface Any {
+ public val typeUrl: String
+ public val value: ByteArray
+
+ public companion object
+}
+
diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/Api.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/Api.kt
new file mode 100644
index 00000000..12466025
--- /dev/null
+++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/Api.kt
@@ -0,0 +1,39 @@
+@file:OptIn(ExperimentalRpcApi::class, InternalRpcApi::class)
+package com.google.protobuf.kotlin
+
+import kotlinx.rpc.internal.utils.*
+
+@kotlinx.rpc.grpc.codec.WithCodec(com.google.protobuf.kotlin.ApiInternal.CODEC::class)
+public interface Api {
+ public val name: String
+ public val methods: List
+ public val options: List
+ public val version: String
+ public val sourceContext: com.google.protobuf.kotlin.SourceContext
+ public val mixins: List
+ public val syntax: com.google.protobuf.kotlin.Syntax
+
+ public companion object
+}
+
+@kotlinx.rpc.grpc.codec.WithCodec(com.google.protobuf.kotlin.MethodInternal.CODEC::class)
+public interface Method {
+ public val name: String
+ public val requestTypeUrl: String
+ public val requestStreaming: Boolean
+ public val responseTypeUrl: String
+ public val responseStreaming: Boolean
+ public val options: List
+ public val syntax: com.google.protobuf.kotlin.Syntax
+
+ public companion object
+}
+
+@kotlinx.rpc.grpc.codec.WithCodec(com.google.protobuf.kotlin.MixinInternal.CODEC::class)
+public interface Mixin {
+ public val name: String
+ public val root: String
+
+ public companion object
+}
+
diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/Duration.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/Duration.kt
new file mode 100644
index 00000000..f0fa480c
--- /dev/null
+++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/Duration.kt
@@ -0,0 +1,13 @@
+@file:OptIn(ExperimentalRpcApi::class, InternalRpcApi::class)
+package com.google.protobuf.kotlin
+
+import kotlinx.rpc.internal.utils.*
+
+@kotlinx.rpc.grpc.codec.WithCodec(com.google.protobuf.kotlin.DurationInternal.CODEC::class)
+public interface Duration {
+ public val seconds: Long
+ public val nanos: Int
+
+ public companion object
+}
+
diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/Empty.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/Empty.kt
new file mode 100644
index 00000000..0f618e7f
--- /dev/null
+++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/Empty.kt
@@ -0,0 +1,10 @@
+@file:OptIn(ExperimentalRpcApi::class, InternalRpcApi::class)
+package com.google.protobuf.kotlin
+
+import kotlinx.rpc.internal.utils.*
+
+@kotlinx.rpc.grpc.codec.WithCodec(com.google.protobuf.kotlin.EmptyInternal.CODEC::class)
+public interface Empty {
+ public companion object
+}
+
diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/FieldMask.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/FieldMask.kt
new file mode 100644
index 00000000..ea41057f
--- /dev/null
+++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/FieldMask.kt
@@ -0,0 +1,12 @@
+@file:OptIn(ExperimentalRpcApi::class, InternalRpcApi::class)
+package com.google.protobuf.kotlin
+
+import kotlinx.rpc.internal.utils.*
+
+@kotlinx.rpc.grpc.codec.WithCodec(com.google.protobuf.kotlin.FieldMaskInternal.CODEC::class)
+public interface FieldMask {
+ public val paths: List
+
+ public companion object
+}
+
diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/SourceContext.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/SourceContext.kt
new file mode 100644
index 00000000..ebc8e81a
--- /dev/null
+++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/SourceContext.kt
@@ -0,0 +1,12 @@
+@file:OptIn(ExperimentalRpcApi::class, InternalRpcApi::class)
+package com.google.protobuf.kotlin
+
+import kotlinx.rpc.internal.utils.*
+
+@kotlinx.rpc.grpc.codec.WithCodec(com.google.protobuf.kotlin.SourceContextInternal.CODEC::class)
+public interface SourceContext {
+ public val fileName: String
+
+ public companion object
+}
+
diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/Struct.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/Struct.kt
new file mode 100644
index 00000000..1469b0ec
--- /dev/null
+++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/Struct.kt
@@ -0,0 +1,63 @@
+@file:OptIn(ExperimentalRpcApi::class, InternalRpcApi::class)
+package com.google.protobuf.kotlin
+
+import kotlin.jvm.JvmInline
+import kotlinx.rpc.internal.utils.*
+
+@kotlinx.rpc.grpc.codec.WithCodec(com.google.protobuf.kotlin.StructInternal.CODEC::class)
+public interface Struct {
+ public val fields: Map
+
+ public companion object
+}
+
+@kotlinx.rpc.grpc.codec.WithCodec(com.google.protobuf.kotlin.ValueInternal.CODEC::class)
+public interface Value {
+ public val kind: com.google.protobuf.kotlin.Value.Kind?
+
+ public sealed interface Kind {
+ @JvmInline
+ public value class NullValue(
+ public val value: com.google.protobuf.kotlin.NullValue,
+ ): Kind
+
+ @JvmInline
+ public value class NumberValue(public val value: Double): Kind
+
+ @JvmInline
+ public value class StringValue(public val value: String): Kind
+
+ @JvmInline
+ public value class BoolValue(public val value: Boolean): Kind
+
+ @JvmInline
+ public value class StructValue(
+ public val value: com.google.protobuf.kotlin.Struct,
+ ): Kind
+
+ @JvmInline
+ public value class ListValue(
+ public val value: com.google.protobuf.kotlin.ListValue,
+ ): Kind
+ }
+
+ public companion object
+}
+
+@kotlinx.rpc.grpc.codec.WithCodec(com.google.protobuf.kotlin.ListValueInternal.CODEC::class)
+public interface ListValue {
+ public val values: List
+
+ public companion object
+}
+
+public sealed class NullValue(public open val number: Int) {
+ public object NULL_VALUE: NullValue(number = 0)
+
+ public data class UNRECOGNIZED(override val number: Int): NullValue(number)
+
+ public companion object {
+ public val entries: List by lazy { listOf(NULL_VALUE) }
+ }
+}
+
diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/Timestamp.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/Timestamp.kt
new file mode 100644
index 00000000..f05bbf2b
--- /dev/null
+++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/Timestamp.kt
@@ -0,0 +1,13 @@
+@file:OptIn(ExperimentalRpcApi::class, InternalRpcApi::class)
+package com.google.protobuf.kotlin
+
+import kotlinx.rpc.internal.utils.*
+
+@kotlinx.rpc.grpc.codec.WithCodec(com.google.protobuf.kotlin.TimestampInternal.CODEC::class)
+public interface Timestamp {
+ public val seconds: Long
+ public val nanos: Int
+
+ public companion object
+}
+
diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/Type.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/Type.kt
new file mode 100644
index 00000000..a58b713f
--- /dev/null
+++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/Type.kt
@@ -0,0 +1,139 @@
+@file:OptIn(ExperimentalRpcApi::class, InternalRpcApi::class)
+package com.google.protobuf.kotlin
+
+import kotlinx.rpc.internal.utils.*
+
+@kotlinx.rpc.grpc.codec.WithCodec(com.google.protobuf.kotlin.TypeInternal.CODEC::class)
+public interface Type {
+ public val name: String
+ public val fields: List
+ public val oneofs: List
+ public val options: List
+ public val sourceContext: com.google.protobuf.kotlin.SourceContext
+ public val syntax: com.google.protobuf.kotlin.Syntax
+ public val edition: String
+
+ public companion object
+}
+
+@kotlinx.rpc.grpc.codec.WithCodec(com.google.protobuf.kotlin.FieldInternal.CODEC::class)
+public interface Field {
+ public val kind: com.google.protobuf.kotlin.Field.Kind
+ public val cardinality: com.google.protobuf.kotlin.Field.Cardinality
+ public val number: Int
+ public val name: String
+ public val typeUrl: String
+ public val oneofIndex: Int
+ public val packed: Boolean
+ public val options: List
+ public val jsonName: String
+ public val defaultValue: String
+
+ public sealed class Kind(public open val number: Int) {
+ public object TYPE_UNKNOWN: Kind(number = 0)
+
+ public object TYPE_DOUBLE: Kind(number = 1)
+
+ public object TYPE_FLOAT: Kind(number = 2)
+
+ public object TYPE_INT64: Kind(number = 3)
+
+ public object TYPE_UINT64: Kind(number = 4)
+
+ public object TYPE_INT32: Kind(number = 5)
+
+ public object TYPE_FIXED64: Kind(number = 6)
+
+ public object TYPE_FIXED32: Kind(number = 7)
+
+ public object TYPE_BOOL: Kind(number = 8)
+
+ public object TYPE_STRING: Kind(number = 9)
+
+ public object TYPE_GROUP: Kind(number = 10)
+
+ public object TYPE_MESSAGE: Kind(number = 11)
+
+ public object TYPE_BYTES: Kind(number = 12)
+
+ public object TYPE_UINT32: Kind(number = 13)
+
+ public object TYPE_ENUM: Kind(number = 14)
+
+ public object TYPE_SFIXED32: Kind(number = 15)
+
+ public object TYPE_SFIXED64: Kind(number = 16)
+
+ public object TYPE_SINT32: Kind(number = 17)
+
+ public object TYPE_SINT64: Kind(number = 18)
+
+ public data class UNRECOGNIZED(override val number: Int): Kind(number)
+
+ public companion object {
+ public val entries: List by lazy { listOf(TYPE_UNKNOWN, TYPE_DOUBLE, TYPE_FLOAT, TYPE_INT64, TYPE_UINT64, TYPE_INT32, TYPE_FIXED64, TYPE_FIXED32, TYPE_BOOL, TYPE_STRING, TYPE_GROUP, TYPE_MESSAGE, TYPE_BYTES, TYPE_UINT32, TYPE_ENUM, TYPE_SFIXED32, TYPE_SFIXED64, TYPE_SINT32, TYPE_SINT64) }
+ }
+ }
+
+ public sealed class Cardinality(public open val number: Int) {
+ public object CARDINALITY_UNKNOWN: Cardinality(number = 0)
+
+ public object CARDINALITY_OPTIONAL: Cardinality(number = 1)
+
+ public object CARDINALITY_REQUIRED: Cardinality(number = 2)
+
+ public object CARDINALITY_REPEATED: Cardinality(number = 3)
+
+ public data class UNRECOGNIZED(override val number: Int): Cardinality(number)
+
+ public companion object {
+ public val entries: List by lazy { listOf(CARDINALITY_UNKNOWN, CARDINALITY_OPTIONAL, CARDINALITY_REQUIRED, CARDINALITY_REPEATED) }
+ }
+ }
+
+ public companion object
+}
+
+@kotlinx.rpc.grpc.codec.WithCodec(com.google.protobuf.kotlin.EnumInternal.CODEC::class)
+public interface Enum {
+ public val name: String
+ public val enumvalue: List
+ public val options: List
+ public val sourceContext: com.google.protobuf.kotlin.SourceContext
+ public val syntax: com.google.protobuf.kotlin.Syntax
+ public val edition: String
+
+ public companion object
+}
+
+@kotlinx.rpc.grpc.codec.WithCodec(com.google.protobuf.kotlin.EnumValueInternal.CODEC::class)
+public interface EnumValue {
+ public val name: String
+ public val number: Int
+ public val options: List
+
+ public companion object
+}
+
+@kotlinx.rpc.grpc.codec.WithCodec(com.google.protobuf.kotlin.OptionInternal.CODEC::class)
+public interface Option {
+ public val name: String
+ public val value: com.google.protobuf.kotlin.Any
+
+ public companion object
+}
+
+public sealed class Syntax(public open val number: Int) {
+ public object SYNTAX_PROTO2: Syntax(number = 0)
+
+ public object SYNTAX_PROTO3: Syntax(number = 1)
+
+ public object SYNTAX_EDITIONS: Syntax(number = 2)
+
+ public data class UNRECOGNIZED(override val number: Int): Syntax(number)
+
+ public companion object {
+ public val entries: List by lazy { listOf(SYNTAX_PROTO2, SYNTAX_PROTO3, SYNTAX_EDITIONS) }
+ }
+}
+
diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/Wrappers.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/Wrappers.kt
new file mode 100644
index 00000000..b5b8dab7
--- /dev/null
+++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/Wrappers.kt
@@ -0,0 +1,68 @@
+@file:OptIn(ExperimentalRpcApi::class, InternalRpcApi::class)
+package com.google.protobuf.kotlin
+
+import kotlinx.rpc.internal.utils.*
+
+@kotlinx.rpc.grpc.codec.WithCodec(com.google.protobuf.kotlin.DoubleValueInternal.CODEC::class)
+public interface DoubleValue {
+ public val value: Double
+
+ public companion object
+}
+
+@kotlinx.rpc.grpc.codec.WithCodec(com.google.protobuf.kotlin.FloatValueInternal.CODEC::class)
+public interface FloatValue {
+ public val value: Float
+
+ public companion object
+}
+
+@kotlinx.rpc.grpc.codec.WithCodec(com.google.protobuf.kotlin.Int64ValueInternal.CODEC::class)
+public interface Int64Value {
+ public val value: Long
+
+ public companion object
+}
+
+@kotlinx.rpc.grpc.codec.WithCodec(com.google.protobuf.kotlin.UInt64ValueInternal.CODEC::class)
+public interface UInt64Value {
+ public val value: ULong
+
+ public companion object
+}
+
+@kotlinx.rpc.grpc.codec.WithCodec(com.google.protobuf.kotlin.Int32ValueInternal.CODEC::class)
+public interface Int32Value {
+ public val value: Int
+
+ public companion object
+}
+
+@kotlinx.rpc.grpc.codec.WithCodec(com.google.protobuf.kotlin.UInt32ValueInternal.CODEC::class)
+public interface UInt32Value {
+ public val value: UInt
+
+ public companion object
+}
+
+@kotlinx.rpc.grpc.codec.WithCodec(com.google.protobuf.kotlin.BoolValueInternal.CODEC::class)
+public interface BoolValue {
+ public val value: Boolean
+
+ public companion object
+}
+
+@kotlinx.rpc.grpc.codec.WithCodec(com.google.protobuf.kotlin.StringValueInternal.CODEC::class)
+public interface StringValue {
+ public val value: String
+
+ public companion object
+}
+
+@kotlinx.rpc.grpc.codec.WithCodec(com.google.protobuf.kotlin.BytesValueInternal.CODEC::class)
+public interface BytesValue {
+ public val value: ByteArray
+
+ public companion object
+}
+
diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Any.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Any.kt
new file mode 100644
index 00000000..5c77b498
--- /dev/null
+++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Any.kt
@@ -0,0 +1,103 @@
+@file:OptIn(ExperimentalRpcApi::class, kotlinx.rpc.internal.utils.InternalRpcApi::class)
+package com.google.protobuf.kotlin
+
+import kotlinx.rpc.internal.utils.*
+import kotlinx.rpc.protobuf.input.stream.asInputStream
+import kotlinx.rpc.protobuf.internal.*
+
+public class AnyInternal: com.google.protobuf.kotlin.Any, kotlinx.rpc.protobuf.internal.InternalMessage(fieldsWithPresence = 0) {
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public override val _size: Int by lazy { computeSize() }
+
+ public override var typeUrl: String by MsgFieldDelegate { "" }
+ public override var value: ByteArray by MsgFieldDelegate { byteArrayOf() }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec {
+ public override fun encode(value: com.google.protobuf.kotlin.Any): kotlinx.rpc.protobuf.input.stream.InputStream {
+ val buffer = kotlinx.io.Buffer()
+ val encoder = kotlinx.rpc.protobuf.internal.WireEncoder(buffer)
+ kotlinx.rpc.protobuf.internal.checkForPlatformEncodeException {
+ value.asInternal().encodeWith(encoder)
+ }
+ encoder.flush()
+ return buffer.asInputStream()
+ }
+
+ public override fun decode(stream: kotlinx.rpc.protobuf.input.stream.InputStream): com.google.protobuf.kotlin.Any {
+ kotlinx.rpc.protobuf.internal.WireDecoder(stream).use {
+ val msg = com.google.protobuf.kotlin.AnyInternal()
+ kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException {
+ com.google.protobuf.kotlin.AnyInternal.decodeWith(msg, it)
+ }
+ msg.checkRequiredFields()
+ return msg
+ }
+ }
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public companion object
+}
+
+public operator fun com.google.protobuf.kotlin.Any.Companion.invoke(body: com.google.protobuf.kotlin.AnyInternal.() -> Unit): com.google.protobuf.kotlin.Any {
+ val msg = com.google.protobuf.kotlin.AnyInternal().apply(body)
+ msg.checkRequiredFields()
+ return msg
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.AnyInternal.checkRequiredFields() {
+ // no required fields to check
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.AnyInternal.encodeWith(encoder: kotlinx.rpc.protobuf.internal.WireEncoder) {
+ if (typeUrl.isNotEmpty()) {
+ encoder.writeString(fieldNr = 1, value = typeUrl)
+ }
+
+ if (value.isNotEmpty()) {
+ encoder.writeBytes(fieldNr = 2, value = value)
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.AnyInternal.Companion.decodeWith(msg: com.google.protobuf.kotlin.AnyInternal, decoder: kotlinx.rpc.protobuf.internal.WireDecoder) {
+ while (true) {
+ val tag = decoder.readTag() ?: break // EOF, we read the whole message
+ when {
+ tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ msg.typeUrl = decoder.readString()
+ }
+
+ tag.fieldNr == 2 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ msg.value = decoder.readBytes()
+ }
+
+ else -> {
+ // we are currently just skipping unknown fields (KRPC-191)
+ decoder.skipValue(tag.wireType)
+ }
+ }
+ }
+}
+
+private fun com.google.protobuf.kotlin.AnyInternal.computeSize(): Int {
+ var __result = 0
+ if (typeUrl.isNotEmpty()) {
+ __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 }
+ }
+
+ if (value.isNotEmpty()) {
+ __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 }
+ }
+
+ return __result
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.Any.asInternal(): com.google.protobuf.kotlin.AnyInternal {
+ return this as? com.google.protobuf.kotlin.AnyInternal ?: error("Message ${this::class.simpleName} is a non-internal message type.")
+}
+
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
new file mode 100644
index 00000000..73bd6d81
--- /dev/null
+++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Api.kt
@@ -0,0 +1,467 @@
+@file:OptIn(ExperimentalRpcApi::class, kotlinx.rpc.internal.utils.InternalRpcApi::class)
+package com.google.protobuf.kotlin
+
+import kotlinx.rpc.internal.utils.*
+import kotlinx.rpc.protobuf.input.stream.asInputStream
+import kotlinx.rpc.protobuf.internal.*
+
+public class ApiInternal: com.google.protobuf.kotlin.Api, kotlinx.rpc.protobuf.internal.InternalMessage(fieldsWithPresence = 1) {
+ private object PresenceIndices {
+ public const val sourceContext: Int = 0
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public override val _size: Int by lazy { computeSize() }
+
+ public override var name: String by MsgFieldDelegate { "" }
+ public override var methods: List by MsgFieldDelegate { mutableListOf() }
+ public override var options: List by MsgFieldDelegate { mutableListOf() }
+ public override var version: String by MsgFieldDelegate { "" }
+ public override var sourceContext: com.google.protobuf.kotlin.SourceContext by MsgFieldDelegate(PresenceIndices.sourceContext) { com.google.protobuf.kotlin.SourceContextInternal() }
+ public override var mixins: List by MsgFieldDelegate { mutableListOf() }
+ public override var syntax: com.google.protobuf.kotlin.Syntax by MsgFieldDelegate { com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2 }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec {
+ public override fun encode(value: com.google.protobuf.kotlin.Api): kotlinx.rpc.protobuf.input.stream.InputStream {
+ val buffer = kotlinx.io.Buffer()
+ val encoder = kotlinx.rpc.protobuf.internal.WireEncoder(buffer)
+ kotlinx.rpc.protobuf.internal.checkForPlatformEncodeException {
+ value.asInternal().encodeWith(encoder)
+ }
+ encoder.flush()
+ return buffer.asInputStream()
+ }
+
+ public override fun decode(stream: kotlinx.rpc.protobuf.input.stream.InputStream): com.google.protobuf.kotlin.Api {
+ kotlinx.rpc.protobuf.internal.WireDecoder(stream).use {
+ val msg = com.google.protobuf.kotlin.ApiInternal()
+ kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException {
+ com.google.protobuf.kotlin.ApiInternal.decodeWith(msg, it)
+ }
+ msg.checkRequiredFields()
+ return msg
+ }
+ }
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public companion object
+}
+
+public class MethodInternal: com.google.protobuf.kotlin.Method, kotlinx.rpc.protobuf.internal.InternalMessage(fieldsWithPresence = 0) {
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public override val _size: Int by lazy { computeSize() }
+
+ public override var name: String by MsgFieldDelegate { "" }
+ public override var requestTypeUrl: String by MsgFieldDelegate { "" }
+ public override var requestStreaming: Boolean by MsgFieldDelegate { false }
+ public override var responseTypeUrl: String by MsgFieldDelegate { "" }
+ public override var responseStreaming: Boolean by MsgFieldDelegate { false }
+ public override var options: List by MsgFieldDelegate { mutableListOf() }
+ public override var syntax: com.google.protobuf.kotlin.Syntax by MsgFieldDelegate { com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2 }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec {
+ public override fun encode(value: com.google.protobuf.kotlin.Method): kotlinx.rpc.protobuf.input.stream.InputStream {
+ val buffer = kotlinx.io.Buffer()
+ val encoder = kotlinx.rpc.protobuf.internal.WireEncoder(buffer)
+ kotlinx.rpc.protobuf.internal.checkForPlatformEncodeException {
+ value.asInternal().encodeWith(encoder)
+ }
+ encoder.flush()
+ return buffer.asInputStream()
+ }
+
+ public override fun decode(stream: kotlinx.rpc.protobuf.input.stream.InputStream): com.google.protobuf.kotlin.Method {
+ kotlinx.rpc.protobuf.internal.WireDecoder(stream).use {
+ val msg = com.google.protobuf.kotlin.MethodInternal()
+ kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException {
+ com.google.protobuf.kotlin.MethodInternal.decodeWith(msg, it)
+ }
+ msg.checkRequiredFields()
+ return msg
+ }
+ }
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public companion object
+}
+
+public class MixinInternal: com.google.protobuf.kotlin.Mixin, kotlinx.rpc.protobuf.internal.InternalMessage(fieldsWithPresence = 0) {
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public override val _size: Int by lazy { computeSize() }
+
+ public override var name: String by MsgFieldDelegate { "" }
+ public override var root: String by MsgFieldDelegate { "" }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec {
+ public override fun encode(value: com.google.protobuf.kotlin.Mixin): kotlinx.rpc.protobuf.input.stream.InputStream {
+ val buffer = kotlinx.io.Buffer()
+ val encoder = kotlinx.rpc.protobuf.internal.WireEncoder(buffer)
+ kotlinx.rpc.protobuf.internal.checkForPlatformEncodeException {
+ value.asInternal().encodeWith(encoder)
+ }
+ encoder.flush()
+ return buffer.asInputStream()
+ }
+
+ public override fun decode(stream: kotlinx.rpc.protobuf.input.stream.InputStream): com.google.protobuf.kotlin.Mixin {
+ kotlinx.rpc.protobuf.internal.WireDecoder(stream).use {
+ val msg = com.google.protobuf.kotlin.MixinInternal()
+ kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException {
+ com.google.protobuf.kotlin.MixinInternal.decodeWith(msg, it)
+ }
+ msg.checkRequiredFields()
+ return msg
+ }
+ }
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public companion object
+}
+
+public operator fun com.google.protobuf.kotlin.Api.Companion.invoke(body: com.google.protobuf.kotlin.ApiInternal.() -> Unit): com.google.protobuf.kotlin.Api {
+ val msg = com.google.protobuf.kotlin.ApiInternal().apply(body)
+ msg.checkRequiredFields()
+ return msg
+}
+
+public operator fun com.google.protobuf.kotlin.Method.Companion.invoke(body: com.google.protobuf.kotlin.MethodInternal.() -> Unit): com.google.protobuf.kotlin.Method {
+ val msg = com.google.protobuf.kotlin.MethodInternal().apply(body)
+ msg.checkRequiredFields()
+ return msg
+}
+
+public operator fun com.google.protobuf.kotlin.Mixin.Companion.invoke(body: com.google.protobuf.kotlin.MixinInternal.() -> Unit): com.google.protobuf.kotlin.Mixin {
+ val msg = com.google.protobuf.kotlin.MixinInternal().apply(body)
+ msg.checkRequiredFields()
+ return msg
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.ApiInternal.checkRequiredFields() {
+ // no required fields to check
+ if (presenceMask[0]) {
+ sourceContext.asInternal().checkRequiredFields()
+ }
+
+ methods.forEach {
+ it.asInternal().checkRequiredFields()
+ }
+
+ options.forEach {
+ it.asInternal().checkRequiredFields()
+ }
+
+ mixins.forEach {
+ it.asInternal().checkRequiredFields()
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.ApiInternal.encodeWith(encoder: kotlinx.rpc.protobuf.internal.WireEncoder) {
+ if (name.isNotEmpty()) {
+ encoder.writeString(fieldNr = 1, value = name)
+ }
+
+ if (methods.isNotEmpty()) {
+ methods.forEach {
+ encoder.writeMessage(fieldNr = 2, value = it.asInternal()) { encodeWith(it) }
+ }
+ }
+
+ if (options.isNotEmpty()) {
+ options.forEach {
+ encoder.writeMessage(fieldNr = 3, value = it.asInternal()) { encodeWith(it) }
+ }
+ }
+
+ if (version.isNotEmpty()) {
+ encoder.writeString(fieldNr = 4, value = version)
+ }
+
+ if (presenceMask[0]) {
+ encoder.writeMessage(fieldNr = 5, value = sourceContext.asInternal()) { encodeWith(it) }
+ }
+
+ if (mixins.isNotEmpty()) {
+ mixins.forEach {
+ encoder.writeMessage(fieldNr = 6, value = it.asInternal()) { encodeWith(it) }
+ }
+ }
+
+ if (com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2 != syntax) {
+ encoder.writeEnum(fieldNr = 7, value = syntax.number)
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.ApiInternal.Companion.decodeWith(msg: com.google.protobuf.kotlin.ApiInternal, decoder: kotlinx.rpc.protobuf.internal.WireDecoder) {
+ while (true) {
+ val tag = decoder.readTag() ?: break // EOF, we read the whole message
+ when {
+ tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ msg.name = decoder.readString()
+ }
+
+ tag.fieldNr == 2 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ val elem = com.google.protobuf.kotlin.MethodInternal()
+ decoder.readMessage(elem.asInternal(), com.google.protobuf.kotlin.MethodInternal::decodeWith)
+ (msg.methods as MutableList).add(elem)
+ }
+
+ tag.fieldNr == 3 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ val elem = com.google.protobuf.kotlin.OptionInternal()
+ decoder.readMessage(elem.asInternal(), com.google.protobuf.kotlin.OptionInternal::decodeWith)
+ (msg.options as MutableList).add(elem)
+ }
+
+ tag.fieldNr == 4 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ msg.version = decoder.readString()
+ }
+
+ tag.fieldNr == 5 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ if (!msg.presenceMask[0]) {
+ msg.sourceContext = com.google.protobuf.kotlin.SourceContextInternal()
+ }
+
+ decoder.readMessage(msg.sourceContext.asInternal(), com.google.protobuf.kotlin.SourceContextInternal::decodeWith)
+ }
+
+ tag.fieldNr == 6 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ val elem = com.google.protobuf.kotlin.MixinInternal()
+ decoder.readMessage(elem.asInternal(), com.google.protobuf.kotlin.MixinInternal::decodeWith)
+ (msg.mixins as MutableList).add(elem)
+ }
+
+ tag.fieldNr == 7 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> {
+ msg.syntax = com.google.protobuf.kotlin.Syntax.fromNumber(decoder.readEnum())
+ }
+
+ else -> {
+ // we are currently just skipping unknown fields (KRPC-191)
+ decoder.skipValue(tag.wireType)
+ }
+ }
+ }
+}
+
+private fun com.google.protobuf.kotlin.ApiInternal.computeSize(): Int {
+ var __result = 0
+ if (name.isNotEmpty()) {
+ __result += kotlinx.rpc.protobuf.internal.WireSize.string(name).let { kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it }
+ }
+
+ if (methods.isNotEmpty()) {
+ __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) }
+ }
+
+ if (version.isNotEmpty()) {
+ __result += kotlinx.rpc.protobuf.internal.WireSize.string(version).let { kotlinx.rpc.protobuf.internal.WireSize.tag(4, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it }
+ }
+
+ 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 (mixins.isNotEmpty()) {
+ __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) {
+ __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(7, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(syntax.number))
+ }
+
+ return __result
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.Api.asInternal(): com.google.protobuf.kotlin.ApiInternal {
+ return this as? com.google.protobuf.kotlin.ApiInternal ?: error("Message ${this::class.simpleName} is a non-internal message type.")
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.MethodInternal.checkRequiredFields() {
+ // no required fields to check
+ options.forEach {
+ it.asInternal().checkRequiredFields()
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.MethodInternal.encodeWith(encoder: kotlinx.rpc.protobuf.internal.WireEncoder) {
+ if (name.isNotEmpty()) {
+ encoder.writeString(fieldNr = 1, value = name)
+ }
+
+ if (requestTypeUrl.isNotEmpty()) {
+ encoder.writeString(fieldNr = 2, value = requestTypeUrl)
+ }
+
+ if (requestStreaming != false) {
+ encoder.writeBool(fieldNr = 3, value = requestStreaming)
+ }
+
+ if (responseTypeUrl.isNotEmpty()) {
+ encoder.writeString(fieldNr = 4, value = responseTypeUrl)
+ }
+
+ if (responseStreaming != false) {
+ encoder.writeBool(fieldNr = 5, value = responseStreaming)
+ }
+
+ if (options.isNotEmpty()) {
+ options.forEach {
+ encoder.writeMessage(fieldNr = 6, value = it.asInternal()) { encodeWith(it) }
+ }
+ }
+
+ if (com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2 != syntax) {
+ encoder.writeEnum(fieldNr = 7, value = syntax.number)
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.MethodInternal.Companion.decodeWith(msg: com.google.protobuf.kotlin.MethodInternal, decoder: kotlinx.rpc.protobuf.internal.WireDecoder) {
+ while (true) {
+ val tag = decoder.readTag() ?: break // EOF, we read the whole message
+ when {
+ tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ msg.name = decoder.readString()
+ }
+
+ tag.fieldNr == 2 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ msg.requestTypeUrl = decoder.readString()
+ }
+
+ tag.fieldNr == 3 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> {
+ msg.requestStreaming = decoder.readBool()
+ }
+
+ tag.fieldNr == 4 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ msg.responseTypeUrl = decoder.readString()
+ }
+
+ tag.fieldNr == 5 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> {
+ msg.responseStreaming = decoder.readBool()
+ }
+
+ tag.fieldNr == 6 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ val elem = com.google.protobuf.kotlin.OptionInternal()
+ decoder.readMessage(elem.asInternal(), com.google.protobuf.kotlin.OptionInternal::decodeWith)
+ (msg.options as MutableList).add(elem)
+ }
+
+ tag.fieldNr == 7 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> {
+ msg.syntax = com.google.protobuf.kotlin.Syntax.fromNumber(decoder.readEnum())
+ }
+
+ else -> {
+ // we are currently just skipping unknown fields (KRPC-191)
+ decoder.skipValue(tag.wireType)
+ }
+ }
+ }
+}
+
+private fun com.google.protobuf.kotlin.MethodInternal.computeSize(): Int {
+ var __result = 0
+ if (name.isNotEmpty()) {
+ __result += kotlinx.rpc.protobuf.internal.WireSize.string(name).let { kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it }
+ }
+
+ if (requestTypeUrl.isNotEmpty()) {
+ __result += kotlinx.rpc.protobuf.internal.WireSize.string(requestTypeUrl).let { kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it }
+ }
+
+ if (requestStreaming != false) {
+ __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(3, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.bool(requestStreaming))
+ }
+
+ if (responseTypeUrl.isNotEmpty()) {
+ __result += kotlinx.rpc.protobuf.internal.WireSize.string(responseTypeUrl).let { kotlinx.rpc.protobuf.internal.WireSize.tag(4, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it }
+ }
+
+ if (responseStreaming != false) {
+ __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(5, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.bool(responseStreaming))
+ }
+
+ if (options.isNotEmpty()) {
+ __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) {
+ __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(7, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(syntax.number))
+ }
+
+ return __result
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.Method.asInternal(): com.google.protobuf.kotlin.MethodInternal {
+ return this as? com.google.protobuf.kotlin.MethodInternal ?: error("Message ${this::class.simpleName} is a non-internal message type.")
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.MixinInternal.checkRequiredFields() {
+ // no required fields to check
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.MixinInternal.encodeWith(encoder: kotlinx.rpc.protobuf.internal.WireEncoder) {
+ if (name.isNotEmpty()) {
+ encoder.writeString(fieldNr = 1, value = name)
+ }
+
+ if (root.isNotEmpty()) {
+ encoder.writeString(fieldNr = 2, value = root)
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.MixinInternal.Companion.decodeWith(msg: com.google.protobuf.kotlin.MixinInternal, decoder: kotlinx.rpc.protobuf.internal.WireDecoder) {
+ while (true) {
+ val tag = decoder.readTag() ?: break // EOF, we read the whole message
+ when {
+ tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ msg.name = decoder.readString()
+ }
+
+ tag.fieldNr == 2 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ msg.root = decoder.readString()
+ }
+
+ else -> {
+ // we are currently just skipping unknown fields (KRPC-191)
+ decoder.skipValue(tag.wireType)
+ }
+ }
+ }
+}
+
+private fun com.google.protobuf.kotlin.MixinInternal.computeSize(): Int {
+ var __result = 0
+ if (name.isNotEmpty()) {
+ __result += kotlinx.rpc.protobuf.internal.WireSize.string(name).let { kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it }
+ }
+
+ if (root.isNotEmpty()) {
+ __result += kotlinx.rpc.protobuf.internal.WireSize.string(root).let { kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it }
+ }
+
+ return __result
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.Mixin.asInternal(): com.google.protobuf.kotlin.MixinInternal {
+ return this as? com.google.protobuf.kotlin.MixinInternal ?: error("Message ${this::class.simpleName} is a non-internal message type.")
+}
+
diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Duration.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Duration.kt
new file mode 100644
index 00000000..0854939e
--- /dev/null
+++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Duration.kt
@@ -0,0 +1,103 @@
+@file:OptIn(ExperimentalRpcApi::class, kotlinx.rpc.internal.utils.InternalRpcApi::class)
+package com.google.protobuf.kotlin
+
+import kotlinx.rpc.internal.utils.*
+import kotlinx.rpc.protobuf.input.stream.asInputStream
+import kotlinx.rpc.protobuf.internal.*
+
+public class DurationInternal: com.google.protobuf.kotlin.Duration, kotlinx.rpc.protobuf.internal.InternalMessage(fieldsWithPresence = 0) {
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public override val _size: Int by lazy { computeSize() }
+
+ public override var seconds: Long by MsgFieldDelegate { 0L }
+ public override var nanos: Int by MsgFieldDelegate { 0 }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec {
+ public override fun encode(value: com.google.protobuf.kotlin.Duration): kotlinx.rpc.protobuf.input.stream.InputStream {
+ val buffer = kotlinx.io.Buffer()
+ val encoder = kotlinx.rpc.protobuf.internal.WireEncoder(buffer)
+ kotlinx.rpc.protobuf.internal.checkForPlatformEncodeException {
+ value.asInternal().encodeWith(encoder)
+ }
+ encoder.flush()
+ return buffer.asInputStream()
+ }
+
+ public override fun decode(stream: kotlinx.rpc.protobuf.input.stream.InputStream): com.google.protobuf.kotlin.Duration {
+ kotlinx.rpc.protobuf.internal.WireDecoder(stream).use {
+ val msg = com.google.protobuf.kotlin.DurationInternal()
+ kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException {
+ com.google.protobuf.kotlin.DurationInternal.decodeWith(msg, it)
+ }
+ msg.checkRequiredFields()
+ return msg
+ }
+ }
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public companion object
+}
+
+public operator fun com.google.protobuf.kotlin.Duration.Companion.invoke(body: com.google.protobuf.kotlin.DurationInternal.() -> Unit): com.google.protobuf.kotlin.Duration {
+ val msg = com.google.protobuf.kotlin.DurationInternal().apply(body)
+ msg.checkRequiredFields()
+ return msg
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.DurationInternal.checkRequiredFields() {
+ // no required fields to check
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.DurationInternal.encodeWith(encoder: kotlinx.rpc.protobuf.internal.WireEncoder) {
+ if (seconds != 0L) {
+ encoder.writeInt64(fieldNr = 1, value = seconds)
+ }
+
+ if (nanos != 0) {
+ encoder.writeInt32(fieldNr = 2, value = nanos)
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.DurationInternal.Companion.decodeWith(msg: com.google.protobuf.kotlin.DurationInternal, decoder: kotlinx.rpc.protobuf.internal.WireDecoder) {
+ while (true) {
+ val tag = decoder.readTag() ?: break // EOF, we read the whole message
+ when {
+ tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> {
+ msg.seconds = decoder.readInt64()
+ }
+
+ tag.fieldNr == 2 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> {
+ msg.nanos = decoder.readInt32()
+ }
+
+ else -> {
+ // we are currently just skipping unknown fields (KRPC-191)
+ decoder.skipValue(tag.wireType)
+ }
+ }
+ }
+}
+
+private fun com.google.protobuf.kotlin.DurationInternal.computeSize(): Int {
+ var __result = 0
+ if (seconds != 0L) {
+ __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.int64(seconds))
+ }
+
+ if (nanos != 0) {
+ __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.int32(nanos))
+ }
+
+ return __result
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.Duration.asInternal(): com.google.protobuf.kotlin.DurationInternal {
+ return this as? com.google.protobuf.kotlin.DurationInternal ?: error("Message ${this::class.simpleName} is a non-internal message type.")
+}
+
diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Empty.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Empty.kt
new file mode 100644
index 00000000..09a799f7
--- /dev/null
+++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Empty.kt
@@ -0,0 +1,78 @@
+@file:OptIn(ExperimentalRpcApi::class, kotlinx.rpc.internal.utils.InternalRpcApi::class)
+package com.google.protobuf.kotlin
+
+import kotlinx.rpc.internal.utils.*
+import kotlinx.rpc.protobuf.input.stream.asInputStream
+import kotlinx.rpc.protobuf.internal.*
+
+public class EmptyInternal: com.google.protobuf.kotlin.Empty, kotlinx.rpc.protobuf.internal.InternalMessage(fieldsWithPresence = 0) {
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public override val _size: Int by lazy { computeSize() }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec {
+ public override fun encode(value: com.google.protobuf.kotlin.Empty): kotlinx.rpc.protobuf.input.stream.InputStream {
+ val buffer = kotlinx.io.Buffer()
+ val encoder = kotlinx.rpc.protobuf.internal.WireEncoder(buffer)
+ kotlinx.rpc.protobuf.internal.checkForPlatformEncodeException {
+ value.asInternal().encodeWith(encoder)
+ }
+ encoder.flush()
+ return buffer.asInputStream()
+ }
+
+ public override fun decode(stream: kotlinx.rpc.protobuf.input.stream.InputStream): com.google.protobuf.kotlin.Empty {
+ kotlinx.rpc.protobuf.internal.WireDecoder(stream).use {
+ val msg = com.google.protobuf.kotlin.EmptyInternal()
+ kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException {
+ com.google.protobuf.kotlin.EmptyInternal.decodeWith(msg, it)
+ }
+ msg.checkRequiredFields()
+ return msg
+ }
+ }
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public companion object
+}
+
+public operator fun com.google.protobuf.kotlin.Empty.Companion.invoke(body: com.google.protobuf.kotlin.EmptyInternal.() -> Unit): com.google.protobuf.kotlin.Empty {
+ val msg = com.google.protobuf.kotlin.EmptyInternal().apply(body)
+ msg.checkRequiredFields()
+ return msg
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.EmptyInternal.checkRequiredFields() {
+ // no required fields to check
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.EmptyInternal.encodeWith(encoder: kotlinx.rpc.protobuf.internal.WireEncoder) {
+ // no fields to encode
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.EmptyInternal.Companion.decodeWith(msg: com.google.protobuf.kotlin.EmptyInternal, decoder: kotlinx.rpc.protobuf.internal.WireDecoder) {
+ while (true) {
+ val tag = decoder.readTag() ?: break // EOF, we read the whole message
+ when {
+ else -> {
+ // we are currently just skipping unknown fields (KRPC-191)
+ decoder.skipValue(tag.wireType)
+ }
+ }
+ }
+}
+
+private fun com.google.protobuf.kotlin.EmptyInternal.computeSize(): Int {
+ var __result = 0
+ return __result
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.Empty.asInternal(): com.google.protobuf.kotlin.EmptyInternal {
+ return this as? com.google.protobuf.kotlin.EmptyInternal ?: error("Message ${this::class.simpleName} is a non-internal message type.")
+}
+
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
new file mode 100644
index 00000000..cd95b2bc
--- /dev/null
+++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/FieldMask.kt
@@ -0,0 +1,93 @@
+@file:OptIn(ExperimentalRpcApi::class, kotlinx.rpc.internal.utils.InternalRpcApi::class)
+package com.google.protobuf.kotlin
+
+import kotlinx.rpc.internal.utils.*
+import kotlinx.rpc.protobuf.input.stream.asInputStream
+import kotlinx.rpc.protobuf.internal.*
+
+public class FieldMaskInternal: com.google.protobuf.kotlin.FieldMask, kotlinx.rpc.protobuf.internal.InternalMessage(fieldsWithPresence = 0) {
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public override val _size: Int by lazy { computeSize() }
+
+ public override var paths: List by MsgFieldDelegate { mutableListOf() }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec {
+ public override fun encode(value: com.google.protobuf.kotlin.FieldMask): kotlinx.rpc.protobuf.input.stream.InputStream {
+ val buffer = kotlinx.io.Buffer()
+ val encoder = kotlinx.rpc.protobuf.internal.WireEncoder(buffer)
+ kotlinx.rpc.protobuf.internal.checkForPlatformEncodeException {
+ value.asInternal().encodeWith(encoder)
+ }
+ encoder.flush()
+ return buffer.asInputStream()
+ }
+
+ public override fun decode(stream: kotlinx.rpc.protobuf.input.stream.InputStream): com.google.protobuf.kotlin.FieldMask {
+ kotlinx.rpc.protobuf.internal.WireDecoder(stream).use {
+ val msg = com.google.protobuf.kotlin.FieldMaskInternal()
+ kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException {
+ com.google.protobuf.kotlin.FieldMaskInternal.decodeWith(msg, it)
+ }
+ msg.checkRequiredFields()
+ return msg
+ }
+ }
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public companion object
+}
+
+public operator fun com.google.protobuf.kotlin.FieldMask.Companion.invoke(body: com.google.protobuf.kotlin.FieldMaskInternal.() -> Unit): com.google.protobuf.kotlin.FieldMask {
+ val msg = com.google.protobuf.kotlin.FieldMaskInternal().apply(body)
+ msg.checkRequiredFields()
+ return msg
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.FieldMaskInternal.checkRequiredFields() {
+ // no required fields to check
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.FieldMaskInternal.encodeWith(encoder: kotlinx.rpc.protobuf.internal.WireEncoder) {
+ if (paths.isNotEmpty()) {
+ paths.forEach {
+ encoder.writeString(1, it)
+ }
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.FieldMaskInternal.Companion.decodeWith(msg: com.google.protobuf.kotlin.FieldMaskInternal, decoder: kotlinx.rpc.protobuf.internal.WireDecoder) {
+ while (true) {
+ val tag = decoder.readTag() ?: break // EOF, we read the whole message
+ when {
+ tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ val elem = decoder.readString()
+ (msg.paths as MutableList).add(elem)
+ }
+
+ else -> {
+ // we are currently just skipping unknown fields (KRPC-191)
+ decoder.skipValue(tag.wireType)
+ }
+ }
+ }
+}
+
+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) }
+ }
+
+ return __result
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.FieldMask.asInternal(): com.google.protobuf.kotlin.FieldMaskInternal {
+ return this as? com.google.protobuf.kotlin.FieldMaskInternal ?: error("Message ${this::class.simpleName} is a non-internal message type.")
+}
+
diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/SourceContext.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/SourceContext.kt
new file mode 100644
index 00000000..f3fce414
--- /dev/null
+++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/SourceContext.kt
@@ -0,0 +1,90 @@
+@file:OptIn(ExperimentalRpcApi::class, kotlinx.rpc.internal.utils.InternalRpcApi::class)
+package com.google.protobuf.kotlin
+
+import kotlinx.rpc.internal.utils.*
+import kotlinx.rpc.protobuf.input.stream.asInputStream
+import kotlinx.rpc.protobuf.internal.*
+
+public class SourceContextInternal: com.google.protobuf.kotlin.SourceContext, kotlinx.rpc.protobuf.internal.InternalMessage(fieldsWithPresence = 0) {
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public override val _size: Int by lazy { computeSize() }
+
+ public override var fileName: String by MsgFieldDelegate { "" }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec {
+ public override fun encode(value: com.google.protobuf.kotlin.SourceContext): kotlinx.rpc.protobuf.input.stream.InputStream {
+ val buffer = kotlinx.io.Buffer()
+ val encoder = kotlinx.rpc.protobuf.internal.WireEncoder(buffer)
+ kotlinx.rpc.protobuf.internal.checkForPlatformEncodeException {
+ value.asInternal().encodeWith(encoder)
+ }
+ encoder.flush()
+ return buffer.asInputStream()
+ }
+
+ public override fun decode(stream: kotlinx.rpc.protobuf.input.stream.InputStream): com.google.protobuf.kotlin.SourceContext {
+ kotlinx.rpc.protobuf.internal.WireDecoder(stream).use {
+ val msg = com.google.protobuf.kotlin.SourceContextInternal()
+ kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException {
+ com.google.protobuf.kotlin.SourceContextInternal.decodeWith(msg, it)
+ }
+ msg.checkRequiredFields()
+ return msg
+ }
+ }
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public companion object
+}
+
+public operator fun com.google.protobuf.kotlin.SourceContext.Companion.invoke(body: com.google.protobuf.kotlin.SourceContextInternal.() -> Unit): com.google.protobuf.kotlin.SourceContext {
+ val msg = com.google.protobuf.kotlin.SourceContextInternal().apply(body)
+ msg.checkRequiredFields()
+ return msg
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.SourceContextInternal.checkRequiredFields() {
+ // no required fields to check
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.SourceContextInternal.encodeWith(encoder: kotlinx.rpc.protobuf.internal.WireEncoder) {
+ if (fileName.isNotEmpty()) {
+ encoder.writeString(fieldNr = 1, value = fileName)
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.SourceContextInternal.Companion.decodeWith(msg: com.google.protobuf.kotlin.SourceContextInternal, decoder: kotlinx.rpc.protobuf.internal.WireDecoder) {
+ while (true) {
+ val tag = decoder.readTag() ?: break // EOF, we read the whole message
+ when {
+ tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ msg.fileName = decoder.readString()
+ }
+
+ else -> {
+ // we are currently just skipping unknown fields (KRPC-191)
+ decoder.skipValue(tag.wireType)
+ }
+ }
+ }
+}
+
+private fun com.google.protobuf.kotlin.SourceContextInternal.computeSize(): Int {
+ var __result = 0
+ if (fileName.isNotEmpty()) {
+ __result += kotlinx.rpc.protobuf.internal.WireSize.string(fileName).let { kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it }
+ }
+
+ return __result
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.SourceContext.asInternal(): com.google.protobuf.kotlin.SourceContextInternal {
+ return this as? com.google.protobuf.kotlin.SourceContextInternal ?: error("Message ${this::class.simpleName} is a non-internal message type.")
+}
+
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
new file mode 100644
index 00000000..6ab75dd5
--- /dev/null
+++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Struct.kt
@@ -0,0 +1,460 @@
+@file:OptIn(ExperimentalRpcApi::class, kotlinx.rpc.internal.utils.InternalRpcApi::class)
+package com.google.protobuf.kotlin
+
+import kotlinx.rpc.internal.utils.*
+import kotlinx.rpc.protobuf.input.stream.asInputStream
+import kotlinx.rpc.protobuf.internal.*
+
+public class StructInternal: com.google.protobuf.kotlin.Struct, kotlinx.rpc.protobuf.internal.InternalMessage(fieldsWithPresence = 0) {
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public override val _size: Int by lazy { computeSize() }
+
+ public override var fields: Map by MsgFieldDelegate { mutableMapOf() }
+
+ public class FieldsEntryInternal: kotlinx.rpc.protobuf.internal.InternalMessage(fieldsWithPresence = 1) {
+ private object PresenceIndices {
+ public const val value: Int = 0
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public override val _size: Int by lazy { computeSize() }
+
+ public var key: String by MsgFieldDelegate { "" }
+ public var value: com.google.protobuf.kotlin.Value by MsgFieldDelegate(PresenceIndices.value) { com.google.protobuf.kotlin.ValueInternal() }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public companion object
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec {
+ public override fun encode(value: com.google.protobuf.kotlin.Struct): kotlinx.rpc.protobuf.input.stream.InputStream {
+ val buffer = kotlinx.io.Buffer()
+ val encoder = kotlinx.rpc.protobuf.internal.WireEncoder(buffer)
+ kotlinx.rpc.protobuf.internal.checkForPlatformEncodeException {
+ value.asInternal().encodeWith(encoder)
+ }
+ encoder.flush()
+ return buffer.asInputStream()
+ }
+
+ public override fun decode(stream: kotlinx.rpc.protobuf.input.stream.InputStream): com.google.protobuf.kotlin.Struct {
+ kotlinx.rpc.protobuf.internal.WireDecoder(stream).use {
+ val msg = com.google.protobuf.kotlin.StructInternal()
+ kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException {
+ com.google.protobuf.kotlin.StructInternal.decodeWith(msg, it)
+ }
+ msg.checkRequiredFields()
+ return msg
+ }
+ }
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public companion object
+}
+
+public class ValueInternal: com.google.protobuf.kotlin.Value, kotlinx.rpc.protobuf.internal.InternalMessage(fieldsWithPresence = 0) {
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public override val _size: Int by lazy { computeSize() }
+
+ public override var kind: com.google.protobuf.kotlin.Value.Kind? = null
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec {
+ public override fun encode(value: com.google.protobuf.kotlin.Value): kotlinx.rpc.protobuf.input.stream.InputStream {
+ val buffer = kotlinx.io.Buffer()
+ val encoder = kotlinx.rpc.protobuf.internal.WireEncoder(buffer)
+ kotlinx.rpc.protobuf.internal.checkForPlatformEncodeException {
+ value.asInternal().encodeWith(encoder)
+ }
+ encoder.flush()
+ return buffer.asInputStream()
+ }
+
+ public override fun decode(stream: kotlinx.rpc.protobuf.input.stream.InputStream): com.google.protobuf.kotlin.Value {
+ kotlinx.rpc.protobuf.internal.WireDecoder(stream).use {
+ val msg = com.google.protobuf.kotlin.ValueInternal()
+ kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException {
+ com.google.protobuf.kotlin.ValueInternal.decodeWith(msg, it)
+ }
+ msg.checkRequiredFields()
+ return msg
+ }
+ }
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public companion object
+}
+
+public class ListValueInternal: com.google.protobuf.kotlin.ListValue, kotlinx.rpc.protobuf.internal.InternalMessage(fieldsWithPresence = 0) {
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public override val _size: Int by lazy { computeSize() }
+
+ public override var values: List by MsgFieldDelegate { mutableListOf() }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec {
+ public override fun encode(value: com.google.protobuf.kotlin.ListValue): kotlinx.rpc.protobuf.input.stream.InputStream {
+ val buffer = kotlinx.io.Buffer()
+ val encoder = kotlinx.rpc.protobuf.internal.WireEncoder(buffer)
+ kotlinx.rpc.protobuf.internal.checkForPlatformEncodeException {
+ value.asInternal().encodeWith(encoder)
+ }
+ encoder.flush()
+ return buffer.asInputStream()
+ }
+
+ public override fun decode(stream: kotlinx.rpc.protobuf.input.stream.InputStream): com.google.protobuf.kotlin.ListValue {
+ kotlinx.rpc.protobuf.internal.WireDecoder(stream).use {
+ val msg = com.google.protobuf.kotlin.ListValueInternal()
+ kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException {
+ com.google.protobuf.kotlin.ListValueInternal.decodeWith(msg, it)
+ }
+ msg.checkRequiredFields()
+ return msg
+ }
+ }
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public companion object
+}
+
+public operator fun com.google.protobuf.kotlin.Struct.Companion.invoke(body: com.google.protobuf.kotlin.StructInternal.() -> Unit): com.google.protobuf.kotlin.Struct {
+ val msg = com.google.protobuf.kotlin.StructInternal().apply(body)
+ msg.checkRequiredFields()
+ return msg
+}
+
+public operator fun com.google.protobuf.kotlin.Value.Companion.invoke(body: com.google.protobuf.kotlin.ValueInternal.() -> Unit): com.google.protobuf.kotlin.Value {
+ val msg = com.google.protobuf.kotlin.ValueInternal().apply(body)
+ msg.checkRequiredFields()
+ return msg
+}
+
+public operator fun com.google.protobuf.kotlin.ListValue.Companion.invoke(body: com.google.protobuf.kotlin.ListValueInternal.() -> Unit): com.google.protobuf.kotlin.ListValue {
+ val msg = com.google.protobuf.kotlin.ListValueInternal().apply(body)
+ msg.checkRequiredFields()
+ return msg
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.StructInternal.checkRequiredFields() {
+ // no required fields to check
+ fields.values.forEach {
+ it.asInternal().checkRequiredFields()
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.StructInternal.encodeWith(encoder: kotlinx.rpc.protobuf.internal.WireEncoder) {
+ if (fields.isNotEmpty()) {
+ fields.forEach { kEntry ->
+ com.google.protobuf.kotlin.StructInternal.FieldsEntryInternal().apply {
+ key = kEntry.key
+ value = kEntry.value
+ }
+ .also { entry ->
+ encoder.writeMessage(fieldNr = 1, value = entry.asInternal()) { encodeWith(it) }
+ }
+ }
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.StructInternal.Companion.decodeWith(msg: com.google.protobuf.kotlin.StructInternal, decoder: kotlinx.rpc.protobuf.internal.WireDecoder) {
+ while (true) {
+ val tag = decoder.readTag() ?: break // EOF, we read the whole message
+ when {
+ tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ with(com.google.protobuf.kotlin.StructInternal.FieldsEntryInternal()) {
+ decoder.readMessage(this.asInternal(), com.google.protobuf.kotlin.StructInternal.FieldsEntryInternal::decodeWith)
+ (msg.fields as MutableMap)[key] = value
+ }
+ }
+
+ else -> {
+ // we are currently just skipping unknown fields (KRPC-191)
+ decoder.skipValue(tag.wireType)
+ }
+ }
+ }
+}
+
+private fun com.google.protobuf.kotlin.StructInternal.computeSize(): Int {
+ var __result = 0
+ if (fields.isNotEmpty()) {
+ __result += fields.entries.sumOf { kEntry ->
+ com.google.protobuf.kotlin.StructInternal.FieldsEntryInternal().apply {
+ key = kEntry.key
+ value = kEntry.value
+ }
+ ._size
+ }
+ }
+
+ return __result
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.Struct.asInternal(): com.google.protobuf.kotlin.StructInternal {
+ return this as? com.google.protobuf.kotlin.StructInternal ?: error("Message ${this::class.simpleName} is a non-internal message type.")
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.ValueInternal.checkRequiredFields() {
+ // no required fields to check
+ kind?.also {
+ when {
+ it is com.google.protobuf.kotlin.Value.Kind.StructValue -> {
+ it.value.asInternal().checkRequiredFields()
+ }
+
+ it is com.google.protobuf.kotlin.Value.Kind.ListValue -> {
+ it.value.asInternal().checkRequiredFields()
+ }
+ }
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.ValueInternal.encodeWith(encoder: kotlinx.rpc.protobuf.internal.WireEncoder) {
+ kind?.also {
+ when (val value = it) {
+ is com.google.protobuf.kotlin.Value.Kind.NullValue -> {
+ encoder.writeEnum(fieldNr = 1, value = value.value.number)
+ }
+
+ is com.google.protobuf.kotlin.Value.Kind.NumberValue -> {
+ encoder.writeDouble(fieldNr = 2, value = value.value)
+ }
+
+ is com.google.protobuf.kotlin.Value.Kind.StringValue -> {
+ encoder.writeString(fieldNr = 3, value = value.value)
+ }
+
+ is com.google.protobuf.kotlin.Value.Kind.BoolValue -> {
+ encoder.writeBool(fieldNr = 4, value = value.value)
+ }
+
+ is com.google.protobuf.kotlin.Value.Kind.StructValue -> {
+ encoder.writeMessage(fieldNr = 5, value = value.value.asInternal()) { encodeWith(it) }
+ }
+
+ is com.google.protobuf.kotlin.Value.Kind.ListValue -> {
+ encoder.writeMessage(fieldNr = 6, value = value.value.asInternal()) { encodeWith(it) }
+ }
+ }
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.ValueInternal.Companion.decodeWith(msg: com.google.protobuf.kotlin.ValueInternal, decoder: kotlinx.rpc.protobuf.internal.WireDecoder) {
+ while (true) {
+ val tag = decoder.readTag() ?: break // EOF, we read the whole message
+ when {
+ tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> {
+ msg.kind = com.google.protobuf.kotlin.Value.Kind.NullValue(com.google.protobuf.kotlin.NullValue.fromNumber(decoder.readEnum()))
+ }
+
+ tag.fieldNr == 2 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> {
+ msg.kind = com.google.protobuf.kotlin.Value.Kind.NumberValue(decoder.readDouble())
+ }
+
+ tag.fieldNr == 3 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ msg.kind = com.google.protobuf.kotlin.Value.Kind.StringValue(decoder.readString())
+ }
+
+ tag.fieldNr == 4 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> {
+ msg.kind = com.google.protobuf.kotlin.Value.Kind.BoolValue(decoder.readBool())
+ }
+
+ tag.fieldNr == 5 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ val field = (msg.kind as? com.google.protobuf.kotlin.Value.Kind.StructValue) ?: com.google.protobuf.kotlin.Value.Kind.StructValue(com.google.protobuf.kotlin.StructInternal()).also {
+ msg.kind = it
+ }
+
+ decoder.readMessage(field.value.asInternal(), com.google.protobuf.kotlin.StructInternal::decodeWith)
+ }
+
+ tag.fieldNr == 6 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ val field = (msg.kind as? com.google.protobuf.kotlin.Value.Kind.ListValue) ?: com.google.protobuf.kotlin.Value.Kind.ListValue(com.google.protobuf.kotlin.ListValueInternal()).also {
+ msg.kind = it
+ }
+
+ decoder.readMessage(field.value.asInternal(), com.google.protobuf.kotlin.ListValueInternal::decodeWith)
+ }
+
+ else -> {
+ // we are currently just skipping unknown fields (KRPC-191)
+ decoder.skipValue(tag.wireType)
+ }
+ }
+ }
+}
+
+private fun com.google.protobuf.kotlin.ValueInternal.computeSize(): Int {
+ var __result = 0
+ kind?.also {
+ when (val value = it) {
+ is com.google.protobuf.kotlin.Value.Kind.NullValue -> {
+ __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(value.value.number))
+ }
+
+ is com.google.protobuf.kotlin.Value.Kind.NumberValue -> {
+ __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.FIXED64) + kotlinx.rpc.protobuf.internal.WireSize.double(value.value))
+ }
+
+ is com.google.protobuf.kotlin.Value.Kind.StringValue -> {
+ __result += kotlinx.rpc.protobuf.internal.WireSize.string(value.value).let { kotlinx.rpc.protobuf.internal.WireSize.tag(3, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it }
+ }
+
+ is com.google.protobuf.kotlin.Value.Kind.BoolValue -> {
+ __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(4, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.bool(value.value))
+ }
+
+ is com.google.protobuf.kotlin.Value.Kind.StructValue -> {
+ __result += value.value.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 }
+ }
+
+ is com.google.protobuf.kotlin.Value.Kind.ListValue -> {
+ __result += value.value.asInternal()._size.let { kotlinx.rpc.protobuf.internal.WireSize.tag(6, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it }
+ }
+ }
+ }
+
+ return __result
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.Value.asInternal(): com.google.protobuf.kotlin.ValueInternal {
+ return this as? com.google.protobuf.kotlin.ValueInternal ?: error("Message ${this::class.simpleName} is a non-internal message type.")
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.ListValueInternal.checkRequiredFields() {
+ // no required fields to check
+ values.forEach {
+ it.asInternal().checkRequiredFields()
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.ListValueInternal.encodeWith(encoder: kotlinx.rpc.protobuf.internal.WireEncoder) {
+ if (values.isNotEmpty()) {
+ values.forEach {
+ encoder.writeMessage(fieldNr = 1, value = it.asInternal()) { encodeWith(it) }
+ }
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.ListValueInternal.Companion.decodeWith(msg: com.google.protobuf.kotlin.ListValueInternal, decoder: kotlinx.rpc.protobuf.internal.WireDecoder) {
+ while (true) {
+ val tag = decoder.readTag() ?: break // EOF, we read the whole message
+ when {
+ tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ val elem = com.google.protobuf.kotlin.ValueInternal()
+ decoder.readMessage(elem.asInternal(), com.google.protobuf.kotlin.ValueInternal::decodeWith)
+ (msg.values as MutableList).add(elem)
+ }
+
+ else -> {
+ // we are currently just skipping unknown fields (KRPC-191)
+ decoder.skipValue(tag.wireType)
+ }
+ }
+ }
+}
+
+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) }
+ }
+
+ return __result
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.ListValue.asInternal(): com.google.protobuf.kotlin.ListValueInternal {
+ return this as? com.google.protobuf.kotlin.ListValueInternal ?: error("Message ${this::class.simpleName} is a non-internal message type.")
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.StructInternal.FieldsEntryInternal.checkRequiredFields() {
+ // no required fields to check
+ if (presenceMask[0]) {
+ value.asInternal().checkRequiredFields()
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.StructInternal.FieldsEntryInternal.encodeWith(encoder: kotlinx.rpc.protobuf.internal.WireEncoder) {
+ if (key.isNotEmpty()) {
+ encoder.writeString(fieldNr = 1, value = key)
+ }
+
+ if (presenceMask[0]) {
+ encoder.writeMessage(fieldNr = 2, value = value.asInternal()) { encodeWith(it) }
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.StructInternal.FieldsEntryInternal.Companion.decodeWith(msg: com.google.protobuf.kotlin.StructInternal.FieldsEntryInternal, decoder: kotlinx.rpc.protobuf.internal.WireDecoder) {
+ while (true) {
+ val tag = decoder.readTag() ?: break // EOF, we read the whole message
+ when {
+ tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ msg.key = decoder.readString()
+ }
+
+ tag.fieldNr == 2 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ if (!msg.presenceMask[0]) {
+ msg.value = com.google.protobuf.kotlin.ValueInternal()
+ }
+
+ decoder.readMessage(msg.value.asInternal(), com.google.protobuf.kotlin.ValueInternal::decodeWith)
+ }
+
+ else -> {
+ // we are currently just skipping unknown fields (KRPC-191)
+ decoder.skipValue(tag.wireType)
+ }
+ }
+ }
+}
+
+private fun com.google.protobuf.kotlin.StructInternal.FieldsEntryInternal.computeSize(): Int {
+ var __result = 0
+ if (key.isNotEmpty()) {
+ __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 (presenceMask[0]) {
+ __result += value.asInternal()._size.let { kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it }
+ }
+
+ return __result
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.StructInternal.FieldsEntryInternal.asInternal(): com.google.protobuf.kotlin.StructInternal.FieldsEntryInternal {
+ return this
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.NullValue.Companion.fromNumber(number: Int): com.google.protobuf.kotlin.NullValue {
+ return when (number) {
+ 0 -> {
+ com.google.protobuf.kotlin.NullValue.NULL_VALUE
+ }
+
+ else -> {
+ com.google.protobuf.kotlin.NullValue.UNRECOGNIZED(number)
+ }
+ }
+}
+
diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Timestamp.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Timestamp.kt
new file mode 100644
index 00000000..27053f95
--- /dev/null
+++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Timestamp.kt
@@ -0,0 +1,103 @@
+@file:OptIn(ExperimentalRpcApi::class, kotlinx.rpc.internal.utils.InternalRpcApi::class)
+package com.google.protobuf.kotlin
+
+import kotlinx.rpc.internal.utils.*
+import kotlinx.rpc.protobuf.input.stream.asInputStream
+import kotlinx.rpc.protobuf.internal.*
+
+public class TimestampInternal: com.google.protobuf.kotlin.Timestamp, kotlinx.rpc.protobuf.internal.InternalMessage(fieldsWithPresence = 0) {
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public override val _size: Int by lazy { computeSize() }
+
+ public override var seconds: Long by MsgFieldDelegate { 0L }
+ public override var nanos: Int by MsgFieldDelegate { 0 }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec {
+ public override fun encode(value: com.google.protobuf.kotlin.Timestamp): kotlinx.rpc.protobuf.input.stream.InputStream {
+ val buffer = kotlinx.io.Buffer()
+ val encoder = kotlinx.rpc.protobuf.internal.WireEncoder(buffer)
+ kotlinx.rpc.protobuf.internal.checkForPlatformEncodeException {
+ value.asInternal().encodeWith(encoder)
+ }
+ encoder.flush()
+ return buffer.asInputStream()
+ }
+
+ public override fun decode(stream: kotlinx.rpc.protobuf.input.stream.InputStream): com.google.protobuf.kotlin.Timestamp {
+ kotlinx.rpc.protobuf.internal.WireDecoder(stream).use {
+ val msg = com.google.protobuf.kotlin.TimestampInternal()
+ kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException {
+ com.google.protobuf.kotlin.TimestampInternal.decodeWith(msg, it)
+ }
+ msg.checkRequiredFields()
+ return msg
+ }
+ }
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public companion object
+}
+
+public operator fun com.google.protobuf.kotlin.Timestamp.Companion.invoke(body: com.google.protobuf.kotlin.TimestampInternal.() -> Unit): com.google.protobuf.kotlin.Timestamp {
+ val msg = com.google.protobuf.kotlin.TimestampInternal().apply(body)
+ msg.checkRequiredFields()
+ return msg
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.TimestampInternal.checkRequiredFields() {
+ // no required fields to check
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.TimestampInternal.encodeWith(encoder: kotlinx.rpc.protobuf.internal.WireEncoder) {
+ if (seconds != 0L) {
+ encoder.writeInt64(fieldNr = 1, value = seconds)
+ }
+
+ if (nanos != 0) {
+ encoder.writeInt32(fieldNr = 2, value = nanos)
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.TimestampInternal.Companion.decodeWith(msg: com.google.protobuf.kotlin.TimestampInternal, decoder: kotlinx.rpc.protobuf.internal.WireDecoder) {
+ while (true) {
+ val tag = decoder.readTag() ?: break // EOF, we read the whole message
+ when {
+ tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> {
+ msg.seconds = decoder.readInt64()
+ }
+
+ tag.fieldNr == 2 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> {
+ msg.nanos = decoder.readInt32()
+ }
+
+ else -> {
+ // we are currently just skipping unknown fields (KRPC-191)
+ decoder.skipValue(tag.wireType)
+ }
+ }
+ }
+}
+
+private fun com.google.protobuf.kotlin.TimestampInternal.computeSize(): Int {
+ var __result = 0
+ if (seconds != 0L) {
+ __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.int64(seconds))
+ }
+
+ if (nanos != 0) {
+ __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.int32(nanos))
+ }
+
+ return __result
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.Timestamp.asInternal(): com.google.protobuf.kotlin.TimestampInternal {
+ return this as? com.google.protobuf.kotlin.TimestampInternal ?: error("Message ${this::class.simpleName} is a non-internal message type.")
+}
+
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
new file mode 100644
index 00000000..6887ef66
--- /dev/null
+++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Type.kt
@@ -0,0 +1,934 @@
+@file:OptIn(ExperimentalRpcApi::class, kotlinx.rpc.internal.utils.InternalRpcApi::class)
+package com.google.protobuf.kotlin
+
+import kotlinx.rpc.internal.utils.*
+import kotlinx.rpc.protobuf.input.stream.asInputStream
+import kotlinx.rpc.protobuf.internal.*
+
+public class TypeInternal: com.google.protobuf.kotlin.Type, kotlinx.rpc.protobuf.internal.InternalMessage(fieldsWithPresence = 1) {
+ private object PresenceIndices {
+ public const val sourceContext: Int = 0
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public override val _size: Int by lazy { computeSize() }
+
+ public override var name: String by MsgFieldDelegate { "" }
+ public override var fields: List by MsgFieldDelegate { mutableListOf() }
+ public override var oneofs: List by MsgFieldDelegate { mutableListOf() }
+ public override var options: List by MsgFieldDelegate { mutableListOf() }
+ public override var sourceContext: com.google.protobuf.kotlin.SourceContext by MsgFieldDelegate(PresenceIndices.sourceContext) { com.google.protobuf.kotlin.SourceContextInternal() }
+ public override var syntax: com.google.protobuf.kotlin.Syntax by MsgFieldDelegate { com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2 }
+ public override var edition: String by MsgFieldDelegate { "" }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec {
+ public override fun encode(value: com.google.protobuf.kotlin.Type): kotlinx.rpc.protobuf.input.stream.InputStream {
+ val buffer = kotlinx.io.Buffer()
+ val encoder = kotlinx.rpc.protobuf.internal.WireEncoder(buffer)
+ kotlinx.rpc.protobuf.internal.checkForPlatformEncodeException {
+ value.asInternal().encodeWith(encoder)
+ }
+ encoder.flush()
+ return buffer.asInputStream()
+ }
+
+ public override fun decode(stream: kotlinx.rpc.protobuf.input.stream.InputStream): com.google.protobuf.kotlin.Type {
+ kotlinx.rpc.protobuf.internal.WireDecoder(stream).use {
+ val msg = com.google.protobuf.kotlin.TypeInternal()
+ kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException {
+ com.google.protobuf.kotlin.TypeInternal.decodeWith(msg, it)
+ }
+ msg.checkRequiredFields()
+ return msg
+ }
+ }
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public companion object
+}
+
+public class FieldInternal: com.google.protobuf.kotlin.Field, kotlinx.rpc.protobuf.internal.InternalMessage(fieldsWithPresence = 0) {
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public override val _size: Int by lazy { computeSize() }
+
+ public override var kind: com.google.protobuf.kotlin.Field.Kind by MsgFieldDelegate { com.google.protobuf.kotlin.Field.Kind.TYPE_UNKNOWN }
+ public override var cardinality: com.google.protobuf.kotlin.Field.Cardinality by MsgFieldDelegate { com.google.protobuf.kotlin.Field.Cardinality.CARDINALITY_UNKNOWN }
+ public override var number: Int by MsgFieldDelegate { 0 }
+ public override var name: String by MsgFieldDelegate { "" }
+ public override var typeUrl: String by MsgFieldDelegate { "" }
+ public override var oneofIndex: Int by MsgFieldDelegate { 0 }
+ public override var packed: Boolean by MsgFieldDelegate { false }
+ public override var options: List by MsgFieldDelegate { mutableListOf() }
+ public override var jsonName: String by MsgFieldDelegate { "" }
+ public override var defaultValue: String by MsgFieldDelegate { "" }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec {
+ public override fun encode(value: com.google.protobuf.kotlin.Field): kotlinx.rpc.protobuf.input.stream.InputStream {
+ val buffer = kotlinx.io.Buffer()
+ val encoder = kotlinx.rpc.protobuf.internal.WireEncoder(buffer)
+ kotlinx.rpc.protobuf.internal.checkForPlatformEncodeException {
+ value.asInternal().encodeWith(encoder)
+ }
+ encoder.flush()
+ return buffer.asInputStream()
+ }
+
+ public override fun decode(stream: kotlinx.rpc.protobuf.input.stream.InputStream): com.google.protobuf.kotlin.Field {
+ kotlinx.rpc.protobuf.internal.WireDecoder(stream).use {
+ val msg = com.google.protobuf.kotlin.FieldInternal()
+ kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException {
+ com.google.protobuf.kotlin.FieldInternal.decodeWith(msg, it)
+ }
+ msg.checkRequiredFields()
+ return msg
+ }
+ }
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public companion object
+}
+
+public class EnumInternal: com.google.protobuf.kotlin.Enum, kotlinx.rpc.protobuf.internal.InternalMessage(fieldsWithPresence = 1) {
+ private object PresenceIndices {
+ public const val sourceContext: Int = 0
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public override val _size: Int by lazy { computeSize() }
+
+ public override var name: String by MsgFieldDelegate { "" }
+ public override var enumvalue: List by MsgFieldDelegate { mutableListOf() }
+ public override var options: List by MsgFieldDelegate { mutableListOf() }
+ public override var sourceContext: com.google.protobuf.kotlin.SourceContext by MsgFieldDelegate(PresenceIndices.sourceContext) { com.google.protobuf.kotlin.SourceContextInternal() }
+ public override var syntax: com.google.protobuf.kotlin.Syntax by MsgFieldDelegate { com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2 }
+ public override var edition: String by MsgFieldDelegate { "" }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec {
+ public override fun encode(value: com.google.protobuf.kotlin.Enum): kotlinx.rpc.protobuf.input.stream.InputStream {
+ val buffer = kotlinx.io.Buffer()
+ val encoder = kotlinx.rpc.protobuf.internal.WireEncoder(buffer)
+ kotlinx.rpc.protobuf.internal.checkForPlatformEncodeException {
+ value.asInternal().encodeWith(encoder)
+ }
+ encoder.flush()
+ return buffer.asInputStream()
+ }
+
+ public override fun decode(stream: kotlinx.rpc.protobuf.input.stream.InputStream): com.google.protobuf.kotlin.Enum {
+ kotlinx.rpc.protobuf.internal.WireDecoder(stream).use {
+ val msg = com.google.protobuf.kotlin.EnumInternal()
+ kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException {
+ com.google.protobuf.kotlin.EnumInternal.decodeWith(msg, it)
+ }
+ msg.checkRequiredFields()
+ return msg
+ }
+ }
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public companion object
+}
+
+public class EnumValueInternal: com.google.protobuf.kotlin.EnumValue, kotlinx.rpc.protobuf.internal.InternalMessage(fieldsWithPresence = 0) {
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public override val _size: Int by lazy { computeSize() }
+
+ public override var name: String by MsgFieldDelegate { "" }
+ public override var number: Int by MsgFieldDelegate { 0 }
+ public override var options: List by MsgFieldDelegate { mutableListOf() }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec {
+ public override fun encode(value: com.google.protobuf.kotlin.EnumValue): kotlinx.rpc.protobuf.input.stream.InputStream {
+ val buffer = kotlinx.io.Buffer()
+ val encoder = kotlinx.rpc.protobuf.internal.WireEncoder(buffer)
+ kotlinx.rpc.protobuf.internal.checkForPlatformEncodeException {
+ value.asInternal().encodeWith(encoder)
+ }
+ encoder.flush()
+ return buffer.asInputStream()
+ }
+
+ public override fun decode(stream: kotlinx.rpc.protobuf.input.stream.InputStream): com.google.protobuf.kotlin.EnumValue {
+ kotlinx.rpc.protobuf.internal.WireDecoder(stream).use {
+ val msg = com.google.protobuf.kotlin.EnumValueInternal()
+ kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException {
+ com.google.protobuf.kotlin.EnumValueInternal.decodeWith(msg, it)
+ }
+ msg.checkRequiredFields()
+ return msg
+ }
+ }
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public companion object
+}
+
+public class OptionInternal: com.google.protobuf.kotlin.Option, kotlinx.rpc.protobuf.internal.InternalMessage(fieldsWithPresence = 1) {
+ private object PresenceIndices {
+ public const val value: Int = 0
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public override val _size: Int by lazy { computeSize() }
+
+ public override var name: String by MsgFieldDelegate { "" }
+ public override var value: com.google.protobuf.kotlin.Any by MsgFieldDelegate(PresenceIndices.value) { com.google.protobuf.kotlin.AnyInternal() }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec {
+ public override fun encode(value: com.google.protobuf.kotlin.Option): kotlinx.rpc.protobuf.input.stream.InputStream {
+ val buffer = kotlinx.io.Buffer()
+ val encoder = kotlinx.rpc.protobuf.internal.WireEncoder(buffer)
+ kotlinx.rpc.protobuf.internal.checkForPlatformEncodeException {
+ value.asInternal().encodeWith(encoder)
+ }
+ encoder.flush()
+ return buffer.asInputStream()
+ }
+
+ public override fun decode(stream: kotlinx.rpc.protobuf.input.stream.InputStream): com.google.protobuf.kotlin.Option {
+ kotlinx.rpc.protobuf.internal.WireDecoder(stream).use {
+ val msg = com.google.protobuf.kotlin.OptionInternal()
+ kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException {
+ com.google.protobuf.kotlin.OptionInternal.decodeWith(msg, it)
+ }
+ msg.checkRequiredFields()
+ return msg
+ }
+ }
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public companion object
+}
+
+public operator fun com.google.protobuf.kotlin.Type.Companion.invoke(body: com.google.protobuf.kotlin.TypeInternal.() -> Unit): com.google.protobuf.kotlin.Type {
+ val msg = com.google.protobuf.kotlin.TypeInternal().apply(body)
+ msg.checkRequiredFields()
+ return msg
+}
+
+public operator fun com.google.protobuf.kotlin.Field.Companion.invoke(body: com.google.protobuf.kotlin.FieldInternal.() -> Unit): com.google.protobuf.kotlin.Field {
+ val msg = com.google.protobuf.kotlin.FieldInternal().apply(body)
+ msg.checkRequiredFields()
+ return msg
+}
+
+public operator fun com.google.protobuf.kotlin.Enum.Companion.invoke(body: com.google.protobuf.kotlin.EnumInternal.() -> Unit): com.google.protobuf.kotlin.Enum {
+ val msg = com.google.protobuf.kotlin.EnumInternal().apply(body)
+ msg.checkRequiredFields()
+ return msg
+}
+
+public operator fun com.google.protobuf.kotlin.EnumValue.Companion.invoke(body: com.google.protobuf.kotlin.EnumValueInternal.() -> Unit): com.google.protobuf.kotlin.EnumValue {
+ val msg = com.google.protobuf.kotlin.EnumValueInternal().apply(body)
+ msg.checkRequiredFields()
+ return msg
+}
+
+public operator fun com.google.protobuf.kotlin.Option.Companion.invoke(body: com.google.protobuf.kotlin.OptionInternal.() -> Unit): com.google.protobuf.kotlin.Option {
+ val msg = com.google.protobuf.kotlin.OptionInternal().apply(body)
+ msg.checkRequiredFields()
+ return msg
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.TypeInternal.checkRequiredFields() {
+ // no required fields to check
+ if (presenceMask[0]) {
+ sourceContext.asInternal().checkRequiredFields()
+ }
+
+ fields.forEach {
+ it.asInternal().checkRequiredFields()
+ }
+
+ options.forEach {
+ it.asInternal().checkRequiredFields()
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.TypeInternal.encodeWith(encoder: kotlinx.rpc.protobuf.internal.WireEncoder) {
+ if (name.isNotEmpty()) {
+ encoder.writeString(fieldNr = 1, value = name)
+ }
+
+ if (fields.isNotEmpty()) {
+ fields.forEach {
+ encoder.writeMessage(fieldNr = 2, value = it.asInternal()) { encodeWith(it) }
+ }
+ }
+
+ if (oneofs.isNotEmpty()) {
+ oneofs.forEach {
+ encoder.writeString(3, it)
+ }
+ }
+
+ if (options.isNotEmpty()) {
+ options.forEach {
+ encoder.writeMessage(fieldNr = 4, value = it.asInternal()) { encodeWith(it) }
+ }
+ }
+
+ if (presenceMask[0]) {
+ encoder.writeMessage(fieldNr = 5, value = sourceContext.asInternal()) { encodeWith(it) }
+ }
+
+ if (com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2 != syntax) {
+ encoder.writeEnum(fieldNr = 6, value = syntax.number)
+ }
+
+ if (edition.isNotEmpty()) {
+ encoder.writeString(fieldNr = 7, value = edition)
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.TypeInternal.Companion.decodeWith(msg: com.google.protobuf.kotlin.TypeInternal, decoder: kotlinx.rpc.protobuf.internal.WireDecoder) {
+ while (true) {
+ val tag = decoder.readTag() ?: break // EOF, we read the whole message
+ when {
+ tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ msg.name = decoder.readString()
+ }
+
+ tag.fieldNr == 2 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ val elem = com.google.protobuf.kotlin.FieldInternal()
+ decoder.readMessage(elem.asInternal(), com.google.protobuf.kotlin.FieldInternal::decodeWith)
+ (msg.fields as MutableList).add(elem)
+ }
+
+ tag.fieldNr == 3 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ val elem = decoder.readString()
+ (msg.oneofs as MutableList).add(elem)
+ }
+
+ tag.fieldNr == 4 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ val elem = com.google.protobuf.kotlin.OptionInternal()
+ decoder.readMessage(elem.asInternal(), com.google.protobuf.kotlin.OptionInternal::decodeWith)
+ (msg.options as MutableList).add(elem)
+ }
+
+ tag.fieldNr == 5 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ if (!msg.presenceMask[0]) {
+ msg.sourceContext = com.google.protobuf.kotlin.SourceContextInternal()
+ }
+
+ decoder.readMessage(msg.sourceContext.asInternal(), com.google.protobuf.kotlin.SourceContextInternal::decodeWith)
+ }
+
+ tag.fieldNr == 6 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> {
+ msg.syntax = com.google.protobuf.kotlin.Syntax.fromNumber(decoder.readEnum())
+ }
+
+ tag.fieldNr == 7 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ msg.edition = decoder.readString()
+ }
+
+ else -> {
+ // we are currently just skipping unknown fields (KRPC-191)
+ decoder.skipValue(tag.wireType)
+ }
+ }
+ }
+}
+
+private fun com.google.protobuf.kotlin.TypeInternal.computeSize(): Int {
+ var __result = 0
+ if (name.isNotEmpty()) {
+ __result += kotlinx.rpc.protobuf.internal.WireSize.string(name).let { kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it }
+ }
+
+ if (fields.isNotEmpty()) {
+ __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) }
+ }
+
+ if (options.isNotEmpty()) {
+ __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) {
+ __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(6, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(syntax.number))
+ }
+
+ if (edition.isNotEmpty()) {
+ __result += kotlinx.rpc.protobuf.internal.WireSize.string(edition).let { kotlinx.rpc.protobuf.internal.WireSize.tag(7, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it }
+ }
+
+ return __result
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.Type.asInternal(): com.google.protobuf.kotlin.TypeInternal {
+ return this as? com.google.protobuf.kotlin.TypeInternal ?: error("Message ${this::class.simpleName} is a non-internal message type.")
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.FieldInternal.checkRequiredFields() {
+ // no required fields to check
+ options.forEach {
+ it.asInternal().checkRequiredFields()
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.FieldInternal.encodeWith(encoder: kotlinx.rpc.protobuf.internal.WireEncoder) {
+ if (com.google.protobuf.kotlin.Field.Kind.TYPE_UNKNOWN != kind) {
+ encoder.writeEnum(fieldNr = 1, value = kind.number)
+ }
+
+ if (com.google.protobuf.kotlin.Field.Cardinality.CARDINALITY_UNKNOWN != cardinality) {
+ encoder.writeEnum(fieldNr = 2, value = cardinality.number)
+ }
+
+ if (number != 0) {
+ encoder.writeInt32(fieldNr = 3, value = number)
+ }
+
+ if (name.isNotEmpty()) {
+ encoder.writeString(fieldNr = 4, value = name)
+ }
+
+ if (typeUrl.isNotEmpty()) {
+ encoder.writeString(fieldNr = 6, value = typeUrl)
+ }
+
+ if (oneofIndex != 0) {
+ encoder.writeInt32(fieldNr = 7, value = oneofIndex)
+ }
+
+ if (packed != false) {
+ encoder.writeBool(fieldNr = 8, value = packed)
+ }
+
+ if (options.isNotEmpty()) {
+ options.forEach {
+ encoder.writeMessage(fieldNr = 9, value = it.asInternal()) { encodeWith(it) }
+ }
+ }
+
+ if (jsonName.isNotEmpty()) {
+ encoder.writeString(fieldNr = 10, value = jsonName)
+ }
+
+ if (defaultValue.isNotEmpty()) {
+ encoder.writeString(fieldNr = 11, value = defaultValue)
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.FieldInternal.Companion.decodeWith(msg: com.google.protobuf.kotlin.FieldInternal, decoder: kotlinx.rpc.protobuf.internal.WireDecoder) {
+ while (true) {
+ val tag = decoder.readTag() ?: break // EOF, we read the whole message
+ when {
+ tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> {
+ msg.kind = com.google.protobuf.kotlin.Field.Kind.fromNumber(decoder.readEnum())
+ }
+
+ tag.fieldNr == 2 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> {
+ msg.cardinality = com.google.protobuf.kotlin.Field.Cardinality.fromNumber(decoder.readEnum())
+ }
+
+ tag.fieldNr == 3 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> {
+ msg.number = decoder.readInt32()
+ }
+
+ tag.fieldNr == 4 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ msg.name = decoder.readString()
+ }
+
+ tag.fieldNr == 6 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ msg.typeUrl = decoder.readString()
+ }
+
+ tag.fieldNr == 7 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> {
+ msg.oneofIndex = decoder.readInt32()
+ }
+
+ tag.fieldNr == 8 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> {
+ msg.packed = decoder.readBool()
+ }
+
+ tag.fieldNr == 9 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ val elem = com.google.protobuf.kotlin.OptionInternal()
+ decoder.readMessage(elem.asInternal(), com.google.protobuf.kotlin.OptionInternal::decodeWith)
+ (msg.options as MutableList).add(elem)
+ }
+
+ tag.fieldNr == 10 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ msg.jsonName = decoder.readString()
+ }
+
+ tag.fieldNr == 11 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ msg.defaultValue = decoder.readString()
+ }
+
+ else -> {
+ // we are currently just skipping unknown fields (KRPC-191)
+ decoder.skipValue(tag.wireType)
+ }
+ }
+ }
+}
+
+private fun com.google.protobuf.kotlin.FieldInternal.computeSize(): Int {
+ var __result = 0
+ if (com.google.protobuf.kotlin.Field.Kind.TYPE_UNKNOWN != kind) {
+ __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) {
+ __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(cardinality.number))
+ }
+
+ if (number != 0) {
+ __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(3, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.int32(number))
+ }
+
+ if (name.isNotEmpty()) {
+ __result += kotlinx.rpc.protobuf.internal.WireSize.string(name).let { kotlinx.rpc.protobuf.internal.WireSize.tag(4, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it }
+ }
+
+ if (typeUrl.isNotEmpty()) {
+ __result += kotlinx.rpc.protobuf.internal.WireSize.string(typeUrl).let { kotlinx.rpc.protobuf.internal.WireSize.tag(6, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it }
+ }
+
+ if (oneofIndex != 0) {
+ __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(7, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.int32(oneofIndex))
+ }
+
+ if (packed != false) {
+ __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(8, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.bool(packed))
+ }
+
+ if (options.isNotEmpty()) {
+ __result = options.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(9, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) }
+ }
+
+ if (jsonName.isNotEmpty()) {
+ __result += kotlinx.rpc.protobuf.internal.WireSize.string(jsonName).let { kotlinx.rpc.protobuf.internal.WireSize.tag(10, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it }
+ }
+
+ if (defaultValue.isNotEmpty()) {
+ __result += kotlinx.rpc.protobuf.internal.WireSize.string(defaultValue).let { kotlinx.rpc.protobuf.internal.WireSize.tag(11, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it }
+ }
+
+ return __result
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.Field.asInternal(): com.google.protobuf.kotlin.FieldInternal {
+ return this as? com.google.protobuf.kotlin.FieldInternal ?: error("Message ${this::class.simpleName} is a non-internal message type.")
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.EnumInternal.checkRequiredFields() {
+ // no required fields to check
+ if (presenceMask[0]) {
+ sourceContext.asInternal().checkRequiredFields()
+ }
+
+ enumvalue.forEach {
+ it.asInternal().checkRequiredFields()
+ }
+
+ options.forEach {
+ it.asInternal().checkRequiredFields()
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.EnumInternal.encodeWith(encoder: kotlinx.rpc.protobuf.internal.WireEncoder) {
+ if (name.isNotEmpty()) {
+ encoder.writeString(fieldNr = 1, value = name)
+ }
+
+ if (enumvalue.isNotEmpty()) {
+ enumvalue.forEach {
+ encoder.writeMessage(fieldNr = 2, value = it.asInternal()) { encodeWith(it) }
+ }
+ }
+
+ if (options.isNotEmpty()) {
+ options.forEach {
+ encoder.writeMessage(fieldNr = 3, value = it.asInternal()) { encodeWith(it) }
+ }
+ }
+
+ if (presenceMask[0]) {
+ encoder.writeMessage(fieldNr = 4, value = sourceContext.asInternal()) { encodeWith(it) }
+ }
+
+ if (com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2 != syntax) {
+ encoder.writeEnum(fieldNr = 5, value = syntax.number)
+ }
+
+ if (edition.isNotEmpty()) {
+ encoder.writeString(fieldNr = 6, value = edition)
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.EnumInternal.Companion.decodeWith(msg: com.google.protobuf.kotlin.EnumInternal, decoder: kotlinx.rpc.protobuf.internal.WireDecoder) {
+ while (true) {
+ val tag = decoder.readTag() ?: break // EOF, we read the whole message
+ when {
+ tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ msg.name = decoder.readString()
+ }
+
+ tag.fieldNr == 2 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ val elem = com.google.protobuf.kotlin.EnumValueInternal()
+ decoder.readMessage(elem.asInternal(), com.google.protobuf.kotlin.EnumValueInternal::decodeWith)
+ (msg.enumvalue as MutableList).add(elem)
+ }
+
+ tag.fieldNr == 3 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ val elem = com.google.protobuf.kotlin.OptionInternal()
+ decoder.readMessage(elem.asInternal(), com.google.protobuf.kotlin.OptionInternal::decodeWith)
+ (msg.options as MutableList).add(elem)
+ }
+
+ tag.fieldNr == 4 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ if (!msg.presenceMask[0]) {
+ msg.sourceContext = com.google.protobuf.kotlin.SourceContextInternal()
+ }
+
+ decoder.readMessage(msg.sourceContext.asInternal(), com.google.protobuf.kotlin.SourceContextInternal::decodeWith)
+ }
+
+ tag.fieldNr == 5 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> {
+ msg.syntax = com.google.protobuf.kotlin.Syntax.fromNumber(decoder.readEnum())
+ }
+
+ tag.fieldNr == 6 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ msg.edition = decoder.readString()
+ }
+
+ else -> {
+ // we are currently just skipping unknown fields (KRPC-191)
+ decoder.skipValue(tag.wireType)
+ }
+ }
+ }
+}
+
+private fun com.google.protobuf.kotlin.EnumInternal.computeSize(): Int {
+ var __result = 0
+ if (name.isNotEmpty()) {
+ __result += kotlinx.rpc.protobuf.internal.WireSize.string(name).let { kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it }
+ }
+
+ if (enumvalue.isNotEmpty()) {
+ __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) }
+ }
+
+ 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) {
+ __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(5, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(syntax.number))
+ }
+
+ if (edition.isNotEmpty()) {
+ __result += kotlinx.rpc.protobuf.internal.WireSize.string(edition).let { kotlinx.rpc.protobuf.internal.WireSize.tag(6, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it }
+ }
+
+ return __result
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.Enum.asInternal(): com.google.protobuf.kotlin.EnumInternal {
+ return this as? com.google.protobuf.kotlin.EnumInternal ?: error("Message ${this::class.simpleName} is a non-internal message type.")
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.EnumValueInternal.checkRequiredFields() {
+ // no required fields to check
+ options.forEach {
+ it.asInternal().checkRequiredFields()
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.EnumValueInternal.encodeWith(encoder: kotlinx.rpc.protobuf.internal.WireEncoder) {
+ if (name.isNotEmpty()) {
+ encoder.writeString(fieldNr = 1, value = name)
+ }
+
+ if (number != 0) {
+ encoder.writeInt32(fieldNr = 2, value = number)
+ }
+
+ if (options.isNotEmpty()) {
+ options.forEach {
+ encoder.writeMessage(fieldNr = 3, value = it.asInternal()) { encodeWith(it) }
+ }
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.EnumValueInternal.Companion.decodeWith(msg: com.google.protobuf.kotlin.EnumValueInternal, decoder: kotlinx.rpc.protobuf.internal.WireDecoder) {
+ while (true) {
+ val tag = decoder.readTag() ?: break // EOF, we read the whole message
+ when {
+ tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ msg.name = decoder.readString()
+ }
+
+ tag.fieldNr == 2 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> {
+ msg.number = decoder.readInt32()
+ }
+
+ tag.fieldNr == 3 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ val elem = com.google.protobuf.kotlin.OptionInternal()
+ decoder.readMessage(elem.asInternal(), com.google.protobuf.kotlin.OptionInternal::decodeWith)
+ (msg.options as MutableList).add(elem)
+ }
+
+ else -> {
+ // we are currently just skipping unknown fields (KRPC-191)
+ decoder.skipValue(tag.wireType)
+ }
+ }
+ }
+}
+
+private fun com.google.protobuf.kotlin.EnumValueInternal.computeSize(): Int {
+ var __result = 0
+ if (name.isNotEmpty()) {
+ __result += kotlinx.rpc.protobuf.internal.WireSize.string(name).let { kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it }
+ }
+
+ if (number != 0) {
+ __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.int32(number))
+ }
+
+ if (options.isNotEmpty()) {
+ __result = options.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(3, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) }
+ }
+
+ return __result
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.EnumValue.asInternal(): com.google.protobuf.kotlin.EnumValueInternal {
+ return this as? com.google.protobuf.kotlin.EnumValueInternal ?: error("Message ${this::class.simpleName} is a non-internal message type.")
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.OptionInternal.checkRequiredFields() {
+ // no required fields to check
+ if (presenceMask[0]) {
+ value.asInternal().checkRequiredFields()
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.OptionInternal.encodeWith(encoder: kotlinx.rpc.protobuf.internal.WireEncoder) {
+ if (name.isNotEmpty()) {
+ encoder.writeString(fieldNr = 1, value = name)
+ }
+
+ if (presenceMask[0]) {
+ encoder.writeMessage(fieldNr = 2, value = value.asInternal()) { encodeWith(it) }
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.OptionInternal.Companion.decodeWith(msg: com.google.protobuf.kotlin.OptionInternal, decoder: kotlinx.rpc.protobuf.internal.WireDecoder) {
+ while (true) {
+ val tag = decoder.readTag() ?: break // EOF, we read the whole message
+ when {
+ tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ msg.name = decoder.readString()
+ }
+
+ tag.fieldNr == 2 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ if (!msg.presenceMask[0]) {
+ msg.value = com.google.protobuf.kotlin.AnyInternal()
+ }
+
+ decoder.readMessage(msg.value.asInternal(), com.google.protobuf.kotlin.AnyInternal::decodeWith)
+ }
+
+ else -> {
+ // we are currently just skipping unknown fields (KRPC-191)
+ decoder.skipValue(tag.wireType)
+ }
+ }
+ }
+}
+
+private fun com.google.protobuf.kotlin.OptionInternal.computeSize(): Int {
+ var __result = 0
+ if (name.isNotEmpty()) {
+ __result += kotlinx.rpc.protobuf.internal.WireSize.string(name).let { kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it }
+ }
+
+ if (presenceMask[0]) {
+ __result += value.asInternal()._size.let { kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it }
+ }
+
+ return __result
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.Option.asInternal(): com.google.protobuf.kotlin.OptionInternal {
+ return this as? com.google.protobuf.kotlin.OptionInternal ?: error("Message ${this::class.simpleName} is a non-internal message type.")
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.Syntax.Companion.fromNumber(number: Int): com.google.protobuf.kotlin.Syntax {
+ return when (number) {
+ 0 -> {
+ com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2
+ }
+
+ 1 -> {
+ com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO3
+ }
+
+ 2 -> {
+ com.google.protobuf.kotlin.Syntax.SYNTAX_EDITIONS
+ }
+
+ else -> {
+ com.google.protobuf.kotlin.Syntax.UNRECOGNIZED(number)
+ }
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.Field.Kind.Companion.fromNumber(number: Int): com.google.protobuf.kotlin.Field.Kind {
+ return when (number) {
+ 0 -> {
+ com.google.protobuf.kotlin.Field.Kind.TYPE_UNKNOWN
+ }
+
+ 1 -> {
+ com.google.protobuf.kotlin.Field.Kind.TYPE_DOUBLE
+ }
+
+ 2 -> {
+ com.google.protobuf.kotlin.Field.Kind.TYPE_FLOAT
+ }
+
+ 3 -> {
+ com.google.protobuf.kotlin.Field.Kind.TYPE_INT64
+ }
+
+ 4 -> {
+ com.google.protobuf.kotlin.Field.Kind.TYPE_UINT64
+ }
+
+ 5 -> {
+ com.google.protobuf.kotlin.Field.Kind.TYPE_INT32
+ }
+
+ 6 -> {
+ com.google.protobuf.kotlin.Field.Kind.TYPE_FIXED64
+ }
+
+ 7 -> {
+ com.google.protobuf.kotlin.Field.Kind.TYPE_FIXED32
+ }
+
+ 8 -> {
+ com.google.protobuf.kotlin.Field.Kind.TYPE_BOOL
+ }
+
+ 9 -> {
+ com.google.protobuf.kotlin.Field.Kind.TYPE_STRING
+ }
+
+ 10 -> {
+ com.google.protobuf.kotlin.Field.Kind.TYPE_GROUP
+ }
+
+ 11 -> {
+ com.google.protobuf.kotlin.Field.Kind.TYPE_MESSAGE
+ }
+
+ 12 -> {
+ com.google.protobuf.kotlin.Field.Kind.TYPE_BYTES
+ }
+
+ 13 -> {
+ com.google.protobuf.kotlin.Field.Kind.TYPE_UINT32
+ }
+
+ 14 -> {
+ com.google.protobuf.kotlin.Field.Kind.TYPE_ENUM
+ }
+
+ 15 -> {
+ com.google.protobuf.kotlin.Field.Kind.TYPE_SFIXED32
+ }
+
+ 16 -> {
+ com.google.protobuf.kotlin.Field.Kind.TYPE_SFIXED64
+ }
+
+ 17 -> {
+ com.google.protobuf.kotlin.Field.Kind.TYPE_SINT32
+ }
+
+ 18 -> {
+ com.google.protobuf.kotlin.Field.Kind.TYPE_SINT64
+ }
+
+ else -> {
+ com.google.protobuf.kotlin.Field.Kind.UNRECOGNIZED(number)
+ }
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.Field.Cardinality.Companion.fromNumber(number: Int): com.google.protobuf.kotlin.Field.Cardinality {
+ return when (number) {
+ 0 -> {
+ com.google.protobuf.kotlin.Field.Cardinality.CARDINALITY_UNKNOWN
+ }
+
+ 1 -> {
+ com.google.protobuf.kotlin.Field.Cardinality.CARDINALITY_OPTIONAL
+ }
+
+ 2 -> {
+ com.google.protobuf.kotlin.Field.Cardinality.CARDINALITY_REQUIRED
+ }
+
+ 3 -> {
+ com.google.protobuf.kotlin.Field.Cardinality.CARDINALITY_REPEATED
+ }
+
+ else -> {
+ com.google.protobuf.kotlin.Field.Cardinality.UNRECOGNIZED(number)
+ }
+ }
+}
+
diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Wrappers.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Wrappers.kt
new file mode 100644
index 00000000..222bee21
--- /dev/null
+++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Wrappers.kt
@@ -0,0 +1,754 @@
+@file:OptIn(ExperimentalRpcApi::class, kotlinx.rpc.internal.utils.InternalRpcApi::class)
+package com.google.protobuf.kotlin
+
+import kotlinx.rpc.internal.utils.*
+import kotlinx.rpc.protobuf.input.stream.asInputStream
+import kotlinx.rpc.protobuf.internal.*
+
+public class DoubleValueInternal: com.google.protobuf.kotlin.DoubleValue, kotlinx.rpc.protobuf.internal.InternalMessage(fieldsWithPresence = 0) {
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public override val _size: Int by lazy { computeSize() }
+
+ public override var value: Double by MsgFieldDelegate { 0.0 }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec {
+ public override fun encode(value: com.google.protobuf.kotlin.DoubleValue): kotlinx.rpc.protobuf.input.stream.InputStream {
+ val buffer = kotlinx.io.Buffer()
+ val encoder = kotlinx.rpc.protobuf.internal.WireEncoder(buffer)
+ kotlinx.rpc.protobuf.internal.checkForPlatformEncodeException {
+ value.asInternal().encodeWith(encoder)
+ }
+ encoder.flush()
+ return buffer.asInputStream()
+ }
+
+ public override fun decode(stream: kotlinx.rpc.protobuf.input.stream.InputStream): com.google.protobuf.kotlin.DoubleValue {
+ kotlinx.rpc.protobuf.internal.WireDecoder(stream).use {
+ val msg = com.google.protobuf.kotlin.DoubleValueInternal()
+ kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException {
+ com.google.protobuf.kotlin.DoubleValueInternal.decodeWith(msg, it)
+ }
+ msg.checkRequiredFields()
+ return msg
+ }
+ }
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public companion object
+}
+
+public class FloatValueInternal: com.google.protobuf.kotlin.FloatValue, kotlinx.rpc.protobuf.internal.InternalMessage(fieldsWithPresence = 0) {
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public override val _size: Int by lazy { computeSize() }
+
+ public override var value: Float by MsgFieldDelegate { 0.0f }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec {
+ public override fun encode(value: com.google.protobuf.kotlin.FloatValue): kotlinx.rpc.protobuf.input.stream.InputStream {
+ val buffer = kotlinx.io.Buffer()
+ val encoder = kotlinx.rpc.protobuf.internal.WireEncoder(buffer)
+ kotlinx.rpc.protobuf.internal.checkForPlatformEncodeException {
+ value.asInternal().encodeWith(encoder)
+ }
+ encoder.flush()
+ return buffer.asInputStream()
+ }
+
+ public override fun decode(stream: kotlinx.rpc.protobuf.input.stream.InputStream): com.google.protobuf.kotlin.FloatValue {
+ kotlinx.rpc.protobuf.internal.WireDecoder(stream).use {
+ val msg = com.google.protobuf.kotlin.FloatValueInternal()
+ kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException {
+ com.google.protobuf.kotlin.FloatValueInternal.decodeWith(msg, it)
+ }
+ msg.checkRequiredFields()
+ return msg
+ }
+ }
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public companion object
+}
+
+public class Int64ValueInternal: com.google.protobuf.kotlin.Int64Value, kotlinx.rpc.protobuf.internal.InternalMessage(fieldsWithPresence = 0) {
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public override val _size: Int by lazy { computeSize() }
+
+ public override var value: Long by MsgFieldDelegate { 0L }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec {
+ public override fun encode(value: com.google.protobuf.kotlin.Int64Value): kotlinx.rpc.protobuf.input.stream.InputStream {
+ val buffer = kotlinx.io.Buffer()
+ val encoder = kotlinx.rpc.protobuf.internal.WireEncoder(buffer)
+ kotlinx.rpc.protobuf.internal.checkForPlatformEncodeException {
+ value.asInternal().encodeWith(encoder)
+ }
+ encoder.flush()
+ return buffer.asInputStream()
+ }
+
+ public override fun decode(stream: kotlinx.rpc.protobuf.input.stream.InputStream): com.google.protobuf.kotlin.Int64Value {
+ kotlinx.rpc.protobuf.internal.WireDecoder(stream).use {
+ val msg = com.google.protobuf.kotlin.Int64ValueInternal()
+ kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException {
+ com.google.protobuf.kotlin.Int64ValueInternal.decodeWith(msg, it)
+ }
+ msg.checkRequiredFields()
+ return msg
+ }
+ }
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public companion object
+}
+
+public class UInt64ValueInternal: com.google.protobuf.kotlin.UInt64Value, kotlinx.rpc.protobuf.internal.InternalMessage(fieldsWithPresence = 0) {
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public override val _size: Int by lazy { computeSize() }
+
+ public override var value: ULong by MsgFieldDelegate { 0uL }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec {
+ public override fun encode(value: com.google.protobuf.kotlin.UInt64Value): kotlinx.rpc.protobuf.input.stream.InputStream {
+ val buffer = kotlinx.io.Buffer()
+ val encoder = kotlinx.rpc.protobuf.internal.WireEncoder(buffer)
+ kotlinx.rpc.protobuf.internal.checkForPlatformEncodeException {
+ value.asInternal().encodeWith(encoder)
+ }
+ encoder.flush()
+ return buffer.asInputStream()
+ }
+
+ public override fun decode(stream: kotlinx.rpc.protobuf.input.stream.InputStream): com.google.protobuf.kotlin.UInt64Value {
+ kotlinx.rpc.protobuf.internal.WireDecoder(stream).use {
+ val msg = com.google.protobuf.kotlin.UInt64ValueInternal()
+ kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException {
+ com.google.protobuf.kotlin.UInt64ValueInternal.decodeWith(msg, it)
+ }
+ msg.checkRequiredFields()
+ return msg
+ }
+ }
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public companion object
+}
+
+public class Int32ValueInternal: com.google.protobuf.kotlin.Int32Value, kotlinx.rpc.protobuf.internal.InternalMessage(fieldsWithPresence = 0) {
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public override val _size: Int by lazy { computeSize() }
+
+ public override var value: Int by MsgFieldDelegate { 0 }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec {
+ public override fun encode(value: com.google.protobuf.kotlin.Int32Value): kotlinx.rpc.protobuf.input.stream.InputStream {
+ val buffer = kotlinx.io.Buffer()
+ val encoder = kotlinx.rpc.protobuf.internal.WireEncoder(buffer)
+ kotlinx.rpc.protobuf.internal.checkForPlatformEncodeException {
+ value.asInternal().encodeWith(encoder)
+ }
+ encoder.flush()
+ return buffer.asInputStream()
+ }
+
+ public override fun decode(stream: kotlinx.rpc.protobuf.input.stream.InputStream): com.google.protobuf.kotlin.Int32Value {
+ kotlinx.rpc.protobuf.internal.WireDecoder(stream).use {
+ val msg = com.google.protobuf.kotlin.Int32ValueInternal()
+ kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException {
+ com.google.protobuf.kotlin.Int32ValueInternal.decodeWith(msg, it)
+ }
+ msg.checkRequiredFields()
+ return msg
+ }
+ }
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public companion object
+}
+
+public class UInt32ValueInternal: com.google.protobuf.kotlin.UInt32Value, kotlinx.rpc.protobuf.internal.InternalMessage(fieldsWithPresence = 0) {
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public override val _size: Int by lazy { computeSize() }
+
+ public override var value: UInt by MsgFieldDelegate { 0u }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec {
+ public override fun encode(value: com.google.protobuf.kotlin.UInt32Value): kotlinx.rpc.protobuf.input.stream.InputStream {
+ val buffer = kotlinx.io.Buffer()
+ val encoder = kotlinx.rpc.protobuf.internal.WireEncoder(buffer)
+ kotlinx.rpc.protobuf.internal.checkForPlatformEncodeException {
+ value.asInternal().encodeWith(encoder)
+ }
+ encoder.flush()
+ return buffer.asInputStream()
+ }
+
+ public override fun decode(stream: kotlinx.rpc.protobuf.input.stream.InputStream): com.google.protobuf.kotlin.UInt32Value {
+ kotlinx.rpc.protobuf.internal.WireDecoder(stream).use {
+ val msg = com.google.protobuf.kotlin.UInt32ValueInternal()
+ kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException {
+ com.google.protobuf.kotlin.UInt32ValueInternal.decodeWith(msg, it)
+ }
+ msg.checkRequiredFields()
+ return msg
+ }
+ }
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public companion object
+}
+
+public class BoolValueInternal: com.google.protobuf.kotlin.BoolValue, kotlinx.rpc.protobuf.internal.InternalMessage(fieldsWithPresence = 0) {
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public override val _size: Int by lazy { computeSize() }
+
+ public override var value: Boolean by MsgFieldDelegate { false }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec {
+ public override fun encode(value: com.google.protobuf.kotlin.BoolValue): kotlinx.rpc.protobuf.input.stream.InputStream {
+ val buffer = kotlinx.io.Buffer()
+ val encoder = kotlinx.rpc.protobuf.internal.WireEncoder(buffer)
+ kotlinx.rpc.protobuf.internal.checkForPlatformEncodeException {
+ value.asInternal().encodeWith(encoder)
+ }
+ encoder.flush()
+ return buffer.asInputStream()
+ }
+
+ public override fun decode(stream: kotlinx.rpc.protobuf.input.stream.InputStream): com.google.protobuf.kotlin.BoolValue {
+ kotlinx.rpc.protobuf.internal.WireDecoder(stream).use {
+ val msg = com.google.protobuf.kotlin.BoolValueInternal()
+ kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException {
+ com.google.protobuf.kotlin.BoolValueInternal.decodeWith(msg, it)
+ }
+ msg.checkRequiredFields()
+ return msg
+ }
+ }
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public companion object
+}
+
+public class StringValueInternal: com.google.protobuf.kotlin.StringValue, kotlinx.rpc.protobuf.internal.InternalMessage(fieldsWithPresence = 0) {
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public override val _size: Int by lazy { computeSize() }
+
+ public override var value: String by MsgFieldDelegate { "" }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec {
+ public override fun encode(value: com.google.protobuf.kotlin.StringValue): kotlinx.rpc.protobuf.input.stream.InputStream {
+ val buffer = kotlinx.io.Buffer()
+ val encoder = kotlinx.rpc.protobuf.internal.WireEncoder(buffer)
+ kotlinx.rpc.protobuf.internal.checkForPlatformEncodeException {
+ value.asInternal().encodeWith(encoder)
+ }
+ encoder.flush()
+ return buffer.asInputStream()
+ }
+
+ public override fun decode(stream: kotlinx.rpc.protobuf.input.stream.InputStream): com.google.protobuf.kotlin.StringValue {
+ kotlinx.rpc.protobuf.internal.WireDecoder(stream).use {
+ val msg = com.google.protobuf.kotlin.StringValueInternal()
+ kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException {
+ com.google.protobuf.kotlin.StringValueInternal.decodeWith(msg, it)
+ }
+ msg.checkRequiredFields()
+ return msg
+ }
+ }
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public companion object
+}
+
+public class BytesValueInternal: com.google.protobuf.kotlin.BytesValue, kotlinx.rpc.protobuf.internal.InternalMessage(fieldsWithPresence = 0) {
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public override val _size: Int by lazy { computeSize() }
+
+ public override var value: ByteArray by MsgFieldDelegate { byteArrayOf() }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec {
+ public override fun encode(value: com.google.protobuf.kotlin.BytesValue): kotlinx.rpc.protobuf.input.stream.InputStream {
+ val buffer = kotlinx.io.Buffer()
+ val encoder = kotlinx.rpc.protobuf.internal.WireEncoder(buffer)
+ kotlinx.rpc.protobuf.internal.checkForPlatformEncodeException {
+ value.asInternal().encodeWith(encoder)
+ }
+ encoder.flush()
+ return buffer.asInputStream()
+ }
+
+ public override fun decode(stream: kotlinx.rpc.protobuf.input.stream.InputStream): com.google.protobuf.kotlin.BytesValue {
+ kotlinx.rpc.protobuf.internal.WireDecoder(stream).use {
+ val msg = com.google.protobuf.kotlin.BytesValueInternal()
+ kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException {
+ com.google.protobuf.kotlin.BytesValueInternal.decodeWith(msg, it)
+ }
+ msg.checkRequiredFields()
+ return msg
+ }
+ }
+ }
+
+ @kotlinx.rpc.internal.utils.InternalRpcApi
+ public companion object
+}
+
+public operator fun com.google.protobuf.kotlin.DoubleValue.Companion.invoke(body: com.google.protobuf.kotlin.DoubleValueInternal.() -> Unit): com.google.protobuf.kotlin.DoubleValue {
+ val msg = com.google.protobuf.kotlin.DoubleValueInternal().apply(body)
+ msg.checkRequiredFields()
+ return msg
+}
+
+public operator fun com.google.protobuf.kotlin.FloatValue.Companion.invoke(body: com.google.protobuf.kotlin.FloatValueInternal.() -> Unit): com.google.protobuf.kotlin.FloatValue {
+ val msg = com.google.protobuf.kotlin.FloatValueInternal().apply(body)
+ msg.checkRequiredFields()
+ return msg
+}
+
+public operator fun com.google.protobuf.kotlin.Int64Value.Companion.invoke(body: com.google.protobuf.kotlin.Int64ValueInternal.() -> Unit): com.google.protobuf.kotlin.Int64Value {
+ val msg = com.google.protobuf.kotlin.Int64ValueInternal().apply(body)
+ msg.checkRequiredFields()
+ return msg
+}
+
+public operator fun com.google.protobuf.kotlin.UInt64Value.Companion.invoke(body: com.google.protobuf.kotlin.UInt64ValueInternal.() -> Unit): com.google.protobuf.kotlin.UInt64Value {
+ val msg = com.google.protobuf.kotlin.UInt64ValueInternal().apply(body)
+ msg.checkRequiredFields()
+ return msg
+}
+
+public operator fun com.google.protobuf.kotlin.Int32Value.Companion.invoke(body: com.google.protobuf.kotlin.Int32ValueInternal.() -> Unit): com.google.protobuf.kotlin.Int32Value {
+ val msg = com.google.protobuf.kotlin.Int32ValueInternal().apply(body)
+ msg.checkRequiredFields()
+ return msg
+}
+
+public operator fun com.google.protobuf.kotlin.UInt32Value.Companion.invoke(body: com.google.protobuf.kotlin.UInt32ValueInternal.() -> Unit): com.google.protobuf.kotlin.UInt32Value {
+ val msg = com.google.protobuf.kotlin.UInt32ValueInternal().apply(body)
+ msg.checkRequiredFields()
+ return msg
+}
+
+public operator fun com.google.protobuf.kotlin.BoolValue.Companion.invoke(body: com.google.protobuf.kotlin.BoolValueInternal.() -> Unit): com.google.protobuf.kotlin.BoolValue {
+ val msg = com.google.protobuf.kotlin.BoolValueInternal().apply(body)
+ msg.checkRequiredFields()
+ return msg
+}
+
+public operator fun com.google.protobuf.kotlin.StringValue.Companion.invoke(body: com.google.protobuf.kotlin.StringValueInternal.() -> Unit): com.google.protobuf.kotlin.StringValue {
+ val msg = com.google.protobuf.kotlin.StringValueInternal().apply(body)
+ msg.checkRequiredFields()
+ return msg
+}
+
+public operator fun com.google.protobuf.kotlin.BytesValue.Companion.invoke(body: com.google.protobuf.kotlin.BytesValueInternal.() -> Unit): com.google.protobuf.kotlin.BytesValue {
+ val msg = com.google.protobuf.kotlin.BytesValueInternal().apply(body)
+ msg.checkRequiredFields()
+ return msg
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.DoubleValueInternal.checkRequiredFields() {
+ // no required fields to check
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.DoubleValueInternal.encodeWith(encoder: kotlinx.rpc.protobuf.internal.WireEncoder) {
+ if (value != 0.0) {
+ encoder.writeDouble(fieldNr = 1, value = value)
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.DoubleValueInternal.Companion.decodeWith(msg: com.google.protobuf.kotlin.DoubleValueInternal, decoder: kotlinx.rpc.protobuf.internal.WireDecoder) {
+ while (true) {
+ val tag = decoder.readTag() ?: break // EOF, we read the whole message
+ when {
+ tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> {
+ msg.value = decoder.readDouble()
+ }
+
+ else -> {
+ // we are currently just skipping unknown fields (KRPC-191)
+ decoder.skipValue(tag.wireType)
+ }
+ }
+ }
+}
+
+private fun com.google.protobuf.kotlin.DoubleValueInternal.computeSize(): Int {
+ var __result = 0
+ if (value != 0.0) {
+ __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.FIXED64) + kotlinx.rpc.protobuf.internal.WireSize.double(value))
+ }
+
+ return __result
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.DoubleValue.asInternal(): com.google.protobuf.kotlin.DoubleValueInternal {
+ return this as? com.google.protobuf.kotlin.DoubleValueInternal ?: error("Message ${this::class.simpleName} is a non-internal message type.")
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.FloatValueInternal.checkRequiredFields() {
+ // no required fields to check
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.FloatValueInternal.encodeWith(encoder: kotlinx.rpc.protobuf.internal.WireEncoder) {
+ if (value != 0.0f) {
+ encoder.writeFloat(fieldNr = 1, value = value)
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.FloatValueInternal.Companion.decodeWith(msg: com.google.protobuf.kotlin.FloatValueInternal, decoder: kotlinx.rpc.protobuf.internal.WireDecoder) {
+ while (true) {
+ val tag = decoder.readTag() ?: break // EOF, we read the whole message
+ when {
+ tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> {
+ msg.value = decoder.readFloat()
+ }
+
+ else -> {
+ // we are currently just skipping unknown fields (KRPC-191)
+ decoder.skipValue(tag.wireType)
+ }
+ }
+ }
+}
+
+private fun com.google.protobuf.kotlin.FloatValueInternal.computeSize(): Int {
+ var __result = 0
+ if (value != 0.0f) {
+ __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.FIXED32) + kotlinx.rpc.protobuf.internal.WireSize.float(value))
+ }
+
+ return __result
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.FloatValue.asInternal(): com.google.protobuf.kotlin.FloatValueInternal {
+ return this as? com.google.protobuf.kotlin.FloatValueInternal ?: error("Message ${this::class.simpleName} is a non-internal message type.")
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.Int64ValueInternal.checkRequiredFields() {
+ // no required fields to check
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.Int64ValueInternal.encodeWith(encoder: kotlinx.rpc.protobuf.internal.WireEncoder) {
+ if (value != 0L) {
+ encoder.writeInt64(fieldNr = 1, value = value)
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.Int64ValueInternal.Companion.decodeWith(msg: com.google.protobuf.kotlin.Int64ValueInternal, decoder: kotlinx.rpc.protobuf.internal.WireDecoder) {
+ while (true) {
+ val tag = decoder.readTag() ?: break // EOF, we read the whole message
+ when {
+ tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> {
+ msg.value = decoder.readInt64()
+ }
+
+ else -> {
+ // we are currently just skipping unknown fields (KRPC-191)
+ decoder.skipValue(tag.wireType)
+ }
+ }
+ }
+}
+
+private fun com.google.protobuf.kotlin.Int64ValueInternal.computeSize(): Int {
+ var __result = 0
+ if (value != 0L) {
+ __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.int64(value))
+ }
+
+ return __result
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.Int64Value.asInternal(): com.google.protobuf.kotlin.Int64ValueInternal {
+ return this as? com.google.protobuf.kotlin.Int64ValueInternal ?: error("Message ${this::class.simpleName} is a non-internal message type.")
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.UInt64ValueInternal.checkRequiredFields() {
+ // no required fields to check
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.UInt64ValueInternal.encodeWith(encoder: kotlinx.rpc.protobuf.internal.WireEncoder) {
+ if (value != 0uL) {
+ encoder.writeUInt64(fieldNr = 1, value = value)
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.UInt64ValueInternal.Companion.decodeWith(msg: com.google.protobuf.kotlin.UInt64ValueInternal, decoder: kotlinx.rpc.protobuf.internal.WireDecoder) {
+ while (true) {
+ val tag = decoder.readTag() ?: break // EOF, we read the whole message
+ when {
+ tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> {
+ msg.value = decoder.readUInt64()
+ }
+
+ else -> {
+ // we are currently just skipping unknown fields (KRPC-191)
+ decoder.skipValue(tag.wireType)
+ }
+ }
+ }
+}
+
+private fun com.google.protobuf.kotlin.UInt64ValueInternal.computeSize(): Int {
+ var __result = 0
+ if (value != 0uL) {
+ __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.uInt64(value))
+ }
+
+ return __result
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.UInt64Value.asInternal(): com.google.protobuf.kotlin.UInt64ValueInternal {
+ return this as? com.google.protobuf.kotlin.UInt64ValueInternal ?: error("Message ${this::class.simpleName} is a non-internal message type.")
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.Int32ValueInternal.checkRequiredFields() {
+ // no required fields to check
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.Int32ValueInternal.encodeWith(encoder: kotlinx.rpc.protobuf.internal.WireEncoder) {
+ if (value != 0) {
+ encoder.writeInt32(fieldNr = 1, value = value)
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.Int32ValueInternal.Companion.decodeWith(msg: com.google.protobuf.kotlin.Int32ValueInternal, decoder: kotlinx.rpc.protobuf.internal.WireDecoder) {
+ while (true) {
+ val tag = decoder.readTag() ?: break // EOF, we read the whole message
+ when {
+ tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> {
+ msg.value = decoder.readInt32()
+ }
+
+ else -> {
+ // we are currently just skipping unknown fields (KRPC-191)
+ decoder.skipValue(tag.wireType)
+ }
+ }
+ }
+}
+
+private fun com.google.protobuf.kotlin.Int32ValueInternal.computeSize(): Int {
+ var __result = 0
+ if (value != 0) {
+ __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.int32(value))
+ }
+
+ return __result
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.Int32Value.asInternal(): com.google.protobuf.kotlin.Int32ValueInternal {
+ return this as? com.google.protobuf.kotlin.Int32ValueInternal ?: error("Message ${this::class.simpleName} is a non-internal message type.")
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.UInt32ValueInternal.checkRequiredFields() {
+ // no required fields to check
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.UInt32ValueInternal.encodeWith(encoder: kotlinx.rpc.protobuf.internal.WireEncoder) {
+ if (value != 0u) {
+ encoder.writeUInt32(fieldNr = 1, value = value)
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.UInt32ValueInternal.Companion.decodeWith(msg: com.google.protobuf.kotlin.UInt32ValueInternal, decoder: kotlinx.rpc.protobuf.internal.WireDecoder) {
+ while (true) {
+ val tag = decoder.readTag() ?: break // EOF, we read the whole message
+ when {
+ tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> {
+ msg.value = decoder.readUInt32()
+ }
+
+ else -> {
+ // we are currently just skipping unknown fields (KRPC-191)
+ decoder.skipValue(tag.wireType)
+ }
+ }
+ }
+}
+
+private fun com.google.protobuf.kotlin.UInt32ValueInternal.computeSize(): Int {
+ var __result = 0
+ if (value != 0u) {
+ __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.uInt32(value))
+ }
+
+ return __result
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.UInt32Value.asInternal(): com.google.protobuf.kotlin.UInt32ValueInternal {
+ return this as? com.google.protobuf.kotlin.UInt32ValueInternal ?: error("Message ${this::class.simpleName} is a non-internal message type.")
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.BoolValueInternal.checkRequiredFields() {
+ // no required fields to check
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.BoolValueInternal.encodeWith(encoder: kotlinx.rpc.protobuf.internal.WireEncoder) {
+ if (value != false) {
+ encoder.writeBool(fieldNr = 1, value = value)
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.BoolValueInternal.Companion.decodeWith(msg: com.google.protobuf.kotlin.BoolValueInternal, decoder: kotlinx.rpc.protobuf.internal.WireDecoder) {
+ while (true) {
+ val tag = decoder.readTag() ?: break // EOF, we read the whole message
+ when {
+ tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> {
+ msg.value = decoder.readBool()
+ }
+
+ else -> {
+ // we are currently just skipping unknown fields (KRPC-191)
+ decoder.skipValue(tag.wireType)
+ }
+ }
+ }
+}
+
+private fun com.google.protobuf.kotlin.BoolValueInternal.computeSize(): Int {
+ var __result = 0
+ if (value != false) {
+ __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.bool(value))
+ }
+
+ return __result
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.BoolValue.asInternal(): com.google.protobuf.kotlin.BoolValueInternal {
+ return this as? com.google.protobuf.kotlin.BoolValueInternal ?: error("Message ${this::class.simpleName} is a non-internal message type.")
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.StringValueInternal.checkRequiredFields() {
+ // no required fields to check
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.StringValueInternal.encodeWith(encoder: kotlinx.rpc.protobuf.internal.WireEncoder) {
+ if (value.isNotEmpty()) {
+ encoder.writeString(fieldNr = 1, value = value)
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.StringValueInternal.Companion.decodeWith(msg: com.google.protobuf.kotlin.StringValueInternal, decoder: kotlinx.rpc.protobuf.internal.WireDecoder) {
+ while (true) {
+ val tag = decoder.readTag() ?: break // EOF, we read the whole message
+ when {
+ tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ msg.value = decoder.readString()
+ }
+
+ else -> {
+ // we are currently just skipping unknown fields (KRPC-191)
+ decoder.skipValue(tag.wireType)
+ }
+ }
+ }
+}
+
+private fun com.google.protobuf.kotlin.StringValueInternal.computeSize(): Int {
+ var __result = 0
+ if (value.isNotEmpty()) {
+ __result += kotlinx.rpc.protobuf.internal.WireSize.string(value).let { kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it }
+ }
+
+ return __result
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.StringValue.asInternal(): com.google.protobuf.kotlin.StringValueInternal {
+ return this as? com.google.protobuf.kotlin.StringValueInternal ?: error("Message ${this::class.simpleName} is a non-internal message type.")
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.BytesValueInternal.checkRequiredFields() {
+ // no required fields to check
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.BytesValueInternal.encodeWith(encoder: kotlinx.rpc.protobuf.internal.WireEncoder) {
+ if (value.isNotEmpty()) {
+ encoder.writeBytes(fieldNr = 1, value = value)
+ }
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.BytesValueInternal.Companion.decodeWith(msg: com.google.protobuf.kotlin.BytesValueInternal, decoder: kotlinx.rpc.protobuf.internal.WireDecoder) {
+ while (true) {
+ val tag = decoder.readTag() ?: break // EOF, we read the whole message
+ when {
+ tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
+ msg.value = decoder.readBytes()
+ }
+
+ else -> {
+ // we are currently just skipping unknown fields (KRPC-191)
+ decoder.skipValue(tag.wireType)
+ }
+ }
+ }
+}
+
+private fun com.google.protobuf.kotlin.BytesValueInternal.computeSize(): Int {
+ var __result = 0
+ if (value.isNotEmpty()) {
+ __result += kotlinx.rpc.protobuf.internal.WireSize.bytes(value).let { kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it }
+ }
+
+ return __result
+}
+
+@kotlinx.rpc.internal.utils.InternalRpcApi
+internal fun com.google.protobuf.kotlin.BytesValue.asInternal(): com.google.protobuf.kotlin.BytesValueInternal {
+ return this as? com.google.protobuf.kotlin.BytesValueInternal ?: error("Message ${this::class.simpleName} is a non-internal message type.")
+}
+
diff --git a/protobuf/protobuf-core/src/commonMain/kotlin/com/google/protobuf/kotlin/duration.kt b/protobuf/protobuf-core/src/commonMain/kotlin/com/google/protobuf/kotlin/duration.kt
new file mode 100644
index 00000000..1020e592
--- /dev/null
+++ b/protobuf/protobuf-core/src/commonMain/kotlin/com/google/protobuf/kotlin/duration.kt
@@ -0,0 +1,15 @@
+/*
+ * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
+ */
+
+package com.google.protobuf.kotlin
+
+import kotlin.time.Duration.Companion.nanoseconds
+import kotlin.time.Duration.Companion.seconds
+
+public fun Duration.toKotlinDuration(): kotlin.time.Duration = seconds.seconds + nanos.nanoseconds
+
+public fun kotlin.time.Duration.toProtobufDuration(): Duration = Duration {
+ seconds = this@toProtobufDuration.inWholeSeconds
+ nanos = (this@toProtobufDuration.inWholeNanoseconds - seconds.seconds.inWholeNanoseconds).toInt()
+}
diff --git a/protobuf/protobuf-core/src/commonMain/kotlin/com/google/protobuf/kotlin/timestamp.kt b/protobuf/protobuf-core/src/commonMain/kotlin/com/google/protobuf/kotlin/timestamp.kt
new file mode 100644
index 00000000..b930ebf1
--- /dev/null
+++ b/protobuf/protobuf-core/src/commonMain/kotlin/com/google/protobuf/kotlin/timestamp.kt
@@ -0,0 +1,17 @@
+/*
+ * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
+ */
+
+@file:OptIn(ExperimentalTime::class)
+
+package com.google.protobuf.kotlin
+
+import kotlin.time.ExperimentalTime
+import kotlin.time.Instant
+
+public fun Timestamp.toInstant(): Instant = Instant.fromEpochSeconds(seconds, nanos)
+
+public fun Instant.toTimestamp(): Timestamp = Timestamp {
+ seconds = epochSeconds
+ nanos = nanosecondsOfSecond
+}
diff --git a/protobuf/protobuf-core/src/commonMain/proto/well-known-types.proto b/protobuf/protobuf-core/src/commonMain/proto/well-known-types.proto
new file mode 100644
index 00000000..9bfdb4ae
--- /dev/null
+++ b/protobuf/protobuf-core/src/commonMain/proto/well-known-types.proto
@@ -0,0 +1,34 @@
+edition = "2023";
+
+// https://protobuf.dev/reference/protobuf/google.protobuf
+
+// Any
+import "google/protobuf/any.proto";
+
+// Api, Method, Mixin
+import "google/protobuf/api.proto";
+
+// Duration
+import "google/protobuf/duration.proto";
+
+// Timestamp
+import "google/protobuf/timestamp.proto";
+
+// Empty
+import "google/protobuf/empty.proto";
+
+// DoubleValue, FloatValue, Int64Value, UInt64Value, Int32Value,
+// UInt32Value, BoolValue, StringValue, BytesValue
+import "google/protobuf/wrappers.proto";
+
+// Type, Field, Kind, Cardinality, Enum, EnumValue, Option, Syntax
+import "google/protobuf/type.proto";
+
+// FieldMask
+import "google/protobuf/field_mask.proto";
+
+// SourceContext
+import "google/protobuf/source_context.proto";
+
+// Struct, Value, NullValue, ListValue
+import "google/protobuf/struct.proto";
diff --git a/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/AModelToKotlinCommonGenerator.kt b/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/AModelToKotlinCommonGenerator.kt
index 1ccd0277..e7d9f462 100644
--- a/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/AModelToKotlinCommonGenerator.kt
+++ b/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/AModelToKotlinCommonGenerator.kt
@@ -22,6 +22,7 @@ const val WITH_CODEC_ANNO = "kotlinx.rpc.grpc.codec.WithCodec"
abstract class AModelToKotlinCommonGenerator(
protected val model: Model,
protected val logger: Logger,
+ private val explicitApiModeEnabled: Boolean,
) {
protected abstract fun CodeGenerator.generatePublicDeclaredEntities(fileDeclaration: FileDeclaration)
protected abstract fun CodeGenerator.generateInternalDeclaredEntities(fileDeclaration: FileDeclaration)
@@ -50,7 +51,7 @@ abstract class AModelToKotlinCommonGenerator(
private fun FileDeclaration.generatePublicKotlinFile(): FileGenerator {
currentPackage = packageName
- return file(logger = logger) {
+ return file(logger = logger, explicitApiModeEnabled = explicitApiModeEnabled) {
filename = this@generatePublicKotlinFile.name
packageName = this@generatePublicKotlinFile.packageName.safeFullName()
packagePath = this@generatePublicKotlinFile.packageName.safeFullName()
@@ -74,7 +75,7 @@ abstract class AModelToKotlinCommonGenerator(
private fun FileDeclaration.generateInternalKotlinFile(): FileGenerator {
currentPackage = packageName
- return file(logger = logger) {
+ return file(logger = logger, explicitApiModeEnabled = explicitApiModeEnabled) {
filename = this@generateInternalKotlinFile.name
packageName = this@generateInternalKotlinFile.packageName.safeFullName()
packagePath =
diff --git a/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/CodeGenerator.kt b/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/CodeGenerator.kt
index 55c25776..ef80a99c 100644
--- a/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/CodeGenerator.kt
+++ b/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/CodeGenerator.kt
@@ -7,15 +7,16 @@ package kotlinx.rpc.protoc.gen.core
import org.slf4j.Logger
import org.slf4j.helpers.NOPLogger
-
open class CodeGenerator(
private val indent: String,
private val builder: StringBuilder = StringBuilder(),
protected val logger: Logger = NOPLogger.NOP_LOGGER,
+ protected val explicitApiModeEnabled: Boolean,
) {
private var isEmpty: Boolean = true
private var result: String? = null
private var lastIsDeclaration: Boolean = false
+ private var needsNewLineAfterDeclaration: Boolean = true
@Suppress("FunctionName")
private fun _append(
@@ -27,7 +28,10 @@ open class CodeGenerator(
var addedNewLineBefore = false
if (lastIsDeclaration) {
- builder.appendLine()
+ if (needsNewLineAfterDeclaration) {
+ builder.appendLine()
+ }
+
lastIsDeclaration = false
addedNewLineBefore = true
} else if (newLineIfAbsent) {
@@ -49,6 +53,7 @@ open class CodeGenerator(
}
isEmpty = false
+ needsNewLineAfterDeclaration = true
}
private fun append(value: String) {
@@ -64,7 +69,7 @@ open class CodeGenerator(
}
private fun withNextIndent(block: CodeGenerator.() -> Unit) {
- CodeGenerator("$indent$ONE_INDENT", builder, logger).block()
+ CodeGenerator("$indent$ONE_INDENT", builder, logger, explicitApiModeEnabled).block()
}
fun scope(
@@ -126,12 +131,18 @@ open class CodeGenerator(
block: (CodeGenerator.() -> Unit)? = null,
) {
if (block == null) {
- newLine()
- lastIsDeclaration = true
+ if (nlAfterClosed) {
+ newLine()
+ }
+ lastIsDeclaration = nlAfterClosed
return
}
- val nested = CodeGenerator("$indent$ONE_INDENT", logger = logger).apply(block)
+ val nested = CodeGenerator(
+ indent = "$indent$ONE_INDENT",
+ logger = logger,
+ explicitApiModeEnabled = explicitApiModeEnabled,
+ ).apply(block)
if (nested.isEmpty) {
newLine()
@@ -160,16 +171,38 @@ open class CodeGenerator(
name: String,
modifiers: String = "",
contextReceiver: String = "",
- type: String = "",
- delegate: Boolean = false,
+ annotations: List = emptyList(),
+ type: String,
+ propertyInitializer: PropertyInitializer = PropertyInitializer.PLAIN,
value: String = "",
+ isVar: Boolean = false,
+ needsNewLineAfterDeclaration: Boolean = true,
block: (CodeGenerator.() -> Unit)? = null,
) {
- val modifiersString = if (modifiers.isEmpty()) "" else "$modifiers "
+ for (annotation in annotations) {
+ addLine(annotation)
+ }
+
+ val modifiersString = (if (modifiers.isEmpty()) "" else "$modifiers ").withVisibility()
val contextString = if (contextReceiver.isEmpty()) "" else "$contextReceiver."
val typeString = if (type.isEmpty()) "" else ": $type"
- val delegateString = if (delegate) " by " else " = "
- scope("${modifiersString}val $contextString$name$typeString$delegateString$value", block = block)
+ val initializer = when (propertyInitializer) {
+ PropertyInitializer.GETTER -> " get() = "
+ PropertyInitializer.DELEGATE -> " by "
+ PropertyInitializer.PLAIN -> " = "
+ }.takeIf { value.isNotEmpty() } ?: ""
+ val varString = if (isVar) "var" else "val"
+
+ scope(
+ "${modifiersString}$varString $contextString$name$typeString$initializer$value",
+ block = block,
+ )
+
+ this.needsNewLineAfterDeclaration = needsNewLineAfterDeclaration
+ }
+
+ enum class PropertyInitializer {
+ GETTER, DELEGATE, PLAIN;
}
fun function(
@@ -179,15 +212,15 @@ open class CodeGenerator(
args: String = "",
contextReceiver: String = "",
annotations: List = emptyList(),
- returnType: String = "",
+ returnType: String,
block: (CodeGenerator.() -> Unit)? = null,
) {
for (annotation in annotations) {
addLine(annotation)
}
- val modifiersString = if (modifiers.isEmpty()) "" else "$modifiers "
+ val modifiersString = (if (modifiers.isEmpty()) "" else "$modifiers ").withVisibility()
val contextString = if (contextReceiver.isEmpty()) "" else "$contextReceiver."
- val returnTypeString = if (returnType.isEmpty()) "" else ": $returnType"
+ val returnTypeString = if (returnType.isEmpty() || returnType == "Unit") "" else ": $returnType"
val typeParametersString = if (typeParameters.isEmpty()) "" else " <$typeParameters>"
scope("${modifiersString}fun$typeParametersString $contextString$name($args)$returnTypeString", block = block)
}
@@ -251,7 +284,7 @@ open class CodeGenerator(
addLine(annotation)
}
- val modifiersString = if (modifiers.isEmpty()) "" else "$modifiers "
+ val modifiersString = (if (modifiers.isEmpty()) "" else "$modifiers ").withVisibility()
val firstLine = "$modifiersString${declarationType.strValue}${if (name.isNotEmpty()) " " else ""}$name"
addLine(firstLine)
@@ -263,7 +296,25 @@ open class CodeGenerator(
val constructorArgsTransformed = constructorArgs.map { (arg, default) ->
val defaultString = default?.let { " = $it" } ?: ""
- "$arg$defaultString"
+ val modifierString = when {
+ !explicitApiModeEnabled -> ""
+
+ arg.contains("val") || arg.contains("var") -> when {
+ modifiers.contains("internal") ||
+ modifiers.contains("private") ||
+ arg.contains("private ") ||
+ arg.contains("protected ") ||
+ arg.contains("internal ") ||
+ arg.contains("public ") ||
+ arg.contains("override ") -> ""
+
+ else -> "public "
+ }
+
+ else -> ""
+ }
+
+ "$modifierString$arg$defaultString"
}
val constructorModifiersTransformed = if (constructorModifiers.isEmpty()) "" else
@@ -313,6 +364,20 @@ open class CodeGenerator(
return result!!
}
+ fun String.withVisibility(): String {
+ return if (explicitApiModeEnabled) {
+ when {
+ contains("public") -> this
+ contains("protected") -> this
+ contains("private") -> this
+ contains("internal") -> this
+ else -> "public $this"
+ }
+ } else {
+ this
+ }
+ }
+
companion object {
private const val ONE_INDENT = " "
}
@@ -324,7 +389,8 @@ class FileGenerator(
var packagePath: String? = packageName,
var fileOptIns: List = emptyList(),
logger: Logger = NOPLogger.NOP_LOGGER,
-) : CodeGenerator("", logger = logger) {
+ explicitApiModeEnabled: Boolean,
+) : CodeGenerator("", logger = logger, explicitApiModeEnabled = explicitApiModeEnabled) {
private val imports = mutableListOf()
fun importPackage(name: String) {
@@ -369,6 +435,13 @@ fun file(
name: String? = null,
packageName: String? = null,
logger: Logger = NOPLogger.NOP_LOGGER,
+ explicitApiModeEnabled: Boolean,
block: FileGenerator.() -> Unit,
-): FileGenerator = FileGenerator(name, packageName, packageName, emptyList(), logger)
- .apply(block)
+): FileGenerator = FileGenerator(
+ filename = name,
+ packageName = packageName,
+ packagePath = packageName,
+ fileOptIns = emptyList(),
+ logger = logger,
+ explicitApiModeEnabled = explicitApiModeEnabled,
+).apply(block)
diff --git a/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/ProtocGenPlugin.kt b/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/ProtocGenPlugin.kt
index d21513fa..fa59e88e 100644
--- a/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/ProtocGenPlugin.kt
+++ b/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/ProtocGenPlugin.kt
@@ -22,9 +22,11 @@ import java.io.File
abstract class ProtocGenPlugin {
companion object {
private const val DEBUG_OUTPUT_OPTION = "debugOutput"
+ private const val EXPLICIT_API_MODE_ENABLED_OPTION = "explicitApiModeEnabled"
}
private var debugOutput: String? = null
+ private var explicitApiModeEnabled: Boolean = false
private val logger: Logger by lazy {
val debugOutput = debugOutput ?: return@lazy NOPLogger.NOP_LOGGER
@@ -57,6 +59,7 @@ abstract class ProtocGenPlugin {
}
debugOutput = parameters[DEBUG_OUTPUT_OPTION]
+ explicitApiModeEnabled = parameters[EXPLICIT_API_MODE_ENABLED_OPTION]?.toBooleanStrictOrNull() ?: false
val files = input.runGeneration()
.map { file ->
@@ -93,8 +96,16 @@ abstract class ProtocGenPlugin {
}
private fun CodeGeneratorRequest.runGeneration(): List {
- return generateKotlinByModel(this.toModel(), logger)
+ return generateKotlinByModel(
+ model = this.toModel(),
+ logger = logger,
+ explicitApiModeEnabled = explicitApiModeEnabled,
+ )
}
- protected abstract fun generateKotlinByModel(model: Model, logger: Logger): List
+ protected abstract fun generateKotlinByModel(
+ model: Model,
+ logger: Logger,
+ explicitApiModeEnabled: Boolean,
+ ): List
}
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 13ee912e..adbcaca1 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
@@ -285,11 +285,17 @@ private fun Descriptors.FileDescriptor.kotlinFileName(): String {
}
private fun Descriptors.FileDescriptor.kotlinPackage(): String {
- return if (options.hasJavaPackage()) {
+ val requestedPackage = if (options.hasJavaPackage()) {
options.javaPackage
} else {
`package`
}
+
+ if (requestedPackage == "com.google.protobuf") {
+ return "com.google.protobuf.kotlin"
+ }
+
+ return requestedPackage
}
private fun Descriptors.FileDescriptor.protoFileNameToKotlinName(): String {
diff --git a/protoc-gen/grpc/src/main/kotlin/kotlinx/rpc/protoc/gen/grpc/GrpcProtocGenPlugin.kt b/protoc-gen/grpc/src/main/kotlin/kotlinx/rpc/protoc/gen/grpc/GrpcProtocGenPlugin.kt
index 85dcb727..a42a354f 100644
--- a/protoc-gen/grpc/src/main/kotlin/kotlinx/rpc/protoc/gen/grpc/GrpcProtocGenPlugin.kt
+++ b/protoc-gen/grpc/src/main/kotlin/kotlinx/rpc/protoc/gen/grpc/GrpcProtocGenPlugin.kt
@@ -13,7 +13,8 @@ object GrpcProtocGenPlugin : ProtocGenPlugin() {
override fun generateKotlinByModel(
model: Model,
logger: Logger,
+ explicitApiModeEnabled: Boolean,
): List {
- return ModelToGrpcKotlinCommonGenerator(model, logger).generateKotlinFiles()
+ return ModelToGrpcKotlinCommonGenerator(model, logger, explicitApiModeEnabled).generateKotlinFiles()
}
}
diff --git a/protoc-gen/grpc/src/main/kotlin/kotlinx/rpc/protoc/gen/grpc/ModelToGrpcKotlinCommonGenerator.kt b/protoc-gen/grpc/src/main/kotlin/kotlinx/rpc/protoc/gen/grpc/ModelToGrpcKotlinCommonGenerator.kt
index 0177b063..e7e51a13 100644
--- a/protoc-gen/grpc/src/main/kotlin/kotlinx/rpc/protoc/gen/grpc/ModelToGrpcKotlinCommonGenerator.kt
+++ b/protoc-gen/grpc/src/main/kotlin/kotlinx/rpc/protoc/gen/grpc/ModelToGrpcKotlinCommonGenerator.kt
@@ -14,7 +14,8 @@ import org.slf4j.Logger
class ModelToGrpcKotlinCommonGenerator(
model: Model,
logger: Logger,
-) : AModelToKotlinCommonGenerator(model, logger) {
+ explicitApiModeEnabled: Boolean,
+) : AModelToKotlinCommonGenerator(model, logger, explicitApiModeEnabled) {
override val FileDeclaration.hasPublicGeneratedContent: Boolean get() = serviceDeclarations.isNotEmpty()
override val FileDeclaration.hasInternalGeneratedContent: Boolean get() = false
@@ -30,8 +31,11 @@ class ModelToGrpcKotlinCommonGenerator(
@Suppress("detekt.LongMethod")
private fun CodeGenerator.generatePublicService(service: ServiceDeclaration) {
- code("@kotlinx.rpc.grpc.annotations.Grpc")
- clazz(service.name.simpleName, declarationType = CodeGenerator.DeclarationType.Interface) {
+ clazz(
+ name = service.name.simpleName,
+ declarationType = CodeGenerator.DeclarationType.Interface,
+ annotations = listOf("@kotlinx.rpc.grpc.annotations.Grpc")
+ ) {
service.methods.forEach { method ->
val inputType = method.inputType
val outputType = method.outputType
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 5d8b1f21..b089b908 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
@@ -24,7 +24,8 @@ import org.slf4j.Logger
class ModelToProtobufKotlinCommonGenerator(
model: Model,
logger: Logger,
-) : AModelToKotlinCommonGenerator(model, logger) {
+ explicitApiModeEnabled: Boolean,
+) : AModelToKotlinCommonGenerator(model, logger, explicitApiModeEnabled) {
override val FileDeclaration.hasPublicGeneratedContent: Boolean
get() = enumDeclarations.isNotEmpty() || messageDeclarations.isNotEmpty()
@@ -63,11 +64,6 @@ class ModelToProtobufKotlinCommonGenerator(
}
}
-
- private fun MessageDeclaration.fields() = actualFields.map {
- it.transformToFieldDeclaration() to it
- }
-
@Suppress("detekt.CyclomaticComplexMethod")
private fun CodeGenerator.generatePublicMessage(declaration: MessageDeclaration) {
if (!declaration.isUserFacing) return
@@ -77,12 +73,17 @@ class ModelToProtobufKotlinCommonGenerator(
declarationType = CodeGenerator.DeclarationType.Interface,
annotations = listOf("@$WITH_CODEC_ANNO(${declaration.internalClassFullName()}.CODEC::class)")
) {
- declaration.fields().forEach { (fieldDeclaration, _) ->
- code("val $fieldDeclaration")
- newLine()
+ declaration.actualFields.forEachIndexed { i, field ->
+ property(
+ name = field.name,
+ type = field.typeFqName(),
+ needsNewLineAfterDeclaration = i == declaration.actualFields.lastIndex,
+ )
}
- newLine()
+ if (declaration.actualFields.isNotEmpty()) {
+ newLine()
+ }
declaration.oneOfDeclarations.forEach { oneOf ->
generateOneOfPublic(oneOf)
@@ -104,9 +105,6 @@ class ModelToProtobufKotlinCommonGenerator(
private fun CodeGenerator.generateInternalMessage(declaration: MessageDeclaration) {
val internalClassName = declaration.internalClassName()
- val annotations = buildList {
- add("@$INTERNAL_RPC_API_ANNO")
- }
val superTypes = buildList {
if (declaration.isUserFacing) {
add(declaration.name.safeFullName())
@@ -116,35 +114,52 @@ class ModelToProtobufKotlinCommonGenerator(
clazz(
name = internalClassName,
- annotations = annotations,
declarationType = CodeGenerator.DeclarationType.Class,
superTypes = superTypes,
) {
generatePresenceIndicesObject(declaration)
- code("override val _size: Int by lazy { computeSize() }")
+ property(
+ name = "_size",
+ modifiers = "override",
+ annotations = listOf("@$INTERNAL_RPC_API_ANNO"),
+ type = "Int",
+ propertyInitializer = CodeGenerator.PropertyInitializer.DELEGATE,
+ value = "lazy { computeSize() }"
+ )
- val override = if (declaration.isUserFacing) "override " else ""
- declaration.fields().forEach { (fieldDeclaration, field) ->
+ val override = if (declaration.isUserFacing) "override" else ""
+ declaration.actualFields.forEachIndexed { i, field ->
val value = when {
field.nullable -> {
- "= null"
+ "null"
}
field.type is FieldType.Message ->
- "by MsgFieldDelegate(PresenceIndices.${field.name}) { " +
+ "MsgFieldDelegate(PresenceIndices.${field.name}) { " +
"${(field.type as FieldType.Message).dec.value.internalClassFullName()}() " +
"}"
else -> {
- val fieldPresence = if (field.presenceIdx != null) "PresenceIndices.${field.name}" else ""
- "by MsgFieldDelegate($fieldPresence) { ${field.type.defaultValue} }"
+ val fieldPresence = if (field.presenceIdx != null) "(PresenceIndices.${field.name})" else ""
+ "MsgFieldDelegate$fieldPresence { ${field.type.defaultValue} }"
}
}
- code("$override var $fieldDeclaration $value")
- newLine()
+ property(
+ name = field.name,
+ modifiers = override,
+ value = value,
+ isVar = true,
+ type = field.typeFqName(),
+ propertyInitializer = if (field.nullable) {
+ CodeGenerator.PropertyInitializer.PLAIN
+ } else {
+ CodeGenerator.PropertyInitializer.DELEGATE
+ },
+ needsNewLineAfterDeclaration = i == declaration.actualFields.lastIndex,
+ )
}
declaration.nestedDeclarations.forEach { nested ->
@@ -154,7 +169,12 @@ class ModelToProtobufKotlinCommonGenerator(
generateCodecObject(declaration)
// required for decodeWith extension
- code("companion object")
+ clazz(
+ name = "",
+ modifiers = "companion",
+ annotations = listOf("@$INTERNAL_RPC_API_ANNO"),
+ declarationType = CodeGenerator.DeclarationType.Object
+ )
}
}
@@ -162,11 +182,11 @@ class ModelToProtobufKotlinCommonGenerator(
if (declaration.presenceMaskSize == 0) {
return
}
- scope("private object PresenceIndices") {
- declaration.fields().forEach { (_, field) ->
+
+ clazz("PresenceIndices", "private", declarationType = CodeGenerator.DeclarationType.Object) {
+ declaration.actualFields.forEach { field ->
if (field.presenceIdx != null) {
- code("const val ${field.name} = ${field.presenceIdx}")
- newLine()
+ property(field.name, modifiers = "const", value = field.presenceIdx.toString(), type = "Int")
}
}
}
@@ -178,7 +198,12 @@ class ModelToProtobufKotlinCommonGenerator(
val msgFqName = declaration.name.safeFullName()
val inputStreamFqName = "kotlinx.rpc.protobuf.input.stream.InputStream"
val bufferFqName = "kotlinx.io.Buffer"
- scope("object CODEC : kotlinx.rpc.grpc.codec.MessageCodec<$msgFqName>") {
+ clazz(
+ name = "CODEC",
+ annotations = listOf("@$INTERNAL_RPC_API_ANNO"),
+ declarationType = CodeGenerator.DeclarationType.Object,
+ superTypes = listOf("kotlinx.rpc.grpc.codec.MessageCodec<$msgFqName>"),
+ ) {
function("encode", modifiers = "override", args = "value: $msgFqName", returnType = inputStreamFqName) {
code("val buffer = $bufferFqName()")
code("val encoder = $PB_PKG.WireEncoder(buffer)")
@@ -226,12 +251,13 @@ class ModelToProtobufKotlinCommonGenerator(
modifiers = "internal",
args = "msg: ${declaration.internalClassFullName()}, decoder: $PB_PKG.WireDecoder",
annotations = listOf("@$INTERNAL_RPC_API_ANNO"),
- contextReceiver = "${declaration.internalClassFullName()}.Companion"
+ contextReceiver = "${declaration.internalClassFullName()}.Companion",
+ returnType = "Unit",
) {
whileBlock("true") {
code("val tag = decoder.readTag() ?: break // EOF, we read the whole message")
whenBlock {
- declaration.fields().forEach { (_, field) -> readMatchCase(field) }
+ declaration.actualFields.forEach { field -> readMatchCase(field) }
whenCase("else") {
code("// we are currently just skipping unknown fields (KRPC-191)")
code("decoder.skipValue(tag.wireType)")
@@ -388,13 +414,14 @@ class ModelToProtobufKotlinCommonGenerator(
annotations = listOf("@$INTERNAL_RPC_API_ANNO"),
args = "encoder: $PB_PKG.WireEncoder",
contextReceiver = declaration.internalClassFullName(),
+ returnType = "Unit",
) {
- if (declaration.fields().isEmpty()) {
+ if (declaration.actualFields.isEmpty()) {
code("// no fields to encode")
return@function
}
- declaration.fields().forEach { (_, field) ->
+ declaration.actualFields.forEach { field ->
val fieldName = field.name
if (field.nullable) {
scope("$fieldName?.also") {
@@ -518,6 +545,7 @@ class ModelToProtobufKotlinCommonGenerator(
modifiers = "internal",
annotations = listOf("@$INTERNAL_RPC_API_ANNO"),
contextReceiver = declaration.internalClassFullName(),
+ returnType = "Unit",
) {
val requiredFields = declaration.actualFields.filter { it.dec.isRequired }
@@ -765,10 +793,6 @@ class ModelToProtobufKotlinCommonGenerator(
is FieldType.Message -> null
}
- private fun FieldDeclaration.transformToFieldDeclaration(): String {
- return "${name}: ${typeFqName()}"
- }
-
private fun CodeGenerator.generateOneOfPublic(declaration: OneOfDeclaration) {
val interfaceName = declaration.name.simpleName
@@ -818,16 +842,22 @@ class ModelToProtobufKotlinCommonGenerator(
clazz("", modifiers = "companion", declarationType = CodeGenerator.DeclarationType.Object) {
declaration.aliases.forEach { alias: EnumDeclaration.Alias ->
- code(
- "val ${alias.name.simpleName}: $className " +
- "get() = ${alias.original.name.simpleName}"
+ property(
+ name = alias.name.simpleName,
+ type = className,
+ propertyInitializer = CodeGenerator.PropertyInitializer.GETTER,
+ value = alias.original.name.simpleName,
)
}
val entryNamesSorted = entriesSorted.joinToString(", ") { it.name.simpleName }
- code("val entries: List<$className> by lazy { listOf($entryNamesSorted) }")
+ property(
+ name = "entries",
+ type = "List<$className>",
+ propertyInitializer = CodeGenerator.PropertyInitializer.DELEGATE,
+ value = "lazy { listOf($entryNamesSorted) }"
+ )
}
-
}
}
}
diff --git a/protoc-gen/protobuf/src/main/kotlin/kotlinx/rpc/protoc/gen/ProtobufProtocGenPlugin.kt b/protoc-gen/protobuf/src/main/kotlin/kotlinx/rpc/protoc/gen/ProtobufProtocGenPlugin.kt
index 813a2516..9f73e993 100644
--- a/protoc-gen/protobuf/src/main/kotlin/kotlinx/rpc/protoc/gen/ProtobufProtocGenPlugin.kt
+++ b/protoc-gen/protobuf/src/main/kotlin/kotlinx/rpc/protoc/gen/ProtobufProtocGenPlugin.kt
@@ -13,7 +13,8 @@ object ProtobufProtocGenPlugin : ProtocGenPlugin() {
override fun generateKotlinByModel(
model: Model,
logger: Logger,
+ explicitApiModeEnabled: Boolean,
): List {
- return ModelToProtobufKotlinCommonGenerator(model, logger).generateKotlinFiles()
+ return ModelToProtobufKotlinCommonGenerator(model, logger, explicitApiModeEnabled).generateKotlinFiles()
}
}
diff --git a/tests/protobuf-conformance/build.gradle.kts b/tests/protobuf-conformance/build.gradle.kts
index 5baa1b3f..97382204 100644
--- a/tests/protobuf-conformance/build.gradle.kts
+++ b/tests/protobuf-conformance/build.gradle.kts
@@ -31,7 +31,7 @@ val generatedCodeDir = project.layout.projectDirectory
tasks.withType().configureEach {
if (name.endsWith("Test")) {
- outputDirectory.set(generatedCodeDir)
+ outputDirectory = generatedCodeDir
}
}