| 1 | // Copyright (C) 2019 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 |
| 3 | |
| 4 | #ifndef QQMLJSTYPEDESCRIPTIONREADER_P_H |
| 5 | #define QQMLJSTYPEDESCRIPTIONREADER_P_H |
| 6 | |
| 7 | #include <qtqmlcompilerexports.h> |
| 8 | |
| 9 | // |
| 10 | // W A R N I N G |
| 11 | // ------------- |
| 12 | // |
| 13 | // This file is not part of the Qt API. It exists purely as an |
| 14 | // implementation detail. This header file may change from version to |
| 15 | // version without notice, or even be removed. |
| 16 | // |
| 17 | // We mean it. |
| 18 | |
| 19 | #include "qqmljsscope_p.h" |
| 20 | |
| 21 | #include <QtQml/private/qqmljsastfwd_p.h> |
| 22 | |
| 23 | // for Q_DECLARE_TR_FUNCTIONS |
| 24 | #include <QtCore/qcoreapplication.h> |
| 25 | |
| 26 | QT_BEGIN_NAMESPACE |
| 27 | |
| 28 | class Q_QMLCOMPILER_EXPORT QQmlJSTypeDescriptionReader |
| 29 | { |
| 30 | Q_DECLARE_TR_FUNCTIONS(QQmlJSTypeDescriptionReader) |
| 31 | public: |
| 32 | QQmlJSTypeDescriptionReader() = default; |
| 33 | explicit QQmlJSTypeDescriptionReader(QString fileName, QString data) |
| 34 | : m_fileName(std::move(fileName)), m_source(std::move(data)) {} |
| 35 | |
| 36 | bool operator()(QList<QQmlJSExportedScope> *objects, QStringList *dependencies); |
| 37 | |
| 38 | QString errorMessage() const { return m_errorMessage; } |
| 39 | QString warningMessage() const { return m_warningMessage; } |
| 40 | |
| 41 | private: |
| 42 | void readDocument(QQmlJS::AST::UiProgram *ast); |
| 43 | void readModule(QQmlJS::AST::UiObjectDefinition *ast); |
| 44 | void readDependencies(QQmlJS::AST::UiScriptBinding *ast); |
| 45 | void readComponent(QQmlJS::AST::UiObjectDefinition *ast); |
| 46 | void readSignalOrMethod(QQmlJS::AST::UiObjectDefinition *ast, bool isMethod, |
| 47 | const QQmlJSScope::Ptr &scope); |
| 48 | void readProperty(QQmlJS::AST::UiObjectDefinition *ast, const QQmlJSScope::Ptr &scope); |
| 49 | void readEnum(QQmlJS::AST::UiObjectDefinition *ast, const QQmlJSScope::Ptr &scope); |
| 50 | void readParameter(QQmlJS::AST::UiObjectDefinition *ast, QQmlJSMetaMethod *metaMethod); |
| 51 | |
| 52 | QString readStringBinding(QQmlJS::AST::UiScriptBinding *ast); |
| 53 | bool readBoolBinding(QQmlJS::AST::UiScriptBinding *ast); |
| 54 | double readNumericBinding(QQmlJS::AST::UiScriptBinding *ast); |
| 55 | QTypeRevision readNumericVersionBinding(QQmlJS::AST::UiScriptBinding *ast); |
| 56 | int readIntBinding(QQmlJS::AST::UiScriptBinding *ast); |
| 57 | QList<QQmlJSScope::Export> readExports(QQmlJS::AST::UiScriptBinding *ast); |
| 58 | void readAliases(QQmlJS::AST::UiScriptBinding *ast, const QQmlJSScope::Ptr &scope); |
| 59 | void readInterfaces(QQmlJS::AST::UiScriptBinding *ast, const QQmlJSScope::Ptr &scope); |
| 60 | void checkMetaObjectRevisions( |
| 61 | QQmlJS::AST::UiScriptBinding *ast, QList<QQmlJSScope::Export> *exports); |
| 62 | |
| 63 | QStringList readStringList(QQmlJS::AST::UiScriptBinding *ast); |
| 64 | void readDeferredNames(QQmlJS::AST::UiScriptBinding *ast, const QQmlJSScope::Ptr &scope); |
| 65 | void readImmediateNames(QQmlJS::AST::UiScriptBinding *ast, const QQmlJSScope::Ptr &scope); |
| 66 | void readEnumValues(QQmlJS::AST::UiScriptBinding *ast, QQmlJSMetaEnum *metaEnum); |
| 67 | |
| 68 | void addError(const QQmlJS::SourceLocation &loc, const QString &message); |
| 69 | void addWarning(const QQmlJS::SourceLocation &loc, const QString &message); |
| 70 | |
| 71 | QQmlJS::AST::ArrayPattern *getArray(QQmlJS::AST::UiScriptBinding *ast); |
| 72 | |
| 73 | QString m_fileName; |
| 74 | QString m_source; |
| 75 | QString m_errorMessage; |
| 76 | QString m_warningMessage; |
| 77 | QList<QQmlJSExportedScope> *m_objects = nullptr; |
| 78 | QStringList *m_dependencies = nullptr; |
| 79 | int m_currentCtorIndex = 0; |
| 80 | }; |
| 81 | |
| 82 | QT_END_NAMESPACE |
| 83 | |
| 84 | #endif // QQMLJSTYPEDESCRIPTIONREADER_P_H |
| 85 | |