Commit d4edad2b by leiguo1029

4/1

parent c06620d7
...@@ -18,7 +18,23 @@ jobject wdNewObject(JNIEnv* env, const char* clsName, const char* methodSig, ... ...@@ -18,7 +18,23 @@ jobject wdNewObject(JNIEnv* env, const char* clsName, const char* methodSig, ...
jvalue wdCallStaticMethod(JNIEnv* env, const char* clsName, const char* methodName, const char* methodSig, ...); jvalue wdCallStaticMethod(JNIEnv* env, const char* clsName, const char* methodName, const char* methodSig, ...);
jvalue wdCallMethod(JNIEnv* env, jobject obj, const char* methodName, const char* methodSig, ...); jvalue wdCallMethod(JNIEnv* env, jobject obj, const char* methodName, const char* methodSig, ...);
jboolean wdCallStaticBooleanMethod(JNIEnv* env, const char* clsName, const char* methodName, const char* methodSig, ...); jboolean wdCallStaticBooleanMethod(JNIEnv* env, const char* clsName, const char* methodName, const char* methodSig, ...);
jbyte wdCallStaticByteMethod(JNIEnv* env, const char* clsName, const char* methodName, const char* methodSig, ...);
jchar wdCallStaticCharMethod(JNIEnv* env, const char* clsName, const char* methodName, const char* methodSig, ...);
jshort wdCallStaticShortMethod(JNIEnv* env, const char* clsName, const char* methodName, const char* methodSig, ...);
jint wdCallStaticIntMethod(JNIEnv* env, const char* clsName, const char* methodName, const char* methodSig, ...);
jlong wdCallStaticLongMethod(JNIEnv* env, const char* clsName, const char* methodName, const char* methodSig, ...);
jfloat wdCallStaticFloatMethod(JNIEnv* env, const char* clsName, const char* methodName, const char* methodSig, ...);
jdouble wdCallStaticDoubleMethod(JNIEnv* env, const char* clsName, const char* methodName, const char* methodSig, ...);
void wdCallStaticVoidMethod(JNIEnv* env, const char* clsName, const char* methodName, const char* methodSig, ...);
jboolean wdCallBooleanMethod(JNIEnv* env, jobject obj, const char* methodName, const char* methodSig, ...);
jbyte wdCallByteMethod(JNIEnv* env, jobject obj, const char* methodName, const char* methodSig, ...);
jchar wdCallCharMethod(JNIEnv* env, jobject obj, const char* methodName, const char* methodSig, ...);
jshort wdCallShortMethod(JNIEnv* env, jobject obj, const char* methodName, const char* methodSig, ...);
jint wdCallIntMethod(JNIEnv* env, jobject obj, const char* methodName, const char* methodSig, ...);
jlong wdCallLongMethod(JNIEnv* env, jobject obj, const char* methodName, const char* methodSig, ...);
jfloat wdCallFloatMethod(JNIEnv* env, jobject obj, const char* methodName, const char* methodSig, ...);
jdouble wdCallDoubleMethod(JNIEnv* env, jobject obj, const char* methodName, const char* methodSig, ...);
void wdCallVoidMethod(JNIEnv* env, jobject obj, const char* methodName, const char* methodSig, ...);
inline jboolean wdGetStaticBooleanField(JNIEnv* env, const char* clsName, const char* fieldName, const char* fieldSig) { inline jboolean wdGetStaticBooleanField(JNIEnv* env, const char* clsName, const char* fieldName, const char* fieldSig) {
return wdGetStaticField(env, clsName, fieldName, fieldSig).z; return wdGetStaticField(env, clsName, fieldName, fieldSig).z;
......
...@@ -28,7 +28,7 @@ jvalue wdGetStaticField(JNIEnv* env, const char* clsName, const char* fieldName, ...@@ -28,7 +28,7 @@ jvalue wdGetStaticField(JNIEnv* env, const char* clsName, const char* fieldName,
jfieldID fieldId = env->GetStaticFieldID(cls, fieldName, fieldSig); jfieldID fieldId = env->GetStaticFieldID(cls, fieldName, fieldSig);
jvalue value; jvalue value;
memset(value, 0, sizeof(jvalue)); memset(value, 0, sizeof(jvalue));
switch(wdGetMethodRetType(fieldSig)) { switch(wdGetFieldType(fieldSig)) {
case '[': case '[':
case 'L': case 'L':
value.l = env->GetStaticObjectField(cls, fieldId); value.l = env->GetStaticObjectField(cls, fieldId);
...@@ -69,7 +69,7 @@ jvalue wdGetField(JNIEnv* env, jobject obj, const char* fieldName, const char* f ...@@ -69,7 +69,7 @@ jvalue wdGetField(JNIEnv* env, jobject obj, const char* fieldName, const char* f
jfieldID fieldId = env->GetFieldID(cls, fieldName, fieldSig); jfieldID fieldId = env->GetFieldID(cls, fieldName, fieldSig);
jvalue value; jvalue value;
memset(value, 0, sizeof(jvalue)); memset(value, 0, sizeof(jvalue));
switch(wdGetMethodRetType(fieldSig)) { switch(wdGetFieldType(fieldSig)) {
case '[': case '[':
case 'L': case 'L':
value.l = env->GetObjectField(cls, fieldId); value.l = env->GetObjectField(cls, fieldId);
...@@ -108,7 +108,7 @@ jvalue wdGetField(JNIEnv* env, jobject obj, const char* fieldName, const char* f ...@@ -108,7 +108,7 @@ jvalue wdGetField(JNIEnv* env, jobject obj, const char* fieldName, const char* f
void wdSetStaticField(JNIEnv* env, const char* clsName, const char* fieldName, const char* fieldSig, jvalue value) { void wdSetStaticField(JNIEnv* env, const char* clsName, const char* fieldName, const char* fieldSig, jvalue value) {
jclass cls = env->FindClass(clsName); jclass cls = env->FindClass(clsName);
jfieldID fieldId = env->GetStaticFieldID(cls, fieldName, fieldSig); jfieldID fieldId = env->GetStaticFieldID(cls, fieldName, fieldSig);
switch(wdGetMethodRetType(fieldSig)) { switch(wdGetFieldType(fieldSig)) {
case '[': case '[':
case 'L': case 'L':
env->SetStaticObjectField(cls, fieldId, value.l); env->SetStaticObjectField(cls, fieldId, value.l);
...@@ -146,7 +146,7 @@ void wdSetStaticField(JNIEnv* env, const char* clsName, const char* fieldName, c ...@@ -146,7 +146,7 @@ void wdSetStaticField(JNIEnv* env, const char* clsName, const char* fieldName, c
void wdSetField(JNIEnv* env, jobject obj, const char* fieldName, const char* fieldSig, jvalue value) { void wdSetField(JNIEnv* env, jobject obj, const char* fieldName, const char* fieldSig, jvalue value) {
jclass cls = env->GetObjectClass(cls); jclass cls = env->GetObjectClass(cls);
jfieldID fieldId = env->GetFieldID(cls, fieldName, fieldSig); jfieldID fieldId = env->GetFieldID(cls, fieldName, fieldSig);
switch(wdGetMethodRetType(fieldSig)) { switch(wdGetFieldType(fieldSig)) {
case '[': case '[':
case 'L': case 'L':
env->SetObjectField(obj, fieldId, value.l); env->SetObjectField(obj, fieldId, value.l);
...@@ -231,6 +231,7 @@ jvalue wdCallStaticMethod(JNIEnv* env, const char* clsName, const char* methodNa ...@@ -231,6 +231,7 @@ jvalue wdCallStaticMethod(JNIEnv* env, const char* clsName, const char* methodNa
case 'D': case 'D':
value.d = env->CallStaticDoubleMethodV(cls, methodId, args); value.d = env->CallStaticDoubleMethodV(cls, methodId, args);
break; break;
default: break;
} }
wdCheckException(env); wdCheckException(env);
env->DeleteLocalRef(cls); env->DeleteLocalRef(cls);
...@@ -274,6 +275,7 @@ jvalue wdCallMethod(JNIEnv* env, jobject obj, const char* methodName, const char ...@@ -274,6 +275,7 @@ jvalue wdCallMethod(JNIEnv* env, jobject obj, const char* methodName, const char
case 'D': case 'D':
value.d = env->CallDoubleMethodV(obj, methodId, args); value.d = env->CallDoubleMethodV(obj, methodId, args);
break; break;
default: break;
} }
wdCheckException(env); wdCheckException(env);
env->DeleteLocalRef(cls); env->DeleteLocalRef(cls);
...@@ -320,7 +322,7 @@ jint wdCallStaticIntMethod(JNIEnv* env, const char* clsName, const char* methodN ...@@ -320,7 +322,7 @@ jint wdCallStaticIntMethod(JNIEnv* env, const char* clsName, const char* methodN
return res; return res;
} }
jlong wdCallStaticlongMethod(JNIEnv* env, const char* clsName, const char* methodName, const char* methodSig, ...) { jlong wdCallStaticLongMethod(JNIEnv* env, const char* clsName, const char* methodName, const char* methodSig, ...) {
va_list args; va_list args;
va_start(args, methodSig); va_start(args, methodSig);
jlong res = wdCallStaticMethod(env, clsName, methodName, methodSig, args).j; jlong res = wdCallStaticMethod(env, clsName, methodName, methodSig, args).j;
...@@ -328,6 +330,120 @@ jlong wdCallStaticlongMethod(JNIEnv* env, const char* clsName, const char* metho ...@@ -328,6 +330,120 @@ jlong wdCallStaticlongMethod(JNIEnv* env, const char* clsName, const char* metho
return res; return res;
} }
jfloat wdCallStaticFloatMethod(JNIEnv* env, const char* clsName, const char* methodName, const char* methodSig, ...) {
va_list args;
va_start(args, methodSig);
jfloat res = wdCallStaticMethod(env, clsName, methodName, methodSig, args).f;
va_end(args);
return res;
}
jdouble wdCallStaticDoubleMethod(JNIEnv* env, const char* clsName, const char* methodName, const char* methodSig, ...) {
va_list args;
va_start(args, methodSig);
jdouble res = wdCallStaticMethod(env, clsName, methodName, methodSig, args).d;
va_end(args);
return res;
}
jobject wdCallStaticObjectMethod(JNIEnv* env, const char* clsName, const char* methodName, const char* methodSig, ...) {
va_list args;
va_start(args, methodSig);
jobject res = wdCallStaticMethod(env, clsName, methodName, methodSig, args).l;
va_end(args);
return res;
}
void wdCallStaticVoidMethod(JNIEnv* env, const char* clsName, const char* methodName, const char* methodSig, ...) {
va_list args;
va_start(args, methodSig);
wdCallStaticMethod(env, clsName, methodName, methodSig, args);
va_end(args);
}
jboolean wdCallBooleanMethod(JNIEnv* env, jobject obj, const char* methodName, const char* methodSig, ...) {
va_list args;
va_start(args, methodSig);
jboolean res = wdCallMethod(env, obj, methodName, methodSig, args).z;
va_end(args);
return res;
}
jbyte wdCallByteMethod(JNIEnv* env, jobject obj, const char* methodName, const char* methodSig, ...) {
va_list args;
va_start(args, methodSig);
jboolean res = wdCallMethod(env, obj, methodName, methodSig, args).b;
va_end(args);
return res;
}
jchar wdCallCharMethod(JNIEnv* env, jobject obj, const char* methodName, const char* methodSig, ...) {
va_list args;
va_start(args, methodSig);
jchar res = wdCallMethod(env, obj, methodName, methodSig, args).c;
va_end(args);
return res;
}
jshort wdCallShortMethod(JNIEnv* env, jobject obj, const char* methodName, const char* methodSig, ...) {
va_list args;
va_start(args, methodSig);
jshort res = wdCallMethod(env, obj, methodName, methodSig, args).s;
va_end(args);
return res;
}
jint wdCallIntMethod(JNIEnv* env, jobject obj, const char* methodName, const char* methodSig, ...) {
va_list args;
va_start(args, methodSig);
jint res = wdCallMethod(env, obj, methodName, methodSig, args).i;
va_end(args);
return res;
}
jlong wdCallLongMethod(JNIEnv* env, jobject obj, const char* methodName, const char* methodSig, ...) {
va_list args;
va_start(args, methodSig);
jlong res = wdCallMethod(env, obj, methodName, methodSig, args).j;
va_end(args);
return res;
}
jfloat wdCallFloatMethod(JNIEnv* env, jobject obj, const char* methodName, const char* methodSig, ...) {
va_list args;
va_start(args, methodSig);
jfloat res = wdCallMethod(env, obj, methodName, methodSig, args).f;
va_end(args);
return res;
}
jdouble wdCallDoubleMethod(JNIEnv* env, jobject obj, const char* methodName, const char* methodSig, ...) {
va_list args;
va_start(args, methodSig);
jdouble res = wdCallMethod(env, obj, methodName, methodSig, args).d;
va_end(args);
return res;
}
jobject wdCallObjectMethod(JNIEnv* env, jobject obj, const char* methodName, const char* methodSig, ...) {
va_list args;
va_start(args, methodSig);
jobject res = wdCallMethod(env, obj, methodName, methodSig, args).l;
va_end(args);
return res;
}
void wdCallVoidMethod(JNIEnv* env, jobject obj, const char* methodName, const char* methodSig, ...) {
va_list args;
va_start(args, methodSig);
wdCallMethod(env, obj, methodName, methodSig, args);
va_end(args);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment