OpenCoverage

qv4variantobject.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4variantobject.cpp
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#include "qv4variantobject_p.h"-
41#include "qv4functionobject_p.h"-
42#include "qv4objectproto_p.h"-
43#include <private/qqmlvaluetypewrapper_p.h>-
44#include <private/qv8engine_p.h>-
45#include <private/qv4qobjectwrapper_p.h>-
46-
47QT_BEGIN_NAMESPACE-
48-
49using namespace QV4;-
50-
51DEFINE_OBJECT_VTABLE(VariantObject);-
52-
53void Heap::VariantObject::init()-
54{-
55 Object::init();-
56 scarceData = new ExecutionEngine::ScarceResourceData;-
57}
executed 98779 times by 153 tests: end of block
Executed by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_parserstress
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlcontext
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • ...
98779
58-
59void Heap::VariantObject::init(const QVariant &value)-
60{-
61 Object::init();-
62 scarceData = new ExecutionEngine::ScarceResourceData(value);-
63 if (isScarce())
isScarce()Description
TRUEevaluated 142 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
FALSEevaluated 29661 times by 56 tests
Evaluated by:
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qjsengine
  • tst_qjsvalue
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmllistreference
  • tst_qqmllocale
  • tst_qqmlmetaobject
  • tst_qqmlproperty
  • tst_qqmlqt
  • tst_qqmlsettings
  • tst_qqmlvaluetypeproviders
  • tst_qqmlvaluetypes
  • tst_qqmlxmlhttprequest
  • tst_qquickaccessible
  • tst_qquickanchors
  • tst_qquickanimatedimage
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickapplication
  • ...
142-29661
64 removeVmePropertyReference();
executed 142 times by 1 test: removeVmePropertyReference();
Executed by:
  • tst_qqmlecmascript
142
65}
executed 29803 times by 56 tests: end of block
Executed by:
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qjsengine
  • tst_qjsvalue
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmllistreference
  • tst_qqmllocale
  • tst_qqmlmetaobject
  • tst_qqmlproperty
  • tst_qqmlqt
  • tst_qqmlsettings
  • tst_qqmlvaluetypeproviders
  • tst_qqmlvaluetypes
  • tst_qqmlxmlhttprequest
  • tst_qquickaccessible
  • tst_qquickanchors
  • tst_qquickanimatedimage
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickapplication
  • ...
29803
66-
67bool VariantObject::Data::isScarce() const-
68{-
69 QVariant::Type t = data().type();-
70 return t == QVariant::Pixmap || t == QVariant::Image;
executed 184893 times by 153 tests: return t == QVariant::Pixmap || t == QVariant::Image;
Executed by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_parserstress
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlcontext
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • ...
184893
71}-
72-
73bool VariantObject::virtualIsEqualTo(Managed *m, Managed *other)-
74{-
75 Q_ASSERT(m->as<QV4::VariantObject>());-
76 QV4::VariantObject *lv = static_cast<QV4::VariantObject *>(m);-
77-
78 if (QV4::VariantObject *rv = other->as<QV4::VariantObject>())
QV4::VariantOb...riantObject>()Description
TRUEevaluated 26 times by 2 tests
Evaluated by:
  • tst_qjsvalue
  • tst_qqmlecmascript
FALSEnever evaluated
0-26
79 return lv->d()->data() == rv->d()->data();
executed 26 times by 2 tests: return lv->d()->data() == rv->d()->data();
Executed by:
  • tst_qjsvalue
  • tst_qqmlecmascript
26
80-
81 if (QV4::QQmlValueTypeWrapper *v = other->as<QQmlValueTypeWrapper>())
QV4::QQmlValue...TypeWrapper>()Description
TRUEnever evaluated
FALSEnever evaluated
0
82 return v->isEqual(lv->d()->data());
never executed: return v->isEqual(lv->d()->data());
0
83-
84 return false;
never executed: return false;
0
85}-
86-
87void VariantObject::addVmePropertyReference() const-
88{-
89 if (d()->isScarce() && ++d()->vmePropertyReferenceCount == 1) {
d()->isScarce()Description
TRUEevaluated 70 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
FALSEevaluated 21767 times by 22 tests
Evaluated by:
  • tst_examples
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmllistreference
  • tst_qqmlmetaobject
  • tst_qqmlqt
  • tst_qqmlvaluetypeproviders
  • tst_qqmlvaluetypes
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpincharea
  • tst_qquickrepeater
  • tst_qquickscreen
  • tst_qquicktext
  • tst_qquicktextinput
  • tst_qquickvisualdatamodel
  • tst_qquickworkerscript
++d()->vmeProp...enceCount == 1Description
TRUEevaluated 64 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
6-21767
90 // remove from the ep->scarceResources list-
91 // since it is now no longer eligible to be-
92 // released automatically by the engine.-
93 d()->addVmePropertyReference();-
94 }
executed 64 times by 1 test: end of block
Executed by:
  • tst_qqmlecmascript
64
95}
executed 21837 times by 22 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmllistreference
  • tst_qqmlmetaobject
  • tst_qqmlqt
  • tst_qqmlvaluetypeproviders
  • tst_qqmlvaluetypes
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpincharea
  • tst_qquickrepeater
  • tst_qquickscreen
  • tst_qquicktext
  • tst_qquicktextinput
  • tst_qquickvisualdatamodel
  • tst_qquickworkerscript
21837
96-
97void VariantObject::removeVmePropertyReference() const-
98{-
99 if (d()->isScarce() && --d()->vmePropertyReferenceCount == 0) {
d()->isScarce()Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
FALSEevaluated 4213 times by 17 tests
Evaluated by:
  • tst_examples
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlmetaobject
  • tst_qqmlvaluetypeproviders
  • tst_qqmlvaluetypes
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpincharea
  • tst_qquickrepeater
  • tst_qquicktext
  • tst_qquicktextinput
  • tst_qquickvisualdatamodel
  • tst_qquickworkerscript
--d()->vmeProp...enceCount == 0Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
FALSEnever evaluated
0-4213
100 // and add to the ep->scarceResources list-
101 // since it is now eligible to be released-
102 // automatically by the engine.-
103 d()->removeVmePropertyReference();-
104 }
executed 6 times by 1 test: end of block
Executed by:
  • tst_qqmlecmascript
6
105}
executed 4219 times by 17 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlmetaobject
  • tst_qqmlvaluetypeproviders
  • tst_qqmlvaluetypes
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpincharea
  • tst_qquickrepeater
  • tst_qquicktext
  • tst_qquicktextinput
  • tst_qquickvisualdatamodel
  • tst_qquickworkerscript
4219
106-
107-
108void VariantPrototype::init()-
109{-
110 defineDefaultProperty(QStringLiteral("preserve"), method_preserve, 0);
executed 98079 times by 153 tests: return qstring_literal_temp;
Executed by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_parserstress
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlcontext
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • ...
98079
111 defineDefaultProperty(QStringLiteral("destroy"), method_destroy, 0);
executed 98663 times by 153 tests: return qstring_literal_temp;
Executed by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_parserstress
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlcontext
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • ...
98663
112 defineDefaultProperty(engine()->id_valueOf(), method_valueOf, 0);-
113 defineDefaultProperty(engine()->id_toString(), method_toString, 0);-
114}
executed 98848 times by 153 tests: end of block
Executed by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_parserstress
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlcontext
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • ...
98848
115-
116ReturnedValue VariantPrototype::method_preserve(const FunctionObject *, const Value *thisObject, const Value *, int)-
117{-
118 const VariantObject *o = thisObject->as<QV4::VariantObject>();-
119 if (o && o->d()->isScarce())
oDescription
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
FALSEnever evaluated
o->d()->isScarce()Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
FALSEnever evaluated
0-24
120 o->d()->addVmePropertyReference();
executed 24 times by 1 test: o->d()->addVmePropertyReference();
Executed by:
  • tst_qqmlecmascript
24
121 RETURN_UNDEFINED();
executed 24 times by 1 test: return QV4::Encode::undefined();
Executed by:
  • tst_qqmlecmascript
24
122}-
123-
124ReturnedValue VariantPrototype::method_destroy(const FunctionObject *, const Value *thisObject, const Value *, int)-
125{-
126 const VariantObject *o = thisObject->as<QV4::VariantObject>();-
127 if (o) {
oDescription
TRUEevaluated 32 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
FALSEnever evaluated
0-32
128 if (o->d()->isScarce())
o->d()->isScarce()Description
TRUEevaluated 32 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
FALSEnever evaluated
0-32
129 o->d()->addVmePropertyReference();
executed 32 times by 1 test: o->d()->addVmePropertyReference();
Executed by:
  • tst_qqmlecmascript
32
130 o->d()->data() = QVariant();-
131 }
executed 32 times by 1 test: end of block
Executed by:
  • tst_qqmlecmascript
32
132 RETURN_UNDEFINED();
executed 32 times by 1 test: return QV4::Encode::undefined();
Executed by:
  • tst_qqmlecmascript
32
133}-
134-
135ReturnedValue VariantPrototype::method_toString(const FunctionObject *b, const Value *thisObject, const Value *, int)-
136{-
137 ExecutionEngine *v4 = b->engine();-
138 const VariantObject *o = thisObject->as<QV4::VariantObject>();-
139 if (!o)
!oDescription
TRUEnever evaluated
FALSEevaluated 32 times by 5 tests
Evaluated by:
  • tst_qjsengine
  • tst_qjsvalue
  • tst_qqmlecmascript
  • tst_qqmlxmlhttprequest
  • tst_qquickimage
0-32
140 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
141 QString result = o->d()->data().toString();-
142 if (result.isEmpty() && !o->d()->data().canConvert(QVariant::String)) {
result.isEmpty()Description
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_qjsengine
  • tst_qjsvalue
FALSEevaluated 26 times by 3 tests
Evaluated by:
  • tst_qqmlecmascript
  • tst_qqmlxmlhttprequest
  • tst_qquickimage
!o->d()->data(...riant::String)Description
TRUEevaluated 4 times by 2 tests
Evaluated by:
  • tst_qjsengine
  • tst_qjsvalue
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qjsvalue
2-26
143 result = QLatin1String("QVariant(")-
144 + QLatin1String(o->d()->data().typeName())-
145 + QLatin1Char(')');-
146 }
executed 4 times by 2 tests: end of block
Executed by:
  • tst_qjsengine
  • tst_qjsvalue
4
147 return Encode(v4->newString(result));
executed 32 times by 5 tests: return Encode(v4->newString(result));
Executed by:
  • tst_qjsengine
  • tst_qjsvalue
  • tst_qqmlecmascript
  • tst_qqmlxmlhttprequest
  • tst_qquickimage
32
148}-
149-
150ReturnedValue VariantPrototype::method_valueOf(const FunctionObject *b, const Value *thisObject, const Value *, int)-
151{-
152 const VariantObject *o = thisObject->as<QV4::VariantObject>();-
153 if (o) {
oDescription
TRUEevaluated 30 times by 3 tests
Evaluated by:
  • tst_qjsengine
  • tst_qqmlecmascript
  • tst_qquickimage
FALSEnever evaluated
0-30
154 QVariant v = o->d()->data();-
155 switch (v.type()) {-
156 case QVariant::Invalid:
never executed: case QVariant::Invalid:
0
157 return Encode::undefined();
never executed: return Encode::undefined();
0
158 case QVariant::String:
never executed: case QVariant::String:
0
159 return Encode(b->engine()->newString(v.toString()));
never executed: return Encode(b->engine()->newString(v.toString()));
0
160 case QVariant::Int:
never executed: case QVariant::Int:
0
161 return Encode(v.toInt());
never executed: return Encode(v.toInt());
0
162 case QVariant::Double:
never executed: case QVariant::Double:
0
163 case QVariant::UInt:
never executed: case QVariant::UInt:
0
164 return Encode(v.toDouble());
never executed: return Encode(v.toDouble());
0
165 case QVariant::Bool:
never executed: case QVariant::Bool:
0
166 return Encode(v.toBool());
never executed: return Encode(v.toBool());
0
167 default:
executed 30 times by 3 tests: default:
Executed by:
  • tst_qjsengine
  • tst_qqmlecmascript
  • tst_qquickimage
30
168 if (QMetaType::typeFlags(v.userType()) & QMetaType::IsEnumeration)
QMetaType::typ...:IsEnumerationDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qjsengine
FALSEevaluated 28 times by 3 tests
Evaluated by:
  • tst_qjsengine
  • tst_qqmlecmascript
  • tst_qquickimage
2-28
169 RETURN_RESULT(Encode(v.toInt()));
executed 2 times by 1 test: return QV4::Encode(Encode(v.toInt()));
Executed by:
  • tst_qjsengine
2
170 break;
executed 28 times by 3 tests: break;
Executed by:
  • tst_qjsengine
  • tst_qqmlecmascript
  • tst_qquickimage
28
171 }-
172 }-
173 return thisObject->asReturnedValue();
executed 28 times by 3 tests: return thisObject->asReturnedValue();
Executed by:
  • tst_qjsengine
  • tst_qqmlecmascript
  • tst_qquickimage
28
174}-
175-
176QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0