/**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** ** This file is part of the QtDeclarative module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions ** contained in the either Technology Preview License Agreement or the ** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain ** additional rights. These rights are described in the Nokia Qt LGPL ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at qt-sales@nokia.com. ** $QT_END_LICENSE$ ** ****************************************************************************/ #include "qmlmetatype.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include QT_BEGIN_NAMESPACE #ifdef QT_BOOTSTRAPPED # ifndef QT_NO_GEOM_VARIANT # define QT_NO_GEOM_VARIANT # endif #else # include # include # include #endif #ifndef QT_NO_GEOM_VARIANT # include # include # include # include #endif #define NS(x) QT_PREPEND_NAMESPACE(x) struct QmlMetaTypeData { QList types; typedef QHash Ids; Ids idToType; typedef QHash Names; Names nameToType; typedef QHash MetaObjects; MetaObjects metaObjectToType; typedef QHash CustomParsers; CustomParsers customParsers; typedef QHash StringConverters; StringConverters stringConverters; QBitArray objects; QBitArray interfaces; QBitArray qmllists; QBitArray lists; }; Q_GLOBAL_STATIC(QmlMetaTypeData, metaTypeData); Q_GLOBAL_STATIC(QReadWriteLock, metaTypeDataLock); class QmlTypePrivate { public: QmlTypePrivate(); void init() const; bool m_isInterface : 1; const char *m_iid; QByteArray m_name; int m_typeId; int m_listId; int m_qmlListId; QmlPrivate::Func m_opFunc; const QMetaObject *m_baseMetaObject; QmlAttachedPropertiesFunc m_attachedPropertiesFunc; int m_parserStatusCast; QmlPrivate::CreateFunc m_extFunc; const QMetaObject *m_extMetaObject; int m_index; mutable volatile bool m_isSetup:1; mutable QList m_metaObjects; mutable QByteArray m_hash; }; QmlTypePrivate::QmlTypePrivate() : m_isInterface(false), m_iid(0), m_typeId(0), m_listId(0), m_qmlListId(0), m_opFunc(0), m_baseMetaObject(0), m_attachedPropertiesFunc(0), m_parserStatusCast(-1), m_extFunc(0), m_extMetaObject(0), m_index(-1), m_isSetup(false) { } QmlType::QmlType(int type, int listType, int qmlListType, QmlPrivate::Func opFunc, const char *iid, int index) : d(new QmlTypePrivate) { d->m_isInterface = true; d->m_iid = iid; d->m_typeId = type; d->m_listId = listType; d->m_qmlListId = qmlListType; d->m_opFunc = opFunc; d->m_index = index; d->m_isSetup = true; } QmlType::QmlType(int type, int listType, int qmlListType, QmlPrivate::Func opFunc, const char *qmlName, const QMetaObject *metaObject, QmlAttachedPropertiesFunc attachedPropertiesFunc, int parserStatusCast, QmlPrivate::CreateFunc extFunc, const QMetaObject *extMetaObject, int index) : d(new QmlTypePrivate) { d->m_name = qmlName; d->m_typeId = type; d->m_listId = listType; d->m_qmlListId = qmlListType; d->m_opFunc = opFunc; d->m_baseMetaObject = metaObject; d->m_attachedPropertiesFunc = attachedPropertiesFunc; d->m_parserStatusCast = parserStatusCast; d->m_extFunc = extFunc; d->m_index = index; if (extMetaObject) d->m_extMetaObject = extMetaObject; } QmlType::~QmlType() { delete d; } void QmlTypePrivate::init() const { if (m_isSetup) return; QWriteLocker lock(metaTypeDataLock()); if (m_isSetup) return; // Setup extended meta object // XXX - very inefficient const QMetaObject *mo = m_baseMetaObject; if (m_extFunc) { QMetaObject *mmo = new QMetaObject; *mmo = *m_extMetaObject; mmo->d.superdata = mo; QmlProxyMetaObject::ProxyData data = { mmo, m_extFunc, 0 }; m_metaObjects << data; } mo = mo->d.superdata; while(mo) { QmlType *t = metaTypeData()->metaObjectToType.value(mo); if (t) { if (t->d->m_extFunc) { QMetaObject *mmo = new QMetaObject; *mmo = *t->d->m_extMetaObject; mmo->d.superdata = m_baseMetaObject; if (!m_metaObjects.isEmpty()) m_metaObjects.last().metaObject->d.superdata = mmo; QmlProxyMetaObject::ProxyData data = { mmo, t->d->m_extFunc, 0 }; m_metaObjects << data; } } mo = mo->d.superdata; } for (int ii = 0; ii < m_metaObjects.count(); ++ii) m_metaObjects[ii].propertyOffset = m_metaObjects.at(ii).metaObject->propertyOffset(); // Calculate hash QByteArray hashData; const QMetaObject *myMetaObject = m_metaObjects.isEmpty()?m_baseMetaObject:m_metaObjects.first().metaObject; for (int ii = 0; ii < myMetaObject->propertyCount(); ++ii) { QMetaProperty prop = myMetaObject->property(ii); hashData.append(prop.type()); hashData.append("|"); hashData.append(prop.name()); hashData.append("|"); } for (int ii = 0; ii < myMetaObject->methodCount(); ++ii) { QMetaMethod method = myMetaObject->method(ii); hashData.append(method.signature()); hashData.append("|"); } m_hash = QCryptographicHash::hash(hashData, QCryptographicHash::Md5); m_isSetup = true; lock.unlock(); } QByteArray QmlType::typeName() const { if (d->m_baseMetaObject) return d->m_baseMetaObject->className(); else return QByteArray(); } QByteArray QmlType::qmlTypeName() const { return d->m_name; } QByteArray QmlType::hash() const { d->init(); return d->m_hash; } QObject *QmlType::create() const { d->init(); QVariant v; QObject *rv = 0; d->m_opFunc(QmlPrivate::Create, 0, v, v, (void **)&rv); if (rv && !d->m_metaObjects.isEmpty()) (void *)new QmlProxyMetaObject(rv, &d->m_metaObjects); return rv; } bool QmlType::isInterface() const { return d->m_isInterface; } int QmlType::typeId() const { return d->m_typeId; } int QmlType::qListTypeId() const { return d->m_listId; } int QmlType::qmlListTypeId() const { return d->m_qmlListId; } void QmlType::listClear(const QVariant &list) { Q_ASSERT(list.userType() == qListTypeId()); QVariant arg; d->m_opFunc(QmlPrivate::Clear, 0, list, arg, 0); } void QmlType::listAppend(const QVariant &list, const QVariant &item) { Q_ASSERT(list.userType() == qListTypeId()); d->m_opFunc(QmlPrivate::Append, 0, list, item, 0); } QVariant QmlType::listAt(const QVariant &list, int idx) { Q_ASSERT(list.userType() == qListTypeId()); QVariant rv; void *ptr = (void *)&rv; d->m_opFunc(QmlPrivate::Value, idx, list, QVariant(), &ptr); return rv; } int QmlType::listCount(const QVariant &list) { Q_ASSERT(list.userType() == qListTypeId()); return d->m_opFunc(QmlPrivate::Length, 0, list, QVariant(), 0); } const QMetaObject *QmlType::metaObject() const { d->init(); if (d->m_metaObjects.isEmpty()) return d->m_baseMetaObject; else return d->m_metaObjects.first().metaObject; } const QMetaObject *QmlType::baseMetaObject() const { return d->m_baseMetaObject; } QmlAttachedPropertiesFunc QmlType::attachedPropertiesFunction() const { return d->m_attachedPropertiesFunc; } int QmlType::parserStatusCast() const { return d->m_parserStatusCast; } QVariant QmlType::fromObject(QObject *obj) const { QVariant rv; QVariant *v_ptr = &rv; QVariant vobj = QVariant::fromValue(obj); d->m_opFunc(QmlPrivate::FromObject, 0, QVariant(), vobj, (void **)&v_ptr); return rv; } const char *QmlType::interfaceIId() const { return d->m_iid; } int QmlType::index() const { return d->m_index; } int QmlMetaType::registerInterface(const QmlPrivate::MetaTypeIds &id, QmlPrivate::Func listFunction, const char *iid) { QWriteLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); int index = data->types.count(); QmlType *type = new QmlType(id.typeId, id.listId, id.qmlListId, listFunction, iid, index); data->types.append(type); data->idToType.insert(type->typeId(), type); data->idToType.insert(type->qListTypeId(), type); data->idToType.insert(type->qmlListTypeId(), type); data->nameToType.insert(type->qmlTypeName(), type); if (data->interfaces.size() < id.typeId) data->interfaces.resize(id.typeId + 16); if (data->qmllists.size() < id.qmlListId) data->qmllists.resize(id.qmlListId + 16); if (data->lists.size() < id.listId) data->lists.resize(id.listId + 16); data->interfaces.setBit(id.typeId, true); data->qmllists.setBit(id.qmlListId, true); data->lists.setBit(id.listId, true); return index; } int QmlMetaType::registerType(const QmlPrivate::MetaTypeIds &id, QmlPrivate::Func func, const char *cname, const QMetaObject *mo, QmlAttachedPropertiesFunc attach, int pStatus, int object, QmlPrivate::CreateFunc extFunc, const QMetaObject *extmo) { Q_UNUSED(object); QWriteLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); QString name = QLatin1String(cname); for (int ii = 0; ii < name.count(); ++ii) { if (!name.at(ii).isLetterOrNumber()) { qWarning("QmlMetaType: Invalid QML name %s", cname); return -1; } } int index = data->types.count(); QmlType *type = new QmlType(id.typeId, id.listId, id.qmlListId, func, cname, mo, attach, pStatus, extFunc, extmo, index); data->types.append(type); data->idToType.insert(type->typeId(), type); data->idToType.insert(type->qListTypeId(), type); data->idToType.insert(type->qmlListTypeId(), type); if (!type->qmlTypeName().isEmpty()) data->nameToType.insert(type->qmlTypeName(), type); data->metaObjectToType.insert(type->baseMetaObject(), type); if (data->objects.size() <= id.typeId) data->objects.resize(id.typeId + 16); if (data->qmllists.size() <= id.qmlListId) data->qmllists.resize(id.qmlListId + 16); if (data->lists.size() <= id.listId) data->lists.resize(id.listId + 16); data->objects.setBit(id.typeId, true); data->qmllists.setBit(id.qmlListId, true); data->lists.setBit(id.listId, true); return index; } void QmlMetaType::registerCustomParser(const char *qmlName, QmlCustomParser *parser) { QWriteLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); Q_ASSERT(parser); if (data->customParsers.contains(qmlName)) { delete parser; return; } data->customParsers.insert(qmlName, parser); } QmlCustomParser *QmlMetaType::customParser(const QByteArray &name) { QReadLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); return data->customParsers.value(name); } int QmlMetaType::qmlParserStatusCast(int userType) { QReadLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); QmlType *type = data->idToType.value(userType); if (type && type->typeId() == userType) return type->parserStatusCast(); else return -1; } QObject *QmlMetaType::toQObject(const QVariant &v) { if (!isObject(v.userType())) return 0; // NOTE: This assumes a cast to QObject does not alter the // object pointer QObject *rv = *(QObject **)v.constData(); return rv; } /* Returns the item type for a list of type \a id. */ int QmlMetaType::listType(int id) { QReadLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); QmlType *type = data->idToType.value(id); if (type && type->qListTypeId() == id) return type->typeId(); else return 0; } /* Returns the item type for a qml list of type \a id. */ int QmlMetaType::qmlListType(int id) { QReadLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); QmlType *type = data->idToType.value(id); if (type && type->qmlListTypeId() == id) return type->typeId(); else return 0; } bool QmlMetaType::clear(const QVariant &list) { int userType = list.userType(); QReadLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); QmlType *type = data->idToType.value(userType); lock.unlock(); if (type && type->qListTypeId() == userType) { type->listClear(list); return true; } else { return false; } } bool QmlMetaType::append(const QVariant &list, const QVariant &item) { int userType = list.userType(); QReadLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); QmlType *type = data->idToType.value(userType); lock.unlock(); if (type && type->qListTypeId() == userType && item.userType() == type->typeId()) { type->listAppend(list, item); return true; } else { return false; } } QObject *QmlMetaType::create(const QByteArray &name) { QReadLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); lock.unlock(); QmlType *type = data->nameToType.value(name); if (type) return type->create(); else return 0; } QVariant QmlMetaType::fromObject(QObject *obj, int typeId) { QReadLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); QmlType *type = data->idToType.value(typeId); if (type && type->typeId() == typeId) return type->fromObject(obj); else return QVariant(); } const QMetaObject *QmlMetaType::rawMetaObjectForType(int id) { QReadLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); QmlType *type = data->idToType.value(id); if (type && type->typeId() == id) return type->baseMetaObject(); else return 0; } const QMetaObject *QmlMetaType::rawMetaObjectForType(const QByteArray &name) { QReadLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); QmlType *type = data->nameToType.value(name); if (type) return type->baseMetaObject(); else return 0; } const QMetaObject *QmlMetaType::metaObjectForType(int id) { QReadLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); QmlType *type = data->idToType.value(id); lock.unlock(); if (type && type->typeId() == id) return type->metaObject(); else return 0; } const QMetaObject *QmlMetaType::metaObjectForType(const QByteArray &name) { QReadLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); QmlType *type = data->nameToType.value(name); lock.unlock(); if (type) return type->metaObject(); else return 0; } int QmlMetaType::type(const QByteArray &name) { QReadLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); QmlType *type = data->nameToType.value(name); if (type) return type->typeId(); else return 0; } int QmlMetaType::attachedPropertiesFuncId(const QByteArray &name) { QReadLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); QmlType *type = data->nameToType.value(name); if (type && type->attachedPropertiesFunction()) return type->index(); else return -1; } int QmlMetaType::attachedPropertiesFuncId(const QMetaObject *mo) { QReadLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); QmlType *type = data->metaObjectToType.value(mo); if (type && type->attachedPropertiesFunction()) return type->index(); else return -1; } QmlAttachedPropertiesFunc QmlMetaType::attachedPropertiesFuncById(int id) { if (id < 0) return 0; QReadLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); return data->types.at(id)->attachedPropertiesFunction(); } QmlAttachedPropertiesFunc QmlMetaType::attachedPropertiesFunc(const QByteArray &name) { QReadLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); QmlType *type = data->nameToType.value(name); if (type) return type->attachedPropertiesFunction(); else return 0; } QMetaProperty QmlMetaType::defaultProperty(const QMetaObject *metaObject) { int idx = metaObject->indexOfClassInfo("DefaultProperty"); if (-1 == idx) return QMetaProperty(); QMetaClassInfo info = metaObject->classInfo(idx); if (!info.value()) return QMetaProperty(); idx = metaObject->indexOfProperty(info.value()); if (-1 == idx) return QMetaProperty(); return metaObject->property(idx); } QMetaProperty QmlMetaType::defaultProperty(QObject *obj) { if (!obj) return QMetaProperty(); const QMetaObject *metaObject = obj->metaObject(); return defaultProperty(metaObject); } QMetaMethod QmlMetaType::defaultMethod(const QMetaObject *metaObject) { int idx = metaObject->indexOfClassInfo("DefaultMethod"); if (-1 == idx) return QMetaMethod(); QMetaClassInfo info = metaObject->classInfo(idx); if (!info.value()) return QMetaMethod(); idx = metaObject->indexOfMethod(info.value()); if (-1 == idx) return QMetaMethod(); return metaObject->method(idx); } QMetaMethod QmlMetaType::defaultMethod(QObject *obj) { if (!obj) return QMetaMethod(); const QMetaObject *metaObject = obj->metaObject(); return defaultMethod(metaObject); } /*! */ QMetaProperty QmlMetaType::property(QObject *obj, const QByteArray &bname) { return property(obj, bname.constData()); } /*! */ QMetaProperty QmlMetaType::property(QObject *obj, const char *name) { if (!obj) return QMetaProperty(); const QMetaObject *metaObject = obj->metaObject(); int idx = metaObject->indexOfProperty(name); if (-1 == idx) return QMetaProperty(); return metaObject->property(idx); } bool QmlMetaType::isObject(int userType) { QReadLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); return userType >= 0 && userType < data->objects.size() && data->objects.testBit(userType); } bool QmlMetaType::isInterface(int userType) { QReadLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); return userType >= 0 && userType < data->interfaces.size() && data->interfaces.testBit(userType); } const char *QmlMetaType::interfaceIId(int userType) { QReadLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); QmlType *type = data->idToType.value(userType); lock.unlock(); if (type && type->isInterface() && type->typeId() == userType) return type->interfaceIId(); else return 0; } bool QmlMetaType::isObject(const QMetaObject *mo) { while(mo) { if (mo == &QObject::staticMetaObject) return true; mo = mo->superClass(); } return false; } bool QmlMetaType::isQmlList(int userType) { QReadLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); return userType >= 0 && userType < data->qmllists.size() && data->qmllists.testBit(userType); } bool QmlMetaType::isList(int userType) { QReadLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); return userType >= 0 && userType < data->lists.size() && data->lists.testBit(userType); } bool QmlMetaType::isList(const QVariant &v) { return (v.type() == QVariant::UserType && isList(v.userType())); } int QmlMetaType::listCount(const QVariant &v) { int userType = v.userType(); QReadLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); QmlType *type = data->idToType.value(userType); lock.unlock(); if (type && type->qListTypeId() == userType) return type->listCount(v); else return 0; } QVariant QmlMetaType::listAt(const QVariant &v, int idx) { int userType = v.userType(); QReadLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); QmlType *type = data->idToType.value(userType); lock.unlock(); if (type && type->qListTypeId() == userType) return type->listAt(v, idx); else return 0; } /*! A custom string convertor allows you to specify a function pointer that returns a variant of \a type. For example, if you have written your own icon class that you want to support as an object property assignable in QML: \code int type = qRegisterMetaType("SuperIcon"); QML::addCustomStringConvertor(type, &SuperIcon::pixmapFromString); \endcode The function pointer must be of the form: \code QVariant (*StringConverter)(const QString &); \endcode */ void QmlMetaType::registerCustomStringConverter(int type, StringConverter converter) { QWriteLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); if (data->stringConverters.contains(type)) return; data->stringConverters.insert(type, converter); } /*! Return the custom string converter for \a type, previously installed through registerCustomStringConverter() */ QmlMetaType::StringConverter QmlMetaType::customStringConverter(int type) { QReadLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); return data->stringConverters.value(type); } QmlType *QmlMetaType::qmlType(const QByteArray &name) { QReadLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); return data->nameToType.value(name); } QList QmlMetaType::qmlTypeNames() { QReadLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); return data->nameToType.keys(); } /*! Copies \a copy into \a data, assuming they both are of type \a type. If \a copy is zero, a default type is copied. Returns true if the copy was successful and false if not. \note This should move into QMetaType once complete */ bool QmlMetaType::copy(int type, void *data, const void *copy) { if (copy) { switch(type) { case QMetaType::VoidStar: case QMetaType::QObjectStar: case QMetaType::QWidgetStar: *static_cast(data) = *static_cast(copy); return true; case QMetaType::Long: *static_cast(data) = *static_cast(copy); return true; case QMetaType::Int: *static_cast(data) = *static_cast(copy); return true; case QMetaType::Short: *static_cast(data) = *static_cast(copy); return true; case QMetaType::Char: *static_cast(data) = *static_cast(copy); return true; case QMetaType::ULong: *static_cast(data) = *static_cast(copy); return true; case QMetaType::UInt: *static_cast(data) = *static_cast(copy); return true; case QMetaType::LongLong: *static_cast(data) = *static_cast(copy); return true; case QMetaType::ULongLong: *static_cast(data) = *static_cast(copy); return true; case QMetaType::UShort: *static_cast(data) = *static_cast(copy); return true; case QMetaType::UChar: *static_cast(data) = *static_cast(copy); return true; case QMetaType::Bool: *static_cast(data) = *static_cast(copy); return true; case QMetaType::Float: *static_cast(data) = *static_cast(copy); return true; case QMetaType::Double: *static_cast(data) = *static_cast(copy); return true; case QMetaType::QChar: *static_cast(data) = *static_cast(copy); return true; #ifndef QT_BOOTSTRAPPED case QMetaType::QVariantMap: *static_cast(data) = *static_cast(copy); return true; case QMetaType::QVariantHash: *static_cast(data) = *static_cast(copy); return true; case QMetaType::QVariantList: *static_cast(data) = *static_cast(copy); return true; #endif case QMetaType::QByteArray: *static_cast(data) = *static_cast(copy); return true; case QMetaType::QString: *static_cast(data) = *static_cast(copy); return true; case QMetaType::QStringList: *static_cast(data) = *static_cast(copy); return true; #ifndef QT_BOOTSTRAPPED case QMetaType::QBitArray: *static_cast(data) = *static_cast(copy); return true; #endif case QMetaType::QDate: *static_cast(data) = *static_cast(copy); return true; case QMetaType::QTime: *static_cast(data) = *static_cast(copy); return true; case QMetaType::QDateTime: *static_cast(data) = *static_cast(copy); return true; #ifndef QT_BOOTSTRAPPED case QMetaType::QUrl: *static_cast(data) = *static_cast(copy); return true; #endif case QMetaType::QLocale: *static_cast(data) = *static_cast(copy); return true; #ifndef QT_NO_GEOM_VARIANT case QMetaType::QRect: *static_cast(data) = *static_cast(copy); return true; case QMetaType::QRectF: *static_cast(data) = *static_cast(copy); return true; case QMetaType::QSize: *static_cast(data) = *static_cast(copy); return true; case QMetaType::QSizeF: *static_cast(data) = *static_cast(copy); return true; case QMetaType::QLine: *static_cast(data) = *static_cast(copy); return true; case QMetaType::QLineF: *static_cast(data) = *static_cast(copy); return true; case QMetaType::QPoint: *static_cast(data) = *static_cast(copy); return true; case QMetaType::QPointF: *static_cast(data) = *static_cast(copy); return true; #endif #ifndef QT_NO_REGEXP case QMetaType::QRegExp: *static_cast(data) = *static_cast(copy); return true; #endif case QMetaType::Void: return true; default: ; } } else { switch(type) { case QMetaType::VoidStar: case QMetaType::QObjectStar: case QMetaType::QWidgetStar: *static_cast(data) = 0; return true; case QMetaType::Long: *static_cast(data) = long(0); return true; case QMetaType::Int: *static_cast(data) = int(0); return true; case QMetaType::Short: *static_cast(data) = short(0); return true; case QMetaType::Char: *static_cast(data) = char(0); return true; case QMetaType::ULong: *static_cast(data) = ulong(0); return true; case QMetaType::UInt: *static_cast(data) = uint(0); return true; case QMetaType::LongLong: *static_cast(data) = qlonglong(0); return true; case QMetaType::ULongLong: *static_cast(data) = qulonglong(0); return true; case QMetaType::UShort: *static_cast(data) = ushort(0); return true; case QMetaType::UChar: *static_cast(data) = uchar(0); return true; case QMetaType::Bool: *static_cast(data) = bool(false); return true; case QMetaType::Float: *static_cast(data) = float(0); return true; case QMetaType::Double: *static_cast(data) = double(); return true; case QMetaType::QChar: *static_cast(data) = NS(QChar)(); return true; #ifndef QT_BOOTSTRAPPED case QMetaType::QVariantMap: *static_cast(data) = NS(QVariantMap)(); return true; case QMetaType::QVariantHash: *static_cast(data) = NS(QVariantHash)(); return true; case QMetaType::QVariantList: *static_cast(data) = NS(QVariantList)(); return true; #endif case QMetaType::QByteArray: *static_cast(data) = NS(QByteArray)(); return true; case QMetaType::QString: *static_cast(data) = NS(QString)(); return true; case QMetaType::QStringList: *static_cast(data) = NS(QStringList)(); return true; #ifndef QT_BOOTSTRAPPED case QMetaType::QBitArray: *static_cast(data) = NS(QBitArray)(); return true; #endif case QMetaType::QDate: *static_cast(data) = NS(QDate)(); return true; case QMetaType::QTime: *static_cast(data) = NS(QTime)(); return true; case QMetaType::QDateTime: *static_cast(data) = NS(QDateTime)(); return true; #ifndef QT_BOOTSTRAPPED case QMetaType::QUrl: *static_cast(data) = NS(QUrl)(); return true; #endif case QMetaType::QLocale: *static_cast(data) = NS(QLocale)(); return true; #ifndef QT_NO_GEOM_VARIANT case QMetaType::QRect: *static_cast(data) = NS(QRect)(); return true; case QMetaType::QRectF: *static_cast(data) = NS(QRectF)(); return true; case QMetaType::QSize: *static_cast(data) = NS(QSize)(); return true; case QMetaType::QSizeF: *static_cast(data) = NS(QSizeF)(); return true; case QMetaType::QLine: *static_cast(data) = NS(QLine)(); return true; case QMetaType::QLineF: *static_cast(data) = NS(QLineF)(); return true; case QMetaType::QPoint: *static_cast(data) = NS(QPoint)(); return true; case QMetaType::QPointF: *static_cast(data) = NS(QPointF)(); return true; #endif #ifndef QT_NO_REGEXP case QMetaType::QRegExp: *static_cast(data) = NS(QRegExp)(); return true; #endif case QMetaType::Void: return true; default: ; } } return false; } void qmlRegisterCustomParser(const char *qmlName, QmlCustomParser *parser) { QmlMetaType::registerCustomParser(qmlName, parser); } QT_END_NAMESPACE