JniUtility Class

Description

JNI工具类。

用于在Unity中对Java的数组和ByteBuffer进行包装。

不支持iOS平台。

wrapByteArray

包装Java的字节数组byte[]。

C

void easyar_JniUtility_wrapByteArray(void * bytes, bool readOnly, easyar_FunctorOfVoid deleter, easyar_Buffer * * Return)

C++17

static std::shared_ptr<Buffer> wrapByteArray(void * bytes, bool readOnly, std::function<void()> deleter)

C++03

static void wrapByteArray(void * bytes, bool readOnly, FunctorOfVoid deleter, Buffer * * Return)

Java

public static @Nonnull Buffer wrapByteArray(long bytes, boolean readOnly, @Nonnull FunctorOfVoid deleter)

Kotlin

companion object fun wrapByteArray(bytes: Long, readOnly: Boolean, deleter: FunctorOfVoid): Buffer

Objective-C

+ (easyar_Buffer *)wrapByteArray:(void *)bytes readOnly:(bool)readOnly deleter:(void (^)())deleter

Swift

public static func wrapByteArray(_ bytes: OpaquePointer?, _ readOnly: Bool, _ deleter: @escaping () -> Void) -> Buffer

C#

public static Buffer wrapByteArray(IntPtr bytes, bool readOnly, Action deleter)

wrapBuffer

包装Java的java.nio.ByteBuffer中的direct buffer。

C

void easyar_JniUtility_wrapBuffer(void * directBuffer, easyar_FunctorOfVoid deleter, easyar_Buffer * * Return)

C++17

static std::shared_ptr<Buffer> wrapBuffer(void * directBuffer, std::function<void()> deleter)

C++03

static void wrapBuffer(void * directBuffer, FunctorOfVoid deleter, Buffer * * Return)

Java

public static @Nonnull Buffer wrapBuffer(long directBuffer, @Nonnull FunctorOfVoid deleter)

Kotlin

companion object fun wrapBuffer(directBuffer: Long, deleter: FunctorOfVoid): Buffer

Objective-C

+ (easyar_Buffer *)wrapBuffer:(void *)directBuffer deleter:(void (^)())deleter

Swift

public static func wrapBuffer(_ directBuffer: OpaquePointer?, _ deleter: @escaping () -> Void) -> Buffer

C#

public static Buffer wrapBuffer(IntPtr directBuffer, Action deleter)

getDirectBufferAddress

调用JNIEnv->GetDirectBufferAddress获得java.nio.ByteBuffer中的direct buffer的原始地址。

C

void * easyar_JniUtility_getDirectBufferAddress(void * directBuffer)

C++17

static void * getDirectBufferAddress(void * directBuffer)

C++03

static void * getDirectBufferAddress(void * directBuffer)

Java

public static long getDirectBufferAddress(long directBuffer)

Kotlin

companion object fun getDirectBufferAddress(directBuffer: Long): Long

Objective-C

+ (void *)getDirectBufferAddress:(void *)directBuffer

Swift

public static func getDirectBufferAddress(_ directBuffer: OpaquePointer?) -> OpaquePointer?

C#

public static IntPtr getDirectBufferAddress(IntPtr directBuffer)

newJniGlobalPointer

获得Java对象在JNI中的全局指针。

Java

public static long Buffer newJniGlobalPointer(java.lang.@Nonnull Object obj)

Kotlin

companion object fun newJniGlobalPointer(obj: java.lang.Object): Long

deleteJniGlobalPointer

释放Java对象在JNI中的全局指针。

Java

public static long Buffer newJniGlobalPointer(java.lang.@Nonnull Object obj)

Kotlin

companion object fun newJniGlobalPointer(obj: java.lang.Object): Long