Commit c06620d7 by Fear1ess

4/1

parent b888a62d
...@@ -5,11 +5,11 @@ project(Wandun) ...@@ -5,11 +5,11 @@ project(Wandun)
include_directories(${CMAKE_SOURCE_DIR}/include) include_directories(${CMAKE_SOURCE_DIR}/include)
if(${CMAKE_ANDROID_ARCH_ABI} STREQUAL "arm64-v8a") if(${CMAKE_ANDROID_ARCH_ABI} STREQUAL "arm64-v8a")
set(OS_DEPENDENDED_SRC set(ARCH_DEPENDENDED_SRC
wd_syscall64.s) wd_syscall64.s)
elseif (${CMAKE_ANDROID_ARCH_ABI} STREQUAL "armeabi-v7a") elseif (${CMAKE_ANDROID_ARCH_ABI} STREQUAL "armeabi-v7a")
set(OS_DEPENDENDED_SRC set(ARCH_DEPENDENDED_SRC
wd_syscall32.s) wd_syscall32.s)
endif() endif()
...@@ -17,8 +17,9 @@ endif() ...@@ -17,8 +17,9 @@ endif()
add_library(wdun add_library(wdun
SHARED SHARED
core.cpp core.cpp
wd_syscall.cpp wd_syscall.cpp
${OS_DEPENDENDED_SRC} jni_helper.cpp
${ARCH_DEPENDENDED_SRC}
) )
target_link_libraries(wdun log) target_link_libraries(wdun log)
......
//
// Created by Fear1ess on 2021/4/1.
//
#ifndef REYUNSDK_JNI_HELPER_H
#define REYUNSDK_JNI_HELPER_H
#include <jni.h>
void wdCheckException(JNIEnv* env);
char wdGetMethodRetType(const char* sig);
inline char wdGetFieldType(const char* sig) { return *sig; }
jvalue wdGetStaticField(JNIEnv* env, const char* clsName, const char* fieldName, const char* fieldSig);
jvalue wdGetField(JNIEnv* env, jobject obj, const char* fieldName, const char* fieldSig);
void wdSetStaticField(JNIEnv* env, const char* clsName, const char* fieldName, const char* fieldSig, jvalue value);
void wdSetField(JNIEnv* env, jobject obj, const char* fieldName, const char* fieldSig, jvalue value);
jobject wdNewObject(JNIEnv* env, const char* clsName, 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, ...);
jboolean wdCallStaticBooleanMethod(JNIEnv* env, const char* clsName, const char* methodName, const char* methodSig, ...);
inline jboolean wdGetStaticBooleanField(JNIEnv* env, const char* clsName, const char* fieldName, const char* fieldSig) {
return wdGetStaticField(env, clsName, fieldName, fieldSig).z;
}
inline jbyte wdGetStaticByteField(JNIEnv* env, const char* clsName, const char* fieldName, const char* fieldSig) {
return wdGetStaticField(env, clsName, fieldName, fieldSig).b;
}
inline jchar wdGetStaticCharField(JNIEnv* env, const char* clsName, const char* fieldName, const char* fieldSig) {
return wdGetStaticField(env, clsName, fieldName, fieldSig).c;
}
inline jshort wdGetStaticShortField(JNIEnv* env, const char* clsName, const char* fieldName, const char* fieldSig) {
return wdGetStaticField(env, clsName, fieldName, fieldSig).s;
}
inline jint wdGetStaticIntField(JNIEnv* env, const char* clsName, const char* fieldName, const char* fieldSig) {
return wdGetStaticField(env, clsName, fieldName, fieldSig).i;
}
inline jlong wdGetStaticLongField(JNIEnv* env, const char* clsName, const char* fieldName, const char* fieldSig) {
return wdGetStaticField(env, clsName, fieldName, fieldSig).j;
}
inline jfloat wdGetStaticFloatField(JNIEnv* env, const char* clsName, const char* fieldName, const char* fieldSig) {
return wdGetStaticField(env, clsName, fieldName, fieldSig).f;
}
inline jdouble wdGetStaticDoubleField(JNIEnv* env, const char* clsName, const char* fieldName, const char* fieldSig) {
return wdGetStaticField(env, clsName, fieldName, fieldSig).d;
}
inline jobject wdGetStaticObjectField(JNIEnv* env, const char* clsName, const char* fieldName, const char* fieldSig) {
return wdGetStaticField(env, clsName, fieldName, fieldSig).l;
}
inline jboolean wdGetBooleanField(JNIEnv* env, jobject obj, const char* fieldName, const char* fieldSig) {
return wdGetField(env, obj, fieldName, fieldSig).z;
}
inline jbyte wdGetByteField(JNIEnv* env, jobject obj, const char* fieldName, const char* fieldSig) {
return wdGetField(env, obj, fieldName, fieldSig).b;
}
inline jchar wdGetCharField(JNIEnv* env, jobject obj, const char* fieldName, const char* fieldSig) {
return wdGetField(env, obj, fieldName, fieldSig).c;
}
inline jshort wdGetShortField(JNIEnv* env, jobject obj, const char* fieldName, const char* fieldSig) {
return wdGetField(env, obj, fieldName, fieldSig).s;
}
inline jint wdGetIntField(JNIEnv* env, jobject obj, const char* fieldName, const char* fieldSig) {
return wdGetField(env, obj, fieldName, fieldSig).i;
}
inline jlong wdGetLongField(JNIEnv* env, jobject obj, const char* fieldName, const char* fieldSig) {
return wdGetField(env, obj, fieldName, fieldSig).j;
}
inline jfloat wdGetFloatField(JNIEnv* env, jobject obj, const char* fieldName, const char* fieldSig) {
return wdGetField(env, obj, fieldName, fieldSig).f;
}
inline jdouble wdGetDoubleField(JNIEnv* env, jobject obj, const char* fieldName, const char* fieldSig) {
return wdGetField(env, obj, fieldName, fieldSig).d;
}
inline jobject wdGetObjectField(JNIEnv* env, jobject obj, const char* fieldName, const char* fieldSig) {
return wdGetField(env, obj, fieldName, fieldSig).l;
}
inline void wdSetStaticBooleanField(JNIEnv* env, const char* clsName, const char* fieldName, const char* fieldSig, jboolean value) {
jvalue j = {.z = value};
wdSetStaticField(env, clsName, fieldName, fieldSig, j);
}
inline void wdSetStaticByteField(JNIEnv* env, const char* clsName, const char* fieldName, const char* fieldSig, jbyte value) {
jvalue j = {.b = value};
wdSetStaticField(env, clsName, fieldName, fieldSig, j);
}
inline void wdSetStaticCharField(JNIEnv* env, const char* clsName, const char* fieldName, const char* fieldSig, jchar value) {
jvalue j = {.c = value};
wdSetStaticField(env, clsName, fieldName, fieldSig, j);
}
inline void wdSetStaticShortField(JNIEnv* env, const char* clsName, const char* fieldName, const char* fieldSig, jshort value) {
jvalue j = {.s = value};
wdSetStaticField(env, clsName, fieldName, fieldSig, j);
}
inline void wdSetStaticIntField(JNIEnv* env, const char* clsName, const char* fieldName, const char* fieldSig, jint value) {
jvalue j = {.i = value};
wdSetStaticField(env, clsName, fieldName, fieldSig, j);
}
inline void wdSetStaticLongField(JNIEnv* env, const char* clsName, const char* fieldName, const char* fieldSig, jlong value) {
jvalue j = {.j = value};
wdSetStaticField(env, clsName, fieldName, fieldSig, j);
}
inline void wdSetStaticFloatField(JNIEnv* env, const char* clsName, const char* fieldName, const char* fieldSig, jfloat value) {
jvalue j = {.f = value};
wdSetStaticField(env, clsName, fieldName, fieldSig, j);
}
inline void wdSetStaticDoubleField(JNIEnv* env, const char* clsName, const char* fieldName, const char* fieldSig, jdouble value) {
jvalue j = {.d = value};
wdSetStaticField(env, clsName, fieldName, fieldSig, j);
}
inline void wdSetStaticObjectField(JNIEnv* env, const char* clsName, const char* fieldName, const char* fieldSig, jobject value) {
jvalue j = {.l = value};
wdSetStaticField(env, clsName, fieldName, fieldSig, j);
}
inline void wdSetBooleanField(JNIEnv* env, jobject obj, const char* fieldName, const char* fieldSig, jboolean value) {
jvalue j = {.z = value};
wdSetField(env, obj, fieldName, fieldSig, j);
}
inline void wdSetByteField(JNIEnv* env, jobject obj, const char* fieldName, const char* fieldSig, jbyte value) {
jvalue j = {.b = value};
wdSetField(env, obj, fieldName, fieldSig, j);
}
inline void wdSetCharField(JNIEnv* env, jobject obj, const char* fieldName, const char* fieldSig, jchar value) {
jvalue j = {.c = value};
wdSetField(env, obj, fieldName, fieldSig, j);
}
inline void wdSetShortField(JNIEnv* env, jobject obj, const char* fieldName, const char* fieldSig, jshort value) {
jvalue j = {.s = value};
wdSetField(env, obj, fieldName, fieldSig, j);
}
inline void wdSetIntField(JNIEnv* env, jobject obj, const char* fieldName, const char* fieldSig, jint value) {
jvalue j = {.i = value};
wdSetField(env, obj, fieldName, fieldSig, j);
}
inline void wdSetLongField(JNIEnv* env, jobject obj, const char* fieldName, const char* fieldSig, jlong value) {
jvalue j = {.j = value};
wdSetField(env, obj, fieldName, fieldSig, j);
}
inline void wdSetFloatField(JNIEnv* env, jobject obj, const char* fieldName, const char* fieldSig, jfloat value) {
jvalue j = {.f = value};
wdSetField(env, obj, fieldName, fieldSig, j);
}
inline void wdSetDoubleField(JNIEnv* env, jobject obj, const char* fieldName, const char* fieldSig, jdouble value) {
jvalue j = {.d = value};
wdSetField(env, obj, fieldName, fieldSig, j);
}
inline void wdSetObjectField(JNIEnv* env, jobject obj, const char* fieldName, const char* fieldSig, jobject value) {
jvalue j = {.l = value};
wdSetField(env, obj, fieldName, fieldSig, j);
}
#endif //REYUNSDK_JNI_HELPER_H
// //
// Created by Fear1ess on 2021/3/31. // Created by Fear1ess on 2021/3/31.
// //
.global wd_syscall32 .global wd_syscall32
.extern wd_set_errno .extern wd_set_errno
......
//
// Created by Fear1ess on 2021/3/31.
//
.global wd_syscall64 .global wd_syscall64
.extern wd_set_errno .extern wd_set_errno
......
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