diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-10-29 02:57:57 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-11-07 01:59:51 +0800 |
commit | 93a6cd8bdfbb7a5bcb03c184cd1457e231a7939f (patch) | |
tree | 9f7d88d1a8729b7e141525be0dea000394cb81f8 /tests/auto/corelib/kernel/qjnitypes | |
parent | e579cdceb8b54fea02c1ed9bfae8b5ef74902270 (diff) |
JNI: allow QString as a parameter to native methods
Expect a jstring on the va_list, and implicitly construct a QString from
that.
As a drive-by, allow native methods to take parameters by reference, and
move implementation details into a Detail namespace.
Add test coverage.
Change-Id: I31214938ccaea3f4d539b432e29d12434dd98377
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Diffstat (limited to 'tests/auto/corelib/kernel/qjnitypes')
-rw-r--r-- | tests/auto/corelib/kernel/qjnitypes/tst_qjnitypes.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/auto/corelib/kernel/qjnitypes/tst_qjnitypes.cpp b/tests/auto/corelib/kernel/qjnitypes/tst_qjnitypes.cpp index 58fd6790c1..c332d6634a 100644 --- a/tests/auto/corelib/kernel/qjnitypes/tst_qjnitypes.cpp +++ b/tests/auto/corelib/kernel/qjnitypes/tst_qjnitypes.cpp @@ -161,6 +161,15 @@ Q_DECLARE_JNI_NATIVE_METHOD(nativeFunction) static_assert(QtJniTypes::nativeMethodSignature(nativeFunction) == "(ILjava/lang/String;J)Z"); +static QString nativeFunctionStrings(JNIEnv *, jclass, const QString &, const QtJniTypes::String &) +{ + return QString(); +} +Q_DECLARE_JNI_NATIVE_METHOD(nativeFunctionStrings) + +static_assert(QtJniTypes::nativeMethodSignature(nativeFunctionStrings) + == "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"); + static int forwardDeclaredNativeFunction(JNIEnv *, jobject, bool); Q_DECLARE_JNI_NATIVE_METHOD(forwardDeclaredNativeFunction) static int forwardDeclaredNativeFunction(JNIEnv *, jobject, bool) { return 0; } |