40 #ifndef QNATIVEINTERFACE_H
41 #define QNATIVEINTERFACE_H
43 #include <QtCore/qglobal.h>
52 #define QT_DECLARE_NATIVE_INTERFACE_3(NativeInterface, Revision, BaseType) \
54 virtual ~NativeInterface(); \
57 using baseType = BaseType; \
58 static constexpr char const *name = QT_STRINGIFY(NativeInterface); \
59 static constexpr int revision = Revision; \
62 template <typename, typename> \
63 friend struct QNativeInterface::Private::has_type_info; \
66 friend bool constexpr QNativeInterface::Private::hasTypeInfo(); \
69 friend struct QNativeInterface::Private::TypeInfo; \
71 NativeInterface() = default; \
72 Q_DISABLE_COPY_MOVE(NativeInterface)
77 #define QT_DECLARE_NATIVE_INTERFACE_2(NativeInterface, Revision) \
78 static_assert(false, "Must provide a base type when specifying revision");
80 #define QT_DECLARE_NATIVE_INTERFACE_1(NativeInterface) \
81 QT_DECLARE_NATIVE_INTERFACE_3(NativeInterface, 0, void)
83 #define QT_DECLARE_NATIVE_INTERFACE(...) \
84 QT_OVERLOADED_MACRO(QT_DECLARE_NATIVE_INTERFACE, __VA_ARGS__)
90 template <
typename NativeInterface,
typename =
void>
95 template <
typename NativeInterface>
97 typename NativeInterface::TypeInfo,
98 typename NativeInterface::TypeInfo::baseType,
99 decltype(&NativeInterface::TypeInfo::name),
100 decltype(&NativeInterface::TypeInfo::revision)
101 >> : std::true_type {};
106 template <
typename NativeInterface>
112 template <
typename NativeInterface>
122 template <
typename BaseType>
134 template <
typename BaseType>
143 return NativeInterface::TypeInfo::revision;
148 static constexpr
char const *
name()
159 template <
typename I>
165 #define QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(T) \
166 template <typename QNativeInterface> \
167 QNativeInterface *nativeInterface() const;
169 #define QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(T) \
170 template <typename NativeInterface, typename TypeInfo = QNativeInterface::Private::NativeInterface<NativeInterface>, \
171 typename BaseType = T, std::enable_if_t<TypeInfo::template isCompatibleWith<T>, bool> = true> \
172 NativeInterface *nativeInterface() const \
174 return static_cast<NativeInterface*>(resolveInterface( \
175 TypeInfo::name(), TypeInfo::revision())); \
178 void *resolveInterface(const char *name, int revision) const; \
constexpr bool hasTypeInfo()
static constexpr char const * name()
static constexpr bool isCompatibleHelper()
static constexpr bool haveTypeInfo
static constexpr bool isCompatibleWith
static constexpr int revision()