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 <private/qtqmlcompilerexports_p.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
26QT_BEGIN_NAMESPACE
27
28class Q_QMLCOMPILER_PRIVATE_EXPORT QQmlJSTypeDescriptionReader
29{
30 Q_DECLARE_TR_FUNCTIONS(QQmlJSTypeDescriptionReader)
31public:
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
41private:
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 readInterfaces(QQmlJS::AST::UiScriptBinding *ast, const QQmlJSScope::Ptr &scope);
59 void checkMetaObjectRevisions(
60 QQmlJS::AST::UiScriptBinding *ast, QList<QQmlJSScope::Export> *exports);
61
62 QStringList readStringList(QQmlJS::AST::UiScriptBinding *ast);
63 void readDeferredNames(QQmlJS::AST::UiScriptBinding *ast, const QQmlJSScope::Ptr &scope);
64 void readImmediateNames(QQmlJS::AST::UiScriptBinding *ast, const QQmlJSScope::Ptr &scope);
65 void readEnumValues(QQmlJS::AST::UiScriptBinding *ast, QQmlJSMetaEnum *metaEnum);
66
67 void addError(const QQmlJS::SourceLocation &loc, const QString &message);
68 void addWarning(const QQmlJS::SourceLocation &loc, const QString &message);
69
70 QQmlJS::AST::ArrayPattern *getArray(QQmlJS::AST::UiScriptBinding *ast);
71
72 QString m_fileName;
73 QString m_source;
74 QString m_errorMessage;
75 QString m_warningMessage;
76 QList<QQmlJSExportedScope> *m_objects = nullptr;
77 QStringList *m_dependencies = nullptr;
78 int m_currentCtorIndex = 0;
79};
80
81QT_END_NAMESPACE
82
83#endif // QQMLJSTYPEDESCRIPTIONREADER_P_H
84

source code of qtdeclarative/src/qmlcompiler/qqmljstypedescriptionreader_p.h