Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/qml/qqmlobjectcreator_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 tools applications 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 | #ifndef QQMLOBJECTCREATOR_P_H | - | ||||||
40 | #define QQMLOBJECTCREATOR_P_H | - | ||||||
41 | - | |||||||
42 | // | - | ||||||
43 | // W A R N I N G | - | ||||||
44 | // ------------- | - | ||||||
45 | // | - | ||||||
46 | // This file is not part of the Qt API. It exists purely as an | - | ||||||
47 | // implementation detail. This header file may change from version to | - | ||||||
48 | // version without notice, or even be removed. | - | ||||||
49 | // | - | ||||||
50 | // We mean it. | - | ||||||
51 | // | - | ||||||
52 | - | |||||||
53 | #include <private/qqmlimport_p.h> | - | ||||||
54 | #include <private/qqmltypenamecache_p.h> | - | ||||||
55 | #include <private/qv4compileddata_p.h> | - | ||||||
56 | #include <private/qqmltypecompiler_p.h> | - | ||||||
57 | #include <private/qfinitestack_p.h> | - | ||||||
58 | #include <private/qrecursionwatcher_p.h> | - | ||||||
59 | #include <private/qqmlprofiler_p.h> | - | ||||||
60 | - | |||||||
61 | #include <qpointer.h> | - | ||||||
62 | - | |||||||
63 | QT_BEGIN_NAMESPACE | - | ||||||
64 | - | |||||||
65 | class QQmlAbstractBinding; | - | ||||||
66 | struct QQmlTypeCompiler; | - | ||||||
67 | class QQmlInstantiationInterrupt; | - | ||||||
68 | class QQmlIncubatorPrivate; | - | ||||||
69 | - | |||||||
70 | struct QQmlObjectCreatorSharedState : public QSharedData | - | ||||||
71 | { | - | ||||||
72 | QQmlContextData *rootContext; | - | ||||||
73 | QQmlContextData *creationContext; | - | ||||||
74 | QFiniteStack<QQmlAbstractBinding::Ptr> allCreatedBindings; | - | ||||||
75 | QFiniteStack<QQmlParserStatus*> allParserStatusCallbacks; | - | ||||||
76 | QFiniteStack<QPointer<QObject> > allCreatedObjects; | - | ||||||
77 | QV4::Value *allJavaScriptObjects; // pointer to vector on JS stack to reference JS wrappers during creation phase. | - | ||||||
78 | QQmlComponentAttached *componentAttached; | - | ||||||
79 | QList<QQmlEnginePrivate::FinalizeCallback> finalizeCallbacks; | - | ||||||
80 | QQmlVmeProfiler profiler; | - | ||||||
81 | QRecursionNode recursionNode; | - | ||||||
82 | }; | - | ||||||
83 | - | |||||||
84 | class Q_QML_PRIVATE_EXPORT QQmlObjectCreator | - | ||||||
85 | { | - | ||||||
86 | Q_DECLARE_TR_FUNCTIONS(QQmlObjectCreator) | - | ||||||
87 | public: | - | ||||||
88 | QQmlObjectCreator(QQmlContextData *parentContext, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, QQmlContextData *creationContext, QQmlIncubatorPrivate *incubator = nullptr); | - | ||||||
89 | ~QQmlObjectCreator(); | - | ||||||
90 | - | |||||||
91 | QObject *create(int subComponentIndex = -1, QObject *parent = nullptr, QQmlInstantiationInterrupt *interrupt = nullptr); | - | ||||||
92 | bool populateDeferredProperties(QObject *instance, QQmlData::DeferredData *deferredData); | - | ||||||
93 | bool populateDeferredBinding(const QQmlProperty &qmlProperty, QQmlData::DeferredData *deferredData, const QV4::CompiledData::Binding *binding); | - | ||||||
94 | QQmlContextData *finalize(QQmlInstantiationInterrupt &interrupt); | - | ||||||
95 | void clear(); | - | ||||||
96 | - | |||||||
97 | QQmlComponentAttached **componentAttachment() const { return &sharedState->componentAttached; } executed 4457 times by 59 tests: return &sharedState->componentAttached; Executed by:
| 4457 | ||||||
98 | - | |||||||
99 | QList<QQmlEnginePrivate::FinalizeCallback> *finalizeCallbacks() const { return &sharedState->finalizeCallbacks; } never executed: return &sharedState->finalizeCallbacks; | 0 | ||||||
100 | - | |||||||
101 | QList<QQmlError> errors; | - | ||||||
102 | - | |||||||
103 | QQmlContextData *parentContextData() const { return parentContext.contextData(); } executed 4577 times by 11 tests: return parentContext.contextData(); Executed by:
| 4577 | ||||||
104 | QFiniteStack<QPointer<QObject> > &allCreatedObjects() const { return sharedState->allCreatedObjects; } executed 4579 times by 11 tests: return sharedState->allCreatedObjects; Executed by:
| 4579 | ||||||
105 | - | |||||||
106 | private: | - | ||||||
107 | QQmlObjectCreator(QQmlContextData *contextData, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, QQmlObjectCreatorSharedState *inheritedSharedState); | - | ||||||
108 | - | |||||||
109 | void init(QQmlContextData *parentContext); | - | ||||||
110 | - | |||||||
111 | QObject *createInstance(int index, QObject *parent = nullptr, bool isContextObject = false); | - | ||||||
112 | - | |||||||
113 | bool populateInstance(int index, QObject *instance, | - | ||||||
114 | QObject *bindingTarget, const QQmlPropertyData *valueTypeProperty); | - | ||||||
115 | - | |||||||
116 | void setupBindings(bool applyDeferredBindings = false); | - | ||||||
117 | bool setPropertyBinding(const QQmlPropertyData *property, const QV4::CompiledData::Binding *binding); | - | ||||||
118 | void setPropertyValue(const QQmlPropertyData *property, const QV4::CompiledData::Binding *binding); | - | ||||||
119 | void setupFunctions(); | - | ||||||
120 | - | |||||||
121 | QString stringAt(int idx) const { return qmlUnit->stringAt(idx); } executed 124052 times by 106 tests: return qmlUnit->stringAt(idx); Executed by:
| 124052 | ||||||
122 | void recordError(const QV4::CompiledData::Location &location, const QString &description); | - | ||||||
123 | - | |||||||
124 | void registerObjectWithContextById(const QV4::CompiledData::Object *object, QObject *instance) const; | - | ||||||
125 | - | |||||||
126 | inline QV4::QmlContext *currentQmlContext(); | - | ||||||
127 | Q_NEVER_INLINE void createQmlContext(); | - | ||||||
128 | - | |||||||
129 | enum Phase { | - | ||||||
130 | Startup, | - | ||||||
131 | CreatingObjects, | - | ||||||
132 | CreatingObjectsPhase2, | - | ||||||
133 | ObjectsCreated, | - | ||||||
134 | Finalizing, | - | ||||||
135 | Done | - | ||||||
136 | } phase; | - | ||||||
137 | - | |||||||
138 | QQmlEngine *engine; | - | ||||||
139 | QV4::ExecutionEngine *v4; | - | ||||||
140 | QQmlRefPointer<QV4::CompiledData::CompilationUnit> compilationUnit; | - | ||||||
141 | const QV4::CompiledData::Unit *qmlUnit; | - | ||||||
142 | QQmlGuardedContextData parentContext; | - | ||||||
143 | QQmlContextData *context; | - | ||||||
144 | const QV4::CompiledData::ResolvedTypeReferenceMap &resolvedTypes; | - | ||||||
145 | const QQmlPropertyCacheVector *propertyCaches; | - | ||||||
146 | QExplicitlySharedDataPointer<QQmlObjectCreatorSharedState> sharedState; | - | ||||||
147 | bool topLevelCreator; | - | ||||||
148 | QQmlIncubatorPrivate *incubator; | - | ||||||
149 | - | |||||||
150 | QObject *_qobject; | - | ||||||
151 | QObject *_scopeObject; | - | ||||||
152 | QObject *_bindingTarget; | - | ||||||
153 | - | |||||||
154 | const QQmlPropertyData *_valueTypeProperty; // belongs to _qobjectForBindings's property cache | - | ||||||
155 | int _compiledObjectIndex; | - | ||||||
156 | const QV4::CompiledData::Object *_compiledObject; | - | ||||||
157 | QQmlData *_ddata; | - | ||||||
158 | QQmlRefPointer<QQmlPropertyCache> _propertyCache; | - | ||||||
159 | QQmlVMEMetaObject *_vmeMetaObject; | - | ||||||
160 | QQmlListProperty<void> _currentList; | - | ||||||
161 | QV4::QmlContext *_qmlContext; | - | ||||||
162 | - | |||||||
163 | friend struct QQmlObjectCreatorRecursionWatcher; | - | ||||||
164 | - | |||||||
165 | typedef std::function<bool(QQmlObjectCreatorSharedState *sharedState)> PendingAliasBinding; | - | ||||||
166 | std::vector<PendingAliasBinding> pendingAliasBindings; | - | ||||||
167 | }; | - | ||||||
168 | - | |||||||
169 | struct QQmlObjectCreatorRecursionWatcher | - | ||||||
170 | { | - | ||||||
171 | QQmlObjectCreatorRecursionWatcher(QQmlObjectCreator *creator); | - | ||||||
172 | - | |||||||
173 | bool hasRecursed() const { return watcher.hasRecursed(); } executed 1042801 times by 135 tests: return watcher.hasRecursed(); Executed by:
| 1042801 | ||||||
174 | - | |||||||
175 | private: | - | ||||||
176 | QExplicitlySharedDataPointer<QQmlObjectCreatorSharedState> sharedState; | - | ||||||
177 | QRecursionWatcher<QQmlObjectCreatorSharedState, &QQmlObjectCreatorSharedState::recursionNode> watcher; | - | ||||||
178 | }; | - | ||||||
179 | - | |||||||
180 | QV4::QmlContext *QQmlObjectCreator::currentQmlContext() | - | ||||||
181 | { | - | ||||||
182 | if (!_qmlContext->isManaged())
| 190539-427029 | ||||||
183 | _qmlContext->setM(QV4::QmlContext::create(v4->rootContext(), context, _scopeObject)); executed 427029 times by 128 tests: _qmlContext->setM(QV4::QmlContext::create(v4->rootContext(), context, _scopeObject)); Executed by:
| 427029 | ||||||
184 | - | |||||||
185 | return _qmlContext; executed 617568 times by 128 tests: return _qmlContext; Executed by:
| 617568 | ||||||
186 | } | - | ||||||
187 | - | |||||||
188 | QT_END_NAMESPACE | - | ||||||
189 | - | |||||||
190 | #endif // QQMLOBJECTCREATOR_P_H | - | ||||||
Source code | Switch to Preprocessed file |