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++17: static std::shared_ptr<Buffer> wrapByteArray(void * bytes, bool readOnly, std::function<void()> deleter)
Traditional C++: 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

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++17: static std::shared_ptr<Buffer> wrapBuffer(void * directBuffer, std::function<void()> deleter)
Traditional C++: 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)