1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file. Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights. These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
42 #include <QtDeclarative/qdeclarativeprivate.h>
43 #include "private/qdeclarativemetatype_p.h"
45 #include "private/qdeclarativeproxymetaobject_p.h"
46 #include "private/qdeclarativecustomparser_p.h"
47 #include "private/qdeclarativeguard_p.h"
49 #include <QtCore/qdebug.h>
50 #include <QtCore/qstringlist.h>
51 #include <QtCore/qmetaobject.h>
52 #include <QtCore/qbitarray.h>
53 #include <QtCore/qreadwritelock.h>
54 #include <qmetatype.h>
55 #include <qobjectdefs.h>
56 #include <qdatetime.h>
57 #include <qbytearray.h>
58 #include <qreadwritelock.h>
60 #include <qstringlist.h>
63 #include <QtCore/qcryptographichash.h>
64 #include <QtScript/qscriptvalue.h>
68 #ifdef QT_BOOTSTRAPPED
69 # ifndef QT_NO_GEOM_VARIANT
70 # define QT_NO_GEOM_VARIANT
73 # include <qbitarray.h>
75 # include <qvariant.h>
78 #ifndef QT_NO_GEOM_VARIANT
83 # include <qvector3d.h>
85 #define NS(x) QT_PREPEND_NAMESPACE(x)
89 struct QDeclarativeMetaTypeData
91 QDeclarativeMetaTypeData();
92 ~QDeclarativeMetaTypeData();
93 QList<QDeclarativeType *> types;
94 typedef QHash<int, QDeclarativeType *> Ids;
96 typedef QHash<QByteArray, QDeclarativeType *> Names;
98 typedef QHash<const QMetaObject *, QDeclarativeType *> MetaObjects;
99 MetaObjects metaObjectToType;
100 typedef QHash<int, QDeclarativeMetaType::StringConverter> StringConverters;
101 StringConverters stringConverters;
102 struct ModuleApiList {
103 ModuleApiList() : sorted(true) {}
104 QList<QDeclarativeMetaType::ModuleApi> moduleApis;
107 typedef QHash<QByteArray, ModuleApiList> ModuleApis;
108 ModuleApis moduleApis;
112 ModuleInfo(int major, int minor)
113 : vmajor_min(major), vminor_min(minor), vmajor_max(major), vminor_max(minor) {}
114 ModuleInfo(int major_min, int minor_min, int major_max, int minor_max)
115 : vmajor_min(major_min), vminor_min(minor_min), vmajor_max(major_max), vminor_max(minor_max) {}
116 int vmajor_min, vminor_min;
117 int vmajor_max, vminor_max;
119 typedef QHash<QByteArray, ModuleInfo> ModuleInfoHash;
120 ModuleInfoHash modules;
123 QBitArray interfaces;
126 QList<QDeclarativePrivate::AutoParentFunction> parentFunctions;
128 Q_GLOBAL_STATIC(QDeclarativeMetaTypeData, metaTypeData)
129 Q_GLOBAL_STATIC(QReadWriteLock, metaTypeDataLock)
131 QDeclarativeMetaTypeData::QDeclarativeMetaTypeData()
136 QDeclarativeMetaTypeData::~QDeclarativeMetaTypeData()
138 for (int i = 0; i < types.count(); ++i)
142 class QDeclarativeTypePrivate
145 QDeclarativeTypePrivate();
149 bool m_isInterface : 1;
155 int m_typeId; int m_listId;
157 mutable bool m_containsRevisionedAttributes;
158 mutable QDeclarativeType *m_superType;
160 int m_allocationSize;
161 void (*m_newFunc)(void *);
162 QString m_noCreationReason;
164 const QMetaObject *m_baseMetaObject;
165 QDeclarativeAttachedPropertiesFunc m_attachedPropertiesFunc;
166 const QMetaObject *m_attachedPropertiesType;
167 int m_attachedPropertiesId;
168 int m_parserStatusCast;
169 int m_propertyValueSourceCast;
170 int m_propertyValueInterceptorCast;
171 QObject *(*m_extFunc)(QObject *);
172 const QMetaObject *m_extMetaObject;
174 QDeclarativeCustomParser *m_customParser;
175 mutable volatile bool m_isSetup:1;
176 mutable bool m_haveSuperType : 1;
177 mutable QList<QDeclarativeProxyMetaObject::ProxyData> m_metaObjects;
179 static QHash<const QMetaObject *, int> m_attachedPropertyIds;
182 QHash<const QMetaObject *, int> QDeclarativeTypePrivate::m_attachedPropertyIds;
184 QDeclarativeTypePrivate::QDeclarativeTypePrivate()
185 : m_isInterface(false), m_iid(0), m_typeId(0), m_listId(0), m_revision(0), m_containsRevisionedAttributes(false),
186 m_superType(0), m_allocationSize(0), m_newFunc(0), m_baseMetaObject(0), m_attachedPropertiesFunc(0),
187 m_attachedPropertiesType(0), m_parserStatusCast(-1), m_propertyValueSourceCast(-1),
188 m_propertyValueInterceptorCast(-1), m_extFunc(0), m_extMetaObject(0), m_index(-1), m_customParser(0),
189 m_isSetup(false), m_haveSuperType(false)
194 QDeclarativeType::QDeclarativeType(int index, const QDeclarativePrivate::RegisterInterface &interface)
195 : d(new QDeclarativeTypePrivate)
197 d->m_isInterface = true;
198 d->m_iid = interface.iid;
199 d->m_typeId = interface.typeId;
200 d->m_listId = interface.listId;
204 d->m_version_maj = 0;
205 d->m_version_min = 0;
208 QDeclarativeType::QDeclarativeType(int index, const QDeclarativePrivate::RegisterType &type)
209 : d(new QDeclarativeTypePrivate)
211 QByteArray name = type.uri;
212 if (type.uri) name += '/';
213 name += type.elementName;
215 d->m_module = type.uri;
217 d->m_version_maj = type.versionMajor;
218 d->m_version_min = type.versionMinor;
219 if (type.version >= 1) // revisions added in version 1
220 d->m_revision = type.revision;
221 d->m_typeId = type.typeId;
222 d->m_listId = type.listId;
223 d->m_allocationSize = type.objectSize;
224 d->m_newFunc = type.create;
225 d->m_noCreationReason = type.noCreationReason;
226 d->m_baseMetaObject = type.metaObject;
227 d->m_attachedPropertiesFunc = type.attachedPropertiesFunction;
228 d->m_attachedPropertiesType = type.attachedPropertiesMetaObject;
229 if (d->m_attachedPropertiesType) {
230 QHash<const QMetaObject *, int>::Iterator iter = d->m_attachedPropertyIds.find(d->m_baseMetaObject);
231 if (iter == d->m_attachedPropertyIds.end())
232 iter = d->m_attachedPropertyIds.insert(d->m_baseMetaObject, index);
233 d->m_attachedPropertiesId = *iter;
235 d->m_attachedPropertiesId = -1;
237 d->m_parserStatusCast = type.parserStatusCast;
238 d->m_propertyValueSourceCast = type.valueSourceCast;
239 d->m_propertyValueInterceptorCast = type.valueInterceptorCast;
240 d->m_extFunc = type.extensionObjectCreate;
242 d->m_customParser = type.customParser;
244 if (type.extensionMetaObject)
245 d->m_extMetaObject = type.extensionMetaObject;
248 QDeclarativeType::~QDeclarativeType()
250 delete d->m_customParser;
254 QByteArray QDeclarativeType::module() const
259 int QDeclarativeType::majorVersion() const
261 return d->m_version_maj;
264 int QDeclarativeType::minorVersion() const
266 return d->m_version_min;
269 bool QDeclarativeType::availableInVersion(int vmajor, int vminor) const
271 return vmajor > d->m_version_maj || (vmajor == d->m_version_maj && vminor >= d->m_version_min);
274 bool QDeclarativeType::availableInVersion(const QByteArray &module, int vmajor, int vminor) const
276 return module == d->m_module && (vmajor > d->m_version_maj || (vmajor == d->m_version_maj && vminor >= d->m_version_min));
279 // returns the nearest _registered_ super class
280 QDeclarativeType *QDeclarativeType::superType() const
282 if (!d->m_haveSuperType) {
283 const QMetaObject *mo = d->m_baseMetaObject->superClass();
284 while (mo && !d->m_superType) {
285 d->m_superType = QDeclarativeMetaType::qmlType(mo, d->m_module, d->m_version_maj, d->m_version_min);
286 mo = mo->superClass();
288 d->m_haveSuperType = true;
291 return d->m_superType;
294 static void clone(QMetaObjectBuilder &builder, const QMetaObject *mo,
295 const QMetaObject *ignoreStart, const QMetaObject *ignoreEnd)
298 for (int ii = mo->classInfoOffset(); ii < mo->classInfoCount(); ++ii) {
299 QMetaClassInfo info = mo->classInfo(ii);
301 int otherIndex = ignoreEnd->indexOfClassInfo(info.name());
302 if (otherIndex >= ignoreStart->classInfoOffset() + ignoreStart->classInfoCount()) {
305 builder.addClassInfo(info.name(), info.value());
310 for (int ii = mo->propertyOffset(); ii < mo->propertyCount(); ++ii) {
311 QMetaProperty property = mo->property(ii);
313 int otherIndex = ignoreEnd->indexOfProperty(property.name());
314 if (otherIndex >= ignoreStart->propertyOffset() + ignoreStart->propertyCount()) {
315 builder.addProperty(QByteArray("__qml_ignore__") + property.name(), QByteArray("void"));
318 builder.addProperty(property);
323 for (int ii = mo->methodOffset(); ii < mo->methodCount(); ++ii) {
324 QMetaMethod method = mo->method(ii);
326 // More complex - need to search name
327 QByteArray name = method.signature();
328 int parenIdx = name.indexOf('(');
329 if (parenIdx != -1) name = name.left(parenIdx);
334 for (int ii = ignoreStart->methodOffset() + ignoreStart->methodCount();
335 !found && ii < ignoreEnd->methodOffset() + ignoreEnd->methodCount();
338 QMetaMethod other = ignoreEnd->method(ii);
339 QByteArray othername = other.signature();
340 int parenIdx = othername.indexOf('(');
341 if (parenIdx != -1) othername = othername.left(parenIdx);
343 found = name == othername;
346 QMetaMethodBuilder m = builder.addMethod(method);
348 m.setAccess(QMetaMethod::Private);
352 for (int ii = mo->enumeratorOffset(); ii < mo->enumeratorCount(); ++ii) {
353 QMetaEnum enumerator = mo->enumerator(ii);
355 int otherIndex = ignoreEnd->indexOfEnumerator(enumerator.name());
356 if (otherIndex >= ignoreStart->enumeratorOffset() + ignoreStart->enumeratorCount()) {
359 builder.addEnumerator(enumerator);
364 void QDeclarativeTypePrivate::init() const
366 if (m_isSetup) return;
368 QWriteLocker lock(metaTypeDataLock());
372 // Setup extended meta object
373 // XXX - very inefficient
374 const QMetaObject *mo = m_baseMetaObject;
376 QMetaObject *mmo = new QMetaObject;
377 *mmo = *m_extMetaObject;
378 mmo->d.superdata = mo;
379 QDeclarativeProxyMetaObject::ProxyData data = { mmo, m_extFunc, 0, 0 };
380 m_metaObjects << data;
383 mo = mo->d.superdata;
385 QDeclarativeType *t = metaTypeData()->metaObjectToType.value(mo);
387 if (t->d->m_extFunc) {
388 QMetaObjectBuilder builder;
389 clone(builder, t->d->m_extMetaObject, t->d->m_baseMetaObject, m_baseMetaObject);
390 QMetaObject *mmo = builder.toMetaObject();
391 mmo->d.superdata = m_baseMetaObject;
392 if (!m_metaObjects.isEmpty())
393 m_metaObjects.last().metaObject->d.superdata = mmo;
394 QDeclarativeProxyMetaObject::ProxyData data = { mmo, t->d->m_extFunc, 0, 0 };
395 m_metaObjects << data;
398 mo = mo->d.superdata;
401 for (int ii = 0; ii < m_metaObjects.count(); ++ii) {
402 m_metaObjects[ii].propertyOffset =
403 m_metaObjects.at(ii).metaObject->propertyOffset();
404 m_metaObjects[ii].methodOffset =
405 m_metaObjects.at(ii).metaObject->methodOffset();
408 // Check for revisioned details
410 const QMetaObject *mo = 0;
411 if (m_metaObjects.isEmpty())
412 mo = m_baseMetaObject;
414 mo = m_metaObjects.first().metaObject;
416 for (int ii = 0; !m_containsRevisionedAttributes && ii < mo->propertyCount(); ++ii) {
417 if (mo->property(ii).revision() != 0)
418 m_containsRevisionedAttributes = true;
421 for (int ii = 0; !m_containsRevisionedAttributes && ii < mo->methodCount(); ++ii) {
422 if (mo->method(ii).revision() != 0)
423 m_containsRevisionedAttributes = true;
431 QByteArray QDeclarativeType::typeName() const
433 if (d->m_baseMetaObject)
434 return d->m_baseMetaObject->className();
439 QByteArray QDeclarativeType::qmlTypeName() const
444 QObject *QDeclarativeType::create() const
448 QObject *rv = (QObject *)operator new(d->m_allocationSize);
451 if (rv && !d->m_metaObjects.isEmpty())
452 (void *)new QDeclarativeProxyMetaObject(rv, &d->m_metaObjects);
457 void QDeclarativeType::create(QObject **out, void **memory, size_t additionalMemory) const
461 QObject *rv = (QObject *)operator new(d->m_allocationSize + additionalMemory);
464 if (rv && !d->m_metaObjects.isEmpty())
465 (void *)new QDeclarativeProxyMetaObject(rv, &d->m_metaObjects);
468 *memory = ((char *)rv) + d->m_allocationSize;
471 QDeclarativeCustomParser *QDeclarativeType::customParser() const
473 return d->m_customParser;
476 QDeclarativeType::CreateFunc QDeclarativeType::createFunction() const
481 QString QDeclarativeType::noCreationReason() const
483 return d->m_noCreationReason;
486 int QDeclarativeType::createSize() const
488 return d->m_allocationSize;
491 bool QDeclarativeType::isCreatable() const
493 return d->m_newFunc != 0;
496 bool QDeclarativeType::isExtendedType() const
500 return !d->m_metaObjects.isEmpty();
503 bool QDeclarativeType::isInterface() const
505 return d->m_isInterface;
508 int QDeclarativeType::typeId() const
513 int QDeclarativeType::qListTypeId() const
518 const QMetaObject *QDeclarativeType::metaObject() const
522 if (d->m_metaObjects.isEmpty())
523 return d->m_baseMetaObject;
525 return d->m_metaObjects.first().metaObject;
529 const QMetaObject *QDeclarativeType::baseMetaObject() const
531 return d->m_baseMetaObject;
534 bool QDeclarativeType::containsRevisionedAttributes() const
538 return d->m_containsRevisionedAttributes;
541 int QDeclarativeType::metaObjectRevision() const
543 return d->m_revision;
546 QDeclarativeAttachedPropertiesFunc QDeclarativeType::attachedPropertiesFunction() const
548 return d->m_attachedPropertiesFunc;
551 const QMetaObject *QDeclarativeType::attachedPropertiesType() const
553 return d->m_attachedPropertiesType;
557 This is the id passed to qmlAttachedPropertiesById(). This is different from the index
558 for the case that a single class is registered under two or more names (eg. Item in
559 Qt 4.7 and QtQuick 1.0).
561 int QDeclarativeType::attachedPropertiesId() const
563 return d->m_attachedPropertiesId;
566 int QDeclarativeType::parserStatusCast() const
568 return d->m_parserStatusCast;
571 int QDeclarativeType::propertyValueSourceCast() const
573 return d->m_propertyValueSourceCast;
576 int QDeclarativeType::propertyValueInterceptorCast() const
578 return d->m_propertyValueInterceptorCast;
581 const char *QDeclarativeType::interfaceIId() const
586 int QDeclarativeType::index() const
591 int registerAutoParentFunction(QDeclarativePrivate::RegisterAutoParent &autoparent)
593 QWriteLocker lock(metaTypeDataLock());
594 QDeclarativeMetaTypeData *data = metaTypeData();
596 data->parentFunctions.append(autoparent.function);
598 return data->parentFunctions.count() - 1;
601 int registerInterface(const QDeclarativePrivate::RegisterInterface &interface)
603 if (interface.version > 0)
604 qFatal("qmlRegisterType(): Cannot mix incompatible QML versions.");
606 QWriteLocker lock(metaTypeDataLock());
607 QDeclarativeMetaTypeData *data = metaTypeData();
609 int index = data->types.count();
611 QDeclarativeType *type = new QDeclarativeType(index, interface);
613 data->types.append(type);
614 data->idToType.insert(type->typeId(), type);
615 data->idToType.insert(type->qListTypeId(), type);
616 // XXX No insertMulti, so no multi-version interfaces?
617 if (!type->qmlTypeName().isEmpty())
618 data->nameToType.insert(type->qmlTypeName(), type);
620 if (data->interfaces.size() <= interface.typeId)
621 data->interfaces.resize(interface.typeId + 16);
622 if (data->lists.size() <= interface.listId)
623 data->lists.resize(interface.listId + 16);
624 data->interfaces.setBit(interface.typeId, true);
625 data->lists.setBit(interface.listId, true);
630 int registerType(const QDeclarativePrivate::RegisterType &type)
632 if (type.elementName) {
633 for (int ii = 0; type.elementName[ii]; ++ii) {
634 if (!isalnum(type.elementName[ii])) {
635 qWarning("qmlRegisterType(): Invalid QML element name \"%s\"", type.elementName);
641 QWriteLocker lock(metaTypeDataLock());
642 QDeclarativeMetaTypeData *data = metaTypeData();
643 int index = data->types.count();
645 QDeclarativeType *dtype = new QDeclarativeType(index, type);
647 data->types.append(dtype);
648 data->idToType.insert(dtype->typeId(), dtype);
649 if (dtype->qListTypeId()) data->idToType.insert(dtype->qListTypeId(), dtype);
651 if (!dtype->qmlTypeName().isEmpty())
652 data->nameToType.insertMulti(dtype->qmlTypeName(), dtype);
654 data->metaObjectToType.insertMulti(dtype->baseMetaObject(), dtype);
656 if (data->objects.size() <= type.typeId)
657 data->objects.resize(type.typeId + 16);
658 if (data->lists.size() <= type.listId)
659 data->lists.resize(type.listId + 16);
660 data->objects.setBit(type.typeId, true);
661 if (type.listId) data->lists.setBit(type.listId, true);
664 QByteArray mod(type.uri);
665 QDeclarativeMetaTypeData::ModuleInfoHash::Iterator it = data->modules.find(mod);
666 if (it == data->modules.end()) {
668 data->modules.insert(mod, QDeclarativeMetaTypeData::ModuleInfo(type.versionMajor,type.versionMinor));
669 } else if ((*it).vmajor_max < type.versionMajor || ((*it).vmajor_max == type.versionMajor && (*it).vminor_max < type.versionMinor)) {
671 data->modules.insert(mod, QDeclarativeMetaTypeData::ModuleInfo((*it).vmajor_min, (*it).vminor_min, type.versionMajor, type.versionMinor));
672 } else if ((*it).vmajor_min > type.versionMajor || ((*it).vmajor_min == type.versionMajor && (*it).vminor_min > type.versionMinor)) {
674 data->modules.insert(mod, QDeclarativeMetaTypeData::ModuleInfo(type.versionMajor, type.versionMinor, (*it).vmajor_min, (*it).vminor_min));
681 int registerModuleApi(const QDeclarativePrivate::RegisterModuleApi &api)
683 QWriteLocker lock(metaTypeDataLock());
685 QDeclarativeMetaTypeData *data = metaTypeData();
686 QByteArray uri(api.uri);
687 QDeclarativeMetaType::ModuleApi import;
688 import.major = api.versionMajor;
689 import.minor = api.versionMinor;
690 import.script = api.scriptApi;
691 import.qobject = api.qobjectApi;
693 int index = data->moduleApiCount++;
695 QDeclarativeMetaTypeData::ModuleApis::Iterator iter = data->moduleApis.find(uri);
696 if (iter == data->moduleApis.end()) {
697 QDeclarativeMetaTypeData::ModuleApiList apis;
698 apis.moduleApis << import;
699 data->moduleApis.insert(uri, apis);
701 iter->moduleApis << import;
702 iter->sorted = false;
710 This method is "over generalized" to allow us to (potentially) register more types of things in
711 the future without adding exported symbols.
713 int QDeclarativePrivate::qmlregister(RegistrationType type, void *data)
715 if (type == TypeRegistration) {
716 return registerType(*reinterpret_cast<RegisterType *>(data));
717 } else if (type == InterfaceRegistration) {
718 return registerInterface(*reinterpret_cast<RegisterInterface *>(data));
719 } else if (type == AutoParentRegistration) {
720 return registerAutoParentFunction(*reinterpret_cast<RegisterAutoParent *>(data));
721 } else if (type == ModuleApiRegistration) {
722 return registerModuleApi(*reinterpret_cast<RegisterModuleApi *>(data));
728 Returns true if any type or API has been registered for the given \a module with at least
729 versionMajor.versionMinor, or if types have been registered for \a module with at most
730 versionMajor.versionMinor.
732 So if only 4.7 and 4.9 have been registered, 4.7,4.8, and 4.9 are valid, but not 4.6 nor 4.10.
734 Passing -1 for both \a versionMajor \a versionMinor will return true if any version is installed.
736 bool QDeclarativeMetaType::isModule(const QByteArray &module, int versionMajor, int versionMinor)
738 QDeclarativeMetaTypeData *data = metaTypeData();
740 // first, check Types
741 QDeclarativeMetaTypeData::ModuleInfoHash::Iterator it = data->modules.find(module);
742 if (it != data->modules.end()
743 && ((versionMajor<0 && versionMinor<0) ||
744 (((*it).vmajor_max > versionMajor ||
745 ((*it).vmajor_max == versionMajor && (*it).vminor_max >= versionMinor))
746 && ((*it).vmajor_min < versionMajor ||
747 ((*it).vmajor_min == versionMajor && (*it).vminor_min <= versionMinor))))) {
751 // then, check ModuleApis
752 foreach (const QDeclarativeMetaType::ModuleApi &mApi, data->moduleApis.value(module).moduleApis) {
753 if ((versionMajor<0 && versionMinor<0)
754 || (mApi.major == versionMajor && mApi.minor == versionMinor)) {
762 QList<QDeclarativePrivate::AutoParentFunction> QDeclarativeMetaType::parentFunctions()
764 QReadLocker lock(metaTypeDataLock());
765 QDeclarativeMetaTypeData *data = metaTypeData();
766 return data->parentFunctions;
769 static bool operator<(const QDeclarativeMetaType::ModuleApi &lhs, const QDeclarativeMetaType::ModuleApi &rhs)
771 return lhs.major < rhs.major || (lhs.major == rhs.major && lhs.minor < rhs.minor);
774 QDeclarativeMetaType::ModuleApi
775 QDeclarativeMetaType::moduleApi(const QByteArray &uri, int versionMajor, int versionMinor)
777 QReadLocker lock(metaTypeDataLock());
778 QDeclarativeMetaTypeData *data = metaTypeData();
780 QDeclarativeMetaTypeData::ModuleApis::Iterator iter = data->moduleApis.find(uri);
781 if (iter == data->moduleApis.end())
784 if (iter->sorted == false) {
785 qSort(iter->moduleApis.begin(), iter->moduleApis.end());
789 for (int ii = iter->moduleApis.count() - 1; ii >= 0; --ii) {
790 const ModuleApi &import = iter->moduleApis.at(ii);
791 if (import.major == versionMajor && import.minor <= versionMinor)
798 QObject *QDeclarativeMetaType::toQObject(const QVariant &v, bool *ok)
800 if (!isQObject(v.userType())) {
807 return *(QObject **)v.constData();
810 bool QDeclarativeMetaType::isQObject(int userType)
812 if (userType == QMetaType::QObjectStar)
815 QReadLocker lock(metaTypeDataLock());
816 QDeclarativeMetaTypeData *data = metaTypeData();
817 return userType >= 0 && userType < data->objects.size() && data->objects.testBit(userType);
821 Returns the item type for a list of type \a id.
823 int QDeclarativeMetaType::listType(int id)
825 QReadLocker lock(metaTypeDataLock());
826 QDeclarativeMetaTypeData *data = metaTypeData();
827 QDeclarativeType *type = data->idToType.value(id);
828 if (type && type->qListTypeId() == id)
829 return type->typeId();
834 int QDeclarativeMetaType::attachedPropertiesFuncId(const QMetaObject *mo)
836 QReadLocker lock(metaTypeDataLock());
837 QDeclarativeMetaTypeData *data = metaTypeData();
839 QDeclarativeType *type = data->metaObjectToType.value(mo);
840 if (type && type->attachedPropertiesFunction())
841 return type->attachedPropertiesId();
846 QDeclarativeAttachedPropertiesFunc QDeclarativeMetaType::attachedPropertiesFuncById(int id)
850 QReadLocker lock(metaTypeDataLock());
851 QDeclarativeMetaTypeData *data = metaTypeData();
852 return data->types.at(id)->attachedPropertiesFunction();
855 QMetaProperty QDeclarativeMetaType::defaultProperty(const QMetaObject *metaObject)
857 int idx = metaObject->indexOfClassInfo("DefaultProperty");
859 return QMetaProperty();
861 QMetaClassInfo info = metaObject->classInfo(idx);
863 return QMetaProperty();
865 idx = metaObject->indexOfProperty(info.value());
867 return QMetaProperty();
869 return metaObject->property(idx);
872 QMetaProperty QDeclarativeMetaType::defaultProperty(QObject *obj)
875 return QMetaProperty();
877 const QMetaObject *metaObject = obj->metaObject();
878 return defaultProperty(metaObject);
881 QMetaMethod QDeclarativeMetaType::defaultMethod(const QMetaObject *metaObject)
883 int idx = metaObject->indexOfClassInfo("DefaultMethod");
885 return QMetaMethod();
887 QMetaClassInfo info = metaObject->classInfo(idx);
889 return QMetaMethod();
891 idx = metaObject->indexOfMethod(info.value());
893 return QMetaMethod();
895 return metaObject->method(idx);
898 QMetaMethod QDeclarativeMetaType::defaultMethod(QObject *obj)
901 return QMetaMethod();
903 const QMetaObject *metaObject = obj->metaObject();
904 return defaultMethod(metaObject);
907 QDeclarativeMetaType::TypeCategory QDeclarativeMetaType::typeCategory(int userType)
911 if (userType == QMetaType::QObjectStar)
914 QReadLocker lock(metaTypeDataLock());
915 QDeclarativeMetaTypeData *data = metaTypeData();
916 if (userType < data->objects.size() && data->objects.testBit(userType))
918 else if (userType < data->lists.size() && data->lists.testBit(userType))
924 bool QDeclarativeMetaType::isInterface(int userType)
926 QReadLocker lock(metaTypeDataLock());
927 QDeclarativeMetaTypeData *data = metaTypeData();
928 return userType >= 0 && userType < data->interfaces.size() && data->interfaces.testBit(userType);
931 const char *QDeclarativeMetaType::interfaceIId(int userType)
933 QReadLocker lock(metaTypeDataLock());
934 QDeclarativeMetaTypeData *data = metaTypeData();
935 QDeclarativeType *type = data->idToType.value(userType);
937 if (type && type->isInterface() && type->typeId() == userType)
938 return type->interfaceIId();
943 bool QDeclarativeMetaType::isList(int userType)
945 QReadLocker lock(metaTypeDataLock());
946 QDeclarativeMetaTypeData *data = metaTypeData();
947 return userType >= 0 && userType < data->lists.size() && data->lists.testBit(userType);
951 A custom string convertor allows you to specify a function pointer that
952 returns a variant of \a type. For example, if you have written your own icon
953 class that you want to support as an object property assignable in QML:
956 int type = qRegisterMetaType<SuperIcon>("SuperIcon");
957 QML::addCustomStringConvertor(type, &SuperIcon::pixmapFromString);
960 The function pointer must be of the form:
962 QVariant (*StringConverter)(const QString &);
965 void QDeclarativeMetaType::registerCustomStringConverter(int type, StringConverter converter)
967 QWriteLocker lock(metaTypeDataLock());
969 QDeclarativeMetaTypeData *data = metaTypeData();
970 if (data->stringConverters.contains(type))
972 data->stringConverters.insert(type, converter);
976 Return the custom string converter for \a type, previously installed through
977 registerCustomStringConverter()
979 QDeclarativeMetaType::StringConverter QDeclarativeMetaType::customStringConverter(int type)
981 QReadLocker lock(metaTypeDataLock());
983 QDeclarativeMetaTypeData *data = metaTypeData();
984 return data->stringConverters.value(type);
988 Returns the type (if any) of URI-qualified named \a name in version specified
989 by \a version_major and \a version_minor.
991 QDeclarativeType *QDeclarativeMetaType::qmlType(const QByteArray &name, int version_major, int version_minor)
993 QReadLocker lock(metaTypeDataLock());
994 QDeclarativeMetaTypeData *data = metaTypeData();
996 QList<QDeclarativeType*> types = data->nameToType.values(name);
997 foreach (QDeclarativeType *t, types) {
998 // XXX version_major<0 just a kludge for QDeclarativePropertyPrivate::initProperty
999 if (version_major<0 || t->availableInVersion(version_major,version_minor))
1006 Returns the type (if any) that corresponds to the \a metaObject. Returns null if no
1009 QDeclarativeType *QDeclarativeMetaType::qmlType(const QMetaObject *metaObject)
1011 QReadLocker lock(metaTypeDataLock());
1012 QDeclarativeMetaTypeData *data = metaTypeData();
1014 return data->metaObjectToType.value(metaObject);
1018 Returns the type (if any) that corresponds to the \a metaObject in version specified
1019 by \a version_major and \a version_minor in module specified by \a uri. Returns null if no
1022 QDeclarativeType *QDeclarativeMetaType::qmlType(const QMetaObject *metaObject, const QByteArray &module, int version_major, int version_minor)
1024 QReadLocker lock(metaTypeDataLock());
1025 QDeclarativeMetaTypeData *data = metaTypeData();
1027 QDeclarativeMetaTypeData::MetaObjects::const_iterator it = data->metaObjectToType.find(metaObject);
1028 while (it != data->metaObjectToType.end() && it.key() == metaObject) {
1029 QDeclarativeType *t = *it;
1030 if (version_major < 0 || t->availableInVersion(module, version_major,version_minor))
1039 Returns the type (if any) that corresponds to the QVariant::Type \a userType.
1040 Returns null if no type is registered.
1042 QDeclarativeType *QDeclarativeMetaType::qmlType(int userType)
1044 QReadLocker lock(metaTypeDataLock());
1045 QDeclarativeMetaTypeData *data = metaTypeData();
1047 QDeclarativeType *type = data->idToType.value(userType);
1048 if (type && type->typeId() == userType)
1055 Returns the list of registered QML type names.
1057 QList<QByteArray> QDeclarativeMetaType::qmlTypeNames()
1059 QReadLocker lock(metaTypeDataLock());
1060 QDeclarativeMetaTypeData *data = metaTypeData();
1062 return data->nameToType.keys();
1066 Returns the list of registered QML types.
1068 QList<QDeclarativeType*> QDeclarativeMetaType::qmlTypes()
1070 QReadLocker lock(metaTypeDataLock());
1071 QDeclarativeMetaTypeData *data = metaTypeData();
1073 return data->nameToType.values();
1078 #include <QtGui/qfont.h>
1079 #include <QtGui/qpixmap.h>
1080 #include <QtGui/qbrush.h>
1081 #include <QtGui/qcolor.h>
1082 #include <QtGui/qpalette.h>
1083 #include <QtGui/qicon.h>
1084 #include <QtGui/qimage.h>
1085 #include <QtGui/qpolygon.h>
1086 #include <QtGui/qregion.h>
1087 #include <QtGui/qbitmap.h>
1088 #include <QtGui/qcursor.h>
1089 #include <QtGui/qsizepolicy.h>
1090 #include <QtGui/qkeysequence.h>
1091 #include <QtGui/qpen.h>
1093 //#include <QtGui/qtextlength.h>
1094 #include <QtGui/qtextformat.h>
1095 #include <QtGui/qmatrix.h>
1096 #include <QtGui/qtransform.h>
1097 #include <QtGui/qmatrix4x4.h>
1098 #include <QtGui/qvector2d.h>
1099 #include <QtGui/qvector3d.h>
1100 #include <QtGui/qvector4d.h>
1101 #include <QtGui/qquaternion.h>
1103 Q_DECLARE_METATYPE(QScriptValue);
1107 bool QDeclarativeMetaType::canCopy(int type)
1110 case QMetaType::VoidStar:
1111 case QMetaType::QObjectStar:
1112 case QMetaType::QWidgetStar:
1113 case QMetaType::Long:
1114 case QMetaType::Int:
1115 case QMetaType::Short:
1116 case QMetaType::Char:
1117 case QMetaType::ULong:
1118 case QMetaType::UInt:
1119 case QMetaType::LongLong:
1120 case QMetaType::ULongLong:
1121 case QMetaType::UShort:
1122 case QMetaType::UChar:
1123 case QMetaType::Bool:
1124 case QMetaType::Float:
1125 case QMetaType::Double:
1126 case QMetaType::QChar:
1127 case QMetaType::QVariantMap:
1128 case QMetaType::QVariantHash:
1129 case QMetaType::QVariantList:
1130 case QMetaType::QByteArray:
1131 case QMetaType::QString:
1132 case QMetaType::QStringList:
1133 case QMetaType::QBitArray:
1134 case QMetaType::QDate:
1135 case QMetaType::QTime:
1136 case QMetaType::QDateTime:
1137 case QMetaType::QUrl:
1138 case QMetaType::QLocale:
1139 case QMetaType::QRect:
1140 case QMetaType::QRectF:
1141 case QMetaType::QSize:
1142 case QMetaType::QSizeF:
1143 case QMetaType::QLine:
1144 case QMetaType::QLineF:
1145 case QMetaType::QPoint:
1146 case QMetaType::QPointF:
1147 case QMetaType::QVector3D:
1148 #ifndef QT_NO_REGEXP
1149 case QMetaType::QRegExp:
1151 case QMetaType::Void:
1153 case QMetaType::QColorGroup:
1155 case QMetaType::QFont:
1156 case QMetaType::QPixmap:
1157 case QMetaType::QBrush:
1158 case QMetaType::QColor:
1159 case QMetaType::QPalette:
1160 case QMetaType::QIcon:
1161 case QMetaType::QImage:
1162 case QMetaType::QPolygon:
1163 case QMetaType::QRegion:
1164 case QMetaType::QBitmap:
1165 #ifndef QT_NO_CURSOR
1166 case QMetaType::QCursor:
1168 case QMetaType::QSizePolicy:
1169 case QMetaType::QKeySequence:
1170 case QMetaType::QPen:
1171 case QMetaType::QTextLength:
1172 case QMetaType::QTextFormat:
1173 case QMetaType::QMatrix:
1174 case QMetaType::QTransform:
1175 case QMetaType::QMatrix4x4:
1176 case QMetaType::QVector2D:
1177 case QMetaType::QVector4D:
1178 case QMetaType::QQuaternion:
1182 if (type == qMetaTypeId<QVariant>() ||
1183 type == qMetaTypeId<QScriptValue>() ||
1184 typeCategory(type) != Unknown) {
1194 Copies \a copy into \a data, assuming they both are of type \a type. If
1195 \a copy is zero, a default type is copied. Returns true if the copy was
1196 successful and false if not.
1198 \note This should move into QMetaType once complete
1201 bool QDeclarativeMetaType::copy(int type, void *data, const void *copy)
1205 case QMetaType::VoidStar:
1206 case QMetaType::QObjectStar:
1207 case QMetaType::QWidgetStar:
1208 *static_cast<void **>(data) = *static_cast<void* const *>(copy);
1210 case QMetaType::Long:
1211 *static_cast<long *>(data) = *static_cast<const long*>(copy);
1213 case QMetaType::Int:
1214 *static_cast<int *>(data) = *static_cast<const int*>(copy);
1216 case QMetaType::Short:
1217 *static_cast<short *>(data) = *static_cast<const short*>(copy);
1219 case QMetaType::Char:
1220 *static_cast<char *>(data) = *static_cast<const char*>(copy);
1222 case QMetaType::ULong:
1223 *static_cast<ulong *>(data) = *static_cast<const ulong*>(copy);
1225 case QMetaType::UInt:
1226 *static_cast<uint *>(data) = *static_cast<const uint*>(copy);
1228 case QMetaType::LongLong:
1229 *static_cast<qlonglong *>(data) = *static_cast<const qlonglong*>(copy);
1231 case QMetaType::ULongLong:
1232 *static_cast<qulonglong *>(data) = *static_cast<const qulonglong*>(copy);
1234 case QMetaType::UShort:
1235 *static_cast<ushort *>(data) = *static_cast<const ushort*>(copy);
1237 case QMetaType::UChar:
1238 *static_cast<uchar *>(data) = *static_cast<const uchar*>(copy);
1240 case QMetaType::Bool:
1241 *static_cast<bool *>(data) = *static_cast<const bool*>(copy);
1243 case QMetaType::Float:
1244 *static_cast<float *>(data) = *static_cast<const float*>(copy);
1246 case QMetaType::Double:
1247 *static_cast<double *>(data) = *static_cast<const double*>(copy);
1249 case QMetaType::QChar:
1250 *static_cast<NS(QChar) *>(data) = *static_cast<const NS(QChar)*>(copy);
1252 case QMetaType::QVariantMap:
1253 *static_cast<NS(QVariantMap) *>(data) = *static_cast<const NS(QVariantMap)*>(copy);
1255 case QMetaType::QVariantHash:
1256 *static_cast<NS(QVariantHash) *>(data) = *static_cast<const NS(QVariantHash)*>(copy);
1258 case QMetaType::QVariantList:
1259 *static_cast<NS(QVariantList) *>(data) = *static_cast<const NS(QVariantList)*>(copy);
1261 case QMetaType::QByteArray:
1262 *static_cast<NS(QByteArray) *>(data) = *static_cast<const NS(QByteArray)*>(copy);
1264 case QMetaType::QString:
1265 *static_cast<NS(QString) *>(data) = *static_cast<const NS(QString)*>(copy);
1267 case QMetaType::QStringList:
1268 *static_cast<NS(QStringList) *>(data) = *static_cast<const NS(QStringList)*>(copy);
1270 case QMetaType::QBitArray:
1271 *static_cast<NS(QBitArray) *>(data) = *static_cast<const NS(QBitArray)*>(copy);
1273 case QMetaType::QDate:
1274 *static_cast<NS(QDate) *>(data) = *static_cast<const NS(QDate)*>(copy);
1276 case QMetaType::QTime:
1277 *static_cast<NS(QTime) *>(data) = *static_cast<const NS(QTime)*>(copy);
1279 case QMetaType::QDateTime:
1280 *static_cast<NS(QDateTime) *>(data) = *static_cast<const NS(QDateTime)*>(copy);
1282 case QMetaType::QUrl:
1283 *static_cast<NS(QUrl) *>(data) = *static_cast<const NS(QUrl)*>(copy);
1285 case QMetaType::QLocale:
1286 *static_cast<NS(QLocale) *>(data) = *static_cast<const NS(QLocale)*>(copy);
1288 case QMetaType::QRect:
1289 *static_cast<NS(QRect) *>(data) = *static_cast<const NS(QRect)*>(copy);
1291 case QMetaType::QRectF:
1292 *static_cast<NS(QRectF) *>(data) = *static_cast<const NS(QRectF)*>(copy);
1294 case QMetaType::QSize:
1295 *static_cast<NS(QSize) *>(data) = *static_cast<const NS(QSize)*>(copy);
1297 case QMetaType::QSizeF:
1298 *static_cast<NS(QSizeF) *>(data) = *static_cast<const NS(QSizeF)*>(copy);
1300 case QMetaType::QLine:
1301 *static_cast<NS(QLine) *>(data) = *static_cast<const NS(QLine)*>(copy);
1303 case QMetaType::QLineF:
1304 *static_cast<NS(QLineF) *>(data) = *static_cast<const NS(QLineF)*>(copy);
1306 case QMetaType::QPoint:
1307 *static_cast<NS(QPoint) *>(data) = *static_cast<const NS(QPoint)*>(copy);
1309 case QMetaType::QPointF:
1310 *static_cast<NS(QPointF) *>(data) = *static_cast<const NS(QPointF)*>(copy);
1312 case QMetaType::QVector3D:
1313 *static_cast<NS(QVector3D) *>(data) = *static_cast<const NS(QVector3D)*>(copy);
1315 #ifndef QT_NO_REGEXP
1316 case QMetaType::QRegExp:
1317 *static_cast<NS(QRegExp) *>(data) = *static_cast<const NS(QRegExp)*>(copy);
1320 case QMetaType::Void:
1325 case QMetaType::QColorGroup:
1326 *static_cast<NS(QColorGroup) *>(data) = *static_cast<const NS(QColorGroup)*>(copy);
1330 case QMetaType::QFont:
1331 *static_cast<NS(QFont) *>(data) = *static_cast<const NS(QFont)*>(copy);
1333 case QMetaType::QPixmap:
1334 *static_cast<NS(QPixmap) *>(data) = *static_cast<const NS(QPixmap)*>(copy);
1336 case QMetaType::QBrush:
1337 *static_cast<NS(QBrush) *>(data) = *static_cast<const NS(QBrush)*>(copy);
1339 case QMetaType::QColor:
1340 *static_cast<NS(QColor) *>(data) = *static_cast<const NS(QColor)*>(copy);
1342 case QMetaType::QPalette:
1343 *static_cast<NS(QPalette) *>(data) = *static_cast<const NS(QPalette)*>(copy);
1345 case QMetaType::QIcon:
1346 *static_cast<NS(QIcon) *>(data) = *static_cast<const NS(QIcon)*>(copy);
1348 case QMetaType::QImage:
1349 *static_cast<NS(QImage) *>(data) = *static_cast<const NS(QImage)*>(copy);
1351 case QMetaType::QPolygon:
1352 *static_cast<NS(QPolygon) *>(data) = *static_cast<const NS(QPolygon)*>(copy);
1354 case QMetaType::QRegion:
1355 *static_cast<NS(QRegion) *>(data) = *static_cast<const NS(QRegion)*>(copy);
1357 case QMetaType::QBitmap:
1358 *static_cast<NS(QBitmap) *>(data) = *static_cast<const NS(QBitmap)*>(copy);
1360 #ifndef QT_NO_CURSOR
1361 case QMetaType::QCursor:
1362 *static_cast<NS(QCursor) *>(data) = *static_cast<const NS(QCursor)*>(copy);
1365 case QMetaType::QSizePolicy:
1366 *static_cast<NS(QSizePolicy) *>(data) = *static_cast<const NS(QSizePolicy)*>(copy);
1368 case QMetaType::QKeySequence:
1369 *static_cast<NS(QKeySequence) *>(data) = *static_cast<const NS(QKeySequence)*>(copy);
1371 case QMetaType::QPen:
1372 *static_cast<NS(QPen) *>(data) = *static_cast<const NS(QPen)*>(copy);
1374 case QMetaType::QTextLength:
1375 *static_cast<NS(QTextLength) *>(data) = *static_cast<const NS(QTextLength)*>(copy);
1377 case QMetaType::QTextFormat:
1378 *static_cast<NS(QTextFormat) *>(data) = *static_cast<const NS(QTextFormat)*>(copy);
1380 case QMetaType::QMatrix:
1381 *static_cast<NS(QMatrix) *>(data) = *static_cast<const NS(QMatrix)*>(copy);
1383 case QMetaType::QTransform:
1384 *static_cast<NS(QTransform) *>(data) = *static_cast<const NS(QTransform)*>(copy);
1386 case QMetaType::QMatrix4x4:
1387 *static_cast<NS(QMatrix4x4) *>(data) = *static_cast<const NS(QMatrix4x4)*>(copy);
1389 case QMetaType::QVector2D:
1390 *static_cast<NS(QVector2D) *>(data) = *static_cast<const NS(QVector2D)*>(copy);
1392 case QMetaType::QVector4D:
1393 *static_cast<NS(QVector4D) *>(data) = *static_cast<const NS(QVector4D)*>(copy);
1395 case QMetaType::QQuaternion:
1396 *static_cast<NS(QQuaternion) *>(data) = *static_cast<const NS(QQuaternion)*>(copy);
1400 if (type == qMetaTypeId<QVariant>()) {
1401 *static_cast<NS(QVariant) *>(data) = *static_cast<const NS(QVariant)*>(copy);
1403 } else if (type == qMetaTypeId<QScriptValue>()) {
1404 *static_cast<NS(QScriptValue) *>(data) = *static_cast<const NS(QScriptValue)*>(copy);
1406 } else if (typeCategory(type) != Unknown) {
1407 *static_cast<void **>(data) = *static_cast<void* const *>(copy);
1414 case QMetaType::VoidStar:
1415 case QMetaType::QObjectStar:
1416 case QMetaType::QWidgetStar:
1417 *static_cast<void **>(data) = 0;
1419 case QMetaType::Long:
1420 *static_cast<long *>(data) = long(0);
1422 case QMetaType::Int:
1423 *static_cast<int *>(data) = int(0);
1425 case QMetaType::Short:
1426 *static_cast<short *>(data) = short(0);
1428 case QMetaType::Char:
1429 *static_cast<char *>(data) = char(0);
1431 case QMetaType::ULong:
1432 *static_cast<ulong *>(data) = ulong(0);
1434 case QMetaType::UInt:
1435 *static_cast<uint *>(data) = uint(0);
1437 case QMetaType::LongLong:
1438 *static_cast<qlonglong *>(data) = qlonglong(0);
1440 case QMetaType::ULongLong:
1441 *static_cast<qulonglong *>(data) = qulonglong(0);
1443 case QMetaType::UShort:
1444 *static_cast<ushort *>(data) = ushort(0);
1446 case QMetaType::UChar:
1447 *static_cast<uchar *>(data) = uchar(0);
1449 case QMetaType::Bool:
1450 *static_cast<bool *>(data) = bool(false);
1452 case QMetaType::Float:
1453 *static_cast<float *>(data) = float(0);
1455 case QMetaType::Double:
1456 *static_cast<double *>(data) = double(0);
1458 case QMetaType::QChar:
1459 *static_cast<NS(QChar) *>(data) = NS(QChar)();
1461 case QMetaType::QVariantMap:
1462 *static_cast<NS(QVariantMap) *>(data) = NS(QVariantMap)();
1464 case QMetaType::QVariantHash:
1465 *static_cast<NS(QVariantHash) *>(data) = NS(QVariantHash)();
1467 case QMetaType::QVariantList:
1468 *static_cast<NS(QVariantList) *>(data) = NS(QVariantList)();
1470 case QMetaType::QByteArray:
1471 *static_cast<NS(QByteArray) *>(data) = NS(QByteArray)();
1473 case QMetaType::QString:
1474 *static_cast<NS(QString) *>(data) = NS(QString)();
1476 case QMetaType::QStringList:
1477 *static_cast<NS(QStringList) *>(data) = NS(QStringList)();
1479 case QMetaType::QBitArray:
1480 *static_cast<NS(QBitArray) *>(data) = NS(QBitArray)();
1482 case QMetaType::QDate:
1483 *static_cast<NS(QDate) *>(data) = NS(QDate)();
1485 case QMetaType::QTime:
1486 *static_cast<NS(QTime) *>(data) = NS(QTime)();
1488 case QMetaType::QDateTime:
1489 *static_cast<NS(QDateTime) *>(data) = NS(QDateTime)();
1491 case QMetaType::QUrl:
1492 *static_cast<NS(QUrl) *>(data) = NS(QUrl)();
1494 case QMetaType::QLocale:
1495 *static_cast<NS(QLocale) *>(data) = NS(QLocale)();
1497 case QMetaType::QRect:
1498 *static_cast<NS(QRect) *>(data) = NS(QRect)();
1500 case QMetaType::QRectF:
1501 *static_cast<NS(QRectF) *>(data) = NS(QRectF)();
1503 case QMetaType::QSize:
1504 *static_cast<NS(QSize) *>(data) = NS(QSize)();
1506 case QMetaType::QSizeF:
1507 *static_cast<NS(QSizeF) *>(data) = NS(QSizeF)();
1509 case QMetaType::QLine:
1510 *static_cast<NS(QLine) *>(data) = NS(QLine)();
1512 case QMetaType::QLineF:
1513 *static_cast<NS(QLineF) *>(data) = NS(QLineF)();
1515 case QMetaType::QPoint:
1516 *static_cast<NS(QPoint) *>(data) = NS(QPoint)();
1518 case QMetaType::QPointF:
1519 *static_cast<NS(QPointF) *>(data) = NS(QPointF)();
1521 case QMetaType::QVector3D:
1522 *static_cast<NS(QVector3D) *>(data) = NS(QVector3D)();
1524 #ifndef QT_NO_REGEXP
1525 case QMetaType::QRegExp:
1526 *static_cast<NS(QRegExp) *>(data) = NS(QRegExp)();
1529 case QMetaType::Void:
1533 case QMetaType::QColorGroup:
1534 *static_cast<NS(QColorGroup) *>(data) = NS(QColorGroup)();
1538 case QMetaType::QFont:
1539 *static_cast<NS(QFont) *>(data) = NS(QFont)();
1541 case QMetaType::QPixmap:
1542 *static_cast<NS(QPixmap) *>(data) = NS(QPixmap)();
1544 case QMetaType::QBrush:
1545 *static_cast<NS(QBrush) *>(data) = NS(QBrush)();
1547 case QMetaType::QColor:
1548 *static_cast<NS(QColor) *>(data) = NS(QColor)();
1550 case QMetaType::QPalette:
1551 *static_cast<NS(QPalette) *>(data) = NS(QPalette)();
1553 case QMetaType::QIcon:
1554 *static_cast<NS(QIcon) *>(data) = NS(QIcon)();
1556 case QMetaType::QImage:
1557 *static_cast<NS(QImage) *>(data) = NS(QImage)();
1559 case QMetaType::QPolygon:
1560 *static_cast<NS(QPolygon) *>(data) = NS(QPolygon)();
1562 case QMetaType::QRegion:
1563 *static_cast<NS(QRegion) *>(data) = NS(QRegion)();
1565 case QMetaType::QBitmap:
1566 *static_cast<NS(QBitmap) *>(data) = NS(QBitmap)();
1568 #ifndef QT_NO_CURSOR
1569 case QMetaType::QCursor:
1570 *static_cast<NS(QCursor) *>(data) = NS(QCursor)();
1573 case QMetaType::QSizePolicy:
1574 *static_cast<NS(QSizePolicy) *>(data) = NS(QSizePolicy)();
1576 case QMetaType::QKeySequence:
1577 *static_cast<NS(QKeySequence) *>(data) = NS(QKeySequence)();
1579 case QMetaType::QPen:
1580 *static_cast<NS(QPen) *>(data) = NS(QPen)();
1582 case QMetaType::QTextLength:
1583 *static_cast<NS(QTextLength) *>(data) = NS(QTextLength)();
1585 case QMetaType::QTextFormat:
1586 *static_cast<NS(QTextFormat) *>(data) = NS(QTextFormat)();
1588 case QMetaType::QMatrix:
1589 *static_cast<NS(QMatrix) *>(data) = NS(QMatrix)();
1591 case QMetaType::QTransform:
1592 *static_cast<NS(QTransform) *>(data) = NS(QTransform)();
1594 case QMetaType::QMatrix4x4:
1595 *static_cast<NS(QMatrix4x4) *>(data) = NS(QMatrix4x4)();
1597 case QMetaType::QVector2D:
1598 *static_cast<NS(QVector2D) *>(data) = NS(QVector2D)();
1600 case QMetaType::QVector4D:
1601 *static_cast<NS(QVector4D) *>(data) = NS(QVector4D)();
1603 case QMetaType::QQuaternion:
1604 *static_cast<NS(QQuaternion) *>(data) = NS(QQuaternion)();
1607 if (type == qMetaTypeId<QVariant>()) {
1608 *static_cast<NS(QVariant) *>(data) = NS(QVariant)();
1610 } else if (type == qMetaTypeId<QScriptValue>()) {
1611 *static_cast<NS(QScriptValue) *>(data) = NS(QScriptValue)();
1613 } else if (typeCategory(type) != Unknown) {
1614 *static_cast<void **>(data) = 0;