Skip to content
Merged
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
18 changes: 7 additions & 11 deletions ink/storage/internal/jni/stroke_input_batch_serialization_jni.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,28 @@
#include "ink/strokes/input/stroke_input_batch.h"
#include "ink/strokes/internal/jni/stroke_input_batch_native_helper.h"

namespace {

using ::ink::DecodeStrokeInputBatch;
using ::ink::EncodeStrokeInputBatch;
using ::ink::StrokeInputBatch;
using ::ink::jni::ParseProtoFromEither;
using ::ink::jni::ParseProtoFromByteArray;
using ::ink::jni::SerializeProto;
using ::ink::jni::ThrowExceptionFromStatus;
using ::ink::native::CastToStrokeInputBatch;
using ::ink::native::NewNativeStrokeInputBatch;
using ::ink::proto::CodedStrokeInputBatch;

} // namespace

extern "C" {

// Constructs a `StrokeInputBatch` from a serialized `CodedStrokeInputBatch`,
// which can be passed in as either a direct `ByteBuffer` or as an array of
// bytes. This returns the address of a heap-allocated `StrokeInputBatch`, which
// must later be freed by the caller.
JNI_METHOD(storage, StrokeInputBatchSerializationNative, jlong, newFromProto)
(JNIEnv* env, jclass klass, jobject direct_byte_buffer, jbyteArray byte_array,
jint offset, jint length) {
JNI_METHOD(storage, StrokeInputBatchSerializationNative, jlong, createFromProto)
(JNIEnv* env, jclass klass, jbyteArray byte_array, jint length) {
CodedStrokeInputBatch coded_input;
if (absl::Status status = ParseProtoFromEither(
env, direct_byte_buffer, byte_array, offset, length, coded_input);
constexpr int kOffset = 0;
if (absl::Status status = ParseProtoFromByteArray(env, byte_array, kOffset,
length, coded_input);
!status.ok()) {
ThrowExceptionFromStatus(env, status);
return 0;
Expand All @@ -64,7 +60,7 @@ JNI_METHOD(storage, StrokeInputBatchSerializationNative, jlong, newFromProto)
return NewNativeStrokeInputBatch(*std::move(input));
}

JNI_METHOD(storage, StrokeInputBatchSerializationNative, jbyteArray, serialize)
JNI_METHOD(storage, StrokeInputBatchSerializationNative, jbyteArray, encode)
(JNIEnv* env, jclass klass, jlong stroke_input_batch_native_pointer) {
CodedStrokeInputBatch coded_input;
EncodeStrokeInputBatch(
Expand Down
Loading