OpenCoverage

qv8engine_p.h #2

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/qml/v8/qv8engine_p.h
Source codeSwitch to Preprocessed file
LineSourceCount
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 QQMLV8ENGINE_P_H-
41#define QQMLV8ENGINE_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 <QtCore/qglobal.h>-
55#include <QtCore/qvariant.h>-
56#include <QtCore/qset.h>-
57#include <QtCore/qmutex.h>-
58#include <QtCore/qstack.h>-
59#include <QtCore/qstringlist.h>-
60#include <QtCore/QElapsedTimer>-
61#include <QtCore/QThreadStorage>-
62-
63#include <QtQml/qjsengine.h>-
64#include "private/qintrusivelist_p.h"-
65-
66-
67#include <private/qv4value_p.h>-
68#include <private/qv4identifier_p.h>-
69#include <private/qv4context_p.h>-
70#include <private/qv4stackframe_p.h>-
71#include <private/qqmldelayedcallqueue_p.h>-
72-
73QT_BEGIN_NAMESPACE-
74-
75namespace QV4 {-
76 struct ArrayObject;-
77 struct ExecutionEngine;-
78 struct QObjectMethod;-
79}-
80-
81#define V4_DEFINE_EXTENSION(dataclass, datafunction) \-
82 static inline dataclass *datafunction(QV4::ExecutionEngine *engine) \-
83 { \-
84 static int extensionId = -1; \-
85 if (extensionId == -1) { \-
86 QV8Engine::registrationMutex()->lock(); \-
87 if (extensionId == -1) \-
88 extensionId = QV8Engine::registerExtension(); \-
89 QV8Engine::registrationMutex()->unlock(); \-
90 } \-
91 dataclass *rv = (dataclass *)engine->v8Engine->extensionData(extensionId); \-
92 if (!rv) { \-
93 rv = new dataclass(engine); \-
94 engine->v8Engine->setExtensionData(extensionId, rv); \-
95 } \-
96 return rv; \-
97 } \-
98-
99// Used to allow a QObject method take and return raw V4 handles without having to expose-
100// 48 in the public API.-
101// Use like this:-
102// class MyClass : public QObject {-
103// Q_OBJECT-
104// ...-
105// Q_INVOKABLE void myMethod(QQmlV4Function*);-
106// };-
107// The QQmlV8Function - and consequently the arguments and return value - only remains-
108// valid during the call. If the return value isn't set within myMethod(), the will return-
109// undefined.-
110-
111class QQmlV4Function-
112{-
113public:-
114 int length() const { return callData->argc(); }
executed 16766 times by 29 tests: return callData->argc();
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlcomponent
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlincubator
  • tst_qqmlinfo
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlproperty
  • tst_qqmlqt
  • tst_qqmlxmlhttprequest
  • tst_qquickanimationcontroller
  • tst_qquickbehaviors
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquickgridview
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicklayouts
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquickpathview
  • tst_qquickpositioners
  • ...
16766
115 QV4::ReturnedValue operator[](int idx) const { return (idx < callData->argc() ? callData->args[idx].asReturnedValue() : QV4::Encode::undefined()); }
executed 17526 times by 30 tests: return (idx < callData->argc() ? callData->args[idx].asReturnedValue() : QV4::Encode::undefined());
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlcomponent
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlincubator
  • tst_qqmlinfo
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlproperty
  • tst_qqmlqt
  • tst_qqmlsqldatabase
  • tst_qqmlxmlhttprequest
  • tst_qquickanimationcontroller
  • tst_qquickbehaviors
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquickgridview
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicklayouts
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquickpathview
  • ...
17526
116 void setReturnValue(QV4::ReturnedValue rv) { *retVal = rv; }
executed 6340 times by 21 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlcomponent
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlincubator
  • tst_qqmlinfo
  • tst_qqmlproperty
  • tst_qqmlqt
  • tst_qqmlsqldatabase
  • tst_qquickanimationcontroller
  • tst_qquickbehaviors
  • tst_qquickdroparea
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicklayouts
  • tst_qquickloader
  • tst_qquickpathview
  • tst_qquickpositioners
  • tst_qquicktextinput
  • tst_qquickvisualdatamodel
6340
117 QV4::ExecutionEngine *v4engine() const { return e; }
executed 15396 times by 30 tests: return e;
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlcomponent
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlincubator
  • tst_qqmlinfo
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlproperty
  • tst_qqmlqt
  • tst_qqmlsqldatabase
  • tst_qqmlxmlhttprequest
  • tst_qquickanimationcontroller
  • tst_qquickbehaviors
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquickgridview
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicklayouts
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquickpathview
  • ...
15396
118private:-
119 friend struct QV4::QObjectMethod;-
120 QQmlV4Function();-
121 QQmlV4Function(const QQmlV4Function &);-
122 QQmlV4Function &operator=(const QQmlV4Function &);-
123-
124 QQmlV4Function(QV4::CallData *callData, QV4::Value *retVal, QV4::ExecutionEngine *e)-
125 : callData(callData), retVal(retVal), e(e)-
126 {-
127 callData->thisObject = QV4::Encode::undefined();-
128 }
executed 12294 times by 31 tests: end of block
Executed by:
  • tst_examples
  • tst_qjsengine
  • tst_qmlcachegen
  • tst_qqmlcomponent
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlincubator
  • tst_qqmlinfo
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlproperty
  • tst_qqmlqt
  • tst_qqmlsqldatabase
  • tst_qqmlxmlhttprequest
  • tst_qquickanimationcontroller
  • tst_qquickbehaviors
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquickgridview
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicklayouts
  • tst_qquicklistview
  • tst_qquickloader
  • ...
12294
129-
130 QV4::CallData *callData;-
131 QV4::Value *retVal;-
132 QV4::ExecutionEngine *e;-
133};-
134-
135class Q_QML_PRIVATE_EXPORT QQmlV4Handle-
136{-
137public:-
138 QQmlV4Handle() : d(QV4::Encode::undefined()) {}
executed 30154 times by 13 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickanimationcontroller
  • tst_qquickgridview
  • tst_qquicklayouts
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
  • tst_quicktestmainwithsetup
30154
139 explicit QQmlV4Handle(const QV4::Value &v) : d(v.asReturnedValue()) {}
executed 31365 times by 16 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmltranslation
  • tst_qqmlxmlhttprequest
  • tst_qquickanimationcontroller
  • tst_qquickcustomaffector
  • tst_qquickgridview
  • tst_qquicklayouts
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
  • tst_qquickworkerscript
  • tst_quicktestmainwithsetup
31365
140 explicit QQmlV4Handle(QV4::ReturnedValue v) : d(v) {}
executed 1542 times by 4 tests: end of block
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickcustomaffector
  • tst_qquickvisualdatamodel
1542
141-
142 operator QV4::ReturnedValue() const { return d; }
executed 31850 times by 17 tests: return d;
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlbinding
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlqt
  • tst_qqmltranslation
  • tst_qqmlvaluetypeproviders
  • tst_qqmlxmlhttprequest
  • tst_qquickanimationcontroller
  • tst_qquickcustomaffector
  • tst_qquickgridview
  • tst_qquicklayouts
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
  • tst_quicktestmainwithsetup
31850
143-
144private:-
145 quint64 d;-
146};-
147-
148class QObject;-
149class QQmlEngine;-
150class QNetworkAccessManager;-
151class QQmlContextData;-
152-
153class Q_QML_PRIVATE_EXPORT QV8Engine-
154{-
155 friend class QJSEngine;-
156public:-
157// static QJSEngine* get(QV8Engine* d) { Q_ASSERT(d); return d->q; }-
158 static QV4::ExecutionEngine *getV4(QV8Engine *d) { return d->m_v4Engine; }
executed 3488 times by 5 tests: return d->m_v4Engine;
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodelworkerscript
  • tst_qquickworkerscript
3488
159-
160 QV8Engine(QV4::ExecutionEngine *v4);-
161 virtual ~QV8Engine();-
162-
163 // This enum should be in sync with QQmlEngine::ObjectOwnership-
164 enum ObjectOwnership { CppOwnership, JavaScriptOwnership };-
165-
166 struct Deletable {-
167 virtual ~Deletable() {}-
168 };-
169-
170 void initQmlGlobalObject();-
171 void setEngine(QQmlEngine *engine);-
172 QQmlEngine *engine() { return m_engine; }
executed 10208149 times by 131 tests: return m_engine;
Executed by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlcontext
  • tst_qqmldebugjs
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlexpression
  • tst_qqmlincubator
  • tst_qqmlinfo
  • tst_qqmlinstantiator
  • tst_qqmlitemmodels
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • ...
10208149
173 QQmlDelayedCallQueue *delayedCallQueue() { return &m_delayedCallQueue; }
never executed: return &m_delayedCallQueue;
0
174-
175#if QT_CONFIG(qml_xml_http_request)-
176 void *xmlHttpRequestData() const { return m_xmlHttpRequestData; }
never executed: return m_xmlHttpRequestData;
0
177#endif-
178-
179 void freezeObject(const QV4::Value &value);-
180-
181#if QT_CONFIG(qml_network)-
182 // Return the network access manager for this engine. By default this returns the network-
183 // access manager of the QQmlEngine. It is overridden in the case of a threaded v8-
184 // instance (like in WorkerScript).-
185 virtual QNetworkAccessManager *networkAccessManager();-
186#endif-
187-
188 // Return the list of illegal id names (the names of the properties on the global object)-
189 const QSet<QString> &illegalNames() const;-
190-
191 static QMutex *registrationMutex();-
192 static int registerExtension();-
193-
194 inline Deletable *extensionData(int) const;-
195 void setExtensionData(int, Deletable *);-
196-
197public:-
198 // used for console.time(), console.timeEnd()-
199 void startTimer(const QString &timerName);-
200 qint64 stopTimer(const QString &timerName, bool *wasRunning);-
201-
202 // used for console.count()-
203 int consoleCountHelper(const QString &file, quint16 line, quint16 column);-
204-
205protected:-
206 QQmlEngine *m_engine;-
207 QQmlDelayedCallQueue m_delayedCallQueue;-
208-
209 QV4::ExecutionEngine *m_v4Engine;-
210-
211#if QT_CONFIG(qml_xml_http_request)-
212 void *m_xmlHttpRequestData;-
213#endif-
214-
215 QVector<Deletable *> m_extensionData;-
216-
217 QSet<QString> m_illegalNames;-
218-
219 QElapsedTimer m_time;-
220 QHash<QString, qint64> m_startedTimers;-
221-
222 QHash<QString, quint32> m_consoleCount;-
223-
224 void initializeGlobal();-
225-
226private:-
227 Q_DISABLE_COPY(QV8Engine)-
228};-
229-
230inline QV8Engine::Deletable *QV8Engine::extensionData(int index) const-
231{-
232 if (index < m_extensionData.count())
index < m_exte...onData.count()Description
TRUEevaluated 4382 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qqmlcomponent
  • tst_qqmllocale
  • tst_qqmlsqldatabase
  • tst_qqmlvaluetypes
  • tst_qquickcustomaffector
  • tst_qquickvisualdatamodel
FALSEevaluated 28 times by 9 tests
Evaluated by:
  • tst_examples
  • tst_qqmlcomponent
  • tst_qqmlecmascript
  • tst_qqmlincubator
  • tst_qqmllocale
  • tst_qqmlsqldatabase
  • tst_qqmlvaluetypes
  • tst_qquickcustomaffector
  • tst_qquickvisualdatamodel
28-4382
233 return m_extensionData[index];
executed 4382 times by 7 tests: return m_extensionData[index];
Executed by:
  • tst_examples
  • tst_qqmlcomponent
  • tst_qqmllocale
  • tst_qqmlsqldatabase
  • tst_qqmlvaluetypes
  • tst_qquickcustomaffector
  • tst_qquickvisualdatamodel
4382
234 else-
235 return nullptr;
executed 28 times by 9 tests: return nullptr;
Executed by:
  • tst_examples
  • tst_qqmlcomponent
  • tst_qqmlecmascript
  • tst_qqmlincubator
  • tst_qqmllocale
  • tst_qqmlsqldatabase
  • tst_qqmlvaluetypes
  • tst_qquickcustomaffector
  • tst_qquickvisualdatamodel
28
236}-
237-
238-
239QT_END_NAMESPACE-
240-
241Q_DECLARE_METATYPE(QQmlV4Handle)
never executed: return id;
never executed: return newId;
const int id =....loadAcquire()Description
TRUEnever evaluated
FALSEnever evaluated
0
242-
243#endif // QQMLV8ENGINE_P_H-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0