JniUtility Class

Description

JNI utility class.

It is used in Unity to wrap Java byte array and ByteBuffer.

It is not supported on iOS.

wrapByteArray

Wraps Java’s byte[]。

C

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

C++

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

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

Wraps Java’s java.nio.ByteBuffer, which must be a direct buffer.

C

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

C++

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

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

Get the raw address of a direct buffer of java.nio.ByteBuffer by calling JNIEnv->GetDirectBufferAddress.

C

void * easyar_JniUtility_getDirectBufferAddress(void * directBuffer)

C++

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

Get the JNI global pointer for a Java object.

Java

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

Kotlin

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

deleteJniGlobalPointer

Release the JNI global pointer for a Java object.

Java

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

Kotlin

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