Commit deed122b authored by Volker Krause's avatar Volker Krause
Browse files

Make property wrappers compatible with the generic JNI object wrappers

This is supposed to gradually replace the use of untyped
QAndroidJniObjects.
parent a9bc37c8
......@@ -7,6 +7,7 @@
#ifndef KANDROIDEXTRAS_JNIPROPERTIES_H
#define KANDROIDEXTRAS_JNIPROPERTIES_H
#include "jniobject.h"
#include "jnisignature.h"
#include "jnitypes.h"
#include "jnitypetraits.h"
......@@ -40,6 +41,11 @@ struct StaticProperty<PropType, ClassType, NameHolder, false> {
{
return Jni::converter<PropType>::convert(get());
}
template <typename RetT = PropType, typename = std::enable_if_t<Jni::is_generic_wrapper<PropType>::value, RetT>>
inline operator Jni::Object<PropType>() const
{
return Jni::Object<PropType>(get());
}
};
template <typename PropType, typename ClassType, typename NameHolder>
......@@ -84,6 +90,11 @@ public:
{
return PropType(get());
}
template <typename RetT = PropType, typename = std::enable_if_t<Jni::is_generic_wrapper<PropType>::value, RetT>>
inline operator Jni::Object<PropType>() const
{
return Jni::Object<PropType>(get());
}
inline Property& operator=(const QAndroidJniObject &value)
{
......
......@@ -51,6 +51,11 @@ template <typename T> struct is_array<Array<T>> : std::true_type {};
template <typename T, typename = std::void_t<>> struct is_object_wrapper : std::false_type {};
template <typename T> struct is_object_wrapper<T, std::void_t<typename T::_jni_ThisType>> : std::true_type {};
/** Type trais for checking whether @tparam T is needs the generic JNI object wrapper (Jni::Object). */
template <typename T> struct is_generic_wrapper : std::conditional_t<
!is_basic_type<T>::value && !is_array<T>::value && !is_object_wrapper<T>::value, std::true_type, std::false_type>
{};
}
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment