return false;
}
-bool QQmlValueTypeProvider::copyValueType(int type, const void *src, void *dst, size_t n)
-{
- Q_ASSERT(src);
- Q_ASSERT(dst);
-
- QQmlValueTypeProvider *p = this;
- do {
- if (p->copy(type, src, dst, n))
- return true;
- } while ((p = p->next));
-
- return false;
-}
-
QVariant QQmlValueTypeProvider::createValueType(int type, int argc, const void *argv[])
{
QVariant v;
const QMetaObject *QQmlValueTypeProvider::getMetaObjectForMetaType(int) { return 0; }
bool QQmlValueTypeProvider::init(int, void *, size_t) { return false; }
bool QQmlValueTypeProvider::destroy(int, void *, size_t) { return false; }
-bool QQmlValueTypeProvider::copy(int, const void *, void *, size_t) { return false; }
bool QQmlValueTypeProvider::create(int, int, const void *[], QVariant *) { return false; }
bool QQmlValueTypeProvider::createFromString(int, const QString &, void *, size_t) { return false; }
bool QQmlValueTypeProvider::createStringFrom(int, const void *, QString *) { return false; }
bool initValueType(int, void *, size_t);
bool destroyValueType(int, void *, size_t);
- bool copyValueType(int, const void *, void *, size_t);
QVariant createValueType(int, int, const void *[]);
bool createValueFromString(int, const QString &, void *, size_t);
virtual const QMetaObject *getMetaObjectForMetaType(int);
virtual bool init(int, void *, size_t);
virtual bool destroy(int, void *, size_t);
- virtual bool copy(int, const void *, void *, size_t);
virtual bool create(int, int, const void *[], QVariant *);
virtual bool createFromString(int, const QString &, void *, size_t);
return false;
}
- template<typename T>
- bool typedCopyConstruct(const void *src, void *dst, size_t dstSize)
- {
- ASSERT_VALID_SIZE(dstSize, sizeof(T));
- const T *srcT = reinterpret_cast<const T *>(src);
- T *destT = reinterpret_cast<T *>(dst);
- new (destT) T(*srcT);
- return true;
- }
-
- bool copy(int type, const void *src, void *dst, size_t dstSize)
- {
- switch (type) {
- case QMetaType::QColor:
- return typedCopyConstruct<QColor>(src, dst, dstSize);
- case QMetaType::QFont:
- return typedCopyConstruct<QFont>(src, dst, dstSize);
- case QMetaType::QVector2D:
- return typedCopyConstruct<QVector2D>(src, dst, dstSize);
- case QMetaType::QVector3D:
- return typedCopyConstruct<QVector3D>(src, dst, dstSize);
- case QMetaType::QVector4D:
- return typedCopyConstruct<QVector4D>(src, dst, dstSize);
- case QMetaType::QQuaternion:
- return typedCopyConstruct<QQuaternion>(src, dst, dstSize);
- case QMetaType::QMatrix4x4:
- {
- if (dstSize >= sizeof(QMatrix4x4))
- return typedCopyConstruct<QMatrix4x4>(src, dst, dstSize);
-
- // special case: copying matrix into variant.
- Q_ASSERT(dstSize >= sizeof(QVariant));
- const QMatrix4x4 *srcMatrix = reinterpret_cast<const QMatrix4x4 *>(src);
- QVariant *dstMatrixVar = reinterpret_cast<QVariant *>(dst);
- new (dstMatrixVar) QVariant(*srcMatrix);
- return true;
- }
- default: break;
- }
-
- return false;
- }
-
bool create(int type, int argc, const void *argv[], QVariant *v)
{
switch (type) {