diff options
Diffstat (limited to 'src/qml/qml/qqmltype_p.h')
-rw-r--r-- | src/qml/qml/qqmltype_p.h | 126 |
1 files changed, 62 insertions, 64 deletions
diff --git a/src/qml/qml/qqmltype_p.h b/src/qml/qml/qqmltype_p.h index ec27b38a73..622e91a4b2 100644 --- a/src/qml/qml/qqmltype_p.h +++ b/src/qml/qml/qqmltype_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QQMLTYPE_P_H #define QQMLTYPE_P_H @@ -60,6 +24,7 @@ #include <QtQml/qjsvalue.h> #include <QtCore/qobject.h> +#include <QtCore/qversionnumber.h> QT_BEGIN_NAMESPACE @@ -75,7 +40,7 @@ namespace QV4 { struct String; } -class Q_QML_PRIVATE_EXPORT QQmlType +class Q_QML_EXPORT QQmlType { public: QQmlType(); @@ -86,10 +51,6 @@ public: explicit QQmlType(const QQmlTypePrivate *priv); ~QQmlType(); - bool operator ==(const QQmlType &other) const { - return d.data() == other.d.data(); - } - bool isValid() const { return !d.isNull(); } QByteArray typeName() const; @@ -97,22 +58,30 @@ public: QString elementName() const; QHashedString module() const; - int majorVersion() const; - int minorVersion() const; + QTypeRevision version() const; + + bool availableInVersion(QTypeRevision version) const; + bool availableInVersion(const QHashedStringRef &module, QTypeRevision version) const; - bool availableInVersion(int vmajor, int vminor) const; - bool availableInVersion(const QHashedStringRef &module, int vmajor, int vminor) const; + typedef QVariant (*CreateValueTypeFunc)(const QJSValue &); + CreateValueTypeFunc createValueTypeFunction() const; + + bool canConstructValueType() const; + bool canPopulateValueType() const; QObject *create() const; - void create(QObject **, void **, size_t) const; + QObject *create(void **, size_t) const; + QObject *createWithQQmlData() const; - typedef void (*CreateFunc)(void *); + typedef void (*CreateFunc)(void *, void *); CreateFunc createFunction() const; + QQmlCustomParser *customParser() const; bool isCreatable() const; typedef QObject *(*ExtensionFunc)(QObject *); ExtensionFunc extensionFunction() const; + const QMetaObject *extensionMetaObject() const; bool isExtendedType() const; QString noCreationReason() const; @@ -122,37 +91,53 @@ public: bool isCompositeSingleton() const; bool isQObjectSingleton() const; bool isQJSValueSingleton() const; + bool isSequentialContainer() const; + bool isValueType() const; - int typeId() const; - int qListTypeId() const; + QMetaType typeId() const; + QMetaType qListTypeId() const; + QMetaSequence listMetaSequence() const; const QMetaObject *metaObject() const; + + // Precondition: The type is actually a value type! + const QMetaObject *metaObjectForValueType() const; + const QMetaObject *baseMetaObject() const; - int metaObjectRevision() const; + QTypeRevision metaObjectRevision() const; bool containsRevisionedAttributes() const; QQmlAttachedPropertiesFunc attachedPropertiesFunction(QQmlEnginePrivate *engine) const; const QMetaObject *attachedPropertiesType(QQmlEnginePrivate *engine) const; -#if QT_DEPRECATED_SINCE(5, 14) - QT_DEPRECATED int attachedPropertiesId(QQmlEnginePrivate *engine) const; -#endif int parserStatusCast() const; const char *interfaceIId() const; int propertyValueSourceCast() const; int propertyValueInterceptorCast() const; + int finalizerCast() const; int index() const; - struct Q_QML_PRIVATE_EXPORT SingletonInstanceInfo + bool isInlineComponentType() const; + + struct Q_QML_EXPORT SingletonInstanceInfo final + : public QQmlRefCounted<SingletonInstanceInfo> { - QJSValue (*scriptCallback)(QQmlEngine *, QJSEngine *) = nullptr; + using Ptr = QQmlRefPointer<SingletonInstanceInfo>; + using ConstPtr = QQmlRefPointer<const SingletonInstanceInfo>; + + static Ptr create() { return Ptr(new SingletonInstanceInfo, Ptr::Adopt); } + + std::function<QJSValue(QQmlEngine *, QJSEngine *)> scriptCallback = {}; std::function<QObject *(QQmlEngine *, QJSEngine *)> qobjectCallback = {}; - const QMetaObject *instanceMetaObject = nullptr; - QString typeName; + QByteArray typeName; QUrl url; // used by composite singletons + + private: + Q_DISABLE_COPY_MOVE(SingletonInstanceInfo) + SingletonInstanceInfo() = default; }; - SingletonInstanceInfo *singletonInstanceInfo() const; + SingletonInstanceInfo::ConstPtr singletonInstanceInfo() const; QUrl sourceUrl() const; @@ -164,8 +149,7 @@ public: int scopedEnumIndex(QQmlEnginePrivate *engine, const QString &, bool *ok) const; int scopedEnumValue(QQmlEnginePrivate *engine, int index, const QV4::String *, bool *ok) const; int scopedEnumValue(QQmlEnginePrivate *engine, int index, const QString &, bool *ok) const; - int scopedEnumValue(QQmlEnginePrivate *engine, const QByteArray &, const QByteArray &, bool *ok) const; - int scopedEnumValue(QQmlEnginePrivate *engine, const QStringRef &, const QStringRef &, bool *ok) const; + int scopedEnumValue(QQmlEnginePrivate *engine, const QHashedStringRef &, const QHashedStringRef &, bool *ok) const; const QQmlTypePrivate *priv() const { return d.data(); } static void refHandle(const QQmlTypePrivate *priv); @@ -178,15 +162,29 @@ public: InterfaceType = 2, CompositeType = 3, CompositeSingletonType = 4, + InlineComponentType = 5, + SequentialContainerType = 6, AnyRegistrationType = 255 }; + void createProxy(QObject *instance) const; + private: - friend uint qHash(const QQmlType &t, uint seed); + friend class QQmlTypePrivate; + friend size_t qHash(const QQmlType &t, size_t seed); + friend bool operator==(const QQmlType &a, const QQmlType &b) noexcept + { + return a.d.data() == b.d.data(); + } + friend bool operator!=(const QQmlType &a, const QQmlType &b) noexcept + { + return !(a == b); + } + QQmlRefPointer<const QQmlTypePrivate> d; }; -inline uint qHash(const QQmlType &t, uint seed = 0) +inline size_t qHash(const QQmlType &t, size_t seed = 0) { return qHash(reinterpret_cast<quintptr>(t.d.data()), seed); } |