| 1 | // Copyright (C) 2019 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 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 | |
| 26 | QT_BEGIN_NAMESPACE |
| 27 | |
| 28 | namespace QQmlJS { |
| 29 | namespace Dom { |
| 30 | |
| 31 | class QmltypesReader |
| 32 | { |
| 33 | Q_DECLARE_TR_FUNCTIONS(TypeDescriptionReader) |
| 34 | public: |
| 35 | explicit QmltypesReader(const DomItem &qmltypesFile) |
| 36 | : m_qmltypesFilePtr(qmltypesFile.ownerAs<QmltypesFile>()), m_qmltypesFile(qmltypesFile) |
| 37 | { |
| 38 | } |
| 39 | |
| 40 | bool parse(); |
| 41 | // static void read |
| 42 | private: |
| 43 | void addError(ErrorMessage &&message); |
| 44 | |
| 45 | void insertProperty(const QQmlJSScope::ConstPtr &jsScope, const QQmlJSMetaProperty &property, |
| 46 | QMap<int, QmlObject> &objs); |
| 47 | void insertSignalOrMethod(const QQmlJSMetaMethod &metaMethod, QMap<int, QmlObject> &objs); |
| 48 | void insertComponent(const QQmlJSScope::ConstPtr &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](const ErrorMessage &m) { this->addError(message: ErrorMessage(m)); }; |
| 57 | } |
| 58 | |
| 59 | private: |
| 60 | std::shared_ptr<QmltypesFile> m_qmltypesFilePtr; |
| 61 | DomItem m_qmltypesFile; |
| 62 | Path m_currentPath; |
| 63 | }; |
| 64 | |
| 65 | } // end namespace Dom |
| 66 | } // end namespace QQmlJS |
| 67 | QT_END_NAMESPACE |
| 68 | #endif // QQMLDOMTYPESREADER_H |
| 69 |
