Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/kernel/qmetatype.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||||||||||||||
2 | ** | - | ||||||||||||||||||||||||
3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||||||||||||||
4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||||||||||||||
5 | ** | - | ||||||||||||||||||||||||
6 | ** This file is part of the QtCore module of the Qt Toolkit. | - | ||||||||||||||||||||||||
7 | ** | - | ||||||||||||||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||||||||||||||
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 http://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||||||||
15 | ** information use the contact form at http://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 2.1 or version 3 as published by the Free | - | ||||||||||||||||||||||||
20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||||||||||||||
21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||||||||||||||
22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||||||||||||||
23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||||||||||||||
24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||||||||||||||
25 | ** | - | ||||||||||||||||||||||||
26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||||||||||||||
27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||||||||||||||
28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||||||||||||||
29 | ** | - | ||||||||||||||||||||||||
30 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||||||||
31 | ** | - | ||||||||||||||||||||||||
32 | ****************************************************************************/ | - | ||||||||||||||||||||||||
33 | - | |||||||||||||||||||||||||
34 | #include "qmetatype.h" | - | ||||||||||||||||||||||||
35 | #include "qmetatype_p.h" | - | ||||||||||||||||||||||||
36 | #include "qobjectdefs.h" | - | ||||||||||||||||||||||||
37 | #include "qdatetime.h" | - | ||||||||||||||||||||||||
38 | #include "qbytearray.h" | - | ||||||||||||||||||||||||
39 | #include "qreadwritelock.h" | - | ||||||||||||||||||||||||
40 | #include "qstring.h" | - | ||||||||||||||||||||||||
41 | #include "qstringlist.h" | - | ||||||||||||||||||||||||
42 | #include "qvector.h" | - | ||||||||||||||||||||||||
43 | #include "qlocale.h" | - | ||||||||||||||||||||||||
44 | #include "qeasingcurve.h" | - | ||||||||||||||||||||||||
45 | #include "quuid.h" | - | ||||||||||||||||||||||||
46 | #include "qvariant.h" | - | ||||||||||||||||||||||||
47 | #include "qdatastream.h" | - | ||||||||||||||||||||||||
48 | #include "qmetatypeswitcher_p.h" | - | ||||||||||||||||||||||||
49 | - | |||||||||||||||||||||||||
50 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
51 | # include "qbitarray.h" | - | ||||||||||||||||||||||||
52 | # include "qurl.h" | - | ||||||||||||||||||||||||
53 | # include "qvariant.h" | - | ||||||||||||||||||||||||
54 | # include "qabstractitemmodel.h" | - | ||||||||||||||||||||||||
55 | # include "qregularexpression.h" | - | ||||||||||||||||||||||||
56 | # include "qjsonvalue.h" | - | ||||||||||||||||||||||||
57 | # include "qjsonobject.h" | - | ||||||||||||||||||||||||
58 | # include "qjsonarray.h" | - | ||||||||||||||||||||||||
59 | # include "qjsondocument.h" | - | ||||||||||||||||||||||||
60 | # include "qbytearraylist.h" | - | ||||||||||||||||||||||||
61 | #endif | - | ||||||||||||||||||||||||
62 | - | |||||||||||||||||||||||||
63 | #ifndef QT_NO_GEOM_VARIANT | - | ||||||||||||||||||||||||
64 | # include "qsize.h" | - | ||||||||||||||||||||||||
65 | # include "qpoint.h" | - | ||||||||||||||||||||||||
66 | # include "qrect.h" | - | ||||||||||||||||||||||||
67 | # include "qline.h" | - | ||||||||||||||||||||||||
68 | #endif | - | ||||||||||||||||||||||||
69 | - | |||||||||||||||||||||||||
70 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||
71 | - | |||||||||||||||||||||||||
72 | #define NS(x) QT_PREPEND_NAMESPACE(x) | - | ||||||||||||||||||||||||
73 | - | |||||||||||||||||||||||||
74 | - | |||||||||||||||||||||||||
75 | namespace { | - | ||||||||||||||||||||||||
76 | struct DefinedTypesFilter { | - | ||||||||||||||||||||||||
77 | template<typename T> | - | ||||||||||||||||||||||||
78 | struct Acceptor { | - | ||||||||||||||||||||||||
79 | static const bool IsAccepted = QtMetaTypePrivate::TypeDefinition<T>::IsAvailable && QModulesPrivate::QTypeModuleInfo<T>::IsCore; | - | ||||||||||||||||||||||||
80 | }; | - | ||||||||||||||||||||||||
81 | }; | - | ||||||||||||||||||||||||
82 | } // namespace | - | ||||||||||||||||||||||||
83 | - | |||||||||||||||||||||||||
84 | /*! | - | ||||||||||||||||||||||||
85 | \macro Q_DECLARE_OPAQUE_POINTER(PointerType) | - | ||||||||||||||||||||||||
86 | \relates QMetaType | - | ||||||||||||||||||||||||
87 | \since 5.0 | - | ||||||||||||||||||||||||
88 | - | |||||||||||||||||||||||||
89 | This macro enables pointers to forward-declared types (\a PointerType) | - | ||||||||||||||||||||||||
90 | to be registered with QMetaType using either Q_DECLARE_METATYPE() | - | ||||||||||||||||||||||||
91 | or qRegisterMetaType(). | - | ||||||||||||||||||||||||
92 | - | |||||||||||||||||||||||||
93 | \sa Q_DECLARE_METATYPE(), qRegisterMetaType() | - | ||||||||||||||||||||||||
94 | */ | - | ||||||||||||||||||||||||
95 | - | |||||||||||||||||||||||||
96 | /*! | - | ||||||||||||||||||||||||
97 | \macro Q_DECLARE_METATYPE(Type) | - | ||||||||||||||||||||||||
98 | \relates QMetaType | - | ||||||||||||||||||||||||
99 | - | |||||||||||||||||||||||||
100 | This macro makes the type \a Type known to QMetaType as long as it | - | ||||||||||||||||||||||||
101 | provides a public default constructor, a public copy constructor and | - | ||||||||||||||||||||||||
102 | a public destructor. | - | ||||||||||||||||||||||||
103 | It is needed to use the type \a Type as a custom type in QVariant. | - | ||||||||||||||||||||||||
104 | - | |||||||||||||||||||||||||
105 | This macro requires that \a Type is a fully defined type at the point where | - | ||||||||||||||||||||||||
106 | it is used. For pointer types, it also requires that the pointed to type is | - | ||||||||||||||||||||||||
107 | fully defined. Use in conjunction with Q_DECLARE_OPAQUE_POINTER() to | - | ||||||||||||||||||||||||
108 | register pointers to forward declared types. | - | ||||||||||||||||||||||||
109 | - | |||||||||||||||||||||||||
110 | Ideally, this macro should be placed below the declaration of | - | ||||||||||||||||||||||||
111 | the class or struct. If that is not possible, it can be put in | - | ||||||||||||||||||||||||
112 | a private header file which has to be included every time that | - | ||||||||||||||||||||||||
113 | type is used in a QVariant. | - | ||||||||||||||||||||||||
114 | - | |||||||||||||||||||||||||
115 | Adding a Q_DECLARE_METATYPE() makes the type known to all template | - | ||||||||||||||||||||||||
116 | based functions, including QVariant. Note that if you intend to | - | ||||||||||||||||||||||||
117 | use the type in \e queued signal and slot connections or in | - | ||||||||||||||||||||||||
118 | QObject's property system, you also have to call | - | ||||||||||||||||||||||||
119 | qRegisterMetaType() since the names are resolved at runtime. | - | ||||||||||||||||||||||||
120 | - | |||||||||||||||||||||||||
121 | This example shows a typical use case of Q_DECLARE_METATYPE(): | - | ||||||||||||||||||||||||
122 | - | |||||||||||||||||||||||||
123 | \snippet code/src_corelib_kernel_qmetatype.cpp 0 | - | ||||||||||||||||||||||||
124 | - | |||||||||||||||||||||||||
125 | If \c MyStruct is in a namespace, the Q_DECLARE_METATYPE() macro | - | ||||||||||||||||||||||||
126 | has to be outside the namespace: | - | ||||||||||||||||||||||||
127 | - | |||||||||||||||||||||||||
128 | \snippet code/src_corelib_kernel_qmetatype.cpp 1 | - | ||||||||||||||||||||||||
129 | - | |||||||||||||||||||||||||
130 | Since \c{MyStruct} is now known to QMetaType, it can be used in QVariant: | - | ||||||||||||||||||||||||
131 | - | |||||||||||||||||||||||||
132 | \snippet code/src_corelib_kernel_qmetatype.cpp 2 | - | ||||||||||||||||||||||||
133 | - | |||||||||||||||||||||||||
134 | Some types are registered automatically and do not need this macro: | - | ||||||||||||||||||||||||
135 | - | |||||||||||||||||||||||||
136 | \list | - | ||||||||||||||||||||||||
137 | \li Pointers to classes derived from QObject | - | ||||||||||||||||||||||||
138 | \li QList<T>, QVector<T>, QQueue<T>, QStack<T>, QSet<T> or QLinkedList<T> | - | ||||||||||||||||||||||||
139 | where T is a registered meta type | - | ||||||||||||||||||||||||
140 | \li QHash<T1, T2>, QMap<T1, T2> or QPair<T1, T2> where T1 and T2 are | - | ||||||||||||||||||||||||
141 | registered meta types | - | ||||||||||||||||||||||||
142 | \li QPointer<T>, QSharedPointer<T>, QWeakPointer<T>, where T is a class that derives from QObject | - | ||||||||||||||||||||||||
143 | \li Enumerations registered with Q_ENUM or Q_FLAG | - | ||||||||||||||||||||||||
144 | \li Classes that have a Q_GADGET macro | - | ||||||||||||||||||||||||
145 | \endlist | - | ||||||||||||||||||||||||
146 | - | |||||||||||||||||||||||||
147 | \sa qRegisterMetaType() | - | ||||||||||||||||||||||||
148 | */ | - | ||||||||||||||||||||||||
149 | - | |||||||||||||||||||||||||
150 | /*! | - | ||||||||||||||||||||||||
151 | \macro Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE(Container) | - | ||||||||||||||||||||||||
152 | \relates QMetaType | - | ||||||||||||||||||||||||
153 | - | |||||||||||||||||||||||||
154 | This macro makes the container \a Container known to QMetaType as a sequential | - | ||||||||||||||||||||||||
155 | container. This makes it possible to put an instance of Container<T> into | - | ||||||||||||||||||||||||
156 | a QVariant, if T itself is known to QMetaType. | - | ||||||||||||||||||||||||
157 | - | |||||||||||||||||||||||||
158 | Note that all of the Qt sequential containers already have built-in | - | ||||||||||||||||||||||||
159 | support, and it is not necessary to use this macro with them. The | - | ||||||||||||||||||||||||
160 | std::vector and std::list containers also have built-in support. | - | ||||||||||||||||||||||||
161 | - | |||||||||||||||||||||||||
162 | This example shows a typical use of Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE(): | - | ||||||||||||||||||||||||
163 | - | |||||||||||||||||||||||||
164 | \snippet code/src_corelib_kernel_qmetatype.cpp 10 | - | ||||||||||||||||||||||||
165 | */ | - | ||||||||||||||||||||||||
166 | - | |||||||||||||||||||||||||
167 | /*! | - | ||||||||||||||||||||||||
168 | \macro Q_DECLARE_ASSOCIATIVE_CONTAINER_METATYPE(Container) | - | ||||||||||||||||||||||||
169 | \relates QMetaType | - | ||||||||||||||||||||||||
170 | - | |||||||||||||||||||||||||
171 | This macro makes the container \a Container known to QMetaType as an associative | - | ||||||||||||||||||||||||
172 | container. This makes it possible to put an instance of Container<T, U> into | - | ||||||||||||||||||||||||
173 | a QVariant, if T and U are themselves known to QMetaType. | - | ||||||||||||||||||||||||
174 | - | |||||||||||||||||||||||||
175 | Note that all of the Qt associative containers already have built-in | - | ||||||||||||||||||||||||
176 | support, and it is not necessary to use this macro with them. The | - | ||||||||||||||||||||||||
177 | std::map container also has built-in support. | - | ||||||||||||||||||||||||
178 | - | |||||||||||||||||||||||||
179 | This example shows a typical use of Q_DECLARE_ASSOCIATIVE_CONTAINER_METATYPE(): | - | ||||||||||||||||||||||||
180 | - | |||||||||||||||||||||||||
181 | \snippet code/src_corelib_kernel_qmetatype.cpp 11 | - | ||||||||||||||||||||||||
182 | */ | - | ||||||||||||||||||||||||
183 | - | |||||||||||||||||||||||||
184 | /*! | - | ||||||||||||||||||||||||
185 | \macro Q_DECLARE_SMART_POINTER_METATYPE(SmartPointer) | - | ||||||||||||||||||||||||
186 | \relates QMetaType | - | ||||||||||||||||||||||||
187 | - | |||||||||||||||||||||||||
188 | This macro makes the smart pointer \a SmartPointer known to QMetaType as a | - | ||||||||||||||||||||||||
189 | smart pointer. This makes it possible to put an instance of SmartPointer<T> into | - | ||||||||||||||||||||||||
190 | a QVariant, if T is a type which inherits QObject. | - | ||||||||||||||||||||||||
191 | - | |||||||||||||||||||||||||
192 | Note that the QWeakPointer, QSharedPointer and QPointer already have built-in | - | ||||||||||||||||||||||||
193 | support, and it is not necessary to use this macro with them. | - | ||||||||||||||||||||||||
194 | - | |||||||||||||||||||||||||
195 | This example shows a typical use of Q_DECLARE_SMART_POINTER_METATYPE(): | - | ||||||||||||||||||||||||
196 | - | |||||||||||||||||||||||||
197 | \snippet code/src_corelib_kernel_qmetatype.cpp 13 | - | ||||||||||||||||||||||||
198 | */ | - | ||||||||||||||||||||||||
199 | - | |||||||||||||||||||||||||
200 | /*! | - | ||||||||||||||||||||||||
201 | \enum QMetaType::Type | - | ||||||||||||||||||||||||
202 | - | |||||||||||||||||||||||||
203 | These are the built-in types supported by QMetaType: | - | ||||||||||||||||||||||||
204 | Read doc on QChar | - | ||||||||||||||||||||||||
205 | Read doc on \l QChar | - | ||||||||||||||||||||||||
206 | - | |||||||||||||||||||||||||
207 | \value Void \c void | - | ||||||||||||||||||||||||
208 | \value Bool \c bool | - | ||||||||||||||||||||||||
209 | \value Int \c int | - | ||||||||||||||||||||||||
210 | \value UInt \c{unsigned int} | - | ||||||||||||||||||||||||
211 | \value Double \c double | - | ||||||||||||||||||||||||
212 | \value QChar QChar | - | ||||||||||||||||||||||||
213 | \value QString QString | - | ||||||||||||||||||||||||
214 | \value QByteArray QByteArray | - | ||||||||||||||||||||||||
215 | - | |||||||||||||||||||||||||
216 | \value VoidStar \c{void *} | - | ||||||||||||||||||||||||
217 | \value Long \c{long} | - | ||||||||||||||||||||||||
218 | \value LongLong LongLong | - | ||||||||||||||||||||||||
219 | \value Short \c{short} | - | ||||||||||||||||||||||||
220 | \value Char \c{char} | - | ||||||||||||||||||||||||
221 | \value ULong \c{unsigned long} | - | ||||||||||||||||||||||||
222 | \value ULongLong ULongLong | - | ||||||||||||||||||||||||
223 | \value UShort \c{unsigned short} | - | ||||||||||||||||||||||||
224 | \value SChar \c{signed char} | - | ||||||||||||||||||||||||
225 | \value UChar \c{unsigned char} | - | ||||||||||||||||||||||||
226 | \value Float \c float | - | ||||||||||||||||||||||||
227 | \value QObjectStar QObject * | - | ||||||||||||||||||||||||
228 | \value QVariant QVariant | - | ||||||||||||||||||||||||
229 | - | |||||||||||||||||||||||||
230 | \value QCursor QCursor | - | ||||||||||||||||||||||||
231 | \value QDate QDate | - | ||||||||||||||||||||||||
232 | \value QSize QSize | - | ||||||||||||||||||||||||
233 | \value QTime QTime | - | ||||||||||||||||||||||||
234 | \value QVariantList QVariantList | - | ||||||||||||||||||||||||
235 | \value QPolygon QPolygon | - | ||||||||||||||||||||||||
236 | \value QPolygonF QPolygonF | - | ||||||||||||||||||||||||
237 | \value QColor QColor | - | ||||||||||||||||||||||||
238 | \value QSizeF QSizeF | - | ||||||||||||||||||||||||
239 | \value QRectF QRectF | - | ||||||||||||||||||||||||
240 | \value QLine QLine | - | ||||||||||||||||||||||||
241 | \value QTextLength QTextLength | - | ||||||||||||||||||||||||
242 | \value QStringList QStringList | - | ||||||||||||||||||||||||
243 | \value QVariantMap QVariantMap | - | ||||||||||||||||||||||||
244 | \value QVariantHash QVariantHash | - | ||||||||||||||||||||||||
245 | \value QIcon QIcon | - | ||||||||||||||||||||||||
246 | \value QPen QPen | - | ||||||||||||||||||||||||
247 | \value QLineF QLineF | - | ||||||||||||||||||||||||
248 | \value QTextFormat QTextFormat | - | ||||||||||||||||||||||||
249 | \value QRect QRect | - | ||||||||||||||||||||||||
250 | \value QPoint QPoint | - | ||||||||||||||||||||||||
251 | \value QUrl QUrl | - | ||||||||||||||||||||||||
252 | \value QRegExp QRegExp | - | ||||||||||||||||||||||||
253 | \value QRegularExpression QRegularExpression | - | ||||||||||||||||||||||||
254 | \value QDateTime QDateTime | - | ||||||||||||||||||||||||
255 | \value QPointF QPointF | - | ||||||||||||||||||||||||
256 | \value QPalette QPalette | - | ||||||||||||||||||||||||
257 | \value QFont QFont | - | ||||||||||||||||||||||||
258 | \value QBrush QBrush | - | ||||||||||||||||||||||||
259 | \value QRegion QRegion | - | ||||||||||||||||||||||||
260 | \value QBitArray QBitArray | - | ||||||||||||||||||||||||
261 | \value QImage QImage | - | ||||||||||||||||||||||||
262 | \value QKeySequence QKeySequence | - | ||||||||||||||||||||||||
263 | \value QSizePolicy QSizePolicy | - | ||||||||||||||||||||||||
264 | \value QPixmap QPixmap | - | ||||||||||||||||||||||||
265 | \value QLocale QLocale | - | ||||||||||||||||||||||||
266 | \value QBitmap QBitmap | - | ||||||||||||||||||||||||
267 | \value QMatrix QMatrix | - | ||||||||||||||||||||||||
268 | \value QTransform QTransform | - | ||||||||||||||||||||||||
269 | \value QMatrix4x4 QMatrix4x4 | - | ||||||||||||||||||||||||
270 | \value QVector2D QVector2D | - | ||||||||||||||||||||||||
271 | \value QVector3D QVector3D | - | ||||||||||||||||||||||||
272 | \value QVector4D QVector4D | - | ||||||||||||||||||||||||
273 | \value QQuaternion QQuaternion | - | ||||||||||||||||||||||||
274 | \value QEasingCurve QEasingCurve | - | ||||||||||||||||||||||||
275 | \value QJsonValue QJsonValue | - | ||||||||||||||||||||||||
276 | \value QJsonObject QJsonObject | - | ||||||||||||||||||||||||
277 | \value QJsonArray QJsonArray | - | ||||||||||||||||||||||||
278 | \value QJsonDocument QJsonDocument | - | ||||||||||||||||||||||||
279 | \value QModelIndex QModelIndex | - | ||||||||||||||||||||||||
280 | \value QPersistentModelIndex QPersistentModelIndex (since 5.5) | - | ||||||||||||||||||||||||
281 | \value QUuid QUuid | - | ||||||||||||||||||||||||
282 | \value QByteArrayList QByteArrayList | - | ||||||||||||||||||||||||
283 | - | |||||||||||||||||||||||||
284 | \value User Base value for user types | - | ||||||||||||||||||||||||
285 | \value UnknownType This is an invalid type id. It is returned from QMetaType for types that are not registered | - | ||||||||||||||||||||||||
286 | - | |||||||||||||||||||||||||
287 | Additional types can be registered using Q_DECLARE_METATYPE(). | - | ||||||||||||||||||||||||
288 | - | |||||||||||||||||||||||||
289 | \sa type(), typeName() | - | ||||||||||||||||||||||||
290 | */ | - | ||||||||||||||||||||||||
291 | - | |||||||||||||||||||||||||
292 | /*! | - | ||||||||||||||||||||||||
293 | \enum QMetaType::TypeFlag | - | ||||||||||||||||||||||||
294 | - | |||||||||||||||||||||||||
295 | The enum describes attributes of a type supported by QMetaType. | - | ||||||||||||||||||||||||
296 | - | |||||||||||||||||||||||||
297 | \value NeedsConstruction This type has non-trivial constructors. If the flag is not set instances can be safely initialized with memset to 0. | - | ||||||||||||||||||||||||
298 | \value NeedsDestruction This type has a non-trivial destructor. If the flag is not set calls to the destructor are not necessary before discarding objects. | - | ||||||||||||||||||||||||
299 | \value MovableType An instance of a type having this attribute can be safely moved by memcpy. | - | ||||||||||||||||||||||||
300 | \omitvalue SharedPointerToQObject | - | ||||||||||||||||||||||||
301 | \value IsEnumeration This type is an enumeration | - | ||||||||||||||||||||||||
302 | \value PointerToQObject This type is a pointer to a derived of QObject | - | ||||||||||||||||||||||||
303 | \omitvalue WeakPointerToQObject | - | ||||||||||||||||||||||||
304 | \omitvalue TrackingPointerToQObject | - | ||||||||||||||||||||||||
305 | \omitvalue WasDeclaredAsMetaType | - | ||||||||||||||||||||||||
306 | \omitvalue IsGadget This type is a Q_GADGET and it's corresponding QMetaObject can be accessed with QMetaType::metaObject Since 5.5. | - | ||||||||||||||||||||||||
307 | */ | - | ||||||||||||||||||||||||
308 | - | |||||||||||||||||||||||||
309 | /*! | - | ||||||||||||||||||||||||
310 | \class QMetaType | - | ||||||||||||||||||||||||
311 | \inmodule QtCore | - | ||||||||||||||||||||||||
312 | \brief The QMetaType class manages named types in the meta-object system. | - | ||||||||||||||||||||||||
313 | - | |||||||||||||||||||||||||
314 | \ingroup objectmodel | - | ||||||||||||||||||||||||
315 | \threadsafe | - | ||||||||||||||||||||||||
316 | - | |||||||||||||||||||||||||
317 | The class is used as a helper to marshall types in QVariant and | - | ||||||||||||||||||||||||
318 | in queued signals and slots connections. It associates a type | - | ||||||||||||||||||||||||
319 | name to a type so that it can be created and destructed | - | ||||||||||||||||||||||||
320 | dynamically at run-time. Declare new types with Q_DECLARE_METATYPE() | - | ||||||||||||||||||||||||
321 | to make them available to QVariant and other template-based functions. | - | ||||||||||||||||||||||||
322 | Call qRegisterMetaType() to make types available to non-template based | - | ||||||||||||||||||||||||
323 | functions, such as the queued signal and slot connections. | - | ||||||||||||||||||||||||
324 | - | |||||||||||||||||||||||||
325 | Any class or struct that has a public default | - | ||||||||||||||||||||||||
326 | constructor, a public copy constructor, and a public destructor | - | ||||||||||||||||||||||||
327 | can be registered. | - | ||||||||||||||||||||||||
328 | - | |||||||||||||||||||||||||
329 | The following code allocates and destructs an instance of | - | ||||||||||||||||||||||||
330 | \c{MyClass}: | - | ||||||||||||||||||||||||
331 | - | |||||||||||||||||||||||||
332 | \snippet code/src_corelib_kernel_qmetatype.cpp 3 | - | ||||||||||||||||||||||||
333 | - | |||||||||||||||||||||||||
334 | If we want the stream operators \c operator<<() and \c | - | ||||||||||||||||||||||||
335 | operator>>() to work on QVariant objects that store custom types, | - | ||||||||||||||||||||||||
336 | the custom type must provide \c operator<<() and \c operator>>() | - | ||||||||||||||||||||||||
337 | operators. | - | ||||||||||||||||||||||||
338 | - | |||||||||||||||||||||||||
339 | \sa Q_DECLARE_METATYPE(), QVariant::setValue(), QVariant::value(), QVariant::fromValue() | - | ||||||||||||||||||||||||
340 | */ | - | ||||||||||||||||||||||||
341 | - | |||||||||||||||||||||||||
342 | /*! | - | ||||||||||||||||||||||||
343 | \fn bool QMetaType::isValid() const | - | ||||||||||||||||||||||||
344 | \since 5.0 | - | ||||||||||||||||||||||||
345 | - | |||||||||||||||||||||||||
346 | Returns \c true if this QMetaType object contains valid | - | ||||||||||||||||||||||||
347 | information about a type, false otherwise. | - | ||||||||||||||||||||||||
348 | */ | - | ||||||||||||||||||||||||
349 | - | |||||||||||||||||||||||||
350 | /*! | - | ||||||||||||||||||||||||
351 | \fn bool QMetaType::isRegistered() const | - | ||||||||||||||||||||||||
352 | \since 5.0 | - | ||||||||||||||||||||||||
353 | - | |||||||||||||||||||||||||
354 | Returns \c true if this QMetaType object contains valid | - | ||||||||||||||||||||||||
355 | information about a type, false otherwise. | - | ||||||||||||||||||||||||
356 | */ | - | ||||||||||||||||||||||||
357 | - | |||||||||||||||||||||||||
358 | /*! | - | ||||||||||||||||||||||||
359 | \fn bool QMetaType::sizeOf() const | - | ||||||||||||||||||||||||
360 | \since 5.0 | - | ||||||||||||||||||||||||
361 | - | |||||||||||||||||||||||||
362 | Returns the size of the type in bytes (i.e. sizeof(T), | - | ||||||||||||||||||||||||
363 | where T is the actual type for which this QMetaType instance | - | ||||||||||||||||||||||||
364 | was constructed for). | - | ||||||||||||||||||||||||
365 | - | |||||||||||||||||||||||||
366 | This function is typically used together with construct() | - | ||||||||||||||||||||||||
367 | to perform low-level management of the memory used by a type. | - | ||||||||||||||||||||||||
368 | - | |||||||||||||||||||||||||
369 | \sa QMetaType::construct(), QMetaType::sizeOf() | - | ||||||||||||||||||||||||
370 | */ | - | ||||||||||||||||||||||||
371 | - | |||||||||||||||||||||||||
372 | /*! | - | ||||||||||||||||||||||||
373 | \fn TypeFlags QMetaType::flags() const | - | ||||||||||||||||||||||||
374 | \since 5.0 | - | ||||||||||||||||||||||||
375 | - | |||||||||||||||||||||||||
376 | Returns flags of the type for which this QMetaType instance was constructed. | - | ||||||||||||||||||||||||
377 | - | |||||||||||||||||||||||||
378 | \sa QMetaType::TypeFlags, QMetaType::typeFlags() | - | ||||||||||||||||||||||||
379 | */ | - | ||||||||||||||||||||||||
380 | - | |||||||||||||||||||||||||
381 | /*! | - | ||||||||||||||||||||||||
382 | \fn const QMetaObject *QMetaType::metaObject() const | - | ||||||||||||||||||||||||
383 | \since 5.5 | - | ||||||||||||||||||||||||
384 | - | |||||||||||||||||||||||||
385 | return a QMetaObject relative to this type. | - | ||||||||||||||||||||||||
386 | - | |||||||||||||||||||||||||
387 | If the type is a pointer type to a subclass of QObject, flags() contains | - | ||||||||||||||||||||||||
388 | QMetaType::PointerToQObject and this function returns the corresponding QMetaObject. This can | - | ||||||||||||||||||||||||
389 | be used to in combinaison with QMetaObject::construct to create QObject of this type. | - | ||||||||||||||||||||||||
390 | - | |||||||||||||||||||||||||
391 | If the type is a Q_GADGET, flags() contains QMetaType::IsGadget, and this function returns its | - | ||||||||||||||||||||||||
392 | QMetaObject. This can be used to retrieve QMetaMethod and QMetaProperty and use them on a | - | ||||||||||||||||||||||||
393 | pointer of this type. (given by QVariant::data for example) | - | ||||||||||||||||||||||||
394 | - | |||||||||||||||||||||||||
395 | If the type is an enumeration, flags() contains QMetaType::IsEnumeration, and this function | - | ||||||||||||||||||||||||
396 | returns the QMetaObject of the enclosing object if the enum was registered as a Q_ENUM or 0 | - | ||||||||||||||||||||||||
397 | otherwise | - | ||||||||||||||||||||||||
398 | - | |||||||||||||||||||||||||
399 | \sa QMetaType::metaObjectForType(), QMetaType::flags() | - | ||||||||||||||||||||||||
400 | */ | - | ||||||||||||||||||||||||
401 | - | |||||||||||||||||||||||||
402 | /*! | - | ||||||||||||||||||||||||
403 | \fn void *QMetaType::create(const void *copy = 0) const | - | ||||||||||||||||||||||||
404 | \since 5.0 | - | ||||||||||||||||||||||||
405 | - | |||||||||||||||||||||||||
406 | Returns a copy of \a copy, assuming it is of the type that this | - | ||||||||||||||||||||||||
407 | QMetaType instance was created for. If \a copy is null, creates | - | ||||||||||||||||||||||||
408 | a default constructed instance. | - | ||||||||||||||||||||||||
409 | - | |||||||||||||||||||||||||
410 | \sa QMetaType::destroy() | - | ||||||||||||||||||||||||
411 | */ | - | ||||||||||||||||||||||||
412 | - | |||||||||||||||||||||||||
413 | /*! | - | ||||||||||||||||||||||||
414 | \fn void QMetaType::destroy(void *data) const | - | ||||||||||||||||||||||||
415 | \since 5.0 | - | ||||||||||||||||||||||||
416 | - | |||||||||||||||||||||||||
417 | Destroys the \a data, assuming it is of the type that this | - | ||||||||||||||||||||||||
418 | QMetaType instance was created for. | - | ||||||||||||||||||||||||
419 | - | |||||||||||||||||||||||||
420 | \sa QMetaType::create() | - | ||||||||||||||||||||||||
421 | */ | - | ||||||||||||||||||||||||
422 | - | |||||||||||||||||||||||||
423 | /*! | - | ||||||||||||||||||||||||
424 | \fn void *QMetaType::construct(int type, const void *copy) | - | ||||||||||||||||||||||||
425 | \deprecated | - | ||||||||||||||||||||||||
426 | - | |||||||||||||||||||||||||
427 | Constructs a value of the given type which is a copy of \a copy. | - | ||||||||||||||||||||||||
428 | The default value for \a copy is 0. | - | ||||||||||||||||||||||||
429 | - | |||||||||||||||||||||||||
430 | Deprecated, use the static function QMetaType::create(int type, | - | ||||||||||||||||||||||||
431 | const void *copy) instead. | - | ||||||||||||||||||||||||
432 | */ | - | ||||||||||||||||||||||||
433 | /*! | - | ||||||||||||||||||||||||
434 | \fn void *QMetaType::construct(void *where, const void *copy = 0) const | - | ||||||||||||||||||||||||
435 | \since 5.0 | - | ||||||||||||||||||||||||
436 | - | |||||||||||||||||||||||||
437 | Constructs a value of the type that this QMetaType instance | - | ||||||||||||||||||||||||
438 | was constructed for in the existing memory addressed by \a where, | - | ||||||||||||||||||||||||
439 | that is a copy of \a copy, and returns \a where. If \a copy is | - | ||||||||||||||||||||||||
440 | zero, the value is default constructed. | - | ||||||||||||||||||||||||
441 | - | |||||||||||||||||||||||||
442 | This is a low-level function for explicitly managing the memory | - | ||||||||||||||||||||||||
443 | used to store the type. Consider calling create() if you don't | - | ||||||||||||||||||||||||
444 | need this level of control (that is, use "new" rather than | - | ||||||||||||||||||||||||
445 | "placement new"). | - | ||||||||||||||||||||||||
446 | - | |||||||||||||||||||||||||
447 | You must ensure that \a where points to a location where the new | - | ||||||||||||||||||||||||
448 | value can be stored and that \a where is suitably aligned. | - | ||||||||||||||||||||||||
449 | The type's size can be queried by calling sizeOf(). | - | ||||||||||||||||||||||||
450 | - | |||||||||||||||||||||||||
451 | The rule of thumb for alignment is that a type is aligned to its | - | ||||||||||||||||||||||||
452 | natural boundary, which is the smallest power of 2 that is bigger | - | ||||||||||||||||||||||||
453 | than the type, unless that alignment is larger than the maximum | - | ||||||||||||||||||||||||
454 | useful alignment for the platform. For practical purposes, | - | ||||||||||||||||||||||||
455 | alignment larger than 2 * sizeof(void*) is only necessary for | - | ||||||||||||||||||||||||
456 | special hardware instructions (e.g., aligned SSE loads and stores | - | ||||||||||||||||||||||||
457 | on x86). | - | ||||||||||||||||||||||||
458 | */ | - | ||||||||||||||||||||||||
459 | - | |||||||||||||||||||||||||
460 | /*! | - | ||||||||||||||||||||||||
461 | \fn void QMetaType::destruct(void *data) const | - | ||||||||||||||||||||||||
462 | \since 5.0 | - | ||||||||||||||||||||||||
463 | - | |||||||||||||||||||||||||
464 | Destructs the value, located at \a data, assuming that it is | - | ||||||||||||||||||||||||
465 | of the type for which this QMetaType instance was constructed for. | - | ||||||||||||||||||||||||
466 | - | |||||||||||||||||||||||||
467 | Unlike destroy(), this function only invokes the type's | - | ||||||||||||||||||||||||
468 | destructor, it doesn't invoke the delete operator. | - | ||||||||||||||||||||||||
469 | \sa QMetaType::construct() | - | ||||||||||||||||||||||||
470 | */ | - | ||||||||||||||||||||||||
471 | - | |||||||||||||||||||||||||
472 | /*! | - | ||||||||||||||||||||||||
473 | \fn QMetaType::~QMetaType() | - | ||||||||||||||||||||||||
474 | - | |||||||||||||||||||||||||
475 | Destructs this object. | - | ||||||||||||||||||||||||
476 | */ | - | ||||||||||||||||||||||||
477 | - | |||||||||||||||||||||||||
478 | #define QT_ADD_STATIC_METATYPE(MetaTypeName, MetaTypeId, RealName) \ | - | ||||||||||||||||||||||||
479 | { #RealName, sizeof(#RealName) - 1, MetaTypeId }, | - | ||||||||||||||||||||||||
480 | - | |||||||||||||||||||||||||
481 | #define QT_ADD_STATIC_METATYPE_ALIASES_ITER(MetaTypeName, MetaTypeId, AliasingName, RealNameStr) \ | - | ||||||||||||||||||||||||
482 | { RealNameStr, sizeof(RealNameStr) - 1, QMetaType::MetaTypeName }, | - | ||||||||||||||||||||||||
483 | - | |||||||||||||||||||||||||
484 | #define QT_ADD_STATIC_METATYPE_HACKS_ITER(MetaTypeName, TypeId, Name) \ | - | ||||||||||||||||||||||||
485 | QT_ADD_STATIC_METATYPE(MetaTypeName, MetaTypeName, Name) | - | ||||||||||||||||||||||||
486 | - | |||||||||||||||||||||||||
487 | static const struct { const char * typeName; int typeNameLength; int type; } types[] = { | - | ||||||||||||||||||||||||
488 | QT_FOR_EACH_STATIC_TYPE(QT_ADD_STATIC_METATYPE) | - | ||||||||||||||||||||||||
489 | QT_FOR_EACH_STATIC_ALIAS_TYPE(QT_ADD_STATIC_METATYPE_ALIASES_ITER) | - | ||||||||||||||||||||||||
490 | QT_FOR_EACH_STATIC_HACKS_TYPE(QT_ADD_STATIC_METATYPE_HACKS_ITER) | - | ||||||||||||||||||||||||
491 | {0, 0, QMetaType::UnknownType} | - | ||||||||||||||||||||||||
492 | }; | - | ||||||||||||||||||||||||
493 | - | |||||||||||||||||||||||||
494 | Q_CORE_EXPORT const QMetaTypeInterface *qMetaTypeGuiHelper = 0; | - | ||||||||||||||||||||||||
495 | Q_CORE_EXPORT const QMetaTypeInterface *qMetaTypeWidgetsHelper = 0; | - | ||||||||||||||||||||||||
496 | Q_CORE_EXPORT const QMetaObject *qMetaObjectWidgetsHelper = 0; | - | ||||||||||||||||||||||||
497 | - | |||||||||||||||||||||||||
498 | class QCustomTypeInfo : public QMetaTypeInterface | - | ||||||||||||||||||||||||
499 | { | - | ||||||||||||||||||||||||
500 | public: | - | ||||||||||||||||||||||||
501 | QCustomTypeInfo() | - | ||||||||||||||||||||||||
502 | : alias(-1) | - | ||||||||||||||||||||||||
503 | { | - | ||||||||||||||||||||||||
504 | QMetaTypeInterface empty = QT_METATYPE_INTERFACE_INIT(void); | - | ||||||||||||||||||||||||
505 | *static_cast<QMetaTypeInterface*>(this) = empty; | - | ||||||||||||||||||||||||
506 | } executed 11942 times by 316 tests: end of block Executed by:
| 11942 | ||||||||||||||||||||||||
507 | QByteArray typeName; | - | ||||||||||||||||||||||||
508 | int alias; | - | ||||||||||||||||||||||||
509 | }; | - | ||||||||||||||||||||||||
510 | - | |||||||||||||||||||||||||
511 | template<typename T, typename Key> | - | ||||||||||||||||||||||||
512 | class QMetaTypeFunctionRegistry | - | ||||||||||||||||||||||||
513 | { | - | ||||||||||||||||||||||||
514 | public: | - | ||||||||||||||||||||||||
515 | ~QMetaTypeFunctionRegistry() | - | ||||||||||||||||||||||||
516 | { | - | ||||||||||||||||||||||||
517 | const QWriteLocker locker(&lock); | - | ||||||||||||||||||||||||
518 | map.clear(); | - | ||||||||||||||||||||||||
519 | } executed 506 times by 237 tests: end of block Executed by:
| 506 | ||||||||||||||||||||||||
520 | - | |||||||||||||||||||||||||
521 | bool contains(Key k) const | - | ||||||||||||||||||||||||
522 | { | - | ||||||||||||||||||||||||
523 | const QReadLocker locker(&lock); | - | ||||||||||||||||||||||||
524 | return map.contains(k); executed 5774 times by 241 tests: return map.contains(k); Executed by:
| 5774 | ||||||||||||||||||||||||
525 | } | - | ||||||||||||||||||||||||
526 | - | |||||||||||||||||||||||||
527 | bool insertIfNotContains(Key k, const T *f) | - | ||||||||||||||||||||||||
528 | { | - | ||||||||||||||||||||||||
529 | const QWriteLocker locker(&lock); | - | ||||||||||||||||||||||||
530 | const T* &fun = map[k]; | - | ||||||||||||||||||||||||
531 | if (fun != 0)
| 1-4772 | ||||||||||||||||||||||||
532 | return false; executed 1 time by 1 test: return false; Executed by:
| 1 | ||||||||||||||||||||||||
533 | fun = f; | - | ||||||||||||||||||||||||
534 | return true; executed 4772 times by 239 tests: return true; Executed by:
| 4772 | ||||||||||||||||||||||||
535 | } | - | ||||||||||||||||||||||||
536 | - | |||||||||||||||||||||||||
537 | const T *function(Key k) const | - | ||||||||||||||||||||||||
538 | { | - | ||||||||||||||||||||||||
539 | const QReadLocker locker(&lock); | - | ||||||||||||||||||||||||
540 | return map.value(k, 0); executed 2257 times by 33 tests: return map.value(k, 0); Executed by:
| 2257 | ||||||||||||||||||||||||
541 | } | - | ||||||||||||||||||||||||
542 | - | |||||||||||||||||||||||||
543 | void remove(int from, int to) | - | ||||||||||||||||||||||||
544 | { | - | ||||||||||||||||||||||||
545 | const Key k(from, to); | - | ||||||||||||||||||||||||
546 | const QWriteLocker locker(&lock); | - | ||||||||||||||||||||||||
547 | map.remove(k); | - | ||||||||||||||||||||||||
548 | } executed 4831 times by 235 tests: end of block Executed by:
| 4831 | ||||||||||||||||||||||||
549 | private: | - | ||||||||||||||||||||||||
550 | mutable QReadWriteLock lock; | - | ||||||||||||||||||||||||
551 | QHash<Key, const T *> map; | - | ||||||||||||||||||||||||
552 | }; | - | ||||||||||||||||||||||||
553 | - | |||||||||||||||||||||||||
554 | typedef QMetaTypeFunctionRegistry<QtPrivate::AbstractConverterFunction,QPair<int,int> > | - | ||||||||||||||||||||||||
555 | QMetaTypeConverterRegistry; | - | ||||||||||||||||||||||||
556 | typedef QMetaTypeFunctionRegistry<QtPrivate::AbstractComparatorFunction,int> | - | ||||||||||||||||||||||||
557 | QMetaTypeComparatorRegistry; | - | ||||||||||||||||||||||||
558 | typedef QMetaTypeFunctionRegistry<QtPrivate::AbstractDebugStreamFunction,int> | - | ||||||||||||||||||||||||
559 | QMetaTypeDebugStreamRegistry; | - | ||||||||||||||||||||||||
560 | - | |||||||||||||||||||||||||
561 | namespace | - | ||||||||||||||||||||||||
562 | { | - | ||||||||||||||||||||||||
563 | union CheckThatItIsPod | - | ||||||||||||||||||||||||
564 | { // This should break if QMetaTypeInterface is not a POD type | - | ||||||||||||||||||||||||
565 | QMetaTypeInterface iface; | - | ||||||||||||||||||||||||
566 | }; | - | ||||||||||||||||||||||||
567 | } | - | ||||||||||||||||||||||||
568 | - | |||||||||||||||||||||||||
569 | Q_DECLARE_TYPEINFO(QCustomTypeInfo, Q_MOVABLE_TYPE); | - | ||||||||||||||||||||||||
570 | Q_GLOBAL_STATIC(QVector<QCustomTypeInfo>, customTypes) executed 495 times by 191 tests: end of block Executed by:
executed 495 times by 191 tests: guard.store(QtGlobalStatic::Destroyed); Executed by:
executed 1227188 times by 345 tests: return &holder.value; Executed by:
| 0-1227188 | ||||||||||||||||||||||||
571 | Q_GLOBAL_STATIC(QReadWriteLock, customTypesLock) executed 495 times by 191 tests: end of block Executed by:
executed 495 times by 191 tests: guard.store(QtGlobalStatic::Destroyed); Executed by:
executed 1201854 times by 345 tests: return &holder.value; Executed by:
| 0-1201854 | ||||||||||||||||||||||||
572 | Q_GLOBAL_STATIC(QMetaTypeConverterRegistry, customTypesConversionRegistry) executed 460 times by 237 tests: end of block Executed by:
executed 460 times by 237 tests: guard.store(QtGlobalStatic::Destroyed); Executed by:
executed 17247 times by 468 tests: return &holder.value; Executed by:
| 0-17247 | ||||||||||||||||||||||||
573 | Q_GLOBAL_STATIC(QMetaTypeComparatorRegistry, customTypesComparatorRegistry) executed 44 times by 21 tests: end of block Executed by:
executed 44 times by 21 tests: guard.store(QtGlobalStatic::Destroyed); Executed by:
executed 381 times by 24 tests: return &holder.value; Executed by:
| 0-381 | ||||||||||||||||||||||||
574 | Q_GLOBAL_STATIC(QMetaTypeDebugStreamRegistry, customTypesDebugStreamRegistry) executed 2 times by 2 tests: end of block Executed by:
executed 2 times by 2 tests: guard.store(QtGlobalStatic::Destroyed); Executed by:
executed 7 times by 2 tests: return &holder.value; Executed by:
| 0-7 | ||||||||||||||||||||||||
575 | - | |||||||||||||||||||||||||
576 | /*! | - | ||||||||||||||||||||||||
577 | \fn bool QMetaType::registerConverter() | - | ||||||||||||||||||||||||
578 | \since 5.2 | - | ||||||||||||||||||||||||
579 | Registers the possibility of an implicit conversion from type From to type To in the meta | - | ||||||||||||||||||||||||
580 | type system. Returns \c true if the registration succeeded, otherwise false. | - | ||||||||||||||||||||||||
581 | */ | - | ||||||||||||||||||||||||
582 | - | |||||||||||||||||||||||||
583 | /*! | - | ||||||||||||||||||||||||
584 | \fn bool QMetaType::registerConverter(MemberFunction function) | - | ||||||||||||||||||||||||
585 | \since 5.2 | - | ||||||||||||||||||||||||
586 | \overload | - | ||||||||||||||||||||||||
587 | Registers a method \a function like To From::function() const as converter from type From | - | ||||||||||||||||||||||||
588 | to type To in the meta type system. Returns \c true if the registration succeeded, otherwise false. | - | ||||||||||||||||||||||||
589 | */ | - | ||||||||||||||||||||||||
590 | - | |||||||||||||||||||||||||
591 | /*! | - | ||||||||||||||||||||||||
592 | \fn bool QMetaType::registerConverter(MemberFunctionOk function) | - | ||||||||||||||||||||||||
593 | \since 5.2 | - | ||||||||||||||||||||||||
594 | \overload | - | ||||||||||||||||||||||||
595 | Registers a method \a function like To From::function(bool *ok) const as converter from type From | - | ||||||||||||||||||||||||
596 | to type To in the meta type system. Returns \c true if the registration succeeded, otherwise false. | - | ||||||||||||||||||||||||
597 | */ | - | ||||||||||||||||||||||||
598 | - | |||||||||||||||||||||||||
599 | /*! | - | ||||||||||||||||||||||||
600 | \fn bool QMetaType::registerConverter(UnaryFunction function) | - | ||||||||||||||||||||||||
601 | \since 5.2 | - | ||||||||||||||||||||||||
602 | \overload | - | ||||||||||||||||||||||||
603 | Registers a unary function object \a function as converter from type From | - | ||||||||||||||||||||||||
604 | to type To in the meta type system. Returns \c true if the registration succeeded, otherwise false. | - | ||||||||||||||||||||||||
605 | */ | - | ||||||||||||||||||||||||
606 | - | |||||||||||||||||||||||||
607 | /*! | - | ||||||||||||||||||||||||
608 | \fn bool QMetaType::registerComparators() | - | ||||||||||||||||||||||||
609 | \since 5.2 | - | ||||||||||||||||||||||||
610 | Registers comparison operators for the user-registered type T. This requires T to have | - | ||||||||||||||||||||||||
611 | both an operator== and an operator<. | - | ||||||||||||||||||||||||
612 | Returns \c true if the registration succeeded, otherwise false. | - | ||||||||||||||||||||||||
613 | */ | - | ||||||||||||||||||||||||
614 | - | |||||||||||||||||||||||||
615 | /*! | - | ||||||||||||||||||||||||
616 | \fn bool QMetaType::registerEqualsComparator() | - | ||||||||||||||||||||||||
617 | \since 5.5 | - | ||||||||||||||||||||||||
618 | Registers equals operator for the user-registered type T. This requires T to have | - | ||||||||||||||||||||||||
619 | an operator==. | - | ||||||||||||||||||||||||
620 | Returns \c true if the registration succeeded, otherwise false. | - | ||||||||||||||||||||||||
621 | */ | - | ||||||||||||||||||||||||
622 | - | |||||||||||||||||||||||||
623 | #ifndef QT_NO_DEBUG_STREAM | - | ||||||||||||||||||||||||
624 | /*! | - | ||||||||||||||||||||||||
625 | \fn bool QMetaType::registerDebugStreamOperator() | - | ||||||||||||||||||||||||
626 | Registers the debug stream operator for the user-registered type T. This requires T to have | - | ||||||||||||||||||||||||
627 | an operator<<(QDebug dbg, T). | - | ||||||||||||||||||||||||
628 | Returns \c true if the registration succeeded, otherwise false. | - | ||||||||||||||||||||||||
629 | */ | - | ||||||||||||||||||||||||
630 | #endif | - | ||||||||||||||||||||||||
631 | - | |||||||||||||||||||||||||
632 | /*! | - | ||||||||||||||||||||||||
633 | Registers function \a f as converter function from type id \a from to \a to. | - | ||||||||||||||||||||||||
634 | If there's already a conversion registered, this does nothing but deleting \a f. | - | ||||||||||||||||||||||||
635 | Returns \c true if the registration succeeded, otherwise false. | - | ||||||||||||||||||||||||
636 | \since 5.2 | - | ||||||||||||||||||||||||
637 | \internal | - | ||||||||||||||||||||||||
638 | */ | - | ||||||||||||||||||||||||
639 | bool QMetaType::registerConverterFunction(const QtPrivate::AbstractConverterFunction *f, int from, int to) | - | ||||||||||||||||||||||||
640 | { | - | ||||||||||||||||||||||||
641 | if (!customTypesConversionRegistry()->insertIfNotContains(qMakePair(from, to), f)) {
| 1-4769 | ||||||||||||||||||||||||
642 | qWarning("Type conversion already registered from type %s to type %s", | - | ||||||||||||||||||||||||
643 | QMetaType::typeName(from), QMetaType::typeName(to)); | - | ||||||||||||||||||||||||
644 | return false; executed 1 time by 1 test: return false; Executed by:
| 1 | ||||||||||||||||||||||||
645 | } | - | ||||||||||||||||||||||||
646 | return true; executed 4769 times by 239 tests: return true; Executed by:
| 4769 | ||||||||||||||||||||||||
647 | } | - | ||||||||||||||||||||||||
648 | - | |||||||||||||||||||||||||
649 | /*! | - | ||||||||||||||||||||||||
650 | \internal | - | ||||||||||||||||||||||||
651 | - | |||||||||||||||||||||||||
652 | Invoked automatically when a converter function object is destroyed. | - | ||||||||||||||||||||||||
653 | */ | - | ||||||||||||||||||||||||
654 | void QMetaType::unregisterConverterFunction(int from, int to) | - | ||||||||||||||||||||||||
655 | { | - | ||||||||||||||||||||||||
656 | if (customTypesConversionRegistry.isDestroyed())
| 0-4831 | ||||||||||||||||||||||||
657 | return; never executed: return; | 0 | ||||||||||||||||||||||||
658 | customTypesConversionRegistry()->remove(from, to); | - | ||||||||||||||||||||||||
659 | } executed 4831 times by 235 tests: end of block Executed by:
| 4831 | ||||||||||||||||||||||||
660 | - | |||||||||||||||||||||||||
661 | bool QMetaType::registerComparatorFunction(const QtPrivate::AbstractComparatorFunction *f, int type) | - | ||||||||||||||||||||||||
662 | { | - | ||||||||||||||||||||||||
663 | if (!customTypesComparatorRegistry()->insertIfNotContains(type, f)) {
| 0-2 | ||||||||||||||||||||||||
664 | qWarning("Comparators already registered for type %s", QMetaType::typeName(type)); | - | ||||||||||||||||||||||||
665 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
666 | } | - | ||||||||||||||||||||||||
667 | return true; executed 2 times by 1 test: return true; Executed by:
| 2 | ||||||||||||||||||||||||
668 | } | - | ||||||||||||||||||||||||
669 | - | |||||||||||||||||||||||||
670 | /*! | - | ||||||||||||||||||||||||
671 | \fn bool QMetaType::hasRegisteredComparators() | - | ||||||||||||||||||||||||
672 | Returns \c true, if the meta type system has registered comparators for type T. | - | ||||||||||||||||||||||||
673 | \since 5.2 | - | ||||||||||||||||||||||||
674 | */ | - | ||||||||||||||||||||||||
675 | - | |||||||||||||||||||||||||
676 | /*! | - | ||||||||||||||||||||||||
677 | Returns \c true, if the meta type system has registered comparators for type id \a typeId. | - | ||||||||||||||||||||||||
678 | \since 5.2 | - | ||||||||||||||||||||||||
679 | */ | - | ||||||||||||||||||||||||
680 | bool QMetaType::hasRegisteredComparators(int typeId) | - | ||||||||||||||||||||||||
681 | { | - | ||||||||||||||||||||||||
682 | return customTypesComparatorRegistry()->contains(typeId); never executed: return customTypesComparatorRegistry()->contains(typeId); | 0 | ||||||||||||||||||||||||
683 | } | - | ||||||||||||||||||||||||
684 | - | |||||||||||||||||||||||||
685 | #ifndef QT_NO_DEBUG_STREAM | - | ||||||||||||||||||||||||
686 | bool QMetaType::registerDebugStreamOperatorFunction(const QtPrivate::AbstractDebugStreamFunction *f, | - | ||||||||||||||||||||||||
687 | int type) | - | ||||||||||||||||||||||||
688 | { | - | ||||||||||||||||||||||||
689 | if (!customTypesDebugStreamRegistry()->insertIfNotContains(type, f)) {
| 0-1 | ||||||||||||||||||||||||
690 | qWarning("Debug stream operator already registered for type %s", QMetaType::typeName(type)); | - | ||||||||||||||||||||||||
691 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
692 | } | - | ||||||||||||||||||||||||
693 | return true; executed 1 time by 1 test: return true; Executed by:
| 1 | ||||||||||||||||||||||||
694 | } | - | ||||||||||||||||||||||||
695 | - | |||||||||||||||||||||||||
696 | /*! | - | ||||||||||||||||||||||||
697 | \fn bool QMetaType::hasRegisteredDebugStreamOperator() | - | ||||||||||||||||||||||||
698 | Returns \c true, if the meta type system has a registered debug stream operator for type T. | - | ||||||||||||||||||||||||
699 | \since 5.2 | - | ||||||||||||||||||||||||
700 | */ | - | ||||||||||||||||||||||||
701 | - | |||||||||||||||||||||||||
702 | /*! | - | ||||||||||||||||||||||||
703 | Returns \c true, if the meta type system has a registered debug stream operator for type | - | ||||||||||||||||||||||||
704 | id \a typeId. | - | ||||||||||||||||||||||||
705 | \since 5.2 | - | ||||||||||||||||||||||||
706 | */ | - | ||||||||||||||||||||||||
707 | bool QMetaType::hasRegisteredDebugStreamOperator(int typeId) | - | ||||||||||||||||||||||||
708 | { | - | ||||||||||||||||||||||||
709 | return customTypesDebugStreamRegistry()->contains(typeId); never executed: return customTypesDebugStreamRegistry()->contains(typeId); | 0 | ||||||||||||||||||||||||
710 | } | - | ||||||||||||||||||||||||
711 | #endif | - | ||||||||||||||||||||||||
712 | - | |||||||||||||||||||||||||
713 | /*! | - | ||||||||||||||||||||||||
714 | Converts the object at \a from from \a fromTypeId to the preallocated space at \a to | - | ||||||||||||||||||||||||
715 | typed \a toTypeId. Returns \c true, if the conversion succeeded, otherwise false. | - | ||||||||||||||||||||||||
716 | \since 5.2 | - | ||||||||||||||||||||||||
717 | */ | - | ||||||||||||||||||||||||
718 | bool QMetaType::convert(const void *from, int fromTypeId, void *to, int toTypeId) | - | ||||||||||||||||||||||||
719 | { | - | ||||||||||||||||||||||||
720 | const QtPrivate::AbstractConverterFunction * const f = | - | ||||||||||||||||||||||||
721 | customTypesConversionRegistry()->function(qMakePair(fromTypeId, toTypeId)); | - | ||||||||||||||||||||||||
722 | return f && f->convert(f, from, to); executed 1872 times by 25 tests: return f && f->convert(f, from, to); Executed by:
| 28-1872 | ||||||||||||||||||||||||
723 | } | - | ||||||||||||||||||||||||
724 | - | |||||||||||||||||||||||||
725 | /*! | - | ||||||||||||||||||||||||
726 | Compares the objects at \a lhs and \a rhs. Both objects need to be of type \a typeId. | - | ||||||||||||||||||||||||
727 | \a result is set to less than, equal to or greater than zero, if \a lhs is less than, equal to | - | ||||||||||||||||||||||||
728 | or greater than \a rhs. Returns \c true, if the comparison succeeded, otherwise \c false. | - | ||||||||||||||||||||||||
729 | \since 5.2 | - | ||||||||||||||||||||||||
730 | */ | - | ||||||||||||||||||||||||
731 | bool QMetaType::compare(const void *lhs, const void *rhs, int typeId, int* result) | - | ||||||||||||||||||||||||
732 | { | - | ||||||||||||||||||||||||
733 | const QtPrivate::AbstractComparatorFunction * const f = | - | ||||||||||||||||||||||||
734 | customTypesComparatorRegistry()->function(typeId); | - | ||||||||||||||||||||||||
735 | if (!f)
| 0-10 | ||||||||||||||||||||||||
736 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
737 | if (f->equals(f, lhs, rhs))
| 2-8 | ||||||||||||||||||||||||
738 | *result = 0; executed 2 times by 1 test: *result = 0; Executed by:
| 2 | ||||||||||||||||||||||||
739 | else if (f->lessThan)
| 3-5 | ||||||||||||||||||||||||
740 | *result = f->lessThan(f, lhs, rhs) ? -1 : 1; executed 5 times by 1 test: *result = f->lessThan(f, lhs, rhs) ? -1 : 1; Executed by:
| 1-5 | ||||||||||||||||||||||||
741 | else | - | ||||||||||||||||||||||||
742 | return false; executed 3 times by 1 test: return false; Executed by:
| 3 | ||||||||||||||||||||||||
743 | return true; executed 7 times by 1 test: return true; Executed by:
| 7 | ||||||||||||||||||||||||
744 | } | - | ||||||||||||||||||||||||
745 | - | |||||||||||||||||||||||||
746 | /*! | - | ||||||||||||||||||||||||
747 | Compares the objects at \a lhs and \a rhs. Both objects need to be of type \a typeId. | - | ||||||||||||||||||||||||
748 | \a result is set to zero, if \a lhs equals to rhs. Returns \c true, if the comparison | - | ||||||||||||||||||||||||
749 | succeeded, otherwise \c false. | - | ||||||||||||||||||||||||
750 | \since 5.5 | - | ||||||||||||||||||||||||
751 | */ | - | ||||||||||||||||||||||||
752 | bool QMetaType::equals(const void *lhs, const void *rhs, int typeId, int *result) | - | ||||||||||||||||||||||||
753 | { | - | ||||||||||||||||||||||||
754 | const QtPrivate::AbstractComparatorFunction * const f | - | ||||||||||||||||||||||||
755 | = customTypesComparatorRegistry()->function(typeId); | - | ||||||||||||||||||||||||
756 | if (!f)
| 23-346 | ||||||||||||||||||||||||
757 | return false; executed 346 times by 24 tests: return false; Executed by:
| 346 | ||||||||||||||||||||||||
758 | if (f->equals(f, lhs, rhs))
| 10-13 | ||||||||||||||||||||||||
759 | *result = 0; executed 10 times by 1 test: *result = 0; Executed by:
| 10 | ||||||||||||||||||||||||
760 | else | - | ||||||||||||||||||||||||
761 | *result = -1; executed 13 times by 1 test: *result = -1; Executed by:
| 13 | ||||||||||||||||||||||||
762 | return true; executed 23 times by 1 test: return true; Executed by:
| 23 | ||||||||||||||||||||||||
763 | } | - | ||||||||||||||||||||||||
764 | - | |||||||||||||||||||||||||
765 | /*! | - | ||||||||||||||||||||||||
766 | Streams the object at \a rhs of type \a typeId to the debug stream \a dbg. Returns \c true | - | ||||||||||||||||||||||||
767 | on success, otherwise false. | - | ||||||||||||||||||||||||
768 | \since 5.2 | - | ||||||||||||||||||||||||
769 | */ | - | ||||||||||||||||||||||||
770 | bool QMetaType::debugStream(QDebug& dbg, const void *rhs, int typeId) | - | ||||||||||||||||||||||||
771 | { | - | ||||||||||||||||||||||||
772 | const QtPrivate::AbstractDebugStreamFunction * const f = customTypesDebugStreamRegistry()->function(typeId); | - | ||||||||||||||||||||||||
773 | if (!f)
| 1-5 | ||||||||||||||||||||||||
774 | return false; executed 5 times by 2 tests: return false; Executed by:
| 5 | ||||||||||||||||||||||||
775 | f->stream(f, dbg, rhs); | - | ||||||||||||||||||||||||
776 | return true; executed 1 time by 1 test: return true; Executed by:
| 1 | ||||||||||||||||||||||||
777 | } | - | ||||||||||||||||||||||||
778 | - | |||||||||||||||||||||||||
779 | /*! | - | ||||||||||||||||||||||||
780 | \fn bool QMetaType::hasRegisteredConverterFunction() | - | ||||||||||||||||||||||||
781 | Returns \c true, if the meta type system has a registered conversion from type From to type To. | - | ||||||||||||||||||||||||
782 | \since 5.2 | - | ||||||||||||||||||||||||
783 | \overload | - | ||||||||||||||||||||||||
784 | */ | - | ||||||||||||||||||||||||
785 | - | |||||||||||||||||||||||||
786 | /*! | - | ||||||||||||||||||||||||
787 | Returns \c true, if the meta type system has a registered conversion from meta type id \a fromTypeId | - | ||||||||||||||||||||||||
788 | to \a toTypeId | - | ||||||||||||||||||||||||
789 | \since 5.2 | - | ||||||||||||||||||||||||
790 | */ | - | ||||||||||||||||||||||||
791 | bool QMetaType::hasRegisteredConverterFunction(int fromTypeId, int toTypeId) | - | ||||||||||||||||||||||||
792 | { | - | ||||||||||||||||||||||||
793 | return customTypesConversionRegistry()->contains(qMakePair(fromTypeId, toTypeId)); executed 5774 times by 241 tests: return customTypesConversionRegistry()->contains(qMakePair(fromTypeId, toTypeId)); Executed by:
| 5774 | ||||||||||||||||||||||||
794 | } | - | ||||||||||||||||||||||||
795 | - | |||||||||||||||||||||||||
796 | #ifndef QT_NO_DATASTREAM | - | ||||||||||||||||||||||||
797 | /*! | - | ||||||||||||||||||||||||
798 | \internal | - | ||||||||||||||||||||||||
799 | */ | - | ||||||||||||||||||||||||
800 | void QMetaType::registerStreamOperators(const char *typeName, SaveOperator saveOp, | - | ||||||||||||||||||||||||
801 | LoadOperator loadOp) | - | ||||||||||||||||||||||||
802 | { | - | ||||||||||||||||||||||||
803 | registerStreamOperators(type(typeName), saveOp, loadOp); | - | ||||||||||||||||||||||||
804 | } executed 5 times by 3 tests: end of block Executed by:
| 5 | ||||||||||||||||||||||||
805 | - | |||||||||||||||||||||||||
806 | /*! | - | ||||||||||||||||||||||||
807 | \internal | - | ||||||||||||||||||||||||
808 | */ | - | ||||||||||||||||||||||||
809 | void QMetaType::registerStreamOperators(int idx, SaveOperator saveOp, | - | ||||||||||||||||||||||||
810 | LoadOperator loadOp) | - | ||||||||||||||||||||||||
811 | { | - | ||||||||||||||||||||||||
812 | if (idx < User)
| 2-4 | ||||||||||||||||||||||||
813 | return; //builtin types should not be registered; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||||||||
814 | QVector<QCustomTypeInfo> *ct = customTypes(); | - | ||||||||||||||||||||||||
815 | if (!ct)
| 0-4 | ||||||||||||||||||||||||
816 | return; never executed: return; | 0 | ||||||||||||||||||||||||
817 | QWriteLocker locker(customTypesLock()); | - | ||||||||||||||||||||||||
818 | QCustomTypeInfo &inf = (*ct)[idx - User]; | - | ||||||||||||||||||||||||
819 | inf.saveOp = saveOp; | - | ||||||||||||||||||||||||
820 | inf.loadOp = loadOp; | - | ||||||||||||||||||||||||
821 | } executed 4 times by 3 tests: end of block Executed by:
| 4 | ||||||||||||||||||||||||
822 | #endif // QT_NO_DATASTREAM | - | ||||||||||||||||||||||||
823 | - | |||||||||||||||||||||||||
824 | /*! | - | ||||||||||||||||||||||||
825 | Returns the type name associated with the given \a typeId, or 0 if no | - | ||||||||||||||||||||||||
826 | matching type was found. The returned pointer must not be deleted. | - | ||||||||||||||||||||||||
827 | - | |||||||||||||||||||||||||
828 | \sa type(), isRegistered(), Type | - | ||||||||||||||||||||||||
829 | */ | - | ||||||||||||||||||||||||
830 | const char *QMetaType::typeName(int typeId) | - | ||||||||||||||||||||||||
831 | { | - | ||||||||||||||||||||||||
832 | const uint type = typeId; | - | ||||||||||||||||||||||||
833 | #define QT_METATYPE_TYPEID_TYPENAME_CONVERTER(MetaTypeName, TypeId, RealName) \ | - | ||||||||||||||||||||||||
834 | case QMetaType::MetaTypeName: return #RealName; break; | - | ||||||||||||||||||||||||
835 | - | |||||||||||||||||||||||||
836 | switch (QMetaType::Type(type)) { | - | ||||||||||||||||||||||||
837 | QT_FOR_EACH_STATIC_TYPE(QT_METATYPE_TYPEID_TYPENAME_CONVERTER) executed 323 times by 6 tests: return "void"; Executed by:
executed 2426 times by 170 tests: return "bool"; Executed by:
executed 9344 times by 210 tests: return "int"; Executed by:
executed 754 times by 169 tests: return "uint"; Executed by:
executed 1375 times by 174 tests: return "qlonglong"; Executed by:
executed 527 times by 169 tests: return "qulonglong"; Executed by:
executed 768 times by 172 tests: return "double"; Executed by:
executed 43 times by 4 tests: return "long"; Executed by:
executed 696 times by 169 tests: return "short"; Executed by:
executed 111 times by 3 tests: return "char"; Executed by:
executed 60 times by 3 tests: return "ulong"; Executed by:
executed 665 times by 169 tests: return "ushort"; Executed by:
executed 187 times by 7 tests: return "uchar"; Executed by:
executed 81 times by 3 tests: return "float"; Executed by:
executed 43 times by 2 tests: return "signed char"; Executed by:
executed 545 times by 163 tests: return "void*"; Executed by:
executed 21 times by 3 tests: return "QChar"; Executed by:
executed 8245 times by 183 tests: return "QString"; Executed by:
executed 685 times by 26 tests: return "QStringList"; Executed by:
executed 204 times by 19 tests: return "QByteArray"; Executed by:
executed 24 times by 2 tests: return "QBitArray"; Executed by:
executed 262 times by 5 tests: return "QDate"; Executed by:
executed 261 times by 5 tests: return "QTime"; Executed by:
executed 273 times by 8 tests: return "QDateTime"; Executed by:
executed 1645 times by 8 tests: return "QUrl"; Executed by:
executed 18 times by 3 tests: return "QLocale"; Executed by:
executed 4506 times by 16 tests: return "QRect"; Executed by:
executed 261 times by 8 tests: return "QRectF"; Executed by:
executed 283 times by 6 tests: return "QSize"; Executed by:
executed 256 times by 5 tests: return "QSizeF"; Executed by:
executed 255 times by 4 tests: return "QLine"; Executed by:
executed 256 times by 4 tests: return "QLineF"; Executed by:
executed 741 times by 13 tests: return "QPoint"; Executed by:
executed 273 times by 7 tests: return "QPointF"; Executed by:
executed 20 times by 2 tests: return "QRegExp"; Executed by:
executed 14 times by 3 tests: return "QEasingCurve"; Executed by:
executed 14 times by 2 tests: return "QUuid"; Executed by:
executed 341 times by 94 tests: return "QVariant"; Executed by:
executed 3326 times by 12 tests: return "QModelIndex"; Executed by:
executed 19 times by 2 tests: return "QRegularExpression"; Executed by:
executed 13 times by 2 tests: return "QJsonValue"; Executed by:
executed 13 times by 2 tests: return "QJsonObject"; Executed by:
executed 13 times by 2 tests: return "QJsonArray"; Executed by:
executed 13 times by 2 tests: return "QJsonDocument"; Executed by:
executed 13 times by 3 tests: return "QPersistentModelIndex"; Executed by:
executed 479 times by 20 tests: return "QObject*"; Executed by:
executed 683 times by 40 tests: return "QVariantMap"; Executed by:
executed 285 times by 13 tests: return "QVariantList"; Executed by:
executed 281 times by 7 tests: return "QVariantHash"; Executed by:
executed 12 times by 2 tests: return "QByteArrayList"; Executed by:
executed 16 times by 4 tests: return "QFont"; Executed by:
executed 14 times by 4 tests: return "QPixmap"; Executed by:
executed 16 times by 4 tests: return "QBrush"; Executed by:
executed 16 times by 4 tests: return "QColor"; Executed by:
executed 20 times by 5 tests: return "QPalette"; Executed by:
executed 258 times by 11 tests: return "QIcon"; Executed by:
executed 16 times by 5 tests: return "QImage"; Executed by:
executed 18 times by 4 tests: return "QPolygon"; Executed by:
executed 18 times by 4 tests: return "QRegion"; Executed by:
executed 14 times by 4 tests: return "QBitmap"; Executed by:
executed 16 times by 4 tests: return "QCursor"; Executed by:
executed 17 times by 5 tests: return "QKeySequence"; Executed by:
executed 16 times by 4 tests: return "QPen"; Executed by:
executed 14 times by 4 tests: return "QTextLength"; Executed by:
executed 14 times by 4 tests: return "QTextFormat"; Executed by:
executed 16 times by 5 tests: return "QMatrix"; Executed by:
executed 18 times by 5 tests: return "QTransform"; Executed by:
executed 15 times by 5 tests: return "QMatrix4x4"; Executed by:
executed 15 times by 5 tests: return "QVector2D"; Executed by:
executed 15 times by 5 tests: return "QVector3D"; Executed by:
executed 15 times by 5 tests: return "QVector4D"; Executed by:
executed 15 times by 5 tests: return "QQuaternion"; Executed by:
executed 12 times by 3 tests: return "QPolygonF"; Executed by:
executed 6 times by 3 tests: return "QSizePolicy"; Executed by:
executed 323 times by 6 tests: case QMetaType::Void: Executed by:
executed 2426 times by 170 tests: case QMetaType::Bool: Executed by:
executed 9344 times by 210 tests: case QMetaType::Int: Executed by:
executed 754 times by 169 tests: case QMetaType::UInt: Executed by:
executed 1375 times by 174 tests: case QMetaType::LongLong: Executed by:
executed 527 times by 169 tests: case QMetaType::ULongLong: Executed by:
executed 768 times by 172 tests: case QMetaType::Double: Executed by:
executed 43 times by 4 tests: case QMetaType::Long: Executed by:
executed 696 times by 169 tests: case QMetaType::Short: Executed by:
executed 111 times by 3 tests: case QMetaType::Char: Executed by:
executed 60 times by 3 tests: case QMetaType::ULong: Executed by:
executed 665 times by 169 tests: case QMetaType::UShort: Executed by:
executed 187 times by 7 tests: case QMetaType::UChar: Executed by:
executed 81 times by 3 tests: case QMetaType::Float: Executed by:
executed 43 times by 2 tests: case QMetaType::SChar: Executed by:
executed 545 times by 163 tests: case QMetaType::VoidStar: Executed by:
executed 21 times by 3 tests: case QMetaType::QChar: Executed by:
executed 8245 times by 183 tests: case QMetaType::QString: Executed by:
executed 685 times by 26 tests: case QMetaType::QStringList: Executed by:
executed 204 times by 19 tests: case QMetaType::QByteArray: Executed by:
executed 24 times by 2 tests: case QMetaType::QBitArray: Executed by:
executed 262 times by 5 tests: case QMetaType::QDate: Executed by:
executed 261 times by 5 tests: case QMetaType::QTime: Executed by:
executed 273 times by 8 tests: case QMetaType::QDateTime: Executed by:
executed 1645 times by 8 tests: case QMetaType::QUrl: Executed by:
executed 18 times by 3 tests: case QMetaType::QLocale: Executed by:
executed 4506 times by 16 tests: case QMetaType::QRect: Executed by:
executed 261 times by 8 tests: case QMetaType::QRectF: Executed by:
executed 283 times by 6 tests: case QMetaType::QSize: Executed by:
executed 256 times by 5 tests: case QMetaType::QSizeF: Executed by:
executed 255 times by 4 tests: case QMetaType::QLine: Executed by:
executed 256 times by 4 tests: case QMetaType::QLineF: Executed by:
executed 741 times by 13 tests: case QMetaType::QPoint: Executed by:
executed 273 times by 7 tests: case QMetaType::QPointF: Executed by:
executed 20 times by 2 tests: case QMetaType::QRegExp: Executed by:
executed 14 times by 3 tests: case QMetaType::QEasingCurve: Executed by:
executed 14 times by 2 tests: case QMetaType::QUuid: Executed by:
executed 341 times by 94 tests: case QMetaType::QVariant: Executed by:
executed 3326 times by 12 tests: case QMetaType::QModelIndex: Executed by:
executed 19 times by 2 tests: case QMetaType::QRegularExpression: Executed by:
executed 13 times by 2 tests: case QMetaType::QJsonValue: Executed by:
executed 13 times by 2 tests: case QMetaType::QJsonObject: Executed by:
executed 13 times by 2 tests: case QMetaType::QJsonArray: Executed by:
executed 13 times by 2 tests: case QMetaType::QJsonDocument: Executed by:
executed 13 times by 3 tests: case QMetaType::QPersistentModelIndex: Executed by:
executed 479 times by 20 tests: case QMetaType::QObjectStar: Executed by:
executed 683 times by 40 tests: case QMetaType::QVariantMap: Executed by:
executed 285 times by 13 tests: case QMetaType::QVariantList: Executed by:
executed 281 times by 7 tests: case QMetaType::QVariantHash: Executed by:
executed 12 times by 2 tests: case QMetaType::QByteArrayList: Executed by:
executed 16 times by 4 tests: case QMetaType::QFont: Executed by:
executed 14 times by 4 tests: case QMetaType::QPixmap: Executed by:
executed 16 times by 4 tests: case QMetaType::QBrush: Executed by:
executed 16 times by 4 tests: case QMetaType::QColor: Executed by:
executed 20 times by 5 tests: case QMetaType::QPalette: Executed by:
executed 258 times by 11 tests: case QMetaType::QIcon: Executed by:
executed 16 times by 5 tests: case QMetaType::QImage: Executed by:
executed 18 times by 4 tests: case QMetaType::QPolygon: Executed by:
executed 18 times by 4 tests: case QMetaType::QRegion: Executed by:
executed 14 times by 4 tests: case QMetaType::QBitmap: Executed by:
executed 16 times by 4 tests: case QMetaType::QCursor: Executed by:
executed 17 times by 5 tests: case QMetaType::QKeySequence: Executed by:
executed 16 times by 4 tests: case QMetaType::QPen: Executed by:
executed 14 times by 4 tests: case QMetaType::QTextLength: Executed by:
executed 14 times by 4 tests: case QMetaType::QTextFormat: Executed by:
executed 16 times by 5 tests: case QMetaType::QMatrix: Executed by:
executed 18 times by 5 tests: case QMetaType::QTransform: Executed by:
executed 15 times by 5 tests: case QMetaType::QMatrix4x4: Executed by:
executed 15 times by 5 tests: case QMetaType::QVector2D: Executed by:
executed 15 times by 5 tests: case QMetaType::QVector3D: Executed by:
executed 15 times by 5 tests: case QMetaType::QVector4D: Executed by:
executed 15 times by 5 tests: case QMetaType::QQuaternion: Executed by:
executed 12 times by 3 tests: case QMetaType::QPolygonF: Executed by:
executed 6 times by 3 tests: case QMetaType::QSizePolicy: Executed by:
dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; dead code: break; | - | ||||||||||||||||||||||||
838 | case QMetaType::UnknownType: executed 12 times by 4 tests: case QMetaType::UnknownType: Executed by:
| 12 | ||||||||||||||||||||||||
839 | case QMetaType::User: executed 18 times by 8 tests: case QMetaType::User: Executed by:
| 18 | ||||||||||||||||||||||||
840 | break; executed 30 times by 12 tests: break; Executed by:
| 30 | ||||||||||||||||||||||||
841 | } | - | ||||||||||||||||||||||||
842 | - | |||||||||||||||||||||||||
843 | if (Q_UNLIKELY(type < QMetaType::User)) {
| 962-6774 | ||||||||||||||||||||||||
844 | return Q_NULLPTR; // It can happen when someone cast int to QVariant::Type, we should not crash... executed 962 times by 5 tests: return nullptr; Executed by:
| 962 | ||||||||||||||||||||||||
845 | } | - | ||||||||||||||||||||||||
846 | - | |||||||||||||||||||||||||
847 | const QVector<QCustomTypeInfo> * const ct = customTypes(); | - | ||||||||||||||||||||||||
848 | QReadLocker locker(customTypesLock()); | - | ||||||||||||||||||||||||
849 | return ct && uint(ct->count()) > type - QMetaType::User && !ct->at(type - QMetaType::User).typeName.isEmpty() executed 6774 times by 195 tests: return ct && uint(ct->count()) > type - QMetaType::User && !ct->at(type - QMetaType::User).typeName.isEmpty() ? ct->at(type - QMetaType::User).typeName.constData() : nullptr; Executed by:
| 0-6774 | ||||||||||||||||||||||||
850 | ? ct->at(type - QMetaType::User).typeName.constData() executed 6774 times by 195 tests: return ct && uint(ct->count()) > type - QMetaType::User && !ct->at(type - QMetaType::User).typeName.isEmpty() ? ct->at(type - QMetaType::User).typeName.constData() : nullptr; Executed by:
| 6774 | ||||||||||||||||||||||||
851 | : Q_NULLPTR; executed 6774 times by 195 tests: return ct && uint(ct->count()) > type - QMetaType::User && !ct->at(type - QMetaType::User).typeName.isEmpty() ? ct->at(type - QMetaType::User).typeName.constData() : nullptr; Executed by:
| 6774 | ||||||||||||||||||||||||
852 | - | |||||||||||||||||||||||||
853 | #undef QT_METATYPE_TYPEID_TYPENAME_CONVERTER | - | ||||||||||||||||||||||||
854 | } | - | ||||||||||||||||||||||||
855 | - | |||||||||||||||||||||||||
856 | /*! | - | ||||||||||||||||||||||||
857 | \internal | - | ||||||||||||||||||||||||
858 | Similar to QMetaType::type(), but only looks in the static set of types. | - | ||||||||||||||||||||||||
859 | */ | - | ||||||||||||||||||||||||
860 | static inline int qMetaTypeStaticType(const char *typeName, int length) | - | ||||||||||||||||||||||||
861 | { | - | ||||||||||||||||||||||||
862 | int i = 0; | - | ||||||||||||||||||||||||
863 | while (types[i].typeName && ((length != types[i].typeNameLength)
| 540382-74305344 | ||||||||||||||||||||||||
864 | || memcmp(typeName, types[i].typeName, length))) {
| 1334526-2734367 | ||||||||||||||||||||||||
865 | ++i; | - | ||||||||||||||||||||||||
866 | } executed 72976146 times by 365 tests: end of block Executed by:
| 72976146 | ||||||||||||||||||||||||
867 | return types[i].type; executed 1874908 times by 365 tests: return types[i].type; Executed by:
| 1874908 | ||||||||||||||||||||||||
868 | } | - | ||||||||||||||||||||||||
869 | - | |||||||||||||||||||||||||
870 | /*! | - | ||||||||||||||||||||||||
871 | \internal | - | ||||||||||||||||||||||||
872 | Similar to QMetaType::type(), but only looks in the custom set of | - | ||||||||||||||||||||||||
873 | types, and doesn't lock the mutex. | - | ||||||||||||||||||||||||
874 | The extra \a firstInvalidIndex parameter is an easy way to avoid | - | ||||||||||||||||||||||||
875 | iterating over customTypes() a second time in registerNormalizedType(). | - | ||||||||||||||||||||||||
876 | */ | - | ||||||||||||||||||||||||
877 | static int qMetaTypeCustomType_unlocked(const char *typeName, int length, int *firstInvalidIndex = 0) | - | ||||||||||||||||||||||||
878 | { | - | ||||||||||||||||||||||||
879 | const QVector<QCustomTypeInfo> * const ct = customTypes(); | - | ||||||||||||||||||||||||
880 | if (!ct)
| 0-540382 | ||||||||||||||||||||||||
881 | return QMetaType::UnknownType; never executed: return QMetaType::UnknownType; | 0 | ||||||||||||||||||||||||
882 | - | |||||||||||||||||||||||||
883 | if (firstInvalidIndex)
| 25192-515190 | ||||||||||||||||||||||||
884 | *firstInvalidIndex = -1; executed 25192 times by 316 tests: *firstInvalidIndex = -1; Executed by:
| 25192 | ||||||||||||||||||||||||
885 | for (int v = 0; v < ct->count(); ++v) {
| 165951-20697251 | ||||||||||||||||||||||||
886 | const QCustomTypeInfo &customInfo = ct->at(v); | - | ||||||||||||||||||||||||
887 | if ((length == customInfo.typeName.size())
| 8174096-12523155 | ||||||||||||||||||||||||
888 | && !memcmp(typeName, customInfo.typeName.constData(), length)) {
| 374431-7799665 | ||||||||||||||||||||||||
889 | if (customInfo.alias >= 0)
| 65-374366 | ||||||||||||||||||||||||
890 | return customInfo.alias; executed 65 times by 6 tests: return customInfo.alias; Executed by:
| 65 | ||||||||||||||||||||||||
891 | return v + QMetaType::User; executed 374366 times by 237 tests: return v + QMetaType::User; Executed by:
| 374366 | ||||||||||||||||||||||||
892 | } | - | ||||||||||||||||||||||||
893 | if (firstInvalidIndex && (*firstInvalidIndex < 0) && customInfo.typeName.isEmpty())
| 3-14493592 | ||||||||||||||||||||||||
894 | *firstInvalidIndex = v; executed 3 times by 1 test: *firstInvalidIndex = v; Executed by:
| 3 | ||||||||||||||||||||||||
895 | } executed 20322820 times by 311 tests: end of block Executed by:
| 20322820 | ||||||||||||||||||||||||
896 | return QMetaType::UnknownType; executed 165951 times by 319 tests: return QMetaType::UnknownType; Executed by:
| 165951 | ||||||||||||||||||||||||
897 | } | - | ||||||||||||||||||||||||
898 | - | |||||||||||||||||||||||||
899 | /*! | - | ||||||||||||||||||||||||
900 | \internal | - | ||||||||||||||||||||||||
901 | - | |||||||||||||||||||||||||
902 | This function is needed until existing code outside of qtbase | - | ||||||||||||||||||||||||
903 | has been changed to call the new version of registerType(). | - | ||||||||||||||||||||||||
904 | */ | - | ||||||||||||||||||||||||
905 | int QMetaType::registerType(const char *typeName, Deleter deleter, | - | ||||||||||||||||||||||||
906 | Creator creator) | - | ||||||||||||||||||||||||
907 | { | - | ||||||||||||||||||||||||
908 | return registerType(typeName, deleter, creator, never executed: return registerType(typeName, deleter, creator, QtMetaTypePrivate::QMetaTypeFunctionHelper<void>::Destruct, QtMetaTypePrivate::QMetaTypeFunctionHelper<void>::Construct, 0, TypeFlags(), 0); | 0 | ||||||||||||||||||||||||
909 | QtMetaTypePrivate::QMetaTypeFunctionHelper<void>::Destruct, never executed: return registerType(typeName, deleter, creator, QtMetaTypePrivate::QMetaTypeFunctionHelper<void>::Destruct, QtMetaTypePrivate::QMetaTypeFunctionHelper<void>::Construct, 0, TypeFlags(), 0); | 0 | ||||||||||||||||||||||||
910 | QtMetaTypePrivate::QMetaTypeFunctionHelper<void>::Construct, 0, TypeFlags(), 0); never executed: return registerType(typeName, deleter, creator, QtMetaTypePrivate::QMetaTypeFunctionHelper<void>::Destruct, QtMetaTypePrivate::QMetaTypeFunctionHelper<void>::Construct, 0, TypeFlags(), 0); | 0 | ||||||||||||||||||||||||
911 | } | - | ||||||||||||||||||||||||
912 | - | |||||||||||||||||||||||||
913 | /*! | - | ||||||||||||||||||||||||
914 | \internal | - | ||||||||||||||||||||||||
915 | \since 5.5 | - | ||||||||||||||||||||||||
916 | - | |||||||||||||||||||||||||
917 | Unregisters the user type with the given \a typeId and all its aliases. | - | ||||||||||||||||||||||||
918 | Returns \c true if the type was unregistered or \c false otherwise. | - | ||||||||||||||||||||||||
919 | - | |||||||||||||||||||||||||
920 | This function was added for QML to be able to deregister types after | - | ||||||||||||||||||||||||
921 | they are unloaded to prevent an infinite increase in custom types for | - | ||||||||||||||||||||||||
922 | applications that are unloading/reloading components often. | - | ||||||||||||||||||||||||
923 | */ | - | ||||||||||||||||||||||||
924 | bool QMetaType::unregisterType(int type) | - | ||||||||||||||||||||||||
925 | { | - | ||||||||||||||||||||||||
926 | QWriteLocker locker(customTypesLock()); | - | ||||||||||||||||||||||||
927 | QVector<QCustomTypeInfo> *ct = customTypes(); | - | ||||||||||||||||||||||||
928 | - | |||||||||||||||||||||||||
929 | // check if user type | - | ||||||||||||||||||||||||
930 | if ((type < User) || ((type - User) >= ct->size()))
| 0-3 | ||||||||||||||||||||||||
931 | return false; executed 1 time by 1 test: return false; Executed by:
| 1 | ||||||||||||||||||||||||
932 | - | |||||||||||||||||||||||||
933 | // only types without Q_DECLARE_METATYPE can be unregistered | - | ||||||||||||||||||||||||
934 | if (ct->data()[type - User].flags & WasDeclaredAsMetaType)
| 1-2 | ||||||||||||||||||||||||
935 | return false; executed 1 time by 1 test: return false; Executed by:
| 1 | ||||||||||||||||||||||||
936 | - | |||||||||||||||||||||||||
937 | // invalidate type and all its alias entries | - | ||||||||||||||||||||||||
938 | for (int v = 0; v < ct->count(); ++v) {
| 2-6080 | ||||||||||||||||||||||||
939 | if (((v + User) == type) || (ct->at(v).alias == type))
| 1-6078 | ||||||||||||||||||||||||
940 | ct->data()[v].typeName.clear(); executed 3 times by 1 test: ct->data()[v].typeName.clear(); Executed by:
| 3 | ||||||||||||||||||||||||
941 | } executed 6080 times by 1 test: end of block Executed by:
| 6080 | ||||||||||||||||||||||||
942 | return true; executed 2 times by 1 test: return true; Executed by:
| 2 | ||||||||||||||||||||||||
943 | } | - | ||||||||||||||||||||||||
944 | - | |||||||||||||||||||||||||
945 | - | |||||||||||||||||||||||||
946 | /*! | - | ||||||||||||||||||||||||
947 | \internal | - | ||||||||||||||||||||||||
948 | \since 5.0 | - | ||||||||||||||||||||||||
949 | - | |||||||||||||||||||||||||
950 | Registers a user type for marshalling, with \a typeName, a \a | - | ||||||||||||||||||||||||
951 | deleter, a \a creator, a \a destructor, a \a constructor, and | - | ||||||||||||||||||||||||
952 | a \a size. Returns the type's handle, or -1 if the type could | - | ||||||||||||||||||||||||
953 | not be registered. | - | ||||||||||||||||||||||||
954 | */ | - | ||||||||||||||||||||||||
955 | int QMetaType::registerType(const char *typeName, Deleter deleter, | - | ||||||||||||||||||||||||
956 | Creator creator, | - | ||||||||||||||||||||||||
957 | Destructor destructor, | - | ||||||||||||||||||||||||
958 | Constructor constructor, | - | ||||||||||||||||||||||||
959 | int size, TypeFlags flags, const QMetaObject *metaObject) | - | ||||||||||||||||||||||||
960 | { | - | ||||||||||||||||||||||||
961 | #ifdef QT_NO_QOBJECT | - | ||||||||||||||||||||||||
962 | NS(QByteArray) normalizedTypeName = typeName; | - | ||||||||||||||||||||||||
963 | #else | - | ||||||||||||||||||||||||
964 | NS(QByteArray) normalizedTypeName = QMetaObject::normalizedType(typeName); | - | ||||||||||||||||||||||||
965 | #endif | - | ||||||||||||||||||||||||
966 | - | |||||||||||||||||||||||||
967 | return registerNormalizedType(normalizedTypeName, deleter, creator, destructor, constructor, size, flags, metaObject); executed 4 times by 1 test: return registerNormalizedType(normalizedTypeName, deleter, creator, destructor, constructor, size, flags, metaObject); Executed by:
| 4 | ||||||||||||||||||||||||
968 | } | - | ||||||||||||||||||||||||
969 | - | |||||||||||||||||||||||||
970 | - | |||||||||||||||||||||||||
971 | /*! | - | ||||||||||||||||||||||||
972 | \internal | - | ||||||||||||||||||||||||
973 | \since 5.0 | - | ||||||||||||||||||||||||
974 | \overload | - | ||||||||||||||||||||||||
975 | Don't use, kept for binary compatibility | - | ||||||||||||||||||||||||
976 | - | |||||||||||||||||||||||||
977 | ### TODO Qt6: remove me | - | ||||||||||||||||||||||||
978 | */ | - | ||||||||||||||||||||||||
979 | int QMetaType::registerNormalizedType(const NS(QByteArray) &normalizedTypeName, Deleter deleter, | - | ||||||||||||||||||||||||
980 | Creator creator, | - | ||||||||||||||||||||||||
981 | Destructor destructor, | - | ||||||||||||||||||||||||
982 | Constructor constructor, | - | ||||||||||||||||||||||||
983 | int size, TypeFlags flags, const QMetaObject *metaObject) | - | ||||||||||||||||||||||||
984 | { | - | ||||||||||||||||||||||||
985 | Q_UNUSED(deleter); | - | ||||||||||||||||||||||||
986 | Q_UNUSED(creator); | - | ||||||||||||||||||||||||
987 | return registerNormalizedType(normalizedTypeName, destructor, constructor, size, flags, metaObject); executed 4 times by 1 test: return registerNormalizedType(normalizedTypeName, destructor, constructor, size, flags, metaObject); Executed by:
| 4 | ||||||||||||||||||||||||
988 | } | - | ||||||||||||||||||||||||
989 | - | |||||||||||||||||||||||||
990 | - | |||||||||||||||||||||||||
991 | /*! | - | ||||||||||||||||||||||||
992 | \internal | - | ||||||||||||||||||||||||
993 | \since 5.5 | - | ||||||||||||||||||||||||
994 | - | |||||||||||||||||||||||||
995 | Registers a user type for marshalling, with \a normalizedTypeName, | - | ||||||||||||||||||||||||
996 | a \a destructor, a \a constructor, and a \a size. Returns the type's | - | ||||||||||||||||||||||||
997 | handle, or -1 if the type could not be registered. | - | ||||||||||||||||||||||||
998 | - | |||||||||||||||||||||||||
999 | \note normalizedTypeName is not checked for conformance with | - | ||||||||||||||||||||||||
1000 | Qt's normalized format, so it must already conform. | - | ||||||||||||||||||||||||
1001 | */ | - | ||||||||||||||||||||||||
1002 | int QMetaType::registerNormalizedType(const NS(QByteArray) &normalizedTypeName, | - | ||||||||||||||||||||||||
1003 | Destructor destructor, | - | ||||||||||||||||||||||||
1004 | Constructor constructor, | - | ||||||||||||||||||||||||
1005 | int size, TypeFlags flags, const QMetaObject *metaObject) | - | ||||||||||||||||||||||||
1006 | { | - | ||||||||||||||||||||||||
1007 | QVector<QCustomTypeInfo> *ct = customTypes(); | - | ||||||||||||||||||||||||
1008 | if (!ct || normalizedTypeName.isEmpty() || !destructor || !constructor)
| 0-24362 | ||||||||||||||||||||||||
1009 | return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
1010 | - | |||||||||||||||||||||||||
1011 | int idx = qMetaTypeStaticType(normalizedTypeName.constData(), | - | ||||||||||||||||||||||||
1012 | normalizedTypeName.size()); | - | ||||||||||||||||||||||||
1013 | - | |||||||||||||||||||||||||
1014 | int previousSize = 0; | - | ||||||||||||||||||||||||
1015 | int previousFlags = 0; | - | ||||||||||||||||||||||||
1016 | if (idx == UnknownType) {
| 0-24362 | ||||||||||||||||||||||||
1017 | QWriteLocker locker(customTypesLock()); | - | ||||||||||||||||||||||||
1018 | int posInVector = -1; | - | ||||||||||||||||||||||||
1019 | idx = qMetaTypeCustomType_unlocked(normalizedTypeName.constData(), | - | ||||||||||||||||||||||||
1020 | normalizedTypeName.size(), | - | ||||||||||||||||||||||||
1021 | &posInVector); | - | ||||||||||||||||||||||||
1022 | if (idx == UnknownType) {
| 11911-12451 | ||||||||||||||||||||||||
1023 | QCustomTypeInfo inf; | - | ||||||||||||||||||||||||
1024 | inf.typeName = normalizedTypeName; | - | ||||||||||||||||||||||||
1025 | #ifndef QT_NO_DATASTREAM | - | ||||||||||||||||||||||||
1026 | inf.loadOp = 0; | - | ||||||||||||||||||||||||
1027 | inf.saveOp = 0; | - | ||||||||||||||||||||||||
1028 | #endif | - | ||||||||||||||||||||||||
1029 | inf.alias = -1; | - | ||||||||||||||||||||||||
1030 | inf.constructor = constructor; | - | ||||||||||||||||||||||||
1031 | inf.destructor = destructor; | - | ||||||||||||||||||||||||
1032 | inf.size = size; | - | ||||||||||||||||||||||||
1033 | inf.flags = flags; | - | ||||||||||||||||||||||||
1034 | inf.metaObject = metaObject; | - | ||||||||||||||||||||||||
1035 | if (posInVector == -1) {
| 3-11908 | ||||||||||||||||||||||||
1036 | idx = ct->size() + User; | - | ||||||||||||||||||||||||
1037 | ct->append(inf); | - | ||||||||||||||||||||||||
1038 | } else { executed 11908 times by 316 tests: end of block Executed by:
| 11908 | ||||||||||||||||||||||||
1039 | idx = posInVector + User; | - | ||||||||||||||||||||||||
1040 | ct->data()[posInVector] = inf; | - | ||||||||||||||||||||||||
1041 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||||||||||||||||||||
1042 | return idx; executed 11911 times by 316 tests: return idx; Executed by:
| 11911 | ||||||||||||||||||||||||
1043 | } | - | ||||||||||||||||||||||||
1044 | - | |||||||||||||||||||||||||
1045 | if (idx >= User) {
| 0-12451 | ||||||||||||||||||||||||
1046 | previousSize = ct->at(idx - User).size; | - | ||||||||||||||||||||||||
1047 | previousFlags = ct->at(idx - User).flags; | - | ||||||||||||||||||||||||
1048 | - | |||||||||||||||||||||||||
1049 | // Set new/additional flags in case of old library/app. | - | ||||||||||||||||||||||||
1050 | // Ensures that older code works in conjunction with new Qt releases | - | ||||||||||||||||||||||||
1051 | // requiring the new flags. | - | ||||||||||||||||||||||||
1052 | if (flags != previousFlags) {
| 0-12451 | ||||||||||||||||||||||||
1053 | QCustomTypeInfo &inf = ct->data()[idx - User]; | - | ||||||||||||||||||||||||
1054 | inf.flags |= flags; | - | ||||||||||||||||||||||||
1055 | if (metaObject)
| 0 | ||||||||||||||||||||||||
1056 | inf.metaObject = metaObject; never executed: inf.metaObject = metaObject; | 0 | ||||||||||||||||||||||||
1057 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1058 | } executed 12451 times by 83 tests: end of block Executed by:
| 12451 | ||||||||||||||||||||||||
1059 | } executed 12451 times by 83 tests: end of block Executed by:
| 12451 | ||||||||||||||||||||||||
1060 | - | |||||||||||||||||||||||||
1061 | if (idx < User) {
| 0-12451 | ||||||||||||||||||||||||
1062 | previousSize = QMetaType::sizeOf(idx); | - | ||||||||||||||||||||||||
1063 | previousFlags = QMetaType::typeFlags(idx); | - | ||||||||||||||||||||||||
1064 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1065 | - | |||||||||||||||||||||||||
1066 | if (previousSize != size) {
| 0-12451 | ||||||||||||||||||||||||
1067 | qFatal("QMetaType::registerType: Binary compatibility break " | - | ||||||||||||||||||||||||
1068 | "-- Size mismatch for type '%s' [%i]. Previously registered " | - | ||||||||||||||||||||||||
1069 | "size %i, now registering size %i.", | - | ||||||||||||||||||||||||
1070 | normalizedTypeName.constData(), idx, previousSize, size); | - | ||||||||||||||||||||||||
1071 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1072 | - | |||||||||||||||||||||||||
1073 | // these flags cannot change in a binary compatible way: | - | ||||||||||||||||||||||||
1074 | const int binaryCompatibilityFlag = PointerToQObject | IsEnumeration | SharedPointerToQObject | - | ||||||||||||||||||||||||
1075 | | WeakPointerToQObject | TrackingPointerToQObject; | - | ||||||||||||||||||||||||
1076 | if ((previousFlags ^ flags) & binaryCompatibilityFlag) {
| 0-12451 | ||||||||||||||||||||||||
1077 | - | |||||||||||||||||||||||||
1078 | const char *msg = "QMetaType::registerType: Binary compatibility break. " | - | ||||||||||||||||||||||||
1079 | "\nType flags for type '%s' [%i] don't match. Previously " | - | ||||||||||||||||||||||||
1080 | "registered TypeFlags(0x%x), now registering TypeFlags(0x%x). "; | - | ||||||||||||||||||||||||
1081 | - | |||||||||||||||||||||||||
1082 | qFatal(msg, normalizedTypeName.constData(), idx, previousFlags, int(flags)); | - | ||||||||||||||||||||||||
1083 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1084 | - | |||||||||||||||||||||||||
1085 | return idx; executed 12451 times by 83 tests: return idx; Executed by:
| 12451 | ||||||||||||||||||||||||
1086 | } | - | ||||||||||||||||||||||||
1087 | - | |||||||||||||||||||||||||
1088 | /*! | - | ||||||||||||||||||||||||
1089 | \internal | - | ||||||||||||||||||||||||
1090 | \since 4.7 | - | ||||||||||||||||||||||||
1091 | - | |||||||||||||||||||||||||
1092 | Registers a user type for marshalling, as an alias of another type (typedef) | - | ||||||||||||||||||||||||
1093 | */ | - | ||||||||||||||||||||||||
1094 | int QMetaType::registerTypedef(const char* typeName, int aliasId) | - | ||||||||||||||||||||||||
1095 | { | - | ||||||||||||||||||||||||
1096 | #ifdef QT_NO_QOBJECT | - | ||||||||||||||||||||||||
1097 | NS(QByteArray) normalizedTypeName = typeName; | - | ||||||||||||||||||||||||
1098 | #else | - | ||||||||||||||||||||||||
1099 | NS(QByteArray) normalizedTypeName = QMetaObject::normalizedType(typeName); | - | ||||||||||||||||||||||||
1100 | #endif | - | ||||||||||||||||||||||||
1101 | - | |||||||||||||||||||||||||
1102 | return registerNormalizedTypedef(normalizedTypeName, aliasId); executed 1 time by 1 test: return registerNormalizedTypedef(normalizedTypeName, aliasId); Executed by:
| 1 | ||||||||||||||||||||||||
1103 | } | - | ||||||||||||||||||||||||
1104 | - | |||||||||||||||||||||||||
1105 | /*! | - | ||||||||||||||||||||||||
1106 | \internal | - | ||||||||||||||||||||||||
1107 | \since 5.0 | - | ||||||||||||||||||||||||
1108 | - | |||||||||||||||||||||||||
1109 | Registers a user type for marshalling, as an alias of another type (typedef). | - | ||||||||||||||||||||||||
1110 | Note that normalizedTypeName is not checked for conformance with Qt's normalized format, | - | ||||||||||||||||||||||||
1111 | so it must already conform. | - | ||||||||||||||||||||||||
1112 | */ | - | ||||||||||||||||||||||||
1113 | int QMetaType::registerNormalizedTypedef(const NS(QByteArray) &normalizedTypeName, int aliasId) | - | ||||||||||||||||||||||||
1114 | { | - | ||||||||||||||||||||||||
1115 | QVector<QCustomTypeInfo> *ct = customTypes(); | - | ||||||||||||||||||||||||
1116 | if (!ct || normalizedTypeName.isEmpty())
| 0-836 | ||||||||||||||||||||||||
1117 | return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
1118 | - | |||||||||||||||||||||||||
1119 | int idx = qMetaTypeStaticType(normalizedTypeName.constData(), | - | ||||||||||||||||||||||||
1120 | normalizedTypeName.size()); | - | ||||||||||||||||||||||||
1121 | - | |||||||||||||||||||||||||
1122 | if (idx == UnknownType) {
| 6-830 | ||||||||||||||||||||||||
1123 | QWriteLocker locker(customTypesLock()); | - | ||||||||||||||||||||||||
1124 | int posInVector = -1; | - | ||||||||||||||||||||||||
1125 | idx = qMetaTypeCustomType_unlocked(normalizedTypeName.constData(), | - | ||||||||||||||||||||||||
1126 | normalizedTypeName.size(), | - | ||||||||||||||||||||||||
1127 | &posInVector); | - | ||||||||||||||||||||||||
1128 | - | |||||||||||||||||||||||||
1129 | if (idx == UnknownType) {
| 31-799 | ||||||||||||||||||||||||
1130 | QCustomTypeInfo inf; | - | ||||||||||||||||||||||||
1131 | inf.typeName = normalizedTypeName; | - | ||||||||||||||||||||||||
1132 | inf.alias = aliasId; | - | ||||||||||||||||||||||||
1133 | if (posInVector == -1)
| 0-31 | ||||||||||||||||||||||||
1134 | ct->append(inf); executed 31 times by 20 tests: ct->append(inf); Executed by:
| 31 | ||||||||||||||||||||||||
1135 | else | - | ||||||||||||||||||||||||
1136 | ct->data()[posInVector] = inf; never executed: ct->data()[posInVector] = inf; | 0 | ||||||||||||||||||||||||
1137 | return aliasId; executed 31 times by 20 tests: return aliasId; Executed by:
| 31 | ||||||||||||||||||||||||
1138 | } | - | ||||||||||||||||||||||||
1139 | } executed 799 times by 36 tests: end of block Executed by:
| 799 | ||||||||||||||||||||||||
1140 | - | |||||||||||||||||||||||||
1141 | if (idx != aliasId) {
| 0-805 | ||||||||||||||||||||||||
1142 | qWarning("QMetaType::registerTypedef: " | - | ||||||||||||||||||||||||
1143 | "-- Type name '%s' previously registered as typedef of '%s' [%i], " | - | ||||||||||||||||||||||||
1144 | "now registering as typedef of '%s' [%i].", | - | ||||||||||||||||||||||||
1145 | normalizedTypeName.constData(), QMetaType::typeName(idx), idx, | - | ||||||||||||||||||||||||
1146 | QMetaType::typeName(aliasId), aliasId); | - | ||||||||||||||||||||||||
1147 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1148 | return idx; executed 805 times by 36 tests: return idx; Executed by:
| 805 | ||||||||||||||||||||||||
1149 | } | - | ||||||||||||||||||||||||
1150 | - | |||||||||||||||||||||||||
1151 | /*! | - | ||||||||||||||||||||||||
1152 | Returns \c true if the datatype with ID \a type is registered; | - | ||||||||||||||||||||||||
1153 | otherwise returns \c false. | - | ||||||||||||||||||||||||
1154 | - | |||||||||||||||||||||||||
1155 | \sa type(), typeName(), Type | - | ||||||||||||||||||||||||
1156 | */ | - | ||||||||||||||||||||||||
1157 | bool QMetaType::isRegistered(int type) | - | ||||||||||||||||||||||||
1158 | { | - | ||||||||||||||||||||||||
1159 | // predefined type | - | ||||||||||||||||||||||||
1160 | if ((type >= FirstCoreType && type <= LastCoreType)
| 3-47929 | ||||||||||||||||||||||||
1161 | || (type >= FirstGuiType && type <= LastGuiType)
| 5-15309 | ||||||||||||||||||||||||
1162 | || (type >= FirstWidgetsType && type <= LastWidgetsType)) {
| 3-15030 | ||||||||||||||||||||||||
1163 | return true; executed 32898 times by 20 tests: return true; Executed by:
| 32898 | ||||||||||||||||||||||||
1164 | } | - | ||||||||||||||||||||||||
1165 | - | |||||||||||||||||||||||||
1166 | QReadLocker locker(customTypesLock()); | - | ||||||||||||||||||||||||
1167 | const QVector<QCustomTypeInfo> * const ct = customTypes(); | - | ||||||||||||||||||||||||
1168 | return ((type >= User) && (ct && ct->count() > type - User) && !ct->at(type - User).typeName.isEmpty()); executed 15034 times by 5 tests: return ((type >= User) && (ct && ct->count() > type - User) && !ct->at(type - User).typeName.isEmpty()); Executed by:
| 0-15034 | ||||||||||||||||||||||||
1169 | } | - | ||||||||||||||||||||||||
1170 | - | |||||||||||||||||||||||||
1171 | template <bool tryNormalizedType> | - | ||||||||||||||||||||||||
1172 | static inline int qMetaTypeTypeImpl(const char *typeName, int length) | - | ||||||||||||||||||||||||
1173 | { | - | ||||||||||||||||||||||||
1174 | if (!length)
| 108-1849572 | ||||||||||||||||||||||||
1175 | return QMetaType::UnknownType; executed 108 times by 4 tests: return QMetaType::UnknownType; Executed by:
| 108 | ||||||||||||||||||||||||
1176 | int type = qMetaTypeStaticType(typeName, length); | - | ||||||||||||||||||||||||
1177 | if (type == QMetaType::UnknownType) {
| 515054-1334518 | ||||||||||||||||||||||||
1178 | QReadLocker locker(customTypesLock()); | - | ||||||||||||||||||||||||
1179 | type = qMetaTypeCustomType_unlocked(typeName, length); | - | ||||||||||||||||||||||||
1180 | #ifndef QT_NO_QOBJECT | - | ||||||||||||||||||||||||
1181 | if ((type == QMetaType::UnknownType) && tryNormalizedType) {
| 138-361177 | ||||||||||||||||||||||||
1182 | const NS(QByteArray) normalizedTypeName = QMetaObject::normalizedType(typeName); | - | ||||||||||||||||||||||||
1183 | type = qMetaTypeStaticType(normalizedTypeName.constData(), | - | ||||||||||||||||||||||||
1184 | normalizedTypeName.size()); | - | ||||||||||||||||||||||||
1185 | if (type == QMetaType::UnknownType) {
| 2-136 | ||||||||||||||||||||||||
1186 | type = qMetaTypeCustomType_unlocked(normalizedTypeName.constData(), | - | ||||||||||||||||||||||||
1187 | normalizedTypeName.size()); | - | ||||||||||||||||||||||||
1188 | } executed 136 times by 21 tests: end of block Executed by:
| 136 | ||||||||||||||||||||||||
1189 | } executed 138 times by 21 tests: end of block Executed by:
| 138 | ||||||||||||||||||||||||
1190 | #endif | - | ||||||||||||||||||||||||
1191 | } executed 515054 times by 235 tests: end of block Executed by:
| 515054 | ||||||||||||||||||||||||
1192 | return type; executed 1849572 times by 285 tests: return type; Executed by:
| 1849572 | ||||||||||||||||||||||||
1193 | } | - | ||||||||||||||||||||||||
1194 | - | |||||||||||||||||||||||||
1195 | /*! | - | ||||||||||||||||||||||||
1196 | Returns a handle to the type called \a typeName, or QMetaType::UnknownType if there is | - | ||||||||||||||||||||||||
1197 | no such type. | - | ||||||||||||||||||||||||
1198 | - | |||||||||||||||||||||||||
1199 | \sa isRegistered(), typeName(), Type | - | ||||||||||||||||||||||||
1200 | */ | - | ||||||||||||||||||||||||
1201 | int QMetaType::type(const char *typeName) | - | ||||||||||||||||||||||||
1202 | { | - | ||||||||||||||||||||||||
1203 | return qMetaTypeTypeImpl</*tryNormalizedType=*/true>(typeName, qstrlen(typeName)); executed 66751 times by 31 tests: return qMetaTypeTypeImpl< true>(typeName, qstrlen(typeName)); Executed by:
| 66751 | ||||||||||||||||||||||||
1204 | } | - | ||||||||||||||||||||||||
1205 | - | |||||||||||||||||||||||||
1206 | /*! | - | ||||||||||||||||||||||||
1207 | \a internal | - | ||||||||||||||||||||||||
1208 | - | |||||||||||||||||||||||||
1209 | Similar to QMetaType::type(); the only difference is that this function | - | ||||||||||||||||||||||||
1210 | doesn't attempt to normalize the type name (i.e., the lookup will fail | - | ||||||||||||||||||||||||
1211 | for type names in non-normalized form). | - | ||||||||||||||||||||||||
1212 | */ | - | ||||||||||||||||||||||||
1213 | int qMetaTypeTypeInternal(const char *typeName) | - | ||||||||||||||||||||||||
1214 | { | - | ||||||||||||||||||||||||
1215 | return qMetaTypeTypeImpl</*tryNormalizedType=*/false>(typeName, qstrlen(typeName)); executed 1610441 times by 272 tests: return qMetaTypeTypeImpl< false>(typeName, qstrlen(typeName)); Executed by:
| 1610441 | ||||||||||||||||||||||||
1216 | } | - | ||||||||||||||||||||||||
1217 | - | |||||||||||||||||||||||||
1218 | /*! | - | ||||||||||||||||||||||||
1219 | \since 5.5 | - | ||||||||||||||||||||||||
1220 | \overload | - | ||||||||||||||||||||||||
1221 | - | |||||||||||||||||||||||||
1222 | Returns a handle to the type called \a typeName, or 0 if there is | - | ||||||||||||||||||||||||
1223 | no such type. | - | ||||||||||||||||||||||||
1224 | - | |||||||||||||||||||||||||
1225 | \sa isRegistered(), typeName() | - | ||||||||||||||||||||||||
1226 | */ | - | ||||||||||||||||||||||||
1227 | int QMetaType::type(const QT_PREPEND_NAMESPACE(QByteArray) &typeName) | - | ||||||||||||||||||||||||
1228 | { | - | ||||||||||||||||||||||||
1229 | return qMetaTypeTypeImpl</*tryNormalizedType=*/true>(typeName.constData(), typeName.size()); executed 172488 times by 225 tests: return qMetaTypeTypeImpl< true>(typeName.constData(), typeName.size()); Executed by:
| 172488 | ||||||||||||||||||||||||
1230 | } | - | ||||||||||||||||||||||||
1231 | - | |||||||||||||||||||||||||
1232 | #ifndef QT_NO_DATASTREAM | - | ||||||||||||||||||||||||
1233 | /*! | - | ||||||||||||||||||||||||
1234 | Writes the object pointed to by \a data with the ID \a type to | - | ||||||||||||||||||||||||
1235 | the given \a stream. Returns \c true if the object is saved | - | ||||||||||||||||||||||||
1236 | successfully; otherwise returns \c false. | - | ||||||||||||||||||||||||
1237 | - | |||||||||||||||||||||||||
1238 | The type must have been registered with qRegisterMetaType() and | - | ||||||||||||||||||||||||
1239 | qRegisterMetaTypeStreamOperators() beforehand. | - | ||||||||||||||||||||||||
1240 | - | |||||||||||||||||||||||||
1241 | Normally, you should not need to call this function directly. | - | ||||||||||||||||||||||||
1242 | Instead, use QVariant's \c operator<<(), which relies on save() | - | ||||||||||||||||||||||||
1243 | to stream custom types. | - | ||||||||||||||||||||||||
1244 | - | |||||||||||||||||||||||||
1245 | \sa load(), qRegisterMetaTypeStreamOperators() | - | ||||||||||||||||||||||||
1246 | */ | - | ||||||||||||||||||||||||
1247 | bool QMetaType::save(QDataStream &stream, int type, const void *data) | - | ||||||||||||||||||||||||
1248 | { | - | ||||||||||||||||||||||||
1249 | if (!data || !isRegistered(type))
| 0-16385 | ||||||||||||||||||||||||
1250 | return false; executed 25 times by 1 test: return false; Executed by:
| 25 | ||||||||||||||||||||||||
1251 | - | |||||||||||||||||||||||||
1252 | switch(type) { | - | ||||||||||||||||||||||||
1253 | case QMetaType::UnknownType: never executed: case QMetaType::UnknownType: | 0 | ||||||||||||||||||||||||
1254 | case QMetaType::Void: never executed: case QMetaType::Void: | 0 | ||||||||||||||||||||||||
1255 | case QMetaType::VoidStar: executed 1 time by 1 test: case QMetaType::VoidStar: Executed by:
| 1 | ||||||||||||||||||||||||
1256 | case QMetaType::QObjectStar: executed 1 time by 1 test: case QMetaType::QObjectStar: Executed by:
| 1 | ||||||||||||||||||||||||
1257 | case QMetaType::QModelIndex: executed 1 time by 1 test: case QMetaType::QModelIndex: Executed by:
| 1 | ||||||||||||||||||||||||
1258 | case QMetaType::QPersistentModelIndex: executed 1 time by 1 test: case QMetaType::QPersistentModelIndex: Executed by:
| 1 | ||||||||||||||||||||||||
1259 | case QMetaType::QJsonValue: executed 1 time by 1 test: case QMetaType::QJsonValue: Executed by:
| 1 | ||||||||||||||||||||||||
1260 | case QMetaType::QJsonObject: executed 1 time by 1 test: case QMetaType::QJsonObject: Executed by:
| 1 | ||||||||||||||||||||||||
1261 | case QMetaType::QJsonArray: executed 1 time by 1 test: case QMetaType::QJsonArray: Executed by:
| 1 | ||||||||||||||||||||||||
1262 | case QMetaType::QJsonDocument: executed 1 time by 1 test: case QMetaType::QJsonDocument: Executed by:
| 1 | ||||||||||||||||||||||||
1263 | return false; executed 8 times by 1 test: return false; Executed by:
| 8 | ||||||||||||||||||||||||
1264 | case QMetaType::Long: executed 5 times by 2 tests: case QMetaType::Long: Executed by:
| 5 | ||||||||||||||||||||||||
1265 | stream << qlonglong(*static_cast<const long *>(data)); | - | ||||||||||||||||||||||||
1266 | break; executed 5 times by 2 tests: break; Executed by:
| 5 | ||||||||||||||||||||||||
1267 | case QMetaType::Int: executed 308 times by 8 tests: case QMetaType::Int: Executed by:
| 308 | ||||||||||||||||||||||||
1268 | stream << *static_cast<const int *>(data); | - | ||||||||||||||||||||||||
1269 | break; executed 308 times by 8 tests: break; Executed by:
| 308 | ||||||||||||||||||||||||
1270 | case QMetaType::Short: executed 5 times by 2 tests: case QMetaType::Short: Executed by:
| 5 | ||||||||||||||||||||||||
1271 | stream << *static_cast<const short *>(data); | - | ||||||||||||||||||||||||
1272 | break; executed 5 times by 2 tests: break; Executed by:
| 5 | ||||||||||||||||||||||||
1273 | case QMetaType::Char: executed 5 times by 2 tests: case QMetaType::Char: Executed by:
| 5 | ||||||||||||||||||||||||
1274 | // force a char to be signed | - | ||||||||||||||||||||||||
1275 | stream << *static_cast<const signed char *>(data); | - | ||||||||||||||||||||||||
1276 | break; executed 5 times by 2 tests: break; Executed by:
| 5 | ||||||||||||||||||||||||
1277 | case QMetaType::ULong: executed 5 times by 2 tests: case QMetaType::ULong: Executed by:
| 5 | ||||||||||||||||||||||||
1278 | stream << qulonglong(*static_cast<const ulong *>(data)); | - | ||||||||||||||||||||||||
1279 | break; executed 5 times by 2 tests: break; Executed by:
| 5 | ||||||||||||||||||||||||
1280 | case QMetaType::UInt: executed 4 times by 2 tests: case QMetaType::UInt: Executed by:
| 4 | ||||||||||||||||||||||||
1281 | stream << *static_cast<const uint *>(data); | - | ||||||||||||||||||||||||
1282 | break; executed 4 times by 2 tests: break; Executed by:
| 4 | ||||||||||||||||||||||||
1283 | case QMetaType::LongLong: executed 3 times by 2 tests: case QMetaType::LongLong: Executed by:
| 3 | ||||||||||||||||||||||||
1284 | stream << *static_cast<const qlonglong *>(data); | - | ||||||||||||||||||||||||
1285 | break; executed 3 times by 2 tests: break; Executed by:
| 3 | ||||||||||||||||||||||||
1286 | case QMetaType::ULongLong: executed 3 times by 2 tests: case QMetaType::ULongLong: Executed by:
| 3 | ||||||||||||||||||||||||
1287 | stream << *static_cast<const qulonglong *>(data); | - | ||||||||||||||||||||||||
1288 | break; executed 3 times by 2 tests: break; Executed by:
| 3 | ||||||||||||||||||||||||
1289 | case QMetaType::UShort: executed 5 times by 2 tests: case QMetaType::UShort: Executed by:
| 5 | ||||||||||||||||||||||||
1290 | stream << *static_cast<const ushort *>(data); | - | ||||||||||||||||||||||||
1291 | break; executed 5 times by 2 tests: break; Executed by:
| 5 | ||||||||||||||||||||||||
1292 | case QMetaType::SChar: executed 1 time by 1 test: case QMetaType::SChar: Executed by:
| 1 | ||||||||||||||||||||||||
1293 | stream << *static_cast<const signed char *>(data); | - | ||||||||||||||||||||||||
1294 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||||||||||||||||||||
1295 | case QMetaType::UChar: executed 5 times by 2 tests: case QMetaType::UChar: Executed by:
| 5 | ||||||||||||||||||||||||
1296 | stream << *static_cast<const uchar *>(data); | - | ||||||||||||||||||||||||
1297 | break; executed 5 times by 2 tests: break; Executed by:
| 5 | ||||||||||||||||||||||||
1298 | case QMetaType::Bool: executed 75 times by 3 tests: case QMetaType::Bool: Executed by:
| 75 | ||||||||||||||||||||||||
1299 | stream << qint8(*static_cast<const bool *>(data)); | - | ||||||||||||||||||||||||
1300 | break; executed 75 times by 3 tests: break; Executed by:
| 75 | ||||||||||||||||||||||||
1301 | case QMetaType::Float: executed 7 times by 2 tests: case QMetaType::Float: Executed by:
| 7 | ||||||||||||||||||||||||
1302 | stream << *static_cast<const float *>(data); | - | ||||||||||||||||||||||||
1303 | break; executed 7 times by 2 tests: break; Executed by:
| 7 | ||||||||||||||||||||||||
1304 | case QMetaType::Double: executed 6 times by 2 tests: case QMetaType::Double: Executed by:
| 6 | ||||||||||||||||||||||||
1305 | stream << *static_cast<const double *>(data); | - | ||||||||||||||||||||||||
1306 | break; executed 6 times by 2 tests: break; Executed by:
| 6 | ||||||||||||||||||||||||
1307 | case QMetaType::QChar: executed 5 times by 2 tests: case QMetaType::QChar: Executed by:
| 5 | ||||||||||||||||||||||||
1308 | stream << *static_cast<const NS(QChar) *>(data); | - | ||||||||||||||||||||||||
1309 | break; executed 5 times by 2 tests: break; Executed by:
| 5 | ||||||||||||||||||||||||
1310 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
1311 | case QMetaType::QVariantMap: executed 77 times by 3 tests: case QMetaType::QVariantMap: Executed by:
| 77 | ||||||||||||||||||||||||
1312 | stream << *static_cast<const NS(QVariantMap)*>(data); | - | ||||||||||||||||||||||||
1313 | break; executed 77 times by 3 tests: break; Executed by:
| 77 | ||||||||||||||||||||||||
1314 | case QMetaType::QVariantHash: executed 3 times by 2 tests: case QMetaType::QVariantHash: Executed by:
| 3 | ||||||||||||||||||||||||
1315 | stream << *static_cast<const NS(QVariantHash)*>(data); | - | ||||||||||||||||||||||||
1316 | break; executed 3 times by 2 tests: break; Executed by:
| 3 | ||||||||||||||||||||||||
1317 | case QMetaType::QVariantList: executed 61 times by 3 tests: case QMetaType::QVariantList: Executed by:
| 61 | ||||||||||||||||||||||||
1318 | stream << *static_cast<const NS(QVariantList)*>(data); | - | ||||||||||||||||||||||||
1319 | break; executed 61 times by 3 tests: break; Executed by:
| 61 | ||||||||||||||||||||||||
1320 | case QMetaType::QVariant: executed 3 times by 2 tests: case QMetaType::QVariant: Executed by:
| 3 | ||||||||||||||||||||||||
1321 | stream << *static_cast<const NS(QVariant)*>(data); | - | ||||||||||||||||||||||||
1322 | break; executed 3 times by 2 tests: break; Executed by:
| 3 | ||||||||||||||||||||||||
1323 | case QMetaType::QByteArrayList: executed 1 time by 1 test: case QMetaType::QByteArrayList: Executed by:
| 1 | ||||||||||||||||||||||||
1324 | stream << *static_cast<const NS(QByteArrayList)*>(data); | - | ||||||||||||||||||||||||
1325 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||||||||||||||||||||
1326 | #endif | - | ||||||||||||||||||||||||
1327 | case QMetaType::QByteArray: executed 14 times by 4 tests: case QMetaType::QByteArray: Executed by:
| 14 | ||||||||||||||||||||||||
1328 | stream << *static_cast<const NS(QByteArray)*>(data); | - | ||||||||||||||||||||||||
1329 | break; executed 14 times by 4 tests: break; Executed by:
| 14 | ||||||||||||||||||||||||
1330 | case QMetaType::QString: executed 12681 times by 12 tests: case QMetaType::QString: Executed by:
| 12681 | ||||||||||||||||||||||||
1331 | stream << *static_cast<const NS(QString)*>(data); | - | ||||||||||||||||||||||||
1332 | break; executed 12681 times by 12 tests: break; Executed by:
| 12681 | ||||||||||||||||||||||||
1333 | case QMetaType::QStringList: executed 25 times by 3 tests: case QMetaType::QStringList: Executed by:
| 25 | ||||||||||||||||||||||||
1334 | stream << *static_cast<const NS(QStringList)*>(data); | - | ||||||||||||||||||||||||
1335 | break; executed 25 times by 3 tests: break; Executed by:
| 25 | ||||||||||||||||||||||||
1336 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
1337 | case QMetaType::QBitArray: executed 5 times by 2 tests: case QMetaType::QBitArray: Executed by:
| 5 | ||||||||||||||||||||||||
1338 | stream << *static_cast<const NS(QBitArray)*>(data); | - | ||||||||||||||||||||||||
1339 | break; executed 5 times by 2 tests: break; Executed by:
| 5 | ||||||||||||||||||||||||
1340 | #endif | - | ||||||||||||||||||||||||
1341 | case QMetaType::QDate: executed 89 times by 3 tests: case QMetaType::QDate: Executed by:
| 89 | ||||||||||||||||||||||||
1342 | stream << *static_cast<const NS(QDate)*>(data); | - | ||||||||||||||||||||||||
1343 | break; executed 89 times by 3 tests: break; Executed by:
| 89 | ||||||||||||||||||||||||
1344 | case QMetaType::QTime: executed 85 times by 3 tests: case QMetaType::QTime: Executed by:
| 85 | ||||||||||||||||||||||||
1345 | stream << *static_cast<const NS(QTime)*>(data); | - | ||||||||||||||||||||||||
1346 | break; executed 85 times by 3 tests: break; Executed by:
| 85 | ||||||||||||||||||||||||
1347 | case QMetaType::QDateTime: executed 13 times by 3 tests: case QMetaType::QDateTime: Executed by:
| 13 | ||||||||||||||||||||||||
1348 | stream << *static_cast<const NS(QDateTime)*>(data); | - | ||||||||||||||||||||||||
1349 | break; executed 13 times by 3 tests: break; Executed by:
| 13 | ||||||||||||||||||||||||
1350 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
1351 | case QMetaType::QUrl: executed 3 times by 2 tests: case QMetaType::QUrl: Executed by:
| 3 | ||||||||||||||||||||||||
1352 | stream << *static_cast<const NS(QUrl)*>(data); | - | ||||||||||||||||||||||||
1353 | break; executed 3 times by 2 tests: break; Executed by:
| 3 | ||||||||||||||||||||||||
1354 | #endif | - | ||||||||||||||||||||||||
1355 | case QMetaType::QLocale: executed 3 times by 2 tests: case QMetaType::QLocale: Executed by:
| 3 | ||||||||||||||||||||||||
1356 | stream << *static_cast<const NS(QLocale)*>(data); | - | ||||||||||||||||||||||||
1357 | break; executed 3 times by 2 tests: break; Executed by:
| 3 | ||||||||||||||||||||||||
1358 | #ifndef QT_NO_GEOM_VARIANT | - | ||||||||||||||||||||||||
1359 | case QMetaType::QRect: executed 2559 times by 4 tests: case QMetaType::QRect: Executed by:
| 2559 | ||||||||||||||||||||||||
1360 | stream << *static_cast<const NS(QRect)*>(data); | - | ||||||||||||||||||||||||
1361 | break; executed 2559 times by 4 tests: break; Executed by:
| 2559 | ||||||||||||||||||||||||
1362 | case QMetaType::QRectF: executed 3 times by 2 tests: case QMetaType::QRectF: Executed by:
| 3 | ||||||||||||||||||||||||
1363 | stream << *static_cast<const NS(QRectF)*>(data); | - | ||||||||||||||||||||||||
1364 | break; executed 3 times by 2 tests: break; Executed by:
| 3 | ||||||||||||||||||||||||
1365 | case QMetaType::QSize: executed 58 times by 4 tests: case QMetaType::QSize: Executed by:
| 58 | ||||||||||||||||||||||||
1366 | stream << *static_cast<const NS(QSize)*>(data); | - | ||||||||||||||||||||||||
1367 | break; executed 58 times by 4 tests: break; Executed by:
| 58 | ||||||||||||||||||||||||
1368 | case QMetaType::QSizeF: executed 3 times by 2 tests: case QMetaType::QSizeF: Executed by:
| 3 | ||||||||||||||||||||||||
1369 | stream << *static_cast<const NS(QSizeF)*>(data); | - | ||||||||||||||||||||||||
1370 | break; executed 3 times by 2 tests: break; Executed by:
| 3 | ||||||||||||||||||||||||
1371 | case QMetaType::QLine: executed 3 times by 2 tests: case QMetaType::QLine: Executed by:
| 3 | ||||||||||||||||||||||||
1372 | stream << *static_cast<const NS(QLine)*>(data); | - | ||||||||||||||||||||||||
1373 | break; executed 3 times by 2 tests: break; Executed by:
| 3 | ||||||||||||||||||||||||
1374 | case QMetaType::QLineF: executed 3 times by 2 tests: case QMetaType::QLineF: Executed by:
| 3 | ||||||||||||||||||||||||
1375 | stream << *static_cast<const NS(QLineF)*>(data); | - | ||||||||||||||||||||||||
1376 | break; executed 3 times by 2 tests: break; Executed by:
| 3 | ||||||||||||||||||||||||
1377 | case QMetaType::QPoint: executed 55 times by 3 tests: case QMetaType::QPoint: Executed by:
| 55 | ||||||||||||||||||||||||
1378 | stream << *static_cast<const NS(QPoint)*>(data); | - | ||||||||||||||||||||||||
1379 | break; executed 55 times by 3 tests: break; Executed by:
| 55 | ||||||||||||||||||||||||
1380 | case QMetaType::QPointF: executed 3 times by 2 tests: case QMetaType::QPointF: Executed by:
| 3 | ||||||||||||||||||||||||
1381 | stream << *static_cast<const NS(QPointF)*>(data); | - | ||||||||||||||||||||||||
1382 | break; executed 3 times by 2 tests: break; Executed by:
| 3 | ||||||||||||||||||||||||
1383 | #endif | - | ||||||||||||||||||||||||
1384 | #ifndef QT_NO_REGEXP | - | ||||||||||||||||||||||||
1385 | case QMetaType::QRegExp: executed 47 times by 3 tests: case QMetaType::QRegExp: Executed by:
| 47 | ||||||||||||||||||||||||
1386 | stream << *static_cast<const NS(QRegExp)*>(data); | - | ||||||||||||||||||||||||
1387 | break; executed 47 times by 3 tests: break; Executed by:
| 47 | ||||||||||||||||||||||||
1388 | #endif | - | ||||||||||||||||||||||||
1389 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
1390 | #ifndef QT_NO_REGULAREXPRESSION | - | ||||||||||||||||||||||||
1391 | case QMetaType::QRegularExpression: executed 4 times by 2 tests: case QMetaType::QRegularExpression: Executed by:
| 4 | ||||||||||||||||||||||||
1392 | stream << *static_cast<const NS(QRegularExpression)*>(data); | - | ||||||||||||||||||||||||
1393 | break; executed 4 times by 2 tests: break; Executed by:
| 4 | ||||||||||||||||||||||||
1394 | #endif // QT_NO_REGULAREXPRESSION | - | ||||||||||||||||||||||||
1395 | case QMetaType::QEasingCurve: executed 1 time by 1 test: case QMetaType::QEasingCurve: Executed by:
| 1 | ||||||||||||||||||||||||
1396 | stream << *static_cast<const NS(QEasingCurve)*>(data); | - | ||||||||||||||||||||||||
1397 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||||||||||||||||||||
1398 | #endif // QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
1399 | case QMetaType::QFont: executed 2 times by 2 tests: case QMetaType::QFont: Executed by:
| 2 | ||||||||||||||||||||||||
1400 | case QMetaType::QPixmap: executed 3 times by 2 tests: case QMetaType::QPixmap: Executed by:
| 3 | ||||||||||||||||||||||||
1401 | case QMetaType::QBrush: executed 3 times by 2 tests: case QMetaType::QBrush: Executed by:
| 3 | ||||||||||||||||||||||||
1402 | case QMetaType::QColor: executed 101 times by 2 tests: case QMetaType::QColor: Executed by:
| 101 | ||||||||||||||||||||||||
1403 | case QMetaType::QPalette: executed 1 time by 1 test: case QMetaType::QPalette: Executed by:
| 1 | ||||||||||||||||||||||||
1404 | case QMetaType::QImage: executed 1 time by 1 test: case QMetaType::QImage: Executed by:
| 1 | ||||||||||||||||||||||||
1405 | case QMetaType::QPolygon: executed 2 times by 1 test: case QMetaType::QPolygon: Executed by:
| 2 | ||||||||||||||||||||||||
1406 | case QMetaType::QPolygonF: executed 3 times by 1 test: case QMetaType::QPolygonF: Executed by:
| 3 | ||||||||||||||||||||||||
1407 | case QMetaType::QRegion: executed 2 times by 1 test: case QMetaType::QRegion: Executed by:
| 2 | ||||||||||||||||||||||||
1408 | case QMetaType::QBitmap: executed 2 times by 1 test: case QMetaType::QBitmap: Executed by:
| 2 | ||||||||||||||||||||||||
1409 | case QMetaType::QCursor: executed 1 time by 1 test: case QMetaType::QCursor: Executed by:
| 1 | ||||||||||||||||||||||||
1410 | case QMetaType::QKeySequence: executed 3 times by 2 tests: case QMetaType::QKeySequence: Executed by:
| 3 | ||||||||||||||||||||||||
1411 | case QMetaType::QPen: executed 1 time by 1 test: case QMetaType::QPen: Executed by:
| 1 | ||||||||||||||||||||||||
1412 | case QMetaType::QTextLength: never executed: case QMetaType::QTextLength: | 0 | ||||||||||||||||||||||||
1413 | case QMetaType::QTextFormat: never executed: case QMetaType::QTextFormat: | 0 | ||||||||||||||||||||||||
1414 | case QMetaType::QMatrix: never executed: case QMetaType::QMatrix: | 0 | ||||||||||||||||||||||||
1415 | case QMetaType::QTransform: never executed: case QMetaType::QTransform: | 0 | ||||||||||||||||||||||||
1416 | case QMetaType::QMatrix4x4: never executed: case QMetaType::QMatrix4x4: | 0 | ||||||||||||||||||||||||
1417 | case QMetaType::QVector2D: never executed: case QMetaType::QVector2D: | 0 | ||||||||||||||||||||||||
1418 | case QMetaType::QVector3D: never executed: case QMetaType::QVector3D: | 0 | ||||||||||||||||||||||||
1419 | case QMetaType::QVector4D: never executed: case QMetaType::QVector4D: | 0 | ||||||||||||||||||||||||
1420 | case QMetaType::QQuaternion: never executed: case QMetaType::QQuaternion: | 0 | ||||||||||||||||||||||||
1421 | case QMetaType::QIcon: never executed: case QMetaType::QIcon: | 0 | ||||||||||||||||||||||||
1422 | if (!qMetaTypeGuiHelper)
| 0-125 | ||||||||||||||||||||||||
1423 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
1424 | qMetaTypeGuiHelper[type - FirstGuiType].saveOp(stream, data); | - | ||||||||||||||||||||||||
1425 | break; executed 125 times by 3 tests: break; Executed by:
| 125 | ||||||||||||||||||||||||
1426 | case QMetaType::QSizePolicy: executed 1 time by 1 test: case QMetaType::QSizePolicy: Executed by:
| 1 | ||||||||||||||||||||||||
1427 | if (!qMetaTypeWidgetsHelper)
| 0-1 | ||||||||||||||||||||||||
1428 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
1429 | qMetaTypeWidgetsHelper[type - FirstWidgetsType].saveOp(stream, data); | - | ||||||||||||||||||||||||
1430 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||||||||||||||||||||
1431 | case QMetaType::QUuid: executed 2 times by 2 tests: case QMetaType::QUuid: Executed by:
| 2 | ||||||||||||||||||||||||
1432 | stream << *static_cast<const NS(QUuid)*>(data); | - | ||||||||||||||||||||||||
1433 | break; executed 2 times by 2 tests: break; Executed by:
| 2 | ||||||||||||||||||||||||
1434 | default: { executed 5 times by 3 tests: default: Executed by:
| 5 | ||||||||||||||||||||||||
1435 | const QVector<QCustomTypeInfo> * const ct = customTypes(); | - | ||||||||||||||||||||||||
1436 | if (!ct)
| 0-5 | ||||||||||||||||||||||||
1437 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
1438 | - | |||||||||||||||||||||||||
1439 | SaveOperator saveOp = 0; | - | ||||||||||||||||||||||||
1440 | { | - | ||||||||||||||||||||||||
1441 | QReadLocker locker(customTypesLock()); | - | ||||||||||||||||||||||||
1442 | saveOp = ct->at(type - User).saveOp; | - | ||||||||||||||||||||||||
1443 | } | - | ||||||||||||||||||||||||
1444 | - | |||||||||||||||||||||||||
1445 | if (!saveOp)
| 1-4 | ||||||||||||||||||||||||
1446 | return false; executed 1 time by 1 test: return false; Executed by:
| 1 | ||||||||||||||||||||||||
1447 | saveOp(stream, data); | - | ||||||||||||||||||||||||
1448 | break; } executed 4 times by 3 tests: break; Executed by:
| 4 | ||||||||||||||||||||||||
1449 | } | - | ||||||||||||||||||||||||
1450 | - | |||||||||||||||||||||||||
1451 | return true; executed 16376 times by 17 tests: return true; Executed by:
| 16376 | ||||||||||||||||||||||||
1452 | } | - | ||||||||||||||||||||||||
1453 | - | |||||||||||||||||||||||||
1454 | /*! | - | ||||||||||||||||||||||||
1455 | Reads the object of the specified \a type from the given \a | - | ||||||||||||||||||||||||
1456 | stream into \a data. Returns \c true if the object is loaded | - | ||||||||||||||||||||||||
1457 | successfully; otherwise returns \c false. | - | ||||||||||||||||||||||||
1458 | - | |||||||||||||||||||||||||
1459 | The type must have been registered with qRegisterMetaType() and | - | ||||||||||||||||||||||||
1460 | qRegisterMetaTypeStreamOperators() beforehand. | - | ||||||||||||||||||||||||
1461 | - | |||||||||||||||||||||||||
1462 | Normally, you should not need to call this function directly. | - | ||||||||||||||||||||||||
1463 | Instead, use QVariant's \c operator>>(), which relies on load() | - | ||||||||||||||||||||||||
1464 | to stream custom types. | - | ||||||||||||||||||||||||
1465 | - | |||||||||||||||||||||||||
1466 | \sa save(), qRegisterMetaTypeStreamOperators() | - | ||||||||||||||||||||||||
1467 | */ | - | ||||||||||||||||||||||||
1468 | bool QMetaType::load(QDataStream &stream, int type, void *data) | - | ||||||||||||||||||||||||
1469 | { | - | ||||||||||||||||||||||||
1470 | if (!data || !isRegistered(type))
| 0-16446 | ||||||||||||||||||||||||
1471 | return false; executed 25 times by 1 test: return false; Executed by:
| 25 | ||||||||||||||||||||||||
1472 | - | |||||||||||||||||||||||||
1473 | switch(type) { | - | ||||||||||||||||||||||||
1474 | case QMetaType::UnknownType: never executed: case QMetaType::UnknownType: | 0 | ||||||||||||||||||||||||
1475 | case QMetaType::Void: never executed: case QMetaType::Void: | 0 | ||||||||||||||||||||||||
1476 | case QMetaType::VoidStar: executed 1 time by 1 test: case QMetaType::VoidStar: Executed by:
| 1 | ||||||||||||||||||||||||
1477 | case QMetaType::QObjectStar: executed 1 time by 1 test: case QMetaType::QObjectStar: Executed by:
| 1 | ||||||||||||||||||||||||
1478 | case QMetaType::QModelIndex: executed 1 time by 1 test: case QMetaType::QModelIndex: Executed by:
| 1 | ||||||||||||||||||||||||
1479 | case QMetaType::QPersistentModelIndex: executed 1 time by 1 test: case QMetaType::QPersistentModelIndex: Executed by:
| 1 | ||||||||||||||||||||||||
1480 | case QMetaType::QJsonValue: executed 1 time by 1 test: case QMetaType::QJsonValue: Executed by:
| 1 | ||||||||||||||||||||||||
1481 | case QMetaType::QJsonObject: executed 1 time by 1 test: case QMetaType::QJsonObject: Executed by:
| 1 | ||||||||||||||||||||||||
1482 | case QMetaType::QJsonArray: executed 1 time by 1 test: case QMetaType::QJsonArray: Executed by:
| 1 | ||||||||||||||||||||||||
1483 | case QMetaType::QJsonDocument: executed 1 time by 1 test: case QMetaType::QJsonDocument: Executed by:
| 1 | ||||||||||||||||||||||||
1484 | return false; executed 8 times by 1 test: return false; Executed by:
| 8 | ||||||||||||||||||||||||
1485 | case QMetaType::Long: { executed 9 times by 2 tests: case QMetaType::Long: Executed by:
| 9 | ||||||||||||||||||||||||
1486 | qlonglong l; | - | ||||||||||||||||||||||||
1487 | stream >> l; | - | ||||||||||||||||||||||||
1488 | *static_cast<long *>(data) = long(l); | - | ||||||||||||||||||||||||
1489 | break; } executed 9 times by 2 tests: break; Executed by:
| 9 | ||||||||||||||||||||||||
1490 | case QMetaType::Int: executed 205 times by 7 tests: case QMetaType::Int: Executed by:
| 205 | ||||||||||||||||||||||||
1491 | stream >> *static_cast<int *>(data); | - | ||||||||||||||||||||||||
1492 | break; executed 205 times by 7 tests: break; Executed by:
| 205 | ||||||||||||||||||||||||
1493 | case QMetaType::Short: executed 9 times by 2 tests: case QMetaType::Short: Executed by:
| 9 | ||||||||||||||||||||||||
1494 | stream >> *static_cast<short *>(data); | - | ||||||||||||||||||||||||
1495 | break; executed 9 times by 2 tests: break; Executed by:
| 9 | ||||||||||||||||||||||||
1496 | case QMetaType::Char: executed 9 times by 2 tests: case QMetaType::Char: Executed by:
| 9 | ||||||||||||||||||||||||
1497 | // force a char to be signed | - | ||||||||||||||||||||||||
1498 | stream >> *static_cast<signed char *>(data); | - | ||||||||||||||||||||||||
1499 | break; executed 9 times by 2 tests: break; Executed by:
| 9 | ||||||||||||||||||||||||
1500 | case QMetaType::ULong: { executed 9 times by 2 tests: case QMetaType::ULong: Executed by:
| 9 | ||||||||||||||||||||||||
1501 | qulonglong ul; | - | ||||||||||||||||||||||||
1502 | stream >> ul; | - | ||||||||||||||||||||||||
1503 | *static_cast<ulong *>(data) = ulong(ul); | - | ||||||||||||||||||||||||
1504 | break; } executed 9 times by 2 tests: break; Executed by:
| 9 | ||||||||||||||||||||||||
1505 | case QMetaType::UInt: executed 8 times by 2 tests: case QMetaType::UInt: Executed by:
| 8 | ||||||||||||||||||||||||
1506 | stream >> *static_cast<uint *>(data); | - | ||||||||||||||||||||||||
1507 | break; executed 8 times by 2 tests: break; Executed by:
| 8 | ||||||||||||||||||||||||
1508 | case QMetaType::LongLong: executed 7 times by 2 tests: case QMetaType::LongLong: Executed by:
| 7 | ||||||||||||||||||||||||
1509 | stream >> *static_cast<qlonglong *>(data); | - | ||||||||||||||||||||||||
1510 | break; executed 7 times by 2 tests: break; Executed by:
| 7 | ||||||||||||||||||||||||
1511 | case QMetaType::ULongLong: executed 7 times by 2 tests: case QMetaType::ULongLong: Executed by:
| 7 | ||||||||||||||||||||||||
1512 | stream >> *static_cast<qulonglong *>(data); | - | ||||||||||||||||||||||||
1513 | break; executed 7 times by 2 tests: break; Executed by:
| 7 | ||||||||||||||||||||||||
1514 | case QMetaType::UShort: executed 9 times by 2 tests: case QMetaType::UShort: Executed by:
| 9 | ||||||||||||||||||||||||
1515 | stream >> *static_cast<ushort *>(data); | - | ||||||||||||||||||||||||
1516 | break; executed 9 times by 2 tests: break; Executed by:
| 9 | ||||||||||||||||||||||||
1517 | case QMetaType::SChar: executed 3 times by 1 test: case QMetaType::SChar: Executed by:
| 3 | ||||||||||||||||||||||||
1518 | stream >> *static_cast<signed char *>(data); | - | ||||||||||||||||||||||||
1519 | break; executed 3 times by 1 test: break; Executed by:
| 3 | ||||||||||||||||||||||||
1520 | case QMetaType::UChar: executed 9 times by 2 tests: case QMetaType::UChar: Executed by:
| 9 | ||||||||||||||||||||||||
1521 | stream >> *static_cast<uchar *>(data); | - | ||||||||||||||||||||||||
1522 | break; executed 9 times by 2 tests: break; Executed by:
| 9 | ||||||||||||||||||||||||
1523 | case QMetaType::Bool: { executed 79 times by 3 tests: case QMetaType::Bool: Executed by:
| 79 | ||||||||||||||||||||||||
1524 | qint8 b; | - | ||||||||||||||||||||||||
1525 | stream >> b; | - | ||||||||||||||||||||||||
1526 | *static_cast<bool *>(data) = b; | - | ||||||||||||||||||||||||
1527 | break; } executed 79 times by 3 tests: break; Executed by:
| 79 | ||||||||||||||||||||||||
1528 | case QMetaType::Float: executed 11 times by 2 tests: case QMetaType::Float: Executed by:
| 11 | ||||||||||||||||||||||||
1529 | stream >> *static_cast<float *>(data); | - | ||||||||||||||||||||||||
1530 | break; executed 11 times by 2 tests: break; Executed by:
| 11 | ||||||||||||||||||||||||
1531 | case QMetaType::Double: executed 10 times by 2 tests: case QMetaType::Double: Executed by:
| 10 | ||||||||||||||||||||||||
1532 | stream >> *static_cast<double *>(data); | - | ||||||||||||||||||||||||
1533 | break; executed 10 times by 2 tests: break; Executed by:
| 10 | ||||||||||||||||||||||||
1534 | case QMetaType::QChar: executed 9 times by 2 tests: case QMetaType::QChar: Executed by:
| 9 | ||||||||||||||||||||||||
1535 | stream >> *static_cast< NS(QChar)*>(data); | - | ||||||||||||||||||||||||
1536 | break; executed 9 times by 2 tests: break; Executed by:
| 9 | ||||||||||||||||||||||||
1537 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
1538 | case QMetaType::QVariantMap: executed 80 times by 3 tests: case QMetaType::QVariantMap: Executed by:
| 80 | ||||||||||||||||||||||||
1539 | stream >> *static_cast< NS(QVariantMap)*>(data); | - | ||||||||||||||||||||||||
1540 | break; executed 80 times by 3 tests: break; Executed by:
| 80 | ||||||||||||||||||||||||
1541 | case QMetaType::QVariantHash: executed 7 times by 2 tests: case QMetaType::QVariantHash: Executed by:
| 7 | ||||||||||||||||||||||||
1542 | stream >> *static_cast< NS(QVariantHash)*>(data); | - | ||||||||||||||||||||||||
1543 | break; executed 7 times by 2 tests: break; Executed by:
| 7 | ||||||||||||||||||||||||
1544 | case QMetaType::QVariantList: executed 50 times by 3 tests: case QMetaType::QVariantList: Executed by:
| 50 | ||||||||||||||||||||||||
1545 | stream >> *static_cast< NS(QVariantList)*>(data); | - | ||||||||||||||||||||||||
1546 | break; executed 50 times by 3 tests: break; Executed by:
| 50 | ||||||||||||||||||||||||
1547 | case QMetaType::QVariant: executed 7 times by 2 tests: case QMetaType::QVariant: Executed by:
| 7 | ||||||||||||||||||||||||
1548 | stream >> *static_cast< NS(QVariant)*>(data); | - | ||||||||||||||||||||||||
1549 | break; executed 7 times by 2 tests: break; Executed by:
| 7 | ||||||||||||||||||||||||
1550 | case QMetaType::QByteArrayList: executed 3 times by 1 test: case QMetaType::QByteArrayList: Executed by:
| 3 | ||||||||||||||||||||||||
1551 | stream >> *static_cast< NS(QByteArrayList)*>(data); | - | ||||||||||||||||||||||||
1552 | break; executed 3 times by 1 test: break; Executed by:
| 3 | ||||||||||||||||||||||||
1553 | #endif | - | ||||||||||||||||||||||||
1554 | case QMetaType::QByteArray: executed 17 times by 3 tests: case QMetaType::QByteArray: Executed by:
| 17 | ||||||||||||||||||||||||
1555 | stream >> *static_cast< NS(QByteArray)*>(data); | - | ||||||||||||||||||||||||
1556 | break; executed 17 times by 3 tests: break; Executed by:
| 17 | ||||||||||||||||||||||||
1557 | case QMetaType::QString: executed 12725 times by 11 tests: case QMetaType::QString: Executed by:
| 12725 | ||||||||||||||||||||||||
1558 | stream >> *static_cast< NS(QString)*>(data); | - | ||||||||||||||||||||||||
1559 | break; executed 12725 times by 11 tests: break; Executed by:
| 12725 | ||||||||||||||||||||||||
1560 | case QMetaType::QStringList: executed 25 times by 3 tests: case QMetaType::QStringList: Executed by:
| 25 | ||||||||||||||||||||||||
1561 | stream >> *static_cast< NS(QStringList)*>(data); | - | ||||||||||||||||||||||||
1562 | break; executed 25 times by 3 tests: break; Executed by:
| 25 | ||||||||||||||||||||||||
1563 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
1564 | case QMetaType::QBitArray: executed 9 times by 2 tests: case QMetaType::QBitArray: Executed by:
| 9 | ||||||||||||||||||||||||
1565 | stream >> *static_cast< NS(QBitArray)*>(data); | - | ||||||||||||||||||||||||
1566 | break; executed 9 times by 2 tests: break; Executed by:
| 9 | ||||||||||||||||||||||||
1567 | #endif | - | ||||||||||||||||||||||||
1568 | case QMetaType::QDate: executed 93 times by 3 tests: case QMetaType::QDate: Executed by:
| 93 | ||||||||||||||||||||||||
1569 | stream >> *static_cast< NS(QDate)*>(data); | - | ||||||||||||||||||||||||
1570 | break; executed 93 times by 3 tests: break; Executed by:
| 93 | ||||||||||||||||||||||||
1571 | case QMetaType::QTime: executed 89 times by 3 tests: case QMetaType::QTime: Executed by:
| 89 | ||||||||||||||||||||||||
1572 | stream >> *static_cast< NS(QTime)*>(data); | - | ||||||||||||||||||||||||
1573 | break; executed 89 times by 3 tests: break; Executed by:
| 89 | ||||||||||||||||||||||||
1574 | case QMetaType::QDateTime: executed 17 times by 3 tests: case QMetaType::QDateTime: Executed by:
| 17 | ||||||||||||||||||||||||
1575 | stream >> *static_cast< NS(QDateTime)*>(data); | - | ||||||||||||||||||||||||
1576 | break; executed 17 times by 3 tests: break; Executed by:
| 17 | ||||||||||||||||||||||||
1577 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
1578 | case QMetaType::QUrl: executed 7 times by 2 tests: case QMetaType::QUrl: Executed by:
| 7 | ||||||||||||||||||||||||
1579 | stream >> *static_cast< NS(QUrl)*>(data); | - | ||||||||||||||||||||||||
1580 | break; executed 7 times by 2 tests: break; Executed by:
| 7 | ||||||||||||||||||||||||
1581 | #endif | - | ||||||||||||||||||||||||
1582 | case QMetaType::QLocale: executed 7 times by 2 tests: case QMetaType::QLocale: Executed by:
| 7 | ||||||||||||||||||||||||
1583 | stream >> *static_cast< NS(QLocale)*>(data); | - | ||||||||||||||||||||||||
1584 | break; executed 7 times by 2 tests: break; Executed by:
| 7 | ||||||||||||||||||||||||
1585 | #ifndef QT_NO_GEOM_VARIANT | - | ||||||||||||||||||||||||
1586 | case QMetaType::QRect: executed 2554 times by 4 tests: case QMetaType::QRect: Executed by:
| 2554 | ||||||||||||||||||||||||
1587 | stream >> *static_cast< NS(QRect)*>(data); | - | ||||||||||||||||||||||||
1588 | break; executed 2554 times by 4 tests: break; Executed by:
| 2554 | ||||||||||||||||||||||||
1589 | case QMetaType::QRectF: executed 7 times by 2 tests: case QMetaType::QRectF: Executed by:
| 7 | ||||||||||||||||||||||||
1590 | stream >> *static_cast< NS(QRectF)*>(data); | - | ||||||||||||||||||||||||
1591 | break; executed 7 times by 2 tests: break; Executed by:
| 7 | ||||||||||||||||||||||||
1592 | case QMetaType::QSize: executed 62 times by 4 tests: case QMetaType::QSize: Executed by:
| 62 | ||||||||||||||||||||||||
1593 | stream >> *static_cast< NS(QSize)*>(data); | - | ||||||||||||||||||||||||
1594 | break; executed 62 times by 4 tests: break; Executed by:
| 62 | ||||||||||||||||||||||||
1595 | case QMetaType::QSizeF: executed 7 times by 2 tests: case QMetaType::QSizeF: Executed by:
| 7 | ||||||||||||||||||||||||
1596 | stream >> *static_cast< NS(QSizeF)*>(data); | - | ||||||||||||||||||||||||
1597 | break; executed 7 times by 2 tests: break; Executed by:
| 7 | ||||||||||||||||||||||||
1598 | case QMetaType::QLine: executed 7 times by 2 tests: case QMetaType::QLine: Executed by:
| 7 | ||||||||||||||||||||||||
1599 | stream >> *static_cast< NS(QLine)*>(data); | - | ||||||||||||||||||||||||
1600 | break; executed 7 times by 2 tests: break; Executed by:
| 7 | ||||||||||||||||||||||||
1601 | case QMetaType::QLineF: executed 7 times by 2 tests: case QMetaType::QLineF: Executed by:
| 7 | ||||||||||||||||||||||||
1602 | stream >> *static_cast< NS(QLineF)*>(data); | - | ||||||||||||||||||||||||
1603 | break; executed 7 times by 2 tests: break; Executed by:
| 7 | ||||||||||||||||||||||||
1604 | case QMetaType::QPoint: executed 59 times by 3 tests: case QMetaType::QPoint: Executed by:
| 59 | ||||||||||||||||||||||||
1605 | stream >> *static_cast< NS(QPoint)*>(data); | - | ||||||||||||||||||||||||
1606 | break; executed 59 times by 3 tests: break; Executed by:
| 59 | ||||||||||||||||||||||||
1607 | case QMetaType::QPointF: executed 7 times by 2 tests: case QMetaType::QPointF: Executed by:
| 7 | ||||||||||||||||||||||||
1608 | stream >> *static_cast< NS(QPointF)*>(data); | - | ||||||||||||||||||||||||
1609 | break; executed 7 times by 2 tests: break; Executed by:
| 7 | ||||||||||||||||||||||||
1610 | #endif | - | ||||||||||||||||||||||||
1611 | #ifndef QT_NO_REGEXP | - | ||||||||||||||||||||||||
1612 | case QMetaType::QRegExp: executed 51 times by 3 tests: case QMetaType::QRegExp: Executed by:
| 51 | ||||||||||||||||||||||||
1613 | stream >> *static_cast< NS(QRegExp)*>(data); | - | ||||||||||||||||||||||||
1614 | break; executed 51 times by 3 tests: break; Executed by:
| 51 | ||||||||||||||||||||||||
1615 | #endif | - | ||||||||||||||||||||||||
1616 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
1617 | #ifndef QT_NO_REGULAREXPRESSION | - | ||||||||||||||||||||||||
1618 | case QMetaType::QRegularExpression: executed 7 times by 2 tests: case QMetaType::QRegularExpression: Executed by:
| 7 | ||||||||||||||||||||||||
1619 | stream >> *static_cast< NS(QRegularExpression)*>(data); | - | ||||||||||||||||||||||||
1620 | break; executed 7 times by 2 tests: break; Executed by:
| 7 | ||||||||||||||||||||||||
1621 | #endif // QT_NO_REGULAREXPRESSION | - | ||||||||||||||||||||||||
1622 | case QMetaType::QEasingCurve: executed 3 times by 1 test: case QMetaType::QEasingCurve: Executed by:
| 3 | ||||||||||||||||||||||||
1623 | stream >> *static_cast< NS(QEasingCurve)*>(data); | - | ||||||||||||||||||||||||
1624 | break; executed 3 times by 1 test: break; Executed by:
| 3 | ||||||||||||||||||||||||
1625 | #endif // QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
1626 | case QMetaType::QFont: executed 2 times by 2 tests: case QMetaType::QFont: Executed by:
| 2 | ||||||||||||||||||||||||
1627 | case QMetaType::QPixmap: executed 2 times by 1 test: case QMetaType::QPixmap: Executed by:
| 2 | ||||||||||||||||||||||||
1628 | case QMetaType::QBrush: executed 3 times by 2 tests: case QMetaType::QBrush: Executed by:
| 3 | ||||||||||||||||||||||||
1629 | case QMetaType::QColor: executed 101 times by 2 tests: case QMetaType::QColor: Executed by:
| 101 | ||||||||||||||||||||||||
1630 | case QMetaType::QPalette: executed 1 time by 1 test: case QMetaType::QPalette: Executed by:
| 1 | ||||||||||||||||||||||||
1631 | case QMetaType::QImage: executed 1 time by 1 test: case QMetaType::QImage: Executed by:
| 1 | ||||||||||||||||||||||||
1632 | case QMetaType::QPolygon: executed 2 times by 1 test: case QMetaType::QPolygon: Executed by:
| 2 | ||||||||||||||||||||||||
1633 | case QMetaType::QPolygonF: executed 3 times by 1 test: case QMetaType::QPolygonF: Executed by:
| 3 | ||||||||||||||||||||||||
1634 | case QMetaType::QRegion: executed 2 times by 1 test: case QMetaType::QRegion: Executed by:
| 2 | ||||||||||||||||||||||||
1635 | case QMetaType::QBitmap: executed 2 times by 1 test: case QMetaType::QBitmap: Executed by:
| 2 | ||||||||||||||||||||||||
1636 | case QMetaType::QCursor: executed 1 time by 1 test: case QMetaType::QCursor: Executed by:
| 1 | ||||||||||||||||||||||||
1637 | case QMetaType::QKeySequence: executed 3 times by 2 tests: case QMetaType::QKeySequence: Executed by:
| 3 | ||||||||||||||||||||||||
1638 | case QMetaType::QPen: executed 1 time by 1 test: case QMetaType::QPen: Executed by:
| 1 | ||||||||||||||||||||||||
1639 | case QMetaType::QTextLength: never executed: case QMetaType::QTextLength: | 0 | ||||||||||||||||||||||||
1640 | case QMetaType::QTextFormat: never executed: case QMetaType::QTextFormat: | 0 | ||||||||||||||||||||||||
1641 | case QMetaType::QMatrix: never executed: case QMetaType::QMatrix: | 0 | ||||||||||||||||||||||||
1642 | case QMetaType::QTransform: never executed: case QMetaType::QTransform: | 0 | ||||||||||||||||||||||||
1643 | case QMetaType::QMatrix4x4: never executed: case QMetaType::QMatrix4x4: | 0 | ||||||||||||||||||||||||
1644 | case QMetaType::QVector2D: never executed: case QMetaType::QVector2D: | 0 | ||||||||||||||||||||||||
1645 | case QMetaType::QVector3D: never executed: case QMetaType::QVector3D: | 0 | ||||||||||||||||||||||||
1646 | case QMetaType::QVector4D: never executed: case QMetaType::QVector4D: | 0 | ||||||||||||||||||||||||
1647 | case QMetaType::QQuaternion: never executed: case QMetaType::QQuaternion: | 0 | ||||||||||||||||||||||||
1648 | case QMetaType::QIcon: never executed: case QMetaType::QIcon: | 0 | ||||||||||||||||||||||||
1649 | if (!qMetaTypeGuiHelper)
| 0-124 | ||||||||||||||||||||||||
1650 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
1651 | qMetaTypeGuiHelper[type - FirstGuiType].loadOp(stream, data); | - | ||||||||||||||||||||||||
1652 | break; executed 124 times by 3 tests: break; Executed by:
| 124 | ||||||||||||||||||||||||
1653 | case QMetaType::QSizePolicy: executed 1 time by 1 test: case QMetaType::QSizePolicy: Executed by:
| 1 | ||||||||||||||||||||||||
1654 | if (!qMetaTypeWidgetsHelper)
| 0-1 | ||||||||||||||||||||||||
1655 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
1656 | qMetaTypeWidgetsHelper[type - FirstWidgetsType].loadOp(stream, data); | - | ||||||||||||||||||||||||
1657 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||||||||||||||||||||
1658 | case QMetaType::QUuid: executed 5 times by 2 tests: case QMetaType::QUuid: Executed by:
| 5 | ||||||||||||||||||||||||
1659 | stream >> *static_cast< NS(QUuid)*>(data); | - | ||||||||||||||||||||||||
1660 | break; executed 5 times by 2 tests: break; Executed by:
| 5 | ||||||||||||||||||||||||
1661 | default: { executed 8 times by 3 tests: default: Executed by:
| 8 | ||||||||||||||||||||||||
1662 | const QVector<QCustomTypeInfo> * const ct = customTypes(); | - | ||||||||||||||||||||||||
1663 | if (!ct)
| 0-8 | ||||||||||||||||||||||||
1664 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
1665 | - | |||||||||||||||||||||||||
1666 | LoadOperator loadOp = 0; | - | ||||||||||||||||||||||||
1667 | { | - | ||||||||||||||||||||||||
1668 | QReadLocker locker(customTypesLock()); | - | ||||||||||||||||||||||||
1669 | loadOp = ct->at(type - User).loadOp; | - | ||||||||||||||||||||||||
1670 | } | - | ||||||||||||||||||||||||
1671 | - | |||||||||||||||||||||||||
1672 | if (!loadOp)
| 2-6 | ||||||||||||||||||||||||
1673 | return false; executed 2 times by 2 tests: return false; Executed by:
| 2 | ||||||||||||||||||||||||
1674 | loadOp(stream, data); | - | ||||||||||||||||||||||||
1675 | break; } executed 6 times by 3 tests: break; Executed by:
| 6 | ||||||||||||||||||||||||
1676 | } | - | ||||||||||||||||||||||||
1677 | return true; executed 16436 times by 16 tests: return true; Executed by:
| 16436 | ||||||||||||||||||||||||
1678 | } | - | ||||||||||||||||||||||||
1679 | #endif // QT_NO_DATASTREAM | - | ||||||||||||||||||||||||
1680 | - | |||||||||||||||||||||||||
1681 | /*! | - | ||||||||||||||||||||||||
1682 | Returns a copy of \a copy, assuming it is of type \a type. If \a | - | ||||||||||||||||||||||||
1683 | copy is zero, creates a default constructed instance. | - | ||||||||||||||||||||||||
1684 | - | |||||||||||||||||||||||||
1685 | \sa destroy(), isRegistered(), Type | - | ||||||||||||||||||||||||
1686 | */ | - | ||||||||||||||||||||||||
1687 | void *QMetaType::create(int type, const void *copy) | - | ||||||||||||||||||||||||
1688 | { | - | ||||||||||||||||||||||||
1689 | QMetaType info(type); | - | ||||||||||||||||||||||||
1690 | if (int size = info.sizeOf())
| 123-575554 | ||||||||||||||||||||||||
1691 | return info.construct(operator new(size), copy); executed 575554 times by 427 tests: return info.construct(operator new(size), copy); Executed by:
| 575554 | ||||||||||||||||||||||||
1692 | return 0; executed 123 times by 1 test: return 0; Executed by:
| 123 | ||||||||||||||||||||||||
1693 | } | - | ||||||||||||||||||||||||
1694 | - | |||||||||||||||||||||||||
1695 | /*! | - | ||||||||||||||||||||||||
1696 | Destroys the \a data, assuming it is of the \a type given. | - | ||||||||||||||||||||||||
1697 | - | |||||||||||||||||||||||||
1698 | \sa create(), isRegistered(), Type | - | ||||||||||||||||||||||||
1699 | */ | - | ||||||||||||||||||||||||
1700 | void QMetaType::destroy(int type, void *data) | - | ||||||||||||||||||||||||
1701 | { | - | ||||||||||||||||||||||||
1702 | QMetaType info(type); | - | ||||||||||||||||||||||||
1703 | info.destruct(data); | - | ||||||||||||||||||||||||
1704 | operator delete(data); | - | ||||||||||||||||||||||||
1705 | } executed 573579 times by 438 tests: end of block Executed by:
| 573579 | ||||||||||||||||||||||||
1706 | - | |||||||||||||||||||||||||
1707 | namespace { | - | ||||||||||||||||||||||||
1708 | class TypeConstructor { | - | ||||||||||||||||||||||||
1709 | template<typename T, bool IsAcceptedType = DefinedTypesFilter::Acceptor<T>::IsAccepted> | - | ||||||||||||||||||||||||
1710 | struct ConstructorImpl { | - | ||||||||||||||||||||||||
1711 | static void *Construct(const int /*type*/, void *where, const void *copy) { return QtMetaTypePrivate::QMetaTypeFunctionHelper<T>::Construct(where, copy); } executed 281 times by 131 tests: return QtMetaTypePrivate::QMetaTypeFunctionHelper<T>::Construct(where, copy); Executed by:
| 281 | ||||||||||||||||||||||||
1712 | }; | - | ||||||||||||||||||||||||
1713 | template<typename T> | - | ||||||||||||||||||||||||
1714 | struct ConstructorImpl<T, /* IsAcceptedType = */ false> { | - | ||||||||||||||||||||||||
1715 | static void *Construct(const int type, void *where, const void *copy) | - | ||||||||||||||||||||||||
1716 | { | - | ||||||||||||||||||||||||
1717 | if (QModulesPrivate::QTypeModuleInfo<T>::IsGui)
| 0-42 | ||||||||||||||||||||||||
1718 | return Q_LIKELY(qMetaTypeGuiHelper) ? qMetaTypeGuiHelper[type - QMetaType::FirstGuiType].constructor(where, copy) : 0; executed 42 times by 1 test: return __builtin_expect(!!(qMetaTypeGuiHelper), true) ? qMetaTypeGuiHelper[type - QMetaType::FirstGuiType].constructor(where, copy) : 0; Executed by:
| 0-42 | ||||||||||||||||||||||||
1719 | - | |||||||||||||||||||||||||
1720 | if (QModulesPrivate::QTypeModuleInfo<T>::IsWidget)
| 0 | ||||||||||||||||||||||||
1721 | return Q_LIKELY(qMetaTypeWidgetsHelper) ? qMetaTypeWidgetsHelper[type - QMetaType::FirstWidgetsType].constructor(where, copy) : 0; never executed: return __builtin_expect(!!(qMetaTypeWidgetsHelper), true) ? qMetaTypeWidgetsHelper[type - QMetaType::FirstWidgetsType].constructor(where, copy) : 0;
| 0 | ||||||||||||||||||||||||
1722 | - | |||||||||||||||||||||||||
1723 | // This point can be reached only for known types that definition is not available, for example | - | ||||||||||||||||||||||||
1724 | // in bootstrap mode. We have no other choice then ignore it. | - | ||||||||||||||||||||||||
1725 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
1726 | } | - | ||||||||||||||||||||||||
1727 | }; | - | ||||||||||||||||||||||||
1728 | public: | - | ||||||||||||||||||||||||
1729 | TypeConstructor(const int type, void *where) | - | ||||||||||||||||||||||||
1730 | : m_type(type) | - | ||||||||||||||||||||||||
1731 | , m_where(where) | - | ||||||||||||||||||||||||
1732 | {} executed 6327 times by 132 tests: end of block Executed by:
| 6327 | ||||||||||||||||||||||||
1733 | - | |||||||||||||||||||||||||
1734 | template<typename T> | - | ||||||||||||||||||||||||
1735 | void *delegate(const T *copy) { return ConstructorImpl<T>::Construct(m_type, m_where, copy); } executed 323 times by 132 tests: return ConstructorImpl<T>::Construct(m_type, m_where, copy); Executed by:
| 323 | ||||||||||||||||||||||||
1736 | void *delegate(const void *) { return m_where; } never executed: return m_where; | 0 | ||||||||||||||||||||||||
1737 | void *delegate(const QMetaTypeSwitcher::UnknownType*) { return m_where; } never executed: return m_where; | 0 | ||||||||||||||||||||||||
1738 | void *delegate(const QMetaTypeSwitcher::NotBuiltinType *copy) { return customTypeConstructor(m_type, m_where, copy); } executed 6004 times by 2 tests: return customTypeConstructor(m_type, m_where, copy); Executed by:
| 6004 | ||||||||||||||||||||||||
1739 | - | |||||||||||||||||||||||||
1740 | private: | - | ||||||||||||||||||||||||
1741 | static void *customTypeConstructor(const int type, void *where, const void *copy) | - | ||||||||||||||||||||||||
1742 | { | - | ||||||||||||||||||||||||
1743 | QMetaType::Constructor ctor; | - | ||||||||||||||||||||||||
1744 | const QVector<QCustomTypeInfo> * const ct = customTypes(); | - | ||||||||||||||||||||||||
1745 | { | - | ||||||||||||||||||||||||
1746 | QReadLocker locker(customTypesLock()); | - | ||||||||||||||||||||||||
1747 | if (Q_UNLIKELY(type < QMetaType::User || !ct || ct->count() <= type - QMetaType::User))
| 0-6004 | ||||||||||||||||||||||||
1748 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
1749 | ctor = ct->at(type - QMetaType::User).constructor; | - | ||||||||||||||||||||||||
1750 | } | - | ||||||||||||||||||||||||
1751 | Q_ASSERT_X(ctor, "void *QMetaType::construct(int type, void *where, const void *copy)", "The type was not properly registered"); | - | ||||||||||||||||||||||||
1752 | return ctor(where, copy); executed 6004 times by 2 tests: return ctor(where, copy); Executed by:
| 6004 | ||||||||||||||||||||||||
1753 | } | - | ||||||||||||||||||||||||
1754 | - | |||||||||||||||||||||||||
1755 | const int m_type; | - | ||||||||||||||||||||||||
1756 | void *m_where; | - | ||||||||||||||||||||||||
1757 | }; | - | ||||||||||||||||||||||||
1758 | } // namespace | - | ||||||||||||||||||||||||
1759 | - | |||||||||||||||||||||||||
1760 | /*! | - | ||||||||||||||||||||||||
1761 | \since 5.0 | - | ||||||||||||||||||||||||
1762 | - | |||||||||||||||||||||||||
1763 | Constructs a value of the given \a type in the existing memory | - | ||||||||||||||||||||||||
1764 | addressed by \a where, that is a copy of \a copy, and returns | - | ||||||||||||||||||||||||
1765 | \a where. If \a copy is zero, the value is default constructed. | - | ||||||||||||||||||||||||
1766 | - | |||||||||||||||||||||||||
1767 | This is a low-level function for explicitly managing the memory | - | ||||||||||||||||||||||||
1768 | used to store the type. Consider calling create() if you don't | - | ||||||||||||||||||||||||
1769 | need this level of control (that is, use "new" rather than | - | ||||||||||||||||||||||||
1770 | "placement new"). | - | ||||||||||||||||||||||||
1771 | - | |||||||||||||||||||||||||
1772 | You must ensure that \a where points to a location that can store | - | ||||||||||||||||||||||||
1773 | a value of type \a type, and that \a where is suitably aligned. | - | ||||||||||||||||||||||||
1774 | The type's size can be queried by calling sizeOf(). | - | ||||||||||||||||||||||||
1775 | - | |||||||||||||||||||||||||
1776 | The rule of thumb for alignment is that a type is aligned to its | - | ||||||||||||||||||||||||
1777 | natural boundary, which is the smallest power of 2 that is bigger | - | ||||||||||||||||||||||||
1778 | than the type, unless that alignment is larger than the maximum | - | ||||||||||||||||||||||||
1779 | useful alignment for the platform. For practical purposes, | - | ||||||||||||||||||||||||
1780 | alignment larger than 2 * sizeof(void*) is only necessary for | - | ||||||||||||||||||||||||
1781 | special hardware instructions (e.g., aligned SSE loads and stores | - | ||||||||||||||||||||||||
1782 | on x86). | - | ||||||||||||||||||||||||
1783 | - | |||||||||||||||||||||||||
1784 | \sa destruct(), sizeOf() | - | ||||||||||||||||||||||||
1785 | */ | - | ||||||||||||||||||||||||
1786 | void *QMetaType::construct(int type, void *where, const void *copy) | - | ||||||||||||||||||||||||
1787 | { | - | ||||||||||||||||||||||||
1788 | if (!where)
| 100-6327 | ||||||||||||||||||||||||
1789 | return 0; executed 100 times by 1 test: return 0; Executed by:
| 100 | ||||||||||||||||||||||||
1790 | TypeConstructor constructor(type, where); | - | ||||||||||||||||||||||||
1791 | return QMetaTypeSwitcher::switcher<void*>(constructor, type, copy); executed 6327 times by 132 tests: return QMetaTypeSwitcher::switcher<void*>(constructor, type, copy); Executed by:
| 6327 | ||||||||||||||||||||||||
1792 | } | - | ||||||||||||||||||||||||
1793 | - | |||||||||||||||||||||||||
1794 | - | |||||||||||||||||||||||||
1795 | namespace { | - | ||||||||||||||||||||||||
1796 | class TypeDestructor { | - | ||||||||||||||||||||||||
1797 | template<typename T, bool IsAcceptedType = DefinedTypesFilter::Acceptor<T>::IsAccepted> | - | ||||||||||||||||||||||||
1798 | struct DestructorImpl { | - | ||||||||||||||||||||||||
1799 | static void Destruct(const int /* type */, void *where) { QtMetaTypePrivate::QMetaTypeFunctionHelper<T>::Destruct(where); } executed 281 times by 131 tests: end of block Executed by:
| 281 | ||||||||||||||||||||||||
1800 | }; | - | ||||||||||||||||||||||||
1801 | template<typename T> | - | ||||||||||||||||||||||||
1802 | struct DestructorImpl<T, /* IsAcceptedType = */ false> { | - | ||||||||||||||||||||||||
1803 | static void Destruct(const int type, void *where) | - | ||||||||||||||||||||||||
1804 | { | - | ||||||||||||||||||||||||
1805 | if (QModulesPrivate::QTypeModuleInfo<T>::IsGui) {
| 0-42 | ||||||||||||||||||||||||
1806 | if (Q_LIKELY(qMetaTypeGuiHelper))
| 0-42 | ||||||||||||||||||||||||
1807 | qMetaTypeGuiHelper[type - QMetaType::FirstGuiType].destructor(where); executed 42 times by 1 test: qMetaTypeGuiHelper[type - QMetaType::FirstGuiType].destructor(where); Executed by:
| 42 | ||||||||||||||||||||||||
1808 | return; executed 42 times by 1 test: return; Executed by:
| 42 | ||||||||||||||||||||||||
1809 | } | - | ||||||||||||||||||||||||
1810 | if (QModulesPrivate::QTypeModuleInfo<T>::IsWidget) {
| 0 | ||||||||||||||||||||||||
1811 | if (Q_LIKELY(qMetaTypeWidgetsHelper))
| 0 | ||||||||||||||||||||||||
1812 | qMetaTypeWidgetsHelper[type - QMetaType::FirstWidgetsType].destructor(where); never executed: qMetaTypeWidgetsHelper[type - QMetaType::FirstWidgetsType].destructor(where); | 0 | ||||||||||||||||||||||||
1813 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1814 | } | - | ||||||||||||||||||||||||
1815 | // This point can be reached only for known types that definition is not available, for example | - | ||||||||||||||||||||||||
1816 | // in bootstrap mode. We have no other choice then ignore it. | - | ||||||||||||||||||||||||
1817 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1818 | }; | - | ||||||||||||||||||||||||
1819 | public: | - | ||||||||||||||||||||||||
1820 | TypeDestructor(const int type) | - | ||||||||||||||||||||||||
1821 | : m_type(type) | - | ||||||||||||||||||||||||
1822 | {} executed 153146 times by 225 tests: end of block Executed by:
| 153146 | ||||||||||||||||||||||||
1823 | - | |||||||||||||||||||||||||
1824 | template<typename T> | - | ||||||||||||||||||||||||
1825 | void delegate(const T *where) { DestructorImpl<T>::Destruct(m_type, const_cast<T*>(where)); } executed 323 times by 132 tests: end of block Executed by:
| 323 | ||||||||||||||||||||||||
1826 | void delegate(const void *) {} | - | ||||||||||||||||||||||||
1827 | void delegate(const QMetaTypeSwitcher::UnknownType*) {} | - | ||||||||||||||||||||||||
1828 | void delegate(const QMetaTypeSwitcher::NotBuiltinType *where) | - | ||||||||||||||||||||||||
1829 | { customTypeDestructor(m_type, const_cast<void *>(static_cast<const void *>(where))); } executed 152823 times by 144 tests: end of block Executed by:
| 152823 | ||||||||||||||||||||||||
1830 | - | |||||||||||||||||||||||||
1831 | private: | - | ||||||||||||||||||||||||
1832 | static void customTypeDestructor(const int type, void *where) | - | ||||||||||||||||||||||||
1833 | { | - | ||||||||||||||||||||||||
1834 | QMetaType::Destructor dtor; | - | ||||||||||||||||||||||||
1835 | const QVector<QCustomTypeInfo> * const ct = customTypes(); | - | ||||||||||||||||||||||||
1836 | { | - | ||||||||||||||||||||||||
1837 | QReadLocker locker(customTypesLock()); | - | ||||||||||||||||||||||||
1838 | if (Q_UNLIKELY(type < QMetaType::User || !ct || ct->count() <= type - QMetaType::User))
| 1-152822 | ||||||||||||||||||||||||
1839 | return; executed 1 time by 1 test: return; Executed by:
| 1 | ||||||||||||||||||||||||
1840 | dtor = ct->at(type - QMetaType::User).destructor; | - | ||||||||||||||||||||||||
1841 | } | - | ||||||||||||||||||||||||
1842 | Q_ASSERT_X(dtor, "void QMetaType::destruct(int type, void *where)", "The type was not properly registered"); | - | ||||||||||||||||||||||||
1843 | dtor(where); | - | ||||||||||||||||||||||||
1844 | } executed 152822 times by 144 tests: end of block Executed by:
| 152822 | ||||||||||||||||||||||||
1845 | - | |||||||||||||||||||||||||
1846 | const int m_type; | - | ||||||||||||||||||||||||
1847 | }; | - | ||||||||||||||||||||||||
1848 | } // namespace | - | ||||||||||||||||||||||||
1849 | - | |||||||||||||||||||||||||
1850 | /*! | - | ||||||||||||||||||||||||
1851 | \since 5.0 | - | ||||||||||||||||||||||||
1852 | - | |||||||||||||||||||||||||
1853 | Destructs the value of the given \a type, located at \a where. | - | ||||||||||||||||||||||||
1854 | - | |||||||||||||||||||||||||
1855 | Unlike destroy(), this function only invokes the type's | - | ||||||||||||||||||||||||
1856 | destructor, it doesn't invoke the delete operator. | - | ||||||||||||||||||||||||
1857 | - | |||||||||||||||||||||||||
1858 | \sa construct() | - | ||||||||||||||||||||||||
1859 | */ | - | ||||||||||||||||||||||||
1860 | void QMetaType::destruct(int type, void *where) | - | ||||||||||||||||||||||||
1861 | { | - | ||||||||||||||||||||||||
1862 | if (!where)
| 51-153146 | ||||||||||||||||||||||||
1863 | return; executed 51 times by 1 test: return; Executed by:
| 51 | ||||||||||||||||||||||||
1864 | TypeDestructor destructor(type); | - | ||||||||||||||||||||||||
1865 | QMetaTypeSwitcher::switcher<void>(destructor, type, where); | - | ||||||||||||||||||||||||
1866 | } executed 153146 times by 225 tests: end of block Executed by:
| 153146 | ||||||||||||||||||||||||
1867 | - | |||||||||||||||||||||||||
1868 | - | |||||||||||||||||||||||||
1869 | namespace { | - | ||||||||||||||||||||||||
1870 | class SizeOf { | - | ||||||||||||||||||||||||
1871 | template<typename T, bool IsAcceptedType = DefinedTypesFilter::Acceptor<T>::IsAccepted> | - | ||||||||||||||||||||||||
1872 | struct SizeOfImpl { | - | ||||||||||||||||||||||||
1873 | static int Size(const int) { return QTypeInfo<T>::sizeOf; } executed 99 times by 1 test: return QTypeInfo<T>::sizeOf; Executed by:
| 99 | ||||||||||||||||||||||||
1874 | }; | - | ||||||||||||||||||||||||
1875 | template<typename T> | - | ||||||||||||||||||||||||
1876 | struct SizeOfImpl<T, /* IsAcceptedType = */ false> { | - | ||||||||||||||||||||||||
1877 | static int Size(const int type) | - | ||||||||||||||||||||||||
1878 | { | - | ||||||||||||||||||||||||
1879 | if (QModulesPrivate::QTypeModuleInfo<T>::IsGui)
| 0-63 | ||||||||||||||||||||||||
1880 | return Q_LIKELY(qMetaTypeGuiHelper) ? qMetaTypeGuiHelper[type - QMetaType::FirstGuiType].size : 0; executed 63 times by 1 test: return __builtin_expect(!!(qMetaTypeGuiHelper), true) ? qMetaTypeGuiHelper[type - QMetaType::FirstGuiType].size : 0; Executed by:
| 0-63 | ||||||||||||||||||||||||
1881 | - | |||||||||||||||||||||||||
1882 | if (QModulesPrivate::QTypeModuleInfo<T>::IsWidget)
| 0 | ||||||||||||||||||||||||
1883 | return Q_LIKELY(qMetaTypeWidgetsHelper) ? qMetaTypeWidgetsHelper[type - QMetaType::FirstWidgetsType].size : 0; never executed: return __builtin_expect(!!(qMetaTypeWidgetsHelper), true) ? qMetaTypeWidgetsHelper[type - QMetaType::FirstWidgetsType].size : 0;
| 0 | ||||||||||||||||||||||||
1884 | - | |||||||||||||||||||||||||
1885 | // This point can be reached only for known types that definition is not available, for example | - | ||||||||||||||||||||||||
1886 | // in bootstrap mode. We have no other choice then ignore it. | - | ||||||||||||||||||||||||
1887 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
1888 | } | - | ||||||||||||||||||||||||
1889 | }; | - | ||||||||||||||||||||||||
1890 | - | |||||||||||||||||||||||||
1891 | public: | - | ||||||||||||||||||||||||
1892 | SizeOf(int type) | - | ||||||||||||||||||||||||
1893 | : m_type(type) | - | ||||||||||||||||||||||||
1894 | {} executed 552 times by 23 tests: end of block Executed by:
| 552 | ||||||||||||||||||||||||
1895 | - | |||||||||||||||||||||||||
1896 | template<typename T> | - | ||||||||||||||||||||||||
1897 | int delegate(const T*) { return SizeOfImpl<T>::Size(m_type); } executed 162 times by 2 tests: return SizeOfImpl<T>::Size(m_type); Executed by:
| 162 | ||||||||||||||||||||||||
1898 | int delegate(const QMetaTypeSwitcher::UnknownType*) { return 0; } executed 3 times by 1 test: return 0; Executed by:
| 3 | ||||||||||||||||||||||||
1899 | int delegate(const QMetaTypeSwitcher::NotBuiltinType*) { return customTypeSizeOf(m_type); } executed 387 times by 22 tests: return customTypeSizeOf(m_type); Executed by:
| 387 | ||||||||||||||||||||||||
1900 | private: | - | ||||||||||||||||||||||||
1901 | static int customTypeSizeOf(const int type) | - | ||||||||||||||||||||||||
1902 | { | - | ||||||||||||||||||||||||
1903 | const QVector<QCustomTypeInfo> * const ct = customTypes(); | - | ||||||||||||||||||||||||
1904 | QReadLocker locker(customTypesLock()); | - | ||||||||||||||||||||||||
1905 | if (Q_UNLIKELY(type < QMetaType::User || !ct || ct->count() <= type - QMetaType::User))
| 1-386 | ||||||||||||||||||||||||
1906 | return 0; executed 1 time by 1 test: return 0; Executed by:
| 1 | ||||||||||||||||||||||||
1907 | return ct->at(type - QMetaType::User).size; executed 386 times by 22 tests: return ct->at(type - QMetaType::User).size; Executed by:
| 386 | ||||||||||||||||||||||||
1908 | } | - | ||||||||||||||||||||||||
1909 | - | |||||||||||||||||||||||||
1910 | const int m_type; | - | ||||||||||||||||||||||||
1911 | }; | - | ||||||||||||||||||||||||
1912 | } // namespace | - | ||||||||||||||||||||||||
1913 | - | |||||||||||||||||||||||||
1914 | /*! | - | ||||||||||||||||||||||||
1915 | \since 5.0 | - | ||||||||||||||||||||||||
1916 | - | |||||||||||||||||||||||||
1917 | Returns the size of the given \a type in bytes (i.e. sizeof(T), | - | ||||||||||||||||||||||||
1918 | where T is the actual type identified by the \a type argument). | - | ||||||||||||||||||||||||
1919 | - | |||||||||||||||||||||||||
1920 | This function is typically used together with construct() | - | ||||||||||||||||||||||||
1921 | to perform low-level management of the memory used by a type. | - | ||||||||||||||||||||||||
1922 | - | |||||||||||||||||||||||||
1923 | \sa construct() | - | ||||||||||||||||||||||||
1924 | */ | - | ||||||||||||||||||||||||
1925 | int QMetaType::sizeOf(int type) | - | ||||||||||||||||||||||||
1926 | { | - | ||||||||||||||||||||||||
1927 | SizeOf sizeOf(type); | - | ||||||||||||||||||||||||
1928 | return QMetaTypeSwitcher::switcher<int>(sizeOf, type, 0); executed 552 times by 23 tests: return QMetaTypeSwitcher::switcher<int>(sizeOf, type, 0); Executed by:
| 552 | ||||||||||||||||||||||||
1929 | } | - | ||||||||||||||||||||||||
1930 | - | |||||||||||||||||||||||||
1931 | namespace { | - | ||||||||||||||||||||||||
1932 | class Flags | - | ||||||||||||||||||||||||
1933 | { | - | ||||||||||||||||||||||||
1934 | template<typename T, bool IsAcceptedType = DefinedTypesFilter::Acceptor<T>::IsAccepted> | - | ||||||||||||||||||||||||
1935 | struct FlagsImpl | - | ||||||||||||||||||||||||
1936 | { | - | ||||||||||||||||||||||||
1937 | static quint32 Flags(const int /* type */) | - | ||||||||||||||||||||||||
1938 | { | - | ||||||||||||||||||||||||
1939 | return QtPrivate::QMetaTypeTypeFlags<T>::Flags; executed 32978 times by 54 tests: return QtPrivate::QMetaTypeTypeFlags<T>::Flags; Executed by:
| 32978 | ||||||||||||||||||||||||
1940 | } | - | ||||||||||||||||||||||||
1941 | }; | - | ||||||||||||||||||||||||
1942 | template<typename T> | - | ||||||||||||||||||||||||
1943 | struct FlagsImpl<T, /* IsAcceptedType = */ false> | - | ||||||||||||||||||||||||
1944 | { | - | ||||||||||||||||||||||||
1945 | static quint32 Flags(const int type) | - | ||||||||||||||||||||||||
1946 | { | - | ||||||||||||||||||||||||
1947 | if (QModulesPrivate::QTypeModuleInfo<T>::IsGui)
| 8-239109 | ||||||||||||||||||||||||
1948 | return Q_LIKELY(qMetaTypeGuiHelper) ? qMetaTypeGuiHelper[type - QMetaType::FirstGuiType].flags : 0; executed 239109 times by 63 tests: return __builtin_expect(!!(qMetaTypeGuiHelper), true) ? qMetaTypeGuiHelper[type - QMetaType::FirstGuiType].flags : 0; Executed by:
| 23-239109 | ||||||||||||||||||||||||
1949 | - | |||||||||||||||||||||||||
1950 | if (QModulesPrivate::QTypeModuleInfo<T>::IsWidget)
| 0-8 | ||||||||||||||||||||||||
1951 | return Q_LIKELY(qMetaTypeWidgetsHelper) ? qMetaTypeWidgetsHelper[type - QMetaType::FirstWidgetsType].flags : 0; executed 8 times by 2 tests: return __builtin_expect(!!(qMetaTypeWidgetsHelper), true) ? qMetaTypeWidgetsHelper[type - QMetaType::FirstWidgetsType].flags : 0; Executed by:
| 1-8 | ||||||||||||||||||||||||
1952 | - | |||||||||||||||||||||||||
1953 | // This point can be reached only for known types that definition is not available, for example | - | ||||||||||||||||||||||||
1954 | // in bootstrap mode. We have no other choice then ignore it. | - | ||||||||||||||||||||||||
1955 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
1956 | } | - | ||||||||||||||||||||||||
1957 | }; | - | ||||||||||||||||||||||||
1958 | public: | - | ||||||||||||||||||||||||
1959 | Flags(const int type) | - | ||||||||||||||||||||||||
1960 | : m_type(type) | - | ||||||||||||||||||||||||
1961 | {} executed 308807 times by 121 tests: end of block Executed by:
| 308807 | ||||||||||||||||||||||||
1962 | template<typename T> | - | ||||||||||||||||||||||||
1963 | quint32 delegate(const T*) { return FlagsImpl<T>::Flags(m_type); } executed 272095 times by 96 tests: return FlagsImpl<T>::Flags(m_type); Executed by:
| 272095 | ||||||||||||||||||||||||
1964 | quint32 delegate(const void*) { return 0; } executed 1 time by 1 test: return 0; Executed by:
| 1 | ||||||||||||||||||||||||
1965 | quint32 delegate(const QMetaTypeSwitcher::UnknownType*) { return 0; } executed 15 times by 4 tests: return 0; Executed by:
| 15 | ||||||||||||||||||||||||
1966 | quint32 delegate(const QMetaTypeSwitcher::NotBuiltinType*) { return customTypeFlags(m_type); } executed 36696 times by 55 tests: return customTypeFlags(m_type); Executed by:
| 36696 | ||||||||||||||||||||||||
1967 | private: | - | ||||||||||||||||||||||||
1968 | const int m_type; | - | ||||||||||||||||||||||||
1969 | static quint32 customTypeFlags(const int type) | - | ||||||||||||||||||||||||
1970 | { | - | ||||||||||||||||||||||||
1971 | const QVector<QCustomTypeInfo> * const ct = customTypes(); | - | ||||||||||||||||||||||||
1972 | if (Q_UNLIKELY(!ct || type < QMetaType::User))
| 0-36696 | ||||||||||||||||||||||||
1973 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
1974 | QReadLocker locker(customTypesLock()); | - | ||||||||||||||||||||||||
1975 | if (Q_UNLIKELY(ct->count() <= type - QMetaType::User))
| 30-36666 | ||||||||||||||||||||||||
1976 | return 0; executed 30 times by 2 tests: return 0; Executed by:
| 30 | ||||||||||||||||||||||||
1977 | return ct->at(type - QMetaType::User).flags; executed 36666 times by 55 tests: return ct->at(type - QMetaType::User).flags; Executed by:
| 36666 | ||||||||||||||||||||||||
1978 | } | - | ||||||||||||||||||||||||
1979 | }; | - | ||||||||||||||||||||||||
1980 | } // namespace | - | ||||||||||||||||||||||||
1981 | - | |||||||||||||||||||||||||
1982 | /*! | - | ||||||||||||||||||||||||
1983 | \since 5.0 | - | ||||||||||||||||||||||||
1984 | - | |||||||||||||||||||||||||
1985 | Returns flags of the given \a type. | - | ||||||||||||||||||||||||
1986 | - | |||||||||||||||||||||||||
1987 | \sa QMetaType::TypeFlags | - | ||||||||||||||||||||||||
1988 | */ | - | ||||||||||||||||||||||||
1989 | QMetaType::TypeFlags QMetaType::typeFlags(int type) | - | ||||||||||||||||||||||||
1990 | { | - | ||||||||||||||||||||||||
1991 | Flags flags(type); | - | ||||||||||||||||||||||||
1992 | return static_cast<QMetaType::TypeFlags>(QMetaTypeSwitcher::switcher<quint32>(flags, type, 0)); executed 308807 times by 121 tests: return static_cast<QMetaType::TypeFlags>(QMetaTypeSwitcher::switcher<quint32>(flags, type, 0)); Executed by:
| 308807 | ||||||||||||||||||||||||
1993 | } | - | ||||||||||||||||||||||||
1994 | - | |||||||||||||||||||||||||
1995 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
1996 | namespace { | - | ||||||||||||||||||||||||
1997 | class MetaObject | - | ||||||||||||||||||||||||
1998 | { | - | ||||||||||||||||||||||||
1999 | public: | - | ||||||||||||||||||||||||
2000 | MetaObject(const int type) | - | ||||||||||||||||||||||||
2001 | : m_type(type) | - | ||||||||||||||||||||||||
2002 | {} executed 32 times by 3 tests: end of block Executed by:
| 32 | ||||||||||||||||||||||||
2003 | - | |||||||||||||||||||||||||
2004 | template<typename T, bool IsAcceptedType = DefinedTypesFilter::Acceptor<T>::IsAccepted> | - | ||||||||||||||||||||||||
2005 | struct MetaObjectImpl | - | ||||||||||||||||||||||||
2006 | { | - | ||||||||||||||||||||||||
2007 | static const QMetaObject *MetaObject(int /*type*/) | - | ||||||||||||||||||||||||
2008 | { return QtPrivate::MetaObjectForType<T>::value(); } executed 3 times by 1 test: return QtPrivate::MetaObjectForType<T>::value(); Executed by:
| 3 | ||||||||||||||||||||||||
2009 | }; | - | ||||||||||||||||||||||||
2010 | template<typename T> | - | ||||||||||||||||||||||||
2011 | struct MetaObjectImpl<T, /* IsAcceptedType = */ false> | - | ||||||||||||||||||||||||
2012 | { | - | ||||||||||||||||||||||||
2013 | static const QMetaObject *MetaObject(int type) { | - | ||||||||||||||||||||||||
2014 | if (QModulesPrivate::QTypeModuleInfo<T>::IsGui)
| 0-1 | ||||||||||||||||||||||||
2015 | return Q_LIKELY(qMetaTypeGuiHelper) ? qMetaTypeGuiHelper[type - QMetaType::FirstGuiType].metaObject : 0; never executed: return __builtin_expect(!!(qMetaTypeGuiHelper), true) ? qMetaTypeGuiHelper[type - QMetaType::FirstGuiType].metaObject : 0;
| 0 | ||||||||||||||||||||||||
2016 | if (QModulesPrivate::QTypeModuleInfo<T>::IsWidget)
| 0-1 | ||||||||||||||||||||||||
2017 | return Q_LIKELY(qMetaTypeWidgetsHelper) ? qMetaTypeWidgetsHelper[type - QMetaType::FirstWidgetsType].metaObject : 0; executed 1 time by 1 test: return __builtin_expect(!!(qMetaTypeWidgetsHelper), true) ? qMetaTypeWidgetsHelper[type - QMetaType::FirstWidgetsType].metaObject : 0; Executed by:
| 0-1 | ||||||||||||||||||||||||
2018 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
2019 | } | - | ||||||||||||||||||||||||
2020 | }; | - | ||||||||||||||||||||||||
2021 | - | |||||||||||||||||||||||||
2022 | template <typename T> | - | ||||||||||||||||||||||||
2023 | const QMetaObject *delegate(const T *) { return MetaObjectImpl<T>::MetaObject(m_type); } executed 4 times by 2 tests: return MetaObjectImpl<T>::MetaObject(m_type); Executed by:
| 4 | ||||||||||||||||||||||||
2024 | const QMetaObject *delegate(const void*) { return 0; } never executed: return 0; | 0 | ||||||||||||||||||||||||
2025 | const QMetaObject *delegate(const QMetaTypeSwitcher::UnknownType*) { return 0; } never executed: return 0; | 0 | ||||||||||||||||||||||||
2026 | const QMetaObject *delegate(const QMetaTypeSwitcher::NotBuiltinType*) { return customMetaObject(m_type); } executed 28 times by 3 tests: return customMetaObject(m_type); Executed by:
| 28 | ||||||||||||||||||||||||
2027 | private: | - | ||||||||||||||||||||||||
2028 | const int m_type; | - | ||||||||||||||||||||||||
2029 | static const QMetaObject *customMetaObject(const int type) | - | ||||||||||||||||||||||||
2030 | { | - | ||||||||||||||||||||||||
2031 | const QVector<QCustomTypeInfo> * const ct = customTypes(); | - | ||||||||||||||||||||||||
2032 | if (Q_UNLIKELY(!ct || type < QMetaType::User))
| 0-28 | ||||||||||||||||||||||||
2033 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
2034 | QReadLocker locker(customTypesLock()); | - | ||||||||||||||||||||||||
2035 | if (Q_UNLIKELY(ct->count() <= type - QMetaType::User))
| 0-28 | ||||||||||||||||||||||||
2036 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
2037 | return ct->at(type - QMetaType::User).metaObject; executed 28 times by 3 tests: return ct->at(type - QMetaType::User).metaObject; Executed by:
| 28 | ||||||||||||||||||||||||
2038 | } | - | ||||||||||||||||||||||||
2039 | }; | - | ||||||||||||||||||||||||
2040 | } // namespace | - | ||||||||||||||||||||||||
2041 | #endif | - | ||||||||||||||||||||||||
2042 | - | |||||||||||||||||||||||||
2043 | /*! | - | ||||||||||||||||||||||||
2044 | \since 5.0 | - | ||||||||||||||||||||||||
2045 | - | |||||||||||||||||||||||||
2046 | returns QMetaType::metaObject for \a type | - | ||||||||||||||||||||||||
2047 | - | |||||||||||||||||||||||||
2048 | \sa metaObject() | - | ||||||||||||||||||||||||
2049 | */ | - | ||||||||||||||||||||||||
2050 | const QMetaObject *QMetaType::metaObjectForType(int type) | - | ||||||||||||||||||||||||
2051 | { | - | ||||||||||||||||||||||||
2052 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
2053 | MetaObject mo(type); | - | ||||||||||||||||||||||||
2054 | return QMetaTypeSwitcher::switcher<const QMetaObject*>(mo, type, 0); executed 32 times by 3 tests: return QMetaTypeSwitcher::switcher<const QMetaObject*>(mo, type, 0); Executed by:
| 32 | ||||||||||||||||||||||||
2055 | #else | - | ||||||||||||||||||||||||
2056 | Q_UNUSED(type); | - | ||||||||||||||||||||||||
2057 | return 0; | - | ||||||||||||||||||||||||
2058 | #endif | - | ||||||||||||||||||||||||
2059 | } | - | ||||||||||||||||||||||||
2060 | - | |||||||||||||||||||||||||
2061 | /*! | - | ||||||||||||||||||||||||
2062 | \fn int qRegisterMetaType(const char *typeName) | - | ||||||||||||||||||||||||
2063 | \relates QMetaType | - | ||||||||||||||||||||||||
2064 | \threadsafe | - | ||||||||||||||||||||||||
2065 | - | |||||||||||||||||||||||||
2066 | Registers the type name \a typeName for the type \c{T}. Returns | - | ||||||||||||||||||||||||
2067 | the internal ID used by QMetaType. Any class or struct that has a | - | ||||||||||||||||||||||||
2068 | public default constructor, a public copy constructor and a public | - | ||||||||||||||||||||||||
2069 | destructor can be registered. | - | ||||||||||||||||||||||||
2070 | - | |||||||||||||||||||||||||
2071 | This function requires that \c{T} is a fully defined type at the point | - | ||||||||||||||||||||||||
2072 | where the function is called. For pointer types, it also requires that the | - | ||||||||||||||||||||||||
2073 | pointed to type is fully defined. Use Q_DECLARE_OPAQUE_POINTER() to be able | - | ||||||||||||||||||||||||
2074 | to register pointers to forward declared types. | - | ||||||||||||||||||||||||
2075 | - | |||||||||||||||||||||||||
2076 | After a type has been registered, you can create and destroy | - | ||||||||||||||||||||||||
2077 | objects of that type dynamically at run-time. | - | ||||||||||||||||||||||||
2078 | - | |||||||||||||||||||||||||
2079 | This example registers the class \c{MyClass}: | - | ||||||||||||||||||||||||
2080 | - | |||||||||||||||||||||||||
2081 | \snippet code/src_corelib_kernel_qmetatype.cpp 4 | - | ||||||||||||||||||||||||
2082 | - | |||||||||||||||||||||||||
2083 | This function is useful to register typedefs so they can be used | - | ||||||||||||||||||||||||
2084 | by QMetaProperty, or in QueuedConnections | - | ||||||||||||||||||||||||
2085 | - | |||||||||||||||||||||||||
2086 | \snippet code/src_corelib_kernel_qmetatype.cpp 9 | - | ||||||||||||||||||||||||
2087 | - | |||||||||||||||||||||||||
2088 | \warning This function is useful only for registering an alias (typedef) | - | ||||||||||||||||||||||||
2089 | for every other use case Q_DECLARE_METATYPE and qMetaTypeId() should be used instead. | - | ||||||||||||||||||||||||
2090 | - | |||||||||||||||||||||||||
2091 | \sa {QMetaType::}{qRegisterMetaTypeStreamOperators()}, {QMetaType::}{isRegistered()}, | - | ||||||||||||||||||||||||
2092 | Q_DECLARE_METATYPE() | - | ||||||||||||||||||||||||
2093 | */ | - | ||||||||||||||||||||||||
2094 | - | |||||||||||||||||||||||||
2095 | /*! | - | ||||||||||||||||||||||||
2096 | \fn void qRegisterMetaTypeStreamOperators(const char *typeName) | - | ||||||||||||||||||||||||
2097 | \relates QMetaType | - | ||||||||||||||||||||||||
2098 | \threadsafe | - | ||||||||||||||||||||||||
2099 | - | |||||||||||||||||||||||||
2100 | Registers the stream operators for the type \c{T} called \a | - | ||||||||||||||||||||||||
2101 | typeName. | - | ||||||||||||||||||||||||
2102 | - | |||||||||||||||||||||||||
2103 | Afterward, the type can be streamed using QMetaType::load() and | - | ||||||||||||||||||||||||
2104 | QMetaType::save(). These functions are used when streaming a | - | ||||||||||||||||||||||||
2105 | QVariant. | - | ||||||||||||||||||||||||
2106 | - | |||||||||||||||||||||||||
2107 | \snippet code/src_corelib_kernel_qmetatype.cpp 5 | - | ||||||||||||||||||||||||
2108 | - | |||||||||||||||||||||||||
2109 | The stream operators should have the following signatures: | - | ||||||||||||||||||||||||
2110 | - | |||||||||||||||||||||||||
2111 | \snippet code/src_corelib_kernel_qmetatype.cpp 6 | - | ||||||||||||||||||||||||
2112 | - | |||||||||||||||||||||||||
2113 | \sa qRegisterMetaType(), QMetaType::isRegistered(), Q_DECLARE_METATYPE() | - | ||||||||||||||||||||||||
2114 | */ | - | ||||||||||||||||||||||||
2115 | - | |||||||||||||||||||||||||
2116 | /*! \typedef QMetaType::Deleter | - | ||||||||||||||||||||||||
2117 | \internal | - | ||||||||||||||||||||||||
2118 | */ | - | ||||||||||||||||||||||||
2119 | /*! \typedef QMetaType::Creator | - | ||||||||||||||||||||||||
2120 | \internal | - | ||||||||||||||||||||||||
2121 | */ | - | ||||||||||||||||||||||||
2122 | /*! \typedef QMetaType::SaveOperator | - | ||||||||||||||||||||||||
2123 | \internal | - | ||||||||||||||||||||||||
2124 | */ | - | ||||||||||||||||||||||||
2125 | /*! \typedef QMetaType::LoadOperator | - | ||||||||||||||||||||||||
2126 | \internal | - | ||||||||||||||||||||||||
2127 | */ | - | ||||||||||||||||||||||||
2128 | /*! \typedef QMetaType::Destructor | - | ||||||||||||||||||||||||
2129 | \internal | - | ||||||||||||||||||||||||
2130 | */ | - | ||||||||||||||||||||||||
2131 | /*! \typedef QMetaType::Constructor | - | ||||||||||||||||||||||||
2132 | \internal | - | ||||||||||||||||||||||||
2133 | */ | - | ||||||||||||||||||||||||
2134 | - | |||||||||||||||||||||||||
2135 | /*! | - | ||||||||||||||||||||||||
2136 | \fn int qRegisterMetaType() | - | ||||||||||||||||||||||||
2137 | \relates QMetaType | - | ||||||||||||||||||||||||
2138 | \threadsafe | - | ||||||||||||||||||||||||
2139 | \since 4.2 | - | ||||||||||||||||||||||||
2140 | - | |||||||||||||||||||||||||
2141 | Call this function to register the type \c T. \c T must be declared with | - | ||||||||||||||||||||||||
2142 | Q_DECLARE_METATYPE(). Returns the meta type Id. | - | ||||||||||||||||||||||||
2143 | - | |||||||||||||||||||||||||
2144 | Example: | - | ||||||||||||||||||||||||
2145 | - | |||||||||||||||||||||||||
2146 | \snippet code/src_corelib_kernel_qmetatype.cpp 7 | - | ||||||||||||||||||||||||
2147 | - | |||||||||||||||||||||||||
2148 | This function requires that \c{T} is a fully defined type at the point | - | ||||||||||||||||||||||||
2149 | where the function is called. For pointer types, it also requires that the | - | ||||||||||||||||||||||||
2150 | pointed to type is fully defined. Use Q_DECLARE_OPAQUE_POINTER() to be able | - | ||||||||||||||||||||||||
2151 | to register pointers to forward declared types. | - | ||||||||||||||||||||||||
2152 | - | |||||||||||||||||||||||||
2153 | After a type has been registered, you can create and destroy | - | ||||||||||||||||||||||||
2154 | objects of that type dynamically at run-time. | - | ||||||||||||||||||||||||
2155 | - | |||||||||||||||||||||||||
2156 | To use the type \c T in QVariant, using Q_DECLARE_METATYPE() is | - | ||||||||||||||||||||||||
2157 | sufficient. To use the type \c T in queued signal and slot connections, | - | ||||||||||||||||||||||||
2158 | \c{qRegisterMetaType<T>()} must be called before the first connection | - | ||||||||||||||||||||||||
2159 | is established. | - | ||||||||||||||||||||||||
2160 | - | |||||||||||||||||||||||||
2161 | Also, to use type \c T with the QObject::property() API, | - | ||||||||||||||||||||||||
2162 | \c{qRegisterMetaType<T>()} must be called before it is used, typically | - | ||||||||||||||||||||||||
2163 | in the constructor of the class that uses \c T, or in the \c{main()} | - | ||||||||||||||||||||||||
2164 | function. | - | ||||||||||||||||||||||||
2165 | - | |||||||||||||||||||||||||
2166 | \sa Q_DECLARE_METATYPE() | - | ||||||||||||||||||||||||
2167 | */ | - | ||||||||||||||||||||||||
2168 | - | |||||||||||||||||||||||||
2169 | /*! | - | ||||||||||||||||||||||||
2170 | \fn int qMetaTypeId() | - | ||||||||||||||||||||||||
2171 | \relates QMetaType | - | ||||||||||||||||||||||||
2172 | \threadsafe | - | ||||||||||||||||||||||||
2173 | \since 4.1 | - | ||||||||||||||||||||||||
2174 | - | |||||||||||||||||||||||||
2175 | Returns the meta type id of type \c T at compile time. If the | - | ||||||||||||||||||||||||
2176 | type was not declared with Q_DECLARE_METATYPE(), compilation will | - | ||||||||||||||||||||||||
2177 | fail. | - | ||||||||||||||||||||||||
2178 | - | |||||||||||||||||||||||||
2179 | Typical usage: | - | ||||||||||||||||||||||||
2180 | - | |||||||||||||||||||||||||
2181 | \snippet code/src_corelib_kernel_qmetatype.cpp 8 | - | ||||||||||||||||||||||||
2182 | - | |||||||||||||||||||||||||
2183 | QMetaType::type() returns the same ID as qMetaTypeId(), but does | - | ||||||||||||||||||||||||
2184 | a lookup at runtime based on the name of the type. | - | ||||||||||||||||||||||||
2185 | QMetaType::type() is a bit slower, but compilation succeeds if a | - | ||||||||||||||||||||||||
2186 | type is not registered. | - | ||||||||||||||||||||||||
2187 | - | |||||||||||||||||||||||||
2188 | \sa Q_DECLARE_METATYPE(), QMetaType::type() | - | ||||||||||||||||||||||||
2189 | */ | - | ||||||||||||||||||||||||
2190 | - | |||||||||||||||||||||||||
2191 | namespace { | - | ||||||||||||||||||||||||
2192 | class TypeInfo { | - | ||||||||||||||||||||||||
2193 | template<typename T, bool IsAcceptedType = DefinedTypesFilter::Acceptor<T>::IsAccepted> | - | ||||||||||||||||||||||||
2194 | struct TypeInfoImpl | - | ||||||||||||||||||||||||
2195 | { | - | ||||||||||||||||||||||||
2196 | TypeInfoImpl(const uint /* type */, QMetaTypeInterface &info) | - | ||||||||||||||||||||||||
2197 | { | - | ||||||||||||||||||||||||
2198 | QMetaTypeInterface tmp = QT_METATYPE_INTERFACE_INIT_NO_DATASTREAM(T); | - | ||||||||||||||||||||||||
2199 | info = tmp; | - | ||||||||||||||||||||||||
2200 | } executed 773604 times by 422 tests: end of block Executed by:
| 773604 | ||||||||||||||||||||||||
2201 | }; | - | ||||||||||||||||||||||||
2202 | - | |||||||||||||||||||||||||
2203 | template<typename T> | - | ||||||||||||||||||||||||
2204 | struct TypeInfoImpl<T, /* IsAcceptedType = */ false> | - | ||||||||||||||||||||||||
2205 | { | - | ||||||||||||||||||||||||
2206 | TypeInfoImpl(const uint type, QMetaTypeInterface &info) | - | ||||||||||||||||||||||||
2207 | { | - | ||||||||||||||||||||||||
2208 | if (QModulesPrivate::QTypeModuleInfo<T>::IsGui) {
| 9574-34632 | ||||||||||||||||||||||||
2209 | if (Q_LIKELY(qMetaTypeGuiHelper))
| 46-9528 | ||||||||||||||||||||||||
2210 | info = qMetaTypeGuiHelper[type - QMetaType::FirstGuiType]; executed 9528 times by 37 tests: info = qMetaTypeGuiHelper[type - QMetaType::FirstGuiType]; Executed by:
| 9528 | ||||||||||||||||||||||||
2211 | return; executed 9574 times by 38 tests: return; Executed by:
| 9574 | ||||||||||||||||||||||||
2212 | } | - | ||||||||||||||||||||||||
2213 | if (QModulesPrivate::QTypeModuleInfo<T>::IsWidget) {
| 0-34632 | ||||||||||||||||||||||||
2214 | if (Q_LIKELY(qMetaTypeWidgetsHelper))
| 2-34630 | ||||||||||||||||||||||||
2215 | info = qMetaTypeWidgetsHelper[type - QMetaType::FirstWidgetsType]; executed 34630 times by 3 tests: info = qMetaTypeWidgetsHelper[type - QMetaType::FirstWidgetsType]; Executed by:
| 34630 | ||||||||||||||||||||||||
2216 | return; executed 34632 times by 4 tests: return; Executed by:
| 34632 | ||||||||||||||||||||||||
2217 | } | - | ||||||||||||||||||||||||
2218 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2219 | }; | - | ||||||||||||||||||||||||
2220 | public: | - | ||||||||||||||||||||||||
2221 | QMetaTypeInterface info; | - | ||||||||||||||||||||||||
2222 | TypeInfo(const uint type) | - | ||||||||||||||||||||||||
2223 | : m_type(type) | - | ||||||||||||||||||||||||
2224 | { | - | ||||||||||||||||||||||||
2225 | QMetaTypeInterface tmp = QT_METATYPE_INTERFACE_INIT_EMPTY(); | - | ||||||||||||||||||||||||
2226 | info = tmp; | - | ||||||||||||||||||||||||
2227 | } executed 1261670 times by 449 tests: end of block Executed by:
| 1261670 | ||||||||||||||||||||||||
2228 | template<typename T> | - | ||||||||||||||||||||||||
2229 | void delegate(const T*) { TypeInfoImpl<T>(m_type, info); } executed 817810 times by 423 tests: end of block Executed by:
| 817810 | ||||||||||||||||||||||||
2230 | void delegate(const QMetaTypeSwitcher::UnknownType*) {} | - | ||||||||||||||||||||||||
2231 | void delegate(const QMetaTypeSwitcher::NotBuiltinType*) { customTypeInfo(m_type); } executed 443842 times by 299 tests: end of block Executed by:
| 443842 | ||||||||||||||||||||||||
2232 | private: | - | ||||||||||||||||||||||||
2233 | void customTypeInfo(const uint type) | - | ||||||||||||||||||||||||
2234 | { | - | ||||||||||||||||||||||||
2235 | const QVector<QCustomTypeInfo> * const ct = customTypes(); | - | ||||||||||||||||||||||||
2236 | if (Q_UNLIKELY(!ct))
| 0-443842 | ||||||||||||||||||||||||
2237 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2238 | QReadLocker locker(customTypesLock()); | - | ||||||||||||||||||||||||
2239 | if (Q_LIKELY(uint(ct->count()) > type - QMetaType::User))
| 34-443808 | ||||||||||||||||||||||||
2240 | info = ct->at(type - QMetaType::User); executed 443808 times by 299 tests: info = ct->at(type - QMetaType::User); Executed by:
| 443808 | ||||||||||||||||||||||||
2241 | } executed 443842 times by 299 tests: end of block Executed by:
| 443842 | ||||||||||||||||||||||||
2242 | - | |||||||||||||||||||||||||
2243 | const uint m_type; | - | ||||||||||||||||||||||||
2244 | }; | - | ||||||||||||||||||||||||
2245 | } // namespace | - | ||||||||||||||||||||||||
2246 | - | |||||||||||||||||||||||||
2247 | /*! | - | ||||||||||||||||||||||||
2248 | \fn QMetaType QMetaType::typeInfo(const int type) | - | ||||||||||||||||||||||||
2249 | \internal | - | ||||||||||||||||||||||||
2250 | */ | - | ||||||||||||||||||||||||
2251 | QMetaType QMetaType::typeInfo(const int type) | - | ||||||||||||||||||||||||
2252 | { | - | ||||||||||||||||||||||||
2253 | TypeInfo typeInfo(type); | - | ||||||||||||||||||||||||
2254 | QMetaTypeSwitcher::switcher<void>(typeInfo, type, 0); | - | ||||||||||||||||||||||||
2255 | return typeInfo.info.constructor ? QMetaType(static_cast<ExtensionFlag>(QMetaType::CreateEx | QMetaType::DestroyEx) executed 1261670 times by 449 tests: return typeInfo.info.constructor ? QMetaType(static_cast<ExtensionFlag>(QMetaType::CreateEx | QMetaType::DestroyEx) , static_cast<const QMetaTypeInterface *>(0) , 0 , 0 , typeInfo.info.saveOp , typeInfo.info.loadOp , typeInfo.info.constructor , typeInfo.info.destructor , typeInfo.info.size , typeInfo.info.flags , type , typeInfo.info.metaObject) : QMetaType(UnknownType); Executed by:
| 100-1261670 | ||||||||||||||||||||||||
2256 | , static_cast<const QMetaTypeInterface *>(0) // typeInfo::info is a temporary variable, we can't return address of it. executed 1261670 times by 449 tests: return typeInfo.info.constructor ? QMetaType(static_cast<ExtensionFlag>(QMetaType::CreateEx | QMetaType::DestroyEx) , static_cast<const QMetaTypeInterface *>(0) , 0 , 0 , typeInfo.info.saveOp , typeInfo.info.loadOp , typeInfo.info.constructor , typeInfo.info.destructor , typeInfo.info.size , typeInfo.info.flags , type , typeInfo.info.metaObject) : QMetaType(UnknownType); Executed by:
| 1261670 | ||||||||||||||||||||||||
2257 | , 0 // unused executed 1261670 times by 449 tests: return typeInfo.info.constructor ? QMetaType(static_cast<ExtensionFlag>(QMetaType::CreateEx | QMetaType::DestroyEx) , static_cast<const QMetaTypeInterface *>(0) , 0 , 0 , typeInfo.info.saveOp , typeInfo.info.loadOp , typeInfo.info.constructor , typeInfo.info.destructor , typeInfo.info.size , typeInfo.info.flags , type , typeInfo.info.metaObject) : QMetaType(UnknownType); Executed by:
| 1261670 | ||||||||||||||||||||||||
2258 | , 0 // unused executed 1261670 times by 449 tests: return typeInfo.info.constructor ? QMetaType(static_cast<ExtensionFlag>(QMetaType::CreateEx | QMetaType::DestroyEx) , static_cast<const QMetaTypeInterface *>(0) , 0 , 0 , typeInfo.info.saveOp , typeInfo.info.loadOp , typeInfo.info.constructor , typeInfo.info.destructor , typeInfo.info.size , typeInfo.info.flags , type , typeInfo.info.metaObject) : QMetaType(UnknownType); Executed by:
| 1261670 | ||||||||||||||||||||||||
2259 | , typeInfo.info.saveOp executed 1261670 times by 449 tests: return typeInfo.info.constructor ? QMetaType(static_cast<ExtensionFlag>(QMetaType::CreateEx | QMetaType::DestroyEx) , static_cast<const QMetaTypeInterface *>(0) , 0 , 0 , typeInfo.info.saveOp , typeInfo.info.loadOp , typeInfo.info.constructor , typeInfo.info.destructor , typeInfo.info.size , typeInfo.info.flags , type , typeInfo.info.metaObject) : QMetaType(UnknownType); Executed by:
| 1261670 | ||||||||||||||||||||||||
2260 | , typeInfo.info.loadOp executed 1261670 times by 449 tests: return typeInfo.info.constructor ? QMetaType(static_cast<ExtensionFlag>(QMetaType::CreateEx | QMetaType::DestroyEx) , static_cast<const QMetaTypeInterface *>(0) , 0 , 0 , typeInfo.info.saveOp , typeInfo.info.loadOp , typeInfo.info.constructor , typeInfo.info.destructor , typeInfo.info.size , typeInfo.info.flags , type , typeInfo.info.metaObject) : QMetaType(UnknownType); Executed by:
| 1261670 | ||||||||||||||||||||||||
2261 | , typeInfo.info.constructor executed 1261670 times by 449 tests: return typeInfo.info.constructor ? QMetaType(static_cast<ExtensionFlag>(QMetaType::CreateEx | QMetaType::DestroyEx) , static_cast<const QMetaTypeInterface *>(0) , 0 , 0 , typeInfo.info.saveOp , typeInfo.info.loadOp , typeInfo.info.constructor , typeInfo.info.destructor , typeInfo.info.size , typeInfo.info.flags , type , typeInfo.info.metaObject) : QMetaType(UnknownType); Executed by:
| 1261670 | ||||||||||||||||||||||||
2262 | , typeInfo.info.destructor executed 1261670 times by 449 tests: return typeInfo.info.constructor ? QMetaType(static_cast<ExtensionFlag>(QMetaType::CreateEx | QMetaType::DestroyEx) , static_cast<const QMetaTypeInterface *>(0) , 0 , 0 , typeInfo.info.saveOp , typeInfo.info.loadOp , typeInfo.info.constructor , typeInfo.info.destructor , typeInfo.info.size , typeInfo.info.flags , type , typeInfo.info.metaObject) : QMetaType(UnknownType); Executed by:
| 1261670 | ||||||||||||||||||||||||
2263 | , typeInfo.info.size executed 1261670 times by 449 tests: return typeInfo.info.constructor ? QMetaType(static_cast<ExtensionFlag>(QMetaType::CreateEx | QMetaType::DestroyEx) , static_cast<const QMetaTypeInterface *>(0) , 0 , 0 , typeInfo.info.saveOp , typeInfo.info.loadOp , typeInfo.info.constructor , typeInfo.info.destructor , typeInfo.info.size , typeInfo.info.flags , type , typeInfo.info.metaObject) : QMetaType(UnknownType); Executed by:
| 1261670 | ||||||||||||||||||||||||
2264 | , typeInfo.info.flags executed 1261670 times by 449 tests: return typeInfo.info.constructor ? QMetaType(static_cast<ExtensionFlag>(QMetaType::CreateEx | QMetaType::DestroyEx) , static_cast<const QMetaTypeInterface *>(0) , 0 , 0 , typeInfo.info.saveOp , typeInfo.info.loadOp , typeInfo.info.constructor , typeInfo.info.destructor , typeInfo.info.size , typeInfo.info.flags , type , typeInfo.info.metaObject) : QMetaType(UnknownType); Executed by:
| 1261670 | ||||||||||||||||||||||||
2265 | , type executed 1261670 times by 449 tests: return typeInfo.info.constructor ? QMetaType(static_cast<ExtensionFlag>(QMetaType::CreateEx | QMetaType::DestroyEx) , static_cast<const QMetaTypeInterface *>(0) , 0 , 0 , typeInfo.info.saveOp , typeInfo.info.loadOp , typeInfo.info.constructor , typeInfo.info.destructor , typeInfo.info.size , typeInfo.info.flags , type , typeInfo.info.metaObject) : QMetaType(UnknownType); Executed by:
| 1261670 | ||||||||||||||||||||||||
2266 | , typeInfo.info.metaObject) executed 1261670 times by 449 tests: return typeInfo.info.constructor ? QMetaType(static_cast<ExtensionFlag>(QMetaType::CreateEx | QMetaType::DestroyEx) , static_cast<const QMetaTypeInterface *>(0) , 0 , 0 , typeInfo.info.saveOp , typeInfo.info.loadOp , typeInfo.info.constructor , typeInfo.info.destructor , typeInfo.info.size , typeInfo.info.flags , type , typeInfo.info.metaObject) : QMetaType(UnknownType); Executed by:
| 1261670 | ||||||||||||||||||||||||
2267 | : QMetaType(UnknownType); executed 1261670 times by 449 tests: return typeInfo.info.constructor ? QMetaType(static_cast<ExtensionFlag>(QMetaType::CreateEx | QMetaType::DestroyEx) , static_cast<const QMetaTypeInterface *>(0) , 0 , 0 , typeInfo.info.saveOp , typeInfo.info.loadOp , typeInfo.info.constructor , typeInfo.info.destructor , typeInfo.info.size , typeInfo.info.flags , type , typeInfo.info.metaObject) : QMetaType(UnknownType); Executed by:
| 1261670 | ||||||||||||||||||||||||
2268 | } | - | ||||||||||||||||||||||||
2269 | - | |||||||||||||||||||||||||
2270 | /*! | - | ||||||||||||||||||||||||
2271 | \fn QMetaType::QMetaType(const int typeId) | - | ||||||||||||||||||||||||
2272 | \since 5.0 | - | ||||||||||||||||||||||||
2273 | - | |||||||||||||||||||||||||
2274 | Constructs a QMetaType object that contains all information about type \a typeId. | - | ||||||||||||||||||||||||
2275 | */ | - | ||||||||||||||||||||||||
2276 | QMetaType::QMetaType(const int typeId) | - | ||||||||||||||||||||||||
2277 | : m_typeId(typeId) | - | ||||||||||||||||||||||||
2278 | { | - | ||||||||||||||||||||||||
2279 | if (Q_UNLIKELY(typeId == UnknownType)) {
| 21416-1261670 | ||||||||||||||||||||||||
2280 | // Constructs invalid QMetaType instance. | - | ||||||||||||||||||||||||
2281 | m_extensionFlags = 0xffffffff; | - | ||||||||||||||||||||||||
2282 | Q_ASSERT(!isValid()); | - | ||||||||||||||||||||||||
2283 | } else { executed 21416 times by 56 tests: end of block Executed by:
| 21416 | ||||||||||||||||||||||||
2284 | // TODO it can be better. | - | ||||||||||||||||||||||||
2285 | *this = QMetaType::typeInfo(typeId); | - | ||||||||||||||||||||||||
2286 | if (m_typeId == UnknownType)
| 100-1261570 | ||||||||||||||||||||||||
2287 | m_extensionFlags = 0xffffffff; executed 100 times by 4 tests: m_extensionFlags = 0xffffffff; Executed by:
| 100 | ||||||||||||||||||||||||
2288 | else if (m_typeId == QMetaType::Void)
| 8-1261562 | ||||||||||||||||||||||||
2289 | m_extensionFlags = CreateEx | DestroyEx | ConstructEx | DestructEx; executed 8 times by 1 test: m_extensionFlags = CreateEx | DestroyEx | ConstructEx | DestructEx; Executed by:
| 8 | ||||||||||||||||||||||||
2290 | } executed 1261670 times by 449 tests: end of block Executed by:
| 1261670 | ||||||||||||||||||||||||
2291 | } | - | ||||||||||||||||||||||||
2292 | - | |||||||||||||||||||||||||
2293 | /*! | - | ||||||||||||||||||||||||
2294 | \fn QMetaType::QMetaType(const QMetaType &other) | - | ||||||||||||||||||||||||
2295 | \since 5.0 | - | ||||||||||||||||||||||||
2296 | - | |||||||||||||||||||||||||
2297 | Copy constructs a QMetaType object. | - | ||||||||||||||||||||||||
2298 | */ | - | ||||||||||||||||||||||||
2299 | QMetaType::QMetaType(const QMetaType &other) | - | ||||||||||||||||||||||||
2300 | : m_creator_unused(other.m_creator_unused) | - | ||||||||||||||||||||||||
2301 | , m_deleter_unused(other.m_deleter_unused) | - | ||||||||||||||||||||||||
2302 | , m_saveOp(other.m_saveOp) | - | ||||||||||||||||||||||||
2303 | , m_loadOp(other.m_loadOp) | - | ||||||||||||||||||||||||
2304 | , m_constructor(other.m_constructor) | - | ||||||||||||||||||||||||
2305 | , m_destructor(other.m_destructor) | - | ||||||||||||||||||||||||
2306 | , m_extension(other.m_extension) // space reserved for future use | - | ||||||||||||||||||||||||
2307 | , m_size(other.m_size) | - | ||||||||||||||||||||||||
2308 | , m_typeFlags(other.m_typeFlags) | - | ||||||||||||||||||||||||
2309 | , m_extensionFlags(other.m_extensionFlags) | - | ||||||||||||||||||||||||
2310 | , m_typeId(other.m_typeId) | - | ||||||||||||||||||||||||
2311 | , m_metaObject(other.m_metaObject) | - | ||||||||||||||||||||||||
2312 | {} never executed: end of block | 0 | ||||||||||||||||||||||||
2313 | - | |||||||||||||||||||||||||
2314 | QMetaType &QMetaType::operator =(const QMetaType &other) | - | ||||||||||||||||||||||||
2315 | { | - | ||||||||||||||||||||||||
2316 | m_creator_unused = other.m_creator_unused; | - | ||||||||||||||||||||||||
2317 | m_deleter_unused = other.m_deleter_unused; | - | ||||||||||||||||||||||||
2318 | m_saveOp = other.m_saveOp; | - | ||||||||||||||||||||||||
2319 | m_loadOp = other.m_loadOp; | - | ||||||||||||||||||||||||
2320 | m_constructor = other.m_constructor; | - | ||||||||||||||||||||||||
2321 | m_destructor = other.m_destructor; | - | ||||||||||||||||||||||||
2322 | m_size = other.m_size; | - | ||||||||||||||||||||||||
2323 | m_typeFlags = other.m_typeFlags; | - | ||||||||||||||||||||||||
2324 | m_extensionFlags = other.m_extensionFlags; | - | ||||||||||||||||||||||||
2325 | m_extension = other.m_extension; // space reserved for future use | - | ||||||||||||||||||||||||
2326 | m_typeId = other.m_typeId; | - | ||||||||||||||||||||||||
2327 | m_metaObject = other.m_metaObject; | - | ||||||||||||||||||||||||
2328 | return *this; executed 1261670 times by 449 tests: return *this; Executed by:
| 1261670 | ||||||||||||||||||||||||
2329 | } | - | ||||||||||||||||||||||||
2330 | - | |||||||||||||||||||||||||
2331 | /*! | - | ||||||||||||||||||||||||
2332 | \fn void QMetaType::ctor(const QMetaTypeInterface *info) | - | ||||||||||||||||||||||||
2333 | \internal | - | ||||||||||||||||||||||||
2334 | - | |||||||||||||||||||||||||
2335 | Method used for future binary compatible extensions. The function may be | - | ||||||||||||||||||||||||
2336 | called from within QMetaType's constructor to force a library call from | - | ||||||||||||||||||||||||
2337 | inlined code. | - | ||||||||||||||||||||||||
2338 | */ | - | ||||||||||||||||||||||||
2339 | void QMetaType::ctor(const QMetaTypeInterface *info) | - | ||||||||||||||||||||||||
2340 | { | - | ||||||||||||||||||||||||
2341 | // Special case for Void type, the type is valid but not constructible. | - | ||||||||||||||||||||||||
2342 | // In future we may consider to remove this assert and extend this function to initialize | - | ||||||||||||||||||||||||
2343 | // differently m_extensionFlags for different types. Currently it is not needed. | - | ||||||||||||||||||||||||
2344 | Q_ASSERT(m_typeId == QMetaType::Void); | - | ||||||||||||||||||||||||
2345 | Q_UNUSED(info); | - | ||||||||||||||||||||||||
2346 | m_extensionFlags = CreateEx | DestroyEx | ConstructEx | DestructEx; | - | ||||||||||||||||||||||||
2347 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||
2348 | - | |||||||||||||||||||||||||
2349 | /*! | - | ||||||||||||||||||||||||
2350 | \fn void QMetaType::dtor() | - | ||||||||||||||||||||||||
2351 | \internal | - | ||||||||||||||||||||||||
2352 | - | |||||||||||||||||||||||||
2353 | Method used for future binary compatible extensions. The function may be | - | ||||||||||||||||||||||||
2354 | called from within QMetaType's destructor to force a library call from | - | ||||||||||||||||||||||||
2355 | inlined code. | - | ||||||||||||||||||||||||
2356 | */ | - | ||||||||||||||||||||||||
2357 | void QMetaType::dtor() | - | ||||||||||||||||||||||||
2358 | {} | - | ||||||||||||||||||||||||
2359 | - | |||||||||||||||||||||||||
2360 | /*! | - | ||||||||||||||||||||||||
2361 | \fn void *QMetaType::createExtended(const void *copy) const | - | ||||||||||||||||||||||||
2362 | \internal | - | ||||||||||||||||||||||||
2363 | - | |||||||||||||||||||||||||
2364 | Method used for future binary compatible extensions. The function may be called | - | ||||||||||||||||||||||||
2365 | during QMetaType::create to force library call from inlined code. | - | ||||||||||||||||||||||||
2366 | - | |||||||||||||||||||||||||
2367 | ### TODO Qt6 remove the extension | - | ||||||||||||||||||||||||
2368 | */ | - | ||||||||||||||||||||||||
2369 | void *QMetaType::createExtended(const void *copy) const | - | ||||||||||||||||||||||||
2370 | { | - | ||||||||||||||||||||||||
2371 | if (m_typeId == QMetaType::UnknownType)
| 0-4140 | ||||||||||||||||||||||||
2372 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
2373 | return m_constructor(operator new(m_size), copy); executed 4140 times by 174 tests: return m_constructor(operator new(m_size), copy); Executed by:
| 4140 | ||||||||||||||||||||||||
2374 | } | - | ||||||||||||||||||||||||
2375 | - | |||||||||||||||||||||||||
2376 | /*! | - | ||||||||||||||||||||||||
2377 | \fn void QMetaType::destroyExtended(void *data) const | - | ||||||||||||||||||||||||
2378 | \internal | - | ||||||||||||||||||||||||
2379 | - | |||||||||||||||||||||||||
2380 | Method used for future binary compatible extensions. The function may be called | - | ||||||||||||||||||||||||
2381 | during QMetaType::destroy to force library call from inlined code. | - | ||||||||||||||||||||||||
2382 | - | |||||||||||||||||||||||||
2383 | ### TODO Qt6 remove the extension | - | ||||||||||||||||||||||||
2384 | */ | - | ||||||||||||||||||||||||
2385 | void QMetaType::destroyExtended(void *data) const | - | ||||||||||||||||||||||||
2386 | { | - | ||||||||||||||||||||||||
2387 | m_destructor(data); | - | ||||||||||||||||||||||||
2388 | operator delete(data); | - | ||||||||||||||||||||||||
2389 | } executed 6096 times by 1 test: end of block Executed by:
| 6096 | ||||||||||||||||||||||||
2390 | - | |||||||||||||||||||||||||
2391 | /*! | - | ||||||||||||||||||||||||
2392 | \fn void *QMetaType::constructExtended(void *where, const void *copy) const | - | ||||||||||||||||||||||||
2393 | \internal | - | ||||||||||||||||||||||||
2394 | - | |||||||||||||||||||||||||
2395 | Method used for future binary compatible extensions. The function may be called | - | ||||||||||||||||||||||||
2396 | during QMetaType::construct to force library call from inlined code. | - | ||||||||||||||||||||||||
2397 | */ | - | ||||||||||||||||||||||||
2398 | void *QMetaType::constructExtended(void *where, const void *copy) const | - | ||||||||||||||||||||||||
2399 | { | - | ||||||||||||||||||||||||
2400 | Q_UNUSED(where); | - | ||||||||||||||||||||||||
2401 | Q_UNUSED(copy); | - | ||||||||||||||||||||||||
2402 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
2403 | } | - | ||||||||||||||||||||||||
2404 | - | |||||||||||||||||||||||||
2405 | /*! | - | ||||||||||||||||||||||||
2406 | \fn void QMetaType::destructExtended(void *data) const | - | ||||||||||||||||||||||||
2407 | \internal | - | ||||||||||||||||||||||||
2408 | - | |||||||||||||||||||||||||
2409 | Method used for future binary compatible extensions. The function may be called | - | ||||||||||||||||||||||||
2410 | during QMetaType::destruct to force library call from inlined code. | - | ||||||||||||||||||||||||
2411 | */ | - | ||||||||||||||||||||||||
2412 | void QMetaType::destructExtended(void *data) const | - | ||||||||||||||||||||||||
2413 | { | - | ||||||||||||||||||||||||
2414 | Q_UNUSED(data); | - | ||||||||||||||||||||||||
2415 | } executed 27 times by 1 test: end of block Executed by:
| 27 | ||||||||||||||||||||||||
2416 | - | |||||||||||||||||||||||||
2417 | /*! | - | ||||||||||||||||||||||||
2418 | \fn uint QMetaType::sizeExtended() const | - | ||||||||||||||||||||||||
2419 | \internal | - | ||||||||||||||||||||||||
2420 | - | |||||||||||||||||||||||||
2421 | Method used for future binary compatible extensions. The function may be | - | ||||||||||||||||||||||||
2422 | called from within QMetaType::size to force a library call from | - | ||||||||||||||||||||||||
2423 | inlined code. | - | ||||||||||||||||||||||||
2424 | */ | - | ||||||||||||||||||||||||
2425 | uint QMetaType::sizeExtended() const | - | ||||||||||||||||||||||||
2426 | { | - | ||||||||||||||||||||||||
2427 | return 0; executed 142 times by 4 tests: return 0; Executed by:
| 142 | ||||||||||||||||||||||||
2428 | } | - | ||||||||||||||||||||||||
2429 | - | |||||||||||||||||||||||||
2430 | /*! | - | ||||||||||||||||||||||||
2431 | \fn QMetaType::TypeFlags QMetaType::flagsExtended() const | - | ||||||||||||||||||||||||
2432 | \internal | - | ||||||||||||||||||||||||
2433 | - | |||||||||||||||||||||||||
2434 | Method used for future binary compatible extensions. The function may be | - | ||||||||||||||||||||||||
2435 | called from within QMetaType::flags to force a library call from | - | ||||||||||||||||||||||||
2436 | inlined code. | - | ||||||||||||||||||||||||
2437 | */ | - | ||||||||||||||||||||||||
2438 | QMetaType::TypeFlags QMetaType::flagsExtended() const | - | ||||||||||||||||||||||||
2439 | { | - | ||||||||||||||||||||||||
2440 | return 0; executed 21221 times by 54 tests: return 0; Executed by:
| 21221 | ||||||||||||||||||||||||
2441 | } | - | ||||||||||||||||||||||||
2442 | - | |||||||||||||||||||||||||
2443 | /*! | - | ||||||||||||||||||||||||
2444 | \brief QMetaType::metaObjectExtended | - | ||||||||||||||||||||||||
2445 | \internal | - | ||||||||||||||||||||||||
2446 | - | |||||||||||||||||||||||||
2447 | Method used for future binary compatible extensions. The function may be | - | ||||||||||||||||||||||||
2448 | called from within QMetaType::metaObject to force a library call from | - | ||||||||||||||||||||||||
2449 | inlined code. | - | ||||||||||||||||||||||||
2450 | */ | - | ||||||||||||||||||||||||
2451 | const QMetaObject *QMetaType::metaObjectExtended() const | - | ||||||||||||||||||||||||
2452 | { | - | ||||||||||||||||||||||||
2453 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
2454 | } | - | ||||||||||||||||||||||||
2455 | - | |||||||||||||||||||||||||
2456 | - | |||||||||||||||||||||||||
2457 | namespace QtPrivate | - | ||||||||||||||||||||||||
2458 | { | - | ||||||||||||||||||||||||
2459 | const QMetaObject *metaObjectForQWidget() | - | ||||||||||||||||||||||||
2460 | { | - | ||||||||||||||||||||||||
2461 | if (!qMetaTypeWidgetsHelper)
| 0 | ||||||||||||||||||||||||
2462 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
2463 | return qMetaObjectWidgetsHelper; never executed: return qMetaObjectWidgetsHelper; | 0 | ||||||||||||||||||||||||
2464 | } | - | ||||||||||||||||||||||||
2465 | } | - | ||||||||||||||||||||||||
2466 | - | |||||||||||||||||||||||||
2467 | namespace QtMetaTypePrivate { | - | ||||||||||||||||||||||||
2468 | const bool VectorBoolElements::true_element = true; | - | ||||||||||||||||||||||||
2469 | const bool VectorBoolElements::false_element = false; | - | ||||||||||||||||||||||||
2470 | } | - | ||||||||||||||||||||||||
2471 | - | |||||||||||||||||||||||||
2472 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||
Source code | Switch to Preprocessed file |