summaryrefslogtreecommitdiffstats
path: root/src/core/qt3dcore_global.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-05-05 07:02:14 +0200
committerSean Harmer <sean.harmer@kdab.com>2016-05-05 13:21:08 +0000
commite702541972ed6bb233618ffb56a84b03cd360c3c (patch)
tree97af33e31362f9a02b10e4ba142548143976e121 /src/core/qt3dcore_global.h
parent4cf737a0f1cc05ff9baa4df329761d65f69e340c (diff)
Introduce local macros for declaring types as movable/primitive/shared
The QtCore macros aren't really suited to a namespaced library like Qt3D. In particular, the use of Q_DECLARE_SHARED is wrong, because it places the free swap() function in the Qt's namespace when it should be in the same (inner) namespace the type is in. Q_DECLARE_TYPEINFO, otoh, is just inconvenient to use because it requires exiting and later re-entering of the Qt3D namespace(s). The new macros do this implicitly. Change-Id: Ic91f447656f08ed59c118ce09cb5ac90ad212955 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/core/qt3dcore_global.h')
-rw-r--r--src/core/qt3dcore_global.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/core/qt3dcore_global.h b/src/core/qt3dcore_global.h
index 55ea7e81a..3eb5a667f 100644
--- a/src/core/qt3dcore_global.h
+++ b/src/core/qt3dcore_global.h
@@ -54,6 +54,25 @@ QT_BEGIN_NAMESPACE
# define QT3DCORESHARED_EXPORT
#endif
+#define QT3D_DECLARE_TYPEINFO(NS, Class, Flags) \
+ } /* NS */ \
+ Q_DECLARE_TYPEINFO(NS :: Class, Flags); \
+ namespace NS { \
+ /*end*/
+
+#define QT3D_DECLARE_TYPEINFO_2(OuterNS, InnerNS, Class, Flags) \
+ } /* InnerNS */ \
+ QT3D_DECLARE_TYPEINFO(OuterNS, InnerNS :: Class, Flags) \
+ namespace InnerNS { \
+ /*end*/
+
+#define QT3D_DECLARE_SHARED(NS, Class) \
+ inline void swap(Class &lhs, Class &rhs) \
+ Q_DECL_NOEXCEPT(noexcept(lhs.swap(rhs))) \
+ { lhs.swap(rhs); } \
+ QT3D_DECLARE_TYPEINFO(NS, Class, Q_MOVABLE_TYPE) \
+ /*end*/
+
QT_END_NAMESPACE
#endif // QT3DCORE_GLOBAL_H