java: Updated gpio.c to use JNI functions set in mraa_lang_func
This is a re-design of commit 0041801. mraa_lang_func_t structure has been added (similar in design to mraa_adv_func_t) that points to JNI functions implemented in src/java/mraajni.c. Functions are set by libmraajava.so, see wrapper entry in src/java/mraajava.i. As gpio.c now uses these functions, language specific #ifdef code has been removed as JNI code is only called if functions are defined (i.e. not NULL) Signed-off-by: Henry Bruce <henry.bruce@intel.com> Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
committed by
Brendan Le Foll
parent
d313ac0579
commit
44b2367fdc
@@ -66,12 +66,21 @@ class Spi;
|
||||
|
||||
%wrapper %{
|
||||
#include "java/mraajni.h"
|
||||
#include "mraa_lang_func.h"
|
||||
extern mraa_lang_func_t* lang_func;
|
||||
|
||||
jint JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
/* initialize mraa */
|
||||
mraa_java_set_jvm(vm);
|
||||
mraa_init();
|
||||
return JNI_VERSION_1_6;
|
||||
/* initialize mraa and set jni functions */
|
||||
mraa_result_t res = mraa_init();
|
||||
if (res == MRAA_SUCCESS || res == MRAA_ERROR_PLATFORM_ALREADY_INITIALISED) {
|
||||
mraa_java_set_jvm(vm);
|
||||
lang_func->java_isr_callback = &mraa_java_isr_callback;
|
||||
lang_func->java_attach_thread = &mraa_java_attach_thread;
|
||||
lang_func->java_detach_thread = &mraa_java_detach_thread;
|
||||
lang_func->java_create_global_ref = &mraa_java_create_global_ref;
|
||||
lang_func->java_delete_global_ref = &mraa_java_delete_global_ref;
|
||||
}
|
||||
return JNI_VERSION_1_8;
|
||||
}
|
||||
%}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user