mirror of
https://github.com/status-im/react-native.git
synced 2025-02-04 21:53:30 +00:00
Add JReadableByteChannel
Summary: Adds `JReadableByteChannel`, which maps to `java.nio.ReadableByteChannel`. This class is useful to stream data from Java to C++ memory (in conjunction with `JByteBuffer`). Differential Revision: D7437312 fbshipit-source-id: 4979706148f0e20228f0f52341fb340497c24a8b
This commit is contained in:
parent
1020ac9481
commit
550339c71b
@ -13,6 +13,7 @@ LOCAL_SRC_FILES:= \
|
|||||||
jni/jni_helpers.cpp \
|
jni/jni_helpers.cpp \
|
||||||
jni/LocalString.cpp \
|
jni/LocalString.cpp \
|
||||||
jni/OnLoad.cpp \
|
jni/OnLoad.cpp \
|
||||||
|
jni/ReadableByteChannel.cpp \
|
||||||
jni/References.cpp \
|
jni/References.cpp \
|
||||||
jni/WeakReference.cpp \
|
jni/WeakReference.cpp \
|
||||||
log.cpp \
|
log.cpp \
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <fb/fbjni.h>
|
||||||
|
#include <fb/fbjni/ByteBuffer.h>
|
||||||
|
|
||||||
|
namespace facebook {
|
||||||
|
namespace jni {
|
||||||
|
|
||||||
|
class JReadableByteChannel : public JavaClass<JReadableByteChannel> {
|
||||||
|
public:
|
||||||
|
static constexpr const char* kJavaDescriptor = "Ljava/nio/channels/ReadableByteChannel;";
|
||||||
|
|
||||||
|
int read(alias_ref<JByteBuffer> dest) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
}}
|
@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <fb/fbjni/ReadableByteChannel.h>
|
||||||
|
|
||||||
|
namespace facebook {
|
||||||
|
namespace jni {
|
||||||
|
|
||||||
|
int JReadableByteChannel::read(alias_ref<JByteBuffer> dest) const {
|
||||||
|
if (!self()) {
|
||||||
|
throwNewJavaException("java/lang/NullPointerException", "java.lang.NullPointerException");
|
||||||
|
}
|
||||||
|
static auto method = javaClassStatic()->getMethod<jint(alias_ref<JByteBuffer>)>("read");
|
||||||
|
return method(self(), dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
}}
|
Loading…
x
Reference in New Issue
Block a user