setObject(obj);
}
-class QQmlVMEVariant
-{
-public:
- inline QQmlVMEVariant();
- inline ~QQmlVMEVariant();
-
- inline const void *dataPtr() const;
- inline void *dataPtr();
- inline int dataType() const;
- inline size_t dataSize() const;
-
- inline QObject *asQObject();
- inline const QVariant &asQVariant();
- inline int asInt();
- inline bool asBool();
- inline double asDouble();
- inline const QString &asQString();
- inline const QUrl &asQUrl();
- inline const QDate &asQDate();
- inline const QDateTime &asQDateTime();
- inline const QRectF &asQRectF();
- inline const QPointF &asQPointF();
- inline const QSizeF &asQSizeF();
-
- inline void setValue(QObject *v, QQmlVMEMetaObject *target, int index);
- inline void setValue(const QVariant &);
- inline void setValue(int);
- inline void setValue(bool);
- inline void setValue(double);
- inline void setValue(const QString &);
- inline void setValue(const QUrl &);
- inline void setValue(const QTime &);
- inline void setValue(const QDate &);
- inline void setValue(const QDateTime &);
- inline void setValue(const QRectF &);
- inline void setValue(const QPointF &);
- inline void setValue(const QSizeF &);
-
- inline void ensureValueType(int);
-
-private:
- int type;
- void *data[8]; // Large enough to hold all types
-
- inline void cleanup();
-};
-
class QQmlVMEMetaObjectEndpoint : public QQmlNotifierEndpoint
{
public:
QFlagPointer<QQmlVMEMetaObject> metaObject;
};
-
-QQmlVMEVariant::QQmlVMEVariant()
-: type(QVariant::Invalid)
-{
-}
-
-QQmlVMEVariant::~QQmlVMEVariant()
-{
- cleanup();
-}
-
-void QQmlVMEVariant::cleanup()
-{
- if (type == QVariant::Invalid) {
- } else if (type == QMetaType::Int ||
- type == QMetaType::Bool ||
- type == QMetaType::Double) {
- type = QVariant::Invalid;
- } else if (type == QMetaType::QObjectStar) {
- ((QQmlVMEVariantQObjectPtr*)dataPtr())->~QQmlVMEVariantQObjectPtr();
- type = QVariant::Invalid;
- } else if (type == QMetaType::QString) {
- ((QString *)dataPtr())->~QString();
- type = QVariant::Invalid;
- } else if (type == QMetaType::QUrl) {
- ((QUrl *)dataPtr())->~QUrl();
- type = QVariant::Invalid;
- } else if (type == QMetaType::QTime) {
- ((QTime *)dataPtr())->~QTime();
- type = QVariant::Invalid;
- } else if (type == QMetaType::QDate) {
- ((QDate *)dataPtr())->~QDate();
- type = QVariant::Invalid;
- } else if (type == QMetaType::QDateTime) {
- ((QDateTime *)dataPtr())->~QDateTime();
- type = QVariant::Invalid;
- } else if (type == QMetaType::QRectF) {
- ((QRectF *)dataPtr())->~QRectF();
- type = QVariant::Invalid;
- } else if (type == QMetaType::QPointF) {
- ((QPointF *)dataPtr())->~QPointF();
- type = QVariant::Invalid;
- } else if (type == QMetaType::QSizeF) {
- ((QSizeF *)dataPtr())->~QSizeF();
- type = QVariant::Invalid;
- } else if (type == qMetaTypeId<QVariant>()) {
- ((QVariant *)dataPtr())->~QVariant();
- type = QVariant::Invalid;
- } else {
- if (QQml_valueTypeProvider()->destroyValueType(type, dataPtr(), dataSize())) {
- type = QVariant::Invalid;
- }
- }
-}
-
-int QQmlVMEVariant::dataType() const
-{
- return type;
-}
-
-const void *QQmlVMEVariant::dataPtr() const
-{
- return &data;
-}
-
-void *QQmlVMEVariant::dataPtr()
-{
- return &data;
-}
-
-size_t QQmlVMEVariant::dataSize() const
-{
- return sizeof(data);
-}
-
-QObject *QQmlVMEVariant::asQObject()
-{
- if (type != QMetaType::QObjectStar)
- setValue((QObject *)0, 0, -1);
-
- return *(QQmlGuard<QObject> *)(dataPtr());
-}
-
-const QVariant &QQmlVMEVariant::asQVariant()
-{
- if (type != QMetaType::QVariant)
- setValue(QVariant());
-
- return *(QVariant *)(dataPtr());
-}
-
-int QQmlVMEVariant::asInt()
-{
- if (type != QMetaType::Int)
- setValue(int(0));
-
- return *(int *)(dataPtr());
-}
-
-bool QQmlVMEVariant::asBool()
-{
- if (type != QMetaType::Bool)
- setValue(bool(false));
-
- return *(bool *)(dataPtr());
-}
-
-double QQmlVMEVariant::asDouble()
-{
- if (type != QMetaType::Double)
- setValue(double(0));
-
- return *(double *)(dataPtr());
-}
-
-const QString &QQmlVMEVariant::asQString()
-{
- if (type != QMetaType::QString)
- setValue(QString());
-
- return *(QString *)(dataPtr());
-}
-
-const QUrl &QQmlVMEVariant::asQUrl()
-{
- if (type != QMetaType::QUrl)
- setValue(QUrl());
-
- return *(QUrl *)(dataPtr());
-}
-
-const QDate &QQmlVMEVariant::asQDate()
-{
- if (type != QMetaType::QDate)
- setValue(QDate());
-
- return *(QDate *)(dataPtr());
-}
-
-const QDateTime &QQmlVMEVariant::asQDateTime()
-{
- if (type != QMetaType::QDateTime)
- setValue(QDateTime());
-
- return *(QDateTime *)(dataPtr());
-}
-
-const QRectF &QQmlVMEVariant::asQRectF()
-{
- if (type != QMetaType::QRectF)
- setValue(QRectF());
-
- return *(QRectF *)(dataPtr());
-}
-
-const QSizeF &QQmlVMEVariant::asQSizeF()
-{
- if (type != QMetaType::QSizeF)
- setValue(QSizeF());
-
- return *(QSizeF *)(dataPtr());
-}
-
-const QPointF &QQmlVMEVariant::asQPointF()
-{
- if (type != QMetaType::QPointF)
- setValue(QPointF());
-
- return *(QPointF *)(dataPtr());
-}
-
-void QQmlVMEVariant::setValue(QObject *v, QQmlVMEMetaObject *target, int index)
-{
- if (type != QMetaType::QObjectStar) {
- cleanup();
- type = QMetaType::QObjectStar;
- new (dataPtr()) QQmlVMEVariantQObjectPtr(false);
- }
- reinterpret_cast<QQmlVMEVariantQObjectPtr*>(dataPtr())->setGuardedValue(v, target, index);
-}
-
-void QQmlVMEVariant::setValue(const QVariant &v)
-{
- if (type != qMetaTypeId<QVariant>()) {
- cleanup();
- type = qMetaTypeId<QVariant>();
- new (dataPtr()) QVariant(v);
- } else {
- *(QVariant *)(dataPtr()) = v;
- }
-}
-
-void QQmlVMEVariant::setValue(int v)
-{
- if (type != QMetaType::Int) {
- cleanup();
- type = QMetaType::Int;
- }
- *(int *)(dataPtr()) = v;
-}
-
-void QQmlVMEVariant::setValue(bool v)
-{
- if (type != QMetaType::Bool) {
- cleanup();
- type = QMetaType::Bool;
- }
- *(bool *)(dataPtr()) = v;
-}
-
-void QQmlVMEVariant::setValue(double v)
-{
- if (type != QMetaType::Double) {
- cleanup();
- type = QMetaType::Double;
- }
- *(double *)(dataPtr()) = v;
-}
-
-void QQmlVMEVariant::setValue(const QString &v)
-{
- if (type != QMetaType::QString) {
- cleanup();
- type = QMetaType::QString;
- new (dataPtr()) QString(v);
- } else {
- *(QString *)(dataPtr()) = v;
- }
-}
-
-void QQmlVMEVariant::setValue(const QUrl &v)
-{
- if (type != QMetaType::QUrl) {
- cleanup();
- type = QMetaType::QUrl;
- new (dataPtr()) QUrl(v);
- } else {
- *(QUrl *)(dataPtr()) = v;
- }
-}
-
-void QQmlVMEVariant::setValue(const QTime &v)
-{
- if (type != QMetaType::QTime) {
- cleanup();
- type = QMetaType::QTime;
- new (dataPtr()) QTime(v);
- } else {
- *(QTime *)(dataPtr()) = v;
- }
-}
-
-void QQmlVMEVariant::setValue(const QDate &v)
-{
- if (type != QMetaType::QDate) {
- cleanup();
- type = QMetaType::QDate;
- new (dataPtr()) QDate(v);
- } else {
- *(QDate *)(dataPtr()) = v;
- }
-}
-
-void QQmlVMEVariant::setValue(const QDateTime &v)
-{
- if (type != QMetaType::QDateTime) {
- cleanup();
- type = QMetaType::QDateTime;
- new (dataPtr()) QDateTime(v);
- } else {
- *(QDateTime *)(dataPtr()) = v;
- }
-}
-
-void QQmlVMEVariant::setValue(const QRectF &v)
-{
- if (type != QMetaType::QRectF) {
- cleanup();
- type = QMetaType::QRectF;
- new (dataPtr()) QRectF(v);
- } else {
- *(QRectF *)(dataPtr()) = v;
- }
-}
-
-void QQmlVMEVariant::setValue(const QPointF &v)
-{
- if (type != QMetaType::QPointF) {
- cleanup();
- type = QMetaType::QPointF;
- new (dataPtr()) QPointF(v);
- } else {
- *(QPointF *)(dataPtr()) = v;
- }
-}
-
-void QQmlVMEVariant::setValue(const QSizeF &v)
-{
- if (type != QMetaType::QSizeF) {
- cleanup();
- type = QMetaType::QSizeF;
- new (dataPtr()) QSizeF(v);
- } else {
- *(QSizeF *)(dataPtr()) = v;
- }
-}
-
-void QQmlVMEVariant::ensureValueType(int t)
-{
- if (type != t) {
- cleanup();
- type = t;
- QQml_valueTypeProvider()->initValueType(t, dataPtr(), dataSize());
- }
-}
-
QQmlVMEMetaObjectEndpoint::QQmlVMEMetaObjectEndpoint()
: QQmlNotifierEndpoint(QQmlNotifierEndpoint::QQmlVMEMetaObjectEndpoint)
{