JNI API review: minor API and implementation cleanups
- prefix ValidField/SignatureTypes predicates with "If" - make QJniArray SMF constexpr and noexcept - remove const from return-by-value QJniArray functions - rename QJniArray::asContainer to toContainer - constrain QJniEnvironment::registerNativeMethods to valid class types - don't home-grow std::forward - make default QtJniTypes::Object constructor implicit - don't include copy/move constructors in QtJniTypes::Object variadic constructor Change-Id: Ied02993d32d8b0f3ef1e571b75ada15ede1f8389 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> (cherry picked from commit a936b86ec8720ac3dc63f9eca0f873b4f86827ce) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
10b480f1d8
commit
7a6359c614
@ -18,10 +18,10 @@ template <typename T> class QJniArray;
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
struct QJniArrayIterator
|
struct QJniArrayIterator
|
||||||
{
|
{
|
||||||
QJniArrayIterator(const QJniArrayIterator &other) = default;
|
constexpr QJniArrayIterator(const QJniArrayIterator &other) noexcept = default;
|
||||||
QJniArrayIterator(QJniArrayIterator &&other) noexcept = default;
|
constexpr QJniArrayIterator(QJniArrayIterator &&other) noexcept = default;
|
||||||
QJniArrayIterator &operator=(const QJniArrayIterator &other) = default;
|
constexpr QJniArrayIterator &operator=(const QJniArrayIterator &other) noexcept = default;
|
||||||
QJniArrayIterator &operator=(QJniArrayIterator &&other) noexcept = default;
|
constexpr QJniArrayIterator &operator=(QJniArrayIterator &&other) noexcept = default;
|
||||||
|
|
||||||
friend bool operator==(const QJniArrayIterator<T> &lhs, const QJniArrayIterator<T> &rhs) noexcept
|
friend bool operator==(const QJniArrayIterator<T> &lhs, const QJniArrayIterator<T> &rhs) noexcept
|
||||||
{
|
{
|
||||||
@ -31,7 +31,7 @@ struct QJniArrayIterator
|
|||||||
{
|
{
|
||||||
return !(lhs == rhs);
|
return !(lhs == rhs);
|
||||||
}
|
}
|
||||||
const T operator*() const
|
T operator*() const
|
||||||
{
|
{
|
||||||
return m_array->at(m_index);
|
return m_array->at(m_index);
|
||||||
}
|
}
|
||||||
@ -196,7 +196,7 @@ public:
|
|||||||
const_iterator constEnd() const { return {end()}; }
|
const_iterator constEnd() const { return {end()}; }
|
||||||
const_iterator cend() const { return {end()}; }
|
const_iterator cend() const { return {end()}; }
|
||||||
|
|
||||||
const T operator[](qsizetype i) const { return at(i); } // const return value to disallow assignment
|
T operator[](qsizetype i) const { return at(i); }
|
||||||
T at(qsizetype i) const
|
T at(qsizetype i) const
|
||||||
{
|
{
|
||||||
JNIEnv *env = jniEnv();
|
JNIEnv *env = jniEnv();
|
||||||
@ -227,7 +227,7 @@ public:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto asContainer() const
|
auto toContainer() const
|
||||||
{
|
{
|
||||||
JNIEnv *env = jniEnv();
|
JNIEnv *env = jniEnv();
|
||||||
if constexpr (std::is_same_v<T, jobject>) {
|
if constexpr (std::is_same_v<T, jobject>) {
|
||||||
@ -337,14 +337,14 @@ namespace QtJniTypes
|
|||||||
template <typename T> struct IsJniArray: std::false_type {};
|
template <typename T> struct IsJniArray: std::false_type {};
|
||||||
template <typename T> struct IsJniArray<QJniArray<T>> : std::true_type {};
|
template <typename T> struct IsJniArray<QJniArray<T>> : std::true_type {};
|
||||||
template <typename T> struct Traits<QJniArray<T>> {
|
template <typename T> struct Traits<QJniArray<T>> {
|
||||||
template <ValidFieldType<T> = true>
|
template <IfValidFieldType<T> = true>
|
||||||
static constexpr auto signature()
|
static constexpr auto signature()
|
||||||
{
|
{
|
||||||
return CTString("[") + Traits<T>::signature();
|
return CTString("[") + Traits<T>::signature();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
template <typename T> struct Traits<QList<T>> {
|
template <typename T> struct Traits<QList<T>> {
|
||||||
template <ValidFieldType<T> = true>
|
template <IfValidFieldType<T> = true>
|
||||||
static constexpr auto signature()
|
static constexpr auto signature()
|
||||||
{
|
{
|
||||||
return CTString("[") + Traits<T>::signature();
|
return CTString("[") + Traits<T>::signature();
|
||||||
|
@ -64,7 +64,11 @@ public:
|
|||||||
return registerNativeMethods(clazz, std::data(methods), methods.size());
|
return registerNativeMethods(clazz, std::data(methods), methods.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Class>
|
template<typename Class
|
||||||
|
#ifndef Q_QDOC
|
||||||
|
, std::enable_if_t<QtJniTypes::isObjectType<Class>(), bool> = true
|
||||||
|
#endif
|
||||||
|
>
|
||||||
bool registerNativeMethods(std::initializer_list<JNINativeMethod> methods)
|
bool registerNativeMethods(std::initializer_list<JNINativeMethod> methods)
|
||||||
{
|
{
|
||||||
return registerNativeMethods(QtJniTypes::Traits<Class>::className().data(), methods);
|
return registerNativeMethods(QtJniTypes::Traits<Class>::className().data(), methods);
|
||||||
|
@ -116,7 +116,7 @@ public:
|
|||||||
|
|
||||||
template <typename Ret, typename ...Args
|
template <typename Ret, typename ...Args
|
||||||
#ifndef Q_QDOC
|
#ifndef Q_QDOC
|
||||||
, QtJniTypes::ValidFieldType<Ret> = true
|
, QtJniTypes::IfValidFieldType<Ret> = true
|
||||||
#endif
|
#endif
|
||||||
>
|
>
|
||||||
auto callMethod(const char *methodName, const char *signature, Args &&...args) const
|
auto callMethod(const char *methodName, const char *signature, Args &&...args) const
|
||||||
@ -148,7 +148,7 @@ public:
|
|||||||
|
|
||||||
template <typename Ret, typename ...Args
|
template <typename Ret, typename ...Args
|
||||||
#ifndef Q_QDOC
|
#ifndef Q_QDOC
|
||||||
, QtJniTypes::ValidSignatureTypes<Ret, Args...> = true
|
, QtJniTypes::IfValidSignatureTypes<Ret, Args...> = true
|
||||||
#endif
|
#endif
|
||||||
>
|
>
|
||||||
auto callMethod(const char *methodName, Args &&...args) const
|
auto callMethod(const char *methodName, Args &&...args) const
|
||||||
@ -159,7 +159,7 @@ public:
|
|||||||
|
|
||||||
template <typename Ret, typename ...Args
|
template <typename Ret, typename ...Args
|
||||||
#ifndef Q_QDOC
|
#ifndef Q_QDOC
|
||||||
, QtJniTypes::ValidSignatureTypes<Ret, Args...> = true
|
, QtJniTypes::IfValidSignatureTypes<Ret, Args...> = true
|
||||||
#endif
|
#endif
|
||||||
>
|
>
|
||||||
QJniObject callObjectMethod(const char *methodName, Args &&...args) const
|
QJniObject callObjectMethod(const char *methodName, Args &&...args) const
|
||||||
@ -192,7 +192,7 @@ public:
|
|||||||
|
|
||||||
template <typename Ret, typename ...Args
|
template <typename Ret, typename ...Args
|
||||||
#ifndef Q_QDOC
|
#ifndef Q_QDOC
|
||||||
, QtJniTypes::ValidFieldType<Ret> = true
|
, QtJniTypes::IfValidFieldType<Ret> = true
|
||||||
#endif
|
#endif
|
||||||
>
|
>
|
||||||
static auto callStaticMethod(jclass clazz, jmethodID methodId, Args &&...args)
|
static auto callStaticMethod(jclass clazz, jmethodID methodId, Args &&...args)
|
||||||
@ -223,7 +223,7 @@ public:
|
|||||||
|
|
||||||
template <typename Ret, typename ...Args
|
template <typename Ret, typename ...Args
|
||||||
#ifndef Q_QDOC
|
#ifndef Q_QDOC
|
||||||
, QtJniTypes::ValidSignatureTypes<Ret, Args...> = true
|
, QtJniTypes::IfValidSignatureTypes<Ret, Args...> = true
|
||||||
#endif
|
#endif
|
||||||
>
|
>
|
||||||
static auto callStaticMethod(const char *className, const char *methodName, Args &&...args)
|
static auto callStaticMethod(const char *className, const char *methodName, Args &&...args)
|
||||||
@ -238,7 +238,7 @@ public:
|
|||||||
|
|
||||||
template <typename Ret, typename ...Args
|
template <typename Ret, typename ...Args
|
||||||
#ifndef Q_QDOC
|
#ifndef Q_QDOC
|
||||||
, QtJniTypes::ValidSignatureTypes<Ret, Args...> = true
|
, QtJniTypes::IfValidSignatureTypes<Ret, Args...> = true
|
||||||
#endif
|
#endif
|
||||||
>
|
>
|
||||||
static auto callStaticMethod(jclass clazz, const char *methodName, Args &&...args)
|
static auto callStaticMethod(jclass clazz, const char *methodName, Args &&...args)
|
||||||
@ -248,7 +248,7 @@ public:
|
|||||||
}
|
}
|
||||||
template <typename Klass, typename Ret, typename ...Args
|
template <typename Klass, typename Ret, typename ...Args
|
||||||
#ifndef Q_QDOC
|
#ifndef Q_QDOC
|
||||||
, QtJniTypes::ValidSignatureTypes<Ret, Args...> = true
|
, QtJniTypes::IfValidSignatureTypes<Ret, Args...> = true
|
||||||
#endif
|
#endif
|
||||||
>
|
>
|
||||||
static auto callStaticMethod(const char *methodName, Args &&...args)
|
static auto callStaticMethod(const char *methodName, Args &&...args)
|
||||||
@ -273,7 +273,7 @@ public:
|
|||||||
|
|
||||||
template <typename Ret, typename ...Args
|
template <typename Ret, typename ...Args
|
||||||
#ifndef Q_QDOC
|
#ifndef Q_QDOC
|
||||||
, QtJniTypes::ValidSignatureTypes<Ret, Args...> = true
|
, QtJniTypes::IfValidSignatureTypes<Ret, Args...> = true
|
||||||
#endif
|
#endif
|
||||||
>
|
>
|
||||||
static QJniObject callStaticObjectMethod(const char *className, const char *methodName, Args &&...args)
|
static QJniObject callStaticObjectMethod(const char *className, const char *methodName, Args &&...args)
|
||||||
@ -287,7 +287,7 @@ public:
|
|||||||
|
|
||||||
template <typename Ret, typename ...Args
|
template <typename Ret, typename ...Args
|
||||||
#ifndef Q_QDOC
|
#ifndef Q_QDOC
|
||||||
, QtJniTypes::ValidSignatureTypes<Ret, Args...> = true
|
, QtJniTypes::IfValidSignatureTypes<Ret, Args...> = true
|
||||||
#endif
|
#endif
|
||||||
>
|
>
|
||||||
static QJniObject callStaticObjectMethod(jclass clazz, const char *methodName, Args &&...args)
|
static QJniObject callStaticObjectMethod(jclass clazz, const char *methodName, Args &&...args)
|
||||||
@ -301,7 +301,7 @@ public:
|
|||||||
|
|
||||||
template <typename T
|
template <typename T
|
||||||
#ifndef Q_QDOC
|
#ifndef Q_QDOC
|
||||||
, QtJniTypes::ValidFieldType<T> = true
|
, QtJniTypes::IfValidFieldType<T> = true
|
||||||
#endif
|
#endif
|
||||||
>
|
>
|
||||||
auto getField(const char *fieldName) const
|
auto getField(const char *fieldName) const
|
||||||
@ -324,7 +324,7 @@ public:
|
|||||||
|
|
||||||
template <typename T
|
template <typename T
|
||||||
#ifndef Q_QDOC
|
#ifndef Q_QDOC
|
||||||
, QtJniTypes::ValidFieldType<T> = true
|
, QtJniTypes::IfValidFieldType<T> = true
|
||||||
#endif
|
#endif
|
||||||
>
|
>
|
||||||
static auto getStaticField(const char *className, const char *fieldName)
|
static auto getStaticField(const char *className, const char *fieldName)
|
||||||
@ -342,7 +342,7 @@ public:
|
|||||||
|
|
||||||
template <typename T
|
template <typename T
|
||||||
#ifndef Q_QDOC
|
#ifndef Q_QDOC
|
||||||
, QtJniTypes::ValidFieldType<T> = true
|
, QtJniTypes::IfValidFieldType<T> = true
|
||||||
#endif
|
#endif
|
||||||
>
|
>
|
||||||
static auto getStaticField(jclass clazz, const char *fieldName)
|
static auto getStaticField(jclass clazz, const char *fieldName)
|
||||||
@ -365,7 +365,7 @@ public:
|
|||||||
|
|
||||||
template <typename Klass, typename T
|
template <typename Klass, typename T
|
||||||
#ifndef Q_QDOC
|
#ifndef Q_QDOC
|
||||||
, QtJniTypes::ValidFieldType<T> = true
|
, QtJniTypes::IfValidFieldType<T> = true
|
||||||
#endif
|
#endif
|
||||||
>
|
>
|
||||||
static auto getStaticField(const char *fieldName)
|
static auto getStaticField(const char *fieldName)
|
||||||
@ -417,7 +417,7 @@ public:
|
|||||||
|
|
||||||
template <typename T
|
template <typename T
|
||||||
#ifndef Q_QDOC
|
#ifndef Q_QDOC
|
||||||
, QtJniTypes::ValidFieldType<T> = true
|
, QtJniTypes::IfValidFieldType<T> = true
|
||||||
#endif
|
#endif
|
||||||
>
|
>
|
||||||
void setField(const char *fieldName, T value)
|
void setField(const char *fieldName, T value)
|
||||||
@ -432,7 +432,7 @@ public:
|
|||||||
|
|
||||||
template <typename T
|
template <typename T
|
||||||
#ifndef Q_QDOC
|
#ifndef Q_QDOC
|
||||||
, QtJniTypes::ValidFieldType<T> = true
|
, QtJniTypes::IfValidFieldType<T> = true
|
||||||
#endif
|
#endif
|
||||||
>
|
>
|
||||||
void setField(const char *fieldName, const char *signature, T value)
|
void setField(const char *fieldName, const char *signature, T value)
|
||||||
@ -446,7 +446,7 @@ public:
|
|||||||
|
|
||||||
template <typename T
|
template <typename T
|
||||||
#ifndef Q_QDOC
|
#ifndef Q_QDOC
|
||||||
, QtJniTypes::ValidFieldType<T> = true
|
, QtJniTypes::IfValidFieldType<T> = true
|
||||||
#endif
|
#endif
|
||||||
>
|
>
|
||||||
static void setStaticField(const char *className, const char *fieldName, T value)
|
static void setStaticField(const char *className, const char *fieldName, T value)
|
||||||
@ -468,7 +468,7 @@ public:
|
|||||||
|
|
||||||
template <typename T
|
template <typename T
|
||||||
#ifndef Q_QDOC
|
#ifndef Q_QDOC
|
||||||
, QtJniTypes::ValidFieldType<T> = true
|
, QtJniTypes::IfValidFieldType<T> = true
|
||||||
#endif
|
#endif
|
||||||
>
|
>
|
||||||
static void setStaticField(const char *className, const char *fieldName,
|
static void setStaticField(const char *className, const char *fieldName,
|
||||||
@ -490,7 +490,7 @@ public:
|
|||||||
|
|
||||||
template <typename T
|
template <typename T
|
||||||
#ifndef Q_QDOC
|
#ifndef Q_QDOC
|
||||||
, QtJniTypes::ValidFieldType<T> = true
|
, QtJniTypes::IfValidFieldType<T> = true
|
||||||
#endif
|
#endif
|
||||||
>
|
>
|
||||||
static void setStaticField(jclass clazz, const char *fieldName,
|
static void setStaticField(jclass clazz, const char *fieldName,
|
||||||
@ -507,7 +507,7 @@ public:
|
|||||||
|
|
||||||
template <typename T
|
template <typename T
|
||||||
#ifndef Q_QDOC
|
#ifndef Q_QDOC
|
||||||
, QtJniTypes::ValidFieldType<T> = true
|
, QtJniTypes::IfValidFieldType<T> = true
|
||||||
#endif
|
#endif
|
||||||
>
|
>
|
||||||
static void setStaticField(jclass clazz, const char *fieldName, T value)
|
static void setStaticField(jclass clazz, const char *fieldName, T value)
|
||||||
@ -517,7 +517,7 @@ public:
|
|||||||
|
|
||||||
template <typename Klass, typename T
|
template <typename Klass, typename T
|
||||||
#ifndef Q_QDOC
|
#ifndef Q_QDOC
|
||||||
, QtJniTypes::ValidFieldType<T> = true
|
, QtJniTypes::IfValidFieldType<T> = true
|
||||||
#endif
|
#endif
|
||||||
>
|
>
|
||||||
static void setStaticField(const char *fieldName, T value)
|
static void setStaticField(const char *fieldName, T value)
|
||||||
@ -793,7 +793,7 @@ auto QJniObject::LocalFrame<Args...>::convertToJni(T &&value)
|
|||||||
} else if constexpr (std::is_base_of_v<QJniObject, Type>) {
|
} else if constexpr (std::is_base_of_v<QJniObject, Type>) {
|
||||||
return value.object();
|
return value.object();
|
||||||
} else {
|
} else {
|
||||||
return static_cast<T &&>(value);
|
return std::forward<T>(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -812,7 +812,7 @@ auto QJniObject::LocalFrame<Args...>::convertFromJni(QJniObject &&object)
|
|||||||
// then that QJniArray would have elements of type
|
// then that QJniArray would have elements of type
|
||||||
using ElementType = typename QJniArrayType::Type;
|
using ElementType = typename QJniArrayType::Type;
|
||||||
// construct a QJniArray from a jobject pointer of that type
|
// construct a QJniArray from a jobject pointer of that type
|
||||||
return QJniArray<ElementType>(object.template object<jarray>()).asContainer();
|
return QJniArray<ElementType>(object.template object<jarray>()).toContainer();
|
||||||
} else if constexpr (std::is_array_v<Type>) {
|
} else if constexpr (std::is_array_v<Type>) {
|
||||||
using ElementType = std::remove_extent_t<Type>;
|
using ElementType = std::remove_extent_t<Type>;
|
||||||
return QJniArray<ElementType>{object};
|
return QJniArray<ElementType>{object};
|
||||||
|
@ -34,12 +34,17 @@ struct Object : QJniObject
|
|||||||
// avoid ambiguities with deleted const char * constructor
|
// avoid ambiguities with deleted const char * constructor
|
||||||
Q_IMPLICIT Object(std::nullptr_t) : QJniObject() {}
|
Q_IMPLICIT Object(std::nullptr_t) : QJniObject() {}
|
||||||
|
|
||||||
// this intentionally includes the default constructor
|
Object()
|
||||||
template<typename ...Args
|
: QJniObject(QtJniTypes::Traits<Class>::className())
|
||||||
, ValidSignatureTypes<Args...> = true
|
{}
|
||||||
|
|
||||||
|
template<typename Arg, typename ...Args
|
||||||
|
, std::enable_if_t<!std::is_same_v<Arg, Object>, bool> = true
|
||||||
|
, IfValidSignatureTypes<Arg, Args...> = true
|
||||||
>
|
>
|
||||||
explicit Object(Args &&...args)
|
explicit Object(Arg && arg, Args &&...args)
|
||||||
: QJniObject(QtJniTypes::Traits<Class>::className(), std::forward<Args>(args)...)
|
: QJniObject(QtJniTypes::Traits<Class>::className(), std::forward<Arg>(arg),
|
||||||
|
std::forward<Args>(args)...)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// named constructors avoid ambiguities
|
// named constructors avoid ambiguities
|
||||||
@ -56,7 +61,7 @@ struct Object : QJniObject
|
|||||||
// public API forwarding to QJniObject, with the implicit Class template parameter
|
// public API forwarding to QJniObject, with the implicit Class template parameter
|
||||||
template <typename Ret, typename ...Args
|
template <typename Ret, typename ...Args
|
||||||
#ifndef Q_QDOC
|
#ifndef Q_QDOC
|
||||||
, QtJniTypes::ValidSignatureTypes<Ret, Args...> = true
|
, QtJniTypes::IfValidSignatureTypes<Ret, Args...> = true
|
||||||
#endif
|
#endif
|
||||||
>
|
>
|
||||||
static auto callStaticMethod(const char *name, Args &&...args)
|
static auto callStaticMethod(const char *name, Args &&...args)
|
||||||
@ -66,7 +71,7 @@ struct Object : QJniObject
|
|||||||
}
|
}
|
||||||
template <typename T
|
template <typename T
|
||||||
#ifndef Q_QDOC
|
#ifndef Q_QDOC
|
||||||
, QtJniTypes::ValidFieldType<T> = true
|
, QtJniTypes::IfValidFieldType<T> = true
|
||||||
#endif
|
#endif
|
||||||
>
|
>
|
||||||
static auto getStaticField(const char *field)
|
static auto getStaticField(const char *field)
|
||||||
@ -75,7 +80,7 @@ struct Object : QJniObject
|
|||||||
}
|
}
|
||||||
template <typename T
|
template <typename T
|
||||||
#ifndef Q_QDOC
|
#ifndef Q_QDOC
|
||||||
, QtJniTypes::ValidFieldType<T> = true
|
, QtJniTypes::IfValidFieldType<T> = true
|
||||||
#endif
|
#endif
|
||||||
>
|
>
|
||||||
static void setStaticField(const char *field, T &&value)
|
static void setStaticField(const char *field, T &&value)
|
||||||
@ -86,7 +91,7 @@ struct Object : QJniObject
|
|||||||
// keep only these overloads, the rest is made private
|
// keep only these overloads, the rest is made private
|
||||||
template <typename Ret, typename ...Args
|
template <typename Ret, typename ...Args
|
||||||
#ifndef Q_QDOC
|
#ifndef Q_QDOC
|
||||||
, QtJniTypes::ValidSignatureTypes<Ret, Args...> = true
|
, QtJniTypes::IfValidSignatureTypes<Ret, Args...> = true
|
||||||
#endif
|
#endif
|
||||||
>
|
>
|
||||||
auto callMethod(const char *method, Args &&...args) const
|
auto callMethod(const char *method, Args &&...args) const
|
||||||
@ -95,7 +100,7 @@ struct Object : QJniObject
|
|||||||
}
|
}
|
||||||
template <typename T
|
template <typename T
|
||||||
#ifndef Q_QDOC
|
#ifndef Q_QDOC
|
||||||
, QtJniTypes::ValidFieldType<T> = true
|
, QtJniTypes::IfValidFieldType<T> = true
|
||||||
#endif
|
#endif
|
||||||
>
|
>
|
||||||
auto getField(const char *fieldName) const
|
auto getField(const char *fieldName) const
|
||||||
@ -105,7 +110,7 @@ struct Object : QJniObject
|
|||||||
|
|
||||||
template <typename T
|
template <typename T
|
||||||
#ifndef Q_QDOC
|
#ifndef Q_QDOC
|
||||||
, QtJniTypes::ValidFieldType<T> = true
|
, QtJniTypes::IfValidFieldType<T> = true
|
||||||
#endif
|
#endif
|
||||||
>
|
>
|
||||||
void setField(const char *fieldName, T &&value)
|
void setField(const char *fieldName, T &&value)
|
||||||
|
@ -156,7 +156,7 @@ struct Traits {
|
|||||||
// The return type of className/signature becomes void for any type
|
// The return type of className/signature becomes void for any type
|
||||||
// not handled here. This indicates that the Traits type is not specialized
|
// not handled here. This indicates that the Traits type is not specialized
|
||||||
// for the respective type, which we use to detect invalid types in the
|
// for the respective type, which we use to detect invalid types in the
|
||||||
// ValidSignatureTypes and ValidFieldType predicates below.
|
// IfValidSignatureTypes and IfValidFieldType predicates below.
|
||||||
|
|
||||||
static constexpr auto className()
|
static constexpr auto className()
|
||||||
{
|
{
|
||||||
@ -281,17 +281,17 @@ constexpr bool ValidSignatureTypesDetail = !std::disjunction<std::is_same<
|
|||||||
void>...,
|
void>...,
|
||||||
IsStringType<Types>...>::value;
|
IsStringType<Types>...>::value;
|
||||||
template<typename ...Types>
|
template<typename ...Types>
|
||||||
using ValidSignatureTypes = std::enable_if_t<
|
using IfValidSignatureTypes = std::enable_if_t<
|
||||||
ValidSignatureTypesDetail<q20::remove_cvref_t<Types>...>, bool>;
|
ValidSignatureTypesDetail<q20::remove_cvref_t<Types>...>, bool>;
|
||||||
|
|
||||||
template<typename Type>
|
template<typename Type>
|
||||||
constexpr bool ValidFieldTypeDetail = isObjectType<Type>() || isPrimitiveType<Type>();
|
constexpr bool ValidFieldTypeDetail = isObjectType<Type>() || isPrimitiveType<Type>();
|
||||||
template<typename Type>
|
template<typename Type>
|
||||||
using ValidFieldType = std::enable_if_t<
|
using IfValidFieldType = std::enable_if_t<
|
||||||
ValidFieldTypeDetail<q20::remove_cvref_t<Type>>, bool>;
|
ValidFieldTypeDetail<q20::remove_cvref_t<Type>>, bool>;
|
||||||
|
|
||||||
|
|
||||||
template<typename R, typename ...Args, ValidSignatureTypes<R, Args...> = true>
|
template<typename R, typename ...Args, IfValidSignatureTypes<R, Args...> = true>
|
||||||
static constexpr auto methodSignature()
|
static constexpr auto methodSignature()
|
||||||
{
|
{
|
||||||
return (CTString("(") +
|
return (CTString("(") +
|
||||||
@ -300,25 +300,25 @@ static constexpr auto methodSignature()
|
|||||||
+ Traits<R>::signature();
|
+ Traits<R>::signature();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, ValidSignatureTypes<T> = true>
|
template<typename T, IfValidSignatureTypes<T> = true>
|
||||||
static constexpr auto fieldSignature()
|
static constexpr auto fieldSignature()
|
||||||
{
|
{
|
||||||
return QtJniTypes::Traits<T>::signature();
|
return QtJniTypes::Traits<T>::signature();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename ...Args, ValidSignatureTypes<Args...> = true>
|
template<typename ...Args, IfValidSignatureTypes<Args...> = true>
|
||||||
static constexpr auto constructorSignature()
|
static constexpr auto constructorSignature()
|
||||||
{
|
{
|
||||||
return methodSignature<void, Args...>();
|
return methodSignature<void, Args...>();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Ret, typename ...Args, ValidSignatureTypes<Ret, Args...> = true>
|
template<typename Ret, typename ...Args, IfValidSignatureTypes<Ret, Args...> = true>
|
||||||
static constexpr auto nativeMethodSignature(Ret (*)(JNIEnv *, jobject, Args...))
|
static constexpr auto nativeMethodSignature(Ret (*)(JNIEnv *, jobject, Args...))
|
||||||
{
|
{
|
||||||
return methodSignature<Ret, Args...>();
|
return methodSignature<Ret, Args...>();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Ret, typename ...Args, ValidSignatureTypes<Ret, Args...> = true>
|
template<typename Ret, typename ...Args, IfValidSignatureTypes<Ret, Args...> = true>
|
||||||
static constexpr auto nativeMethodSignature(Ret (*)(JNIEnv *, jclass, Args...))
|
static constexpr auto nativeMethodSignature(Ret (*)(JNIEnv *, jclass, Args...))
|
||||||
{
|
{
|
||||||
return methodSignature<Ret, Args...>();
|
return methodSignature<Ret, Args...>();
|
||||||
|
@ -1550,13 +1550,13 @@ void tst_QJniObject::templateApiCheck()
|
|||||||
const auto array = TestClass::callStaticMethod<jboolean[]>("staticBooleanArrayMethod");
|
const auto array = TestClass::callStaticMethod<jboolean[]>("staticBooleanArrayMethod");
|
||||||
QVERIFY(array.isValid());
|
QVERIFY(array.isValid());
|
||||||
QCOMPARE(array.size(), 3);
|
QCOMPARE(array.size(), 3);
|
||||||
QCOMPARE(array.asContainer(), (QList<jboolean>{true, true, true}));
|
QCOMPARE(array.toContainer(), (QList<jboolean>{true, true, true}));
|
||||||
|
|
||||||
QJniArray<jboolean> newArray(QList<jboolean>{true, false, false});
|
QJniArray<jboolean> newArray(QList<jboolean>{true, false, false});
|
||||||
QVERIFY(newArray.isValid());
|
QVERIFY(newArray.isValid());
|
||||||
const auto reverse = TestClass::callStaticMethod<jboolean[]>("staticReverseBooleanArray", newArray);
|
const auto reverse = TestClass::callStaticMethod<jboolean[]>("staticReverseBooleanArray", newArray);
|
||||||
QVERIFY(reverse.isValid());
|
QVERIFY(reverse.isValid());
|
||||||
QCOMPARE(reverse.asContainer(), (QList<jboolean>{false, false, true}));
|
QCOMPARE(reverse.toContainer(), (QList<jboolean>{false, false, true}));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -1566,13 +1566,13 @@ void tst_QJniObject::templateApiCheck()
|
|||||||
const auto array = testClass.callMethod<jboolean[]>("booleanArrayMethod");
|
const auto array = testClass.callMethod<jboolean[]>("booleanArrayMethod");
|
||||||
QVERIFY(array.isValid());
|
QVERIFY(array.isValid());
|
||||||
QCOMPARE(array.size(), 3);
|
QCOMPARE(array.size(), 3);
|
||||||
QCOMPARE(array.asContainer(), (QList<jboolean>{true, true, true}));
|
QCOMPARE(array.toContainer(), (QList<jboolean>{true, true, true}));
|
||||||
|
|
||||||
QJniArray<jboolean> newArray(QList<jboolean>{true, false, false});
|
QJniArray<jboolean> newArray(QList<jboolean>{true, false, false});
|
||||||
QVERIFY(newArray.isValid());
|
QVERIFY(newArray.isValid());
|
||||||
const auto reverse = testClass.callMethod<jboolean[]>("reverseBooleanArray", newArray);
|
const auto reverse = testClass.callMethod<jboolean[]>("reverseBooleanArray", newArray);
|
||||||
QVERIFY(reverse.isValid());
|
QVERIFY(reverse.isValid());
|
||||||
QCOMPARE(reverse.asContainer(), (QList<jboolean>{false, false, true}));
|
QCOMPARE(reverse.toContainer(), (QList<jboolean>{false, false, true}));
|
||||||
}
|
}
|
||||||
|
|
||||||
// jbyteArray ---------------------------------------------------------------------------------
|
// jbyteArray ---------------------------------------------------------------------------------
|
||||||
@ -1584,13 +1584,13 @@ void tst_QJniObject::templateApiCheck()
|
|||||||
const auto array = TestClass::callStaticMethod<jbyte[]>("staticByteArrayMethod");
|
const auto array = TestClass::callStaticMethod<jbyte[]>("staticByteArrayMethod");
|
||||||
QVERIFY(array.isValid());
|
QVERIFY(array.isValid());
|
||||||
QCOMPARE(array.size(), 3);
|
QCOMPARE(array.size(), 3);
|
||||||
QCOMPARE(array.asContainer(), "abc");
|
QCOMPARE(array.toContainer(), "abc");
|
||||||
|
|
||||||
QJniArray<jbyte> newArray(QByteArray{"cba"});
|
QJniArray<jbyte> newArray(QByteArray{"cba"});
|
||||||
QVERIFY(newArray.isValid());
|
QVERIFY(newArray.isValid());
|
||||||
const auto reverse = TestClass::callStaticMethod<jbyte[]>("staticReverseByteArray", newArray);
|
const auto reverse = TestClass::callStaticMethod<jbyte[]>("staticReverseByteArray", newArray);
|
||||||
QVERIFY(reverse.isValid());
|
QVERIFY(reverse.isValid());
|
||||||
QCOMPARE(reverse.asContainer(), "abc");
|
QCOMPARE(reverse.toContainer(), "abc");
|
||||||
|
|
||||||
const QByteArray reverse2 = TestClass::callStaticMethod<QByteArray>("staticReverseByteArray",
|
const QByteArray reverse2 = TestClass::callStaticMethod<QByteArray>("staticReverseByteArray",
|
||||||
QByteArray("abc"));
|
QByteArray("abc"));
|
||||||
@ -1604,13 +1604,13 @@ void tst_QJniObject::templateApiCheck()
|
|||||||
const auto array = testClass.callMethod<jbyte[]>("byteArrayMethod");
|
const auto array = testClass.callMethod<jbyte[]>("byteArrayMethod");
|
||||||
QVERIFY(array.isValid());
|
QVERIFY(array.isValid());
|
||||||
QCOMPARE(array.size(), 3);
|
QCOMPARE(array.size(), 3);
|
||||||
QCOMPARE(array.asContainer(), "abc");
|
QCOMPARE(array.toContainer(), "abc");
|
||||||
|
|
||||||
QJniArray<jbyte> newArray = QJniArrayBase::fromContainer(QByteArray{"cba"});
|
QJniArray<jbyte> newArray = QJniArrayBase::fromContainer(QByteArray{"cba"});
|
||||||
QVERIFY(newArray.isValid());
|
QVERIFY(newArray.isValid());
|
||||||
const auto reverse = testClass.callMethod<jbyte[]>("reverseByteArray", newArray);
|
const auto reverse = testClass.callMethod<jbyte[]>("reverseByteArray", newArray);
|
||||||
QVERIFY(reverse.isValid());
|
QVERIFY(reverse.isValid());
|
||||||
QCOMPARE(reverse.asContainer(), "abc");
|
QCOMPARE(reverse.toContainer(), "abc");
|
||||||
}
|
}
|
||||||
|
|
||||||
// jcharArray ---------------------------------------------------------------------------------
|
// jcharArray ---------------------------------------------------------------------------------
|
||||||
@ -1622,13 +1622,13 @@ void tst_QJniObject::templateApiCheck()
|
|||||||
const auto array = TestClass::callStaticMethod<jchar[]>("staticCharArrayMethod");
|
const auto array = TestClass::callStaticMethod<jchar[]>("staticCharArrayMethod");
|
||||||
QVERIFY(array.isValid());
|
QVERIFY(array.isValid());
|
||||||
QCOMPARE(array.size(), 3);
|
QCOMPARE(array.size(), 3);
|
||||||
QCOMPARE(array.asContainer(), (QList<jchar>{u'a', u'b', u'c'}));
|
QCOMPARE(array.toContainer(), (QList<jchar>{u'a', u'b', u'c'}));
|
||||||
|
|
||||||
QJniArray<jchar> newArray(QList<jchar>{u'c', u'b', u'a'});
|
QJniArray<jchar> newArray(QList<jchar>{u'c', u'b', u'a'});
|
||||||
QVERIFY(newArray.isValid());
|
QVERIFY(newArray.isValid());
|
||||||
const auto reverse = TestClass::callStaticMethod<jchar[]>("staticReverseCharArray", newArray);
|
const auto reverse = TestClass::callStaticMethod<jchar[]>("staticReverseCharArray", newArray);
|
||||||
QVERIFY(reverse.isValid());
|
QVERIFY(reverse.isValid());
|
||||||
QCOMPARE(reverse.asContainer(), (QList<jchar>{u'a', u'b', u'c'}));
|
QCOMPARE(reverse.toContainer(), (QList<jchar>{u'a', u'b', u'c'}));
|
||||||
|
|
||||||
const QList<jchar> reverse2 = TestClass::callStaticMethod<QList<jchar>>("staticReverseCharArray",
|
const QList<jchar> reverse2 = TestClass::callStaticMethod<QList<jchar>>("staticReverseCharArray",
|
||||||
(QList<jchar>{u'c', u'b', u'a'}));
|
(QList<jchar>{u'c', u'b', u'a'}));
|
||||||
@ -1642,13 +1642,13 @@ void tst_QJniObject::templateApiCheck()
|
|||||||
const auto array = testClass.callMethod<jchar[]>("charArrayMethod");
|
const auto array = testClass.callMethod<jchar[]>("charArrayMethod");
|
||||||
QVERIFY(array.isValid());
|
QVERIFY(array.isValid());
|
||||||
QCOMPARE(array.size(), 3);
|
QCOMPARE(array.size(), 3);
|
||||||
QCOMPARE(array.asContainer(), (QList<jchar>{u'a', u'b', u'c'}));
|
QCOMPARE(array.toContainer(), (QList<jchar>{u'a', u'b', u'c'}));
|
||||||
|
|
||||||
QJniArray<jchar> newArray = QJniArrayBase::fromContainer(QList<jchar>{u'c', u'b', u'a'});
|
QJniArray<jchar> newArray = QJniArrayBase::fromContainer(QList<jchar>{u'c', u'b', u'a'});
|
||||||
QVERIFY(newArray.isValid());
|
QVERIFY(newArray.isValid());
|
||||||
const auto reverse = testClass.callMethod<jchar[]>("reverseCharArray", newArray);
|
const auto reverse = testClass.callMethod<jchar[]>("reverseCharArray", newArray);
|
||||||
QVERIFY(reverse.isValid());
|
QVERIFY(reverse.isValid());
|
||||||
QCOMPARE(reverse.asContainer(), (QList<jchar>{u'a', u'b', u'c'}));
|
QCOMPARE(reverse.toContainer(), (QList<jchar>{u'a', u'b', u'c'}));
|
||||||
}
|
}
|
||||||
|
|
||||||
// jshortArray --------------------------------------------------------------------------------
|
// jshortArray --------------------------------------------------------------------------------
|
||||||
@ -1660,13 +1660,13 @@ void tst_QJniObject::templateApiCheck()
|
|||||||
const auto array = TestClass::callStaticMethod<jshort[]>("staticShortArrayMethod");
|
const auto array = TestClass::callStaticMethod<jshort[]>("staticShortArrayMethod");
|
||||||
QVERIFY(array.isValid());
|
QVERIFY(array.isValid());
|
||||||
QCOMPARE(array.size(), 3);
|
QCOMPARE(array.size(), 3);
|
||||||
QCOMPARE(array.asContainer(), (QList<jshort>{3, 2, 1}));
|
QCOMPARE(array.toContainer(), (QList<jshort>{3, 2, 1}));
|
||||||
|
|
||||||
QJniArray<jshort> newArray(QList<jshort>{3, 2, 1});
|
QJniArray<jshort> newArray(QList<jshort>{3, 2, 1});
|
||||||
QVERIFY(newArray.isValid());
|
QVERIFY(newArray.isValid());
|
||||||
const auto reverse = TestClass::callStaticMethod<jshort[]>("staticReverseShortArray", newArray);
|
const auto reverse = TestClass::callStaticMethod<jshort[]>("staticReverseShortArray", newArray);
|
||||||
QVERIFY(reverse.isValid());
|
QVERIFY(reverse.isValid());
|
||||||
QCOMPARE(reverse.asContainer(), (QList<jshort>{1, 2, 3}));
|
QCOMPARE(reverse.toContainer(), (QList<jshort>{1, 2, 3}));
|
||||||
|
|
||||||
const QList<jshort> reverse2 = TestClass::callStaticMethod<QList<jshort>>("staticReverseShortArray",
|
const QList<jshort> reverse2 = TestClass::callStaticMethod<QList<jshort>>("staticReverseShortArray",
|
||||||
(QList<jshort>{1, 2, 3}));
|
(QList<jshort>{1, 2, 3}));
|
||||||
@ -1680,14 +1680,14 @@ void tst_QJniObject::templateApiCheck()
|
|||||||
const auto array = testClass.callMethod<jshort[]>("shortArrayMethod");
|
const auto array = testClass.callMethod<jshort[]>("shortArrayMethod");
|
||||||
QVERIFY(array.isValid());
|
QVERIFY(array.isValid());
|
||||||
QCOMPARE(array.size(), 3);
|
QCOMPARE(array.size(), 3);
|
||||||
QCOMPARE(array.asContainer(), (QList<jshort>{3, 2, 1}));
|
QCOMPARE(array.toContainer(), (QList<jshort>{3, 2, 1}));
|
||||||
|
|
||||||
QJniArray<jshort> newArray = QJniArrayBase::fromContainer(QList<jshort>{3, 2, 1});
|
QJniArray<jshort> newArray = QJniArrayBase::fromContainer(QList<jshort>{3, 2, 1});
|
||||||
static_assert(std::is_same_v<decltype(newArray)::Type, jshort>);
|
static_assert(std::is_same_v<decltype(newArray)::Type, jshort>);
|
||||||
QVERIFY(newArray.isValid());
|
QVERIFY(newArray.isValid());
|
||||||
const auto reverse = testClass.callMethod<jshort[]>("reverseShortArray", newArray);
|
const auto reverse = testClass.callMethod<jshort[]>("reverseShortArray", newArray);
|
||||||
QVERIFY(reverse.isValid());
|
QVERIFY(reverse.isValid());
|
||||||
QCOMPARE(reverse.asContainer(), (QList<jshort>{1, 2, 3}));
|
QCOMPARE(reverse.toContainer(), (QList<jshort>{1, 2, 3}));
|
||||||
}
|
}
|
||||||
|
|
||||||
// jintArray ----------------------------------------------------------------------------------
|
// jintArray ----------------------------------------------------------------------------------
|
||||||
@ -1699,13 +1699,13 @@ void tst_QJniObject::templateApiCheck()
|
|||||||
const auto array = TestClass::callStaticMethod<jint[]>("staticIntArrayMethod");
|
const auto array = TestClass::callStaticMethod<jint[]>("staticIntArrayMethod");
|
||||||
QVERIFY(array.isValid());
|
QVERIFY(array.isValid());
|
||||||
QCOMPARE(array.size(), 3);
|
QCOMPARE(array.size(), 3);
|
||||||
QCOMPARE(array.asContainer(), (QList<jint>{3, 2, 1}));
|
QCOMPARE(array.toContainer(), (QList<jint>{3, 2, 1}));
|
||||||
|
|
||||||
QJniArray<jint> newArray(QList<jint>{3, 2, 1});
|
QJniArray<jint> newArray(QList<jint>{3, 2, 1});
|
||||||
QVERIFY(newArray.isValid());
|
QVERIFY(newArray.isValid());
|
||||||
const auto reverse = TestClass::callStaticMethod<jint[]>("staticReverseIntArray", newArray);
|
const auto reverse = TestClass::callStaticMethod<jint[]>("staticReverseIntArray", newArray);
|
||||||
QVERIFY(reverse.isValid());
|
QVERIFY(reverse.isValid());
|
||||||
QCOMPARE(reverse.asContainer(), (QList<jint>{1, 2, 3}));
|
QCOMPARE(reverse.toContainer(), (QList<jint>{1, 2, 3}));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -1715,13 +1715,13 @@ void tst_QJniObject::templateApiCheck()
|
|||||||
const auto array = testClass.callMethod<jint[]>("intArrayMethod");
|
const auto array = testClass.callMethod<jint[]>("intArrayMethod");
|
||||||
QVERIFY(array.isValid());
|
QVERIFY(array.isValid());
|
||||||
QCOMPARE(array.size(), 3);
|
QCOMPARE(array.size(), 3);
|
||||||
QCOMPARE(array.asContainer(), (QList<jint>{3, 2, 1}));
|
QCOMPARE(array.toContainer(), (QList<jint>{3, 2, 1}));
|
||||||
|
|
||||||
QJniArray<jint> newArray = QJniArrayBase::fromContainer(QList<jint>{3, 2, 1});
|
QJniArray<jint> newArray = QJniArrayBase::fromContainer(QList<jint>{3, 2, 1});
|
||||||
QVERIFY(newArray.isValid());
|
QVERIFY(newArray.isValid());
|
||||||
const auto reverse = testClass.callMethod<jint[]>("reverseIntArray", newArray);
|
const auto reverse = testClass.callMethod<jint[]>("reverseIntArray", newArray);
|
||||||
QVERIFY(reverse.isValid());
|
QVERIFY(reverse.isValid());
|
||||||
QCOMPARE(reverse.asContainer(), (QList<jint>{1, 2, 3}));
|
QCOMPARE(reverse.toContainer(), (QList<jint>{1, 2, 3}));
|
||||||
}
|
}
|
||||||
|
|
||||||
// jlongArray ---------------------------------------------------------------------------------
|
// jlongArray ---------------------------------------------------------------------------------
|
||||||
@ -1733,13 +1733,13 @@ void tst_QJniObject::templateApiCheck()
|
|||||||
const auto array = TestClass::callStaticMethod<jlong[]>("staticLongArrayMethod");
|
const auto array = TestClass::callStaticMethod<jlong[]>("staticLongArrayMethod");
|
||||||
QVERIFY(array.isValid());
|
QVERIFY(array.isValid());
|
||||||
QCOMPARE(array.size(), 3);
|
QCOMPARE(array.size(), 3);
|
||||||
QCOMPARE(array.asContainer(), (QList<jlong>{3, 2, 1}));
|
QCOMPARE(array.toContainer(), (QList<jlong>{3, 2, 1}));
|
||||||
|
|
||||||
QJniArray<jlong> newArray(QList<jlong>{3, 2, 1});
|
QJniArray<jlong> newArray(QList<jlong>{3, 2, 1});
|
||||||
QVERIFY(newArray.isValid());
|
QVERIFY(newArray.isValid());
|
||||||
const auto reverse = TestClass::callStaticMethod<jlong[]>("staticReverseLongArray", newArray);
|
const auto reverse = TestClass::callStaticMethod<jlong[]>("staticReverseLongArray", newArray);
|
||||||
QVERIFY(reverse.isValid());
|
QVERIFY(reverse.isValid());
|
||||||
QCOMPARE(reverse.asContainer(), (QList<jlong>{1, 2, 3}));
|
QCOMPARE(reverse.toContainer(), (QList<jlong>{1, 2, 3}));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -1749,13 +1749,13 @@ void tst_QJniObject::templateApiCheck()
|
|||||||
const auto array = testClass.callMethod<jlong[]>("longArrayMethod");
|
const auto array = testClass.callMethod<jlong[]>("longArrayMethod");
|
||||||
QVERIFY(array.isValid());
|
QVERIFY(array.isValid());
|
||||||
QCOMPARE(array.size(), 3);
|
QCOMPARE(array.size(), 3);
|
||||||
QCOMPARE(array.asContainer(), (QList<jlong>{3, 2, 1}));
|
QCOMPARE(array.toContainer(), (QList<jlong>{3, 2, 1}));
|
||||||
|
|
||||||
QJniArray<jlong> newArray = QJniArrayBase::fromContainer(QList<jlong>{3, 2, 1});
|
QJniArray<jlong> newArray = QJniArrayBase::fromContainer(QList<jlong>{3, 2, 1});
|
||||||
QVERIFY(newArray.isValid());
|
QVERIFY(newArray.isValid());
|
||||||
const auto reverse = testClass.callMethod<jlong[]>("reverseLongArray", newArray);
|
const auto reverse = testClass.callMethod<jlong[]>("reverseLongArray", newArray);
|
||||||
QVERIFY(reverse.isValid());
|
QVERIFY(reverse.isValid());
|
||||||
QCOMPARE(reverse.asContainer(), (QList<jlong>{1, 2, 3}));
|
QCOMPARE(reverse.toContainer(), (QList<jlong>{1, 2, 3}));
|
||||||
}
|
}
|
||||||
|
|
||||||
// jfloatArray --------------------------------------------------------------------------------
|
// jfloatArray --------------------------------------------------------------------------------
|
||||||
@ -1767,13 +1767,13 @@ void tst_QJniObject::templateApiCheck()
|
|||||||
const auto array = TestClass::callStaticMethod<jfloat[]>("staticFloatArrayMethod");
|
const auto array = TestClass::callStaticMethod<jfloat[]>("staticFloatArrayMethod");
|
||||||
QVERIFY(array.isValid());
|
QVERIFY(array.isValid());
|
||||||
QCOMPARE(array.size(), 3);
|
QCOMPARE(array.size(), 3);
|
||||||
QCOMPARE(array.asContainer(), (QList<jfloat>{1.0f, 2.0f, 3.0f}));
|
QCOMPARE(array.toContainer(), (QList<jfloat>{1.0f, 2.0f, 3.0f}));
|
||||||
|
|
||||||
QJniArray<jfloat> newArray(QList<jfloat>{3.0f, 2.0f, 1.0f});
|
QJniArray<jfloat> newArray(QList<jfloat>{3.0f, 2.0f, 1.0f});
|
||||||
QVERIFY(newArray.isValid());
|
QVERIFY(newArray.isValid());
|
||||||
const auto reverse = TestClass::callStaticMethod<jfloat[]>("staticReverseFloatArray", newArray);
|
const auto reverse = TestClass::callStaticMethod<jfloat[]>("staticReverseFloatArray", newArray);
|
||||||
QVERIFY(reverse.isValid());
|
QVERIFY(reverse.isValid());
|
||||||
QCOMPARE(reverse.asContainer(), (QList<jfloat>{1.0f, 2.0f, 3.0f}));
|
QCOMPARE(reverse.toContainer(), (QList<jfloat>{1.0f, 2.0f, 3.0f}));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -1783,13 +1783,13 @@ void tst_QJniObject::templateApiCheck()
|
|||||||
const auto array = testClass.callMethod<jfloat[]>("floatArrayMethod");
|
const auto array = testClass.callMethod<jfloat[]>("floatArrayMethod");
|
||||||
QVERIFY(array.isValid());
|
QVERIFY(array.isValid());
|
||||||
QCOMPARE(array.size(), 3);
|
QCOMPARE(array.size(), 3);
|
||||||
QCOMPARE(array.asContainer(), (QList<jfloat>{1.0f, 2.0f, 3.0f}));
|
QCOMPARE(array.toContainer(), (QList<jfloat>{1.0f, 2.0f, 3.0f}));
|
||||||
|
|
||||||
QJniArray<jfloat> newArray = QJniArrayBase::fromContainer(QList<jfloat>{3.0f, 2.0f, 1.0f});
|
QJniArray<jfloat> newArray = QJniArrayBase::fromContainer(QList<jfloat>{3.0f, 2.0f, 1.0f});
|
||||||
QVERIFY(newArray.isValid());
|
QVERIFY(newArray.isValid());
|
||||||
const auto reverse = testClass.callMethod<jfloat[]>("reverseFloatArray", newArray);
|
const auto reverse = testClass.callMethod<jfloat[]>("reverseFloatArray", newArray);
|
||||||
QVERIFY(reverse.isValid());
|
QVERIFY(reverse.isValid());
|
||||||
QCOMPARE(reverse.asContainer(), (QList<jfloat>{1.0f, 2.0f, 3.0f}));
|
QCOMPARE(reverse.toContainer(), (QList<jfloat>{1.0f, 2.0f, 3.0f}));
|
||||||
}
|
}
|
||||||
|
|
||||||
// jdoubleArray -------------------------------------------------------------------------------
|
// jdoubleArray -------------------------------------------------------------------------------
|
||||||
@ -1801,13 +1801,13 @@ void tst_QJniObject::templateApiCheck()
|
|||||||
const auto array = TestClass::callStaticMethod<jdouble[]>("staticDoubleArrayMethod");
|
const auto array = TestClass::callStaticMethod<jdouble[]>("staticDoubleArrayMethod");
|
||||||
QVERIFY(array.isValid());
|
QVERIFY(array.isValid());
|
||||||
QCOMPARE(array.size(), 3);
|
QCOMPARE(array.size(), 3);
|
||||||
QCOMPARE(array.asContainer(), (QList<jdouble>{3.0, 2.0, 1.0}));
|
QCOMPARE(array.toContainer(), (QList<jdouble>{3.0, 2.0, 1.0}));
|
||||||
|
|
||||||
QJniArray<jdouble> newArray(QList<jdouble>{3.0, 2.0, 1.0});
|
QJniArray<jdouble> newArray(QList<jdouble>{3.0, 2.0, 1.0});
|
||||||
QVERIFY(newArray.isValid());
|
QVERIFY(newArray.isValid());
|
||||||
const auto reverse = TestClass::callStaticMethod<jdouble[]>("staticReverseDoubleArray", newArray);
|
const auto reverse = TestClass::callStaticMethod<jdouble[]>("staticReverseDoubleArray", newArray);
|
||||||
QVERIFY(reverse.isValid());
|
QVERIFY(reverse.isValid());
|
||||||
QCOMPARE(reverse.asContainer(), (QList<jdouble>{1.0, 2.0, 3.0}));
|
QCOMPARE(reverse.toContainer(), (QList<jdouble>{1.0, 2.0, 3.0}));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -1817,13 +1817,13 @@ void tst_QJniObject::templateApiCheck()
|
|||||||
const auto array = testClass.callMethod<jdouble[]>("doubleArrayMethod");
|
const auto array = testClass.callMethod<jdouble[]>("doubleArrayMethod");
|
||||||
QVERIFY(array.isValid());
|
QVERIFY(array.isValid());
|
||||||
QCOMPARE(array.size(), 3);
|
QCOMPARE(array.size(), 3);
|
||||||
QCOMPARE(array.asContainer(), (QList<jdouble>{3.0, 2.0, 1.0}));
|
QCOMPARE(array.toContainer(), (QList<jdouble>{3.0, 2.0, 1.0}));
|
||||||
|
|
||||||
QJniArray<jdouble> newArray = QJniArrayBase::fromContainer(QList<jdouble>{3.0, 2.0, 1.0});
|
QJniArray<jdouble> newArray = QJniArrayBase::fromContainer(QList<jdouble>{3.0, 2.0, 1.0});
|
||||||
QVERIFY(newArray.isValid());
|
QVERIFY(newArray.isValid());
|
||||||
const auto reverse = testClass.callMethod<jdouble[]>("reverseDoubleArray", newArray);
|
const auto reverse = testClass.callMethod<jdouble[]>("reverseDoubleArray", newArray);
|
||||||
QVERIFY(reverse.isValid());
|
QVERIFY(reverse.isValid());
|
||||||
QCOMPARE(reverse.asContainer(), (QList<jdouble>{1.0, 2.0, 3.0}));
|
QCOMPARE(reverse.toContainer(), (QList<jdouble>{1.0, 2.0, 3.0}));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user