Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/qml/qqmltypenamecache_p.h |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||
2 | ** | - | ||||||
3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||
4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||
5 | ** | - | ||||||
6 | ** This file is part of the QtQml module of the Qt Toolkit. | - | ||||||
7 | ** | - | ||||||
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||
9 | ** Commercial License Usage | - | ||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||
14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||
15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||
16 | ** | - | ||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||
19 | ** General Public License version 3 as published by the Free Software | - | ||||||
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||
21 | ** packaging of this file. Please review the following information to | - | ||||||
22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||
24 | ** | - | ||||||
25 | ** GNU General Public License Usage | - | ||||||
26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||
27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||
28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||
29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||
31 | ** included in the packaging of this file. Please review the following | - | ||||||
32 | ** information to ensure the GNU General Public License requirements will | - | ||||||
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||
35 | ** | - | ||||||
36 | ** $QT_END_LICENSE$ | - | ||||||
37 | ** | - | ||||||
38 | ****************************************************************************/ | - | ||||||
39 | - | |||||||
40 | #ifndef QQMLTYPENAMECACHE_P_H | - | ||||||
41 | #define QQMLTYPENAMECACHE_P_H | - | ||||||
42 | - | |||||||
43 | // | - | ||||||
44 | // W A R N I N G | - | ||||||
45 | // ------------- | - | ||||||
46 | // | - | ||||||
47 | // This file is not part of the Qt API. It exists purely as an | - | ||||||
48 | // implementation detail. This header file may change from version to | - | ||||||
49 | // version without notice, or even be removed. | - | ||||||
50 | // | - | ||||||
51 | // We mean it. | - | ||||||
52 | // | - | ||||||
53 | - | |||||||
54 | #include <private/qqmlrefcount_p.h> | - | ||||||
55 | #include "qqmlcleanup_p.h" | - | ||||||
56 | #include "qqmlmetatype_p.h" | - | ||||||
57 | - | |||||||
58 | #include <private/qhashedstring_p.h> | - | ||||||
59 | #include <private/qqmlimport_p.h> | - | ||||||
60 | - | |||||||
61 | #include <QtCore/qvector.h> | - | ||||||
62 | - | |||||||
63 | QT_BEGIN_NAMESPACE | - | ||||||
64 | - | |||||||
65 | struct QQmlImportRef { | - | ||||||
66 | inline QQmlImportRef() | - | ||||||
67 | : scriptIndex(-1) | - | ||||||
68 | {} executed 1486 times by 44 tests: end of block Executed by:
| 1486 | ||||||
69 | // Imported module | - | ||||||
70 | QVector<QQmlTypeModuleVersion> modules; | - | ||||||
71 | - | |||||||
72 | // Or, imported script | - | ||||||
73 | int scriptIndex; | - | ||||||
74 | - | |||||||
75 | // Or, imported compositeSingletons | - | ||||||
76 | QStringHash<QUrl> compositeSingletons; | - | ||||||
77 | - | |||||||
78 | // The qualifier of this import | - | ||||||
79 | QString m_qualifier; | - | ||||||
80 | }; | - | ||||||
81 | - | |||||||
82 | class QQmlType; | - | ||||||
83 | class QQmlEngine; | - | ||||||
84 | class Q_QML_PRIVATE_EXPORT QQmlTypeNameCache : public QQmlRefCount | - | ||||||
85 | { | - | ||||||
86 | public: | - | ||||||
87 | QQmlTypeNameCache(const QQmlImports &imports); | - | ||||||
88 | ~QQmlTypeNameCache() override; | - | ||||||
89 | - | |||||||
90 | inline bool isEmpty() const; | - | ||||||
91 | - | |||||||
92 | void add(const QHashedString &name, int sciptIndex = -1, const QHashedString &nameSpace = QHashedString()); | - | ||||||
93 | void add(const QHashedString &name, const QUrl &url, const QHashedString &nameSpace = QHashedString()); | - | ||||||
94 | - | |||||||
95 | struct Result { | - | ||||||
96 | inline Result(); | - | ||||||
97 | inline Result(const QQmlImportRef *importNamespace); | - | ||||||
98 | inline Result(const QQmlType &type); | - | ||||||
99 | inline Result(int scriptIndex); | - | ||||||
100 | inline Result(const Result &); | - | ||||||
101 | - | |||||||
102 | inline bool isValid() const; | - | ||||||
103 | - | |||||||
104 | QQmlType type; | - | ||||||
105 | const QQmlImportRef *importNamespace; | - | ||||||
106 | int scriptIndex; | - | ||||||
107 | }; | - | ||||||
108 | Result query(const QHashedStringRef &) const; | - | ||||||
109 | Result query(const QHashedStringRef &, const QQmlImportRef *importNamespace) const; | - | ||||||
110 | Result query(const QV4::String *, QQmlImport::RecursionRestriction recursionRestriction = QQmlImport::PreventRecursion) const; | - | ||||||
111 | Result query(const QV4::String *, const QQmlImportRef *importNamespace) const; | - | ||||||
112 | - | |||||||
113 | private: | - | ||||||
114 | friend class QQmlImports; | - | ||||||
115 | - | |||||||
116 | template<typename Key> | - | ||||||
117 | Result query(const QStringHash<QQmlImportRef> &imports, Key key) const | - | ||||||
118 | { | - | ||||||
119 | QQmlImportRef *i = imports.value(key); | - | ||||||
120 | if (i) {
| 850-441536 | ||||||
121 | Q_ASSERT(!i->m_qualifier.isEmpty()); | - | ||||||
122 | if (i->scriptIndex != -1) {
| 420-430 | ||||||
123 | return Result(i->scriptIndex); executed 430 times by 13 tests: return Result(i->scriptIndex); Executed by:
| 430 | ||||||
124 | } else { | - | ||||||
125 | return Result(i); executed 420 times by 6 tests: return Result(i); Executed by:
| 420 | ||||||
126 | } | - | ||||||
127 | } | - | ||||||
128 | - | |||||||
129 | return Result(); executed 441536 times by 87 tests: return Result(); Executed by:
| 441536 | ||||||
130 | } | - | ||||||
131 | - | |||||||
132 | template<typename Key> | - | ||||||
133 | Result query(const QStringHash<QUrl> &urls, Key key) const | - | ||||||
134 | { | - | ||||||
135 | QUrl *url = urls.value(key); | - | ||||||
136 | if (url) {
| 160-289979 | ||||||
137 | QQmlType type = QQmlMetaType::qmlType(*url); | - | ||||||
138 | return Result(type); executed 160 times by 2 tests: return Result(type); Executed by:
| 160 | ||||||
139 | } | - | ||||||
140 | - | |||||||
141 | return Result(); executed 289979 times by 64 tests: return Result(); Executed by:
| 289979 | ||||||
142 | } | - | ||||||
143 | - | |||||||
144 | template<typename Key> | - | ||||||
145 | Result typeSearch(const QVector<QQmlTypeModuleVersion> &modules, Key key) const | - | ||||||
146 | { | - | ||||||
147 | QVector<QQmlTypeModuleVersion>::const_iterator end = modules.constEnd(); | - | ||||||
148 | for (QVector<QQmlTypeModuleVersion>::const_iterator it = modules.constBegin(); it != end; ++it) {
| 290139-469346 | ||||||
149 | QQmlType type = it->type(key); | - | ||||||
150 | if (type.isValid())
| 151719-317627 | ||||||
151 | return Result(type); executed 151719 times by 63 tests: return Result(type); Executed by:
| 151719 | ||||||
152 | } executed 317627 times by 71 tests: end of block Executed by:
| 317627 | ||||||
153 | - | |||||||
154 | return Result(); executed 290139 times by 64 tests: return Result(); Executed by:
| 290139 | ||||||
155 | } | - | ||||||
156 | - | |||||||
157 | QStringHash<QQmlImportRef> m_namedImports; | - | ||||||
158 | QMap<const QQmlImportRef *, QStringHash<QQmlImportRef> > m_namespacedImports; | - | ||||||
159 | QVector<QQmlTypeModuleVersion> m_anonymousImports; | - | ||||||
160 | QStringHash<QUrl> m_anonymousCompositeSingletons; | - | ||||||
161 | QQmlImports m_imports; | - | ||||||
162 | }; | - | ||||||
163 | - | |||||||
164 | QQmlTypeNameCache::Result::Result() | - | ||||||
165 | : importNamespace(nullptr), scriptIndex(-1) | - | ||||||
166 | { | - | ||||||
167 | } executed 1021654 times by 87 tests: end of block Executed by:
| 1021654 | ||||||
168 | - | |||||||
169 | QQmlTypeNameCache::Result::Result(const QQmlImportRef *importNamespace) | - | ||||||
170 | : importNamespace(importNamespace), scriptIndex(-1) | - | ||||||
171 | { | - | ||||||
172 | } executed 420 times by 6 tests: end of block Executed by:
| 420 | ||||||
173 | - | |||||||
174 | QQmlTypeNameCache::Result::Result(const QQmlType &type) | - | ||||||
175 | : type(type), importNamespace(nullptr), scriptIndex(-1) | - | ||||||
176 | { | - | ||||||
177 | } executed 152311 times by 64 tests: end of block Executed by:
| 152311 | ||||||
178 | - | |||||||
179 | QQmlTypeNameCache::Result::Result(int scriptIndex) | - | ||||||
180 | : importNamespace(nullptr), scriptIndex(scriptIndex) | - | ||||||
181 | { | - | ||||||
182 | } executed 430 times by 13 tests: end of block Executed by:
| 430 | ||||||
183 | - | |||||||
184 | QQmlTypeNameCache::Result::Result(const Result &o) | - | ||||||
185 | : type(o.type), importNamespace(o.importNamespace), scriptIndex(o.scriptIndex) | - | ||||||
186 | { | - | ||||||
187 | } executed 442276 times by 88 tests: end of block Executed by:
| 442276 | ||||||
188 | - | |||||||
189 | bool QQmlTypeNameCache::Result::isValid() const | - | ||||||
190 | { | - | ||||||
191 | return type.isValid() || importNamespace || scriptIndex != -1; executed 1699399 times by 88 tests: return type.isValid() || importNamespace || scriptIndex != -1; Executed by:
| 1699399 | ||||||
192 | } | - | ||||||
193 | - | |||||||
194 | bool QQmlTypeNameCache::isEmpty() const | - | ||||||
195 | { | - | ||||||
196 | return m_namedImports.isEmpty() && m_anonymousImports.isEmpty() executed 282 times by 13 tests: return m_namedImports.isEmpty() && m_anonymousImports.isEmpty() && m_anonymousCompositeSingletons.isEmpty(); Executed by:
| 282 | ||||||
197 | && m_anonymousCompositeSingletons.isEmpty(); executed 282 times by 13 tests: return m_namedImports.isEmpty() && m_anonymousImports.isEmpty() && m_anonymousCompositeSingletons.isEmpty(); Executed by:
| 282 | ||||||
198 | } | - | ||||||
199 | - | |||||||
200 | QT_END_NAMESPACE | - | ||||||
201 | - | |||||||
202 | #endif // QQMLTYPENAMECACHE_P_H | - | ||||||
203 | - | |||||||
Source code | Switch to Preprocessed file |