00001
00015 #ifndef _JNILIB_H_
00016 #define _JNILIB_H_
00017
00018
00019
00020 #include "jni.h"
00021 #include <stdlib.h>
00022 #include <string.h>
00023
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027
00028 struct Jvm_;
00029
00030 struct JvmCPP_;
00031
00032 #ifdef __cplusplus
00033 typedef JvmCPP_ Jvm;
00034 #else
00035 typedef struct Jvm_ Jvm;
00036 #endif
00037
00041 typedef struct JvmData {
00042 JavaVM* jvm;
00043 JavaVMInitArgs vm_args;
00044 JNIEnv* env;
00045 const char* classpath;
00046 } JvmData;
00047
00051 typedef struct Jvm_ {
00052 JvmData jvm;
00053 jint (*destroyJvm)(Jvm* jvm);
00054 } Jvm_;
00055
00059 typedef struct JvmCPP_ {
00060 JvmData jvm;
00061 struct Jvm_ *functions;
00062
00063 #ifdef __cplusplus
00064
00065 jint destroyJvm() {
00066 return functions->destroyJvm(this);
00067 }
00068
00069 #endif
00070
00071 } JvmCPP_;
00072
00073 void initJvm(Jvm* jvm, const char* classpath);
00074
00075 JavaVM* getJavaVM();
00076 JNIEnv* getJNIEnv();
00077
00078 jobject newObject(jclass cls, jmethodID mid, ...);
00079 jobject newObjectBySignature(jclass cls, const char* signature, ...);
00080
00081 void callStaticVoidMethod(jclass cls, jmethodID mid, ...);
00082 jint callStaticIntMethod(jclass cls, jmethodID mid, ...);
00083 jobject callStaticObjectMethod(jclass cls, jmethodID mid, ...);
00084
00085 void callVoidMethod(jobject obj, jmethodID mid, ...);
00086 jboolean callBooleanMethod(jobject obj, jmethodID mid, ...);
00087 jbyte callByteMethod(jobject obj, jmethodID mid, ...);
00088 jchar callCharMethod(jobject obj, jmethodID mid, ...);
00089 jshort callShortMethod(jobject obj, jmethodID mid, ...);
00090 jint callIntMethod(jobject obj, jmethodID mid, ...);
00091 jlong callLongMethod(jobject obj, jmethodID mid, ...);
00092 jfloat callFloatMethod(jobject obj, jmethodID mid, ...);
00093 jdouble callDoubleMethod(jobject obj, jmethodID mid, ...);
00094 jobject callObjectMethod(jobject obj, jmethodID mid, ...);
00095
00096 void callVoidMethodByName(jobject obj, const char* method, const char* signature, ...);
00097 jboolean callBooleanMethodByName(jobject obj, const char* method, const char* signature, ...);
00098 jbyte callByteMethodByName(jobject obj, const char* method, const char* signature, ...);
00099 jchar callCharMethodByName(jobject obj, const char* method, const char* signature, ...);
00100 jshort callShortMethodByName(jobject obj, const char* method, const char* signature, ...);
00101 jint callIntMethodByName(jobject obj, const char* method, const char* signature, ...);
00102 jlong callLongMethodByName(jobject obj, const char* method, const char* signature, ...);
00103 jfloat callFloatMethodByName(jobject obj, const char* method, const char* signature, ...);
00104 jdouble callDoubleMethodByName(jobject obj, const char* method, const char* signature, ...);
00105 jobject callObjectMethodByName(jobject obj, const char* method, const char* signature, ...);
00106
00107 jint getStaticIntFieldByName(const char* strclass, const char* strfield);
00108 jobject getStaticObjectFieldByName(const char* strclass, const char* strfield, const char* signature);
00109
00110 jclass findClass(const char* strclass);
00111 jclass getObjectClass(jobject obj);
00112 jmethodID findStaticMethod(jclass cls, const char* method, const char* signature);
00113 jmethodID findMethod(jclass cls, const char* method, const char* signature);
00114 jfieldID findStaticField(jclass cls, const char* field, const char* signature);
00115 jint registerNatives(jclass cls, const JNINativeMethod* nm, jint nMethods);
00116 jobject createGlobalReference(jobject obj);
00117 void deleteGlobalReference(jobject obj);
00118 void deleteLocalReference(jobject);
00119
00120 jboolean exception();
00121 void throwByName(const char *name, const char *msg);
00122
00123 jboolean isSameObject(jobject obj1, jobject obj2);
00124
00125 jstring createJString(const char* str);
00126
00127 char* convertJString(jstring jstr);
00128
00129 void jnisleep(jint ms);
00130
00131 #ifdef __cplusplus
00132 }
00133 #endif
00134
00135 #endif
00136
00137