Add std::nullptr_t as builtin type in QMetaType

Change-Id: If6c484bc89a2610c6a9e3e7bd54ef85ef40a783f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
This commit is contained in:
Jędrzej Nowacki 2016-02-25 15:08:32 +01:00
parent 958bc5793f
commit d7132c6c6d
3 changed files with 10 additions and 1 deletions

View File

@ -1268,6 +1268,7 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data)
case QMetaType::UnknownType:
case QMetaType::Void:
case QMetaType::VoidStar:
case QMetaType::Nullptr:
case QMetaType::QObjectStar:
case QMetaType::QModelIndex:
case QMetaType::QPersistentModelIndex:
@ -1489,6 +1490,7 @@ bool QMetaType::load(QDataStream &stream, int type, void *data)
case QMetaType::UnknownType:
case QMetaType::Void:
case QMetaType::VoidStar:
case QMetaType::Nullptr:
case QMetaType::QObjectStar:
case QMetaType::QModelIndex:
case QMetaType::QPersistentModelIndex:
@ -1838,6 +1840,8 @@ public:
template<typename T>
void delegate(const T *where) { DestructorImpl<T>::Destruct(m_type, const_cast<T*>(where)); }
// MSVC2013 and earlier can not const_cast a std::nullptr_t pointer.
void delegate(const std::nullptr_t *) {}
void delegate(const void *) {}
void delegate(const QMetaTypeSwitcher::UnknownType*) {}
void delegate(const QMetaTypeSwitcher::NotBuiltinType *where)

View File

@ -86,6 +86,7 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId();
F(UChar, 37, uchar) \
F(Float, 38, float) \
F(SChar, 40, signed char) \
F(Nullptr, 51, std::nullptr_t) \
#define QT_FOR_EACH_STATIC_PRIMITIVE_POINTER(F)\
F(VoidStar, 31, void*) \
@ -414,7 +415,7 @@ public:
QT_FOR_EACH_STATIC_TYPE(QT_DEFINE_METATYPE_ID)
FirstCoreType = Bool,
LastCoreType = QPersistentModelIndex,
LastCoreType = Nullptr,
FirstGuiType = QFont,
LastGuiType = QPolygonF,
FirstWidgetsType = QSizePolicy,

View File

@ -669,6 +669,9 @@ template<> struct TestValueFactory<QMetaType::QModelIndex> {
template<> struct TestValueFactory<QMetaType::QPersistentModelIndex> {
static QPersistentModelIndex *create() { return new QPersistentModelIndex(); }
};
template<> struct TestValueFactory<QMetaType::Nullptr> {
static std::nullptr_t *create() { return new std::nullptr_t; }
};
template<> struct TestValueFactory<QMetaType::QRegExp> {
static QRegExp *create()
{
@ -1798,6 +1801,7 @@ DECLARE_NONSTREAMABLE(QJsonArray)
DECLARE_NONSTREAMABLE(QJsonDocument)
DECLARE_NONSTREAMABLE(QObject*)
DECLARE_NONSTREAMABLE(QWidget*)
DECLARE_NONSTREAMABLE(std::nullptr_t)
#define DECLARE_GUI_CLASS_NONSTREAMABLE(MetaTypeName, MetaTypeId, RealType) \
DECLARE_NONSTREAMABLE(RealType)