I have various Scala native methods. Some examples:
@native protected def xOpen(): Long
@native protected def flushNative(xServPtr: Long): Unit
@native protected def drawLineNative(xServPtr: Long, winPtr: Long, x1: Int, y1: Int, x2: Int, y2: Int): Unit
@native protected def newGraphicsContextNative(xServPtr: Long, winPtr: Long): Long
//And a couple of the signatures from the C++ file.
extern "C" JNIEXPORT void JNICALL Java_pXClient_XCClass_flushNative(JNIEnv * env, jobject c1, jlong displayPtr)
extern "C" JNIEXPORT jlong JNICALL Java_pXClient_XCClass_newGraphicsContextNative(JNIEnv * env, jobject c1,
jlong displayPtr, jlong winPtr)
I would like to have stronger typing on the pointers rather than passing them all as longs. Is there a way to use AnyVal classes here eg:
class XServPtr(val value: Long) extends AnyVal
class WinPtr(val value: Long) extends AnyVal
and can I add custom types to JNI? Then I could do custom c++ implicit type conversions from the JNI type to the specific c++ pointer type and have type safety at both ends.