qt5base-lts/tests/auto/corelib/kernel
Volker Hilsheimer dd8da7ebd9 Compile-time generate a JNINativeMethod from a C function
Add a template function that allows us to get the method signature
string from a free function, which are used as native callbacks methods
from Java.

Provide a macro that defines a signature object, and a JNINativeMethod
object based on it, in an internal namespace so that we don't pollute
the namespace with generated names.

Add another macro to get the generated JNINativeMethod object based on
the free function name.

Lastly, add overloads to QJniEnvironment::registerNativeMethods that
take a std::initializer_list of JNINativeMethods.

We can now declare a free function to be a JNI native method:

static bool callbackFromJava(JNIEnv *e, jobject /*thiz*/, jstring p1)
{
   // ...
}
Q_JNI_DECLARE_NATIVE_METHOD(callbackFromJava);

and register it with the JNI environment like this:

QJniEnvironment jni;
jni.registerNativeMethods(clazz, {
    Q_JNI_NATIVE_METHOD(callbackFromJava)
});

removing a significant amount of boiler plate code.

Change-Id: Ie4007b24125879fed3dae1f4d232b4aa95999b44
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-05-23 21:12:06 +02:00
..
qapplicationstatic Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qcoreapplication Fix return value of qGlobalPostedEventsCount() 2022-05-18 17:54:15 +02:00
qdeadlinetimer Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qelapsedtimer Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qeventdispatcher Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qeventloop Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qjnienvironment Compile-time generate a JNINativeMethod from a C function 2022-05-23 21:12:06 +02:00
qjniobject Fold methods for object return type into generic methods 2022-05-17 00:34:06 +02:00
qjnitypes Return specific types for frequently used Java objects 2022-05-17 00:34:06 +02:00
qmath Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qmetacontainer Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qmetaenum Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qmetamethod Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qmetaobject Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qmetaobjectbuilder Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qmetaproperty Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qmetatype Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qmimedata Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qobject QMetaType: disable conversion from smart pointer<const QObject> 2022-05-21 11:43:59 +02:00
qpointer Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qproperty Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qsharedmemory Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qsignalblocker Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qsignalmapper Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qsocketnotifier Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qsystemsemaphore Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qtimer Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qtranslator Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qvariant Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qwineventnotifier Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
CMakeLists.txt Generate JNI signature strings at compile time 2022-05-05 07:29:25 +02:00