| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4managed_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 | #ifndef QMLJS_MANAGED_H | - |
| 40 | #define QMLJS_MANAGED_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 "qv4global_p.h" | - |
| 54 | #include "qv4value_p.h" | - |
| 55 | #include "qv4enginebase_p.h" | - |
| 56 | #include <private/qv4heap_p.h> | - |
| 57 | #include <private/qv4writebarrier_p.h> | - |
| 58 | #include <private/qv4vtable_p.h> | - |
| 59 | - | |
| 60 | QT_BEGIN_NAMESPACE | - |
| 61 | - | |
| 62 | namespace QV4 { | - |
| 63 | - | |
| 64 | #define Q_MANAGED_CHECK \ | - |
| 65 | template <typename Type> inline void qt_check_for_QMANAGED_macro(const Type *_q_argument) const \ | - |
| 66 | { int i = qYouForgotTheQ_MANAGED_Macro(this, _q_argument); i = i + 1; } | - |
| 67 | - | |
| 68 | template <typename T> | - |
| 69 | inline int qYouForgotTheQ_MANAGED_Macro(T, T) { return 0; } executed 19739283 times by 154 tests: return 0;Executed by:
| 19739283 |
| 70 | - | |
| 71 | template <typename T1, typename T2> | - |
| 72 | inline void qYouForgotTheQ_MANAGED_Macro(T1, T2) {} | - |
| 73 | - | |
| 74 | #define V4_MANAGED_SIZE_TEST void __dataTest() { static_assert (sizeof(*this) == sizeof(Managed), "Classes derived from Managed can't have own data members."); } | - |
| 75 | - | |
| 76 | #define V4_NEEDS_DESTROY static void virtualDestroy(QV4::Heap::Base *b) { static_cast<Data *>(b)->destroy(); } | - |
| 77 | - | |
| 78 | - | |
| 79 | #define V4_MANAGED_ITSELF(DataClass, superClass) \ | - |
| 80 | public: \ | - |
| 81 | Q_MANAGED_CHECK \ | - |
| 82 | typedef QV4::Heap::DataClass Data; \ | - |
| 83 | typedef superClass SuperClass; \ | - |
| 84 | static const QV4::VTable static_vtbl; \ | - |
| 85 | static inline const QV4::VTable *staticVTable() { return &static_vtbl; } \ | - |
| 86 | V4_MANAGED_SIZE_TEST \ | - |
| 87 | QV4::Heap::DataClass *d_unchecked() const { return static_cast<QV4::Heap::DataClass *>(m()); } \ | - |
| 88 | QV4::Heap::DataClass *d() const { \ | - |
| 89 | QV4::Heap::DataClass *dptr = d_unchecked(); \ | - |
| 90 | dptr->_checkIsInitialized(); \ | - |
| 91 | return dptr; \ | - |
| 92 | } | - |
| 93 | - | |
| 94 | #define V4_MANAGED(DataClass, superClass) \ | - |
| 95 | private: \ | - |
| 96 | DataClass() Q_DECL_EQ_DELETE; \ | - |
| 97 | Q_DISABLE_COPY(DataClass) \ | - |
| 98 | V4_MANAGED_ITSELF(DataClass, superClass) \ | - |
| 99 | Q_STATIC_ASSERT(std::is_trivial< QV4::Heap::DataClass >::value); | - |
| 100 | - | |
| 101 | #define Q_MANAGED_TYPE(type) \ | - |
| 102 | public: \ | - |
| 103 | enum { MyType = Type_##type }; | - |
| 104 | - | |
| 105 | #define V4_INTERNALCLASS(c) \ | - |
| 106 | static Heap::InternalClass *defaultInternalClass(QV4::EngineBase *e) \ | - |
| 107 | { return e->internalClasses(QV4::EngineBase::Class_##c); } | - |
| 108 | - | |
| 109 | struct Q_QML_PRIVATE_EXPORT Managed : Value, VTableBase | - |
| 110 | { | - |
| 111 | V4_MANAGED_ITSELF(Base, Managed) never executed: end of blocknever executed: end of blocknever executed: return &static_vtbl;executed 1547909825 times by 154 tests: return static_cast<QV4::Heap::Base *>(m());Executed by:
executed 1541424663 times by 154 tests: return dptr;Executed by:
| 0-1547909825 |
| 112 | enum { | - |
| 113 | IsExecutionContext = false, | - |
| 114 | IsString = false, | - |
| 115 | IsStringOrSymbol = false, | - |
| 116 | IsObject = false, | - |
| 117 | IsFunctionObject = false, | - |
| 118 | IsErrorObject = false, | - |
| 119 | IsArrayData = false | - |
| 120 | }; | - |
| 121 | private: | - |
| 122 | void *operator new(size_t); | - |
| 123 | Managed() Q_DECL_EQ_DELETE; | - |
| 124 | Q_DISABLE_COPY(Managed) | - |
| 125 | - | |
| 126 | public: | - |
| 127 | enum { NInlineProperties = 0 }; | - |
| 128 | - | |
| 129 | enum Type { | - |
| 130 | Type_Invalid, | - |
| 131 | Type_String, | - |
| 132 | Type_Object, | - |
| 133 | Type_Symbol, | - |
| 134 | Type_ArrayObject, | - |
| 135 | Type_FunctionObject, | - |
| 136 | Type_GeneratorObject, | - |
| 137 | Type_BooleanObject, | - |
| 138 | Type_NumberObject, | - |
| 139 | Type_StringObject, | - |
| 140 | Type_SymbolObject, | - |
| 141 | Type_DateObject, | - |
| 142 | Type_RegExpObject, | - |
| 143 | Type_ErrorObject, | - |
| 144 | Type_ArgumentsObject, | - |
| 145 | Type_JsonObject, | - |
| 146 | Type_MathObject, | - |
| 147 | Type_ProxyObject, | - |
| 148 | - | |
| 149 | Type_ExecutionContext, | - |
| 150 | Type_InternalClass, | - |
| 151 | Type_SetIteratorObject, | - |
| 152 | Type_MapIteratorObject, | - |
| 153 | Type_ArrayIteratorObject, | - |
| 154 | Type_StringIteratorObject, | - |
| 155 | Type_ForInIterator, | - |
| 156 | Type_RegExp, | - |
| 157 | - | |
| 158 | Type_QmlSequence | - |
| 159 | }; | - |
| 160 | Q_MANAGED_TYPE(Invalid) | - |
| 161 | - | |
| 162 | Heap::InternalClass *internalClass() const { return d()->internalClass; } executed 1439261680 times by 154 tests: return d()->internalClass;Executed by:
| 1439261680 |
| 163 | const VTable *vtable() const { return d()->internalClass->vtable; } executed 11711836 times by 31 tests: return d()->internalClass->vtable;Executed by:
| 11711836 |
| 164 | inline ExecutionEngine *engine() const { return internalClass()->engine; } executed 887819321 times by 154 tests: return internalClass()->engine;Executed by:
| 887819321 |
| 165 | - | |
| 166 | bool isListType() const { return d()->internalClass->vtable->type == Type_QmlSequence; } executed 30800 times by 46 tests: return d()->internalClass->vtable->type == Type_QmlSequence;Executed by:
| 30800 |
| 167 | bool isArrayLike() const { return isArrayObject() || isListType(); } never executed: return isArrayObject() || isListType(); | 0 |
| 168 | - | |
| 169 | bool isArrayObject() const { return d()->internalClass->vtable->type == Type_ArrayObject; } executed 315433 times by 57 tests: return d()->internalClass->vtable->type == Type_ArrayObject;Executed by:
| 315433 |
| 170 | bool isStringObject() const { return d()->internalClass->vtable->type == Type_StringObject; } executed 81856404 times by 29 tests: return d()->internalClass->vtable->type == Type_StringObject;Executed by:
| 81856404 |
| 171 | bool isSymbolObject() const { return d()->internalClass->vtable->type == Type_SymbolObject; } never executed: return d()->internalClass->vtable->type == Type_SymbolObject; | 0 |
| 172 | - | |
| 173 | QString className() const; | - |
| 174 | - | |
| 175 | bool isEqualTo(const Managed *other) const | - |
| 176 | { return d()->internalClass->vtable->isEqualTo(const_cast<Managed *>(this), const_cast<Managed *>(other)); } executed 11886711 times by 32 tests: return d()->internalClass->vtable->isEqualTo(const_cast<Managed *>(this), const_cast<Managed *>(other));Executed by:
| 11886711 |
| 177 | - | |
| 178 | bool inUse() const { return d()->inUse(); } executed 1277401 times by 27 tests: return d()->inUse();Executed by:
| 1277401 |
| 179 | bool markBit() const { return d()->isMarked(); } executed 2962358 times by 154 tests: return d()->isMarked();Executed by:
| 2962358 |
| 180 | inline void mark(MarkStack *markStack); | - |
| 181 | - | |
| 182 | Q_ALWAYS_INLINE Heap::Base *heapObject() const { | - |
| 183 | return m(); executed 62628 times by 35 tests: return m();Executed by:
| 62628 |
| 184 | } | - |
| 185 | - | |
| 186 | template<typename T> inline T *cast() { | - |
| 187 | return static_cast<T *>(this); executed 98779 times by 154 tests: return static_cast<T *>(this);Executed by:
| 98779 |
| 188 | } | - |
| 189 | template<typename T> inline const T *cast() const { | - |
| 190 | return static_cast<const T *>(this); executed 4 times by 1 test: return static_cast<const T *>(this);Executed by:
| 4 |
| 191 | } | - |
| 192 | - | |
| 193 | protected: | - |
| 194 | static bool virtualIsEqualTo(Managed *m, Managed *other); | - |
| 195 | - | |
| 196 | private: | - |
| 197 | friend class MemoryManager; | - |
| 198 | friend struct Identifiers; | - |
| 199 | friend struct ObjectIterator; | - |
| 200 | }; | - |
| 201 | - | |
| 202 | inline void Managed::mark(MarkStack *markStack) | - |
| 203 | { | - |
| 204 | Q_ASSERT(m()); | - |
| 205 | m()->mark(markStack); | - |
| 206 | } executed 1476199 times by 27 tests: end of blockExecuted by:
| 1476199 |
| 207 | - | |
| 208 | template<> | - |
| 209 | inline const Managed *Value::as() const { | - |
| 210 | return managed(); executed 99759 times by 21 tests: return managed();Executed by:
| 99759 |
| 211 | } | - |
| 212 | - | |
| 213 | template<> | - |
| 214 | inline const Object *Value::as() const { | - |
| 215 | return objectValue(); executed 62712486 times by 154 tests: return objectValue();Executed by:
| 62712486 |
| 216 | } | - |
| 217 | - | |
| 218 | - | |
| 219 | struct InternalClass : Managed | - |
| 220 | { | - |
| 221 | V4_MANAGED_ITSELF(InternalClass, Managed) never executed: end of blocknever executed: end of blockexecuted 99198 times by 154 tests: return &static_vtbl;Executed by:
executed 289076219 times by 154 tests: return static_cast<QV4::Heap::InternalClass *>(m());Executed by:
executed 289412480 times by 154 tests: return dptr;Executed by:
| 0-289412480 |
| 222 | Q_MANAGED_TYPE(InternalClass) | - |
| 223 | V4_INTERNALCLASS(Empty) never executed: return e->internalClasses(QV4::EngineBase::Class_Empty); | 0 |
| 224 | V4_NEEDS_DESTROY executed 72685390 times by 154 tests: end of blockExecuted by:
| 72685390 |
| 225 | - | |
| 226 | Q_REQUIRED_RESULT Heap::InternalClass *changeVTable(const VTable *vt) { | - |
| 227 | return d()->changeVTable(vt); executed 46489866 times by 154 tests: return d()->changeVTable(vt);Executed by:
| 46489866 |
| 228 | } | - |
| 229 | Q_REQUIRED_RESULT Heap::InternalClass *changePrototype(Heap::Object *proto) { | - |
| 230 | return d()->changePrototype(proto); executed 52485428 times by 154 tests: return d()->changePrototype(proto);Executed by:
| 52485428 |
| 231 | } | - |
| 232 | Q_REQUIRED_RESULT Heap::InternalClass *addMember(PropertyKey identifier, PropertyAttributes data, uint *index = 0) { | - |
| 233 | return d()->addMember(identifier, data, index); executed 21915465 times by 154 tests: return d()->addMember(identifier, data, index);Executed by:
| 21915465 |
| 234 | } | - |
| 235 | - | |
| 236 | void operator =(Heap::InternalClass *ic) { | - |
| 237 | Value::operator=(ic); | - |
| 238 | } never executed: end of block | 0 |
| 239 | }; | - |
| 240 | - | |
| 241 | } | - |
| 242 | - | |
| 243 | - | |
| 244 | QT_END_NAMESPACE | - |
| 245 | - | |
| 246 | #endif | - |
| Source code | Switch to Preprocessed file |