summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qtclasshelpermacros.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/global/qtclasshelpermacros.h')
-rw-r--r--src/corelib/global/qtclasshelpermacros.h36
1 files changed, 12 insertions, 24 deletions
diff --git a/src/corelib/global/qtclasshelpermacros.h b/src/corelib/global/qtclasshelpermacros.h
index 3c59404910..8839e80fb9 100644
--- a/src/corelib/global/qtclasshelpermacros.h
+++ b/src/corelib/global/qtclasshelpermacros.h
@@ -78,6 +78,13 @@ template <typename T> inline T *qGetPtrHelper(T *ptr) noexcept { return ptr; }
template <typename Ptr> inline auto qGetPtrHelper(Ptr &ptr) noexcept -> decltype(ptr.get())
{ static_assert(noexcept(ptr.get()), "Smart d pointers for Q_DECLARE_PRIVATE must have noexcept get()"); return ptr.get(); }
+class QObject;
+class QObjectPrivate;
+namespace QtPrivate {
+ template <typename ObjPrivate> void assertObjectType(QObjectPrivate *d);
+ inline const QObject *getQObject(const QObjectPrivate *d);
+}
+
#define Q_DECLARE_PRIVATE(Class) \
inline Class##Private* d_func() noexcept \
{ Q_CAST_IGNORE_ALIGN(return reinterpret_cast<Class##Private *>(qGetPtrHelper(d_ptr));) } \
@@ -95,32 +102,14 @@ template <typename Ptr> inline auto qGetPtrHelper(Ptr &ptr) noexcept -> decltype
#define Q_DECLARE_PUBLIC(Class) \
inline Class* q_func() noexcept { return static_cast<Class *>(q_ptr); } \
inline const Class* q_func() const noexcept { return static_cast<const Class *>(q_ptr); } \
- friend class Class;
+ friend class Class; \
+ friend const QObject *QtPrivate::getQObject(const QObjectPrivate *d); \
+ template <typename ObjPrivate> friend void QtPrivate::assertObjectType(QObjectPrivate *d);
#define Q_D(Class) Class##Private * const d = d_func()
#define Q_Q(Class) Class * const q = q_func()
/*
- Compilers which follow outdated template instantiation rules
- require a class to have a comparison operator to exist when
- a QList of this type is instantiated. It's not actually
- used in the list, though. Hence the dummy implementation.
- Just in case other code relies on it we better trigger a warning
- mandating a real implementation.
-*/
-
-#ifdef Q_FULL_TEMPLATE_INSTANTIATION
-# define Q_DUMMY_COMPARISON_OPERATOR(C) \
- bool operator==(const C&) const { \
- qWarning(#C"::operator==(const "#C"&) was called"); \
- return false; \
- }
-#else
-
-# define Q_DUMMY_COMPARISON_OPERATOR(C)
-#endif
-
-/*
Specialize a shared type with:
Q_DECLARE_SHARED(type)
@@ -130,12 +119,11 @@ template <typename Ptr> inline auto qGetPtrHelper(Ptr &ptr) noexcept -> decltype
namespace as Qt for this to work.
*/
-#define Q_DECLARE_SHARED_IMPL(TYPE, FLAGS) \
-Q_DECLARE_TYPEINFO(TYPE, FLAGS); \
+#define Q_DECLARE_SHARED(TYPE) \
+Q_DECLARE_TYPEINFO(TYPE, Q_RELOCATABLE_TYPE); \
inline void swap(TYPE &value1, TYPE &value2) \
noexcept(noexcept(value1.swap(value2))) \
{ value1.swap(value2); }
-#define Q_DECLARE_SHARED(TYPE) Q_DECLARE_SHARED_IMPL(TYPE, Q_RELOCATABLE_TYPE)
#endif // __cplusplus