Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4variantobject.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||
2 | - | |||||||||||||||||||
3 | - | |||||||||||||||||||
4 | using namespace QV4; | - | ||||||||||||||||||
5 | - | |||||||||||||||||||
6 | const QV4::VTable VariantObject::static_vtbl = { (std::is_same<VariantObject::SuperClass, Object>::value) ? nullptr : &VariantObject::SuperClass::static_vtbl, (sizeof(VariantObject::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), (sizeof(VariantObject::Data) + (VariantObject::NInlineProperties*sizeof(QV4::Value)) + QV4::Chunk::SlotSize - 1)/QV4::Chunk::SlotSize*QV4::Chunk::SlotSize/sizeof(QV4::Value) - (sizeof(VariantObject::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), VariantObject::IsExecutionContext, VariantObject::IsString, VariantObject::IsObject, VariantObject::IsFunctionObject, VariantObject::IsErrorObject, VariantObject::IsArrayData, VariantObject::IsStringOrSymbol, VariantObject::MyType, { 0, 0, 0, 0 }, "VariantObject", VariantObject::virtualDestroy, VariantObject::Data::markObjects, VariantObject::virtualIsEqualTo, VariantObject::virtualGet, VariantObject::virtualPut, VariantObject::virtualDeleteProperty, VariantObject::virtualHasProperty, VariantObject::virtualGetOwnProperty, VariantObject::virtualDefineOwnProperty, VariantObject::virtualIsExtensible, VariantObject::virtualPreventExtensions, VariantObject::virtualGetPrototypeOf, VariantObject::virtualSetPrototypeOf, VariantObject::virtualGetLength, VariantObject::virtualAdvanceIterator, VariantObject::virtualInstanceOf, VariantObject::virtualCall, VariantObject::virtualCallAsConstructor, }; | - | ||||||||||||||||||
7 | - | |||||||||||||||||||
8 | void Heap::VariantObject::init() | - | ||||||||||||||||||
9 | { | - | ||||||||||||||||||
10 | Object::init(); | - | ||||||||||||||||||
11 | scarceData = new ExecutionEngine::ScarceResourceData; | - | ||||||||||||||||||
12 | } executed 98779 times by 153 tests: end of block Executed by:
| 98779 | ||||||||||||||||||
13 | - | |||||||||||||||||||
14 | void Heap::VariantObject::init(const QVariant &value) | - | ||||||||||||||||||
15 | { | - | ||||||||||||||||||
16 | Object::init(); | - | ||||||||||||||||||
17 | scarceData = new ExecutionEngine::ScarceResourceData(value); | - | ||||||||||||||||||
18 | if (isScarce()
| 142-29661 | ||||||||||||||||||
19 | removeVmePropertyReference(); executed 142 times by 1 test: removeVmePropertyReference(); Executed by:
| 142 | ||||||||||||||||||
20 | } executed 29803 times by 56 tests: end of block Executed by:
| 29803 | ||||||||||||||||||
21 | - | |||||||||||||||||||
22 | bool VariantObject::Data::isScarce() const | - | ||||||||||||||||||
23 | { | - | ||||||||||||||||||
24 | QVariant::Type t = data().type(); | - | ||||||||||||||||||
25 | return executed 184893 times by 153 tests: t == QVariant::Pixmap || t == QVariant::Image;return t == QVariant::Pixmap || t == QVariant::Image; Executed by:
executed 184893 times by 153 tests: return t == QVariant::Pixmap || t == QVariant::Image; Executed by:
| 184893 | ||||||||||||||||||
26 | } | - | ||||||||||||||||||
27 | - | |||||||||||||||||||
28 | bool VariantObject::virtualIsEqualTo(Managed *m, Managed *other) | - | ||||||||||||||||||
29 | { | - | ||||||||||||||||||
30 | ((m->as<QV4::VariantObject>()) ? static_cast<void>(0) : qt_assert("m->as<QV4::VariantObject>()", __FILE__, 75)); | - | ||||||||||||||||||
31 | QV4::VariantObject *lv = static_cast<QV4::VariantObject *>(m); | - | ||||||||||||||||||
32 | - | |||||||||||||||||||
33 | if (QV4::VariantObject *rv = other->as<QV4::VariantObject>()
| 0-26 | ||||||||||||||||||
34 | return executed 26 times by 2 tests: lv->d()->data() == rv->d()->data();return lv->d()->data() == rv->d()->data(); Executed by:
executed 26 times by 2 tests: return lv->d()->data() == rv->d()->data(); Executed by:
| 26 | ||||||||||||||||||
35 | - | |||||||||||||||||||
36 | if (QV4::QQmlValueTypeWrapper *v = other->as<QQmlValueTypeWrapper>()
| 0 | ||||||||||||||||||
37 | return never executed: v->isEqual(lv->d()->data());return v->isEqual(lv->d()->data()); never executed: return v->isEqual(lv->d()->data()); | 0 | ||||||||||||||||||
38 | - | |||||||||||||||||||
39 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||
40 | } | - | ||||||||||||||||||
41 | - | |||||||||||||||||||
42 | void VariantObject::addVmePropertyReference() const | - | ||||||||||||||||||
43 | { | - | ||||||||||||||||||
44 | if (d()->isScarce()
| 6-21767 | ||||||||||||||||||
45 | - | |||||||||||||||||||
46 | - | |||||||||||||||||||
47 | - | |||||||||||||||||||
48 | d()->addVmePropertyReference(); | - | ||||||||||||||||||
49 | } executed 64 times by 1 test: end of block Executed by:
| 64 | ||||||||||||||||||
50 | } executed 21837 times by 22 tests: end of block Executed by:
| 21837 | ||||||||||||||||||
51 | - | |||||||||||||||||||
52 | void VariantObject::removeVmePropertyReference() const | - | ||||||||||||||||||
53 | { | - | ||||||||||||||||||
54 | if (d()->isScarce()
| 0-4213 | ||||||||||||||||||
55 | - | |||||||||||||||||||
56 | - | |||||||||||||||||||
57 | - | |||||||||||||||||||
58 | d()->removeVmePropertyReference(); | - | ||||||||||||||||||
59 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||
60 | } executed 4219 times by 17 tests: end of block Executed by:
| 4219 | ||||||||||||||||||
61 | - | |||||||||||||||||||
62 | - | |||||||||||||||||||
63 | void VariantPrototype::init() | - | ||||||||||||||||||
64 | { | - | ||||||||||||||||||
65 | defineDefaultProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "preserve")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "preserve" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98079 times by 153 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 98079 times by 153 tests: }()), method_preserve, 0);return qstring_literal_temp; Executed by:
| 98079 | ||||||||||||||||||
66 | defineDefaultProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "destroy")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "destroy" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98663 times by 153 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 98663 times by 153 tests: }()), method_destroy, 0);return qstring_literal_temp; Executed by:
| 98663 | ||||||||||||||||||
67 | defineDefaultProperty(engine()->id_valueOf(), method_valueOf, 0); | - | ||||||||||||||||||
68 | defineDefaultProperty(engine()->id_toString(), method_toString, 0); | - | ||||||||||||||||||
69 | } executed 98848 times by 153 tests: end of block Executed by:
| 98848 | ||||||||||||||||||
70 | - | |||||||||||||||||||
71 | ReturnedValue VariantPrototype::method_preserve(const FunctionObject *, const Value *thisObject, const Value *, int) | - | ||||||||||||||||||
72 | { | - | ||||||||||||||||||
73 | const VariantObject *o = thisObject->as<QV4::VariantObject>(); | - | ||||||||||||||||||
74 | if (o
| 0-24 | ||||||||||||||||||
75 | o->d()->addVmePropertyReference(); executed 24 times by 1 test: o->d()->addVmePropertyReference(); Executed by:
| 24 | ||||||||||||||||||
76 | return executed 24 times by 1 test: QV4::Encode::undefined();return QV4::Encode::undefined(); Executed by:
executed 24 times by 1 test: return QV4::Encode::undefined(); Executed by:
| 24 | ||||||||||||||||||
77 | } | - | ||||||||||||||||||
78 | - | |||||||||||||||||||
79 | ReturnedValue VariantPrototype::method_destroy(const FunctionObject *, const Value *thisObject, const Value *, int) | - | ||||||||||||||||||
80 | { | - | ||||||||||||||||||
81 | const VariantObject *o = thisObject->as<QV4::VariantObject>(); | - | ||||||||||||||||||
82 | if (o
| 0-32 | ||||||||||||||||||
83 | if (o->d()->isScarce()
| 0-32 | ||||||||||||||||||
84 | o->d()->addVmePropertyReference(); executed 32 times by 1 test: o->d()->addVmePropertyReference(); Executed by:
| 32 | ||||||||||||||||||
85 | o->d()->data() = QVariant(); | - | ||||||||||||||||||
86 | } executed 32 times by 1 test: end of block Executed by:
| 32 | ||||||||||||||||||
87 | return executed 32 times by 1 test: QV4::Encode::undefined();return QV4::Encode::undefined(); Executed by:
executed 32 times by 1 test: return QV4::Encode::undefined(); Executed by:
| 32 | ||||||||||||||||||
88 | } | - | ||||||||||||||||||
89 | - | |||||||||||||||||||
90 | ReturnedValue VariantPrototype::method_toString(const FunctionObject *b, const Value *thisObject, const Value *, int) | - | ||||||||||||||||||
91 | { | - | ||||||||||||||||||
92 | ExecutionEngine *v4 = b->engine(); | - | ||||||||||||||||||
93 | const VariantObject *o = thisObject->as<QV4::VariantObject>(); | - | ||||||||||||||||||
94 | if (!o
| 0-32 | ||||||||||||||||||
95 | return never executed: QV4::Encode::undefined();return QV4::Encode::undefined(); never executed: return QV4::Encode::undefined(); | 0 | ||||||||||||||||||
96 | QString result = o->d()->data().toString(); | - | ||||||||||||||||||
97 | if (result.isEmpty()
| 2-26 | ||||||||||||||||||
98 | result = QLatin1String("QVariant(") | - | ||||||||||||||||||
99 | + QLatin1String(o->d()->data().typeName()) | - | ||||||||||||||||||
100 | + QLatin1Char(')'); | - | ||||||||||||||||||
101 | } executed 4 times by 2 tests: end of block Executed by:
| 4 | ||||||||||||||||||
102 | return executed 32 times by 5 tests: Encode(v4->newString(result));return Encode(v4->newString(result)); Executed by:
executed 32 times by 5 tests: return Encode(v4->newString(result)); Executed by:
| 32 | ||||||||||||||||||
103 | } | - | ||||||||||||||||||
104 | - | |||||||||||||||||||
105 | ReturnedValue VariantPrototype::method_valueOf(const FunctionObject *b, const Value *thisObject, const Value *, int) | - | ||||||||||||||||||
106 | { | - | ||||||||||||||||||
107 | const VariantObject *o = thisObject->as<QV4::VariantObject>(); | - | ||||||||||||||||||
108 | if (o
| 0-30 | ||||||||||||||||||
109 | QVariant v = o->d()->data(); | - | ||||||||||||||||||
110 | switch (v.type()) { | - | ||||||||||||||||||
111 | case never executed: QVariant::Invalid:case QVariant::Invalid: never executed: case QVariant::Invalid: | 0 | ||||||||||||||||||
112 | return never executed: Encode::undefined();return Encode::undefined(); never executed: return Encode::undefined(); | 0 | ||||||||||||||||||
113 | case never executed: QVariant::String:case QVariant::String: never executed: case QVariant::String: | 0 | ||||||||||||||||||
114 | return never executed: Encode(b->engine()->newString(v.toString()));return Encode(b->engine()->newString(v.toString())); never executed: return Encode(b->engine()->newString(v.toString())); | 0 | ||||||||||||||||||
115 | case never executed: QVariant::Int:case QVariant::Int: never executed: case QVariant::Int: | 0 | ||||||||||||||||||
116 | return never executed: Encode(v.toInt());return Encode(v.toInt()); never executed: return Encode(v.toInt()); | 0 | ||||||||||||||||||
117 | case never executed: QVariant::Double:case QVariant::Double: never executed: case QVariant::Double: | 0 | ||||||||||||||||||
118 | case never executed: QVariant::UInt:case QVariant::UInt: never executed: case QVariant::UInt: | 0 | ||||||||||||||||||
119 | return never executed: Encode(v.toDouble());return Encode(v.toDouble()); never executed: return Encode(v.toDouble()); | 0 | ||||||||||||||||||
120 | case never executed: QVariant::Bool:case QVariant::Bool: never executed: case QVariant::Bool: | 0 | ||||||||||||||||||
121 | return never executed: Encode(v.toBool());return Encode(v.toBool()); never executed: return Encode(v.toBool()); | 0 | ||||||||||||||||||
122 | default executed 30 times by 3 tests: :default: Executed by:
executed 30 times by 3 tests: default: Executed by:
| 30 | ||||||||||||||||||
123 | if (QMetaType::typeFlags(v.userType()) & QMetaType::IsEnumeration
| 2-28 | ||||||||||||||||||
124 | return executed 2 times by 1 test: QV4::Encode(Encode(v.toInt()));return QV4::Encode(Encode(v.toInt())); Executed by:
executed 2 times by 1 test: return QV4::Encode(Encode(v.toInt())); Executed by:
| 2 | ||||||||||||||||||
125 | break; executed 28 times by 3 tests: break; Executed by:
| 28 | ||||||||||||||||||
126 | } | - | ||||||||||||||||||
127 | } | - | ||||||||||||||||||
128 | return executed 28 times by 3 tests: thisObject->asReturnedValue();return thisObject->asReturnedValue(); Executed by:
executed 28 times by 3 tests: return thisObject->asReturnedValue(); Executed by:
| 28 | ||||||||||||||||||
129 | } | - | ||||||||||||||||||
130 | - | |||||||||||||||||||
131 | - | |||||||||||||||||||
Switch to Source code | Preprocessed file |