Inline static data for basic types into the QML instruction
authorAaron Kennedy <aaron.kennedy@nokia.com>
Thu, 5 May 2011 04:16:27 +0000 (14:16 +1000)
committerAaron Kennedy <aaron.kennedy@nokia.com>
Thu, 5 May 2011 05:26:04 +0000 (15:26 +1000)
The following types are now entirely inline:
    QPoint, QPointF
    QSize, QSizeF
    QRect, QRectF
    QVector3D,
    QTime, QDateTime
    CustomTypeData

Reviewed-by: Martin Jones
Change-Id: I7024d136c77f8fb23ef6a6abb23ddfe0f9f8a1ca

src/declarative/qml/qdeclarativecompileddata.cpp
src/declarative/qml/qdeclarativecompiler.cpp
src/declarative/qml/qdeclarativecompiler_p.h
src/declarative/qml/qdeclarativeinstruction.cpp
src/declarative/qml/qdeclarativeinstruction_p.h
src/declarative/qml/qdeclarativevme.cpp
tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp
tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp

index 1f5d111..4c7f270 100644 (file)
@@ -97,70 +97,6 @@ int QDeclarativeCompiledData::indexForUrl(const QUrl &data)
     return idx;
 }
 
-int QDeclarativeCompiledData::indexForFloat(float *data, int count)
-{
-    Q_ASSERT(count > 0);
-
-    for (int ii = 0; ii <= floatData.count() - count; ++ii) {
-        bool found = true;
-        for (int jj = 0; jj < count; ++jj) {
-            if (floatData.at(ii + jj) != data[jj]) {
-                found = false;
-                break;
-            }
-        }
-
-        if (found)
-            return ii;
-    }
-
-    int idx = floatData.count();
-    for (int ii = 0; ii < count; ++ii)
-        floatData << data[ii];
-
-    return idx;
-}
-
-int QDeclarativeCompiledData::indexForInt(int *data, int count)
-{
-    Q_ASSERT(count > 0);
-
-    for (int ii = 0; ii <= intData.count() - count; ++ii) {
-        bool found = true;
-        for (int jj = 0; jj < count; ++jj) {
-            if (intData.at(ii + jj) != data[jj]) {
-                found = false;
-                break;
-            }
-        }
-
-        if (found)
-            return ii;
-    }
-
-    int idx = intData.count();
-    for (int ii = 0; ii < count; ++ii)
-        intData << data[ii];
-
-    return idx;
-}
-
-int QDeclarativeCompiledData::indexForLocation(const QDeclarativeParser::Location &l)
-{
-    // ### FIXME
-    int rv = locations.count();
-    locations << l;
-    return rv;
-}
-
-int QDeclarativeCompiledData::indexForLocation(const QDeclarativeParser::LocationSpan &l)
-{
-    // ### FIXME
-    int rv = locations.count();
-    locations << l.start << l.end;
-    return rv;
-}
-
 QDeclarativeCompiledData::QDeclarativeCompiledData(QDeclarativeEngine *engine)
 : QDeclarativeCleanup(engine), importCache(0), root(0), rootPropertyCache(0)
 {
index d8aa938..31a9f66 100644 (file)
@@ -441,74 +441,84 @@ void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop,
         case QVariant::Time:
             {
             QTime time = QDeclarativeStringConverters::timeFromString(string);
-            int data[] = { time.hour(), time.minute(),
-                           time.second(), time.msec() };
-            int index = output->indexForInt(data, 4);
             instr.setType(QDeclarativeInstruction::StoreTime);
             instr.storeTime.propertyIndex = prop.propertyIndex();
-            instr.storeTime.valueIndex = index;
+            instr.storeTime.time = *(QDeclarativeInstruction::instr_storeTime::QTime *)&time;
             }
             break;
         case QVariant::DateTime:
             {
             QDateTime dateTime = QDeclarativeStringConverters::dateTimeFromString(string);
-            int data[] = { dateTime.date().toJulianDay(),
-                           dateTime.time().hour(),
-                           dateTime.time().minute(),
-                           dateTime.time().second(),
-                           dateTime.time().msec() };
-            int index = output->indexForInt(data, 5);
+            QTime time = dateTime.time();
             instr.setType(QDeclarativeInstruction::StoreDateTime);
             instr.storeDateTime.propertyIndex = prop.propertyIndex();
-            instr.storeDateTime.valueIndex = index;
+            instr.storeDateTime.date = dateTime.date().toJulianDay();
+            instr.storeDateTime.time = *(QDeclarativeInstruction::instr_storeTime::QTime *)&time;
             }
             break;
 #endif // QT_NO_DATESTRING
         case QVariant::Point:
+            {
+            bool ok;
+            QPoint point = QDeclarativeStringConverters::pointFFromString(string, &ok).toPoint();
+            instr.setType(QDeclarativeInstruction::StorePoint);
+            instr.storePoint.propertyIndex = prop.propertyIndex();
+            instr.storePoint.point.xp = point.x();
+            instr.storePoint.point.yp = point.y();
+            }
+            break;
         case QVariant::PointF:
             {
             bool ok;
-            QPointF point =
-                QDeclarativeStringConverters::pointFFromString(string, &ok);
-            float data[] = { float(point.x()), float(point.y()) };
-            int index = output->indexForFloat(data, 2);
-            if (type == QVariant::PointF)
-                instr.setType(QDeclarativeInstruction::StorePointF);
-            else
-                instr.setType(QDeclarativeInstruction::StorePoint);
-            instr.storeRealPair.propertyIndex = prop.propertyIndex();
-            instr.storeRealPair.valueIndex = index;
+            QPointF point = QDeclarativeStringConverters::pointFFromString(string, &ok);
+            instr.setType(QDeclarativeInstruction::StorePointF);
+            instr.storePointF.propertyIndex = prop.propertyIndex();
+            instr.storePointF.point.xp = point.x();
+            instr.storePointF.point.yp = point.y();
             }
             break;
         case QVariant::Size:
+            {
+            bool ok;
+            QSize size = QDeclarativeStringConverters::sizeFFromString(string, &ok).toSize();
+            instr.setType(QDeclarativeInstruction::StoreSize);
+            instr.storeSize.propertyIndex = prop.propertyIndex();
+            instr.storeSize.size.wd = size.width();
+            instr.storeSize.size.ht = size.height();
+            }
+            break;
         case QVariant::SizeF:
             {
             bool ok;
             QSizeF size = QDeclarativeStringConverters::sizeFFromString(string, &ok);
-            float data[] = { float(size.width()), float(size.height()) };
-            int index = output->indexForFloat(data, 2);
-            if (type == QVariant::SizeF)
-                instr.setType(QDeclarativeInstruction::StoreSizeF);
-            else
-                instr.setType(QDeclarativeInstruction::StoreSize);
-            instr.storeRealPair.propertyIndex = prop.propertyIndex();
-            instr.storeRealPair.valueIndex = index;
+            instr.setType(QDeclarativeInstruction::StoreSizeF);
+            instr.storeSizeF.propertyIndex = prop.propertyIndex();
+            instr.storeSizeF.size.wd = size.width();
+            instr.storeSizeF.size.ht = size.height();
             }
             break;
         case QVariant::Rect:
+            {
+            bool ok;
+            QRect rect = QDeclarativeStringConverters::rectFFromString(string, &ok).toRect();
+            instr.setType(QDeclarativeInstruction::StoreRect);
+            instr.storeRect.propertyIndex = prop.propertyIndex();
+            instr.storeRect.rect.x1 = rect.left();
+            instr.storeRect.rect.y1 = rect.top();
+            instr.storeRect.rect.x2 = rect.right();
+            instr.storeRect.rect.y2 = rect.bottom();
+            }
+            break;
         case QVariant::RectF:
             {
             bool ok;
             QRectF rect = QDeclarativeStringConverters::rectFFromString(string, &ok);
-            float data[] = { float(rect.x()), float(rect.y()),
-                             float(rect.width()), float(rect.height()) };
-            int index = output->indexForFloat(data, 4);
-            if (type == QVariant::RectF)
-                instr.setType(QDeclarativeInstruction::StoreRectF);
-            else
-                instr.setType(QDeclarativeInstruction::StoreRect);
-            instr.storeRect.propertyIndex = prop.propertyIndex();
-            instr.storeRect.valueIndex = index;
+            instr.setType(QDeclarativeInstruction::StoreRectF);
+            instr.storeRectF.propertyIndex = prop.propertyIndex();
+            instr.storeRectF.rect.xp = rect.left();
+            instr.storeRectF.rect.yp = rect.top();
+            instr.storeRectF.rect.w = rect.width();
+            instr.storeRectF.rect.h = rect.height();
             }
             break;
         case QVariant::Bool:
@@ -522,28 +532,21 @@ void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop,
         case QVariant::Vector3D:
             {
             bool ok;
-            QVector3D vector =
-                QDeclarativeStringConverters::vector3DFromString(string, &ok);
-            float data[] = { float(vector.x()), float(vector.y()), float(vector.z()) };
-            int index = output->indexForFloat(data, 3);
+            QVector3D vector = QDeclarativeStringConverters::vector3DFromString(string, &ok);
             instr.setType(QDeclarativeInstruction::StoreVector3D);
-            instr.storeRealPair.propertyIndex = prop.propertyIndex();
-            instr.storeRealPair.valueIndex = index;
+            instr.storeVector3D.propertyIndex = prop.propertyIndex();
+            instr.storeVector3D.vector.xp = vector.x();
+            instr.storeVector3D.vector.yp = vector.y();
+            instr.storeVector3D.vector.zp = vector.z();
             }
             break;
         default:
             {
             int t = prop.userType();
-            int index = output->customTypeData.count();
             instr.setType(QDeclarativeInstruction::AssignCustomType);
             instr.assignCustomType.propertyIndex = prop.propertyIndex();
-            instr.assignCustomType.valueIndex = index;
-            instr.assignCustomType.line = v->location.start.line;
-
-            QDeclarativeCompiledData::CustomTypeData data;
-            data.index = output->indexForString(string);
-            data.type = t;
-            output->customTypeData << data;
+            instr.assignCustomType.primitive = output->indexForString(string);
+            instr.assignCustomType.type = t;
             }
             break;
     }
@@ -557,9 +560,6 @@ void QDeclarativeCompiler::reset(QDeclarativeCompiledData *data)
 {
     data->types.clear();
     data->primitives.clear();
-    data->floatData.clear();
-    data->intData.clear();
-    data->customTypeData.clear();
     data->datas.clear();
     data->bytecode.clear();
 }
index 3697d3a..417a1fa 100644 (file)
@@ -102,21 +102,12 @@ public:
         QDeclarativePropertyCache *createPropertyCache(QDeclarativeEngine *);
     };
     QList<TypeReference> types;
-    struct CustomTypeData
-    {
-        int index;
-        int type;
-    };
 
     const QMetaObject *root;
     QAbstractDynamicMetaObject rootData;
     QDeclarativePropertyCache *rootPropertyCache;
     QList<QString> primitives;
-    QList<float> floatData;
-    QList<int> intData;
-    QList<CustomTypeData> customTypeData;
     QList<QByteArray> datas;
-    QList<QDeclarativeParser::Location> locations;
     QByteArray bytecode;
     QList<QScriptProgram *> cachedPrograms;
     QList<QScriptValue *> cachedClosures;
@@ -144,10 +135,6 @@ private:
 
     int indexForString(const QString &);
     int indexForByteArray(const QByteArray &);
-    int indexForFloat(float *, int);
-    int indexForInt(int *, int);
-    int indexForLocation(const QDeclarativeParser::Location &);
-    int indexForLocation(const QDeclarativeParser::LocationSpan &);
     int indexForUrl(const QUrl &);
 };
 
index 202e646..f664913 100644 (file)
@@ -106,31 +106,31 @@ void QDeclarativeCompiledData::dump(QDeclarativeInstruction *instr, int idx)
         qWarning().nospace() << idx << "\t\t" << "STORE_DATE\t\t" << instr->storeDate.propertyIndex << "\t" << instr->storeDate.value;
         break;
     case QDeclarativeInstruction::StoreTime:
-        qWarning().nospace() << idx << "\t\t" << "STORE_TIME\t\t" << instr->storeTime.propertyIndex << "\t" << instr->storeTime.valueIndex;
+        qWarning().nospace() << idx << "\t\t" << "STORE_TIME\t\t" << instr->storeTime.propertyIndex;
         break;
     case QDeclarativeInstruction::StoreDateTime:
-        qWarning().nospace() << idx << "\t\t" << "STORE_DATETIME\t\t" << instr->storeDateTime.propertyIndex << "\t" << instr->storeDateTime.valueIndex;
+        qWarning().nospace() << idx << "\t\t" << "STORE_DATETIME\t\t" << instr->storeDateTime.propertyIndex;
         break;
     case QDeclarativeInstruction::StorePoint:
-        qWarning().nospace() << idx << "\t\t" << "STORE_POINT\t\t" << instr->storeRealPair.propertyIndex << "\t" << instr->storeRealPair.valueIndex;
+        qWarning().nospace() << idx << "\t\t" << "STORE_POINT\t\t" << instr->storePoint.propertyIndex << "\t" << instr->storePoint.point.xp << "\t" << instr->storePoint.point.yp;
         break;
     case QDeclarativeInstruction::StorePointF:
-        qWarning().nospace() << idx << "\t\t" << "STORE_POINTF\t\t" << instr->storeRealPair.propertyIndex << "\t" << instr->storeRealPair.valueIndex;
+        qWarning().nospace() << idx << "\t\t" << "STORE_POINTF\t\t" << instr->storePointF.propertyIndex << "\t" << instr->storePointF.point.xp << "\t" << instr->storePointF.point.yp;
         break;
     case QDeclarativeInstruction::StoreSize:
-        qWarning().nospace() << idx << "\t\t" << "STORE_SIZE\t\t" << instr->storeRealPair.propertyIndex << "\t" << instr->storeRealPair.valueIndex;
+        qWarning().nospace() << idx << "\t\t" << "STORE_SIZE\t\t" << instr->storeSize.propertyIndex << "\t" << instr->storeSize.size.wd << "\t" << instr->storeSize.size.ht;
         break;
     case QDeclarativeInstruction::StoreSizeF:
-        qWarning().nospace() << idx << "\t\t" << "STORE_SIZEF\t\t" << instr->storeRealPair.propertyIndex << "\t" << instr->storeRealPair.valueIndex;
+        qWarning().nospace() << idx << "\t\t" << "STORE_SIZEF\t\t" << instr->storeSizeF.propertyIndex << "\t" << instr->storeSizeF.size.wd << "\t" << instr->storeSizeF.size.ht;
         break;
     case QDeclarativeInstruction::StoreRect:
-        qWarning().nospace() << idx << "\t\t" << "STORE_RECT\t\t" << instr->storeRect.propertyIndex << "\t" << instr->storeRect.valueIndex;
+        qWarning().nospace() << idx << "\t\t" << "STORE_RECT\t\t" << instr->storeRect.propertyIndex << "\t" << instr->storeRect.rect.x1 << "\t" << instr->storeRect.rect.y1 << "\t" << instr->storeRect.rect.x2 << "\t" << instr->storeRect.rect.y2;
         break;
     case QDeclarativeInstruction::StoreRectF:
-        qWarning().nospace() << idx << "\t\t" << "STORE_RECTF\t\t" << instr->storeRect.propertyIndex << "\t" << instr->storeRect.valueIndex;
+        qWarning().nospace() << idx << "\t\t" << "STORE_RECTF\t\t" << instr->storeRectF.propertyIndex << "\t" << instr->storeRectF.rect.xp << "\t" << instr->storeRectF.rect.yp << "\t" << instr->storeRectF.rect.w << "\t" << instr->storeRectF.rect.h;
         break;
     case QDeclarativeInstruction::StoreVector3D:
-        qWarning().nospace() << idx << "\t\t" << "STORE_VECTOR3D\t\t" << instr->storeVector3D.propertyIndex << "\t" << instr->storeVector3D.valueIndex;
+        qWarning().nospace() << idx << "\t\t" << "STORE_VECTOR3D\t\t" << instr->storeVector3D.propertyIndex << "\t" << instr->storeVector3D.vector.xp << "\t" << instr->storeVector3D.vector.yp << "\t" << instr->storeVector3D.vector.zp;
         break;
     case QDeclarativeInstruction::StoreVariant:
         qWarning().nospace() << idx << "\t\t" << "STORE_VARIANT\t\t" << instr->storeString.propertyIndex << "\t" << instr->storeString.value << "\t\t" << primitives.at(instr->storeString.value);
@@ -166,7 +166,7 @@ void QDeclarativeCompiledData::dump(QDeclarativeInstruction *instr, int idx)
         qWarning().nospace() << idx << "\t\t" << "ASSIGN_SIGNAL_OBJECT\t" << instr->assignSignalObject.signal << "\t\t\t" << datas.at(instr->assignSignalObject.signal);
         break;
     case QDeclarativeInstruction::AssignCustomType:
-        qWarning().nospace() << idx << "\t\t" << "ASSIGN_CUSTOMTYPE\t" << instr->assignCustomType.propertyIndex << "\t" << instr->assignCustomType.valueIndex;
+        qWarning().nospace() << idx << "\t\t" << "ASSIGN_CUSTOMTYPE\t" << instr->assignCustomType.propertyIndex << "\t" << instr->assignCustomType.primitive << "\t" << instr->assignCustomType.type;
         break;
     case QDeclarativeInstruction::StoreBinding:
         qWarning().nospace() << idx << "\t\t" << "STORE_BINDING\t" << instr->assignBinding.property << "\t" << instr->assignBinding.value << "\t" << instr->assignBinding.context;
index b436ce5..cbf34a8 100644 (file)
@@ -81,12 +81,12 @@ QT_BEGIN_NAMESPACE
     F(StoreDate, storeDate) \
     F(StoreTime, storeTime) \
     F(StoreDateTime, storeDateTime) \
-    F(StorePoint, storeRealPair) \
-    F(StorePointF, storeRealPair) \
-    F(StoreSize, storeRealPair) \
-    F(StoreSizeF, storeRealPair) \
+    F(StorePoint, storePoint) \
+    F(StorePointF, storePointF) \
+    F(StoreSize, storeSize) \
+    F(StoreSizeF, storeSizeF) \
     F(StoreRect, storeRect) \
-    F(StoreRectF, storeRect) \
+    F(StoreRectF, storeRectF) \
     F(StoreVector3D, storeVector3D) \
     F(StoreObject, storeObject) \
     F(AssignCustomType, assignCustomType) \
@@ -268,27 +268,45 @@ union QDeclarativeInstruction
     struct instr_storeTime {
         QML_INSTR_HEADER
         int propertyIndex;
-        int valueIndex;
+        struct QTime {
+            int mds;
+#if defined(Q_OS_WINCE)
+            int startTick;
+#endif
+        } time;
     };
     struct instr_storeDateTime {
         QML_INSTR_HEADER
         int propertyIndex;
-        int valueIndex;
-    };
-    struct instr_storeRealPair {
-        QML_INSTR_HEADER
-        int propertyIndex;
-        int valueIndex;
+        int date;
+        instr_storeTime::QTime time;
     };
     struct instr_storeRect {
         QML_INSTR_HEADER
         int propertyIndex;
-        int valueIndex;
+        struct QRect {
+#if defined(Q_OS_MAC)
+            int y1;
+            int x1;
+            int y2;
+            int x2;
+#else
+            int x1;
+            int y1;
+            int x2;
+            int y2;
+#endif
+        } rect;
     };
-    struct instr_storeVector3D {
+    struct instr_storeRectF {
         QML_INSTR_HEADER
         int propertyIndex;
-        int valueIndex;
+        struct QRectF {
+            qreal xp;
+            qreal yp;
+            qreal w;
+            qreal h;
+        } rect;
     };
     struct instr_storeObject {
         QML_INSTR_HEADER
@@ -298,7 +316,8 @@ union QDeclarativeInstruction
     struct instr_assignCustomType {
         QML_INSTR_HEADER
         int propertyIndex;
-        int valueIndex;
+        int primitive;
+        int type;
         ushort line;
     };
     struct instr_storeSignal {
@@ -335,6 +354,52 @@ union QDeclarativeInstruction
         QML_INSTR_HEADER
         ushort line;
     };
+    struct instr_storePoint {
+        QML_INSTR_HEADER
+        int propertyIndex;
+        struct QPoint {
+#if defined(Q_OS_MAC)
+            int yp;
+            int xp;
+#else
+            int xp;
+            int yp;
+#endif
+        } point;
+    };
+    struct instr_storePointF {
+        QML_INSTR_HEADER
+        int propertyIndex;
+        struct QPointF {
+            qreal xp;
+            qreal yp;
+        } point;
+    };
+    struct instr_storeSize {
+        QML_INSTR_HEADER
+        int propertyIndex;
+        struct QSize {
+            int wd;
+            int ht;
+        } size;
+    };
+    struct instr_storeSizeF {
+        QML_INSTR_HEADER
+        int propertyIndex;
+        struct QSizeF {
+            qreal wd;
+            qreal ht;
+        } size;
+    };
+    struct instr_storeVector3D {
+        QML_INSTR_HEADER
+        int propertyIndex;
+        struct QVector3D {
+            float xp;
+            float yp;
+            float zp;
+        } vector;
+    };
 
     instr_common common;
     instr_init init;
@@ -362,8 +427,12 @@ union QDeclarativeInstruction
     instr_storeDate storeDate;
     instr_storeTime storeTime;
     instr_storeDateTime storeDateTime;
-    instr_storeRealPair storeRealPair;
+    instr_storePoint storePoint;
+    instr_storePointF storePointF;
+    instr_storeSize storeSize;
+    instr_storeSizeF storeSizeF;
     instr_storeRect storeRect;
+    instr_storeRectF storeRectF;
     instr_storeVector3D storeVector3D;
     instr_storeObject storeObject;
     instr_assignCustomType assignCustomType;
index 03abae7..13539a0 100644 (file)
@@ -161,9 +161,6 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
     const QList<QDeclarativeCompiledData::TypeReference> &types = comp->types;
     const QList<QString> &primitives = comp->primitives;
     const QList<QByteArray> &datas = comp->datas;
-    const QList<QDeclarativeCompiledData::CustomTypeData> &customTypeData = comp->customTypeData;
-    const QList<int> &intData = comp->intData;
-    const QList<float> &floatData = comp->floatData;
     const QList<QDeclarativePropertyCache *> &propertyCaches = comp->propertyCaches;
     const QList<QDeclarativeScriptData *> &scripts = comp->scripts;
     const QList<QUrl> &urls = comp->urls;
@@ -475,12 +472,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
             QObject *target = stack.top();
             CLEAN_PROPERTY(target, instr.propertyIndex);
 
-            QTime t;
-            t.setHMS(intData.at(instr.valueIndex),
-                     intData.at(instr.valueIndex+1),
-                     intData.at(instr.valueIndex+2),
-                     intData.at(instr.valueIndex+3));
-            void *a[] = { &t, 0, &status, &flags };
+            QTime *t = (QTime *)&instr.time;
+            void *a[] = { t, 0, &status, &flags };
             QMetaObject::metacall(target, QMetaObject::WriteProperty, 
                                   instr.propertyIndex, a);
         QML_END_INSTR(StoreTime)
@@ -489,12 +482,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
             QObject *target = stack.top();
             CLEAN_PROPERTY(target, instr.propertyIndex);
 
-            QTime t;
-            t.setHMS(intData.at(instr.valueIndex+1),
-                     intData.at(instr.valueIndex+2),
-                     intData.at(instr.valueIndex+3),
-                     intData.at(instr.valueIndex+4));
-            QDateTime dt(QDate::fromJulianDay(intData.at(instr.valueIndex)), t);
+            QTime *t = (QTime *)&instr.time;
+            QDateTime dt(QDate::fromJulianDay(instr.date), *t);
             void *a[] = { &dt, 0, &status, &flags };
             QMetaObject::metacall(target, QMetaObject::WriteProperty,
                                   instr.propertyIndex, a);
@@ -504,9 +493,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
             QObject *target = stack.top();
             CLEAN_PROPERTY(target, instr.propertyIndex);
 
-            QPoint p = QPointF(floatData.at(instr.valueIndex),
-                               floatData.at(instr.valueIndex+1)).toPoint();
-            void *a[] = { &p, 0, &status, &flags };
+            QPoint *p = (QPoint *)&instr.point;
+            void *a[] = { p, 0, &status, &flags };
             QMetaObject::metacall(target, QMetaObject::WriteProperty, 
                                   instr.propertyIndex, a);
         QML_END_INSTR(StorePoint)
@@ -515,9 +503,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
             QObject *target = stack.top();
             CLEAN_PROPERTY(target, instr.propertyIndex);
 
-            QPointF p(floatData.at(instr.valueIndex),
-                      floatData.at(instr.valueIndex+1));
-            void *a[] = { &p, 0, &status, &flags };
+            QPointF *p = (QPointF *)&instr.point;
+            void *a[] = { p, 0, &status, &flags };
             QMetaObject::metacall(target, QMetaObject::WriteProperty, 
                                   instr.propertyIndex, a);
         QML_END_INSTR(StorePointF)
@@ -526,9 +513,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
             QObject *target = stack.top();
             CLEAN_PROPERTY(target, instr.propertyIndex);
 
-            QSize p = QSizeF(floatData.at(instr.valueIndex),
-                             floatData.at(instr.valueIndex+1)).toSize();
-            void *a[] = { &p, 0, &status, &flags };
+            QSize *s = (QSize *)&instr.size;
+            void *a[] = { s, 0, &status, &flags };
             QMetaObject::metacall(target, QMetaObject::WriteProperty, 
                                   instr.propertyIndex, a);
         QML_END_INSTR(StoreSize)
@@ -537,9 +523,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
             QObject *target = stack.top();
             CLEAN_PROPERTY(target, instr.propertyIndex);
 
-            QSizeF s(floatData.at(instr.valueIndex),
-                     floatData.at(instr.valueIndex+1));
-            void *a[] = { &s, 0, &status, &flags };
+            QSizeF *s = (QSizeF *)&instr.size;
+            void *a[] = { s, 0, &status, &flags };
             QMetaObject::metacall(target, QMetaObject::WriteProperty, 
                                   instr.propertyIndex, a);
         QML_END_INSTR(StoreSizeF)
@@ -548,11 +533,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
             QObject *target = stack.top();
             CLEAN_PROPERTY(target, instr.propertyIndex);
 
-            QRect r = QRectF(floatData.at(instr.valueIndex),
-                             floatData.at(instr.valueIndex+1),
-                             floatData.at(instr.valueIndex+2),
-                             floatData.at(instr.valueIndex+3)).toRect();
-            void *a[] = { &r, 0, &status, &flags };
+            QRect *r = (QRect *)&instr.rect;
+            void *a[] = { r, 0, &status, &flags };
             QMetaObject::metacall(target, QMetaObject::WriteProperty, 
                                   instr.propertyIndex, a);
         QML_END_INSTR(StoreRect)
@@ -561,11 +543,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
             QObject *target = stack.top();
             CLEAN_PROPERTY(target, instr.propertyIndex);
 
-            QRectF r(floatData.at(instr.valueIndex),
-                     floatData.at(instr.valueIndex+1),
-                     floatData.at(instr.valueIndex+2),
-                     floatData.at(instr.valueIndex+3));
-            void *a[] = { &r, 0, &status, &flags };
+            QRectF *r = (QRectF *)&instr.rect;
+            void *a[] = { r, 0, &status, &flags };
             QMetaObject::metacall(target, QMetaObject::WriteProperty, 
                                   instr.propertyIndex, a);
         QML_END_INSTR(StoreRectF)
@@ -574,10 +553,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
             QObject *target = stack.top();
             CLEAN_PROPERTY(target, instr.propertyIndex);
 
-            QVector3D p(floatData.at(instr.valueIndex),
-                        floatData.at(instr.valueIndex+1),
-                        floatData.at(instr.valueIndex+2));
-            void *a[] = { &p, 0, &status, &flags };
+            QVector3D *v = (QVector3D *)&instr.vector;
+            void *a[] = { v, 0, &status, &flags };
             QMetaObject::metacall(target, QMetaObject::WriteProperty, 
                                   instr.propertyIndex, a);
         QML_END_INSTR(StoreVector3D)
@@ -596,15 +573,14 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
             QObject *target = stack.top();
             CLEAN_PROPERTY(target, instr.propertyIndex);
 
-            QDeclarativeCompiledData::CustomTypeData data = customTypeData.at(instr.valueIndex);
-            const QString &primitive = primitives.at(data.index);
-            QDeclarativeMetaType::StringConverter converter = 
-                QDeclarativeMetaType::customStringConverter(data.type);
+            const QString &primitive = primitives.at(instr.primitive);
+            int type = instr.type;
+            QDeclarativeMetaType::StringConverter converter = QDeclarativeMetaType::customStringConverter(type);
             QVariant v = (*converter)(primitive);
 
             QMetaProperty prop = 
                     target->metaObject()->property(instr.propertyIndex);
-            if (v.isNull() || ((int)prop.type() != data.type && prop.userType() != data.type)) 
+            if (v.isNull() || ((int)prop.type() != type && prop.userType() != type)) 
                 VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot assign value %1 to property %2").arg(primitive).arg(QString::fromUtf8(prop.name())), instr.line);
 
             void *a[] = { (void *)v.data(), 0, &status, &flags };
index 789b395..17f27f2 100644 (file)
@@ -55,6 +55,15 @@ public:
 
 private slots:
     void dump();
+
+    void point();
+    void pointf();
+    void size();
+    void sizef();
+    void rect();
+    void rectf();
+    void vector3d();
+    void time();
 };
 
 static QStringList messages;
@@ -198,7 +207,6 @@ void tst_qdeclarativeinstruction::dump()
         QDeclarativeInstruction i;
         i.setType(QDeclarativeInstruction::StoreTime);
         i.storeTime.propertyIndex = 11;
-        i.storeTime.valueIndex = 33;
         data->addInstruction(i);
     }
 
@@ -206,39 +214,42 @@ void tst_qdeclarativeinstruction::dump()
         QDeclarativeInstruction i;
         i.setType(QDeclarativeInstruction::StoreDateTime);
         i.storeDateTime.propertyIndex = 12;
-        i.storeDateTime.valueIndex = 44;
         data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
         i.setType(QDeclarativeInstruction::StorePoint);
-        i.storeRealPair.propertyIndex = 13;
-        i.storeRealPair.valueIndex = 3;
+        i.storePoint.propertyIndex = 13;
+        i.storePoint.point.xp = 3;
+        i.storePoint.point.yp = 7;
         data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
         i.setType(QDeclarativeInstruction::StorePointF);
-        i.storeRealPair.propertyIndex = 14;
-        i.storeRealPair.valueIndex = 9;
+        i.storePointF.propertyIndex = 13;
+        i.storePointF.point.xp = 3;
+        i.storePointF.point.yp = 7;
         data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
         i.setType(QDeclarativeInstruction::StoreSize);
-        i.storeRealPair.propertyIndex = 15;
-        i.storeRealPair.valueIndex = 8;
+        i.storeSize.propertyIndex = 15;
+        i.storeSize.size.wd = 8;
+        i.storeSize.size.ht = 11;
         data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
         i.setType(QDeclarativeInstruction::StoreSizeF);
-        i.storeRealPair.propertyIndex = 16;
-        i.storeRealPair.valueIndex = 99;
+        i.storeSizeF.propertyIndex = 15;
+        i.storeSizeF.size.wd = 8;
+        i.storeSizeF.size.ht = 11;
         data->addInstruction(i);
     }
 
@@ -246,15 +257,21 @@ void tst_qdeclarativeinstruction::dump()
         QDeclarativeInstruction i;
         i.setType(QDeclarativeInstruction::StoreRect);
         i.storeRect.propertyIndex = 17;
-        i.storeRect.valueIndex = 2;
+        i.storeRect.rect.x1 = 7;
+        i.storeRect.rect.y1 = 9;
+        i.storeRect.rect.x2 = 11;
+        i.storeRect.rect.y2 = 13;
         data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
         i.setType(QDeclarativeInstruction::StoreRectF);
-        i.storeRect.propertyIndex = 18;
-        i.storeRect.valueIndex = 19;
+        i.storeRectF.propertyIndex = 18;
+        i.storeRectF.rect.xp = 11.3;
+        i.storeRectF.rect.yp = 9.8;
+        i.storeRectF.rect.w = 3;
+        i.storeRectF.rect.h = 2.1;
         data->addInstruction(i);
     }
 
@@ -262,7 +279,9 @@ void tst_qdeclarativeinstruction::dump()
         QDeclarativeInstruction i;
         i.setType(QDeclarativeInstruction::StoreVector3D);
         i.storeVector3D.propertyIndex = 19;
-        i.storeVector3D.valueIndex = 9;
+        i.storeVector3D.vector.xp = 9;
+        i.storeVector3D.vector.yp = 3;
+        i.storeVector3D.vector.zp = 92;
         data->addInstruction(i);
     }
 
@@ -329,7 +348,8 @@ void tst_qdeclarativeinstruction::dump()
         QDeclarativeInstruction i;
         i.setType(QDeclarativeInstruction::AssignCustomType);
         i.assignCustomType.propertyIndex = 25;
-        i.assignCustomType.valueIndex = 4;
+        i.assignCustomType.primitive = 6;
+        i.assignCustomType.type = 9;
         data->addInstruction(i);
     }
 
@@ -501,15 +521,15 @@ void tst_qdeclarativeinstruction::dump()
         << "11\t\tSTORE_URL\t\t8\t0\t\tQUrl(\"http://www.nokia.com\") "
         << "12\t\tSTORE_COLOR\t\t9\t\t\t\"ff00ff00\""
         << "13\t\tSTORE_DATE\t\t10\t9"
-        << "14\t\tSTORE_TIME\t\t11\t33"
-        << "15\t\tSTORE_DATETIME\t\t12\t44"
-        << "16\t\tSTORE_POINT\t\t13\t3"
-        << "17\t\tSTORE_POINTF\t\t14\t9"
-        << "18\t\tSTORE_SIZE\t\t15\t8"
-        << "19\t\tSTORE_SIZEF\t\t16\t99"
-        << "20\t\tSTORE_RECT\t\t17\t2"
-        << "21\t\tSTORE_RECTF\t\t18\t19"
-        << "22\t\tSTORE_VECTOR3D\t\t19\t9"
+        << "14\t\tSTORE_TIME\t\t11"
+        << "15\t\tSTORE_DATETIME\t\t12"
+        << "16\t\tSTORE_POINT\t\t13\t3\t7"
+        << "17\t\tSTORE_POINTF\t\t13\t3\t7"
+        << "18\t\tSTORE_SIZE\t\t15\t8\t11"
+        << "19\t\tSTORE_SIZEF\t\t15\t8\t11"
+        << "20\t\tSTORE_RECT\t\t17\t7\t9\t11\t13"
+        << "21\t\tSTORE_RECTF\t\t18\t11.3\t9.8\t3\t2.1"
+        << "22\t\tSTORE_VECTOR3D\t\t19\t9\t3\t92"
         << "23\t\tSTORE_VARIANT\t\t20\t2\t\t\"color(1, 1, 1, 1)\""
         << "24\t\tSTORE_OBJECT\t\t21"
         << "25\t\tSTORE_VARIANT_OBJECT\t22"
@@ -517,7 +537,7 @@ void tst_qdeclarativeinstruction::dump()
         << "27\t\tSTORE_SIGNAL\t\t2\t3\t\t\"console.log(1921)\""
         << "28\t\tSTORE_SCRIPT_STRING\t24\t3\t1"
         << "29\t\tASSIGN_SIGNAL_OBJECT\t0\t\t\t\"mySignal\""
-        << "30\t\tASSIGN_CUSTOMTYPE\t25\t4"
+        << "30\t\tASSIGN_CUSTOMTYPE\t25\t6\t9"
         << "31\t\tSTORE_BINDING\t26\t3\t2"
         << "32\t\tSTORE_COMPILED_BINDING\t27\t2\t4"
         << "33\t\tSTORE_VALUE_SOURCE\t29\t4"
@@ -553,6 +573,120 @@ void tst_qdeclarativeinstruction::dump()
     data->release();
 }
 
+void tst_qdeclarativeinstruction::point()
+{
+    QCOMPARE(sizeof(QDeclarativeInstruction::instr_storePoint::QPoint), sizeof(QPoint));
+    QCOMPARE(Q_ALIGNOF(QDeclarativeInstruction::instr_storePoint::QPoint), Q_ALIGNOF(QPoint));
+
+    QDeclarativeInstruction i;
+    i.storePoint.point.xp = 8;
+    i.storePoint.point.yp = 11;
+
+    const QPoint &point = (const QPoint &)(i.storePoint.point);
+    QCOMPARE(point.x(), 8);
+    QCOMPARE(point.y(), 11);
+}
+
+void tst_qdeclarativeinstruction::pointf()
+{
+    QCOMPARE(sizeof(QDeclarativeInstruction::instr_storePointF::QPointF), sizeof(QPointF));
+    QCOMPARE(Q_ALIGNOF(QDeclarativeInstruction::instr_storePointF::QPointF), Q_ALIGNOF(QPointF));
+
+    QDeclarativeInstruction i;
+    i.storePointF.point.xp = 8.7;
+    i.storePointF.point.yp = 11.3;
+
+    const QPointF &point = (const QPointF &)(i.storePointF.point);
+    QCOMPARE(point.x(), 8.7);
+    QCOMPARE(point.y(), 11.3);
+}
+
+void tst_qdeclarativeinstruction::size()
+{
+    QCOMPARE(sizeof(QDeclarativeInstruction::instr_storeSize::QSize), sizeof(QSize));
+    QCOMPARE(Q_ALIGNOF(QDeclarativeInstruction::instr_storeSize::QSize), Q_ALIGNOF(QSize));
+
+    QDeclarativeInstruction i;
+    i.storeSize.size.wd = 8;
+    i.storeSize.size.ht = 11;
+
+    const QSize &size = (const QSize &)(i.storeSize.size);
+    QCOMPARE(size.width(), 8);
+    QCOMPARE(size.height(), 11);
+}
+
+void tst_qdeclarativeinstruction::sizef()
+{
+    QCOMPARE(sizeof(QDeclarativeInstruction::instr_storeSizeF::QSizeF), sizeof(QSizeF));
+    QCOMPARE(Q_ALIGNOF(QDeclarativeInstruction::instr_storeSizeF::QSizeF), Q_ALIGNOF(QSizeF));
+
+    QDeclarativeInstruction i;
+    i.storeSizeF.size.wd = 8;
+    i.storeSizeF.size.ht = 11;
+
+    const QSizeF &size = (const QSizeF &)(i.storeSizeF.size);
+    QCOMPARE(size.width(), (qreal)8);
+    QCOMPARE(size.height(), (qreal)11);
+}
+
+void tst_qdeclarativeinstruction::rect()
+{
+    QCOMPARE(sizeof(QDeclarativeInstruction::instr_storeRect::QRect), sizeof(QRect));
+    QCOMPARE(Q_ALIGNOF(QDeclarativeInstruction::instr_storeRect::QRect), Q_ALIGNOF(QRect));
+
+    QDeclarativeInstruction i;
+    i.storeRect.rect.x1 = 8;
+    i.storeRect.rect.y1 = 11;
+    i.storeRect.rect.x2 = 13;
+    i.storeRect.rect.y2 = 19;
+
+    const QRect &rect = (const QRect &)(i.storeRect.rect);
+    QCOMPARE(rect.left(), 8);
+    QCOMPARE(rect.top(), 11);
+    QCOMPARE(rect.right(), 13);
+    QCOMPARE(rect.bottom(), 19);
+}
+
+void tst_qdeclarativeinstruction::rectf()
+{
+    QCOMPARE(sizeof(QDeclarativeInstruction::instr_storeRectF::QRectF), sizeof(QRectF));
+    QCOMPARE(Q_ALIGNOF(QDeclarativeInstruction::instr_storeRectF::QRectF), Q_ALIGNOF(QRectF));
+
+    QDeclarativeInstruction i;
+    i.storeRectF.rect.xp = 8;
+    i.storeRectF.rect.yp = 11;
+    i.storeRectF.rect.w = 13;
+    i.storeRectF.rect.h = 19;
+
+    const QRectF &rect = (const QRectF &)(i.storeRectF.rect);
+    QCOMPARE(rect.left(), (qreal)8);
+    QCOMPARE(rect.top(), (qreal)11);
+    QCOMPARE(rect.width(), (qreal)13);
+    QCOMPARE(rect.height(), (qreal)19);
+}
+
+void tst_qdeclarativeinstruction::vector3d()
+{
+    QCOMPARE(sizeof(QDeclarativeInstruction::instr_storeVector3D::QVector3D), sizeof(QVector3D));
+    QCOMPARE(Q_ALIGNOF(QDeclarativeInstruction::instr_storeVector3D::QVector3D), Q_ALIGNOF(QVector3D));
+
+    QDeclarativeInstruction i;
+    i.storeVector3D.vector.xp = 8.2;
+    i.storeVector3D.vector.yp = 99.3;
+    i.storeVector3D.vector.zp = 12.0;
+
+    const QVector3D &vector = (const QVector3D &)(i.storeVector3D.vector);
+    QCOMPARE(vector.x(), (qreal)(float)8.2);
+    QCOMPARE(vector.y(), (qreal)(float)99.3);
+    QCOMPARE(vector.z(), (qreal)(float)12.0);
+}
+
+void tst_qdeclarativeinstruction::time()
+{
+    QCOMPARE(sizeof(QDeclarativeInstruction::instr_storeTime::QTime), sizeof(QTime));
+    QCOMPARE(Q_ALIGNOF(QDeclarativeInstruction::instr_storeTime::QTime), Q_ALIGNOF(QTime));
+}
+
 QTEST_MAIN(tst_qdeclarativeinstruction)
 
 #include "tst_qdeclarativeinstruction.moc"
index 42a02ed..f9684b9 100644 (file)
@@ -549,11 +549,11 @@ void tst_qdeclarativelanguage::assignBasicTypes()
     QCOMPARE(object->timeProperty(), QTime(11, 11, 32));
     QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1)));
     QCOMPARE(object->pointProperty(), QPoint(99,13));
-    QCOMPARE(object->pointFProperty(), QPointF((float)-10.1, (float)12.3));
+    QCOMPARE(object->pointFProperty(), QPointF(-10.1, 12.3));
     QCOMPARE(object->sizeProperty(), QSize(99, 13));
-    QCOMPARE(object->sizeFProperty(), QSizeF((float)0.1, (float)0.2));
+    QCOMPARE(object->sizeFProperty(), QSizeF(0.1, 0.2));
     QCOMPARE(object->rectProperty(), QRect(9, 7, 100, 200));
-    QCOMPARE(object->rectFProperty(), QRectF((float)1000.1, (float)-10.9, (float)400, (float)90.99));
+    QCOMPARE(object->rectFProperty(), QRectF(1000.1, -10.9, 400, 90.99));
     QCOMPARE(object->boolProperty(), true);
     QCOMPARE(object->variantProperty(), QVariant("Hello World!"));
     QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2));