diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-07-29 12:28:00 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-07-29 09:39:41 +0200 |
commit | 8dbeeb524ff58772613de37e6683c9fc558f506f (patch) | |
tree | fd0315e57f4284123f5f68af6ee646a30a720154 /src/declarative | |
parent | ecb1a20324b53bd0cf60da18bde6f7a56f4567d3 (diff) |
Fix alias warnings in V4
Task-number: QTBUG-19736 QTBUG-19693
Change-Id: I6b9c2c167bfe60bcd3c5af7d53ec79c5eec60b74
Reviewed-on: http://codereview.qt.nokia.com/2362
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/qml/v4/qdeclarativev4bindings.cpp | 46 |
1 files changed, 20 insertions, 26 deletions
diff --git a/src/declarative/qml/v4/qdeclarativev4bindings.cpp b/src/declarative/qml/v4/qdeclarativev4bindings.cpp index 9209e93e4f..29c9ce05c5 100644 --- a/src/declarative/qml/v4/qdeclarativev4bindings.cpp +++ b/src/declarative/qml/v4/qdeclarativev4bindings.cpp @@ -67,20 +67,20 @@ struct Register { void setNaN() { setqreal(qSNaN()); } bool isUndefined() const { return dataType == UndefinedType; } - void setQObject(QObject *o) { *((QObject **)data) = o; dataType = QObjectStarType; } - QObject *getQObject() const { return *((QObject **)data); } + void setQObject(QObject *o) { qobjectValue = o; dataType = QObjectStarType; } + QObject *getQObject() const { return qobjectValue; } - void setqreal(qreal v) { *((qreal *)data) = v; dataType = QRealType; } - qreal getqreal() const { return *((qreal *)data); } - qreal &getqrealref() const { return *((qreal *)data); } + void setqreal(qreal v) { qrealValue = v; dataType = QRealType; } + qreal getqreal() const { return qrealValue; } + qreal &getqrealref() { return qrealValue; } - void setint(int v) { *((int *)data) = v; dataType = IntType; } - int getint() const { return *((int *)data); } - int &getintref() const { return *((int *)data); } + void setint(int v) { intValue = v; dataType = IntType; } + int getint() const { return intValue; } + int &getintref() { return intValue; } - void setbool(bool v) { *((bool *)data) = v; dataType = BoolType; } - bool getbool() const { return *((bool *)data); } - bool &getboolref() const { return *((bool *)data); } + void setbool(bool v) { boolValue = v; dataType = BoolType; } + bool getbool() const { return boolValue; } + bool &getboolref() { return boolValue; } QVariant *getvariantptr() { return (QVariant *)typeDataPtr(); } QString *getstringptr() { return (QString *)typeDataPtr(); } @@ -97,10 +97,16 @@ struct Register { Type gettype() const { return dataType; } void settype(Type t) { dataType = t; } - // int type; // Optional type - Type dataType; // Type of data - void *data[2]; // Object stored here + union { + QObject *qobjectValue; + qreal qrealValue; + int intValue; + bool boolValue; + void *data[sizeof(QVariant)]; + qint64 q_for_alignment_1; + double q_for_alignment_2; + }; inline void cleanup(); inline void cleanupString(); @@ -498,18 +504,6 @@ inline static QUrl toUrl(Register *reg, int type, QDeclarativeContextData *conte return base; } -static QObject *variantToQObject(const QVariant &value, bool *ok) -{ - if (ok) *ok = true; - - if (value.userType() == QMetaType::QObjectStar) { - return qvariant_cast<QObject*>(value); - } else { - if (ok) *ok = false; - return 0; - } -} - void QDeclarativeV4BindingsPrivate::init() { if (program->subscriptions) |