Skip to content

Commit f296a61

Browse files
committed
grpc-native: Rename grpcpp_c to kgrpc
Signed-off-by: Johannes Zottele <[email protected]>
1 parent aeb874d commit f296a61

File tree

10 files changed

+27
-27
lines changed

10 files changed

+27
-27
lines changed

cinterop-c/BUILD.bazel

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
load("@rules_cc//cc:defs.bzl", "cc_library")
22

33
cc_static_library(
4-
name = "grpcpp_c_static",
4+
name = "kgrpc_static",
55
deps = [
6-
":grpcpp_c",
6+
":kgrpc",
77
],
88
)
99

1010
cc_library(
11-
name = "grpcpp_c",
12-
srcs = ["src/grpcpp_c.cpp"],
13-
hdrs = glob(["include/**/*.h"]),
11+
name = "kgrpc",
12+
srcs = ["src/kgrpc.cpp"],
13+
hdrs = glob(["include/kgrpc.h"]),
1414
copts = ["-std=c++20"],
1515
includes = ["include"],
1616
visibility = ["//visibility:public"],
@@ -35,7 +35,7 @@ cc_static_library(
3535
cc_library(
3636
name = "protowire",
3737
srcs = ["src/protowire.cpp"],
38-
hdrs = glob(["include/*.h"]),
38+
hdrs = glob(["include/protowire.h"]),
3939
copts = ["-std=c++20"],
4040
includes = ["include"],
4141
visibility = ["//visibility:public"],

cinterop-c/include/grpcpp_c.h renamed to cinterop-c/include/kgrpc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ extern "C" {
2323
typedef struct {
2424
grpc_completion_queue_functor functor;
2525
void *user_data;
26-
} grpc_cb_tag;
26+
} kgrpc_cb_tag;
2727

2828
/*
2929
* Call to grpc_iomgr_run_in_background(), which is not exposed as extern "C" and therefore must be wrapped.

cinterop-c/src/grpcpp_c.cpp renamed to cinterop-c/src/kgrpc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5-
#include <grpcpp_c.h>
5+
#include <kgrpc.h>
66

77
#include "src/core/lib/iomgr/iomgr.h"
88

grpc/grpc-core/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ kotlin {
7070
}
7171
}
7272

73-
configureCLibCInterop(project, ":grpcpp_c_static") { cinteropCLib ->
73+
configureCLibCInterop(project, ":kgrpc_static") { cinteropCLib ->
7474
@Suppress("unused")
75-
val libgrpcpp_c by creating {
75+
val libkgrpc by creating {
7676
includeDirs(
7777
cinteropCLib.resolve("include"),
7878
cinteropCLib.resolve("bazel-cinterop-c/external/grpc+/include"),
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
headers = grpcpp_c.h grpc/grpc.h grpc/credentials.h grpc/byte_buffer_reader.h \
1+
headers = kgrpc.h grpc/grpc.h grpc/credentials.h grpc/byte_buffer_reader.h \
22
grpc/support/alloc.h
33

4-
headerFilter= grpcpp_c.h grpc/slice.h grpc/byte_buffer.h grpc/grpc.h \
4+
headerFilter= kgrpc.h grpc/slice.h grpc/byte_buffer.h grpc/grpc.h \
55
grpc/impl/grpc_types.h grpc/credentials.h grpc/support/time.h grpc/byte_buffer_reader.h \
66
grpc/support/alloc.h
77

88
noStringConversion = grpc_slice_from_copied_buffer my_grpc_slice_from_copied_buffer
99
strictEnums = grpc_status_code grpc_connectivity_state grpc_call_error
1010

11-
staticLibraries = libgrpcpp_c_static.a
11+
staticLibraries = libkgrpc_static.a

grpc/grpc-core/src/nativeMain/kotlin/kotlinx/rpc/grpc/internal/CompletionQueue.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import kotlinx.atomicfu.atomic
1010
import kotlinx.atomicfu.locks.SynchronizedObject
1111
import kotlinx.atomicfu.locks.synchronized
1212
import kotlinx.cinterop.*
13-
import libgrpcpp_c.*
13+
import libkgrpc.*
1414
import platform.posix.memset
1515
import kotlin.experimental.ExperimentalNativeApi
1616
import kotlin.native.ref.createCleaner
@@ -49,7 +49,7 @@ internal class CompletionQueue {
4949

5050
private val thisStableRef = StableRef.create(this)
5151

52-
private val shutdownFunctor = nativeHeap.alloc<grpc_cb_tag> {
52+
private val shutdownFunctor = nativeHeap.alloc<kgrpc_cb_tag> {
5353
functor.functor_run = SHUTDOWN_CB
5454
user_data = thisStableRef.asCPointer()
5555
}.reinterpret<grpc_completion_queue_functor>()
@@ -127,15 +127,15 @@ internal class CompletionQueue {
127127
// kq stands for kompletion_queue lol
128128
@CName("kq_ops_complete_cb")
129129
private fun opsCompleteCb(functor: CPointer<grpc_completion_queue_functor>?, ok: Int) {
130-
val tag = functor!!.reinterpret<grpc_cb_tag>()
130+
val tag = functor!!.reinterpret<kgrpc_cb_tag>()
131131
val cont = tag.pointed.user_data!!.asStableRef<CallbackFuture<Boolean>>().get()
132132
deleteCbTag(tag)
133133
cont.complete(ok != 0)
134134
}
135135

136136
@CName("kq_shutdown_cb")
137137
private fun shutdownCb(functor: CPointer<grpc_completion_queue_functor>?, ok: Int) {
138-
val tag = functor!!.reinterpret<grpc_cb_tag>()
138+
val tag = functor!!.reinterpret<kgrpc_cb_tag>()
139139
val cq = tag.pointed.user_data!!.asStableRef<CompletionQueue>().get()
140140
cq._shutdownDone.complete(Unit)
141141
cq._state.value = CompletionQueue.State.CLOSED
@@ -148,16 +148,16 @@ private val SHUTDOWN_CB = staticCFunction(::shutdownCb)
148148
private fun newCbTag(
149149
userData: Any,
150150
cb: CPointer<CFunction<(CPointer<grpc_completion_queue_functor>?, Int) -> Unit>>,
151-
): CPointer<grpc_cb_tag> {
152-
val tag = nativeHeap.alloc<grpc_cb_tag>()
153-
memset(tag.ptr, 0, sizeOf<grpc_cb_tag>().convert())
151+
): CPointer<kgrpc_cb_tag> {
152+
val tag = nativeHeap.alloc<kgrpc_cb_tag>()
153+
memset(tag.ptr, 0, sizeOf<kgrpc_cb_tag>().convert())
154154
tag.functor.functor_run = cb
155155
tag.user_data = StableRef.create(userData).asCPointer()
156156
return tag.ptr
157157
}
158158

159-
@CName("grpc_cb_tag_destroy")
160-
private fun deleteCbTag(tag: CPointer<grpc_cb_tag>) {
159+
@CName("kgrpc_cb_tag_destroy")
160+
private fun deleteCbTag(tag: CPointer<kgrpc_cb_tag>) {
161161
tag.pointed.user_data!!.asStableRef<Any>().dispose()
162162
nativeHeap.free(tag)
163163
}

grpc/grpc-core/src/nativeMain/kotlin/kotlinx/rpc/grpc/internal/NativeClientCall.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import kotlinx.rpc.grpc.Status
1616
import kotlinx.rpc.grpc.StatusCode
1717
import kotlinx.rpc.protobuf.input.stream.asInputStream
1818
import kotlinx.rpc.protobuf.input.stream.asSource
19-
import libgrpcpp_c.*
19+
import libkgrpc.*
2020
import kotlin.experimental.ExperimentalNativeApi
2121
import kotlin.native.ref.createCleaner
2222

grpc/grpc-core/src/nativeMain/kotlin/kotlinx/rpc/grpc/internal/NativeGrpcLibrary.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import kotlinx.atomicfu.atomic
1010
import kotlinx.atomicfu.locks.reentrantLock
1111
import kotlinx.atomicfu.locks.withLock
1212
import kotlinx.cinterop.ExperimentalForeignApi
13-
import libgrpcpp_c.grpc_init
14-
import libgrpcpp_c.grpc_shutdown
13+
import libkgrpc.grpc_init
14+
import libkgrpc.grpc_shutdown
1515
import kotlin.experimental.ExperimentalNativeApi
1616

1717
internal object GrpcRuntime {

grpc/grpc-core/src/nativeMain/kotlin/kotlinx/rpc/grpc/internal/NativeManagedChannel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import kotlinx.cinterop.ExperimentalForeignApi
1313
import kotlinx.coroutines.*
1414
import kotlinx.rpc.grpc.ManagedChannel
1515
import kotlinx.rpc.grpc.ManagedChannelPlatform
16-
import libgrpcpp_c.*
16+
import libkgrpc.*
1717
import kotlin.coroutines.cancellation.CancellationException
1818
import kotlin.experimental.ExperimentalNativeApi
1919
import kotlin.native.ref.createCleaner

grpc/grpc-core/src/nativeMain/kotlin/kotlinx/rpc/grpc/internal/utils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import kotlinx.cinterop.*
1010
import kotlinx.io.*
1111
import kotlinx.io.unsafe.UnsafeBufferOperations
1212
import kotlinx.rpc.grpc.StatusCode
13-
import libgrpcpp_c.*
13+
import libkgrpc.*
1414
import platform.posix.memcpy
1515

1616
@OptIn(ExperimentalForeignApi::class, InternalIoApi::class, UnsafeIoApi::class)

0 commit comments

Comments
 (0)