Add lime.utils.JNI, initially supporting JNI.getEnv
This commit is contained in:
33
lime/utils/JNI.hx
Normal file
33
lime/utils/JNI.hx
Normal file
@@ -0,0 +1,33 @@
|
||||
package lime.utils;
|
||||
|
||||
|
||||
import lime.system.System;
|
||||
|
||||
|
||||
class JNI {
|
||||
|
||||
|
||||
public static function getEnv ():Dynamic {
|
||||
|
||||
#if android
|
||||
return lime_jni_getenv ();
|
||||
#else
|
||||
return null;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Native Methods
|
||||
|
||||
|
||||
|
||||
|
||||
#if (cpp || neko || nodejs)
|
||||
private static var lime_jni_getenv = System.load ("lime", "lime_jni_getenv", 0);
|
||||
#end
|
||||
|
||||
|
||||
}
|
||||
@@ -135,6 +135,7 @@
|
||||
<file name="src/backend/sdl/SDLRenderer.cpp" />
|
||||
<file name="src/backend/sdl/SDLMouse.cpp" />
|
||||
<file name="src/backend/sdl/SDLSystem.cpp" />
|
||||
<file name="src/backend/sdl/SDLJNI.cpp" />
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
22
project/include/utils/JNI.h
Normal file
22
project/include/utils/JNI.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef LIME_UTILS_JNI_H
|
||||
#define LIME_UTILS_JNI_H
|
||||
|
||||
|
||||
namespace lime {
|
||||
|
||||
|
||||
class JNI {
|
||||
|
||||
|
||||
public:
|
||||
|
||||
static void *GetEnv ();
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <ui/TouchEvent.h>
|
||||
#include <ui/Window.h>
|
||||
#include <ui/WindowEvent.h>
|
||||
#include <utils/JNI.h>
|
||||
#include <vm/NekoVM.h>
|
||||
|
||||
|
||||
@@ -295,6 +296,17 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value lime_jni_getenv () {
|
||||
|
||||
#ifdef ANDROID
|
||||
return alloc_float ((intptr_t)JNI::GetEnv ());
|
||||
#else
|
||||
return alloc_null ();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_key_event_manager_register (value callback, value eventObject) {
|
||||
|
||||
KeyEvent::callback = new AutoGCRoot (callback);
|
||||
@@ -531,6 +543,7 @@ namespace lime {
|
||||
DEFINE_PRIM (lime_font_outline_decompose, 2);
|
||||
DEFINE_PRIM (lime_image_encode, 3);
|
||||
DEFINE_PRIM (lime_image_load, 1);
|
||||
DEFINE_PRIM (lime_jni_getenv, 0);
|
||||
DEFINE_PRIM (lime_key_event_manager_register, 2);
|
||||
DEFINE_PRIM (lime_lzma_encode, 1);
|
||||
DEFINE_PRIM (lime_lzma_decode, 1);
|
||||
|
||||
21
project/src/backend/sdl/SDLJNI.cpp
Normal file
21
project/src/backend/sdl/SDLJNI.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifdef ANDROID
|
||||
|
||||
|
||||
#include <utils/JNI.h>
|
||||
#include <SDL_system.h>
|
||||
|
||||
|
||||
namespace lime {
|
||||
|
||||
|
||||
void *JNI::GetEnv () {
|
||||
|
||||
return SDL_AndroidGetJNIEnv ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user