Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4propertykey_p.h |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||
2 | ** | - | ||||||
3 | ** Copyright (C) 2018 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 QV4PROPERTYKEY_H | - | ||||||
40 | #define QV4PROPERTYKEY_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 <private/qv4global_p.h> | - | ||||||
54 | - | |||||||
55 | QT_BEGIN_NAMESPACE | - | ||||||
56 | - | |||||||
57 | class QString; | - | ||||||
58 | - | |||||||
59 | namespace QV4 { | - | ||||||
60 | - | |||||||
61 | struct PropertyKey | - | ||||||
62 | { | - | ||||||
63 | private: | - | ||||||
64 | // Property keys are Strings, Symbols or unsigned integers. | - | ||||||
65 | // For convenience we derive them from Values, allowing us to store them | - | ||||||
66 | // on the JS stack | - | ||||||
67 | // | - | ||||||
68 | // They do however behave somewhat different than a Value: | - | ||||||
69 | // * If the key is a String, the pointer to the string is stored in the identifier | - | ||||||
70 | // table and thus unique. | - | ||||||
71 | // * If the key is a Symbol it simply points to the referenced symbol object | - | ||||||
72 | // * if the key is an array index (a uint < UINT_MAX), it's encoded as an | - | ||||||
73 | // integer value | - | ||||||
74 | quint64 val; | - | ||||||
75 | - | |||||||
76 | // Important: Always keep this in sync with the definitions for Integers and heap objects in Value | - | ||||||
77 | static const quint64 ArrayIndexMask = 0x3800000000000ull; | - | ||||||
78 | enum { | - | ||||||
79 | IsManagedOrUndefined_Shift = 64-15, | - | ||||||
80 | }; | - | ||||||
81 | inline bool isManaged() const { return (val >> IsManagedOrUndefined_Shift) == 0; } executed 1248550206 times by 154 tests: return (val >> IsManagedOrUndefined_Shift) == 0; Executed by:
| 1248550206 | ||||||
82 | inline quint32 value() const { return val & quint64(~quint32(0)); } never executed: return val & quint64(~quint32(0)); | 0 | ||||||
83 | - | |||||||
84 | #if QT_POINTER_SIZE == 8 | - | ||||||
85 | QML_NEARLY_ALWAYS_INLINE Heap::StringOrSymbol *m() const | - | ||||||
86 | { | - | ||||||
87 | Heap::StringOrSymbol *b; | - | ||||||
88 | memcpy(&b, &val, 8); | - | ||||||
89 | return b; executed 855780226 times by 154 tests: return b; Executed by:
| 855780226 | ||||||
90 | } | - | ||||||
91 | QML_NEARLY_ALWAYS_INLINE void setM(Heap::StringOrSymbol *b) | - | ||||||
92 | { | - | ||||||
93 | memcpy(&val, &b, 8); | - | ||||||
94 | } executed 39477573 times by 154 tests: end of block Executed by:
| 39477573 | ||||||
95 | #elif QT_POINTER_SIZE == 4 | - | ||||||
96 | QML_NEARLY_ALWAYS_INLINE Heap::StringOrSymbol *m() const | - | ||||||
97 | { | - | ||||||
98 | Q_STATIC_ASSERT(sizeof(Heap::StringOrSymbol*) == sizeof(quint32)); | - | ||||||
99 | Heap::StringOrSymbol *b; | - | ||||||
100 | quint32 v = value(); | - | ||||||
101 | memcpy(&b, &v, 4); | - | ||||||
102 | return b; | - | ||||||
103 | } | - | ||||||
104 | QML_NEARLY_ALWAYS_INLINE void setM(Heap::StringOrSymbol *b) | - | ||||||
105 | { | - | ||||||
106 | quint32 v; | - | ||||||
107 | memcpy(&v, &b, 4); | - | ||||||
108 | val = v; | - | ||||||
109 | } | - | ||||||
110 | #endif | - | ||||||
111 | - | |||||||
112 | public: | - | ||||||
113 | static PropertyKey invalid() { PropertyKey key; key.val = 0; return key; } executed 50437646 times by 154 tests: return key; Executed by:
| 50437646 | ||||||
114 | static PropertyKey fromArrayIndex(uint idx) { PropertyKey key; key.val = ArrayIndexMask | static_cast<quint64>(idx); return key; } executed 302335 times by 45 tests: return key; Executed by:
| 302335 | ||||||
115 | bool isStringOrSymbol() const { return isManaged() && val != 0; } executed 298361688 times by 154 tests: return isManaged() && val != 0; Executed by:
| 298361688 | ||||||
116 | uint asArrayIndex() const { return (isManaged() || val == 0) ? std::numeric_limits<uint>::max() : static_cast<uint>(val & 0xffffffff); } executed 28853600 times by 153 tests: return (isManaged() || val == 0) ? std::numeric_limits<uint>::max() : static_cast<uint>(val & 0xffffffff); Executed by:
| 28853600 | ||||||
117 | uint isArrayIndex() const { return !isManaged() && val != 0; } executed 67784102 times by 154 tests: return !isManaged() && val != 0; Executed by:
| 67784102 | ||||||
118 | bool isValid() const { return val != 0; } executed 1114834823 times by 154 tests: return val != 0; Executed by:
| 1114834823 | ||||||
119 | static PropertyKey fromStringOrSymbol(Heap::StringOrSymbol *b) | - | ||||||
120 | { PropertyKey key; key.setM(b); return key; } executed 39464339 times by 154 tests: return key; Executed by:
| 39464339 | ||||||
121 | Heap::StringOrSymbol *asStringOrSymbol() const { | - | ||||||
122 | if (!isManaged())
| 10-855712302 | ||||||
123 | return nullptr; executed 10 times by 1 test: return nullptr; Executed by:
| 10 | ||||||
124 | return m(); executed 855727583 times by 154 tests: return m(); Executed by:
| 855727583 | ||||||
125 | } | - | ||||||
126 | - | |||||||
127 | bool isString() const; | - | ||||||
128 | bool isSymbol() const; | - | ||||||
129 | - | |||||||
130 | Q_QML_EXPORT QString toQString() const; | - | ||||||
131 | Heap::StringOrSymbol *toStringOrSymbol(ExecutionEngine *e); | - | ||||||
132 | quint64 id() const { return val; } executed 482529292 times by 154 tests: return val; Executed by:
| 482529292 | ||||||
133 | - | |||||||
134 | bool operator ==(const PropertyKey &other) const { return val == other.val; } executed 794026452 times by 154 tests: return val == other.val; Executed by:
| 794026452 | ||||||
135 | bool operator !=(const PropertyKey &other) const { return val != other.val; } executed 1188 times by 20 tests: return val != other.val; Executed by:
| 1188 | ||||||
136 | bool operator <(const PropertyKey &other) const { return val < other.val; } executed 310282825 times by 154 tests: return val < other.val; Executed by:
| 310282825 | ||||||
137 | }; | - | ||||||
138 | - | |||||||
139 | } | - | ||||||
140 | - | |||||||
141 | QT_END_NAMESPACE | - | ||||||
142 | - | |||||||
143 | #endif | - | ||||||
Source code | Switch to Preprocessed file |