Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion ink/brush/internal/jni/brush_behavior_jni.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,13 @@ JNI_METHOD(brush, BrushBehaviorNative, jlong, createFromOrderedNodes)
jlong* node_pointers =
env->GetLongArrayElements(node_native_pointer_array, nullptr);
ABSL_CHECK(node_pointers != nullptr);
// Both `jlong` and `int64_t` are required to be 64-bit integers which JNI and
// Kotlin-cinterop respectively both map to Kotlin `Long`. However, on MacOS
// they represent two distinct (though equivalent) types, `jlong` is `long`
// but `int64_t` is `long long`.
static_assert(sizeof(jlong) == sizeof(int64_t));
int64_t result = BrushBehaviorNative_createFromOrderedNodes(
env, node_pointers, num_nodes,
env, reinterpret_cast<int64_t*>(node_pointers), num_nodes,
JStringToStdString(env, developer_comment).c_str(),
&ThrowExceptionFromStatusCallback);
env->ReleaseLongArrayElements(
Expand Down
8 changes: 7 additions & 1 deletion ink/brush/internal/jni/brush_tip_jni.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,16 @@ JNI_METHOD(brush, BrushTipNative, jlong, create)
env->GetArrayLength(behavior_native_pointers_array);
jlong* behavior_pointers =
env->GetLongArrayElements(behavior_native_pointers_array, nullptr);
// Both `jlong` and `int64_t` are required to be 64-bit integers which JNI and
// Kotlin-cinterop respectively both map to Kotlin `Long`. However, on MacOS
// they represent two distinct (though equivalent) types, `jlong` is `long`
// but `int64_t` is `long long`.
static_assert(sizeof(jlong) == sizeof(int64_t));
int64_t result = BrushTipNative_create(
env, scale_x, scale_y, corner_rounding, slant_degrees, pinch,
rotation_degrees, particle_gap_distance_scale,
particle_gap_duration_millis, behavior_pointers, num_behaviors,
particle_gap_duration_millis,
reinterpret_cast<int64_t*>(behavior_pointers), num_behaviors,
&ThrowExceptionFromStatusCallback);
env->ReleaseLongArrayElements(behavior_native_pointers_array,
behavior_pointers, JNI_ABORT);
Expand Down
8 changes: 7 additions & 1 deletion ink/jni/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
load("@rules_cc//cc:cc_library.bzl", "cc_library")

Expand All @@ -27,7 +28,7 @@ cc_binary(
],
features = ["-legacy_whole_archive"],
linkopts = select({
"@platforms//os:macos": [
"@platforms//os:ios": [
"-Wl,-exported_symbols_list,$(location :exported_symbols.txt)",
],
"//conditions:default": [
Expand All @@ -42,6 +43,11 @@ cc_binary(
],
)

build_test(
name = "libink_so_build_test",
targets = [":libink.so"],
)

cc_library(
name = "android_no_proto_jni",
tags = ["keep_dep"],
Expand Down
1 change: 1 addition & 0 deletions ink/kmp/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ package(
cc_static_library(
name = "ink",
deps = [
"//ink/brush/internal/jni:cinterop",
"//ink/geometry/internal/jni:cinterop",
"//ink/jni/internal:cinterop",
],
Expand Down
Loading