Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqmljstypedescriptionreader_p.h
Go to the documentation of this file.
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// Qt-Security score:significant
4
5#ifndef QQMLJSTYPEDESCRIPTIONREADER_P_H
6#define QQMLJSTYPEDESCRIPTIONREADER_P_H
7
8#include <qtqmlcompilerexports.h>
9
10//
11// W A R N I N G
12// -------------
13//
14// This file is not part of the Qt API. It exists purely as an
15// implementation detail. This header file may change from version to
16// version without notice, or even be removed.
17//
18// We mean it.
19
20#include "qqmljsscope_p.h"
21
22#include <QtQml/private/qqmljsastfwd_p.h>
23
24// for Q_DECLARE_TR_FUNCTIONS
25#include <QtCore/qcoreapplication.h>
26
28
29class Q_QMLCOMPILER_EXPORT QQmlJSTypeDescriptionReader
30{
31 Q_DECLARE_TR_FUNCTIONS(QQmlJSTypeDescriptionReader)
32public:
33 explicit QQmlJSTypeDescriptionReader(QString fileName, QString data)
34 : m_fileName(std::move(fileName)), m_source(std::move(data)) {}
35
36 Q_DISABLE_COPY_MOVE(QQmlJSTypeDescriptionReader)
37
38 bool operator()(QList<QQmlJSExportedScope> *objects, QStringList *dependencies);
39
40 QString errorMessage() const { return m_errorMessage; }
41 QString warningMessage() const { return m_warningMessage; }
42
43private:
44 void readDocument(QQmlJS::AST::UiProgram *ast);
45 void readModule(QQmlJS::AST::UiObjectDefinition *ast);
46 void readDependencies(QQmlJS::AST::UiScriptBinding *ast);
47 void readComponent(QQmlJS::AST::UiObjectDefinition *ast);
48 void readSignalOrMethod(QQmlJS::AST::UiObjectDefinition *ast, bool isMethod,
49 const QQmlJSScope::Ptr &scope);
50 void readProperty(QQmlJS::AST::UiObjectDefinition *ast, const QQmlJSScope::Ptr &scope);
51 void readEnum(QQmlJS::AST::UiObjectDefinition *ast, const QQmlJSScope::Ptr &scope);
52 void readParameter(QQmlJS::AST::UiObjectDefinition *ast, QQmlJSMetaMethod *metaMethod);
53
54 QString readStringBinding(QQmlJS::AST::UiScriptBinding *ast);
55 bool readBoolBinding(QQmlJS::AST::UiScriptBinding *ast);
56 double readNumericBinding(QQmlJS::AST::UiScriptBinding *ast);
57 QTypeRevision readNumericVersionBinding(QQmlJS::AST::UiScriptBinding *ast);
58 int readIntBinding(QQmlJS::AST::UiScriptBinding *ast);
59 QList<QQmlJSScope::Export> readExports(QQmlJS::AST::UiScriptBinding *ast);
60 void readAliases(QQmlJS::AST::UiScriptBinding *ast, const QQmlJSScope::Ptr &scope);
61 void readInterfaces(QQmlJS::AST::UiScriptBinding *ast, const QQmlJSScope::Ptr &scope);
62 void checkMetaObjectRevisions(
63 QQmlJS::AST::UiScriptBinding *ast, QList<QQmlJSScope::Export> *exports);
64
65 QStringList readStringList(QQmlJS::AST::UiScriptBinding *ast);
66 void readDeferredNames(QQmlJS::AST::UiScriptBinding *ast, const QQmlJSScope::Ptr &scope);
67 void readImmediateNames(QQmlJS::AST::UiScriptBinding *ast, const QQmlJSScope::Ptr &scope);
68 void readEnumValues(QQmlJS::AST::UiScriptBinding *ast, QQmlJSMetaEnum *metaEnum);
69
70 void addError(const QQmlJS::SourceLocation &loc, const QString &message);
71 void addWarning(const QQmlJS::SourceLocation &loc, const QString &message);
72
73 QQmlJS::AST::ArrayPattern *getArray(QQmlJS::AST::UiScriptBinding *ast);
74
75 QString m_fileName;
76 QString m_source;
77 QString m_errorMessage;
78 QString m_warningMessage;
79 QList<QQmlJSExportedScope> *m_objects = nullptr;
80 QStringList *m_dependencies = nullptr;
81 int m_currentCtorIndex = 0;
82 int m_currentMethodIndex = 0;
83};
84
85QT_END_NAMESPACE
86
87#endif // QQMLJSTYPEDESCRIPTIONREADER_P_H
friend bool operator==(const Import &a, const Import &b)
QString prefix() const
bool isValid() const
QTypeRevision version() const
QString name() const
bool isDependency() const
Import()=default
bool isFile() const
friend size_t qHash(const Import &key, size_t seed=0) noexcept
Import(QString prefix, QString name, QTypeRevision version, bool isFile, bool isDependency)
static QStringList aliases(const QQmlJSScope::ConstPtr &scope)
static const QLatin1String JsrootDotQmltypes
static bool isVersionAllowed(const QQmlJSScope::Export &exportEntry, const QQmlJS::Import &importDescription)
static bool isComposite(const QQmlJSScope::ConstPtr &scope)
static QString resolvePreferredPath(const QString &qmldirPath, const QString &prefer, QQmlJSResourceFileMapper *mapper)
static const QString prefixedName(const QString &prefix, const QString &name)
static const QLatin1String SlashQmldir
static QString internalName(const QQmlJSScope::ConstPtr &scope)
static bool fileSelectedScopesAreCompatibleHeuristic(const QQmlJSScope::ConstPtr &scope1, const QQmlJSScope::ConstPtr &scope2)
static const QLatin1String PluginsDotQmltypes
QQmlJSImporterFlag
@ UseOptionalImports
@ PreferQmlFilesFromSourceFolder
@ TolerateFileSelectors
QString name(const QQmlJSScope::ConstPtr &type) const
void addTypes(ContextualTypes &&types)
void addTypes(const ContextualTypes &types)
ContextualTypes(CompileContext context, const QHash< QString, ImportedScope< QQmlJSScope::ConstPtr > > &types, const QMultiHash< QQmlJSScope::ConstPtr, QString > &names, const QQmlJSScope::ConstPtr &arrayType)
CompileContext context() const
bool isNullType(const QString &name) const
ImportedScope< QQmlJSScope::ConstPtr > type(const QString &name) const
bool hasType(const QString &name) const
QQmlJSScope::ConstPtr arrayType() const
void setType(const QString &name, const ImportedScope< QQmlJSScope::ConstPtr > &type)
void clearType(const QString &name)