From 980b86d09f39ecd76fc46ec68e2bbd40e641bec1 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Sun, 17 Sep 2023 12:46:39 +0200 Subject: [PATCH] JNI: remove compatibility template functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With all submodules ported, we can remove the old template functions that prevented us from partial specialization for containers. Change-Id: I78467b6b343b779270e6f49d7db4ac5deb1a0b95 Reviewed-by: Zoltan Gera Reviewed-by: Tinja Paavoseppä --- src/corelib/kernel/qjniobject.h | 8 ++++---- src/corelib/kernel/qjnitypes_impl.h | 30 ++++++++--------------------- 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/src/corelib/kernel/qjniobject.h b/src/corelib/kernel/qjniobject.h index d469c33921..f84bf93986 100644 --- a/src/corelib/kernel/qjniobject.h +++ b/src/corelib/kernel/qjniobject.h @@ -46,7 +46,7 @@ public: template static inline QJniObject construct(Args &&...args) { - return QJniObject(QtJniTypes::className().data(), + return QJniObject(QtJniTypes::Traits::className().data(), QtJniTypes::constructorSignature().data(), std::forward(args)...); } @@ -190,7 +190,7 @@ public: static auto callStaticMethod(const char *methodName, Args &&...args) { QJniEnvironment env; - const jclass clazz = QJniObject::loadClass(QtJniTypes::className().data(), + const jclass clazz = QJniObject::loadClass(QtJniTypes::Traits::className().data(), env.jniEnv()); const jmethodID id = clazz ? getMethodID(env.jniEnv(), clazz, methodName, QtJniTypes::methodSignature().data(), true) @@ -315,7 +315,7 @@ public: > static auto getStaticField(const char *fieldName) { - return getStaticField(QtJniTypes::className(), fieldName); + return getStaticField(QtJniTypes::Traits::className(), fieldName); } template static void setStaticField(const char *fieldName, T value) { - setStaticField(QtJniTypes::className(), fieldName, value); + setStaticField(QtJniTypes::Traits::className(), fieldName, value); } static QJniObject fromString(const QString &string); diff --git a/src/corelib/kernel/qjnitypes_impl.h b/src/corelib/kernel/qjnitypes_impl.h index feab8c4781..511b59de4f 100644 --- a/src/corelib/kernel/qjnitypes_impl.h +++ b/src/corelib/kernel/qjnitypes_impl.h @@ -240,30 +240,16 @@ struct Traits { } }; -// compatibility until submodules are ported -template -constexpr auto typeSignature() -{ - return Traits::signature(); -} - -template -constexpr auto className() -{ - return Traits::className(); -} - -// have to use the compatibility functions here until porting is complete template static constexpr bool isPrimitiveType() { - return typeSignature().size() == 2; + return Traits::signature().size() == 2; } template static constexpr bool isArrayType() { - constexpr auto signature = typeSignature(); + constexpr auto signature = Traits::signature(); return signature.startsWith('[') && signature.size() > 2; } @@ -273,7 +259,7 @@ static constexpr bool isObjectType() if constexpr (std::is_convertible_v) { return true; } else { - constexpr auto signature = typeSignature(); + constexpr auto signature = Traits::signature(); return (signature.startsWith('L') && signature.endsWith(';')) || isArrayType(); } } @@ -286,10 +272,10 @@ static constexpr void assertObjectType() "an object type signature registered)!"); } -// A set of types is valid if typeSignature is implemented for all of them +// A set of types is valid if Traits::signature is implemented for all of them template constexpr bool ValidSignatureTypesDetail = !std::disjunction()), + decltype(Traits::signature()), void>..., IsStringType...>::value; template @@ -307,15 +293,15 @@ template = true> static constexpr auto methodSignature() { return (CTString("(") + - ... + typeSignature>()) + ... + Traits>::signature()) + CTString(")") - + typeSignature(); + + Traits::signature(); } template = true> static constexpr auto fieldSignature() { - return QtJniTypes::typeSignature(); + return QtJniTypes::Traits::signature(); } template = true>