diff options
Diffstat (limited to 'library/src/main/cpp/akono-jni.cpp')
-rw-r--r-- | library/src/main/cpp/akono-jni.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/library/src/main/cpp/akono-jni.cpp b/library/src/main/cpp/akono-jni.cpp new file mode 100644 index 00000000..2131e0eb --- /dev/null +++ b/library/src/main/cpp/akono-jni.cpp @@ -0,0 +1,58 @@ +#include <string.h> +#include <jni.h> +#include <libplatform/libplatform.h> +#include <v8.h> + +/* This is a trivial JNI example where we use a native method + * to return a new VM String. See the corresponding Java source + * file located at: + * + * hello-jni/app/src/main/java/com/example/hellojni/HelloJni.java + */ +extern "C" JNIEXPORT jstring JNICALL +Java_akono_AkonoJni_stringFromJNI(JNIEnv* env, jobject thiz) +{ +#if defined(__arm__) + #if defined(__ARM_ARCH_7A__) + #if defined(__ARM_NEON__) + #if defined(__ARM_PCS_VFP) + #define ABI "armeabi-v7a/NEON (hard-float)" + #else + #define ABI "armeabi-v7a/NEON" + #endif + #else + #if defined(__ARM_PCS_VFP) + #define ABI "armeabi-v7a (hard-float)" + #else + #define ABI "armeabi-v7a" + #endif + #endif + #else + #define ABI "armeabi" + #endif +#elif defined(__i386__) +#define ABI "x86" +#elif defined(__x86_64__) +#define ABI "x86_64" +#elif defined(__mips64) /* mips64el-* toolchain defines __mips__ too */ +#define ABI "mips64" +#elif defined(__mips__) +#define ABI "mips" +#elif defined(__aarch64__) +#define ABI "arm64-v8a" +#else +#define ABI "unknown" +#endif + + return env->NewStringUTF("Hello from JNI ! Compiled with ABI " ABI "."); +} + + +extern "C" JNIEXPORT jstring JNICALL +Java_akono_AkonoJni_evalJs(JNIEnv* env, jobject thiz, jstring source) +{ + std::unique_ptr<v8::Platform> platform = v8::platform::NewDefaultPlatform(); + v8::V8::InitializePlatform(platform.get()); + v8::V8::Initialize(); + return env->NewStringUTF("Hello World"); +} |