-
Notifications
You must be signed in to change notification settings - Fork 40
gRPC: Support initial proto generation for common (JVM and Native) #415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
49db8e1
grpc-native: First message generation
Jozott00 4e545e0
grpc-native: Support for repeated fields in Message generation
Jozott00 0090141
grpc-native: Remove guards in generated kotlin
Jozott00 d5e9f00
grpc-native: Move internal decode/encoding into grpc.pb package and m…
Jozott00 ce3b69f
grpc-native: Address PR comments
Jozott00 eaa24fa
grpc-native: Rename ProtosTest class
Jozott00 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 0 additions & 54 deletions
54
grpc/grpc-core/src/commonMain/kotlin/kotlinx/rpc/grpc/internal/WireEncoder.kt
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
grpc/grpc-core/src/commonMain/kotlin/kotlinx/rpc/grpc/internal/WireSize.kt
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
grpc/grpc-core/src/commonMain/kotlin/kotlinx/rpc/grpc/pb/WireEncoder.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
package kotlinx.rpc.grpc.pb | ||
|
||
import kotlinx.io.Sink | ||
import kotlinx.rpc.internal.utils.InternalRpcApi | ||
|
||
/** | ||
* A platform-specific class that encodes values into protobuf's wire format. | ||
* | ||
* If one `write*()` method returns false, the encoding of the value failed | ||
* and no further encodings can be performed on this [WireEncoder]. | ||
* | ||
* [flush] must be called to ensure that all data is written to the [Sink]. | ||
*/ | ||
@InternalRpcApi | ||
@OptIn(ExperimentalUnsignedTypes::class) | ||
public interface WireEncoder { | ||
public fun flush() | ||
public fun writeBool(fieldNr: Int, value: Boolean): Boolean | ||
public fun writeInt32(fieldNr: Int, value: Int): Boolean | ||
public fun writeInt64(fieldNr: Int, value: Long): Boolean | ||
public fun writeUInt32(fieldNr: Int, value: UInt): Boolean | ||
public fun writeUInt64(fieldNr: Int, value: ULong): Boolean | ||
public fun writeSInt32(fieldNr: Int, value: Int): Boolean | ||
public fun writeSInt64(fieldNr: Int, value: Long): Boolean | ||
public fun writeFixed32(fieldNr: Int, value: UInt): Boolean | ||
public fun writeFixed64(fieldNr: Int, value: ULong): Boolean | ||
public fun writeSFixed32(fieldNr: Int, value: Int): Boolean | ||
public fun writeSFixed64(fieldNr: Int, value: Long): Boolean | ||
public fun writeFloat(fieldNr: Int, value: Float): Boolean | ||
public fun writeDouble(fieldNr: Int, value: Double): Boolean | ||
public fun writeEnum(fieldNr: Int, value: Int): Boolean | ||
public fun writeBytes(fieldNr: Int, value: ByteArray): Boolean | ||
public fun writeString(fieldNr: Int, value: String): Boolean | ||
public fun writePackedBool(fieldNr: Int, value: List<Boolean>, fieldSize: Int): Boolean | ||
public fun writePackedInt32(fieldNr: Int, value: List<Int>, fieldSize: Int): Boolean | ||
public fun writePackedInt64(fieldNr: Int, value: List<Long>, fieldSize: Int): Boolean | ||
public fun writePackedUInt32(fieldNr: Int, value: List<UInt>, fieldSize: Int): Boolean | ||
public fun writePackedUInt64(fieldNr: Int, value: List<ULong>, fieldSize: Int): Boolean | ||
public fun writePackedSInt32(fieldNr: Int, value: List<Int>, fieldSize: Int): Boolean | ||
public fun writePackedSInt64(fieldNr: Int, value: List<Long>, fieldSize: Int): Boolean | ||
public fun writePackedFixed32(fieldNr: Int, value: List<UInt>): Boolean | ||
public fun writePackedFixed64(fieldNr: Int, value: List<ULong>): Boolean | ||
public fun writePackedSFixed32(fieldNr: Int, value: List<Int>): Boolean | ||
public fun writePackedSFixed64(fieldNr: Int, value: List<Long>): Boolean | ||
public fun writePackedFloat(fieldNr: Int, value: List<Float>): Boolean | ||
public fun writePackedDouble(fieldNr: Int, value: List<Double>): Boolean | ||
public fun writePackedEnum(fieldNr: Int, value: List<Int>, fieldSize: Int): Boolean = | ||
writePackedInt32(fieldNr, value, fieldSize) | ||
} | ||
|
||
|
||
internal expect fun WireEncoder(sink: Sink): WireEncoder |
24 changes: 24 additions & 0 deletions
24
grpc/grpc-core/src/commonMain/kotlin/kotlinx/rpc/grpc/pb/WireSize.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
package kotlinx.rpc.grpc.pb | ||
|
||
public object WireSize | ||
|
||
public expect fun WireSize.int32(value: Int): Int | ||
public expect fun WireSize.int64(value: Long): Int | ||
public expect fun WireSize.uInt32(value: UInt): Int | ||
public expect fun WireSize.uInt64(value: ULong): Int | ||
public expect fun WireSize.sInt32(value: Int): Int | ||
public expect fun WireSize.sInt64(value: Long): Int | ||
|
||
public fun WireSize.bool(value: Boolean): Int = int32(if (value) 1 else 0) | ||
public fun WireSize.enum(value: Int): Int = int32(value) | ||
public fun WireSize.packedInt32(value: List<Int>): Int = value.sumOf { int32(it) } | ||
public fun WireSize.packedInt64(value: List<Long>): Int = value.sumOf { int64(it) } | ||
public fun WireSize.packedUInt32(value: List<UInt>): Int = value.sumOf { uInt32(it) } | ||
public fun WireSize.packedUInt64(value: List<ULong>): Int = value.sumOf { uInt64(it) } | ||
public fun WireSize.packedSInt32(value: List<Int>): Int = value.sumOf { sInt32(it) } | ||
public fun WireSize.packedSInt64(value: List<Long>): Int = value.sumOf { sInt64(it) } | ||
public fun WireSize.packedEnum(value: List<Int>): Int = value.sumOf { enum(it) } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.