| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4persistent_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 QV4PERSISTENT_H | - | ||||||
| 40 | #define QV4PERSISTENT_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 "qv4value_p.h" | - | ||||||
| 54 | #include "qv4managed_p.h" | - | ||||||
| 55 | - | |||||||
| 56 | QT_BEGIN_NAMESPACE | - | ||||||
| 57 | - | |||||||
| 58 | namespace QV4 { | - | ||||||
| 59 | - | |||||||
| 60 | struct Q_QML_EXPORT PersistentValueStorage | - | ||||||
| 61 | { | - | ||||||
| 62 | PersistentValueStorage(ExecutionEngine *engine); | - | ||||||
| 63 | ~PersistentValueStorage(); | - | ||||||
| 64 | - | |||||||
| 65 | Value *allocate(); | - | ||||||
| 66 | static void free(Value *e); | - | ||||||
| 67 | - | |||||||
| 68 | void mark(MarkStack *markStack); | - | ||||||
| 69 | - | |||||||
| 70 | struct Iterator { | - | ||||||
| 71 | Iterator(void *p, int idx); | - | ||||||
| 72 | Iterator(const Iterator &o); | - | ||||||
| 73 | Iterator & operator=(const Iterator &o); | - | ||||||
| 74 | ~Iterator(); | - | ||||||
| 75 | void *p; | - | ||||||
| 76 | int index; | - | ||||||
| 77 | Iterator &operator++(); | - | ||||||
| 78 | bool operator !=(const Iterator &other) { | - | ||||||
| 79 | return p != other.p || index != other.index; executed 118051618 times by 154 tests: return p != other.p || index != other.index;Executed by:
| 118051618 | ||||||
| 80 | } | - | ||||||
| 81 | Value &operator *(); | - | ||||||
| 82 | }; | - | ||||||
| 83 | Iterator begin() { return Iterator(firstPage, 0); } executed 223946 times by 154 tests: return Iterator(firstPage, 0);Executed by:
| 223946 | ||||||
| 84 | Iterator end() { return Iterator(nullptr, 0); } executed 117999173 times by 154 tests: return Iterator(nullptr, 0);Executed by:
| 117999173 | ||||||
| 85 | - | |||||||
| 86 | static ExecutionEngine *getEngine(Value *v); | - | ||||||
| 87 | - | |||||||
| 88 | ExecutionEngine *engine; | - | ||||||
| 89 | void *firstPage; | - | ||||||
| 90 | private: | - | ||||||
| 91 | static void freePage(void *page); | - | ||||||
| 92 | }; | - | ||||||
| 93 | - | |||||||
| 94 | class Q_QML_EXPORT PersistentValue | - | ||||||
| 95 | { | - | ||||||
| 96 | public: | - | ||||||
| 97 | PersistentValue() {} | - | ||||||
| 98 | PersistentValue(const PersistentValue &other); | - | ||||||
| 99 | PersistentValue &operator=(const PersistentValue &other); | - | ||||||
| 100 | PersistentValue &operator=(const WeakValue &other); | - | ||||||
| 101 | PersistentValue &operator=(Object *object); | - | ||||||
| 102 | ~PersistentValue(); | - | ||||||
| 103 | - | |||||||
| 104 | PersistentValue(ExecutionEngine *engine, const Value &value); | - | ||||||
| 105 | PersistentValue(ExecutionEngine *engine, ReturnedValue value); | - | ||||||
| 106 | PersistentValue(ExecutionEngine *engine, Object *object); | - | ||||||
| 107 | - | |||||||
| 108 | void set(ExecutionEngine *engine, const Value &value); | - | ||||||
| 109 | void set(ExecutionEngine *engine, ReturnedValue value); | - | ||||||
| 110 | void set(ExecutionEngine *engine, Heap::Base *obj); | - | ||||||
| 111 | - | |||||||
| 112 | ReturnedValue value() const { | - | ||||||
| 113 | return (val ? val->asReturnedValue() : Encode::undefined()); executed 1177898 times by 131 tests: return (val ? val->asReturnedValue() : Encode::undefined());Executed by:
| 1177898 | ||||||
| 114 | } | - | ||||||
| 115 | Value *valueRef() const { | - | ||||||
| 116 | return val; executed 5139314 times by 129 tests: return val;Executed by:
| 5139314 | ||||||
| 117 | } | - | ||||||
| 118 | Managed *asManaged() const { | - | ||||||
| 119 | if (!val)
| 0 | ||||||
| 120 | return nullptr; never executed: return nullptr; | 0 | ||||||
| 121 | return val->managed(); never executed: return val->managed(); | 0 | ||||||
| 122 | } | - | ||||||
| 123 | template<typename T> | - | ||||||
| 124 | T *as() const { | - | ||||||
| 125 | if (!val)
| 76-275573 | ||||||
| 126 | return nullptr; executed 76 times by 2 tests: return nullptr;Executed by:
| 76 | ||||||
| 127 | return val->as<T>(); executed 275573 times by 69 tests: return val->as<T>();Executed by:
| 275573 | ||||||
| 128 | } | - | ||||||
| 129 | - | |||||||
| 130 | ExecutionEngine *engine() const { | - | ||||||
| 131 | if (!val)
| 6-3944 | ||||||
| 132 | return nullptr; executed 6 times by 1 test: return nullptr;Executed by:
| 6 | ||||||
| 133 | return PersistentValueStorage::getEngine(val); executed 3944 times by 12 tests: return PersistentValueStorage::getEngine(val);Executed by:
| 3944 | ||||||
| 134 | } | - | ||||||
| 135 | - | |||||||
| 136 | bool isUndefined() const { return !val || val->isUndefined(); } executed 153437 times by 39 tests: return !val || val->isUndefined();Executed by:
| 153437 | ||||||
| 137 | bool isNullOrUndefined() const { return !val || val->isNullOrUndefined(); } executed 398 times by 13 tests: return !val || val->isNullOrUndefined();Executed by:
| 398 | ||||||
| 138 | void clear() { | - | ||||||
| 139 | PersistentValueStorage::free(val); | - | ||||||
| 140 | val = nullptr; | - | ||||||
| 141 | } executed 385434 times by 150 tests: end of blockExecuted by:
| 385434 | ||||||
| 142 | bool isEmpty() { return !val; } never executed: return !val; | 0 | ||||||
| 143 | - | |||||||
| 144 | private: | - | ||||||
| 145 | Value *val = nullptr; | - | ||||||
| 146 | }; | - | ||||||
| 147 | - | |||||||
| 148 | class Q_QML_EXPORT WeakValue | - | ||||||
| 149 | { | - | ||||||
| 150 | public: | - | ||||||
| 151 | WeakValue() {} | - | ||||||
| 152 | WeakValue(const WeakValue &other); | - | ||||||
| 153 | WeakValue(ExecutionEngine *engine, const Value &value); | - | ||||||
| 154 | WeakValue &operator=(const WeakValue &other); | - | ||||||
| 155 | ~WeakValue(); | - | ||||||
| 156 | - | |||||||
| 157 | void set(ExecutionEngine *engine, const Value &value) | - | ||||||
| 158 | { | - | ||||||
| 159 | if (!val)
| 0-1688113 | ||||||
| 160 | allocVal(engine); executed 1688114 times by 154 tests: allocVal(engine);Executed by:
| 1688114 | ||||||
| 161 | *val = value; | - | ||||||
| 162 | } executed 1688145 times by 154 tests: end of blockExecuted by:
| 1688145 | ||||||
| 163 | - | |||||||
| 164 | void set(ExecutionEngine *engine, ReturnedValue value) | - | ||||||
| 165 | { | - | ||||||
| 166 | if (!val)
| 0-6 | ||||||
| 167 | allocVal(engine); executed 6 times by 1 test: allocVal(engine);Executed by:
| 6 | ||||||
| 168 | *val = value; | - | ||||||
| 169 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||
| 170 | - | |||||||
| 171 | void set(ExecutionEngine *engine, Heap::Base *obj) | - | ||||||
| 172 | { | - | ||||||
| 173 | if (!val)
| 2-66349 | ||||||
| 174 | allocVal(engine); executed 66349 times by 99 tests: allocVal(engine);Executed by:
| 66349 | ||||||
| 175 | *val = obj; | - | ||||||
| 176 | } executed 66351 times by 99 tests: end of blockExecuted by:
| 66351 | ||||||
| 177 | - | |||||||
| 178 | ReturnedValue value() const { | - | ||||||
| 179 | return (val ? val->asReturnedValue() : Encode::undefined()); executed 7676491 times by 135 tests: return (val ? val->asReturnedValue() : Encode::undefined());Executed by:
| 7676491 | ||||||
| 180 | } | - | ||||||
| 181 | Value *valueRef() const { | - | ||||||
| 182 | return val; executed 16 times by 1 test: return val;Executed by:
| 16 | ||||||
| 183 | } | - | ||||||
| 184 | Managed *asManaged() const { | - | ||||||
| 185 | if (!val)
| 0-619899 | ||||||
| 186 | return nullptr; never executed: return nullptr; | 0 | ||||||
| 187 | return val->managed(); executed 619899 times by 99 tests: return val->managed();Executed by:
| 619899 | ||||||
| 188 | } | - | ||||||
| 189 | template <typename T> | - | ||||||
| 190 | T *as() const { | - | ||||||
| 191 | if (!val)
| 3059-1149781 | ||||||
| 192 | return nullptr; executed 1149758 times by 154 tests: return nullptr;Executed by:
| 1149758 | ||||||
| 193 | return val->as<T>(); executed 3059 times by 5 tests: return val->as<T>();Executed by:
| 3059 | ||||||
| 194 | } | - | ||||||
| 195 | - | |||||||
| 196 | ExecutionEngine *engine() const { | - | ||||||
| 197 | if (!val)
| 0-1752672 | ||||||
| 198 | return nullptr; never executed: return nullptr; | 0 | ||||||
| 199 | return PersistentValueStorage::getEngine(val); executed 1752679 times by 154 tests: return PersistentValueStorage::getEngine(val);Executed by:
| 1752679 | ||||||
| 200 | } | - | ||||||
| 201 | - | |||||||
| 202 | bool isUndefined() const { return !val || val->isUndefined(); } executed 13353037 times by 142 tests: return !val || val->isUndefined();Executed by:
| 13353037 | ||||||
| 203 | bool isNullOrUndefined() const { return !val || val->isNullOrUndefined(); } executed 986 times by 12 tests: return !val || val->isNullOrUndefined();Executed by:
| 986 | ||||||
| 204 | void clear() { free(); } executed 59484 times by 56 tests: end of blockExecuted by:
| 59484 | ||||||
| 205 | - | |||||||
| 206 | void markOnce(MarkStack *markStack); | - | ||||||
| 207 | - | |||||||
| 208 | private: | - | ||||||
| 209 | Value *val = nullptr; | - | ||||||
| 210 | - | |||||||
| 211 | private: | - | ||||||
| 212 | Q_NEVER_INLINE void allocVal(ExecutionEngine *engine); | - | ||||||
| 213 | - | |||||||
| 214 | void free(); | - | ||||||
| 215 | }; | - | ||||||
| 216 | - | |||||||
| 217 | } // namespace QV4 | - | ||||||
| 218 | - | |||||||
| 219 | QT_END_NAMESPACE | - | ||||||
| 220 | - | |||||||
| 221 | #endif | - | ||||||
| Source code | Switch to Preprocessed file |