Merge PropertyCache::Data and ValueTypeData
authorAaron Kennedy <aaron.kennedy@nokia.com>
Tue, 11 Oct 2011 01:09:17 +0000 (11:09 +1000)
committerQt by Nokia <qt-info@nokia.com>
Sun, 16 Oct 2011 23:05:43 +0000 (01:05 +0200)
Change-Id: I22cbb159d009151dd77ecbcdad16f27ecb9d6dba
Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
15 files changed:
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/qdeclarativeproperty.cpp
src/declarative/qml/qdeclarativeproperty_p.h
src/declarative/qml/qdeclarativepropertycache_p.h
src/declarative/qml/qdeclarativevme.cpp
src/declarative/qml/v8/qv8bindings.cpp
src/declarative/qml/v8/qv8bindings_p.h
src/declarative/qml/v8/qv8qobjectwrapper.cpp
src/declarative/qml/v8/qv8valuetypewrapper.cpp
tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp
tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp

index 41e46e7..32c6546 100644 (file)
@@ -1870,7 +1870,7 @@ void QDeclarativeCompiler::genPropertyAssignment(QDeclarativeScript::Property *p
                 store.property = genValueTypeData(prop, valueTypeProperty);
                 store.owner = 1;
             } else {
-                store.property = genPropertyData(prop);
+                store.property = prop->core;
                 store.owner = 0;
             }
             QDeclarativeType *valueType = toQmlType(v->object);
@@ -1885,7 +1885,7 @@ void QDeclarativeCompiler::genPropertyAssignment(QDeclarativeScript::Property *p
                 store.property = genValueTypeData(prop, valueTypeProperty);
                 store.owner = 1;
             } else {
-                store.property = genPropertyData(prop);
+                store.property = prop->core;
                 store.owner = 0;
             }
             QDeclarativeType *valueType = toQmlType(v->object);
@@ -3226,7 +3226,7 @@ void QDeclarativeCompiler::genBindingAssignment(QDeclarativeScript::Value *bindi
         if (ref.bindingContext.owner) {
             store.property = genValueTypeData(prop, valueTypeProperty);
         } else {
-            store.property = genPropertyData(prop);
+            store.property = prop->core;
         }
 
         output->addInstruction(store);
@@ -3248,7 +3248,7 @@ void QDeclarativeCompiler::genBindingAssignment(QDeclarativeScript::Value *bindi
         if (ref.bindingContext.owner) {
             store.assignBinding.property = genValueTypeData(prop, valueTypeProperty);
         } else {
-            store.assignBinding.property = genPropertyData(prop);
+            store.assignBinding.property = prop->core;
         }
         output->addInstructionHelper(
             !prop->isAlias ? QDeclarativeInstruction::StoreBinding
@@ -3271,22 +3271,14 @@ int QDeclarativeCompiler::genContextCache()
     return output->contextCaches.count() - 1;
 }
 
-int QDeclarativeCompiler::genValueTypeData(QDeclarativeScript::Property *valueTypeProp, 
-                                  QDeclarativeScript::Property *prop)
+QDeclarativePropertyCache::Data 
+QDeclarativeCompiler::genValueTypeData(QDeclarativeScript::Property *valueTypeProp, 
+                                       QDeclarativeScript::Property *prop)
 {
     typedef QDeclarativePropertyPrivate QDPP;
-    QByteArray data = QDPP::saveValueType(prop->parent->metaObject(), prop->index, 
-                                          enginePrivate->valueTypes[prop->type]->metaObject(), 
-                                          valueTypeProp->index, engine);
-
-    return output->indexForByteArray(data);
-}
-
-int QDeclarativeCompiler::genPropertyData(QDeclarativeScript::Property *prop)
-{
-    typedef QDeclarativePropertyPrivate QDPP;
-    QByteArray data = QDPP::saveProperty(&prop->core);
-    return output->indexForByteArray(data);
+    return QDPP::saveValueType(prop->parent->metaObject(), prop->index, 
+                               enginePrivate->valueTypes[prop->type]->metaObject(), 
+                               valueTypeProp->index, engine);
 }
 
 bool QDeclarativeCompiler::completeComponentBuild()
index 5e3ad03..86471a6 100644 (file)
@@ -373,8 +373,8 @@ private:
                               QDeclarativeScript::Property *valueTypeProperty = 0);
     int genContextCache();
 
-    int genValueTypeData(QDeclarativeScript::Property *prop, QDeclarativeScript::Property *valueTypeProp);
-    int genPropertyData(QDeclarativeScript::Property *prop);
+    QDeclarativePropertyCache::Data genValueTypeData(QDeclarativeScript::Property *prop, 
+                                                     QDeclarativeScript::Property *valueTypeProp);
 
     int componentTypeRef();
 
index 3d505c7..c47f68f 100644 (file)
@@ -184,22 +184,22 @@ void QDeclarativeCompiledData::dump(QDeclarativeInstruction *instr, int idx)
         qWarning().nospace() << idx << "\t\t" << "INIT_V8_BINDING\t" << instr->initV8Bindings.program << "\t" << instr->initV8Bindings.programIndex << "\t" << instr->initV8Bindings.line;
         break;
     case QDeclarativeInstruction::StoreBinding:
-        qWarning().nospace() << idx << "\t\t" << "STORE_BINDING\t" << instr->assignBinding.property << "\t" << instr->assignBinding.value << "\t" << instr->assignBinding.context;
+        qWarning().nospace() << idx << "\t\t" << "STORE_BINDING\t" << instr->assignBinding.property.coreIndex << "\t" << instr->assignBinding.value << "\t" << instr->assignBinding.context;
         break;
     case QDeclarativeInstruction::StoreBindingOnAlias:
-        qWarning().nospace() << idx << "\t\t" << "STORE_BINDING_ALIAS\t" << instr->assignBinding.property << "\t" << instr->assignBinding.value << "\t" << instr->assignBinding.context;
+        qWarning().nospace() << idx << "\t\t" << "STORE_BINDING_ALIAS\t" << instr->assignBinding.property.coreIndex << "\t" << instr->assignBinding.value << "\t" << instr->assignBinding.context;
         break;
     case QDeclarativeInstruction::StoreV4Binding:
-        qWarning().nospace() << idx << "\t\t" << "STORE_COMPILED_BINDING\t" << instr->assignBinding.property << "\t" << instr->assignBinding.value << "\t" << instr->assignBinding.context;
+        qWarning().nospace() << idx << "\t\t" << "STORE_COMPILED_BINDING\t" << instr->assignV4Binding.property << "\t" << instr->assignV4Binding.value << "\t" << instr->assignV4Binding.context;
         break;
     case QDeclarativeInstruction::StoreV8Binding:
-        qWarning().nospace() << idx << "\t\t" << "STORE_V8_BINDING\t" << instr->assignBinding.property << "\t" << instr->assignBinding.value << "\t" << instr->assignBinding.context;
+        qWarning().nospace() << idx << "\t\t" << "STORE_V8_BINDING\t" << instr->assignBinding.property.coreIndex << "\t" << instr->assignBinding.value << "\t" << instr->assignBinding.context;
         break;
     case QDeclarativeInstruction::StoreValueSource:
-        qWarning().nospace() << idx << "\t\t" << "STORE_VALUE_SOURCE\t" << instr->assignValueSource.property << "\t" << instr->assignValueSource.castValue;
+        qWarning().nospace() << idx << "\t\t" << "STORE_VALUE_SOURCE\t" << instr->assignValueSource.property.coreIndex << "\t" << instr->assignValueSource.castValue;
         break;
     case QDeclarativeInstruction::StoreValueInterceptor:
-        qWarning().nospace() << idx << "\t\t" << "STORE_VALUE_INTERCEPTOR\t" << instr->assignValueInterceptor.property << "\t" << instr->assignValueInterceptor.castValue;
+        qWarning().nospace() << idx << "\t\t" << "STORE_VALUE_INTERCEPTOR\t" << instr->assignValueInterceptor.property.coreIndex << "\t" << instr->assignValueInterceptor.castValue;
         break;
     case QDeclarativeInstruction::BeginObject:
         qWarning().nospace() << idx << "\t\t" << "BEGIN\t\t\t" << instr->begin.castValue;
index b6efb19..7b36c9a 100644 (file)
@@ -54,6 +54,7 @@
 //
 
 #include <QtCore/qglobal.h>
+#include <private/qdeclarativepropertycache_p.h>
 
 QT_BEGIN_NAMESPACE
 
@@ -106,8 +107,8 @@ QT_BEGIN_NAMESPACE
     F(InitV8Bindings, initV8Bindings) \
     F(StoreBinding, assignBinding) \
     F(StoreBindingOnAlias, assignBinding) \
-    F(StoreV4Binding, assignBinding) \
     F(StoreV8Binding, assignBinding) \
+    F(StoreV4Binding, assignV4Binding) \
     F(StoreValueSource, assignValueSource) \
     F(StoreValueInterceptor, assignValueInterceptor) \
     F(StoreObjectQList, common) \
@@ -210,13 +211,13 @@ union QDeclarativeInstruction
     };
     struct instr_assignValueSource {
         QML_INSTR_HEADER
-        int property;
+        QDeclarativePropertyCache::RawData property;
         int owner;
         int castValue;
     };
     struct instr_assignValueInterceptor {
         QML_INSTR_HEADER
-        int property;
+        QDeclarativePropertyCache::RawData property;
         int owner;
         int castValue;
     };
@@ -226,7 +227,7 @@ union QDeclarativeInstruction
         ushort programIndex;
         ushort line;
     };
-    struct instr_assignBinding {
+    struct instr_assignV4Binding {
         QML_INSTR_HEADER
         unsigned int property;
         int value;
@@ -235,6 +236,15 @@ union QDeclarativeInstruction
         bool isRoot;
         ushort line;
     };
+    struct instr_assignBinding {
+        QML_INSTR_HEADER
+        QDeclarativePropertyCache::RawData property;
+        int value;
+        short context;
+        short owner;
+        bool isRoot;
+        ushort line;
+    };
     struct instr_fetch {
         QML_INSTR_HEADER
         int property;
@@ -466,6 +476,7 @@ union QDeclarativeInstruction
     instr_assignValueSource assignValueSource;
     instr_assignValueInterceptor assignValueInterceptor;
     instr_initV8Bindings initV8Bindings;
+    instr_assignV4Binding assignV4Binding;
     instr_assignBinding assignBinding;
     instr_fetch fetch;
     instr_fetchValue fetchValue;
index d95b13c..e43cd6f 100644 (file)
@@ -285,11 +285,18 @@ void QDeclarativePropertyPrivate::initProperty(QObject *obj, const QString &name
 
             QMetaProperty vtProp = typeObject->metaObject()->property(idx);
 
+            typedef QDeclarativePropertyCache::Data PCD;
+
+            Q_ASSERT(PCD::flagsForProperty(vtProp) <= PCD::ValueTypeFlagMask);
+            Q_ASSERT(vtProp.userType() <= 0xFF);
+            Q_ASSERT(idx <= 0xFF);
+
             object = currentObject;
             core = *property;
-            valueType.flags = QDeclarativePropertyCache::Data::flagsForProperty(vtProp);
-            valueType.valueTypeCoreIdx = idx;
-            valueType.valueTypePropType = vtProp.userType();
+            core.setFlags(core.getFlags() | PCD::IsValueTypeVirtual);
+            core.valueTypeFlags = PCD::flagsForProperty(vtProp);
+            core.valueTypePropType = vtProp.userType();
+            core.valueTypeCoreIndex = idx;
 
             return; 
         } else {
@@ -413,7 +420,7 @@ const char *QDeclarativeProperty::propertyTypeName() const
         else valueType = QDeclarativeValueTypeFactory::valueType(d->core.propType);
         Q_ASSERT(valueType);
 
-        const char *rv = valueType->metaObject()->property(d->valueType.valueTypeCoreIdx).typeName();
+        const char *rv = valueType->metaObject()->property(d->core.valueTypeCoreIndex).typeName();
 
         if (!ep) delete valueType;
 
@@ -437,8 +444,10 @@ bool QDeclarativeProperty::operator==(const QDeclarativeProperty &other) const
     // from the other members
     return d->object == other.d->object &&
            d->core.coreIndex == other.d->core.coreIndex &&
-           d->valueType.valueTypeCoreIdx == other.d->valueType.valueTypeCoreIdx &&
-           d->valueType.valueTypePropType == other.d->valueType.valueTypePropType;
+           d->core.isValueTypeVirtual() == other.d->core.isValueTypeVirtual() &&
+           (!d->core.isValueTypeVirtual() ||
+            (d->core.valueTypeCoreIndex == other.d->core.valueTypeCoreIndex &&
+             d->core.valueTypePropType == other.d->core.valueTypePropType));
 }
 
 /*!
@@ -452,14 +461,14 @@ int QDeclarativeProperty::propertyType() const
 
 bool QDeclarativePropertyPrivate::isValueType() const
 {
-    return valueType.valueTypeCoreIdx != -1;
+    return core.isValueTypeVirtual();
 }
 
 int QDeclarativePropertyPrivate::propertyType() const
 {
     uint type = this->type();
     if (isValueType()) {
-        return valueType.valueTypePropType;
+        return core.valueTypePropType;
     } else if (type & QDeclarativeProperty::Property) {
         if (core.propType == (int)QVariant::LastType)
             return qMetaTypeId<QVariant>();
@@ -601,7 +610,8 @@ QString QDeclarativeProperty::name() const
             else valueType = QDeclarativeValueTypeFactory::valueType(d->core.propType);
             Q_ASSERT(valueType);
 
-            rv += QString::fromUtf8(valueType->metaObject()->property(d->valueType.valueTypeCoreIdx).name());
+            const char *vtName = valueType->metaObject()->property(d->core.valueTypeCoreIndex).name();
+            rv += QString::fromUtf8(vtName);
 
             if (!ep) delete valueType;
 
@@ -657,7 +667,8 @@ QDeclarativePropertyPrivate::binding(const QDeclarativeProperty &that)
     if (!that.d || !that.isProperty() || !that.d->object)
         return 0;
 
-    return binding(that.d->object, that.d->core.coreIndex, that.d->valueType.valueTypeCoreIdx);
+    return binding(that.d->object, that.d->core.coreIndex, 
+                   that.d->core.getValueTypeCoreIndex());
 }
 
 /*!
@@ -685,7 +696,8 @@ QDeclarativePropertyPrivate::setBinding(const QDeclarativeProperty &that,
     }
 
     return that.d->setBinding(that.d->object, that.d->core.coreIndex, 
-                              that.d->valueType.valueTypeCoreIdx, newBinding, flags);
+                              that.d->core.getValueTypeCoreIndex(),
+                              newBinding, flags);
 }
 
 QDeclarativeAbstractBinding *
@@ -1003,8 +1015,7 @@ QVariant QDeclarativePropertyPrivate::readValueProperty()
 
         valueType->read(object, core.coreIndex);
 
-        QVariant rv =
-            valueType->metaObject()->property(this->valueType.valueTypeCoreIdx).read(valueType);
+        QVariant rv = valueType->metaObject()->property(core.valueTypeCoreIndex).read(valueType);
 
         if (!ep) delete valueType;
         return rv;
@@ -1070,16 +1081,25 @@ bool QDeclarativePropertyPrivate::writeEnumProperty(const QMetaProperty &prop, i
 
 bool QDeclarativePropertyPrivate::writeValueProperty(const QVariant &value, WriteFlags flags)
 {
+    return writeValueProperty(object, engine, core, value, effectiveContext(), flags);
+}
+
+bool 
+QDeclarativePropertyPrivate::writeValueProperty(QObject *object, QDeclarativeEngine *engine,
+                                                const QDeclarativePropertyCache::Data &core, 
+                                                const QVariant &value, 
+                                                QDeclarativeContextData *context, WriteFlags flags)
+{
     // Remove any existing bindings on this property
-    if (!(flags & DontRemoveBinding) &&
-        (type() & QDeclarativeProperty::Property) && object) {
+    if (!(flags & DontRemoveBinding) && object) {
         QDeclarativeAbstractBinding *binding = setBinding(object, core.coreIndex,
-                                                          valueType.valueTypeCoreIdx, 0, flags);
+                                                          core.getValueTypeCoreIndex(), 
+                                                          0, flags);
         if (binding) binding->destroy();
     }
 
     bool rv = false;
-    if (isValueType()) {
+    if (core.isValueTypeVirtual()) {
         QDeclarativeEnginePrivate *ep = engine?QDeclarativeEnginePrivate::get(engine):0;
 
         QDeclarativeValueType *writeBack = 0;
@@ -1092,24 +1112,26 @@ bool QDeclarativePropertyPrivate::writeValueProperty(const QVariant &value, Writ
         writeBack->read(object, core.coreIndex);
 
         QDeclarativePropertyCache::Data data = core;
-        data.setFlags(valueType.flags);
-        data.coreIndex = valueType.valueTypeCoreIdx;
-        data.propType = valueType.valueTypePropType;
-        rv = write(writeBack, data, value, effectiveContext(), flags);
+        data.setFlags(QDeclarativePropertyCache::Data::Flag(core.valueTypeFlags));
+        data.coreIndex = core.valueTypeCoreIndex;
+        data.propType = core.valueTypePropType;
+
+        rv = write(writeBack, data, value, context, flags);
 
         writeBack->write(object, core.coreIndex, flags);
         if (!ep) delete writeBack;
 
     } else {
 
-        rv = write(object, core, value, effectiveContext(), flags);
+        rv = write(object, core, value, context, flags);
 
     }
 
     return rv;
 }
 
-bool QDeclarativePropertyPrivate::write(QObject *object, const QDeclarativePropertyCache::Data &property, 
+bool QDeclarativePropertyPrivate::write(QObject *object, 
+                                        const QDeclarativePropertyCache::Data &property, 
                                         const QVariant &value, QDeclarativeContextData *context, 
                                         WriteFlags flags)
 {
@@ -1272,33 +1294,31 @@ bool QDeclarativePropertyPrivate::write(QObject *object, const QDeclarativePrope
 }
 
 // Returns true if successful, false if an error description was set on expression
-bool QDeclarativePropertyPrivate::writeBinding(const QDeclarativeProperty &that, 
+bool QDeclarativePropertyPrivate::writeBinding(QObject *object, 
+                                               const QDeclarativePropertyCache::Data &core,
                                                QDeclarativeJavaScriptExpression *expression, 
                                                v8::Handle<v8::Value> result, bool isUndefined,
                                                WriteFlags flags)
 {
-    QV8Engine *engine = QDeclarativeEnginePrivate::getV8Engine(expression->context()->engine);
-
-    QDeclarativePropertyPrivate *pp = that.d;
+    Q_ASSERT(object);
+    Q_ASSERT(core.coreIndex);
 
-    if (!pp)
-        return true;
-    
-    QObject *object = that.object();
-    int type = that.propertyType();
+    QDeclarativeContextData *context = expression->context();
+    QDeclarativeEngine *engine = context->engine;
+    QV8Engine *v8engine = QDeclarativeEnginePrivate::getV8Engine(engine);
 
 #define QUICK_STORE(cpptype, conversion) \
         { \
             cpptype o = (conversion); \
             int status = -1; \
             void *argv[] = { &o, 0, &status, &flags }; \
-            QMetaObject::metacall(object, QMetaObject::WriteProperty, pp->core.coreIndex, argv); \
+            QMetaObject::metacall(object, QMetaObject::WriteProperty, core.coreIndex, argv); \
             return true; \
         } \
 
 
-    if (!isUndefined && object && pp->valueType.valueTypeCoreIdx == -1) {
-        switch (type) {
+    if (!isUndefined && !core.isValueTypeVirtual()) {
+        switch (core.propType) {
         case QMetaType::Int:
             if (result->IsInt32()) 
                 QUICK_STORE(int, result->Int32Value())
@@ -1315,46 +1335,49 @@ bool QDeclarativePropertyPrivate::writeBinding(const QDeclarativeProperty &that,
             break;
         case QMetaType::QString:
             if (result->IsString())
-                QUICK_STORE(QString, engine->toString(result))
+                QUICK_STORE(QString, v8engine->toString(result))
             break;
         default:
             break;
         }
     }
-
 #undef QUICK_STORE
 
+    int type = core.isValueTypeVirtual()?core.valueTypePropType:core.propType;
+
     QDeclarativeDeleteWatcher watcher(expression);
 
     QVariant value;
-    bool isVmeProperty = pp->core.isVMEProperty();
+    bool isVmeProperty = core.isVMEProperty();
 
     if (isUndefined) {
-    } else if (that.propertyTypeCategory() == QDeclarativeProperty::List) {
-        value = engine->toVariant(result, qMetaTypeId<QList<QObject *> >());
-    } else if (result->IsNull() && that.propertyTypeCategory() == QDeclarativeProperty::Object) {
+    } else if (core.isQList()) {
+        value = v8engine->toVariant(result, qMetaTypeId<QList<QObject *> >());
+    } else if (result->IsNull() && core.isQObject()) {
         value = QVariant::fromValue((QObject *)0);
     } else if (!isVmeProperty) {
-        value = engine->toVariant(result, type);
+        value = v8engine->toVariant(result, type);
     }
 
     if (expression->error.isValid()) {
         return false;
-    } else if (isUndefined && that.isResettable()) {
-        that.reset();
+    } else if (isUndefined && core.isResettable()) {
+        void *args[] = { 0 };
+        QMetaObject::metacall(object, QMetaObject::ResetProperty, core.coreIndex, args);
     } else if (isUndefined && type == qMetaTypeId<QVariant>()) {
-        QDeclarativePropertyPrivate::write(that, QVariant(), flags);
+        writeValueProperty(object, engine, core, QVariant(), context, flags);
     } else if (isUndefined) {
         expression->error.setDescription(QLatin1String("Unable to assign [undefined] to ") +
-                                         QLatin1String(QMetaType::typeName(type)) +
-                                         QLatin1String(" ") + that.name());
+                                         QLatin1String(QMetaType::typeName(type))); 
         return false;
     } else if (result->IsFunction()) {
         expression->error.setDescription(QLatin1String("Unable to assign a function to a property."));
         return false;
     } else if (isVmeProperty) {
-        static_cast<QDeclarativeVMEMetaObject *>(const_cast<QMetaObject *>(that.object()->metaObject()))->setVMEProperty(that.index(), result);
-    } else if (object && !QDeclarativePropertyPrivate::write(that, value, flags)) {
+        typedef QDeclarativeVMEMetaObject VMEMO;
+        VMEMO *vmemo = static_cast<VMEMO *>(const_cast<QMetaObject *>(object->metaObject()));
+        vmemo->setVMEProperty(core.coreIndex, result);
+    } else if (!writeValueProperty(object, engine, core, value, context, flags)) {
 
         if (watcher.wasDeleted()) 
             return true;
@@ -1373,6 +1396,23 @@ bool QDeclarativePropertyPrivate::writeBinding(const QDeclarativeProperty &that,
     return true;
 }
 
+bool QDeclarativePropertyPrivate::writeBinding(const QDeclarativeProperty &that, 
+                                               QDeclarativeJavaScriptExpression *expression, 
+                                               v8::Handle<v8::Value> result, bool isUndefined,
+                                               WriteFlags flags)
+{
+    QDeclarativePropertyPrivate *pp = that.d;
+
+    if (!pp)
+        return true;
+
+    QObject *object = that.object();
+    if (!object)
+        return true;
+
+    return writeBinding(object, pp->core, expression, result, isUndefined, flags);
+}
+
 const QMetaObject *QDeclarativePropertyPrivate::rawMetaObjectForType(QDeclarativeEnginePrivate *engine, int userType)
 {
     if (engine) {
@@ -1549,7 +1589,7 @@ int QDeclarativeProperty::index() const
 
 int QDeclarativePropertyPrivate::valueTypeCoreIndex(const QDeclarativeProperty &that)
 {
-    return that.d ? that.d->valueType.valueTypeCoreIdx : -1;
+    return that.d ? that.d->core.getValueTypeCoreIndex() : -1;
 }
 
 /*!
@@ -1560,84 +1600,38 @@ int QDeclarativePropertyPrivate::bindingIndex(const QDeclarativeProperty &that)
 {
     if (!that.d)
         return -1;
-    int rv = that.d->core.coreIndex;
-    if (rv != -1 && that.d->valueType.valueTypeCoreIdx != -1)
-        rv = rv | (that.d->valueType.valueTypeCoreIdx << 24);
-    return rv;
+    return bindingIndex(that.d->core);
 }
 
-struct SerializedData {
-    bool isValueType;
-    QDeclarativePropertyCache::Data core;
-};
-
-struct ValueTypeSerializedData : public SerializedData {
-    QDeclarativePropertyCache::ValueTypeData valueType;
-};
-
-QByteArray QDeclarativePropertyPrivate::saveValueType(const QMetaObject *metaObject, int index, 
-                                                      const QMetaObject *subObject, int subIndex,
-                                                      QDeclarativeEngine *)
+int QDeclarativePropertyPrivate::bindingIndex(const QDeclarativePropertyCache::Data &that)
 {
-    QMetaProperty prop = metaObject->property(index);
-    QMetaProperty subProp = subObject->property(subIndex);
-
-    ValueTypeSerializedData sd;
-    memset(&sd, 0, sizeof(sd));
-    sd.isValueType = true;
-    sd.core.load(metaObject->property(index));
-    sd.valueType.flags = QDeclarativePropertyCache::Data::flagsForProperty(subProp);
-    sd.valueType.valueTypeCoreIdx = subIndex;
-    sd.valueType.valueTypePropType = subProp.userType();
-
-    QByteArray rv((const char *)&sd, sizeof(sd));
-
+    int rv = that.coreIndex;
+    if (rv != -1 && that.isValueTypeVirtual())
+        rv = rv | (that.valueTypeCoreIndex << 24);
     return rv;
 }
 
-QByteArray QDeclarativePropertyPrivate::saveProperty(const QMetaObject *metaObject, int index, 
-                                                     QDeclarativeEngine *engine)
+QDeclarativePropertyCache::Data
+QDeclarativePropertyPrivate::saveValueType(const QMetaObject *metaObject, int index, 
+                                           const QMetaObject *subObject, int subIndex,
+                                           QDeclarativeEngine *)
 {
-    SerializedData sd;
-    memset(&sd, 0, sizeof(sd));
-    sd.isValueType = false;
-    sd.core.load(metaObject->property(index), engine);
-
-    QByteArray rv((const char *)&sd, sizeof(sd));
-    return rv;
-}
-
-QByteArray QDeclarativePropertyPrivate::saveProperty(QDeclarativePropertyCache::Data *core)
-{
-    SerializedData sd;
-    memset(&sd, 0, sizeof(sd));
-    sd.isValueType = false;
-    sd.core = *core;
-
-    QByteArray rv((const char *)&sd, sizeof(sd));
-    return rv;
-}
-
-QDeclarativeProperty 
-QDeclarativePropertyPrivate::restore(const QByteArray &data, QObject *object, QDeclarativeContextData *ctxt)
-{
-    QDeclarativeProperty prop;
+    QMetaProperty prop = metaObject->property(index);
+    QMetaProperty subProp = subObject->property(subIndex);
 
-    if (data.isEmpty())
-        return prop;
+    QDeclarativePropertyCache::Data core;
+    core.load(metaObject->property(index));
+    core.setFlags(core.getFlags() | QDeclarativePropertyCache::Data::IsValueTypeVirtual);
+    core.valueTypeFlags = QDeclarativePropertyCache::Data::flagsForProperty(subProp);
+    core.valueTypeCoreIndex = subIndex;
+    core.valueTypePropType = subProp.userType();
 
-    const SerializedData *sd = (const SerializedData *)data.constData();
-    if (sd->isValueType) {
-        const ValueTypeSerializedData *vt = (const ValueTypeSerializedData *)sd;
-        return restore(vt->core, vt->valueType, object, ctxt);
-    } else {
-        QDeclarativePropertyCache::ValueTypeData data;
-        return restore(sd->core, data, object, ctxt);
-    }
+    return core;
 }
 
 QDeclarativeProperty
-QDeclarativePropertyPrivate::restore(const QDeclarativePropertyCache::Data &data, const QDeclarativePropertyCache::ValueTypeData &valueType, QObject *object, QDeclarativeContextData *ctxt)
+QDeclarativePropertyPrivate::restore(const QDeclarativePropertyCache::Data &data, 
+                                     QObject *object, QDeclarativeContextData *ctxt)
 {
     QDeclarativeProperty prop;
 
@@ -1647,7 +1641,6 @@ QDeclarativePropertyPrivate::restore(const QDeclarativePropertyCache::Data &data
     prop.d->engine = ctxt?ctxt->engine:0;
 
     prop.d->core = data;
-    prop.d->valueType = valueType;
 
     return prop;
 }
index f8ecef1..5bfbf47 100644 (file)
@@ -84,9 +84,6 @@ public:
     QDeclarativePropertyCache::Data core;
     QString nameCache;
 
-    // Describes the "virtual" value-type sub-property.  
-    QDeclarativePropertyCache::ValueTypeData valueType;
-
     void initProperty(QObject *obj, const QString &name);
     void initDefault(QObject *obj);
 
@@ -101,6 +98,10 @@ public:
     static const QMetaObject *rawMetaObjectForType(QDeclarativeEnginePrivate *, int);
     static bool writeEnumProperty(const QMetaProperty &prop, int idx, QObject *object, 
                                   const QVariant &value, int flags);
+    static bool writeValueProperty(QObject *, QDeclarativeEngine *,
+                                   const QDeclarativePropertyCache::Data &, 
+                                   const QVariant &, QDeclarativeContextData *, 
+                                   WriteFlags flags = 0);
     static bool write(QObject *, const QDeclarativePropertyCache::Data &, const QVariant &, 
                       QDeclarativeContextData *, WriteFlags flags = 0);
     static void findAliasTarget(QObject *, int, QObject **, int *);
@@ -111,21 +112,18 @@ public:
                                                            QDeclarativeAbstractBinding *);
     static QDeclarativeAbstractBinding *binding(QObject *, int coreIndex, int valueTypeIndex /* -1 */);
 
-    static QByteArray saveValueType(const QMetaObject *, int, 
-                                    const QMetaObject *, int,
-                                    QDeclarativeEngine *);
-    static QByteArray saveProperty(const QMetaObject *, int, 
-                                   QDeclarativeEngine *);
-    static QByteArray saveProperty(QDeclarativePropertyCache::Data *);
-
-    static QDeclarativeProperty restore(const QByteArray &, QObject *, QDeclarativeContextData *);
+    static QDeclarativePropertyCache::Data saveValueType(const QMetaObject *, int, 
+                                                         const QMetaObject *, int,
+                                                         QDeclarativeEngine *);
     static QDeclarativeProperty restore(const QDeclarativePropertyCache::Data &,
-                                        const QDeclarativePropertyCache::ValueTypeData &,
                                         QObject *,
                                         QDeclarativeContextData *);
 
     static bool equal(const QMetaObject *, const QMetaObject *);
     static bool canConvert(const QMetaObject *from, const QMetaObject *to);
+    static inline QDeclarativePropertyPrivate *get(const QDeclarativeProperty &p) {
+        return p.d;
+    }
 
     // "Public" (to QML) methods
     static QDeclarativeAbstractBinding *binding(const QDeclarativeProperty &that);
@@ -140,8 +138,13 @@ public:
                              QDeclarativeJavaScriptExpression *expression, 
                              v8::Handle<v8::Value> result, bool isUndefined,
                              WriteFlags flags);
+    static bool writeBinding(QObject *, const QDeclarativePropertyCache::Data &,
+                             QDeclarativeJavaScriptExpression *expression, 
+                             v8::Handle<v8::Value> result, bool isUndefined,
+                             WriteFlags flags);
     static int valueTypeCoreIndex(const QDeclarativeProperty &that);
     static int bindingIndex(const QDeclarativeProperty &that);
+    static int bindingIndex(const QDeclarativePropertyCache::Data &that);
     static QMetaMethod findSignalByName(const QMetaObject *mo, const QByteArray &);
     static bool connect(const QObject *sender, int signal_index,
                         const QObject *receiver, int method_index,
index c1610f8..f1161b2 100644 (file)
@@ -74,45 +74,48 @@ public:
     QDeclarativePropertyCache(QDeclarativeEngine *, const QMetaObject *);
     virtual ~QDeclarativePropertyCache();
 
-    struct Data {
-        inline Data(); 
-        inline bool operator==(const Data &);
-
+    // We have this somewhat aweful split between RawData and Data so that RawData can be
+    // used in unions.  In normal code, you should always use Data which initializes RawData
+    // to an invalid state on construction.
+    struct Data;
+    struct RawData {
         enum Flag { 
                     NoFlags           = 0x00000000,
+                    ValueTypeFlagMask = 0x0000FFFF, // Flags in valueTypeFlags must fit in this mask
 
                     // Can apply to all properties, except IsFunction
-                    IsConstant        = 0x00000001, // Has CONST flag
-                    IsWritable        = 0x00000002, // Has WRITE function
-                    IsResettable      = 0x00000004, // Has RESET function
-                    IsAlias           = 0x00000008, // Is a QML alias to another property
-                    IsFinal           = 0x00000010, // Has FINAL flag
-                    IsDirect          = 0x00000020, // Exists on a C++ QMetaObject
+                    IsConstant         = 0x00000001, // Has CONST flag
+                    IsWritable         = 0x00000002, // Has WRITE function
+                    IsResettable       = 0x00000004, // Has RESET function
+                    IsAlias            = 0x00000008, // Is a QML alias to another property
+                    IsFinal            = 0x00000010, // Has FINAL flag
+                    IsDirect           = 0x00000020, // Exists on a C++ QMetaObject
 
                     // These are mutualy exclusive
-                    IsFunction        = 0x00000040, // Is an invokable
-                    IsQObjectDerived  = 0x00000080, // Property type is a QObject* derived type
-                    IsEnumType        = 0x00000100, // Property type is an enum
-                    IsQList           = 0x00000200, // Property type is a QML list
-                    IsQmlBinding      = 0x00000400, // Property type is a QDeclarativeBinding*
-                    IsQJSValue        = 0x00000800, // Property type is a QScriptValue
-                    IsV8Handle        = 0x00001000, // Property type is a QDeclarativeV8Handle
-                    IsVMEProperty     = 0x00002000, // Property type is a "var" property of VMEMO
+                    IsFunction         = 0x00000040, // Is an invokable
+                    IsQObjectDerived   = 0x00000080, // Property type is a QObject* derived type
+                    IsEnumType         = 0x00000100, // Property type is an enum
+                    IsQList            = 0x00000200, // Property type is a QML list
+                    IsQmlBinding       = 0x00000400, // Property type is a QDeclarativeBinding*
+                    IsQJSValue         = 0x00000800, // Property type is a QScriptValue
+                    IsV8Handle         = 0x00001000, // Property type is a QDeclarativeV8Handle
+                    IsVMEProperty      = 0x00002000, // Property type is a "var" property of VMEMO
+                    IsValueTypeVirtual = 0x00004000, // Property is a value type "virtual" property
 
                     // Apply only to IsFunctions
-                    IsVMEFunction     = 0x00004000, // Function was added by QML
-                    HasArguments      = 0x00008000, // Function takes arguments
-                    IsSignal          = 0x00010000, // Function is a signal
-                    IsVMESignal       = 0x00020000, // Signal was added by QML
-                    IsV8Function      = 0x00040000, // Function takes QDeclarativeV8Function* args
-                    IsSignalHandler   = 0x00080000, // Function is a signal handler
+                    IsVMEFunction      = 0x00008000, // Function was added by QML
+                    HasArguments       = 0x00010000, // Function takes arguments
+                    IsSignal           = 0x00020000, // Function is a signal
+                    IsVMESignal        = 0x00040000, // Signal was added by QML
+                    IsV8Function       = 0x00080000, // Function takes QDeclarativeV8Function* args
+                    IsSignalHandler    = 0x00100000, // Function is a signal handler
 
                     // Internal QDeclarativePropertyCache flags
-                    NotFullyResolved  = 0x00100000  // True if the type data is to be lazily resolved
+                    NotFullyResolved   = 0x00200000  // True if the type data is to be lazily resolved
         };
         Q_DECLARE_FLAGS(Flags, Flag)
 
-        Flags getFlags() const { return flags; }
+        Flags getFlags() const { return Flag(flags); }
         void setFlags(Flags f) { flags = f; }
 
         bool isValid() const { return coreIndex != -1; } 
@@ -131,6 +134,7 @@ public:
         bool isQJSValue() const { return flags & IsQJSValue; }
         bool isV8Handle() const { return flags & IsV8Handle; }
         bool isVMEProperty() const { return flags & IsVMEProperty; }
+        bool isValueTypeVirtual() const { return flags & IsValueTypeVirtual; }
         bool isVMEFunction() const { return flags & IsVMEFunction; }
         bool hasArguments() const { return flags & HasArguments; }
         bool isSignal() const { return flags & IsSignal; }
@@ -144,34 +148,51 @@ public:
         };
         int coreIndex;
         union {
-            int notifyIndex; // When !IsFunction
+            int notifyIndex;  // When !IsFunction
             int relatedIndex; // When IsFunction
         };
-        uint overrideIndexIsProperty : 1;
-        int overrideIndex : 31;
+        union {
+            struct { // When !IsValueTypeVirtual
+                uint overrideIndexIsProperty : 1;
+                signed int overrideIndex : 31;
+            };
+            struct { // When IsValueTypeVirtual
+                quint16 valueTypeFlags; // flags of the access property on the value type proxy object
+                quint8 valueTypePropType; // The QVariant::Type of access property on the value type 
+                                          // proxy object
+                quint8 valueTypeCoreIndex; // The prop index of the access property on the value type 
+                                           //proxy object
+            };
+        };
         int revision; 
         int metaObjectOffset;
 
+    private:
+        friend struct Data;
+        friend class QDeclarativePropertyCache;
+        quint32 flags;
+    };
+
+    struct Data : public RawData {
+        inline Data(); 
+        inline Data(const RawData &); 
+
+        inline bool operator==(const RawData &);
+
         static Flags flagsForProperty(const QMetaProperty &, QDeclarativeEngine *engine = 0);
         void load(const QMetaProperty &, QDeclarativeEngine *engine = 0);
         void load(const QMetaMethod &);
         QString name(QObject *);
         QString name(const QMetaObject *);
 
+        // Returns -1 if not a value type virtual property
+        inline int getValueTypeCoreIndex() const;
+
     private:
+        friend class QDeclarativePropertyCache;
         void lazyLoad(const QMetaProperty &, QDeclarativeEngine *engine = 0);
         void lazyLoad(const QMetaMethod &);
         bool notFullyResolved() const { return flags & NotFullyResolved; }
-        friend class QDeclarativePropertyCache;
-        Flags flags;
-    };
-
-    struct ValueTypeData {
-        inline ValueTypeData();
-        inline bool operator==(const ValueTypeData &);
-        Data::Flags flags;     // flags of the access property on the value type proxy object
-        int valueTypeCoreIdx;  // The prop index of the access property on the value type proxy object
-        int valueTypePropType; // The QVariant::Type of access property on the value type proxy object
     };
 
     void update(QDeclarativeEngine *, const QMetaObject *);
@@ -235,18 +256,37 @@ private:
 Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativePropertyCache::Data::Flags);
   
 QDeclarativePropertyCache::Data::Data()
-: propType(0), coreIndex(-1), notifyIndex(-1), overrideIndexIsProperty(false), overrideIndex(-1),
-  revision(0), metaObjectOffset(-1), flags(0)
 {
+    propType = 0;
+    coreIndex = -1;
+    notifyIndex = -1;
+    overrideIndexIsProperty = false;
+    overrideIndex = -1;
+    revision = 0;
+    metaObjectOffset = -1; 
+    flags = 0;
 }
 
-bool QDeclarativePropertyCache::Data::operator==(const QDeclarativePropertyCache::Data &other)
+QDeclarativePropertyCache::Data::Data(const QDeclarativePropertyCache::RawData &d)
+{
+    *(static_cast<RawData *>(this)) = d;
+}
+
+bool QDeclarativePropertyCache::Data::operator==(const QDeclarativePropertyCache::RawData &other)
 {
     return flags == other.flags &&
            propType == other.propType &&
            coreIndex == other.coreIndex &&
            notifyIndex == other.notifyIndex &&
-           revision == other.revision;
+           revision == other.revision &&
+           (!isValueTypeVirtual() || 
+            (valueTypeCoreIndex == other.valueTypeCoreIndex && 
+             valueTypePropType == other.valueTypePropType));
+}
+
+int QDeclarativePropertyCache::Data::getValueTypeCoreIndex() const
+{
+    return isValueTypeVirtual()?valueTypeCoreIndex:-1;
 }
 
 QDeclarativePropertyCache::Data *
@@ -261,18 +301,6 @@ QDeclarativePropertyCache::overrideData(Data *data) const
         return method(data->overrideIndex);
 }
 
-QDeclarativePropertyCache::ValueTypeData::ValueTypeData()
-: flags(QDeclarativePropertyCache::Data::NoFlags), valueTypeCoreIdx(-1), valueTypePropType(0) 
-{
-}
-
-bool QDeclarativePropertyCache::ValueTypeData::operator==(const ValueTypeData &o) 
-{ 
-    return flags == o.flags &&
-           valueTypeCoreIdx == o.valueTypeCoreIdx &&
-           valueTypePropType == o.valueTypePropType; 
-}
-
 bool QDeclarativePropertyCache::isAllowedInRevision(Data *data) const
 {
     return (data->metaObjectOffset == -1 && data->revision == 0) ||
index 9091978..d407fae 100644 (file)
@@ -907,7 +907,7 @@ QObject *QDeclarativeVME::run(QList<QDeclarativeError> *errors,
                 objects.at(objects.count() - 1 - instr.context);
 
             QDeclarativeProperty mp = 
-                QDeclarativePropertyPrivate::restore(DATAS.at(instr.property), target, CTXT);
+                QDeclarativePropertyPrivate::restore(instr.property, target, CTXT);
 
             int coreIndex = mp.index();
 
@@ -930,7 +930,7 @@ QObject *QDeclarativeVME::run(QList<QDeclarativeError> *errors,
                 objects.at(objects.count() - 1 - instr.context);
 
             QDeclarativeProperty mp = 
-                QDeclarativePropertyPrivate::restore(DATAS.at(instr.property), target, CTXT);
+                QDeclarativePropertyPrivate::restore(instr.property, target, CTXT);
 
             int coreIndex = mp.index();
 
@@ -970,19 +970,15 @@ QObject *QDeclarativeVME::run(QList<QDeclarativeError> *errors,
             QObject *scope = 
                 objects.at(objects.count() - 1 - instr.context);
 
-            QDeclarativeProperty mp = 
-                QDeclarativePropertyPrivate::restore(DATAS.at(instr.property), target, CTXT);
-
-            int coreIndex = mp.index();
-
-            if (instr.isRoot && BINDINGSKIPLIST.testBit(coreIndex))
+            if (instr.isRoot && BINDINGSKIPLIST.testBit(instr.property.coreIndex))
                 QML_NEXT_INSTR(StoreV8Binding);
 
             QDeclarativeAbstractBinding *binding = 
-                CTXT->v8bindings->configBinding(instr.value, target, scope, mp, instr.line);
+                CTXT->v8bindings->configBinding(instr.value, target, scope, 
+                                                instr.property, instr.line);
             bindValues.push(binding);
             binding->m_mePtr = &bindValues.top();
-            binding->addToObject(target, QDeclarativePropertyPrivate::bindingIndex(mp));
+            binding->addToObject(target, QDeclarativePropertyPrivate::bindingIndex(instr.property));
         QML_END_INSTR(StoreV8Binding)
 
         QML_BEGIN_INSTR(StoreValueSource)
@@ -991,7 +987,7 @@ QObject *QDeclarativeVME::run(QList<QDeclarativeError> *errors,
             QObject *target = objects.at(objects.count() - 1 - instr.owner);
 
             QDeclarativeProperty prop = 
-                QDeclarativePropertyPrivate::restore(DATAS.at(instr.property), target, CTXT);
+                QDeclarativePropertyPrivate::restore(instr.property, target, CTXT);
             obj->setParent(target);
             vs->setTarget(prop);
         QML_END_INSTR(StoreValueSource)
@@ -1001,7 +997,7 @@ QObject *QDeclarativeVME::run(QList<QDeclarativeError> *errors,
             QDeclarativePropertyValueInterceptor *vi = reinterpret_cast<QDeclarativePropertyValueInterceptor *>(reinterpret_cast<char *>(obj) + instr.castValue);
             QObject *target = objects.at(objects.count() - 1 - instr.owner);
             QDeclarativeProperty prop = 
-                QDeclarativePropertyPrivate::restore(DATAS.at(instr.property), target, CTXT);
+                QDeclarativePropertyPrivate::restore(instr.property, target, CTXT);
             obj->setParent(target);
             vi->setTarget(prop);
             QDeclarativeVMEMetaObject *mo = static_cast<QDeclarativeVMEMetaObject *>((QMetaObject*)target->metaObject());
index b94cebd..e1a0f4c 100644 (file)
@@ -52,7 +52,7 @@
 QT_BEGIN_NAMESPACE
 
 QV8Bindings::Binding::Binding()
-: index(-1), enabled(false), updating(false), line(-1), parent(0)
+: index(-1), enabled(false), updating(false), line(-1), object(0), parent(0)
 {
 }
 
@@ -94,8 +94,10 @@ void QV8Bindings::Binding::update(QDeclarativePropertyPrivate::WriteFlags flags)
                                                &isUndefined);
 
         bool needsErrorData = false;
-        if (!watcher.wasDeleted() && !error.isValid()) 
-            needsErrorData = !QDeclarativePropertyPrivate::writeBinding(property, this, result, isUndefined, flags);
+        if (!watcher.wasDeleted() && !error.isValid()) {
+            typedef QDeclarativePropertyPrivate PP;
+            needsErrorData = !PP::writeBinding(object, property, this, result, isUndefined, flags);
+        }
 
         if (!watcher.wasDeleted()) {
 
@@ -120,7 +122,8 @@ void QV8Bindings::Binding::update(QDeclarativePropertyPrivate::WriteFlags flags)
         ep->dereferenceScarceResources(); 
 
     } else {
-        QDeclarativeBindingPrivate::printBindingLoopError(property);
+        QDeclarativeProperty p = QDeclarativePropertyPrivate::restore(property, object, context);
+        QDeclarativeBindingPrivate::printBindingLoopError(p);
     }
 }
 
@@ -179,13 +182,15 @@ QV8Bindings::~QV8Bindings()
 }
 
 QDeclarativeAbstractBinding *QV8Bindings::configBinding(int index, QObject *target, QObject *scope, 
-                                                        const QDeclarativeProperty &property, int line)
+                                                        const QDeclarativePropertyCache::Data &p,
+                                                        int line)
 {
     QV8Bindings::Binding *rv = bindings + index;
 
     rv->line = line;
     rv->index = index;
-    rv->property = property;
+    rv->object = target;
+    rv->property = p;
     rv->setContext(context());
     rv->setScopeObject(scope);
     rv->setUseSharedContext(true);
index 9b6fb84..60b1afd 100644 (file)
@@ -53,6 +53,7 @@
 // We mean it.
 //
 
+#include "private/qdeclarativepropertycache_p.h"
 #include "private/qdeclarativeexpression_p.h"
 #include "private/qdeclarativebinding_p.h"
 
@@ -73,7 +74,8 @@ public:
     virtual ~QV8Bindings();
 
     QDeclarativeAbstractBinding *configBinding(int index, QObject *target, QObject *scope, 
-                                               const QDeclarativeProperty &prop, int line);
+                                               const QDeclarativePropertyCache::Data &prop,
+                                               int line);
 
 private:
     Q_DISABLE_COPY(QV8Bindings)
@@ -98,7 +100,8 @@ private:
         bool enabled:1;
         bool updating:1;
         int line;
-        QDeclarativeProperty property;
+        QObject *object;
+        QDeclarativePropertyCache::Data property;
         QV8Bindings *parent;
     };
 
index 0c0481f..1dc3db7 100644 (file)
@@ -549,10 +549,9 @@ static inline void StoreProperty(QV8Engine *engine, QObject *object, QDeclarativ
         int lineNumber = frame->GetLineNumber();
         QString url = engine->toString(frame->GetScriptName());
 
-        QDeclarativePropertyCache::ValueTypeData valueTypeData;
         newBinding = new QDeclarativeBinding(&function, object, context);
         newBinding->setSourceLocation(url, lineNumber);
-        newBinding->setTarget(QDeclarativePropertyPrivate::restore(*property, valueTypeData, object, context));
+        newBinding->setTarget(QDeclarativePropertyPrivate::restore(*property, object, context));
         newBinding->setEvaluateFlags(newBinding->evaluateFlags() | QDeclarativeBinding::RequiresThisObject);
     }
 
index e459fee..35037fa 100644 (file)
@@ -296,13 +296,13 @@ v8::Handle<v8::Value> QV8ValueTypeWrapper::Setter(v8::Local<v8::String> property
             v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(value);
 
             QDeclarativePropertyCache::Data cacheData;
-            cacheData.setFlags(QDeclarativePropertyCache::Data::IsWritable);
+            cacheData.setFlags(QDeclarativePropertyCache::Data::IsWritable |
+                               QDeclarativePropertyCache::Data::IsValueTypeVirtual);
             cacheData.propType = reference->object->metaObject()->property(reference->property).userType();
             cacheData.coreIndex = reference->property;
-
-            QDeclarativePropertyCache::ValueTypeData valueTypeData;
-            valueTypeData.valueTypeCoreIdx = index;
-            valueTypeData.valueTypePropType = p.userType();
+            cacheData.valueTypeFlags = 0;
+            cacheData.valueTypeCoreIndex = index;
+            cacheData.valueTypePropType = p.userType();
 
             v8::Local<v8::StackTrace> trace = 
                 v8::StackTrace::CurrentStackTrace(1, 
@@ -314,8 +314,8 @@ v8::Handle<v8::Value> QV8ValueTypeWrapper::Setter(v8::Local<v8::String> property
 
             newBinding = new QDeclarativeBinding(&function, reference->object, context);
             newBinding->setSourceLocation(url, lineNumber);
-            newBinding->setTarget(QDeclarativePropertyPrivate::restore(cacheData, valueTypeData
-                                                                       reference->object, context));
+            newBinding->setTarget(QDeclarativePropertyPrivate::restore(cacheData, reference->object
+                                                                       context));
             newBinding->setEvaluateFlags(newBinding->evaluateFlags() | QDeclarativeBinding::RequiresThisObject);
         }
 
index c30e9c5..3feecfc 100644 (file)
@@ -643,7 +643,7 @@ void tst_qdeclarativeecmascript::deferredPropertiesErrors()
     QVERIFY(object->objectProperty() == 0);
     QVERIFY(object->objectProperty2() == 0);
 
-    QString warning = component.url().toString() + ":6: Unable to assign [undefined] to QObject* objectProperty";
+    QString warning = component.url().toString() + ":6: Unable to assign [undefined] to QObject*";
     QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
 
     qmlExecuteDeferred(object);
@@ -754,8 +754,8 @@ void tst_qdeclarativeecmascript::enums()
     {
     QDeclarativeComponent component(&engine, TEST_FILE("enums.2.qml"));
 
-    QString warning1 = component.url().toString() + ":5: Unable to assign [undefined] to int a";
-    QString warning2 = component.url().toString() + ":6: Unable to assign [undefined] to int b";
+    QString warning1 = component.url().toString() + ":5: Unable to assign [undefined] to int";
+    QString warning2 = component.url().toString() + ":6: Unable to assign [undefined] to int";
     QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
     QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
 
@@ -893,7 +893,7 @@ void tst_qdeclarativeecmascript::nonExistentAttachedObject()
 {
     QDeclarativeComponent component(&engine, TEST_FILE("nonExistentAttachedObject.qml"));
 
-    QString warning = component.url().toString() + ":4: Unable to assign [undefined] to QString stringProperty";
+    QString warning = component.url().toString() + ":4: Unable to assign [undefined] to QString";
     QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
 
     QObject *object = component.create();
@@ -1349,7 +1349,7 @@ void tst_qdeclarativeecmascript::scriptErrors()
     QString warning3 = url.left(url.length() - 3) + "js:4: Error: Invalid write to global property \"a\"";
     QString warning4 = url + ":10: ReferenceError: Can't find variable: a";
     QString warning5 = url + ":8: ReferenceError: Can't find variable: a";
-    QString warning6 = url + ":7: Unable to assign [undefined] to int x";
+    QString warning6 = url + ":7: Unable to assign [undefined] to int";
     QString warning7 = url + ":12: Error: Cannot assign to read-only property \"trueProperty\"";
     QString warning8 = url + ":13: Error: Cannot assign to non-existent property \"fakeProperty\"";
 
index 6026cac..06ee4e9 100644 (file)
@@ -268,7 +268,7 @@ void tst_qdeclarativeengine::outputWarningsToStandardError()
     delete o;
 
     QCOMPARE(warnings.count(), 1);
-    QCOMPARE(warnings.at(0), QLatin1String("<Unknown File>:1: Unable to assign [undefined] to int a"));
+    QCOMPARE(warnings.at(0), QLatin1String("<Unknown File>:1: Unable to assign [undefined] to int"));
     warnings.clear();
 
 
index f1697ea..ebe9253 100644 (file)
@@ -322,7 +322,7 @@ void tst_qdeclarativeinstruction::dump()
 
     {
         QDeclarativeCompiledData::Instruction::StoreBinding i;
-        i.property = 26;
+        i.property.coreIndex = 26;
         i.value = 3;
         i.context = 2;
         i.owner = 0;
@@ -340,7 +340,7 @@ void tst_qdeclarativeinstruction::dump()
 
     {
         QDeclarativeCompiledData::Instruction::StoreValueSource i;
-        i.property = 29;
+        i.property.coreIndex = 29;
         i.owner = 1;
         i.castValue = 4;
         data->addInstruction(i);
@@ -348,7 +348,7 @@ void tst_qdeclarativeinstruction::dump()
 
     {
         QDeclarativeCompiledData::Instruction::StoreValueInterceptor i;
-        i.property = 30;
+        i.property.coreIndex = 30;
         i.owner = 2;
         i.castValue = -4;
         data->addInstruction(i);