Detect QMetaType::QReal from the definition of qreal
[profile/ivi/qtbase.git] / src / corelib / kernel / qmetatype.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtCore module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QMETATYPE_H
43 #define QMETATYPE_H
44
45 #include <QtCore/qglobal.h>
46 #include <QtCore/qatomic.h>
47 #include <QtCore/qbytearray.h>
48
49 #include <new>
50
51 #ifdef Bool
52 #error qmetatype.h must be included before any header file that defines Bool
53 #endif
54
55 QT_BEGIN_HEADER
56
57 QT_BEGIN_NAMESPACE
58
59
60 // F is a tuple: (QMetaType::TypeName, QMetaType::TypeNameID, RealType)
61 #define QT_FOR_EACH_STATIC_PRIMITIVE_TYPE(F)\
62     F(Void, 0, void) \
63     F(Bool, 1, bool) \
64     F(Int, 2, int) \
65     F(UInt, 3, uint) \
66     F(LongLong, 4, qlonglong) \
67     F(ULongLong, 5, qulonglong) \
68     F(Double, 6, double) \
69     F(Long, 32, long) \
70     F(Short, 33, short) \
71     F(Char, 34, char) \
72     F(ULong, 35, ulong) \
73     F(UShort, 36, ushort) \
74     F(UChar, 37, uchar) \
75     F(Float, 38, float) \
76
77 #define QT_FOR_EACH_STATIC_PRIMITIVE_POINTER(F)\
78     F(VoidStar, 31, void*) \
79
80 #define QT_FOR_EACH_STATIC_CORE_CLASS(F)\
81     F(QChar, 7, QChar) \
82     F(QString, 10, QString) \
83     F(QStringList, 11, QStringList) \
84     F(QByteArray, 12, QByteArray) \
85     F(QBitArray, 13, QBitArray) \
86     F(QDate, 14, QDate) \
87     F(QTime, 15, QTime) \
88     F(QDateTime, 16, QDateTime) \
89     F(QUrl, 17, QUrl) \
90     F(QLocale, 18, QLocale) \
91     F(QRect, 19, QRect) \
92     F(QRectF, 20, QRectF) \
93     F(QSize, 21, QSize) \
94     F(QSizeF, 22, QSizeF) \
95     F(QLine, 23, QLine) \
96     F(QLineF, 24, QLineF) \
97     F(QPoint, 25, QPoint) \
98     F(QPointF, 26, QPointF) \
99     F(QRegExp, 27, QRegExp) \
100     F(QEasingCurve, 29, QEasingCurve) \
101     F(QUuid, 30, QUuid) \
102     F(QVariant, 41, QVariant) \
103     F(QModelIndex, 42, QModelIndex) \
104
105 #define QT_FOR_EACH_STATIC_CORE_POINTER(F)\
106     F(QObjectStar, 39, QObject*) \
107     F(QWidgetStar, 40, QWidget*) \
108
109 #define QT_FOR_EACH_STATIC_CORE_TEMPLATE(F)\
110     F(QVariantMap, 8, QVariantMap) \
111     F(QVariantList, 9, QVariantList) \
112     F(QVariantHash, 28, QVariantHash) \
113
114 #define QT_FOR_EACH_STATIC_GUI_CLASS(F)\
115     F(QFont, 64, QFont) \
116     F(QPixmap, 65, QPixmap) \
117     F(QBrush, 66, QBrush) \
118     F(QColor, 67, QColor) \
119     F(QPalette, 68, QPalette) \
120     F(QImage, 69, QImage) \
121     F(QPolygon, 70, QPolygon) \
122     F(QRegion, 71, QRegion) \
123     F(QBitmap, 72, QBitmap) \
124     F(QCursor, 73, QCursor) \
125     F(QKeySequence, 74, QKeySequence) \
126     F(QPen, 75, QPen) \
127     F(QTextLength, 76, QTextLength) \
128     F(QTextFormat, 77, QTextFormat) \
129     F(QMatrix, 78, QMatrix) \
130     F(QTransform, 79, QTransform) \
131     F(QMatrix4x4, 80, QMatrix4x4) \
132     F(QVector2D, 81, QVector2D) \
133     F(QVector3D, 82, QVector3D) \
134     F(QVector4D, 83, QVector4D) \
135     F(QQuaternion, 84, QQuaternion) \
136     F(QPolygonF, 85, QPolygonF) \
137
138 #define QT_FOR_EACH_STATIC_WIDGETS_CLASS(F)\
139     F(QIcon, 120, QIcon) \
140     F(QSizePolicy, 121, QSizePolicy) \
141
142 // ### FIXME kill that set
143 #define QT_FOR_EACH_STATIC_HACKS_TYPE(F)\
144     F(QMetaTypeId2<qreal>::MetaType, -1, qreal)
145
146 // F is a tuple: (QMetaType::TypeName, QMetaType::TypeNameID, AliasingType, "RealType")
147 #define QT_FOR_EACH_STATIC_ALIAS_TYPE(F)\
148     F(ULong, -1, ulong, "unsigned long") \
149     F(UInt, -1, uint, "unsigned int") \
150     F(UShort, -1, ushort, "unsigned short") \
151     F(UChar, -1, uchar, "unsigned char") \
152     F(LongLong, -1, qlonglong, "long long") \
153     F(ULongLong, -1, qulonglong, "unsigned long long") \
154     F(Char, -1, char, "qint8") \
155     F(Char, -1, char, "signed char") \
156     F(UChar, -1, uchar, "quint8") \
157     F(Short, -1, short, "qint16") \
158     F(UShort, -1, ushort, "quint16") \
159     F(Int, -1, int, "qint32") \
160     F(UInt, -1, uint, "quint32") \
161     F(LongLong, -1, qlonglong, "qint64") \
162     F(ULongLong, -1, qulonglong, "quint64") \
163     F(QVariantList, -1, QVariantList, "QList<QVariant>") \
164     F(QVariantMap, -1, QVariantMap, "QMap<QString,QVariant>") \
165     F(QVariantHash, -1, QVariantHash, "QHash<QString,QVariant>") \
166
167 #define QT_FOR_EACH_STATIC_TYPE(F)\
168     QT_FOR_EACH_STATIC_PRIMITIVE_TYPE(F)\
169     QT_FOR_EACH_STATIC_PRIMITIVE_POINTER(F)\
170     QT_FOR_EACH_STATIC_CORE_CLASS(F)\
171     QT_FOR_EACH_STATIC_CORE_POINTER(F)\
172     QT_FOR_EACH_STATIC_CORE_TEMPLATE(F)\
173     QT_FOR_EACH_STATIC_GUI_CLASS(F)\
174     QT_FOR_EACH_STATIC_WIDGETS_CLASS(F)\
175
176 #define QT_DEFINE_METATYPE_ID(TypeName, Id, Name) \
177     TypeName = Id,
178
179 class QDataStream;
180 class QMetaTypeInterface;
181
182 class Q_CORE_EXPORT QMetaType {
183     enum ExtensionFlag { NoExtensionFlags,
184                          CreateEx = 0x1, DestroyEx = 0x2,
185                          ConstructEx = 0x4, DestructEx = 0x8,
186                          NameEx = 0x10, SizeEx = 0x20,
187                          CtorEx = 0x40, DtorEx = 0x80,
188                          FlagsEx = 0x100
189                        };
190 public:
191     enum Type {
192         // these are merged with QVariant
193         QT_FOR_EACH_STATIC_TYPE(QT_DEFINE_METATYPE_ID)
194
195         FirstCoreType = Void,
196         LastCoreType = QModelIndex,
197         FirstGuiType = QFont,
198         LastGuiType = QPolygonF,
199         FirstWidgetsType = QIcon,
200         LastWidgetsType = QSizePolicy,
201         HighestInternalId = LastWidgetsType,
202
203         QReal = sizeof(qreal) == sizeof(double) ? Double : Float,
204
205         User = 256
206     };
207
208     enum TypeFlag {
209         NeedsConstruction = 0x1,
210         NeedsDestruction = 0x2,
211         MovableType = 0x4,
212         PointerToQObject = 0x8
213     };
214     Q_DECLARE_FLAGS(TypeFlags, TypeFlag)
215
216     typedef void (*Deleter)(void *);
217     typedef void *(*Creator)(const void *);
218
219     typedef void (*Destructor)(void *);
220     typedef void *(*Constructor)(void *, const void *);
221
222     typedef void (*SaveOperator)(QDataStream &, const void *);
223     typedef void (*LoadOperator)(QDataStream &, void *);
224 #ifndef QT_NO_DATASTREAM
225     static void registerStreamOperators(const char *typeName, SaveOperator saveOp,
226                                         LoadOperator loadOp);
227     static void registerStreamOperators(int type, SaveOperator saveOp,
228                                         LoadOperator loadOp);
229 #endif
230     static int registerType(const char *typeName, Deleter deleter,
231                             Creator creator);
232     static int registerType(const char *typeName, Deleter deleter,
233                             Creator creator,
234                             Destructor destructor,
235                             Constructor constructor,
236                             int size,
237                             QMetaType::TypeFlags flags);
238     static int registerTypedef(const char *typeName, int aliasId);
239     static int type(const char *typeName);
240     static const char *typeName(int type);
241     static int sizeOf(int type);
242     static TypeFlags typeFlags(int type);
243     static bool isRegistered(int type);
244     static void *create(int type, const void *copy = 0);
245 #if QT_DEPRECATED_SINCE(5, 0)
246     QT_DEPRECATED static void *construct(int type, const void *copy = 0)
247     { return create(type, copy); }
248 #endif
249     static void destroy(int type, void *data);
250     static void *construct(int type, void *where, const void *copy);
251     static void destruct(int type, void *where);
252
253 #ifndef QT_NO_DATASTREAM
254     static bool save(QDataStream &stream, int type, const void *data);
255     static bool load(QDataStream &stream, int type, void *data);
256 #endif
257
258     QMetaType(const int type);
259     inline ~QMetaType();
260
261     inline bool isValid() const;
262     inline bool isRegistered() const;
263     inline int sizeOf() const;
264     inline TypeFlags flags() const;
265
266     inline void *create(const void *copy = 0) const;
267     inline void destroy(void *data) const;
268     inline void *construct(void *where, const void *copy = 0) const;
269     inline void destruct(void *data) const;
270 private:
271     static QMetaType typeInfo(const int type);
272     inline QMetaType(const ExtensionFlag extensionFlags, const QMetaTypeInterface *info,
273                      Creator creator,
274                      Deleter deleter,
275                      SaveOperator saveOp,
276                      LoadOperator loadOp,
277                      Constructor constructor,
278                      Destructor destructor,
279                      uint sizeOf,
280                      uint theTypeFlags,
281                      int typeId);
282     QMetaType(const QMetaType &other);
283     QMetaType &operator =(const QMetaType &);
284     inline bool isExtended(const ExtensionFlag flag) const { return m_extensionFlags & flag; }
285
286     // Methods used for future binary compatibile extensions
287     void ctor(const QMetaTypeInterface *info);
288     void dtor();
289     uint sizeExtended() const;
290     QMetaType::TypeFlags flagsExtended() const;
291     void *createExtended(const void *copy = 0) const;
292     void destroyExtended(void *data) const;
293     void *constructExtended(void *where, const void *copy = 0) const;
294     void destructExtended(void *data) const;
295
296     Creator m_creator;
297     Deleter m_deleter;
298     SaveOperator m_saveOp;
299     LoadOperator m_loadOp;
300     Constructor m_constructor;
301     Destructor m_destructor;
302     void *m_extension; // space reserved for future use
303     uint m_size;
304     uint m_typeFlags;
305     uint m_extensionFlags;
306     int m_typeId;
307 };
308
309 #undef QT_DEFINE_METATYPE_ID
310
311 Q_DECLARE_OPERATORS_FOR_FLAGS(QMetaType::TypeFlags)
312
313 template <typename T>
314 void qMetaTypeDeleteHelper(void *t)
315 {
316     delete static_cast<T*>(t);
317 }
318 template <> inline void qMetaTypeDeleteHelper<void>(void *) {}
319
320 template <typename T>
321 void *qMetaTypeCreateHelper(const void *t)
322 {
323     if (t)
324         return new T(*static_cast<const T*>(t));
325     return new T();
326 }
327
328 template <> inline void *qMetaTypeCreateHelper<void>(const void *) { return 0; }
329
330 template <typename T>
331 void qMetaTypeDestructHelper(void *t)
332 {
333     Q_UNUSED(t) // Silence MSVC that warns for POD types.
334     static_cast<T*>(t)->~T();
335 }
336
337 template <> inline void qMetaTypeDestructHelper<void>(void *) {}
338
339 template <typename T>
340 void *qMetaTypeConstructHelper(void *where, const void *t)
341 {
342     if (t)
343         return new (where) T(*static_cast<const T*>(t));
344     return new (where) T;
345 }
346
347 template <> inline void *qMetaTypeConstructHelper<void>(void *, const void *) { return 0; }
348
349 #ifndef QT_NO_DATASTREAM
350 template <typename T>
351 void qMetaTypeSaveHelper(QDataStream &stream, const void *t)
352 {
353     stream << *static_cast<const T*>(t);
354 }
355
356 template <> inline void qMetaTypeSaveHelper<void>(QDataStream &, const void *) {}
357
358 template <typename T>
359 void qMetaTypeLoadHelper(QDataStream &stream, void *t)
360 {
361     stream >> *static_cast<T*>(t);
362 }
363
364 template <> inline void qMetaTypeLoadHelper<void>(QDataStream &, void *) {}
365 #endif // QT_NO_DATASTREAM
366
367 template <typename T>
368 struct QMetaTypeId
369 {
370     enum { Defined = 0 };
371 };
372
373 template <typename T>
374 struct QMetaTypeId2
375 {
376     enum { Defined = QMetaTypeId<T>::Defined };
377     static inline int qt_metatype_id() { return QMetaTypeId<T>::qt_metatype_id(); }
378 };
379
380 class QObject;
381 class QWidget;
382
383 namespace QtPrivate {
384     template <typename T, bool Defined = QMetaTypeId2<T>::Defined>
385     struct QMetaTypeIdHelper {
386         static inline int qt_metatype_id()
387         { return QMetaTypeId2<T>::qt_metatype_id(); }
388     };
389     template <typename T> struct QMetaTypeIdHelper<T, false> {
390         static inline int qt_metatype_id()
391         { return -1; }
392     };
393
394     template<typename T>
395     struct IsPointerToTypeDerivedFromQObject
396     {
397         enum { Value = false };
398     };
399
400     // Specialize to avoid sizeof(void) warning
401     template<>
402     struct IsPointerToTypeDerivedFromQObject<void*>
403     {
404         enum { Value = false };
405     };
406     template<>
407     struct IsPointerToTypeDerivedFromQObject<QObject*>
408     {
409         enum { Value = true };
410     };
411     template<>
412     struct IsPointerToTypeDerivedFromQObject<QWidget*>
413     {
414         enum { Value = true };
415     };
416
417     template<typename T>
418     struct IsPointerToTypeDerivedFromQObject<T*>
419     {
420         typedef qint8 yes_type;
421         typedef qint64 no_type;
422
423 #ifndef QT_NO_QOBJECT
424         static yes_type checkType(QObject* );
425 #endif
426         static no_type checkType(...);
427         Q_STATIC_ASSERT_X(sizeof(T), "Type argument of Q_DECLARE_METATYPE(T*) must be fully defined");
428         enum { Value = sizeof(checkType(static_cast<T*>(0))) == sizeof(yes_type) };
429     };
430
431     // Function pointers don't derive from QObject
432     template <class Result> struct IsPointerToTypeDerivedFromQObject<Result(*)()> { enum { Value = false }; };
433     template <class Result, class Arg0> struct IsPointerToTypeDerivedFromQObject<Result(*)(Arg0)> { enum { Value = false }; };
434     template <class Result, class Arg0, class Arg1> struct IsPointerToTypeDerivedFromQObject<Result(*)(Arg0, Arg1)> { enum { Value = false }; };
435     template <class Result, class Arg0, class Arg1, class Arg2> struct IsPointerToTypeDerivedFromQObject<Result(*)(Arg0, Arg1, Arg2)> { enum { Value = false }; };
436 }
437
438 template <typename T>
439 int qRegisterMetaType(const char *typeName
440 #ifndef qdoc
441     , T * dummy = 0
442 #endif
443 )
444 {
445     const int typedefOf = dummy ? -1 : QtPrivate::QMetaTypeIdHelper<T>::qt_metatype_id();
446     if (typedefOf != -1)
447         return QMetaType::registerTypedef(typeName, typedefOf);
448
449     QMetaType::TypeFlags flags;
450     if (!QTypeInfo<T>::isStatic)
451         flags |= QMetaType::MovableType;
452     if (QTypeInfo<T>::isComplex) {
453         flags |= QMetaType::NeedsConstruction;
454         flags |= QMetaType::NeedsDestruction;
455     }
456     if (QtPrivate::IsPointerToTypeDerivedFromQObject<T>::Value)
457         flags |= QMetaType::PointerToQObject;
458
459     return QMetaType::registerType(typeName, qMetaTypeDeleteHelper<T>,
460                                    qMetaTypeCreateHelper<T>,
461                                    qMetaTypeDestructHelper<T>,
462                                    qMetaTypeConstructHelper<T>,
463                                    sizeof(T),
464                                    flags);
465 }
466
467 #ifndef QT_NO_DATASTREAM
468 template <typename T>
469 void qRegisterMetaTypeStreamOperators(const char *typeName
470 #ifndef qdoc
471     , T * /* dummy */ = 0
472 #endif
473 )
474 {
475     qRegisterMetaType<T>(typeName);
476     QMetaType::registerStreamOperators(typeName, qMetaTypeSaveHelper<T>, qMetaTypeLoadHelper<T>);
477 }
478 #endif // QT_NO_DATASTREAM
479
480 template <typename T>
481 inline int qMetaTypeId(
482 #ifndef qdoc
483     T * /* dummy */ = 0
484 #endif
485 )
486 {
487     return QMetaTypeId2<T>::qt_metatype_id();
488 }
489
490 template <typename T>
491 inline int qRegisterMetaType(
492 #if !defined(qdoc) && !defined(Q_CC_SUN)
493     T * dummy = 0
494 #endif
495 )
496 {
497 #ifdef Q_CC_SUN
498     return qMetaTypeId(static_cast<T *>(0));
499 #else
500     return qMetaTypeId(dummy);
501 #endif
502 }
503
504 #ifndef QT_NO_DATASTREAM
505 template <typename T>
506 inline int qRegisterMetaTypeStreamOperators()
507 {
508     register int id = qMetaTypeId<T>();
509     QMetaType::registerStreamOperators(id, qMetaTypeSaveHelper<T>, qMetaTypeLoadHelper<T>);
510     return id;
511 }
512 #endif
513
514 #define Q_DECLARE_OPAQUE_POINTER(POINTER)                               \
515     QT_BEGIN_NAMESPACE namespace QtPrivate {                            \
516         template <>                                                     \
517         struct IsPointerToTypeDerivedFromQObject<POINTER >              \
518         {                                                               \
519             enum { Value = false };                                     \
520         };                                                              \
521     } QT_END_NAMESPACE                                                  \
522     /**/
523
524 #define Q_DECLARE_METATYPE(TYPE)                                        \
525     QT_BEGIN_NAMESPACE                                                  \
526     template <>                                                         \
527     struct QMetaTypeId< TYPE >                                          \
528     {                                                                   \
529         enum { Defined = 1 };                                           \
530         static int qt_metatype_id()                                     \
531             {                                                           \
532                 static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0); \
533                 if (!metatype_id.load())                                \
534                     metatype_id.storeRelease(qRegisterMetaType< TYPE >(#TYPE, \
535                                reinterpret_cast< TYPE *>(quintptr(-1)))); \
536                 return metatype_id.loadAcquire();                       \
537             }                                                           \
538     };                                                                  \
539     QT_END_NAMESPACE
540
541 #define Q_DECLARE_BUILTIN_METATYPE(TYPE, NAME) \
542     QT_BEGIN_NAMESPACE \
543     template<> struct QMetaTypeId2<TYPE> \
544     { \
545         enum { Defined = 1, MetaType = QMetaType::NAME }; \
546         static inline int qt_metatype_id() { return QMetaType::NAME; } \
547     }; \
548     QT_END_NAMESPACE
549
550 #define QT_FORWARD_DECLARE_STATIC_TYPES_ITER(TypeName, TypeId, Name) \
551     class Name;
552
553 QT_FOR_EACH_STATIC_CORE_CLASS(QT_FORWARD_DECLARE_STATIC_TYPES_ITER)
554 QT_FOR_EACH_STATIC_GUI_CLASS(QT_FORWARD_DECLARE_STATIC_TYPES_ITER)
555 QT_FOR_EACH_STATIC_WIDGETS_CLASS(QT_FORWARD_DECLARE_STATIC_TYPES_ITER)
556
557 #undef QT_FORWARD_DECLARE_STATIC_TYPES_ITER
558
559 template <class T> class QList;
560 template <class T> class QLinkedList;
561 template <class T> class QVector;
562 template <class T> class QQueue;
563 template <class T> class QStack;
564 template <class T> class QSet;
565 template <class T> class QSharedPointer;
566 template <class T1, class T2> class QMap;
567 template <class T1, class T2> class QHash;
568 typedef QList<QVariant> QVariantList;
569 typedef QMap<QString, QVariant> QVariantMap;
570 typedef QHash<QString, QVariant> QVariantHash;
571
572 #define Q_DECLARE_METATYPE_TEMPLATE_1ARG(SINGLE_ARG_TEMPLATE) \
573 template <typename T> \
574 struct QMetaTypeId< SINGLE_ARG_TEMPLATE<T> > \
575 { \
576     enum { \
577         Defined = QMetaTypeId2<T>::Defined \
578     }; \
579     static int qt_metatype_id() \
580     { \
581         static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0); \
582         if (!metatype_id.load()) \
583             metatype_id.storeRelease(qRegisterMetaType< SINGLE_ARG_TEMPLATE<T> >( QByteArray(QByteArray(#SINGLE_ARG_TEMPLATE "<") + QMetaType::typeName(qMetaTypeId<T>()) + ">").constData(), \
584                         reinterpret_cast< SINGLE_ARG_TEMPLATE<T> *>(quintptr(-1)))); \
585         return metatype_id.loadAcquire(); \
586     } \
587 };
588
589 Q_DECLARE_METATYPE_TEMPLATE_1ARG(QList)
590 Q_DECLARE_METATYPE_TEMPLATE_1ARG(QVector)
591 Q_DECLARE_METATYPE_TEMPLATE_1ARG(QQueue)
592 Q_DECLARE_METATYPE_TEMPLATE_1ARG(QStack)
593 Q_DECLARE_METATYPE_TEMPLATE_1ARG(QSet)
594 Q_DECLARE_METATYPE_TEMPLATE_1ARG(QSharedPointer)
595 Q_DECLARE_METATYPE_TEMPLATE_1ARG(QLinkedList)
596
597 inline QMetaType::QMetaType(const ExtensionFlag extensionFlags, const QMetaTypeInterface *info,
598                             Creator creator,
599                             Deleter deleter,
600                             SaveOperator saveOp,
601                             LoadOperator loadOp,
602                             Constructor constructor,
603                             Destructor destructor,
604                             uint size,
605                             uint theTypeFlags,
606                             int typeId)
607     : m_creator(creator)
608     , m_deleter(deleter)
609     , m_saveOp(saveOp)
610     , m_loadOp(loadOp)
611     , m_constructor(constructor)
612     , m_destructor(destructor)
613     , m_size(size)
614     , m_typeFlags(theTypeFlags)
615     , m_extensionFlags(extensionFlags)
616     , m_typeId(typeId)
617 {
618     if (Q_UNLIKELY(isExtended(CtorEx) || typeId == QMetaType::Void))
619         ctor(info);
620 }
621
622 inline QMetaType::~QMetaType()
623 {
624     if (Q_UNLIKELY(isExtended(DtorEx)))
625         dtor();
626 }
627
628 inline bool QMetaType::isValid() const
629 {
630     return m_typeId >= 0;
631 }
632
633 inline bool QMetaType::isRegistered() const
634 {
635     return isValid();
636 }
637
638 inline void *QMetaType::create(const void *copy) const
639 {
640     if (Q_UNLIKELY(isExtended(CreateEx)))
641         return createExtended(copy);
642     return m_creator(copy);
643 }
644
645 inline void QMetaType::destroy(void *data) const
646 {
647     if (Q_UNLIKELY(isExtended(DestroyEx)))
648         return destroyExtended(data);
649     m_deleter(data);
650 }
651
652 inline void *QMetaType::construct(void *where, const void *copy) const
653 {
654     if (Q_UNLIKELY(isExtended(ConstructEx)))
655         return constructExtended(where, copy);
656     return m_constructor(where, copy);
657 }
658
659 inline void QMetaType::destruct(void *data) const
660 {
661     if (Q_UNLIKELY(isExtended(DestructEx)))
662         return destructExtended(data);
663     if (Q_UNLIKELY(!data))
664         return;
665     m_destructor(data);
666 }
667
668 inline int QMetaType::sizeOf() const
669 {
670     if (Q_UNLIKELY(isExtended(SizeEx)))
671         return sizeExtended();
672     return m_size;
673 }
674
675 inline QMetaType::TypeFlags QMetaType::flags() const
676 {
677     if (Q_UNLIKELY(isExtended(FlagsEx)))
678         return flagsExtended();
679     return QMetaType::TypeFlags(m_typeFlags);
680 }
681
682 QT_END_NAMESPACE
683
684
685 #define QT_DECLARE_BUILTIN_METATYPE_ITER(MetaTypeName, MetaTypeId, Name) \
686     Q_DECLARE_BUILTIN_METATYPE(Name, MetaTypeName)
687
688 QT_FOR_EACH_STATIC_TYPE(QT_DECLARE_BUILTIN_METATYPE_ITER)
689 Q_DECLARE_BUILTIN_METATYPE(signed char, Char)
690
691 #undef QT_DECLARE_BUILTIN_METATYPE_ITER
692
693
694 QT_END_HEADER
695
696 #endif // QMETATYPE_H