diff options
| author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-07-08 12:31:36 +0200 |
|---|---|---|
| committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-07-12 13:25:04 +0200 |
| commit | 7b6350fa7743fa4ca10f5aebe0962b6544604e33 (patch) | |
| tree | ef89bf9d601538fc85369dcf450079236ddcfb1d /src/corelib/kernel/qjniobject.cpp | |
| parent | 1c563035c7b66349018898cb880ffef8c002a545 (diff) | |
QJniObject: Add template overloads for get/setStaticField
Allow specifying the Java class on which to set/get the field via its
corresponding C++ type, removing the need to explicitly provide the
Java type string.
Those were missing from a085a14d76553ebd1fa4a4a11a27110ee544a531, which
was noticed when porting QtConnectivity over to the new template APIs.
Pick-to: 6.4
Change-Id: I8f324c9fcc486b4c6c2f2b9051f7eca0cbec0e91
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'src/corelib/kernel/qjniobject.cpp')
| -rw-r--r-- | src/corelib/kernel/qjniobject.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/corelib/kernel/qjniobject.cpp b/src/corelib/kernel/qjniobject.cpp index dda4f474029..62a5993559b 100644 --- a/src/corelib/kernel/qjniobject.cpp +++ b/src/corelib/kernel/qjniobject.cpp @@ -1231,6 +1231,14 @@ QJniObject QJniObject::callStaticObjectMethod(jclass clazz, jmethodID methodId, */ /*! + \fn template <typename Klass, typename T> auto QJniObject::getStaticField(const char *fieldName) + + Retrieves the value from the static field \a fieldName for the class \c Klass. + + \c Klass needs to be a C++ type with a registered type mapping to a Java type. +*/ + +/*! \fn template <typename T> void QJniObject::setStaticField(const char *className, const char *fieldName, T value) Sets the static field \a fieldName of the class \a className to \a value. @@ -1243,6 +1251,14 @@ QJniObject QJniObject::callStaticObjectMethod(jclass clazz, jmethodID methodId, */ /*! + \fn template <typename Klass, typename T> auto QJniObject::setStaticField(const char *fieldName, T value) + + Sets the static field \a fieldName of the class \c Klass to \a value. + + \c Klass needs to be a C++ type with a registered type mapping to a Java type. +*/ + +/*! \fn QJniObject QJniObject::getStaticObjectField(const char *className, const char *fieldName, const char *signature) Retrieves a JNI object from the field \a fieldName with \a signature from |
