浏览代码

Added java JNI module.

Mark Sibly 8 年之前
父节点
当前提交
e30817af3f
共有 4 个文件被更改,包括 70 次插入0 次删除
  1. 29 0
      modules/jni/jni.monkey2
  2. 8 0
      modules/jni/module.json
  3. 23 0
      modules/jni/native/jni_glue.cpp
  4. 10 0
      modules/jni/native/jni_glue.h

+ 29 - 0
modules/jni/jni.monkey2

@@ -0,0 +1,29 @@
+
+Namespace jni
+
+#If __TARGET__="android"
+
+#Import "<mojo>"
+
+#Import "native/jni_glue.cpp"
+#Import "native/jni_glue.h"
+
+Extern
+
+Class jobject Extends Void
+End
+
+Class jclass Extends jobject
+End
+
+Class jfieldID Extends Void
+End
+
+Class jmethodID Extends Void
+End
+
+Function FindClass:jclass( name:CString )="bbJNI::FindClass"
+
+Function GetMethodID( clazz:jclass,name:CString,sig:CString )="bbJNI::GetMethodID"
+
+#End

+ 8 - 0
modules/jni/module.json

@@ -0,0 +1,8 @@
+{
+	"module":"jni",
+	"about":"Java JNI wrapper",
+	"author":"Mark Sibly",
+	"version":"1.0.0",
+	"support":"http://monkey2.monkey-x.com",
+	"depends":["mojo"]
+}

+ 23 - 0
modules/jni/native/jni_glue.cpp

@@ -0,0 +1,23 @@
+
+#include "jni_glue.h"
+
+extern "C"{
+	JNIEnv *Android_JNI_GetEnv(void);
+}
+
+namespace bbJNI{
+
+	jclass FindClass( const char *name ){
+	
+		JNIEnv *env=Android_JNI_GetEnv();
+		
+		return env->FindClass( name );
+	}
+
+	jmethodID GetMethodID( jclass clazz,const char *name,const char *sig ){
+	
+		JNIEnv *env=Android_JNI_GetEnv();
+		
+		return env->GetMethodID( clazz,name,sig );
+	}
+}

+ 10 - 0
modules/jni/native/jni_glue.h

@@ -0,0 +1,10 @@
+
+#include <jni.h>
+
+namespace bbJNI{
+
+	jclass FindClass( const char *name );
+	
+	jmethodID GetMethodID( jclass clazz,const char *name,const char *sig );
+	
+}