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 QQMLDOMTYPESREADER_H
5#define QQMLDOMTYPESREADER_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16
17#include "qqmldomexternalitems_p.h"
18
19#include <QtQml/private/qqmljsastfwd_p.h>
20
21// for Q_DECLARE_TR_FUNCTIONS
22#include <QtCore/qcoreapplication.h>
23#include <private/qqmljsmetatypes_p.h>
24#include <private/qqmljsscope_p.h>
25
26QT_BEGIN_NAMESPACE
27
28namespace QQmlJS {
29namespace Dom {
30
31class QmltypesReader
32{
33 Q_DECLARE_TR_FUNCTIONS(TypeDescriptionReader)
34public:
35 explicit QmltypesReader(DomItem qmltypesFile)
36 : m_qmltypesFilePtr(qmltypesFile.ownerAs<QmltypesFile>()), m_qmltypesFile(qmltypesFile)
37 {
38 }
39
40 bool parse();
41 // static void read
42private:
43 void addError(ErrorMessage message);
44
45 void insertProperty(QQmlJSScope::Ptr jsScope, const QQmlJSMetaProperty &property,
46 QMap<int, QmlObject> &objs);
47 void insertSignalOrMethod(const QQmlJSMetaMethod &metaMethod, QMap<int, QmlObject> &objs);
48 void insertComponent(const QQmlJSScope::Ptr &jsScope,
49 const QList<QQmlJSScope::Export> &exportsList);
50 EnumDecl enumFromMetaEnum(const QQmlJSMetaEnum &metaEnum);
51
52 std::shared_ptr<QmltypesFile> qmltypesFilePtr() { return m_qmltypesFilePtr; }
53 DomItem &qmltypesFile() { return m_qmltypesFile; }
54 ErrorHandler handler()
55 {
56 return [this](ErrorMessage m) { this->addError(message: m); };
57 }
58
59private:
60 bool m_isValid;
61 std::shared_ptr<QmltypesFile> m_qmltypesFilePtr;
62 DomItem m_qmltypesFile;
63 Path m_currentPath;
64};
65
66} // end namespace Dom
67} // end namespace QQmlJS
68QT_END_NAMESPACE
69#endif // QQMLDOMTYPESREADER_H
70

source code of qtdeclarative/src/qmldom/qqmldomtypesreader_p.h