summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qmetatype_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-07-12 12:19:34 +0200
committerLars Knoll <lars.knoll@qt.io>2020-08-24 00:17:05 +0200
commit73fd7f2efcdb31e33febe840357a9d7b05e89165 (patch)
tree5a2a5756e03892c55856a4275521c1924213e3b9 /src/corelib/kernel/qmetatype_p.h
parenta701b0ed30cda064aea111f18355c8b268c22974 (diff)
Use QMetaTypeModuleHelper as the interface to do type conversions
Move the type conversions from QVariant::Helper to QMetaType. Only do this for Qt Gui in a first step. This makes it possible to completely remove the Handler struct in QVariant, and now allows QMetaType to also convert Gui types. Moving the conversion of Core types into QMetaType will require further work. Change-Id: I061f789deca1b595d92bb29227eb54b8e71a3ee3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qmetatype_p.h')
-rw-r--r--src/corelib/kernel/qmetatype_p.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/corelib/kernel/qmetatype_p.h b/src/corelib/kernel/qmetatype_p.h
index dedec4d469..9e391e6476 100644
--- a/src/corelib/kernel/qmetatype_p.h
+++ b/src/corelib/kernel/qmetatype_p.h
@@ -128,10 +128,31 @@ QT_WARNING_POP
#undef QT_DECLARE_GUI_MODULE_TYPES_ITER
#undef QT_DECLARE_WIDGETS_MODULE_TYPES_ITER
+#define QMETATYPE_CONVERTER(To, From, assign_and_return) \
+ case makePair(QMetaType::To, QMetaType::From): \
+ if (onlyCheck) \
+ return true; \
+ { \
+ const From &source = *static_cast<const From *>(from); \
+ To &result = *static_cast<To *>(to); \
+ assign_and_return \
+ }
+#define QMETATYPE_CONVERTER_FUNCTION(To, assign_and_return) \
+ { \
+ To &result = *static_cast<To *>(r); \
+ assign_and_return \
+ }
+
class QMetaTypeModuleHelper
{
public:
+ static constexpr auto makePair(int from, int to) -> quint64
+ {
+ return (quint64(from) << 32) + quint64(to);
+ };
+
virtual QtPrivate::QMetaTypeInterface *interfaceForType(int) const = 0;
+ virtual bool convert(const void *, int, void *, int) const { return false; }
};
namespace QtMetaTypePrivate {