From: Aaron Kennedy Date: Tue, 25 Oct 2011 15:24:37 +0000 (+0100) Subject: Rename QDeclarativePropertyCache::Data to QDeclarativePropertyData X-Git-Tag: qt-v5.0.0-alpha1~1283 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=060927726d0b053d599867f8b05d07da6e0b6a78;p=profile%2Fivi%2Fqtdeclarative.git Rename QDeclarativePropertyCache::Data to QDeclarativePropertyData This class is now too large to be nicely nested. Change-Id: I32cfa5caa524b8bf447d1f8c53ef2763f60bdac1 Reviewed-by: Aaron Kennedy --- diff --git a/src/declarative/debugger/qdeclarativeenginedebugservice.cpp b/src/declarative/debugger/qdeclarativeenginedebugservice.cpp index 7fa577d..a1b02ab 100644 --- a/src/declarative/debugger/qdeclarativeenginedebugservice.cpp +++ b/src/declarative/debugger/qdeclarativeenginedebugservice.cpp @@ -674,8 +674,8 @@ void QDeclarativeEngineDebugService::setMethodBody(int objectId, const QString & if (!contextData) return; - QDeclarativePropertyCache::Data dummy; - QDeclarativePropertyCache::Data *prop = + QDeclarativePropertyData dummy; + QDeclarativePropertyData *prop = QDeclarativePropertyCache::property(context->engine(), object, method, dummy); if (!prop || !prop->isVMEFunction()) diff --git a/src/declarative/items/qquickvisualadaptormodel.cpp b/src/declarative/items/qquickvisualadaptormodel.cpp index 28ea830..25baee6 100644 --- a/src/declarative/items/qquickvisualadaptormodel.cpp +++ b/src/declarative/items/qquickvisualadaptormodel.cpp @@ -688,7 +688,7 @@ QString QQuickVisualAdaptorModel::stringValue(int index, const QString &name) QDeclarativeData *ddata = QDeclarativeData::get(data); if (ddata && ddata->propertyCache) { - QDeclarativePropertyCache::Data *prop = ddata->propertyCache->property(name); + QDeclarativePropertyData *prop = ddata->propertyCache->property(name); if (prop) { if (prop->propType == QVariant::String) { void *args[] = { &val, 0 }; diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index 5762f42..4788491 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -1125,8 +1125,8 @@ void QDeclarativeCompiler::genObject(QDeclarativeScript::Object *obj) reinterpret_cast(obj->synthdata.constData()); for (int ii = 0; ii < vmeMetaData->aliasCount; ++ii) { int index = obj->metaObject()->propertyOffset() + vmeMetaData->propertyCount + ii; - QDeclarativePropertyCache::Data *data = propertyCache->property(index); - data->setFlags(data->getFlags() | QDeclarativePropertyCache::Data::IsAlias); + QDeclarativePropertyData *data = propertyCache->property(index); + data->setFlags(data->getFlags() | QDeclarativePropertyData::IsAlias); } } @@ -1529,7 +1529,7 @@ bool QDeclarativeCompiler::buildSignal(QDeclarativeScript::Property *prop, QDecl bool notInRevision = false; - QDeclarativePropertyCache::Data *sig = signal(obj, QStringRef(&name), ¬InRevision); + QDeclarativePropertyData *sig = signal(obj, QStringRef(&name), ¬InRevision); if (sig == 0) { @@ -1634,7 +1634,7 @@ bool QDeclarativeCompiler::buildProperty(QDeclarativeScript::Property *prop, } else { // Setup regular property data bool notInRevision = false; - QDeclarativePropertyCache::Data *d = + QDeclarativePropertyData *d = prop->name().isEmpty()?0:property(obj, prop->name(), ¬InRevision); if (d == 0 && notInRevision) { @@ -1650,7 +1650,7 @@ bool QDeclarativeCompiler::buildProperty(QDeclarativeScript::Property *prop, prop->core = *d; } else if (prop->isDefault) { QMetaProperty p = QDeclarativeMetaType::defaultProperty(metaObject); - QDeclarativePropertyCache::Data defaultPropertyData; + QDeclarativePropertyData defaultPropertyData; defaultPropertyData.load(p, engine); if (p.name()) prop->setName(QLatin1String(p.name())); @@ -2056,7 +2056,7 @@ bool QDeclarativeCompiler::buildValueTypeProperty(QObject *type, for (Property *prop = obj->properties.first(); prop; prop = obj->properties.next(prop)) { - QDeclarativePropertyCache::Data *d = property(obj, prop->name()); + QDeclarativePropertyData *d = property(obj, prop->name()); if (d == 0) COMPILE_EXCEPTION(prop, tr("Cannot assign to non-existent property \"%1\"").arg(prop->name().toString())); @@ -2627,7 +2627,7 @@ bool QDeclarativeCompiler::buildDynamicMeta(QDeclarativeScript::Object *obj, Dyn if (!resolveAlias) { // No point doing this for both the alias and non alias cases - QDeclarativePropertyCache::Data *d = property(obj, p->name); + QDeclarativePropertyData *d = property(obj, p->name); if (d && d->isFinal()) COMPILE_EXCEPTION(p, tr("Cannot override FINAL property")); } @@ -2988,16 +2988,16 @@ bool QDeclarativeCompiler::buildDynamicMeta(QDeclarativeScript::Object *obj, Dyn if (obj->type != -1) { QDeclarativePropertyCache *cache = output->types[obj->type].createPropertyCache(engine)->copy(); cache->append(engine, &obj->extObject, - QDeclarativePropertyCache::Data::NoFlags, - QDeclarativePropertyCache::Data::IsVMEFunction, - QDeclarativePropertyCache::Data::IsVMESignal); + QDeclarativePropertyData::NoFlags, + QDeclarativePropertyData::IsVMEFunction, + QDeclarativePropertyData::IsVMESignal); // now we modify the flags appropriately for var properties. int propertyOffset = obj->extObject.propertyOffset(); - QDeclarativePropertyCache::Data *currPropData = 0; + QDeclarativePropertyData *currPropData = 0; for (int pvi = firstPropertyVarIndex; pvi < totalPropCount; ++pvi) { currPropData = cache->property(pvi + propertyOffset); - currPropData->setFlags(currPropData->getFlags() | QDeclarativePropertyCache::Data::IsVMEProperty); + currPropData->setFlags(currPropData->getFlags() | QDeclarativePropertyData::IsVMEProperty); } obj->synthCache = cache; @@ -3275,7 +3275,7 @@ int QDeclarativeCompiler::genContextCache() return output->contextCaches.count() - 1; } -QDeclarativePropertyCache::Data +QDeclarativePropertyData QDeclarativeCompiler::genValueTypeData(QDeclarativeScript::Property *valueTypeProp, QDeclarativeScript::Property *prop) { @@ -3498,7 +3498,7 @@ QStringList QDeclarativeCompiler::deferredProperties(QDeclarativeScript::Object return rv; } -QDeclarativePropertyCache::Data * +QDeclarativePropertyData * QDeclarativeCompiler::property(QDeclarativeScript::Object *object, int index) { QDeclarativePropertyCache *cache = 0; @@ -3513,7 +3513,7 @@ QDeclarativeCompiler::property(QDeclarativeScript::Object *object, int index) return cache->property(index); } -QDeclarativePropertyCache::Data * +QDeclarativePropertyData * QDeclarativeCompiler::property(QDeclarativeScript::Object *object, const QHashedStringRef &name, bool *notInRevision) { if (notInRevision) *notInRevision = false; @@ -3527,7 +3527,7 @@ QDeclarativeCompiler::property(QDeclarativeScript::Object *object, const QHashed else cache = QDeclarativeEnginePrivate::get(engine)->cache(object->metaObject()); - QDeclarativePropertyCache::Data *d = cache->property(name); + QDeclarativePropertyData *d = cache->property(name); // Find the first property while (d && d->isFunction()) @@ -3542,7 +3542,7 @@ QDeclarativeCompiler::property(QDeclarativeScript::Object *object, const QHashed } // This code must match the semantics of QDeclarativePropertyPrivate::findSignalByName -QDeclarativePropertyCache::Data * +QDeclarativePropertyData * QDeclarativeCompiler::signal(QDeclarativeScript::Object *object, const QHashedStringRef &name, bool *notInRevision) { if (notInRevision) *notInRevision = false; @@ -3557,7 +3557,7 @@ QDeclarativeCompiler::signal(QDeclarativeScript::Object *object, const QHashedSt cache = QDeclarativeEnginePrivate::get(engine)->cache(object->metaObject()); - QDeclarativePropertyCache::Data *d = cache->property(name); + QDeclarativePropertyData *d = cache->property(name); if (notInRevision) *notInRevision = false; while (d && !(d->isFunction())) @@ -3585,7 +3585,7 @@ QDeclarativeCompiler::signal(QDeclarativeScript::Object *object, const QHashedSt int QDeclarativeCompiler::indexOfSignal(QDeclarativeScript::Object *object, const QString &name, bool *notInRevision) { - QDeclarativePropertyCache::Data *d = signal(object, QStringRef(&name), notInRevision); + QDeclarativePropertyData *d = signal(object, QStringRef(&name), notInRevision); return d?d->coreIndex:-1; } @@ -3598,7 +3598,7 @@ int QDeclarativeCompiler::indexOfProperty(QDeclarativeScript::Object *object, co int QDeclarativeCompiler::indexOfProperty(QDeclarativeScript::Object *object, const QHashedStringRef &name, bool *notInRevision) { - QDeclarativePropertyCache::Data *d = property(object, name, notInRevision); + QDeclarativePropertyData *d = property(object, name, notInRevision); return d?d->coreIndex:-1; } diff --git a/src/declarative/qml/qdeclarativecompiler_p.h b/src/declarative/qml/qdeclarativecompiler_p.h index ef37335..2615109 100644 --- a/src/declarative/qml/qdeclarativecompiler_p.h +++ b/src/declarative/qml/qdeclarativecompiler_p.h @@ -373,8 +373,8 @@ private: QDeclarativeScript::Property *valueTypeProperty = 0); int genContextCache(); - QDeclarativePropertyCache::Data genValueTypeData(QDeclarativeScript::Property *prop, - QDeclarativeScript::Property *valueTypeProp); + QDeclarativePropertyData genValueTypeData(QDeclarativeScript::Property *prop, + QDeclarativeScript::Property *valueTypeProp); int componentTypeRef(); @@ -385,11 +385,11 @@ private: QStringList deferredProperties(QDeclarativeScript::Object *); - QDeclarativePropertyCache::Data *property(QDeclarativeScript::Object *, int); - QDeclarativePropertyCache::Data *property(QDeclarativeScript::Object *, const QHashedStringRef &, - bool *notInRevision = 0); - QDeclarativePropertyCache::Data *signal(QDeclarativeScript::Object *, const QHashedStringRef &, - bool *notInRevision = 0); + QDeclarativePropertyData *property(QDeclarativeScript::Object *, int); + QDeclarativePropertyData *property(QDeclarativeScript::Object *, const QHashedStringRef &, + bool *notInRevision = 0); + QDeclarativePropertyData *signal(QDeclarativeScript::Object *, const QHashedStringRef &, + bool *notInRevision = 0); int indexOfProperty(QDeclarativeScript::Object *, const QHashedStringRef &, bool *notInRevision = 0); int indexOfProperty(QDeclarativeScript::Object *, const QString &, bool *notInRevision = 0); int indexOfSignal(QDeclarativeScript::Object *, const QString &, bool *notInRevision = 0); diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp index d4662cf..c9ae825 100644 --- a/src/declarative/qml/qdeclarativecontext.cpp +++ b/src/declarative/qml/qdeclarativecontext.cpp @@ -381,8 +381,8 @@ QVariant QDeclarativeContext::contextProperty(const QString &name) const QByteArray utf8Name = name.toUtf8(); if (data->contextObject) { QObject *obj = data->contextObject; - QDeclarativePropertyCache::Data local; - QDeclarativePropertyCache::Data *property = + QDeclarativePropertyData local; + QDeclarativePropertyData *property = QDeclarativePropertyCache::property(data->engine, obj, name, local); if (property) value = obj->metaObject()->property(property->coreIndex).read(obj); diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 673ac42..1f539ee 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -1659,12 +1659,12 @@ QDeclarativePropertyCache *QDeclarativeEnginePrivate::createCache(QDeclarativeTy !overloadError && iter != raw->stringCache.end(); ++iter) { - QDeclarativePropertyCache::Data *d = *iter; + QDeclarativePropertyData *d = *iter; if (raw->isAllowedInRevision(d)) continue; // Not excluded - no problems // check that a regular "name" overload isn't happening - QDeclarativePropertyCache::Data *current = d; + QDeclarativePropertyData *current = d; while (!overloadError && current) { current = d->overrideData(current); if (current && raw->isAllowedInRevision(current)) diff --git a/src/declarative/qml/qdeclarativeinstruction_p.h b/src/declarative/qml/qdeclarativeinstruction_p.h index 7b36c9a..8940e99 100644 --- a/src/declarative/qml/qdeclarativeinstruction_p.h +++ b/src/declarative/qml/qdeclarativeinstruction_p.h @@ -211,13 +211,13 @@ union QDeclarativeInstruction }; struct instr_assignValueSource { QML_INSTR_HEADER - QDeclarativePropertyCache::RawData property; + QDeclarativePropertyRawData property; int owner; int castValue; }; struct instr_assignValueInterceptor { QML_INSTR_HEADER - QDeclarativePropertyCache::RawData property; + QDeclarativePropertyRawData property; int owner; int castValue; }; @@ -238,7 +238,7 @@ union QDeclarativeInstruction }; struct instr_assignBinding { QML_INSTR_HEADER - QDeclarativePropertyCache::RawData property; + QDeclarativePropertyRawData property; int value; short context; short owner; diff --git a/src/declarative/qml/qdeclarativelist.cpp b/src/declarative/qml/qdeclarativelist.cpp index 04cef6c..c717ed0 100644 --- a/src/declarative/qml/qdeclarativelist.cpp +++ b/src/declarative/qml/qdeclarativelist.cpp @@ -135,8 +135,8 @@ QDeclarativeListReference::QDeclarativeListReference(QObject *object, const char { if (!object || !property) return; - QDeclarativePropertyCache::Data local; - QDeclarativePropertyCache::Data *data = + QDeclarativePropertyData local; + QDeclarativePropertyData *data = QDeclarativePropertyCache::property(engine, object, QLatin1String(property), local); if (!data || !data->isQList()) return; diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp index 9e4770f..ea3df6c 100644 --- a/src/declarative/qml/qdeclarativeproperty.cpp +++ b/src/declarative/qml/qdeclarativeproperty.cpp @@ -266,8 +266,8 @@ void QDeclarativePropertyPrivate::initProperty(QObject *obj, const QString &name } - QDeclarativePropertyCache::Data local; - QDeclarativePropertyCache::Data *property = + QDeclarativePropertyData local; + QDeclarativePropertyData *property = QDeclarativePropertyCache::property(engine, obj, pathName, local); if (!property) return; // Not a property @@ -285,7 +285,7 @@ void QDeclarativePropertyPrivate::initProperty(QObject *obj, const QString &name QMetaProperty vtProp = typeObject->metaObject()->property(idx); - typedef QDeclarativePropertyCache::Data PCD; + typedef QDeclarativePropertyData PCD; Q_ASSERT(PCD::flagsForProperty(vtProp) <= PCD::ValueTypeFlagMask); Q_ASSERT(vtProp.userType() <= 0xFF); @@ -330,8 +330,8 @@ void QDeclarativePropertyPrivate::initProperty(QObject *obj, const QString &name } // Property - QDeclarativePropertyCache::Data local; - QDeclarativePropertyCache::Data *property = + QDeclarativePropertyData local; + QDeclarativePropertyData *property = QDeclarativePropertyCache::property(engine, currentObject, terminal, local); if (property && !property->isFunction()) { object = currentObject; @@ -707,7 +707,7 @@ QDeclarativePropertyPrivate::binding(QObject *object, int coreIndex, int valueTy if (!data) return 0; - QDeclarativePropertyCache::Data *propertyData = + QDeclarativePropertyData *propertyData = data->propertyCache?data->propertyCache->property(coreIndex):0; if (propertyData && propertyData->isAlias()) { const QDeclarativeVMEMetaObject *vme = @@ -748,7 +748,7 @@ void QDeclarativePropertyPrivate::findAliasTarget(QObject *object, int bindingIn QDeclarativeData *data = QDeclarativeData::get(object, false); if (data) { - QDeclarativePropertyCache::Data *propertyData = + QDeclarativePropertyData *propertyData = data->propertyCache?data->propertyCache->property(coreIndex):0; if (propertyData && propertyData->isAlias()) { const QDeclarativeVMEMetaObject *vme = @@ -782,7 +782,7 @@ QDeclarativePropertyPrivate::setBinding(QObject *object, int coreIndex, int valu QDeclarativeAbstractBinding *binding = 0; if (data) { - QDeclarativePropertyCache::Data *propertyData = + QDeclarativePropertyData *propertyData = data->propertyCache?data->propertyCache->property(coreIndex):0; if (propertyData && propertyData->isAlias()) { const QDeclarativeVMEMetaObject *vme = @@ -836,7 +836,7 @@ QDeclarativePropertyPrivate::setBindingNoEnable(QObject *object, int coreIndex, QDeclarativeAbstractBinding *binding = 0; if (data) { - QDeclarativePropertyCache::Data *propertyData = + QDeclarativePropertyData *propertyData = data->propertyCache?data->propertyCache->property(coreIndex):0; if (propertyData && propertyData->isAlias()) { const QDeclarativeVMEMetaObject *vme = @@ -1089,7 +1089,7 @@ bool QDeclarativePropertyPrivate::writeValueProperty(const QVariant &value, Writ bool QDeclarativePropertyPrivate::writeValueProperty(QObject *object, QDeclarativeEngine *engine, - const QDeclarativePropertyCache::Data &core, + const QDeclarativePropertyData &core, const QVariant &value, QDeclarativeContextData *context, WriteFlags flags) { @@ -1114,8 +1114,8 @@ QDeclarativePropertyPrivate::writeValueProperty(QObject *object, QDeclarativeEng writeBack->read(object, core.coreIndex); - QDeclarativePropertyCache::Data data = core; - data.setFlags(QDeclarativePropertyCache::Data::Flag(core.valueTypeFlags)); + QDeclarativePropertyData data = core; + data.setFlags(QDeclarativePropertyData::Flag(core.valueTypeFlags)); data.coreIndex = core.valueTypeCoreIndex; data.propType = core.valueTypePropType; @@ -1134,7 +1134,7 @@ QDeclarativePropertyPrivate::writeValueProperty(QObject *object, QDeclarativeEng } bool QDeclarativePropertyPrivate::write(QObject *object, - const QDeclarativePropertyCache::Data &property, + const QDeclarativePropertyData &property, const QVariant &value, QDeclarativeContextData *context, WriteFlags flags) { @@ -1298,7 +1298,7 @@ bool QDeclarativePropertyPrivate::write(QObject *object, // Returns true if successful, false if an error description was set on expression bool QDeclarativePropertyPrivate::writeBinding(QObject *object, - const QDeclarativePropertyCache::Data &core, + const QDeclarativePropertyData &core, QDeclarativeJavaScriptExpression *expression, v8::Handle result, bool isUndefined, WriteFlags flags) @@ -1606,7 +1606,7 @@ int QDeclarativePropertyPrivate::bindingIndex(const QDeclarativeProperty &that) return bindingIndex(that.d->core); } -int QDeclarativePropertyPrivate::bindingIndex(const QDeclarativePropertyCache::Data &that) +int QDeclarativePropertyPrivate::bindingIndex(const QDeclarativePropertyData &that) { int rv = that.coreIndex; if (rv != -1 && that.isValueTypeVirtual()) @@ -1614,7 +1614,7 @@ int QDeclarativePropertyPrivate::bindingIndex(const QDeclarativePropertyCache::D return rv; } -QDeclarativePropertyCache::Data +QDeclarativePropertyData QDeclarativePropertyPrivate::saveValueType(const QMetaObject *metaObject, int index, const QMetaObject *subObject, int subIndex, QDeclarativeEngine *) @@ -1622,10 +1622,10 @@ QDeclarativePropertyPrivate::saveValueType(const QMetaObject *metaObject, int in QMetaProperty prop = metaObject->property(index); QMetaProperty subProp = subObject->property(subIndex); - QDeclarativePropertyCache::Data core; + QDeclarativePropertyData core; core.load(metaObject->property(index)); - core.setFlags(core.getFlags() | QDeclarativePropertyCache::Data::IsValueTypeVirtual); - core.valueTypeFlags = QDeclarativePropertyCache::Data::flagsForProperty(subProp); + core.setFlags(core.getFlags() | QDeclarativePropertyData::IsValueTypeVirtual); + core.valueTypeFlags = QDeclarativePropertyData::flagsForProperty(subProp); core.valueTypeCoreIndex = subIndex; core.valueTypePropType = subProp.userType(); @@ -1633,7 +1633,7 @@ QDeclarativePropertyPrivate::saveValueType(const QMetaObject *metaObject, int in } QDeclarativeProperty -QDeclarativePropertyPrivate::restore(const QDeclarativePropertyCache::Data &data, +QDeclarativePropertyPrivate::restore(const QDeclarativePropertyData &data, QObject *object, QDeclarativeContextData *ctxt) { QDeclarativeProperty prop; @@ -1737,7 +1737,7 @@ static inline void flush_vme_signal(const QObject *object, int index) { QDeclarativeData *data = static_cast(QObjectPrivate::get(const_cast(object))->declarativeData); if (data && data->propertyCache) { - QDeclarativePropertyCache::Data *property = data->propertyCache->method(index); + QDeclarativePropertyData *property = data->propertyCache->method(index); if (property && property->isVMESignal()) { const QMetaObject *metaObject = object->metaObject(); diff --git a/src/declarative/qml/qdeclarativeproperty_p.h b/src/declarative/qml/qdeclarativeproperty_p.h index 5bfbf47..f2e86dd 100644 --- a/src/declarative/qml/qdeclarativeproperty_p.h +++ b/src/declarative/qml/qdeclarativeproperty_p.h @@ -81,7 +81,7 @@ public: QDeclarativeGuard object; bool isNameCached:1; - QDeclarativePropertyCache::Data core; + QDeclarativePropertyData core; QString nameCache; void initProperty(QObject *obj, const QString &name); @@ -99,10 +99,10 @@ public: static bool writeEnumProperty(const QMetaProperty &prop, int idx, QObject *object, const QVariant &value, int flags); static bool writeValueProperty(QObject *, QDeclarativeEngine *, - const QDeclarativePropertyCache::Data &, + const QDeclarativePropertyData &, const QVariant &, QDeclarativeContextData *, WriteFlags flags = 0); - static bool write(QObject *, const QDeclarativePropertyCache::Data &, const QVariant &, + static bool write(QObject *, const QDeclarativePropertyData &, const QVariant &, QDeclarativeContextData *, WriteFlags flags = 0); static void findAliasTarget(QObject *, int, QObject **, int *); static QDeclarativeAbstractBinding *setBinding(QObject *, int coreIndex, int valueTypeIndex /* -1 */, @@ -112,10 +112,10 @@ public: QDeclarativeAbstractBinding *); static QDeclarativeAbstractBinding *binding(QObject *, int coreIndex, int valueTypeIndex /* -1 */); - static QDeclarativePropertyCache::Data saveValueType(const QMetaObject *, int, - const QMetaObject *, int, - QDeclarativeEngine *); - static QDeclarativeProperty restore(const QDeclarativePropertyCache::Data &, + static QDeclarativePropertyData saveValueType(const QMetaObject *, int, + const QMetaObject *, int, + QDeclarativeEngine *); + static QDeclarativeProperty restore(const QDeclarativePropertyData &, QObject *, QDeclarativeContextData *); @@ -138,13 +138,13 @@ public: QDeclarativeJavaScriptExpression *expression, v8::Handle result, bool isUndefined, WriteFlags flags); - static bool writeBinding(QObject *, const QDeclarativePropertyCache::Data &, + static bool writeBinding(QObject *, const QDeclarativePropertyData &, QDeclarativeJavaScriptExpression *expression, v8::Handle 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 int bindingIndex(const QDeclarativePropertyData &that); static QMetaMethod findSignalByName(const QMetaObject *mo, const QByteArray &); static bool connect(const QObject *sender, int signal_index, const QObject *receiver, int method_index, diff --git a/src/declarative/qml/qdeclarativepropertycache.cpp b/src/declarative/qml/qdeclarativepropertycache.cpp index 6cb952e..d997319 100644 --- a/src/declarative/qml/qdeclarativepropertycache.cpp +++ b/src/declarative/qml/qdeclarativepropertycache.cpp @@ -63,58 +63,58 @@ public: // Flags that do *NOT* depend on the property's QMetaProperty::userType() and thus are quick // to load -static QDeclarativePropertyCache::Data::Flags fastFlagsForProperty(const QMetaProperty &p) +static QDeclarativePropertyData::Flags fastFlagsForProperty(const QMetaProperty &p) { - QDeclarativePropertyCache::Data::Flags flags; + QDeclarativePropertyData::Flags flags; if (p.isConstant()) - flags |= QDeclarativePropertyCache::Data::IsConstant; + flags |= QDeclarativePropertyData::IsConstant; if (p.isWritable()) - flags |= QDeclarativePropertyCache::Data::IsWritable; + flags |= QDeclarativePropertyData::IsWritable; if (p.isResettable()) - flags |= QDeclarativePropertyCache::Data::IsResettable; + flags |= QDeclarativePropertyData::IsResettable; if (p.isFinal()) - flags |= QDeclarativePropertyCache::Data::IsFinal; + flags |= QDeclarativePropertyData::IsFinal; if (p.isEnumType()) - flags |= QDeclarativePropertyCache::Data::IsEnumType; + flags |= QDeclarativePropertyData::IsEnumType; return flags; } // Flags that do depend on the property's QMetaProperty::userType() and thus are slow to // load -static QDeclarativePropertyCache::Data::Flags flagsForPropertyType(int propType, QDeclarativeEngine *engine) +static QDeclarativePropertyData::Flags flagsForPropertyType(int propType, QDeclarativeEngine *engine) { - QDeclarativePropertyCache::Data::Flags flags; + QDeclarativePropertyData::Flags flags; if (propType < QMetaType::User && propType != QMetaType::QObjectStar && propType != QMetaType::QWidgetStar) { } else if (propType == qMetaTypeId()) { - flags |= QDeclarativePropertyCache::Data::IsQmlBinding; + flags |= QDeclarativePropertyData::IsQmlBinding; } else if (propType == qMetaTypeId()) { - flags |= QDeclarativePropertyCache::Data::IsQJSValue; + flags |= QDeclarativePropertyData::IsQJSValue; } else if (propType == qMetaTypeId()) { - flags |= QDeclarativePropertyCache::Data::IsV8Handle; + flags |= QDeclarativePropertyData::IsV8Handle; } else { QDeclarativeMetaType::TypeCategory cat = engine ? QDeclarativeEnginePrivate::get(engine)->typeCategory(propType) : QDeclarativeMetaType::typeCategory(propType); if (cat == QDeclarativeMetaType::Object) - flags |= QDeclarativePropertyCache::Data::IsQObjectDerived; + flags |= QDeclarativePropertyData::IsQObjectDerived; else if (cat == QDeclarativeMetaType::List) - flags |= QDeclarativePropertyCache::Data::IsQList; + flags |= QDeclarativePropertyData::IsQList; } return flags; } -QDeclarativePropertyCache::Data::Flags -QDeclarativePropertyCache::Data::flagsForProperty(const QMetaProperty &p, QDeclarativeEngine *engine) +QDeclarativePropertyData::Flags +QDeclarativePropertyData::flagsForProperty(const QMetaProperty &p, QDeclarativeEngine *engine) { return fastFlagsForProperty(p) | flagsForPropertyType(p.userType(), engine); } -void QDeclarativePropertyCache::Data::lazyLoad(const QMetaProperty &p, QDeclarativeEngine *engine) +void QDeclarativePropertyData::lazyLoad(const QMetaProperty &p, QDeclarativeEngine *engine) { Q_UNUSED(engine); @@ -127,16 +127,16 @@ void QDeclarativePropertyCache::Data::lazyLoad(const QMetaProperty &p, QDeclarat int type = p.type(); if (type == QMetaType::QObjectStar || type == QMetaType::QWidgetStar) { propType = type; - flags |= QDeclarativePropertyCache::Data::IsQObjectDerived; + flags |= QDeclarativePropertyData::IsQObjectDerived; } else if (type == QVariant::UserType || type == -1) { propTypeName = p.typeName(); - flags |= QDeclarativePropertyCache::Data::NotFullyResolved; + flags |= QDeclarativePropertyData::NotFullyResolved; } else { propType = type; } } -void QDeclarativePropertyCache::Data::load(const QMetaProperty &p, QDeclarativeEngine *engine) +void QDeclarativePropertyData::load(const QMetaProperty &p, QDeclarativeEngine *engine) { propType = p.userType(); if (QVariant::Type(propType) == QVariant::LastType) @@ -147,13 +147,13 @@ void QDeclarativePropertyCache::Data::load(const QMetaProperty &p, QDeclarativeE revision = p.revision(); } -void QDeclarativePropertyCache::Data::load(const QMetaMethod &m) +void QDeclarativePropertyData::load(const QMetaMethod &m) { coreIndex = m.methodIndex(); arguments = 0; - flags |= Data::IsFunction; + flags |= IsFunction; if (m.methodType() == QMetaMethod::Signal) - flags |= Data::IsSignal; + flags |= IsSignal; propType = QVariant::Invalid; const char *returnType = m.typeName(); @@ -165,28 +165,28 @@ void QDeclarativePropertyCache::Data::load(const QMetaMethod &m) ++signature; if (*signature != ')') { - flags |= Data::HasArguments; + flags |= HasArguments; if (0 == ::strcmp(signature, "QDeclarativeV8Function*)")) { - flags |= Data::IsV8Function; + flags |= IsV8Function; } } revision = m.revision(); } -void QDeclarativePropertyCache::Data::lazyLoad(const QMetaMethod &m) +void QDeclarativePropertyData::lazyLoad(const QMetaMethod &m) { coreIndex = m.methodIndex(); arguments = 0; - flags |= Data::IsFunction; + flags |= IsFunction; if (m.methodType() == QMetaMethod::Signal) - flags |= Data::IsSignal; + flags |= IsSignal; propType = QVariant::Invalid; const char *returnType = m.typeName(); if (returnType && *returnType) { propTypeName = returnType; - flags |= Data::NotFullyResolved; + flags |= NotFullyResolved; } const char *signature = m.signature(); @@ -194,9 +194,9 @@ void QDeclarativePropertyCache::Data::lazyLoad(const QMetaMethod &m) ++signature; if (*signature != ')') { - flags |= Data::HasArguments; + flags |= HasArguments; if (0 == ::strcmp(signature, "QDeclarativeV8Function*)")) { - flags |= Data::IsV8Function; + flags |= IsV8Function; } } @@ -259,12 +259,12 @@ void QDeclarativePropertyCache::clear() engine = 0; } -QDeclarativePropertyCache::Data QDeclarativePropertyCache::create(const QMetaObject *metaObject, - const QString &property) +QDeclarativePropertyData QDeclarativePropertyCache::create(const QMetaObject *metaObject, + const QString &property) { Q_ASSERT(metaObject); - QDeclarativePropertyCache::Data rv; + QDeclarativePropertyData rv; { const QMetaObject *cmo = metaObject; const QByteArray propertyName = property.toUtf8(); @@ -322,14 +322,18 @@ QDeclarativePropertyCache *QDeclarativePropertyCache::copy(int reserve) } void QDeclarativePropertyCache::append(QDeclarativeEngine *engine, const QMetaObject *metaObject, - Data::Flag propertyFlags, Data::Flag methodFlags, Data::Flag signalFlags) + QDeclarativePropertyData::Flag propertyFlags, + QDeclarativePropertyData::Flag methodFlags, + QDeclarativePropertyData::Flag signalFlags) { append(engine, metaObject, -1, propertyFlags, methodFlags, signalFlags); } void QDeclarativePropertyCache::append(QDeclarativeEngine *engine, const QMetaObject *metaObject, int revision, - Data::Flag propertyFlags, Data::Flag methodFlags, Data::Flag signalFlags) + QDeclarativePropertyData::Flag propertyFlags, + QDeclarativePropertyData::Flag methodFlags, + QDeclarativePropertyData::Flag signalFlags) { Q_UNUSED(revision); Q_ASSERT(constructor.IsEmpty()); // We should not be appending to an in-use property cache @@ -364,8 +368,8 @@ void QDeclarativePropertyCache::append(QDeclarativeEngine *engine, const QMetaOb ++cptr; } - Data *data = &methodIndexCache[ii - methodIndexCacheStart]; - Data *sigdata = 0; + QDeclarativePropertyData *data = &methodIndexCache[ii - methodIndexCacheStart]; + QDeclarativePropertyData *sigdata = 0; data->lazyLoad(m); @@ -375,21 +379,21 @@ void QDeclarativePropertyCache::append(QDeclarativeEngine *engine, const QMetaOb data->flags |= methodFlags; if (!dynamicMetaObject) - data->flags |= Data::IsDirect; + data->flags |= QDeclarativePropertyData::IsDirect; data->metaObjectOffset = allowedRevisionCache.count() - 1; if (data->isSignal()) { sigdata = &signalHandlerIndexCache[signalHandlerIndex]; *sigdata = *data; - sigdata->flags |= Data::IsSignalHandler; + sigdata->flags |= QDeclarativePropertyData::IsSignalHandler; } - Data *old = 0; + QDeclarativePropertyData *old = 0; if (utf8) { QHashedString methodName(QString::fromUtf8(signature, cptr - signature)); - if (Data **it = stringCache.value(methodName)) + if (QDeclarativePropertyData **it = stringCache.value(methodName)) old = *it; stringCache.insert(methodName, data); @@ -400,7 +404,7 @@ void QDeclarativePropertyCache::append(QDeclarativeEngine *engine, const QMetaOb } } else { QHashedCStringRef methodName(signature, cptr - signature); - if (Data **it = stringCache.value(methodName)) + if (QDeclarativePropertyData **it = stringCache.value(methodName)) old = *it; stringCache.insert(methodName, data); @@ -423,9 +427,9 @@ void QDeclarativePropertyCache::append(QDeclarativeEngine *engine, const QMetaOb if (old) { // We only overload methods in the same class, exactly like C++ - if (old->flags & Data::IsFunction && old->coreIndex >= methodOffset) - data->flags |= Data::IsOverload; - data->overrideIndexIsProperty = !bool(old->flags & Data::IsFunction); + if (old->isFunction() && old->coreIndex >= methodOffset) + data->flags |= QDeclarativePropertyData::IsOverload; + data->overrideIndexIsProperty = !old->isFunction(); data->overrideIndex = old->coreIndex; } } @@ -447,38 +451,38 @@ void QDeclarativePropertyCache::append(QDeclarativeEngine *engine, const QMetaOb ++cptr; } - Data *data = &propertyIndexCache[ii - propertyIndexCacheStart]; + QDeclarativePropertyData *data = &propertyIndexCache[ii - propertyIndexCacheStart]; data->lazyLoad(p, engine); data->flags |= propertyFlags; if (!dynamicMetaObject) - data->flags |= Data::IsDirect; + data->flags |= QDeclarativePropertyData::IsDirect; data->metaObjectOffset = allowedRevisionCache.count() - 1; - Data *old = 0; + QDeclarativePropertyData *old = 0; if (utf8) { QHashedString propName(QString::fromUtf8(str, cptr - str)); - if (Data **it = stringCache.value(propName)) + if (QDeclarativePropertyData **it = stringCache.value(propName)) old = *it; stringCache.insert(propName, data); } else { QHashedCStringRef propName(str, cptr - str); - if (Data **it = stringCache.value(propName)) + if (QDeclarativePropertyData **it = stringCache.value(propName)) old = *it; stringCache.insert(propName, data); } if (old) { - data->overrideIndexIsProperty = !bool(old->flags & Data::IsFunction); + data->overrideIndexIsProperty = !old->isFunction(); data->overrideIndex = old->coreIndex; } } } -void QDeclarativePropertyCache::resolve(Data *data) const +void QDeclarativePropertyCache::resolve(QDeclarativePropertyData *data) const { Q_ASSERT(data->notFullyResolved()); @@ -487,10 +491,10 @@ void QDeclarativePropertyCache::resolve(Data *data) const data->propType = qMetaTypeId(); - if (!(data->flags & Data::IsFunction)) + if (!data->isFunction()) data->flags |= flagsForPropertyType(data->propType, engine); - data->flags &= ~Data::NotFullyResolved; + data->flags &= ~QDeclarativePropertyData::NotFullyResolved; } void QDeclarativePropertyCache::updateRecur(QDeclarativeEngine *engine, const QMetaObject *metaObject) @@ -520,7 +524,7 @@ void QDeclarativePropertyCache::update(QDeclarativeEngine *engine, const QMetaOb updateRecur(engine,metaObject); } -QDeclarativePropertyCache::Data * +QDeclarativePropertyData * QDeclarativePropertyCache::property(int index) const { if (index < 0 || index >= (propertyIndexCacheStart + propertyIndexCache.count())) @@ -529,12 +533,12 @@ QDeclarativePropertyCache::property(int index) const if (index < propertyIndexCacheStart) return parent->property(index); - Data *rv = const_cast(&propertyIndexCache.at(index - propertyIndexCacheStart)); + QDeclarativePropertyData *rv = const_cast(&propertyIndexCache.at(index - propertyIndexCacheStart)); if (rv->notFullyResolved()) resolve(rv); return rv; } -QDeclarativePropertyCache::Data * +QDeclarativePropertyData * QDeclarativePropertyCache::method(int index) const { if (index < 0 || index >= (methodIndexCacheStart + methodIndexCache.count())) @@ -543,36 +547,36 @@ QDeclarativePropertyCache::method(int index) const if (index < methodIndexCacheStart) return parent->method(index); - Data *rv = const_cast(&methodIndexCache.at(index - methodIndexCacheStart)); + QDeclarativePropertyData *rv = const_cast(&methodIndexCache.at(index - methodIndexCacheStart)); if (rv->notFullyResolved()) resolve(rv); return rv; } -QDeclarativePropertyCache::Data * +QDeclarativePropertyData * QDeclarativePropertyCache::property(const QHashedStringRef &str) const { - QDeclarativePropertyCache::Data **rv = stringCache.value(str); + QDeclarativePropertyData **rv = stringCache.value(str); if (rv && (*rv)->notFullyResolved()) resolve(*rv); return rv?*rv:0; } -QDeclarativePropertyCache::Data * +QDeclarativePropertyData * QDeclarativePropertyCache::property(const QHashedCStringRef &str) const { - QDeclarativePropertyCache::Data **rv = stringCache.value(str); + QDeclarativePropertyData **rv = stringCache.value(str); if (rv && (*rv)->notFullyResolved()) resolve(*rv); return rv?*rv:0; } -QDeclarativePropertyCache::Data * +QDeclarativePropertyData * QDeclarativePropertyCache::property(const QString &str) const { - QDeclarativePropertyCache::Data **rv = stringCache.value(str); + QDeclarativePropertyData **rv = stringCache.value(str); if (rv && (*rv)->notFullyResolved()) resolve(*rv); return rv?*rv:0; } -QString QDeclarativePropertyCache::Data::name(QObject *object) +QString QDeclarativePropertyData::name(QObject *object) { if (!object) return QString(); @@ -580,7 +584,7 @@ QString QDeclarativePropertyCache::Data::name(QObject *object) return name(object->metaObject()); } -QString QDeclarativePropertyCache::Data::name(const QMetaObject *metaObject) +QString QDeclarativePropertyData::name(const QMetaObject *metaObject) { if (!metaObject || coreIndex == -1) return QString(); @@ -645,7 +649,7 @@ int *QDeclarativePropertyCache::methodParameterTypes(QObject *object, int index, while (index < c->methodIndexCacheStart) c = c->parent; - Data *rv = const_cast(&c->methodIndexCache.at(index - c->methodIndexCacheStart)); + QDeclarativePropertyData *rv = const_cast(&c->methodIndexCache.at(index - c->methodIndexCacheStart)); if (rv->arguments) return static_cast(rv->arguments)->arguments; @@ -695,9 +699,9 @@ int *QDeclarativePropertyCache::methodParameterTypes(QObject *object, int index, } } -QDeclarativePropertyCache::Data * +QDeclarativePropertyData * QDeclarativePropertyCache::property(QDeclarativeEngine *engine, QObject *obj, - const QHashedV8String &name, Data &local) + const QHashedV8String &name, QDeclarativePropertyData &local) { // XXX Optimize for worker script case where engine isn't available QDeclarativePropertyCache *cache = 0; @@ -713,7 +717,7 @@ QDeclarativePropertyCache::property(QDeclarativeEngine *engine, QObject *obj, } } - QDeclarativePropertyCache::Data *rv = 0; + QDeclarativePropertyData *rv = 0; if (cache) { rv = cache->property(name); @@ -728,11 +732,11 @@ QDeclarativePropertyCache::property(QDeclarativeEngine *engine, QObject *obj, return rv; } -QDeclarativePropertyCache::Data * +QDeclarativePropertyData * QDeclarativePropertyCache::property(QDeclarativeEngine *engine, QObject *obj, - const QString &name, Data &local) + const QString &name, QDeclarativePropertyData &local) { - QDeclarativePropertyCache::Data *rv = 0; + QDeclarativePropertyData *rv = 0; if (!engine) { local = QDeclarativePropertyCache::create(obj->metaObject(), name); diff --git a/src/declarative/qml/qdeclarativepropertycache_p.h b/src/declarative/qml/qdeclarativepropertycache_p.h index 176d6b3..fc4a24c 100644 --- a/src/declarative/qml/qdeclarativepropertycache_p.h +++ b/src/declarative/qml/qdeclarativepropertycache_p.h @@ -68,161 +68,172 @@ class QMetaProperty; class QV8Engine; class QV8QObjectWrapper; class QDeclarativePropertyCacheMethodArguments; +class QDeclarativePropertyData; -class Q_DECLARATIVE_EXPORT QDeclarativePropertyCache : public QDeclarativeRefCount, public QDeclarativeCleanup +// 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. +class QDeclarativePropertyRawData { public: - QDeclarativePropertyCache(QDeclarativeEngine *); - QDeclarativePropertyCache(QDeclarativeEngine *, const QMetaObject *); - virtual ~QDeclarativePropertyCache(); - - // 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 - - // 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 - IsValueTypeVirtual = 0x00004000, // Property is a value type "virtual" property - - // Apply only to IsFunctions - 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 - IsOverload = 0x00200000, // Function is an overload of another function - - // Internal QDeclarativePropertyCache flags - NotFullyResolved = 0x00400000 // True if the type data is to be lazily resolved - }; - Q_DECLARE_FLAGS(Flags, Flag) - - Flags getFlags() const { return Flag(flags); } - void setFlags(Flags f) { flags = f; } - - bool isValid() const { return coreIndex != -1; } - - bool isConstant() const { return flags & IsConstant; } - bool isWritable() const { return flags & IsWritable; } - bool isResettable() const { return flags & IsResettable; } - bool isAlias() const { return flags & IsAlias; } - bool isFinal() const { return flags & IsFinal; } - bool isDirect() const { return flags & IsDirect; } - bool isFunction() const { return flags & IsFunction; } - bool isQObject() const { return flags & IsQObjectDerived; } - bool isEnum() const { return flags & IsEnumType; } - bool isQList() const { return flags & IsQList; } - bool isQmlBinding() const { return flags & IsQmlBinding; } - 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; } - bool isVMESignal() const { return flags & IsVMESignal; } - bool isV8Function() const { return flags & IsV8Function; } - bool isSignalHandler() const { return flags & IsSignalHandler; } - bool isOverload() const { return flags & IsOverload; } - - union { - int propType; // When !NotFullyResolved - const char *propTypeName; // When NotFullyResolved - }; - int coreIndex; - union { - int notifyIndex; // When !IsFunction - void *arguments; // When IsFunction && HasArguments + 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 + + // 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 + IsValueTypeVirtual = 0x00004000, // Property is a value type "virtual" property + + // Apply only to IsFunctions + 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 + IsOverload = 0x00200000, // Function is an overload of another function + + // Internal QDeclarativePropertyCache flags + NotFullyResolved = 0x00400000 // True if the type data is to be lazily resolved + }; + Q_DECLARE_FLAGS(Flags, Flag) + + Flags getFlags() const { return Flag(flags); } + void setFlags(Flags f) { flags = f; } + + bool isValid() const { return coreIndex != -1; } + + bool isConstant() const { return flags & IsConstant; } + bool isWritable() const { return flags & IsWritable; } + bool isResettable() const { return flags & IsResettable; } + bool isAlias() const { return flags & IsAlias; } + bool isFinal() const { return flags & IsFinal; } + bool isDirect() const { return flags & IsDirect; } + bool isFunction() const { return flags & IsFunction; } + bool isQObject() const { return flags & IsQObjectDerived; } + bool isEnum() const { return flags & IsEnumType; } + bool isQList() const { return flags & IsQList; } + bool isQmlBinding() const { return flags & IsQmlBinding; } + 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; } + bool isVMESignal() const { return flags & IsVMESignal; } + bool isV8Function() const { return flags & IsV8Function; } + bool isSignalHandler() const { return flags & IsSignalHandler; } + bool isOverload() const { return flags & IsOverload; } + + union { + int propType; // When !NotFullyResolved + const char *propTypeName; // When NotFullyResolved + }; + int coreIndex; + union { + int notifyIndex; // When !IsFunction + void *arguments; // When IsFunction && HasArguments + }; + union { + struct { // When !IsValueTypeVirtual + uint overrideIndexIsProperty : 1; + signed 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 - }; + 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; }; + int revision; + int metaObjectOffset; + +private: + friend class QDeclarativePropertyData; + friend class QDeclarativePropertyCache; + quint32 flags; +}; +Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativePropertyRawData::Flags); - struct Data : public RawData { - inline Data(); - inline Data(const RawData &); +class QDeclarativePropertyData : public QDeclarativePropertyRawData +{ +public: + inline QDeclarativePropertyData(); + inline QDeclarativePropertyData(const QDeclarativePropertyRawData &); - inline bool operator==(const RawData &); + inline bool operator==(const QDeclarativePropertyRawData &); - 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 *); + 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; + // 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; } - }; +private: + friend class QDeclarativePropertyCache; + void lazyLoad(const QMetaProperty &, QDeclarativeEngine *engine = 0); + void lazyLoad(const QMetaMethod &); + bool notFullyResolved() const { return flags & NotFullyResolved; } +}; + +class Q_DECLARATIVE_EXPORT QDeclarativePropertyCache : public QDeclarativeRefCount, public QDeclarativeCleanup +{ +public: + QDeclarativePropertyCache(QDeclarativeEngine *); + QDeclarativePropertyCache(QDeclarativeEngine *, const QMetaObject *); + virtual ~QDeclarativePropertyCache(); void update(QDeclarativeEngine *, const QMetaObject *); QDeclarativePropertyCache *copy(int reserve = 0); - void append(QDeclarativeEngine *, const QMetaObject *, Data::Flag propertyFlags = Data::NoFlags, - Data::Flag methodFlags = Data::NoFlags, Data::Flag signalFlags = Data::NoFlags); - void append(QDeclarativeEngine *, const QMetaObject *, int revision, Data::Flag propertyFlags = Data::NoFlags, - Data::Flag methodFlags = Data::NoFlags, Data::Flag signalFlags = Data::NoFlags); - - static Data create(const QMetaObject *, const QString &); - - inline Data *property(const QHashedV8String &) const; - Data *property(const QHashedStringRef &) const; - Data *property(const QHashedCStringRef &) const; - Data *property(const QString &) const; - Data *property(int) const; - Data *method(int) const; + void append(QDeclarativeEngine *, const QMetaObject *, + QDeclarativePropertyData::Flag propertyFlags = QDeclarativePropertyData::NoFlags, + QDeclarativePropertyData::Flag methodFlags = QDeclarativePropertyData::NoFlags, + QDeclarativePropertyData::Flag signalFlags = QDeclarativePropertyData::NoFlags); + void append(QDeclarativeEngine *, const QMetaObject *, int revision, + QDeclarativePropertyData::Flag propertyFlags = QDeclarativePropertyData::NoFlags, + QDeclarativePropertyData::Flag methodFlags = QDeclarativePropertyData::NoFlags, + QDeclarativePropertyData::Flag signalFlags = QDeclarativePropertyData::NoFlags); + + static QDeclarativePropertyData create(const QMetaObject *, const QString &); + + inline QDeclarativePropertyData *property(const QHashedV8String &) const; + QDeclarativePropertyData *property(const QHashedStringRef &) const; + QDeclarativePropertyData *property(const QHashedCStringRef &) const; + QDeclarativePropertyData *property(const QString &) const; + QDeclarativePropertyData *property(int) const; + QDeclarativePropertyData *method(int) const; QStringList propertyNames() const; - inline Data *overrideData(Data *) const; - inline bool isAllowedInRevision(Data *) const; + inline QDeclarativePropertyData *overrideData(QDeclarativePropertyData *) const; + inline bool isAllowedInRevision(QDeclarativePropertyData *) const; inline QDeclarativeEngine *qmlEngine() const; - static Data *property(QDeclarativeEngine *, QObject *, const QString &, Data &); - static Data *property(QDeclarativeEngine *, QObject *, const QHashedV8String &, Data &); + static QDeclarativePropertyData *property(QDeclarativeEngine *, QObject *, const QString &, + QDeclarativePropertyData &); + static QDeclarativePropertyData *property(QDeclarativeEngine *, QObject *, const QHashedV8String &, + QDeclarativePropertyData &); static int *methodParameterTypes(QObject *, int index, QVarLengthArray &dummy, QByteArray *unknownTypeError); @@ -238,11 +249,11 @@ private: // Implemented in v8/qv8qobjectwrapper.cpp v8::Local newQObject(QObject *, QV8Engine *); - typedef QVector IndexCache; - typedef QStringHash StringCache; + typedef QVector IndexCache; + typedef QStringHash StringCache; typedef QVector AllowedRevisionCache; - void resolve(Data *) const; + void resolve(QDeclarativePropertyData *) const; void updateRecur(QDeclarativeEngine *, const QMetaObject *); QDeclarativeEngine *engine; @@ -261,9 +272,8 @@ private: const QMetaObject *metaObject; QDeclarativePropertyCacheMethodArguments *argumentsCache; }; -Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativePropertyCache::Data::Flags); -QDeclarativePropertyCache::Data::Data() +QDeclarativePropertyData::QDeclarativePropertyData() { propType = 0; coreIndex = -1; @@ -275,12 +285,12 @@ QDeclarativePropertyCache::Data::Data() flags = 0; } -QDeclarativePropertyCache::Data::Data(const QDeclarativePropertyCache::RawData &d) +QDeclarativePropertyData::QDeclarativePropertyData(const QDeclarativePropertyRawData &d) { - *(static_cast(this)) = d; + *(static_cast(this)) = d; } -bool QDeclarativePropertyCache::Data::operator==(const QDeclarativePropertyCache::RawData &other) +bool QDeclarativePropertyData::operator==(const QDeclarativePropertyRawData &other) { return flags == other.flags && propType == other.propType && @@ -292,13 +302,13 @@ bool QDeclarativePropertyCache::Data::operator==(const QDeclarativePropertyCache valueTypePropType == other.valueTypePropType)); } -int QDeclarativePropertyCache::Data::getValueTypeCoreIndex() const +int QDeclarativePropertyData::getValueTypeCoreIndex() const { return isValueTypeVirtual()?valueTypeCoreIndex:-1; } -QDeclarativePropertyCache::Data * -QDeclarativePropertyCache::overrideData(Data *data) const +QDeclarativePropertyData * +QDeclarativePropertyCache::overrideData(QDeclarativePropertyData *data) const { if (data->overrideIndex < 0) return 0; @@ -309,7 +319,7 @@ QDeclarativePropertyCache::overrideData(Data *data) const return method(data->overrideIndex); } -bool QDeclarativePropertyCache::isAllowedInRevision(Data *data) const +bool QDeclarativePropertyCache::isAllowedInRevision(QDeclarativePropertyData *data) const { return (data->metaObjectOffset == -1 && data->revision == 0) || (allowedRevisionCache[data->metaObjectOffset] >= data->revision); @@ -320,9 +330,9 @@ QDeclarativeEngine *QDeclarativePropertyCache::qmlEngine() const return engine; } -QDeclarativePropertyCache::Data *QDeclarativePropertyCache::property(const QHashedV8String &str) const +QDeclarativePropertyData *QDeclarativePropertyCache::property(const QHashedV8String &str) const { - QDeclarativePropertyCache::Data **rv = stringCache.value(str); + QDeclarativePropertyData **rv = stringCache.value(str); if (rv && (*rv)->notFullyResolved()) resolve(*rv); return rv?*rv:0; } diff --git a/src/declarative/qml/qdeclarativescript_p.h b/src/declarative/qml/qdeclarativescript_p.h index c5b9a7e..dbf94b2 100644 --- a/src/declarative/qml/qdeclarativescript_p.h +++ b/src/declarative/qml/qdeclarativescript_p.h @@ -250,7 +250,7 @@ public: // The core data in the case of a regular property. // XXX This has to be a value now as the synthCache may change during // compilation which invalidates pointers. We should fix this. - QDeclarativePropertyCache::Data core; + QDeclarativePropertyData core; // Returns true if this is an empty property - both value and values // are unset. diff --git a/src/declarative/qml/v4/qv4irbuilder.cpp b/src/declarative/qml/v4/qv4irbuilder.cpp index cfe7721..a1e7539 100644 --- a/src/declarative/qml/v4/qv4irbuilder.cpp +++ b/src/declarative/qml/v4/qv4irbuilder.cpp @@ -456,7 +456,7 @@ bool QV4IRBuilder::visit(AST::IdentifierExpression *ast) const QMetaObject *metaObject = m_expression->context->metaObject(); if (!cache) cache = m_engine->cache(metaObject); - QDeclarativePropertyCache::Data *data = cache->property(name); + QDeclarativePropertyData *data = cache->property(name); if (data && data->revision != 0) { if (qmlVerboseCompiler()) @@ -477,7 +477,7 @@ bool QV4IRBuilder::visit(AST::IdentifierExpression *ast) const QMetaObject *metaObject = m_expression->component->metaObject(); if (!cache) cache = m_engine->cache(metaObject); - QDeclarativePropertyCache::Data *data = cache->property(name); + QDeclarativePropertyData *data = cache->property(name); if (data && data->revision != 0) { if (qmlVerboseCompiler()) @@ -603,7 +603,7 @@ bool QV4IRBuilder::visit(AST::FieldMemberExpression *ast) << (*baseName->id + QLatin1String(".") + ast->name.toString()); } else if(const QMetaObject *attachedMeta = baseName->declarativeType->attachedPropertiesType()) { QDeclarativePropertyCache *cache = m_engine->cache(attachedMeta); - QDeclarativePropertyCache::Data *data = cache->property(name); + QDeclarativePropertyData *data = cache->property(name); if (!data || data->isFunction()) return false; // Don't support methods (or non-existing properties ;) @@ -625,7 +625,7 @@ bool QV4IRBuilder::visit(AST::FieldMemberExpression *ast) QDeclarativePropertyCache *cache = idObject->synthCache?idObject->synthCache:m_engine->cache(idObject->metaObject()); - QDeclarativePropertyCache::Data *data = cache->property(name); + QDeclarativePropertyData *data = cache->property(name); if (!data || data->isFunction()) return false; // Don't support methods (or non-existing properties ;) @@ -649,7 +649,7 @@ bool QV4IRBuilder::visit(AST::FieldMemberExpression *ast) m_engine->metaObjectForType(baseName->meta->property(baseName->index).userType()); QDeclarativePropertyCache *cache = m_engine->cache(m); - QDeclarativePropertyCache::Data *data = cache->property(name); + QDeclarativePropertyData *data = cache->property(name); if (!data || data->isFunction()) return false; // Don't support methods (or non-existing properties ;) diff --git a/src/declarative/qml/v8/qv8bindings.cpp b/src/declarative/qml/v8/qv8bindings.cpp index e1a0f4c..57411ae 100644 --- a/src/declarative/qml/v8/qv8bindings.cpp +++ b/src/declarative/qml/v8/qv8bindings.cpp @@ -182,7 +182,7 @@ QV8Bindings::~QV8Bindings() } QDeclarativeAbstractBinding *QV8Bindings::configBinding(int index, QObject *target, QObject *scope, - const QDeclarativePropertyCache::Data &p, + const QDeclarativePropertyData &p, int line) { QV8Bindings::Binding *rv = bindings + index; diff --git a/src/declarative/qml/v8/qv8bindings_p.h b/src/declarative/qml/v8/qv8bindings_p.h index f7581a4..9040625 100644 --- a/src/declarative/qml/v8/qv8bindings_p.h +++ b/src/declarative/qml/v8/qv8bindings_p.h @@ -74,7 +74,7 @@ public: virtual ~QV8Bindings(); QDeclarativeAbstractBinding *configBinding(int index, QObject *target, QObject *scope, - const QDeclarativePropertyCache::Data &prop, + const QDeclarativePropertyData &prop, int line); private: @@ -101,7 +101,7 @@ private: bool updating:1; int line; QObject *object; - QDeclarativePropertyCache::Data property; + QDeclarativePropertyData property; QV8Bindings *parent; }; diff --git a/src/declarative/qml/v8/qv8qobjectwrapper.cpp b/src/declarative/qml/v8/qv8qobjectwrapper.cpp index 031cf83..79d1d20 100644 --- a/src/declarative/qml/v8/qv8qobjectwrapper.cpp +++ b/src/declarative/qml/v8/qv8qobjectwrapper.cpp @@ -348,7 +348,7 @@ QObject *QV8QObjectWrapper::toQObject(QV8ObjectResource *r) // Load value properties static v8::Handle LoadProperty(QV8Engine *engine, QObject *object, - const QDeclarativePropertyCache::Data &property) + const QDeclarativePropertyData &property) { Q_ASSERT(!property.isFunction()); @@ -394,7 +394,7 @@ static v8::Handle LoadProperty(QV8Engine *engine, QObject *object, } static v8::Handle LoadPropertyDirect(QV8Engine *engine, QObject *object, - const QDeclarativePropertyCache::Data &property) + const QDeclarativePropertyData &property) { Q_ASSERT(!property.isFunction()); @@ -478,8 +478,8 @@ v8::Handle QV8QObjectWrapper::GetProperty(QV8Engine *engine, QObject } } - QDeclarativePropertyCache::Data local; - QDeclarativePropertyCache::Data *result = 0; + QDeclarativePropertyData local; + QDeclarativePropertyData *result = 0; { QDeclarativeData *ddata = QDeclarativeData::get(object, false); if (ddata && ddata->propertyCache) @@ -533,7 +533,7 @@ v8::Handle QV8QObjectWrapper::GetProperty(QV8Engine *engine, QObject } // Setter for writable properties. Shared between the interceptor and fast property accessor -static inline void StoreProperty(QV8Engine *engine, QObject *object, QDeclarativePropertyCache::Data *property, +static inline void StoreProperty(QV8Engine *engine, QObject *object, QDeclarativePropertyData *property, v8::Handle value) { QDeclarativeBinding *newBinding = 0; @@ -623,8 +623,8 @@ bool QV8QObjectWrapper::SetProperty(QV8Engine *engine, QObject *object, const QH engine->qobjectWrapper()->m_destroyString == property) return true; - QDeclarativePropertyCache::Data local; - QDeclarativePropertyCache::Data *result = 0; + QDeclarativePropertyData local; + QDeclarativePropertyData *result = 0; result = QDeclarativePropertyCache::property(engine->engine(), object, property, local); if (!result) @@ -730,8 +730,8 @@ v8::Handle QV8QObjectWrapper::Query(v8::Local property, QHashedV8String propertystring(property); - QDeclarativePropertyCache::Data local; - QDeclarativePropertyCache::Data *result = 0; + QDeclarativePropertyData local; + QDeclarativePropertyData *result = 0; result = QDeclarativePropertyCache::property(engine->engine(), object, propertystring, local); if (!result) @@ -811,7 +811,7 @@ static void FastValueSetter(v8::Local, v8::Local value, Q_ASSERT(ddata); Q_ASSERT(ddata->propertyCache); - QDeclarativePropertyCache::Data *pdata = ddata->propertyCache->property(index); + QDeclarativePropertyData *pdata = ddata->propertyCache->property(index); Q_ASSERT(pdata); Q_ASSERT(pdata->isWritable() || pdata->isQList()); @@ -881,7 +881,7 @@ v8::Local QDeclarativePropertyCache::newQObject(QObject *object, QV8 // performance, but the cost of setting up this structure hasn't been measured so // its not guarenteed that this is a win overall. We need to try and measure the cost. for (StringCache::ConstIterator iter = stringCache.begin(); iter != stringCache.end(); ++iter) { - Data *property = *iter; + QDeclarativePropertyData *property = *iter; if (property->isFunction() || property->coreIndex >= 0x7FFF || property->notifyIndex >= 0x0FFF || property->coreIndex == 0) @@ -1588,9 +1588,9 @@ static QByteArray QMetaMethod_name(const QMetaMethod &m) /*! Returns the next related method, if one, or 0. */ -static const QDeclarativePropertyCache::Data * RelatedMethod(QObject *object, - const QDeclarativePropertyCache::Data *current, - QDeclarativePropertyCache::Data &dummy) +static const QDeclarativePropertyData * RelatedMethod(QObject *object, + const QDeclarativePropertyData *current, + QDeclarativePropertyData &dummy) { QDeclarativePropertyCache *cache = QDeclarativeData::get(object)->propertyCache; if (!current->isOverload()) @@ -1616,7 +1616,7 @@ static const QDeclarativePropertyCache::Data * RelatedMethod(QObject *object, QByteArray methodName = QMetaMethod_name(method); for (int ii = current->overrideIndex - 1; ii >= methodOffset; --ii) { if (methodName == QMetaMethod_name(mo->method(ii))) { - dummy.setFlags(dummy.getFlags() | QDeclarativePropertyCache::Data::IsOverload); + dummy.setFlags(dummy.getFlags() | QDeclarativePropertyData::IsOverload); dummy.overrideIndexIsProperty = 0; dummy.overrideIndex = ii; return &dummy; @@ -1627,7 +1627,7 @@ static const QDeclarativePropertyCache::Data * RelatedMethod(QObject *object, } } -static v8::Handle CallPrecise(QObject *object, const QDeclarativePropertyCache::Data &data, +static v8::Handle CallPrecise(QObject *object, const QDeclarativePropertyData &data, QV8Engine *engine, CallArgs &callArgs) { if (data.hasArguments()) { @@ -1674,17 +1674,17 @@ Resolve the overloaded method to call. The algorithm works conceptually like th If two or more overloads have the same match score, call the last one. The match score is constructed by adding the matchScore() result for each of the parameters. */ -static v8::Handle CallOverloaded(QObject *object, const QDeclarativePropertyCache::Data &data, +static v8::Handle CallOverloaded(QObject *object, const QDeclarativePropertyData &data, QV8Engine *engine, CallArgs &callArgs) { int argumentCount = callArgs.Length(); - const QDeclarativePropertyCache::Data *best = 0; + const QDeclarativePropertyData *best = 0; int bestParameterScore = INT_MAX; int bestMatchScore = INT_MAX; - QDeclarativePropertyCache::Data dummy; - const QDeclarativePropertyCache::Data *attempt = &data; + QDeclarativePropertyData dummy; + const QDeclarativePropertyData *attempt = &data; do { QVarLengthArray dummy; @@ -1726,7 +1726,7 @@ static v8::Handle CallOverloaded(QObject *object, const QDeclarativeP return CallPrecise(object, *best, engine, callArgs); } else { QString error = QLatin1String("Unable to determine callable overload. Candidates are:"); - const QDeclarativePropertyCache::Data *candidate = &data; + const QDeclarativePropertyData *candidate = &data; while (candidate) { error += QLatin1String("\n ") + QString::fromUtf8(object->metaObject()->method(candidate->coreIndex).signature()); @@ -1822,11 +1822,11 @@ v8::Handle QV8QObjectWrapper::Invoke(const v8::Arguments &args) } } - QDeclarativePropertyCache::Data method; + QDeclarativePropertyData method; if (QDeclarativeData *ddata = static_cast(QObjectPrivate::get(object)->declarativeData)) { if (ddata->propertyCache) { - QDeclarativePropertyCache::Data *d = ddata->propertyCache->method(index); + QDeclarativePropertyData *d = ddata->propertyCache->method(index); if (!d) return v8::Undefined(); method = *d; diff --git a/src/declarative/qml/v8/qv8valuetypewrapper.cpp b/src/declarative/qml/v8/qv8valuetypewrapper.cpp index 35037fa..2c46b77 100644 --- a/src/declarative/qml/v8/qv8valuetypewrapper.cpp +++ b/src/declarative/qml/v8/qv8valuetypewrapper.cpp @@ -295,9 +295,9 @@ v8::Handle QV8ValueTypeWrapper::Setter(v8::Local property QDeclarativeContextData *context = r->engine->callingContext(); v8::Handle function = v8::Handle::Cast(value); - QDeclarativePropertyCache::Data cacheData; - cacheData.setFlags(QDeclarativePropertyCache::Data::IsWritable | - QDeclarativePropertyCache::Data::IsValueTypeVirtual); + QDeclarativePropertyData cacheData; + cacheData.setFlags(QDeclarativePropertyData::IsWritable | + QDeclarativePropertyData::IsValueTypeVirtual); cacheData.propType = reference->object->metaObject()->property(reference->property).userType(); cacheData.coreIndex = reference->property; cacheData.valueTypeFlags = 0; diff --git a/src/qtquick1/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/qtquick1/graphicsitems/qdeclarativevisualitemmodel.cpp index 58bd09b..a1fe5ff 100644 --- a/src/qtquick1/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -1157,7 +1157,7 @@ QString QDeclarative1VisualDataModel::stringValue(int index, const QString &name QDeclarativeData *ddata = QDeclarativeData::get(data); if (ddata && ddata->propertyCache) { - QDeclarativePropertyCache::Data *prop = ddata->propertyCache->property(name); + QDeclarativePropertyData *prop = ddata->propertyCache->property(name); if (prop) { if (prop->propType == QVariant::String) { void *args[] = { &val, 0 };