/** * File generated by Jenny -- https://github.com/LanderlYoung/Jenny * * DO NOT EDIT THIS FILE. * * For bug report, please refer to github issue tracker https://github.com/LanderlYoung/Jenny/issues. */ /* C++ header file for class io/github/landerlyoung/jennysampleapp/NativeDrawable */ #pragma once #include namespace NativeDrawable { // DO NOT modify static constexpr auto FULL_CLASS_NAME = u8"io/github/landerlyoung/jennysampleapp/NativeDrawable"; /* * Class: io.github.landerlyoung.jennysampleapp.NativeDrawable * Method: private final long nativeInit() * Signature: ()J */ jlong JNICALL nativeInit(JNIEnv* env, jobject thiz); /* * Class: io.github.landerlyoung.jennysampleapp.NativeDrawable * Method: public final void onClick() * Signature: ()V */ void JNICALL onClick(JNIEnv* env, jobject thiz); /* * Class: io.github.landerlyoung.jennysampleapp.NativeDrawable * Method: public void draw(android.graphics.Canvas canvas) * Signature: (Landroid/graphics/Canvas;)V */ void JNICALL draw(JNIEnv* env, jobject thiz, jobject canvas); /* * Class: io.github.landerlyoung.jennysampleapp.NativeDrawable * Method: public final void release() * Signature: ()V */ void JNICALL release(JNIEnv* env, jobject thiz); /** * register Native functions * @returns success or not */ inline bool registerNativeFunctions(JNIEnv* env) { // 1. C++20 has u8"" string as char8_t type, we should cast them. // 2. jni.h has JNINativeMethod::name as char* type not const char*. (while Android does) #define jenny_u8cast(u8) const_cast(reinterpret_cast(u8)) const JNINativeMethod gsNativeMethods[] = { { /* method name */ jenny_u8cast(u8"nativeInit"), /* method signature */ jenny_u8cast(u8"()J"), /* function pointer */ reinterpret_cast(nativeInit) }, { /* method name */ jenny_u8cast(u8"onClick"), /* method signature */ jenny_u8cast(u8"()V"), /* function pointer */ reinterpret_cast(onClick) }, { /* method name */ jenny_u8cast(u8"draw"), /* method signature */ jenny_u8cast(u8"(Landroid/graphics/Canvas;)V"), /* function pointer */ reinterpret_cast(draw) }, { /* method name */ jenny_u8cast(u8"release"), /* method signature */ jenny_u8cast(u8"()V"), /* function pointer */ reinterpret_cast(release) } }; const int gsMethodCount = sizeof(gsNativeMethods) / sizeof(JNINativeMethod); bool success = false; jclass clazz = env->FindClass(jenny_u8cast(FULL_CLASS_NAME)); if (clazz != nullptr) { success = !env->RegisterNatives(clazz, gsNativeMethods, gsMethodCount); env->DeleteLocalRef(clazz); } return success; #undef jenny_u8cast } } // endof namespace NativeDrawable