Skip to content

Instantly share code, notes, and snippets.

@harold-b
Last active April 13, 2024 12:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harold-b/a78e5caaadaf15aa1e9575294c272bb9 to your computer and use it in GitHub Desktop.
Save harold-b/a78e5caaadaf15aa1e9575294c272bb9 to your computer and use it in GitHub Desktop.
Simple jni bindings for odin
package jni
import "base:intrinsics"
import "base:runtime"
import cffi "core:c"
when ODIN_OS == .Linux {
foreign import lib {
"system:jni",
}
}
when ODIN_OS == .Windows {
foreign import lib {
"system:jni.lib",
}
}
when ODIN_OS == .Darwin {
foreign import lib {
"system:jni",
}
}
JNI_FALSE :: 0
JNI_TRUE :: 1
JNI_OK :: 0
JNI_ERR :: (-1)
JNI_EDETACHED :: (-2)
JNI_EVERSION :: (-3)
JNI_ENOMEM :: (-4)
JNI_EEXIST :: (-5)
JNI_EINVAL :: (-6)
JNI_COMMIT :: 1
JNI_ABORT :: 2
JNI_VERSION_1_1 :: 0x00010001
JNI_VERSION_1_2 :: 0x00010002
JNI_VERSION_1_4 :: 0x00010004
JNI_VERSION_1_6 :: 0x00010006
JNI_VERSION_1_8 :: 0x00010008
JNI_VERSION_9 :: 0x00090000
JNI_VERSION_10 :: 0x000a0000
foreign lib {
}
@(default_calling_convention="c")
foreign lib {
@(link_name="JNI_GetDefaultJavaVMInitArgs")
GetDefaultJavaVMInitArgs :: proc(args: rawptr) -> cffi.int ---
@(link_name="JNI_CreateJavaVM")
CreateJavaVM :: proc(pvm: ^^^InvokeInterface, penv: ^rawptr, args: rawptr) -> cffi.int ---
@(link_name="JNI_GetCreatedJavaVMs")
GetCreatedJavaVMs :: proc(_0: ^^^InvokeInterface, _1: jsize, _2: ^cffi.int) -> cffi.int ---
@(link_name="JNI_OnLoad")
OnLoad :: proc(vm: ^^InvokeInterface, reserved: rawptr) -> cffi.int ---
@(link_name="JNI_OnUnload")
OnUnload :: proc(vm: ^^InvokeInterface, reserved: rawptr) ---
}
/// jint
jint :: distinct cffi.int
/// jlong
jlong :: distinct cffi.long
/// jbyte
jbyte :: distinct cffi.schar
/// jboolean
jboolean :: distinct cffi.uchar
/// jchar
jchar :: distinct cffi.ushort
/// jshort
jshort :: distinct cffi.short
/// jfloat
jfloat :: distinct cffi.float
/// jdouble
jdouble :: distinct cffi.double
/// jsize
jsize :: distinct cffi.int
/// jobject
jobject :: distinct ^_jobject
/// jclass
jclass :: distinct ^_jobject
/// jthrowable
jthrowable :: distinct ^_jobject
/// jstring
jstring :: distinct ^_jobject
/// jarray
jarray :: distinct ^_jobject
/// jbooleanArray
jbooleanArray :: distinct ^_jobject
/// jbyteArray
jbyteArray :: distinct ^_jobject
/// jcharArray
jcharArray :: distinct ^_jobject
/// jshortArray
jshortArray :: distinct ^_jobject
/// jintArray
jintArray :: distinct ^_jobject
/// jlongArray
jlongArray :: distinct ^_jobject
/// jfloatArray
jfloatArray :: distinct ^_jobject
/// jdoubleArray
jdoubleArray :: distinct ^_jobject
/// jobjectArray
jobjectArray :: distinct ^_jobject
/// jweak
jweak :: distinct ^_jobject
/// jfieldID
jfieldID :: distinct ^_jfieldID
/// jmethodID
jmethodID :: distinct ^_jmethodID
/// JNIEnv
Env :: distinct ^NativeInterface_
/// JavaVM
JavaVM :: distinct ^InvokeInterface
/// jobjectRefType
jobjectRefType :: enum cffi.uint {
JNIInvalidRefType = 0,
JNILocalRefType = 1,
JNIGlobalRefType = 2,
JNIWeakGlobalRefType = 3,
}
/// _jobject
_jobject :: struct {}
/// _jfieldID
_jfieldID :: struct {}
/// _jmethodID
_jmethodID :: struct {}
/// JNINativeMethod
NativeMethod :: struct #align (8) {
name : cstring,
signature : cstring,
fnPtr : rawptr,
}
/// JNINativeInterface_
NativeInterface_ :: struct #align (8) {
reserved0 : rawptr,
reserved1 : rawptr,
reserved2 : rawptr,
reserved3 : rawptr,
GetVersion : proc "c" (env: ^^NativeInterface_) -> cffi.int,
DefineClass : proc "c" (env: ^^NativeInterface_, name: cstring, loader: ^_jobject, buf: ^cffi.schar, len: cffi.int) -> ^_jobject,
FindClass : proc "c" (env: ^^NativeInterface_, name: cstring) -> ^_jobject,
FromReflectedMethod : proc "c" (env: ^^NativeInterface_, method: ^_jobject) -> ^_jmethodID,
FromReflectedField : proc "c" (env: ^^NativeInterface_, field: ^_jobject) -> ^_jfieldID,
ToReflectedMethod : proc "c" (env: ^^NativeInterface_, cls: ^_jobject, methodID: ^_jmethodID, isStatic: cffi.uchar) -> ^_jobject,
GetSuperclass : proc "c" (env: ^^NativeInterface_, sub: ^_jobject) -> ^_jobject,
IsAssignableFrom : proc "c" (env: ^^NativeInterface_, sub: ^_jobject, sup: ^_jobject) -> cffi.uchar,
ToReflectedField : proc "c" (env: ^^NativeInterface_, cls: ^_jobject, fieldID: ^_jfieldID, isStatic: cffi.uchar) -> ^_jobject,
Throw : proc "c" (env: ^^NativeInterface_, obj: ^_jobject) -> cffi.int,
ThrowNew : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, msg: cstring) -> cffi.int,
ExceptionOccurred : proc "c" (env: ^^NativeInterface_) -> ^_jobject,
ExceptionDescribe : proc "c" (env: ^^NativeInterface_),
ExceptionClear : proc "c" (env: ^^NativeInterface_),
FatalError : proc "c" (env: ^^NativeInterface_, msg: cstring),
PushLocalFrame : proc "c" (env: ^^NativeInterface_, capacity: cffi.int) -> cffi.int,
PopLocalFrame : proc "c" (env: ^^NativeInterface_, result: ^_jobject) -> ^_jobject,
NewGlobalRef : proc "c" (env: ^^NativeInterface_, lobj: ^_jobject) -> ^_jobject,
DeleteGlobalRef : proc "c" (env: ^^NativeInterface_, gref: ^_jobject),
DeleteLocalRef : proc "c" (env: ^^NativeInterface_, obj: ^_jobject),
IsSameObject : proc "c" (env: ^^NativeInterface_, obj1: ^_jobject, obj2: ^_jobject) -> cffi.uchar,
NewLocalRef : proc "c" (env: ^^NativeInterface_, ref: ^_jobject) -> ^_jobject,
EnsureLocalCapacity : proc "c" (env: ^^NativeInterface_, capacity: cffi.int) -> cffi.int,
AllocObject : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject) -> ^_jobject,
NewObject : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, methodID: ^_jmethodID) -> ^_jobject,
NewObjectV : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, methodID: ^_jmethodID, args: cstring) -> ^_jobject,
NewObjectA : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, methodID: ^_jmethodID, args: ^jvalue) -> ^_jobject,
GetObjectClass : proc "c" (env: ^^NativeInterface_, obj: ^_jobject) -> ^_jobject,
IsInstanceOf : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, clazz: ^_jobject) -> cffi.uchar,
GetMethodID : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, name: cstring, sig: cstring) -> ^_jmethodID,
CallObjectMethod : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, methodID: ^_jmethodID) -> ^_jobject,
CallObjectMethodV : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, methodID: ^_jmethodID, args: cstring) -> ^_jobject,
CallObjectMethodA : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, methodID: ^_jmethodID, args: ^jvalue) -> ^_jobject,
CallBooleanMethod : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, methodID: ^_jmethodID) -> cffi.uchar,
CallBooleanMethodV : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, methodID: ^_jmethodID, args: cstring) -> cffi.uchar,
CallBooleanMethodA : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, methodID: ^_jmethodID, args: ^jvalue) -> cffi.uchar,
CallByteMethod : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, methodID: ^_jmethodID) -> cffi.schar,
CallByteMethodV : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, methodID: ^_jmethodID, args: cstring) -> cffi.schar,
CallByteMethodA : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, methodID: ^_jmethodID, args: ^jvalue) -> cffi.schar,
CallCharMethod : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, methodID: ^_jmethodID) -> cffi.ushort,
CallCharMethodV : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, methodID: ^_jmethodID, args: cstring) -> cffi.ushort,
CallCharMethodA : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, methodID: ^_jmethodID, args: ^jvalue) -> cffi.ushort,
CallShortMethod : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, methodID: ^_jmethodID) -> cffi.short,
CallShortMethodV : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, methodID: ^_jmethodID, args: cstring) -> cffi.short,
CallShortMethodA : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, methodID: ^_jmethodID, args: ^jvalue) -> cffi.short,
CallIntMethod : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, methodID: ^_jmethodID) -> cffi.int,
CallIntMethodV : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, methodID: ^_jmethodID, args: cstring) -> cffi.int,
CallIntMethodA : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, methodID: ^_jmethodID, args: ^jvalue) -> cffi.int,
CallLongMethod : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, methodID: ^_jmethodID) -> cffi.long,
CallLongMethodV : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, methodID: ^_jmethodID, args: cstring) -> cffi.long,
CallLongMethodA : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, methodID: ^_jmethodID, args: ^jvalue) -> cffi.long,
CallFloatMethod : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, methodID: ^_jmethodID) -> cffi.float,
CallFloatMethodV : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, methodID: ^_jmethodID, args: cstring) -> cffi.float,
CallFloatMethodA : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, methodID: ^_jmethodID, args: ^jvalue) -> cffi.float,
CallDoubleMethod : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, methodID: ^_jmethodID) -> cffi.double,
CallDoubleMethodV : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, methodID: ^_jmethodID, args: cstring) -> cffi.double,
CallDoubleMethodA : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, methodID: ^_jmethodID, args: ^jvalue) -> cffi.double,
CallVoidMethod : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, methodID: ^_jmethodID),
CallVoidMethodV : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, methodID: ^_jmethodID, args: cstring),
CallVoidMethodA : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, methodID: ^_jmethodID, args: ^jvalue),
CallNonvirtualObjectMethod : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, clazz: ^_jobject, methodID: ^_jmethodID) -> ^_jobject,
CallNonvirtualObjectMethodV : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, clazz: ^_jobject, methodID: ^_jmethodID, args: cstring) -> ^_jobject,
CallNonvirtualObjectMethodA : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, clazz: ^_jobject, methodID: ^_jmethodID, args: ^jvalue) -> ^_jobject,
CallNonvirtualBooleanMethod : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, clazz: ^_jobject, methodID: ^_jmethodID) -> cffi.uchar,
CallNonvirtualBooleanMethodV : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, clazz: ^_jobject, methodID: ^_jmethodID, args: cstring) -> cffi.uchar,
CallNonvirtualBooleanMethodA : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, clazz: ^_jobject, methodID: ^_jmethodID, args: ^jvalue) -> cffi.uchar,
CallNonvirtualByteMethod : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, clazz: ^_jobject, methodID: ^_jmethodID) -> cffi.schar,
CallNonvirtualByteMethodV : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, clazz: ^_jobject, methodID: ^_jmethodID, args: cstring) -> cffi.schar,
CallNonvirtualByteMethodA : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, clazz: ^_jobject, methodID: ^_jmethodID, args: ^jvalue) -> cffi.schar,
CallNonvirtualCharMethod : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, clazz: ^_jobject, methodID: ^_jmethodID) -> cffi.ushort,
CallNonvirtualCharMethodV : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, clazz: ^_jobject, methodID: ^_jmethodID, args: cstring) -> cffi.ushort,
CallNonvirtualCharMethodA : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, clazz: ^_jobject, methodID: ^_jmethodID, args: ^jvalue) -> cffi.ushort,
CallNonvirtualShortMethod : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, clazz: ^_jobject, methodID: ^_jmethodID) -> cffi.short,
CallNonvirtualShortMethodV : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, clazz: ^_jobject, methodID: ^_jmethodID, args: cstring) -> cffi.short,
CallNonvirtualShortMethodA : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, clazz: ^_jobject, methodID: ^_jmethodID, args: ^jvalue) -> cffi.short,
CallNonvirtualIntMethod : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, clazz: ^_jobject, methodID: ^_jmethodID) -> cffi.int,
CallNonvirtualIntMethodV : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, clazz: ^_jobject, methodID: ^_jmethodID, args: cstring) -> cffi.int,
CallNonvirtualIntMethodA : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, clazz: ^_jobject, methodID: ^_jmethodID, args: ^jvalue) -> cffi.int,
CallNonvirtualLongMethod : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, clazz: ^_jobject, methodID: ^_jmethodID) -> cffi.long,
CallNonvirtualLongMethodV : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, clazz: ^_jobject, methodID: ^_jmethodID, args: cstring) -> cffi.long,
CallNonvirtualLongMethodA : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, clazz: ^_jobject, methodID: ^_jmethodID, args: ^jvalue) -> cffi.long,
CallNonvirtualFloatMethod : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, clazz: ^_jobject, methodID: ^_jmethodID) -> cffi.float,
CallNonvirtualFloatMethodV : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, clazz: ^_jobject, methodID: ^_jmethodID, args: cstring) -> cffi.float,
CallNonvirtualFloatMethodA : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, clazz: ^_jobject, methodID: ^_jmethodID, args: ^jvalue) -> cffi.float,
CallNonvirtualDoubleMethod : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, clazz: ^_jobject, methodID: ^_jmethodID) -> cffi.double,
CallNonvirtualDoubleMethodV : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, clazz: ^_jobject, methodID: ^_jmethodID, args: cstring) -> cffi.double,
CallNonvirtualDoubleMethodA : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, clazz: ^_jobject, methodID: ^_jmethodID, args: ^jvalue) -> cffi.double,
CallNonvirtualVoidMethod : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, clazz: ^_jobject, methodID: ^_jmethodID),
CallNonvirtualVoidMethodV : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, clazz: ^_jobject, methodID: ^_jmethodID, args: cstring),
CallNonvirtualVoidMethodA : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, clazz: ^_jobject, methodID: ^_jmethodID, args: ^jvalue),
GetFieldID : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, name: cstring, sig: cstring) -> ^_jfieldID,
GetObjectField : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, fieldID: ^_jfieldID) -> ^_jobject,
GetBooleanField : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, fieldID: ^_jfieldID) -> cffi.uchar,
GetByteField : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, fieldID: ^_jfieldID) -> cffi.schar,
GetCharField : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, fieldID: ^_jfieldID) -> cffi.ushort,
GetShortField : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, fieldID: ^_jfieldID) -> cffi.short,
GetIntField : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, fieldID: ^_jfieldID) -> cffi.int,
GetLongField : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, fieldID: ^_jfieldID) -> cffi.long,
GetFloatField : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, fieldID: ^_jfieldID) -> cffi.float,
GetDoubleField : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, fieldID: ^_jfieldID) -> cffi.double,
SetObjectField : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, fieldID: ^_jfieldID, val: ^_jobject),
SetBooleanField : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, fieldID: ^_jfieldID, val: cffi.uchar),
SetByteField : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, fieldID: ^_jfieldID, val: cffi.schar),
SetCharField : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, fieldID: ^_jfieldID, val: cffi.ushort),
SetShortField : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, fieldID: ^_jfieldID, val: cffi.short),
SetIntField : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, fieldID: ^_jfieldID, val: cffi.int),
SetLongField : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, fieldID: ^_jfieldID, val: cffi.long),
SetFloatField : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, fieldID: ^_jfieldID, val: cffi.float),
SetDoubleField : proc "c" (env: ^^NativeInterface_, obj: ^_jobject, fieldID: ^_jfieldID, val: cffi.double),
GetStaticMethodID : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, name: cstring, sig: cstring) -> ^_jmethodID,
CallStaticObjectMethod : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, methodID: ^_jmethodID) -> ^_jobject,
CallStaticObjectMethodV : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, methodID: ^_jmethodID, args: cstring) -> ^_jobject,
CallStaticObjectMethodA : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, methodID: ^_jmethodID, args: ^jvalue) -> ^_jobject,
CallStaticBooleanMethod : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, methodID: ^_jmethodID) -> cffi.uchar,
CallStaticBooleanMethodV : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, methodID: ^_jmethodID, args: cstring) -> cffi.uchar,
CallStaticBooleanMethodA : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, methodID: ^_jmethodID, args: ^jvalue) -> cffi.uchar,
CallStaticByteMethod : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, methodID: ^_jmethodID) -> cffi.schar,
CallStaticByteMethodV : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, methodID: ^_jmethodID, args: cstring) -> cffi.schar,
CallStaticByteMethodA : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, methodID: ^_jmethodID, args: ^jvalue) -> cffi.schar,
CallStaticCharMethod : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, methodID: ^_jmethodID) -> cffi.ushort,
CallStaticCharMethodV : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, methodID: ^_jmethodID, args: cstring) -> cffi.ushort,
CallStaticCharMethodA : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, methodID: ^_jmethodID, args: ^jvalue) -> cffi.ushort,
CallStaticShortMethod : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, methodID: ^_jmethodID) -> cffi.short,
CallStaticShortMethodV : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, methodID: ^_jmethodID, args: cstring) -> cffi.short,
CallStaticShortMethodA : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, methodID: ^_jmethodID, args: ^jvalue) -> cffi.short,
CallStaticIntMethod : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, methodID: ^_jmethodID) -> cffi.int,
CallStaticIntMethodV : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, methodID: ^_jmethodID, args: cstring) -> cffi.int,
CallStaticIntMethodA : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, methodID: ^_jmethodID, args: ^jvalue) -> cffi.int,
CallStaticLongMethod : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, methodID: ^_jmethodID) -> cffi.long,
CallStaticLongMethodV : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, methodID: ^_jmethodID, args: cstring) -> cffi.long,
CallStaticLongMethodA : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, methodID: ^_jmethodID, args: ^jvalue) -> cffi.long,
CallStaticFloatMethod : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, methodID: ^_jmethodID) -> cffi.float,
CallStaticFloatMethodV : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, methodID: ^_jmethodID, args: cstring) -> cffi.float,
CallStaticFloatMethodA : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, methodID: ^_jmethodID, args: ^jvalue) -> cffi.float,
CallStaticDoubleMethod : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, methodID: ^_jmethodID) -> cffi.double,
CallStaticDoubleMethodV : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, methodID: ^_jmethodID, args: cstring) -> cffi.double,
CallStaticDoubleMethodA : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, methodID: ^_jmethodID, args: ^jvalue) -> cffi.double,
CallStaticVoidMethod : proc "c" (env: ^^NativeInterface_, cls: ^_jobject, methodID: ^_jmethodID),
CallStaticVoidMethodV : proc "c" (env: ^^NativeInterface_, cls: ^_jobject, methodID: ^_jmethodID, args: cstring),
CallStaticVoidMethodA : proc "c" (env: ^^NativeInterface_, cls: ^_jobject, methodID: ^_jmethodID, args: ^jvalue),
GetStaticFieldID : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, name: cstring, sig: cstring) -> ^_jfieldID,
GetStaticObjectField : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, fieldID: ^_jfieldID) -> ^_jobject,
GetStaticBooleanField : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, fieldID: ^_jfieldID) -> cffi.uchar,
GetStaticByteField : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, fieldID: ^_jfieldID) -> cffi.schar,
GetStaticCharField : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, fieldID: ^_jfieldID) -> cffi.ushort,
GetStaticShortField : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, fieldID: ^_jfieldID) -> cffi.short,
GetStaticIntField : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, fieldID: ^_jfieldID) -> cffi.int,
GetStaticLongField : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, fieldID: ^_jfieldID) -> cffi.long,
GetStaticFloatField : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, fieldID: ^_jfieldID) -> cffi.float,
GetStaticDoubleField : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, fieldID: ^_jfieldID) -> cffi.double,
SetStaticObjectField : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, fieldID: ^_jfieldID, value: ^_jobject),
SetStaticBooleanField : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, fieldID: ^_jfieldID, value: cffi.uchar),
SetStaticByteField : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, fieldID: ^_jfieldID, value: cffi.schar),
SetStaticCharField : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, fieldID: ^_jfieldID, value: cffi.ushort),
SetStaticShortField : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, fieldID: ^_jfieldID, value: cffi.short),
SetStaticIntField : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, fieldID: ^_jfieldID, value: cffi.int),
SetStaticLongField : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, fieldID: ^_jfieldID, value: cffi.long),
SetStaticFloatField : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, fieldID: ^_jfieldID, value: cffi.float),
SetStaticDoubleField : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, fieldID: ^_jfieldID, value: cffi.double),
NewString : proc "c" (env: ^^NativeInterface_, unicode: ^cffi.ushort, len: cffi.int) -> ^_jobject,
GetStringLength : proc "c" (env: ^^NativeInterface_, str: ^_jobject) -> cffi.int,
GetStringChars : proc "c" (env: ^^NativeInterface_, str: ^_jobject, isCopy: ^cffi.uchar) -> ^cffi.ushort,
ReleaseStringChars : proc "c" (env: ^^NativeInterface_, str: ^_jobject, chars: ^cffi.ushort),
NewStringUTF : proc "c" (env: ^^NativeInterface_, utf: cstring) -> ^_jobject,
GetStringUTFLength : proc "c" (env: ^^NativeInterface_, str: ^_jobject) -> cffi.int,
GetStringUTFChars : proc "c" (env: ^^NativeInterface_, str: ^_jobject, isCopy: ^cffi.uchar) -> cstring,
ReleaseStringUTFChars : proc "c" (env: ^^NativeInterface_, str: ^_jobject, chars: cstring),
GetArrayLength : proc "c" (env: ^^NativeInterface_, array: ^_jobject) -> cffi.int,
NewObjectArray : proc "c" (env: ^^NativeInterface_, len: cffi.int, clazz: ^_jobject, init: ^_jobject) -> ^_jobject,
GetObjectArrayElement : proc "c" (env: ^^NativeInterface_, array: ^_jobject, index: cffi.int) -> ^_jobject,
SetObjectArrayElement : proc "c" (env: ^^NativeInterface_, array: ^_jobject, index: cffi.int, val: ^_jobject),
NewBooleanArray : proc "c" (env: ^^NativeInterface_, len: cffi.int) -> ^_jobject,
NewByteArray : proc "c" (env: ^^NativeInterface_, len: cffi.int) -> ^_jobject,
NewCharArray : proc "c" (env: ^^NativeInterface_, len: cffi.int) -> ^_jobject,
NewShortArray : proc "c" (env: ^^NativeInterface_, len: cffi.int) -> ^_jobject,
NewIntArray : proc "c" (env: ^^NativeInterface_, len: cffi.int) -> ^_jobject,
NewLongArray : proc "c" (env: ^^NativeInterface_, len: cffi.int) -> ^_jobject,
NewFloatArray : proc "c" (env: ^^NativeInterface_, len: cffi.int) -> ^_jobject,
NewDoubleArray : proc "c" (env: ^^NativeInterface_, len: cffi.int) -> ^_jobject,
GetBooleanArrayElements : proc "c" (env: ^^NativeInterface_, array: ^_jobject, isCopy: ^cffi.uchar) -> ^cffi.uchar,
GetByteArrayElements : proc "c" (env: ^^NativeInterface_, array: ^_jobject, isCopy: ^cffi.uchar) -> ^cffi.schar,
GetCharArrayElements : proc "c" (env: ^^NativeInterface_, array: ^_jobject, isCopy: ^cffi.uchar) -> ^cffi.ushort,
GetShortArrayElements : proc "c" (env: ^^NativeInterface_, array: ^_jobject, isCopy: ^cffi.uchar) -> ^cffi.short,
GetIntArrayElements : proc "c" (env: ^^NativeInterface_, array: ^_jobject, isCopy: ^cffi.uchar) -> ^cffi.int,
GetLongArrayElements : proc "c" (env: ^^NativeInterface_, array: ^_jobject, isCopy: ^cffi.uchar) -> ^cffi.long,
GetFloatArrayElements : proc "c" (env: ^^NativeInterface_, array: ^_jobject, isCopy: ^cffi.uchar) -> ^cffi.float,
GetDoubleArrayElements : proc "c" (env: ^^NativeInterface_, array: ^_jobject, isCopy: ^cffi.uchar) -> ^cffi.double,
ReleaseBooleanArrayElements : proc "c" (env: ^^NativeInterface_, array: ^_jobject, elems: ^cffi.uchar, mode: cffi.int),
ReleaseByteArrayElements : proc "c" (env: ^^NativeInterface_, array: ^_jobject, elems: ^cffi.schar, mode: cffi.int),
ReleaseCharArrayElements : proc "c" (env: ^^NativeInterface_, array: ^_jobject, elems: ^cffi.ushort, mode: cffi.int),
ReleaseShortArrayElements : proc "c" (env: ^^NativeInterface_, array: ^_jobject, elems: ^cffi.short, mode: cffi.int),
ReleaseIntArrayElements : proc "c" (env: ^^NativeInterface_, array: ^_jobject, elems: ^cffi.int, mode: cffi.int),
ReleaseLongArrayElements : proc "c" (env: ^^NativeInterface_, array: ^_jobject, elems: ^cffi.long, mode: cffi.int),
ReleaseFloatArrayElements : proc "c" (env: ^^NativeInterface_, array: ^_jobject, elems: ^cffi.float, mode: cffi.int),
ReleaseDoubleArrayElements : proc "c" (env: ^^NativeInterface_, array: ^_jobject, elems: ^cffi.double, mode: cffi.int),
GetBooleanArrayRegion : proc "c" (env: ^^NativeInterface_, array: ^_jobject, start: cffi.int, l: cffi.int, buf: ^cffi.uchar),
GetByteArrayRegion : proc "c" (env: ^^NativeInterface_, array: ^_jobject, start: cffi.int, len: cffi.int, buf: ^cffi.schar),
GetCharArrayRegion : proc "c" (env: ^^NativeInterface_, array: ^_jobject, start: cffi.int, len: cffi.int, buf: ^cffi.ushort),
GetShortArrayRegion : proc "c" (env: ^^NativeInterface_, array: ^_jobject, start: cffi.int, len: cffi.int, buf: ^cffi.short),
GetIntArrayRegion : proc "c" (env: ^^NativeInterface_, array: ^_jobject, start: cffi.int, len: cffi.int, buf: ^cffi.int),
GetLongArrayRegion : proc "c" (env: ^^NativeInterface_, array: ^_jobject, start: cffi.int, len: cffi.int, buf: ^cffi.long),
GetFloatArrayRegion : proc "c" (env: ^^NativeInterface_, array: ^_jobject, start: cffi.int, len: cffi.int, buf: ^cffi.float),
GetDoubleArrayRegion : proc "c" (env: ^^NativeInterface_, array: ^_jobject, start: cffi.int, len: cffi.int, buf: ^cffi.double),
SetBooleanArrayRegion : proc "c" (env: ^^NativeInterface_, array: ^_jobject, start: cffi.int, l: cffi.int, buf: ^cffi.uchar),
SetByteArrayRegion : proc "c" (env: ^^NativeInterface_, array: ^_jobject, start: cffi.int, len: cffi.int, buf: ^cffi.schar),
SetCharArrayRegion : proc "c" (env: ^^NativeInterface_, array: ^_jobject, start: cffi.int, len: cffi.int, buf: ^cffi.ushort),
SetShortArrayRegion : proc "c" (env: ^^NativeInterface_, array: ^_jobject, start: cffi.int, len: cffi.int, buf: ^cffi.short),
SetIntArrayRegion : proc "c" (env: ^^NativeInterface_, array: ^_jobject, start: cffi.int, len: cffi.int, buf: ^cffi.int),
SetLongArrayRegion : proc "c" (env: ^^NativeInterface_, array: ^_jobject, start: cffi.int, len: cffi.int, buf: ^cffi.long),
SetFloatArrayRegion : proc "c" (env: ^^NativeInterface_, array: ^_jobject, start: cffi.int, len: cffi.int, buf: ^cffi.float),
SetDoubleArrayRegion : proc "c" (env: ^^NativeInterface_, array: ^_jobject, start: cffi.int, len: cffi.int, buf: ^cffi.double),
RegisterNatives : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject, methods: ^NativeMethod, nMethods: cffi.int) -> cffi.int,
UnregisterNatives : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject) -> cffi.int,
MonitorEnter : proc "c" (env: ^^NativeInterface_, obj: ^_jobject) -> cffi.int,
MonitorExit : proc "c" (env: ^^NativeInterface_, obj: ^_jobject) -> cffi.int,
GetJavaVM : proc "c" (env: ^^NativeInterface_, vm: ^^^InvokeInterface) -> cffi.int,
GetStringRegion : proc "c" (env: ^^NativeInterface_, str: ^_jobject, start: cffi.int, len: cffi.int, buf: ^cffi.ushort),
GetStringUTFRegion : proc "c" (env: ^^NativeInterface_, str: ^_jobject, start: cffi.int, len: cffi.int, buf: cstring),
GetPrimitiveArrayCritical : proc "c" (env: ^^NativeInterface_, array: ^_jobject, isCopy: ^cffi.uchar) -> rawptr,
ReleasePrimitiveArrayCritical : proc "c" (env: ^^NativeInterface_, array: ^_jobject, carray: rawptr, mode: cffi.int),
GetStringCritical : proc "c" (env: ^^NativeInterface_, string: ^_jobject, isCopy: ^cffi.uchar) -> ^cffi.ushort,
ReleaseStringCritical : proc "c" (env: ^^NativeInterface_, string: ^_jobject, cstring: ^cffi.ushort),
NewWeakGlobalRef : proc "c" (env: ^^NativeInterface_, obj: ^_jobject) -> ^_jobject,
DeleteWeakGlobalRef : proc "c" (env: ^^NativeInterface_, ref: ^_jobject),
ExceptionCheck : proc "c" (env: ^^NativeInterface_) -> cffi.uchar,
NewDirectByteBuffer : proc "c" (env: ^^NativeInterface_, address: rawptr, capacity: cffi.long) -> ^_jobject,
GetDirectBufferAddress : proc "c" (env: ^^NativeInterface_, buf: ^_jobject) -> rawptr,
GetDirectBufferCapacity : proc "c" (env: ^^NativeInterface_, buf: ^_jobject) -> cffi.long,
GetObjectRefType : proc "c" (env: ^^NativeInterface_, obj: ^_jobject) -> jobjectRefType,
GetModule : proc "c" (env: ^^NativeInterface_, clazz: ^_jobject) -> ^_jobject,
}
/// JNIEnv_
Env_ :: struct #align (8) {
functions : ^NativeInterface_,
}
/// JNIInvokeInterface_
InvokeInterface :: struct #align (8) {
reserved0 : rawptr,
reserved1 : rawptr,
reserved2 : rawptr,
DestroyJavaVM : proc "c" (vm: ^^InvokeInterface) -> cffi.int,
AttachCurrentThread : proc "c" (vm: ^^InvokeInterface, penv: ^rawptr, args: rawptr) -> cffi.int,
DetachCurrentThread : proc "c" (vm: ^^InvokeInterface) -> cffi.int,
GetEnv : proc "c" (vm: ^^InvokeInterface, penv: ^rawptr, version: cffi.int) -> cffi.int,
AttachCurrentThreadAsDaemon : proc "c" (vm: ^^InvokeInterface, penv: ^rawptr, args: rawptr) -> cffi.int,
}
/// JavaVM_
JavaVM_ :: struct #align (8) {
functions : ^InvokeInterface,
}
/// JavaVMOption
JavaVMOption :: struct #align (8) {
optionString : cstring,
extraInfo : rawptr,
}
/// JavaVMInitArgs
JavaVMInitArgs :: struct #align (8) {
version : cffi.int,
nOptions : cffi.int,
options : ^JavaVMOption,
ignoreUnrecognized : cffi.uchar,
}
/// JavaVMAttachArgs
JavaVMAttachArgs :: struct #align (8) {
version : cffi.int,
name : cstring,
group : ^_jobject,
}
/// jvalue
jvalue :: struct {
z : cffi.uchar,
b : cffi.schar,
c : cffi.ushort,
s : cffi.short,
i : cffi.int,
j : cffi.long,
f : cffi.float,
d : cffi.double,
l : ^_jobject,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment