Metatype: make the Qt CBOR value-like types built-in meta types
This change only adds them to the registry and reserves the IDs. The next commit will handle conversions. Change-Id: I56b444f9d6274221a3b7fffd150d2d49f40940c2 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
71e41d7230
commit
6c64a9b2d2
@ -245,11 +245,8 @@ void CborDiagnosticDumper::saveFile(QIODevice *f, const QVariant &contents, cons
|
||||
|
||||
CborConverter::CborConverter()
|
||||
{
|
||||
qRegisterMetaType<QCborSimpleType>();
|
||||
qRegisterMetaType<QCborTag>();
|
||||
qRegisterMetaTypeStreamOperators<QCborSimpleType>();
|
||||
qRegisterMetaTypeStreamOperators<QCborTag>();
|
||||
QMetaType::registerDebugStreamOperator<QCborSimpleType>();
|
||||
QMetaType::registerDebugStreamOperator<QCborTag>();
|
||||
}
|
||||
|
||||
|
@ -65,6 +65,9 @@
|
||||
# include "qjsonobject.h"
|
||||
# include "qjsonarray.h"
|
||||
# include "qjsondocument.h"
|
||||
# include "qcborvalue.h"
|
||||
# include "qcborarray.h"
|
||||
# include "qcbormap.h"
|
||||
# include "qbytearraylist.h"
|
||||
#endif
|
||||
|
||||
@ -1346,6 +1349,9 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data)
|
||||
case QMetaType::QJsonObject:
|
||||
case QMetaType::QJsonArray:
|
||||
case QMetaType::QJsonDocument:
|
||||
case QMetaType::QCborValue:
|
||||
case QMetaType::QCborArray:
|
||||
case QMetaType::QCborMap:
|
||||
return false;
|
||||
case QMetaType::Nullptr:
|
||||
stream << *static_cast<const std::nullptr_t *>(data);
|
||||
@ -1484,6 +1490,9 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data)
|
||||
case QMetaType::QEasingCurve:
|
||||
stream << *static_cast<const NS(QEasingCurve)*>(data);
|
||||
break;
|
||||
case QMetaType::QCborSimpleType:
|
||||
stream << *static_cast<const quint8 *>(data);
|
||||
break;
|
||||
#endif // QT_BOOTSTRAPPED
|
||||
case QMetaType::QFont:
|
||||
case QMetaType::QPixmap:
|
||||
@ -1572,6 +1581,9 @@ bool QMetaType::load(QDataStream &stream, int type, void *data)
|
||||
case QMetaType::QJsonObject:
|
||||
case QMetaType::QJsonArray:
|
||||
case QMetaType::QJsonDocument:
|
||||
case QMetaType::QCborValue:
|
||||
case QMetaType::QCborArray:
|
||||
case QMetaType::QCborMap:
|
||||
return false;
|
||||
case QMetaType::Nullptr:
|
||||
stream >> *static_cast<std::nullptr_t *>(data);
|
||||
@ -1716,6 +1728,9 @@ bool QMetaType::load(QDataStream &stream, int type, void *data)
|
||||
case QMetaType::QEasingCurve:
|
||||
stream >> *static_cast< NS(QEasingCurve)*>(data);
|
||||
break;
|
||||
case QMetaType::QCborSimpleType:
|
||||
stream >> *static_cast<quint8 *>(data);
|
||||
break;
|
||||
#endif // QT_BOOTSTRAPPED
|
||||
case QMetaType::QFont:
|
||||
case QMetaType::QPixmap:
|
||||
|
@ -1,6 +1,7 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Copyright (C) 2018 Intel Corporation.
|
||||
** Copyright (C) 2014 Olivier Goffart <ogoffart@woboq.com>
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
@ -60,6 +61,9 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
// from qcborcommon.h
|
||||
enum class QCborSimpleType : quint8;
|
||||
|
||||
template <typename T>
|
||||
struct QMetaTypeId2;
|
||||
|
||||
@ -85,6 +89,7 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId();
|
||||
F(Float, 38, float) \
|
||||
F(SChar, 40, signed char) \
|
||||
F(Nullptr, 51, std::nullptr_t) \
|
||||
F(QCborSimpleType, 52, QCborSimpleType) \
|
||||
|
||||
#define QT_FOR_EACH_STATIC_PRIMITIVE_POINTER(F)\
|
||||
F(VoidStar, 31, void*) \
|
||||
@ -125,6 +130,9 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId();
|
||||
F(QJsonObject, 46, QJsonObject) \
|
||||
F(QJsonArray, 47, QJsonArray) \
|
||||
F(QJsonDocument, 48, QJsonDocument) \
|
||||
F(QCborValue, 53, QCborValue) \
|
||||
F(QCborArray, 54, QCborArray) \
|
||||
F(QCborMap, 55, QCborMap) \
|
||||
QT_FOR_EACH_STATIC_ITEMMODEL_CLASS(F)
|
||||
|
||||
#define QT_FOR_EACH_STATIC_CORE_POINTER(F)\
|
||||
@ -420,7 +428,7 @@ public:
|
||||
QT_FOR_EACH_STATIC_TYPE(QT_DEFINE_METATYPE_ID)
|
||||
|
||||
FirstCoreType = Bool,
|
||||
LastCoreType = Nullptr,
|
||||
LastCoreType = QCborMap,
|
||||
FirstGuiType = QFont,
|
||||
LastGuiType = QPolygonF,
|
||||
FirstWidgetsType = QSizePolicy,
|
||||
@ -450,13 +458,18 @@ public:
|
||||
Void = 43,
|
||||
Nullptr = 51,
|
||||
QVariantMap = 8, QVariantList = 9, QVariantHash = 28,
|
||||
QCborSimpleType = 52, QCborValue = 53, QCborArray = 54, QCborMap = 55,
|
||||
|
||||
// Gui types
|
||||
QFont = 64, QPixmap = 65, QBrush = 66, QColor = 67, QPalette = 68,
|
||||
QIcon = 69, QImage = 70, QPolygon = 71, QRegion = 72, QBitmap = 73,
|
||||
QCursor = 74, QKeySequence = 75, QPen = 76, QTextLength = 77, QTextFormat = 78,
|
||||
QMatrix = 79, QTransform = 80, QMatrix4x4 = 81, QVector2D = 82,
|
||||
QVector3D = 83, QVector4D = 84, QQuaternion = 85, QPolygonF = 86,
|
||||
|
||||
// Widget types
|
||||
QSizePolicy = 121,
|
||||
LastCoreType = Nullptr,
|
||||
LastCoreType = QCborMap,
|
||||
LastGuiType = QPolygonF,
|
||||
User = 1024
|
||||
};
|
||||
|
@ -196,6 +196,10 @@ struct TypeDefinition {
|
||||
// Ignore these types, as incomplete
|
||||
#ifdef QT_BOOTSTRAPPED
|
||||
template<> struct TypeDefinition<QBitArray> { static const bool IsAvailable = false; };
|
||||
template<> struct TypeDefinition<QCborArray> { static const bool IsAvailable = false; };
|
||||
template<> struct TypeDefinition<QCborMap> { static const bool IsAvailable = false; };
|
||||
template<> struct TypeDefinition<QCborSimpleType> { static const bool IsAvailable = false; };
|
||||
template<> struct TypeDefinition<QCborValue> { static const bool IsAvailable = false; };
|
||||
template<> struct TypeDefinition<QEasingCurve> { static const bool IsAvailable = false; };
|
||||
template<> struct TypeDefinition<QJsonArray> { static const bool IsAvailable = false; };
|
||||
template<> struct TypeDefinition<QJsonDocument> { static const bool IsAvailable = false; };
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Intel Corporation.
|
||||
** Copyright (C) 2018 Intel Corporation.
|
||||
** Copyright (C) 2015 Olivier Goffart <ogoffart@woboq.com>
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
@ -60,6 +60,9 @@
|
||||
#include "qabstractitemmodel.h"
|
||||
#endif
|
||||
#ifndef QT_BOOTSTRAPPED
|
||||
#include "qcborarray.h"
|
||||
#include "qcborcommon.h"
|
||||
#include "qcbormap.h"
|
||||
#include "qjsonvalue.h"
|
||||
#include "qjsonobject.h"
|
||||
#include "qjsonarray.h"
|
||||
|
@ -128,7 +128,6 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, QCborTag tg);
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
Q_DECLARE_METATYPE(QCborSimpleType)
|
||||
Q_DECLARE_METATYPE(QCborTag)
|
||||
|
||||
#endif // QCBORSTREAM_H
|
||||
|
@ -1186,6 +1186,10 @@ static void testMetaTypesHelper(QSettings::Format format)
|
||||
F(QJsonArray) \
|
||||
F(QJsonDocument) \
|
||||
F(QPersistentModelIndex) \
|
||||
F(QCborSimpleType) \
|
||||
F(QCborValue) \
|
||||
F(QCborArray) \
|
||||
F(QCborMap) \
|
||||
|
||||
#define EXCLUDE_NON_SUPPORTED_METATYPES(MetaTypeName) \
|
||||
template<> void testMetaTypesHelper<QMetaType::MetaTypeName>(QSettings::Format) \
|
||||
|
@ -1574,6 +1574,9 @@ DECLARE_NONSTREAMABLE(QJsonValue)
|
||||
DECLARE_NONSTREAMABLE(QJsonObject)
|
||||
DECLARE_NONSTREAMABLE(QJsonArray)
|
||||
DECLARE_NONSTREAMABLE(QJsonDocument)
|
||||
DECLARE_NONSTREAMABLE(QCborValue)
|
||||
DECLARE_NONSTREAMABLE(QCborArray)
|
||||
DECLARE_NONSTREAMABLE(QCborMap)
|
||||
DECLARE_NONSTREAMABLE(QObject*)
|
||||
DECLARE_NONSTREAMABLE(QWidget*)
|
||||
|
||||
|
@ -273,6 +273,24 @@ template<> struct TestValueFactory<QMetaType::QJsonDocument> {
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
template<> struct TestValueFactory<QMetaType::QCborSimpleType> {
|
||||
static QCborSimpleType *create() { return new QCborSimpleType(QCborSimpleType::True); }
|
||||
};
|
||||
template<> struct TestValueFactory<QMetaType::QCborValue> {
|
||||
static QCborValue *create() { return new QCborValue(123.); }
|
||||
};
|
||||
template<> struct TestValueFactory<QMetaType::QCborMap> {
|
||||
static QCborMap *create() {
|
||||
return new QCborMap{{0, 0}, {"Hello", 1}, {1, nullptr}};
|
||||
}
|
||||
};
|
||||
template<> struct TestValueFactory<QMetaType::QCborArray> {
|
||||
static QCborArray *create() {
|
||||
return new QCborArray{0, 1, -2, 2.5, false, nullptr, "Hello", QByteArray("World") };
|
||||
}
|
||||
};
|
||||
|
||||
template<> struct TestValueFactory<QMetaType::QVariant> {
|
||||
static QVariant *create() { return new QVariant(QStringList(QStringList() << "Q" << "t")); }
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user