summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qmetatype.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-08-04 10:35:46 +0200
committerLars Knoll <lars.knoll@qt.io>2020-08-24 00:19:05 +0200
commit1697fbdf05ff643d617a9ba1614454926e86a3d9 (patch)
tree1c090fd9254ccedf33e724158e115157998304cf /src/corelib/kernel/qmetatype.h
parent92b37676328a960bc092b1f3834233c550376457 (diff)
Deprecate the static int based API in QMetaType
And remove one of the type id to name mapping that still existed in QMetaType. QMetaTypeInterface can provide that, so there's no need to have a second copy of the data. qMetaTypeTypeInternal() can still map all the names of all builtin types to ids. That functionality is for now still required by moc and can't be removed yet. Change-Id: Ib4f8e9c71e1e7d99d52da9e44477c9a1f1805e57 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/kernel/qmetatype.h')
-rw-r--r--src/corelib/kernel/qmetatype.h52
1 files changed, 37 insertions, 15 deletions
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index cbf1e19187..ba4f2e8050 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -363,18 +363,39 @@ public:
static void registerNormalizedTypedef(const QT_PREPEND_NAMESPACE(QByteArray) &normalizedTypeName, QMetaType type);
- static int type(const char *typeName);
-
- static int type(const QT_PREPEND_NAMESPACE(QByteArray) &typeName);
- static const char *typeName(int type);
- static int sizeOf(int type);
- static TypeFlags typeFlags(int type);
- static const QMetaObject *metaObjectForType(int type);
+#if QT_DEPRECATED_SINCE(6, 0)
+ QT_DEPRECATED_VERSION_6_0
+ static int type(const char *typeName)
+ { return QMetaType::fromName(typeName).id(); }
+ QT_DEPRECATED_VERSION_6_0
+ static int type(const QT_PREPEND_NAMESPACE(QByteArray) &typeName)
+ { return QMetaType::fromName(typeName).id(); }
+ QT_DEPRECATED_VERSION_6_0
+ static const char *typeName(int type)
+ { return QMetaType(type).name(); }
+ QT_DEPRECATED_VERSION_6_0
+ static int sizeOf(int type)
+ { return QMetaType(type).sizeOf(); }
+ QT_DEPRECATED_VERSION_6_0
+ static TypeFlags typeFlags(int type)
+ { return QMetaType(type).flags(); }
+ QT_DEPRECATED_VERSION_6_0
+ static const QMetaObject *metaObjectForType(int type)
+ { return QMetaType(type).metaObject(); }
+ QT_DEPRECATED_VERSION_6_0
+ static void *create(int type, const void *copy = nullptr)
+ { return QMetaType(type).create(copy); }
+ QT_DEPRECATED_VERSION_6_0
+ static void destroy(int type, void *data)
+ { return QMetaType(type).destroy(data); }
+ QT_DEPRECATED_VERSION_6_0
+ static void *construct(int type, void *where, const void *copy)
+ { return QMetaType(type).construct(where, copy); }
+ QT_DEPRECATED_VERSION_6_0
+ static void destruct(int type, void *where)
+ { return QMetaType(type).destruct(where); }
+#endif
static bool isRegistered(int type);
- static void *create(int type, const void *copy = nullptr);
- static void destroy(int type, void *data);
- static void *construct(int type, void *where, const void *copy);
- static void destruct(int type, void *where);
explicit QMetaType(int type);
explicit constexpr QMetaType(QtPrivate::QMetaTypeInterface *d) : d_ptr(d) {}
@@ -387,7 +408,7 @@ public:
int alignOf() const;
TypeFlags flags() const;
const QMetaObject *metaObject() const;
- QT_PREPEND_NAMESPACE(QByteArray) name() const;
+ const char *name() const;
void *create(const void *copy = nullptr) const;
void destroy(void *data) const;
@@ -415,6 +436,7 @@ public:
template<typename T>
static QMetaType fromType();
+ static QMetaType fromName(QByteArrayView name);
friend bool operator==(const QMetaType &a, const QMetaType &b) { return a.id() == b.id(); }
friend bool operator!=(const QMetaType &a, const QMetaType &b) { return !(a == b); }
@@ -1690,7 +1712,7 @@ struct QMetaTypeId< SINGLE_ARG_TEMPLATE<T> > \
static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0); \
if (const int id = metatype_id.loadRelaxed()) \
return id; \
- const char *tName = QMetaType::typeName(qMetaTypeId<T>()); \
+ const char *tName = QMetaType::fromType<T>().name(); \
Q_ASSERT(tName); \
const int tNameLen = int(qstrlen(tName)); \
QByteArray typeName; \
@@ -1725,8 +1747,8 @@ struct QMetaTypeId< DOUBLE_ARG_TEMPLATE<T, U> > \
static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0); \
if (const int id = metatype_id.loadAcquire()) \
return id; \
- const char *tName = QMetaType::typeName(qMetaTypeId<T>()); \
- const char *uName = QMetaType::typeName(qMetaTypeId<U>()); \
+ const char *tName = QMetaType::fromType<T>().name(); \
+ const char *uName = QMetaType::fromType<U>().name(); \
Q_ASSERT(tName); \
Q_ASSERT(uName); \
const int tNameLen = int(qstrlen(tName)); \