diff options
Diffstat (limited to 'src/qmltyperegistrar/qqmltypesclassdescription_p.h')
-rw-r--r-- | src/qmltyperegistrar/qqmltypesclassdescription_p.h | 108 |
1 files changed, 81 insertions, 27 deletions
diff --git a/src/qmltyperegistrar/qqmltypesclassdescription_p.h b/src/qmltyperegistrar/qqmltypesclassdescription_p.h index cb08237a20..b48a0670da 100644 --- a/src/qmltyperegistrar/qqmltypesclassdescription_p.h +++ b/src/qmltyperegistrar/qqmltypesclassdescription_p.h @@ -15,38 +15,71 @@ // We mean it. // +#include <private/qmetatypesjsonprocessor_p.h> + #include <QtCore/qstring.h> -#include <QtCore/qjsonobject.h> +#include <QtCore/qcbormap.h> #include <QtCore/qvector.h> #include <QtCore/qset.h> #include <QtCore/qversionnumber.h> QT_BEGIN_NAMESPACE +struct FoundType +{ + enum Origin { + Unknown, + OwnTypes, + ForeignTypes, + }; + + FoundType() = default; + FoundType(const MetaType &single, Origin origin); + + MetaType native; + MetaType javaScript; + + Origin nativeOrigin = Unknown; + Origin javaScriptOrigin = Unknown; + + operator bool() const { return !native.isEmpty() || !javaScript.isEmpty(); } + + MetaType select(const MetaType &category, QAnyStringView relation) const; + +}; + struct QmlTypesClassDescription { - const QJsonObject *resolvedClass = nullptr; - QString file; - QString className; - QString elementName; - QString defaultProp; - QString parentProp; - QString superClass; - QString attachedType; - QString extensionType; - QString sequenceValueType; - QString accessSemantics; + // All the string views in this class are based on string data in the JSON they are parsed from. + // You must keep the relevant QCborValues alive while the QmlTypesClassDescription exists. + + MetaType resolvedClass; + QAnyStringView file; + QAnyStringView className; + QList<QAnyStringView> primitiveAliases; + QList<QAnyStringView> elementNames; + QAnyStringView defaultProp; + QAnyStringView parentProp; + QAnyStringView superClass; + QAnyStringView attachedType; + QAnyStringView javaScriptExtensionType; + QAnyStringView nativeExtensionType; + QAnyStringView sequenceValueType; + QAnyStringView accessSemantics; QList<QTypeRevision> revisions; QTypeRevision addedInRevision; QTypeRevision removedInRevision; bool isCreatable = true; + bool isStructured = false; bool isSingleton = false; bool hasCustomParser = false; - bool omitFromQmlTypes = false; + bool isRootClass = false; + bool extensionIsJavaScript = false; bool extensionIsNamespace = false; - QStringList implementsInterfaces; - QStringList deferredNames; - QStringList immediateNames; + bool registerEnumClassesScoped = false; + QList<QAnyStringView> implementsInterfaces; + QList<QAnyStringView> deferredNames; + QList<QAnyStringView> immediateNames; enum CollectMode { TopLevel, @@ -54,23 +87,44 @@ struct QmlTypesClassDescription RelatedType }; - void collect(const QJsonObject *classDef, const QVector<QJsonObject> &types, - const QVector<QJsonObject> &foreign, CollectMode mode, - QTypeRevision defaultRevision); - void collectRelated(const QString &related, const QVector<QJsonObject> &types, - const QVector<QJsonObject> &foreign, QTypeRevision defaultRevision); + void collect( + const MetaType &classDef, const QVector<MetaType> &types, + const QVector<MetaType> &foreign, CollectMode mode, QTypeRevision defaultRevision); + FoundType collectRelated( + QAnyStringView related, const QVector<MetaType> &types, + const QVector<MetaType> &foreign, QTypeRevision defaultRevision, + const QList<QAnyStringView> &namespaces); - static const QJsonObject *findType(const QVector<QJsonObject> &types, const QString &name); + static FoundType findType( + const QVector<MetaType> &types, const QVector<MetaType> &foreign, + const QAnyStringView &name, const QList<QAnyStringView> &namespaces); - void collectLocalAnonymous(const QJsonObject *classDef,const QVector<QJsonObject> &types, - const QVector<QJsonObject> &foreign, QTypeRevision defaultRevision); + void collectLocalAnonymous( + const MetaType &classDef, const QVector<MetaType> &types, + const QVector<MetaType> &foreign, QTypeRevision defaultRevision); private: void collectSuperClasses( - const QJsonObject *classDef, const QVector<QJsonObject> &types, - const QVector<QJsonObject> &foreign, CollectMode mode, QTypeRevision defaultRevision); - void collectInterfaces(const QJsonObject *classDef); + const MetaType &classDef, const QVector<MetaType> &types, + const QVector<MetaType> &foreign, CollectMode mode, QTypeRevision defaultRevision); + void collectInterfaces(const MetaType &classDef); +}; + +struct ResolvedTypeAlias +{ + ResolvedTypeAlias(QAnyStringView alias, const QList<UsingDeclaration> &usingDeclarations); + + QAnyStringView type; + bool isList = false; + bool isPointer = false; + bool isConstant = false; + +private: + void handleVoid(); + void handleList(); + void handlePointer(); + void handleConst(); }; QT_END_NAMESPACE |