diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-08-15 13:09:55 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-08-15 16:53:19 +0200 |
commit | c7ec7cd2a1ae9bec31113fae1f1e549b2bf98e0b (patch) | |
tree | fc81fba4e7815ea061da277cf3bcf3102866932f /src/corelib/kernel/qobjectdefs.h | |
parent | 7947032e2d1d68b2c0f79874db7adcf560851f29 (diff) | |
parent | 6132260da394a9627947f0fe6a279c20863b6ad2 (diff) |
Merge branch 'wip/qt6' into wip/cmake
Change-Id: I50ac36b8803c296998149e98cc61e38687cdd14b
Diffstat (limited to 'src/corelib/kernel/qobjectdefs.h')
-rw-r--r-- | src/corelib/kernel/qobjectdefs.h | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index ef22b6e67f..dc2d832fe5 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Intel Corporation. +** Copyright (C) 2019 The Qt Company Ltd. +** Copyright (C) 2019 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -572,13 +572,42 @@ struct Q_CORE_EXPORT QMetaObject int static_metacall(Call, int, void **) const; static int metacall(QObject *, Call, int, void **); + template <const QMetaObject &MO> static constexpr const QMetaObject *staticMetaObject() + { + return &MO; + } + + struct SuperData { + const QMetaObject *direct; + SuperData() = default; + constexpr SuperData(std::nullptr_t) : direct(nullptr) {} + constexpr SuperData(const QMetaObject *mo) : direct(mo) {} + + constexpr const QMetaObject *operator->() const { return operator const QMetaObject *(); } + +#ifdef QT_NO_DATA_RELOCATION + using Getter = const QMetaObject *(*)(); + Getter indirect = nullptr; + constexpr SuperData(Getter g) : direct(nullptr), indirect(g) {} + constexpr operator const QMetaObject *() const + { return indirect ? indirect() : direct; } + template <const QMetaObject &MO> static constexpr SuperData link() + { return SuperData(QMetaObject::staticMetaObject<MO>); } +#else + constexpr operator const QMetaObject *() const + { return direct; } + template <const QMetaObject &MO> static constexpr SuperData link() + { return SuperData(QMetaObject::staticMetaObject<MO>()); } +#endif + }; + struct { // private data - const QMetaObject *superdata; + SuperData superdata; const QByteArrayData *stringdata; const uint *data; typedef void (*StaticMetacallFunction)(QObject *, QMetaObject::Call, int, void **); StaticMetacallFunction static_metacall; - const QMetaObject * const *relatedMetaObjects; + const SuperData *relatedMetaObjects; void *extradata; //reserved for future use } d; |