mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 01:15:35 +00:00
app/internal/window: [Android] remove JNI_OnLoad JNI callback
There can only be one JNI_OnLoad callback per JNI library, and the Gio program may need it for its own purposes. Gio only used JNI_OnLoad for explicitly registering native methods. Switch to implicit name based registration and get rid of JNI_OnLoad. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -4,101 +4,6 @@
|
||||
#include "os_android.h"
|
||||
#include "_cgo_export.h"
|
||||
|
||||
JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
JNIEnv *env;
|
||||
if ((*vm)->GetEnv(vm, (void**)&env, JNI_VERSION_1_6) != JNI_OK) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
jclass viewClass = (*env)->FindClass(env, "org/gioui/GioView");
|
||||
if (viewClass == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
static const JNINativeMethod methods[] = {
|
||||
{
|
||||
.name = "runGoMain",
|
||||
.signature = "([BLandroid/content/Context;)V",
|
||||
.fnPtr = runGoMain
|
||||
},
|
||||
{
|
||||
.name = "onCreateView",
|
||||
.signature = "(Lorg/gioui/GioView;)J",
|
||||
.fnPtr = onCreateView
|
||||
},
|
||||
{
|
||||
.name = "onDestroyView",
|
||||
.signature = "(J)V",
|
||||
.fnPtr = onDestroyView
|
||||
},
|
||||
{
|
||||
.name = "onStartView",
|
||||
.signature = "(J)V",
|
||||
.fnPtr = onStartView
|
||||
},
|
||||
{
|
||||
.name = "onStopView",
|
||||
.signature = "(J)V",
|
||||
.fnPtr = onStopView
|
||||
},
|
||||
{
|
||||
.name = "onSurfaceDestroyed",
|
||||
.signature = "(J)V",
|
||||
.fnPtr = onSurfaceDestroyed
|
||||
},
|
||||
{
|
||||
.name = "onSurfaceChanged",
|
||||
.signature = "(JLandroid/view/Surface;)V",
|
||||
.fnPtr = onSurfaceChanged
|
||||
},
|
||||
{
|
||||
.name = "onConfigurationChanged",
|
||||
.signature = "(J)V",
|
||||
.fnPtr = onConfigurationChanged
|
||||
},
|
||||
{
|
||||
.name = "onWindowInsets",
|
||||
.signature = "(JIIII)V",
|
||||
.fnPtr = onWindowInsets
|
||||
},
|
||||
{
|
||||
.name = "onLowMemory",
|
||||
.signature = "()V",
|
||||
.fnPtr = onLowMemory
|
||||
},
|
||||
{
|
||||
.name = "onTouchEvent",
|
||||
.signature = "(JIIIFFIJ)V",
|
||||
.fnPtr = onTouchEvent
|
||||
},
|
||||
{
|
||||
.name = "onKeyEvent",
|
||||
.signature = "(JIIJ)V",
|
||||
.fnPtr = onKeyEvent
|
||||
},
|
||||
{
|
||||
.name = "onFrameCallback",
|
||||
.signature = "(JJ)V",
|
||||
.fnPtr = onFrameCallback
|
||||
},
|
||||
{
|
||||
.name = "onBack",
|
||||
.signature = "(J)Z",
|
||||
.fnPtr = onBack
|
||||
},
|
||||
{
|
||||
.name = "onFocusChange",
|
||||
.signature = "(JZ)V",
|
||||
.fnPtr = onFocusChange
|
||||
}
|
||||
};
|
||||
if ((*env)->RegisterNatives(env, viewClass, methods, sizeof(methods)/sizeof(methods[0])) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return JNI_VERSION_1_6;
|
||||
}
|
||||
|
||||
jint gio_jni_GetEnv(JavaVM *vm, JNIEnv **env, jint version) {
|
||||
return (*vm)->GetEnv(vm, (void **)env, version);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user