diff options
author | Erik Verbruggen <erik.verbruggen@qt.io> | 2016-08-04 12:38:43 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2016-08-10 14:21:15 +0000 |
commit | 86a55cdb8cb850066e1dcc288d2dddf600652994 (patch) | |
tree | 7ac865843e71259d09938c1ee993cf7c80d67293 | |
parent | 1351ac74078038cdf2f80640c8d4ba605a0ea16b (diff) |
QML: Make all fields in QQmlPropertyRawData private
And add accessors. This makes it easier later on to change the storage
of the fields.
Change-Id: I21163668ac83a7d52f398981baf3c27ef161c177
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
21 files changed, 520 insertions, 473 deletions
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp index 12ed987ca0..f72b8a51f9 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp @@ -753,7 +753,7 @@ bool QQmlEngineDebugServiceImpl::setMethodBody(int objectId, const QString &meth if (!prop || !prop->isVMEFunction()) return false; - QMetaMethod metaMethod = object->metaObject()->method(prop->coreIndex); + QMetaMethod metaMethod = object->metaObject()->method(prop->coreIndex()); QList<QByteArray> paramNames = metaMethod.parameterNames(); QString paramStr; @@ -772,12 +772,12 @@ bool QQmlEngineDebugServiceImpl::setMethodBody(int objectId, const QString &meth QV4::Scope scope(v4); int lineNumber = 0; - QV4::ScopedFunctionObject oldMethod(scope, vmeMetaObject->vmeMethod(prop->coreIndex)); + QV4::ScopedFunctionObject oldMethod(scope, vmeMetaObject->vmeMethod(prop->coreIndex())); if (oldMethod && oldMethod->d()->function) { lineNumber = oldMethod->d()->function->compiledFunction->location.line; } QV4::ScopedValue v(scope, QQmlJavaScriptExpression::evalFunction(contextData, object, jsfunction, contextData->urlString(), lineNumber)); - vmeMetaObject->setVmeMethod(prop->coreIndex, v); + vmeMetaObject->setVmeMethod(prop->coreIndex(), v); return true; } diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp index 1bc2b30087..ef8ffa8620 100644 --- a/src/qml/compiler/qqmlirbuilder.cpp +++ b/src/qml/compiler/qqmlirbuilder.cpp @@ -1845,20 +1845,20 @@ static QV4::IR::DiscoveredType resolveMetaObjectProperty( if (property->isEnum()) return QV4::IR::VarType; - switch (property->propType) { + switch (property->propType()) { case QMetaType::Bool: result = QV4::IR::BoolType; break; case QMetaType::Int: result = QV4::IR::SInt32Type; break; case QMetaType::Double: result = QV4::IR::DoubleType; break; case QMetaType::QString: result = QV4::IR::StringType; break; default: if (property->isQObject()) { - if (QQmlPropertyCache *cache = qmlEngine->propertyCacheForType(property->propType)) { + if (QQmlPropertyCache *cache = qmlEngine->propertyCacheForType(property->propType())) { auto newResolver = resolver->owner->New<QV4::IR::MemberExpressionResolver>(); newResolver->owner = resolver->owner; initMetaObjectResolver(newResolver, cache); return QV4::IR::DiscoveredType(newResolver); } - } else if (const QMetaObject *valueTypeMetaObject = QQmlValueTypeFactory::metaObjectForMetaType(property->propType)) { + } else if (const QMetaObject *valueTypeMetaObject = QQmlValueTypeFactory::metaObjectForMetaType(property->propType())) { if (QQmlPropertyCache *cache = qmlEngine->cache(valueTypeMetaObject)) { auto newResolver = resolver->owner->New<QV4::IR::MemberExpressionResolver>(); newResolver->owner = resolver->owner; @@ -2053,7 +2053,7 @@ QQmlPropertyData *PropertyResolver::signal(const QString &name, bool *notInRevis d = property(propName, notInRevision); if (d) - return cache->signal(d->notifyIndex); + return cache->signal(d->notifyIndex()); } return 0; diff --git a/src/qml/compiler/qqmlpropertycachecreator_p.h b/src/qml/compiler/qqmlpropertycachecreator_p.h index a1b0a14890..10bcd1dbc1 100644 --- a/src/qml/compiler/qqmlpropertycachecreator_p.h +++ b/src/qml/compiler/qqmlpropertycachecreator_p.h @@ -124,7 +124,7 @@ inline QQmlCompileError QQmlPropertyCacheCreator<ObjectContainer>::buildMetaObje // group properties and value type group properties. For the former the base type is derived from // the property that references us, for the latter we only need a meta-object on the referencing object // because interceptors can't go to the shared value type instances. - if (context.instantiatingProperty && QQmlValueTypeFactory::isValueType(context.instantiatingProperty->propType)) { + if (context.instantiatingProperty && QQmlValueTypeFactory::isValueType(context.instantiatingProperty->propType())) { if (!propertyCaches->needsVMEMetaObject(context.referencingObjectIndex)) { const CompiledObject *obj = objectContainer->objectAt(context.referencingObjectIndex); auto *typeRef = objectContainer->resolvedTypes.value(obj->inheritedTypeNameIndex); @@ -180,8 +180,8 @@ inline QQmlPropertyCache *QQmlPropertyCacheCreator<ObjectContainer>::propertyCac { if (context.instantiatingProperty) { if (context.instantiatingProperty->isQObject()) { - return enginePrivate->rawPropertyCacheForType(context.instantiatingProperty->propType); - } else if (const QMetaObject *vtmo = QQmlValueTypeFactory::metaObjectForMetaType(context.instantiatingProperty->propType)) { + return enginePrivate->rawPropertyCacheForType(context.instantiatingProperty->propType()); + } else if (const QMetaObject *vtmo = QQmlValueTypeFactory::metaObjectForMetaType(context.instantiatingProperty->propType())) { return enginePrivate->cache(vtmo); } } else if (obj->inheritedTypeNameIndex != 0) { @@ -664,7 +664,7 @@ inline void QQmlPropertyCacheAliasCreator<ObjectContainer>::propertyDataForAlias QQmlPropertyData *targetProperty = targetCache->property(coreIndex); Q_ASSERT(targetProperty); - *type = targetProperty->propType; + *type = targetProperty->propType(); writable = targetProperty->isWritable(); resettable = targetProperty->isResettable(); @@ -680,7 +680,7 @@ inline void QQmlPropertyCacheAliasCreator<ObjectContainer>::propertyDataForAlias *type = QVariant::Int; } else { // Copy type flags - propertyFlags->copyPropertyTypeFlags(targetProperty->getFlags()); + propertyFlags->copyPropertyTypeFlags(targetProperty->flags()); if (targetProperty->isVarProperty()) propertyFlags->type = QQmlPropertyData::Flags::QVariantType; diff --git a/src/qml/compiler/qqmlpropertyvalidator.cpp b/src/qml/compiler/qqmlpropertyvalidator.cpp index c644330e97..45379d5155 100644 --- a/src/qml/compiler/qqmlpropertyvalidator.cpp +++ b/src/qml/compiler/qqmlpropertyvalidator.cpp @@ -206,7 +206,7 @@ QVector<QQmlCompileError> QQmlPropertyValidator::validateObject(int objectIndex, } if (binding->type >= QV4::CompiledData::Binding::Type_Object && (pd || binding->isAttachedProperty())) { - const QVector<QQmlCompileError> subObjectValidatorErrors = validateObject(binding->value.objectIndex, binding, pd && QQmlValueTypeFactory::metaObjectForMetaType(pd->propType)); + const QVector<QQmlCompileError> subObjectValidatorErrors = validateObject(binding->value.objectIndex, binding, pd && QQmlValueTypeFactory::metaObjectForMetaType(pd->propType())); if (!subObjectValidatorErrors.isEmpty()) return subObjectValidatorErrors; } @@ -240,7 +240,7 @@ QVector<QQmlCompileError> QQmlPropertyValidator::validateObject(int objectIndex, if (!pd->isQList() && (binding->flags & QV4::CompiledData::Binding::IsListItem)) { QString error; - if (pd->propType == qMetaTypeId<QQmlScriptString>()) + if (pd->propType() == qMetaTypeId<QQmlScriptString>()) error = tr( "Cannot assign multiple values to a script property"); else error = tr( "Cannot assign multiple values to a singular property"); @@ -255,7 +255,7 @@ QVector<QQmlCompileError> QQmlPropertyValidator::validateObject(int objectIndex, if (loc < (*assignedGroupProperty)->valueLocation) loc = (*assignedGroupProperty)->valueLocation; - if (pd && QQmlValueTypeFactory::isValueType(pd->propType)) + if (pd && QQmlValueTypeFactory::isValueType(pd->propType())) return recordError(loc, tr("Property has already been assigned a value")); return recordError(loc, tr("Cannot assign a value directly to a grouped property")); } @@ -269,8 +269,8 @@ QVector<QQmlCompileError> QQmlPropertyValidator::validateObject(int objectIndex, if (bindingError.isSet()) return recordError(bindingError); } else if (binding->isGroupProperty()) { - if (QQmlValueTypeFactory::isValueType(pd->propType)) { - if (QQmlValueTypeFactory::metaObjectForMetaType(pd->propType)) { + if (QQmlValueTypeFactory::isValueType(pd->propType())) { + if (QQmlValueTypeFactory::metaObjectForMetaType(pd->propType())) { if (!pd->isWritable()) { return recordError(binding->location, tr("Invalid property assignment: \"%1\" is a read-only property").arg(name)); } @@ -278,7 +278,7 @@ QVector<QQmlCompileError> QQmlPropertyValidator::validateObject(int objectIndex, return recordError(binding->location, tr("Invalid grouped property access")); } } else { - if (!enginePrivate->propertyCacheForType(pd->propType)) { + if (!enginePrivate->propertyCacheForType(pd->propType())) { return recordError(binding->location, tr("Invalid grouped property access")); } } @@ -334,7 +334,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache return noError; QString value = binding->valueAsString(qmlUnit); - QMetaProperty p = propertyCache->firstCppMetaObject()->property(property->coreIndex); + QMetaProperty p = propertyCache->firstCppMetaObject()->property(property->coreIndex()); bool ok; if (p.isFlagType()) { p.enumerator().keysToValue(value.toUtf8().constData(), &ok); @@ -347,7 +347,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache return noError; } - switch (property->propType) { + switch (property->propType()) { case QMetaType::QVariant: break; case QVariant::String: { @@ -541,12 +541,12 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: regular expression expected; use /pattern/ syntax")); default: { // generate single literal value assignment to a list property if required - if (property->propType == qMetaTypeId<QList<qreal> >()) { + if (property->propType() == qMetaTypeId<QList<qreal> >()) { if (binding->type != QV4::CompiledData::Binding::Type_Number) { return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: number or array of numbers expected")); } break; - } else if (property->propType == qMetaTypeId<QList<int> >()) { + } else if (property->propType() == qMetaTypeId<QList<int> >()) { bool ok = (binding->type == QV4::CompiledData::Binding::Type_Number); if (ok) { double n = binding->valueAsNumber(); @@ -556,31 +556,31 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache if (!ok) return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: int or array of ints expected")); break; - } else if (property->propType == qMetaTypeId<QList<bool> >()) { + } else if (property->propType() == qMetaTypeId<QList<bool> >()) { if (binding->type != QV4::CompiledData::Binding::Type_Boolean) { return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: bool or array of bools expected")); } break; - } else if (property->propType == qMetaTypeId<QList<QUrl> >()) { + } else if (property->propType() == qMetaTypeId<QList<QUrl> >()) { if (binding->type != QV4::CompiledData::Binding::Type_String) { return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: url or array of urls expected")); } break; - } else if (property->propType == qMetaTypeId<QList<QString> >()) { + } else if (property->propType() == qMetaTypeId<QList<QString> >()) { if (!binding->evaluatesToString()) { return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: string or array of strings expected")); } break; - } else if (property->propType == qMetaTypeId<QJSValue>()) { + } else if (property->propType() == qMetaTypeId<QJSValue>()) { break; - } else if (property->propType == qMetaTypeId<QQmlScriptString>()) { + } else if (property->propType() == qMetaTypeId<QQmlScriptString>()) { break; } // otherwise, try a custom type assignment - QQmlMetaType::StringConverter converter = QQmlMetaType::customStringConverter(property->propType); + QQmlMetaType::StringConverter converter = QQmlMetaType::customStringConverter(property->propType()); if (!converter) { - return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: unsupported type \"%1\"").arg(QString::fromLatin1(QMetaType::typeName(property->propType)))); + return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: unsupported type \"%1\"").arg(QString::fromLatin1(QMetaType::typeName(property->propType())))); } } break; @@ -652,15 +652,15 @@ QQmlCompileError QQmlPropertyValidator::validateObjectBinding(QQmlPropertyData * return noError; } - if (QQmlMetaType::isInterface(property->propType)) { + if (QQmlMetaType::isInterface(property->propType())) { // Can only check at instantiation time if the created sub-object successfully casts to the // target interface. return noError; - } else if (property->propType == QMetaType::QVariant) { + } else if (property->propType() == QMetaType::QVariant) { // We can convert everything to QVariant :) return noError; } else if (property->isQList()) { - const int listType = enginePrivate->listType(property->propType); + const int listType = enginePrivate->listType(property->propType()); if (!QQmlMetaType::isInterface(listType)) { QQmlPropertyCache *source = propertyCaches.at(binding->value.objectIndex); if (!canCoerce(listType, source)) { @@ -672,15 +672,15 @@ QQmlCompileError QQmlPropertyValidator::validateObjectBinding(QQmlPropertyData * return noError; } else if (binding->flags & QV4::CompiledData::Binding::IsSignalHandlerObject && property->isFunction()) { return noError; - } else if (QQmlValueTypeFactory::isValueType(property->propType)) { + } else if (QQmlValueTypeFactory::isValueType(property->propType())) { return QQmlCompileError(binding->location, tr("Unexpected object assignment")); - } else if (property->propType == qMetaTypeId<QQmlScriptString>()) { + } else if (property->propType() == qMetaTypeId<QQmlScriptString>()) { return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: script expected")); } else { // We want to raw metaObject here as the raw metaobject is the // actual property type before we applied any extensions that might // effect the properties on the type, but don't effect assignability - QQmlPropertyCache *propertyMetaObject = enginePrivate->rawPropertyCacheForType(property->propType); + QQmlPropertyCache *propertyMetaObject = enginePrivate->rawPropertyCacheForType(property->propType()); // Will be true if the assgned type inherits propertyMetaObject bool isAssignable = false; diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp index e1166286c2..4b33363d09 100644 --- a/src/qml/compiler/qqmltypecompiler.cpp +++ b/src/qml/compiler/qqmltypecompiler.cpp @@ -390,7 +390,7 @@ bool SignalHandlerConverter::convertSignalHandlerExpressionsToFunctionDeclaratio bool notInRevision = false; QQmlPropertyData *signal = resolver.signal(propertyName, ¬InRevision); if (signal) { - int sigIndex = propertyCache->methodIndexToSignalIndex(signal->coreIndex); + int sigIndex = propertyCache->methodIndexToSignalIndex(signal->coreIndex()); sigIndex = propertyCache->originalClone(sigIndex); bool unnamedParameter = false; @@ -547,7 +547,7 @@ bool QQmlEnumTypeResolver::resolveEnumBindings() if (!pd) continue; - if (!pd->isEnum() && pd->propType != QMetaType::Int) + if (!pd->isEnum() && pd->propType() != QMetaType::Int) continue; if (!tryQualifiedEnumAssignment(obj, propertyCache, pd, binding)) @@ -577,7 +577,7 @@ bool QQmlEnumTypeResolver::assignEnumToBinding(QmlIR::Binding *binding, const QS bool QQmlEnumTypeResolver::tryQualifiedEnumAssignment(const QmlIR::Object *obj, const QQmlPropertyCache *propertyCache, const QQmlPropertyData *prop, QmlIR::Binding *binding) { - bool isIntProp = (prop->propType == QMetaType::Int) && !prop->isEnum(); + bool isIntProp = (prop->propType() == QMetaType::Int) && !prop->isEnum(); if (!prop->isEnum() && !isIntProp) return true; @@ -621,7 +621,7 @@ bool QQmlEnumTypeResolver::tryQualifiedEnumAssignment(const QmlIR::Object *obj, auto *tr = resolvedTypes->value(obj->inheritedTypeNameIndex); if (type && tr && tr->type == type) { - QMetaProperty mprop = propertyCache->firstCppMetaObject()->property(prop->coreIndex); + QMetaProperty mprop = propertyCache->firstCppMetaObject()->property(prop->coreIndex()); // When these two match, we can short cut the search if (mprop.isFlagType()) { @@ -758,7 +758,7 @@ void QQmlScriptStringScanner::scan() continue; bool notInRevision = false; QQmlPropertyData *pd = binding->propertyNameIndex != quint32(0) ? resolver.property(stringAt(binding->propertyNameIndex), ¬InRevision) : defaultProperty; - if (!pd || pd->propType != scriptStringMetaType) + if (!pd || pd->propType() != scriptStringMetaType) continue; QmlIR::CompiledFunctionOrExpression *foe = obj->functionsAndExpressions->slowAt(binding->value.compiledScriptIndex); @@ -815,7 +815,7 @@ void QQmlComponentAndAliasResolver::findAndRegisterImplicitComponents(const QmlI if (!pd || !pd->isQObject()) continue; - QQmlPropertyCache *pc = enginePrivate->rawPropertyCacheForType(pd->propType); + QQmlPropertyCache *pc = enginePrivate->rawPropertyCacheForType(pd->propType()); const QMetaObject *mo = pc->firstCppMetaObject(); while (mo) { if (mo == &QQmlComponent::staticMetaObject) @@ -1116,15 +1116,15 @@ QQmlComponentAndAliasResolver::AliasResolutionResult QQmlComponentAndAliasResolv } } - if (!targetProperty || targetProperty->coreIndex > 0x0000FFFF) { + if (!targetProperty || targetProperty->coreIndex() > 0x0000FFFF) { *error = QQmlCompileError(alias->referenceLocation, tr("Invalid alias target location: %1").arg(property.toString())); break; } - propIdx = QQmlPropertyIndex(targetProperty->coreIndex); + propIdx = QQmlPropertyIndex(targetProperty->coreIndex()); if (!subProperty.isEmpty()) { - const QMetaObject *valueTypeMetaObject = QQmlValueTypeFactory::metaObjectForMetaType(targetProperty->propType); + const QMetaObject *valueTypeMetaObject = QQmlValueTypeFactory::metaObjectForMetaType(targetProperty->propType()); if (!valueTypeMetaObject) { *error = QQmlCompileError(alias->referenceLocation, tr("Invalid alias target location: %1").arg(subProperty.toString())); break; diff --git a/src/qml/compiler/qv4isel_p.cpp b/src/qml/compiler/qv4isel_p.cpp index d97eec5e1d..72e6c276a9 100644 --- a/src/qml/compiler/qv4isel_p.cpp +++ b/src/qml/compiler/qv4isel_p.cpp @@ -149,18 +149,18 @@ void IRDecoder::visitMove(IR::Move *s) if (_function && attachedPropertiesId == 0 && !m->property->isConstant()) { if (m->kind == IR::Member::MemberOfQmlContextObject) { - _function->contextObjectPropertyDependencies.insert(m->property->coreIndex, m->property->notifyIndex); + _function->contextObjectPropertyDependencies.insert(m->property->coreIndex(), m->property->notifyIndex()); captureRequired = false; } else if (m->kind == IR::Member::MemberOfQmlScopeObject) { - _function->scopeObjectPropertyDependencies.insert(m->property->coreIndex, m->property->notifyIndex); + _function->scopeObjectPropertyDependencies.insert(m->property->coreIndex(), m->property->notifyIndex()); captureRequired = false; } } if (m->kind == IR::Member::MemberOfQmlScopeObject || m->kind == IR::Member::MemberOfQmlContextObject) { - getQmlContextProperty(m->base, (IR::Member::MemberKind)m->kind, m->property->coreIndex, s->target); + getQmlContextProperty(m->base, (IR::Member::MemberKind)m->kind, m->property->coreIndex(), s->target); return; } - getQObjectProperty(m->base, m->property->coreIndex, captureRequired, isSingletonProperty, attachedPropertiesId, s->target); + getQObjectProperty(m->base, m->property->coreIndex(), captureRequired, isSingletonProperty, attachedPropertiesId, s->target); #endif // V4_BOOTSTRAP return; } else if (m->kind == IR::Member::MemberOfIdObjectsArray) { @@ -187,7 +187,7 @@ void IRDecoder::visitMove(IR::Move *s) #ifndef V4_BOOTSTRAP Q_ASSERT(member->kind != IR::Member::MemberOfIdObjectsArray); if (member->kind == IR::Member::MemberOfQmlScopeObject || member->kind == IR::Member::MemberOfQmlContextObject) { - callQmlContextProperty(member->base, (IR::Member::MemberKind)member->kind, member->property->coreIndex, c->args, s->target); + callQmlContextProperty(member->base, (IR::Member::MemberKind)member->kind, member->property->coreIndex(), c->args, s->target); return; } #endif @@ -216,10 +216,10 @@ void IRDecoder::visitMove(IR::Move *s) Q_UNIMPLEMENTED(); #else if (m->kind == IR::Member::MemberOfQmlScopeObject || m->kind == IR::Member::MemberOfQmlContextObject) { - setQmlContextProperty(s->source, m->base, (IR::Member::MemberKind)m->kind, m->property->coreIndex); + setQmlContextProperty(s->source, m->base, (IR::Member::MemberKind)m->kind, m->property->coreIndex()); return; } - setQObjectProperty(s->source, m->base, m->property->coreIndex); + setQObjectProperty(s->source, m->base, m->property->coreIndex()); #endif return; } else { @@ -263,7 +263,7 @@ void IRDecoder::visitExp(IR::Exp *s) #ifndef V4_BOOTSTRAP Q_ASSERT(member->kind != IR::Member::MemberOfIdObjectsArray); if (member->kind == IR::Member::MemberOfQmlScopeObject || member->kind == IR::Member::MemberOfQmlContextObject) { - callQmlContextProperty(member->base, (IR::Member::MemberKind)member->kind, member->property->coreIndex, c->args, 0); + callQmlContextProperty(member->base, (IR::Member::MemberKind)member->kind, member->property->coreIndex(), c->args, 0); return; } #endif @@ -295,7 +295,7 @@ void IRDecoder::callBuiltin(IR::Call *call, Expr *result) if (member->kind == IR::Member::MemberOfQmlScopeObject || member->kind == IR::Member::MemberOfQmlContextObject) { callBuiltinTypeofQmlContextProperty(member->base, IR::Member::MemberKind(member->kind), - member->property->coreIndex, result); + member->property->coreIndex(), result); return; } #endif diff --git a/src/qml/compiler/qv4jsir.cpp b/src/qml/compiler/qv4jsir.cpp index b6c5226894..5687834b00 100644 --- a/src/qml/compiler/qv4jsir.cpp +++ b/src/qml/compiler/qv4jsir.cpp @@ -911,8 +911,8 @@ void IRPrinter::visitMember(Member *e) *out << '.' << *e->name; #ifndef V4_BOOTSTRAP if (e->property) - *out << " (meta-property " << e->property->coreIndex - << " <" << QMetaType::typeName(e->property->propType) + *out << " (meta-property " << e->property->coreIndex() + << " <" << QMetaType::typeName(e->property->propType()) << ">)"; else if (e->kind == Member::MemberOfIdObjectsArray) *out << "(id object " << e->idIndex << ")"; diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 8fef45891a..624c37a694 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -124,7 +124,7 @@ struct ReadAccessor { Q_UNUSED(n); void *args[] = { output, 0 }; - QMetaObject::metacall(object, QMetaObject::ReadProperty, property.coreIndex, args); + QMetaObject::metacall(object, QMetaObject::ReadProperty, property.coreIndex(), args); } static inline void Direct(QObject *object, const QQmlPropertyData &property, @@ -134,16 +134,16 @@ struct ReadAccessor { Q_UNUSED(n); void *args[] = { output, 0 }; - object->qt_metacall(QMetaObject::ReadProperty, property.coreIndex, args); + object->qt_metacall(QMetaObject::ReadProperty, property.coreIndex(), args); } static inline void Accessor(QObject *object, const QQmlPropertyData &property, void *output, QQmlNotifier **n) { - Q_ASSERT(property.accessors); + Q_ASSERT(property.accessors()); - property.accessors->read(object, output); - if (n) property.accessors->notifier(object, n); + property.accessors()->read(object, output); + if (n) property.accessors()->notifier(object, n); } }; @@ -162,32 +162,32 @@ static QV4::ReturnedValue LoadProperty(QV4::ExecutionEngine *v4, QObject *object ReadFunction(object, property, &rv, notifier); return QV4::QObjectWrapper::wrap(v4, rv); } else if (property.isQList()) { - return QmlListWrapper::create(v4, object, property.coreIndex, property.propType); - } else if (property.propType == QMetaType::QReal) { + return QmlListWrapper::create(v4, object, property.coreIndex(), property.propType()); + } else if (property.propType() == QMetaType::QReal) { qreal v = 0; ReadFunction(object, property, &v, notifier); return QV4::Encode(v); - } else if (property.propType == QMetaType::Int || property.isEnum()) { + } else if (property.propType() == QMetaType::Int || property.isEnum()) { int v = 0; ReadFunction(object, property, &v, notifier); return QV4::Encode(v); - } else if (property.propType == QMetaType::Bool) { + } else if (property.propType() == QMetaType::Bool) { bool v = false; ReadFunction(object, property, &v, notifier); return QV4::Encode(v); - } else if (property.propType == QMetaType::QString) { + } else if (property.propType() == QMetaType::QString) { QString v; ReadFunction(object, property, &v, notifier); return v4->newString(v)->asReturnedValue(); - } else if (property.propType == QMetaType::UInt) { + } else if (property.propType() == QMetaType::UInt) { uint v = 0; ReadFunction(object, property, &v, notifier); return QV4::Encode(v); - } else if (property.propType == QMetaType::Float) { + } else if (property.propType() == QMetaType::Float) { float v = 0; ReadFunction(object, property, &v, notifier); return QV4::Encode(v); - } else if (property.propType == QMetaType::Double) { + } else if (property.propType() == QMetaType::Double) { double v = 0; ReadFunction(object, property, &v, notifier); return QV4::Encode(v); @@ -195,7 +195,7 @@ static QV4::ReturnedValue LoadProperty(QV4::ExecutionEngine *v4, QObject *object QQmlV4Handle handle; ReadFunction(object, property, &handle, notifier); return handle; - } else if (property.propType == qMetaTypeId<QJSValue>()) { + } else if (property.propType() == qMetaTypeId<QJSValue>()) { QJSValue v; ReadFunction(object, property, &v, notifier); return QJSValuePrivate::convertedToValue(v4, v); @@ -205,32 +205,32 @@ static QV4::ReturnedValue LoadProperty(QV4::ExecutionEngine *v4, QObject *object if (QQmlValueTypeFactory::isValueType(v.userType())) { if (const QMetaObject *valueTypeMetaObject = QQmlValueTypeFactory::metaObjectForMetaType(v.userType())) - return QV4::QQmlValueTypeWrapper::create(v4, object, property.coreIndex, valueTypeMetaObject, v.userType()); // VariantReference value-type. + return QV4::QQmlValueTypeWrapper::create(v4, object, property.coreIndex(), valueTypeMetaObject, v.userType()); // VariantReference value-type. } return scope.engine->fromVariant(v); - } else if (QQmlValueTypeFactory::isValueType(property.propType)) { + } else if (QQmlValueTypeFactory::isValueType(property.propType())) { Q_ASSERT(notifier == 0); - if (const QMetaObject *valueTypeMetaObject = QQmlValueTypeFactory::metaObjectForMetaType(property.propType)) - return QV4::QQmlValueTypeWrapper::create(v4, object, property.coreIndex, valueTypeMetaObject, property.propType); + if (const QMetaObject *valueTypeMetaObject = QQmlValueTypeFactory::metaObjectForMetaType(property.propType())) + return QV4::QQmlValueTypeWrapper::create(v4, object, property.coreIndex(), valueTypeMetaObject, property.propType()); } else { Q_ASSERT(notifier == 0); // see if it's a sequence type bool succeeded = false; - QV4::ScopedValue retn(scope, QV4::SequencePrototype::newSequence(v4, property.propType, object, property.coreIndex, &succeeded)); + QV4::ScopedValue retn(scope, QV4::SequencePrototype::newSequence(v4, property.propType(), object, property.coreIndex(), &succeeded)); if (succeeded) return retn->asReturnedValue(); } - if (property.propType == QMetaType::UnknownType) { - QMetaProperty p = object->metaObject()->property(property.coreIndex); + if (property.propType() == QMetaType::UnknownType) { + QMetaProperty p = object->metaObject()->property(property.coreIndex()); qWarning("QMetaProperty::read: Unable to handle unregistered datatype '%s' for property " "'%s::%s'", p.typeName(), object->metaObject()->className(), p.name()); return QV4::Encode::undefined(); } else { - QVariant v(property.propType, (void *)0); + QVariant v(property.propType(), (void *)0); ReadFunction(object, property, v.data(), notifier); return scope.engine->fromVariant(v); } @@ -328,25 +328,25 @@ ReturnedValue QObjectWrapper::getQmlProperty(QQmlContextData *qmlContext, String ReturnedValue QObjectWrapper::getProperty(ExecutionEngine *engine, QObject *object, QQmlPropertyData *property, bool captureRequired) { - QQmlData::flushPendingBinding(object, QQmlPropertyIndex(property->coreIndex)); + QQmlData::flushPendingBinding(object, QQmlPropertyIndex(property->coreIndex())); if (property->isFunction() && !property->isVarProperty()) { if (property->isVMEFunction()) { QQmlVMEMetaObject *vmemo = QQmlVMEMetaObject::get(object); Q_ASSERT(vmemo); - return vmemo->vmeMethod(property->coreIndex); + return vmemo->vmeMethod(property->coreIndex()); } else if (property->isV4Function()) { Scope scope(engine); ScopedContext global(scope, engine->qmlContext()); if (!global) global = engine->rootContext(); - return QV4::QObjectMethod::create(global, object, property->coreIndex); + return QV4::QObjectMethod::create(global, object, property->coreIndex()); } else if (property->isSignalHandler()) { QmlSignalHandler::initProto(engine); - return engine->memoryManager->allocObject<QV4::QmlSignalHandler>(object, property->coreIndex)->asReturnedValue(); + return engine->memoryManager->allocObject<QV4::QmlSignalHandler>(object, property->coreIndex())->asReturnedValue(); } else { ExecutionContext *global = engine->rootContext(); - return QV4::QObjectMethod::create(global, object, property->coreIndex); + return QV4::QObjectMethod::create(global, object, property->coreIndex()); } } @@ -356,19 +356,19 @@ ReturnedValue QObjectWrapper::getProperty(ExecutionEngine *engine, QObject *obje QQmlNotifier *n = 0; QQmlNotifier **nptr = 0; - if (ep && ep->propertyCapture && property->accessors->notifier) + if (ep && ep->propertyCapture && property->accessors()->notifier) nptr = &n; Scope scope(engine); QV4::ScopedValue rv(scope, LoadProperty<ReadAccessor::Accessor>(engine, object, *property, nptr)); if (captureRequired && !property->isConstant()) { - if (property->accessors->notifier) { + if (property->accessors()->notifier) { if (n && ep->propertyCapture) ep->propertyCapture->captureProperty(n); } else { if (ep->propertyCapture) - ep->propertyCapture->captureProperty(object, property->coreIndex, property->notifyIndex); + ep->propertyCapture->captureProperty(object, property->coreIndex(), property->notifyIndex()); } } @@ -376,12 +376,12 @@ ReturnedValue QObjectWrapper::getProperty(ExecutionEngine *engine, QObject *obje } if (captureRequired && ep && ep->propertyCapture && !property->isConstant()) - ep->propertyCapture->captureProperty(object, property->coreIndex, property->notifyIndex); + ep->propertyCapture->captureProperty(object, property->coreIndex(), property->notifyIndex()); if (property->isVarProperty()) { QQmlVMEMetaObject *vmemo = QQmlVMEMetaObject::get(object); Q_ASSERT(vmemo); - return vmemo->vmeProperty(property->coreIndex); + return vmemo->vmeProperty(property->coreIndex()); } else if (property->isDirect()) { return LoadProperty<ReadAccessor::Direct>(engine, object, *property, 0); } else { @@ -448,13 +448,13 @@ void QObjectWrapper::setProperty(ExecutionEngine *engine, QObject *object, QQmlP QV4::ScopedFunctionObject f(scope, value); if (f) { if (!f->isBinding()) { - if (!property->isVarProperty() && property->propType != qMetaTypeId<QJSValue>()) { + if (!property->isVarProperty() && property->propType() != qMetaTypeId<QJSValue>()) { // assigning a JS function to a non var or QJSValue property or is not allowed. QString error = QLatin1String("Cannot assign JavaScript function to "); - if (!QMetaType::typeName(property->propType)) + if (!QMetaType::typeName(property->propType())) error += QLatin1String("[unknown property type]"); else - error += QLatin1String(QMetaType::typeName(property->propType)); + error += QLatin1String(QMetaType::typeName(property->propType())); scope.engine->throwError(error); return; } @@ -473,13 +473,13 @@ void QObjectWrapper::setProperty(ExecutionEngine *engine, QObject *object, QQmlP if (newBinding) QQmlPropertyPrivate::setBinding(newBinding); else - QQmlPropertyPrivate::removeBinding(object, QQmlPropertyIndex(property->coreIndex)); + QQmlPropertyPrivate::removeBinding(object, QQmlPropertyIndex(property->coreIndex())); if (!newBinding && property->isVarProperty()) { // allow assignment of "special" values (null, undefined, function) to var properties QQmlVMEMetaObject *vmemo = QQmlVMEMetaObject::get(object); Q_ASSERT(vmemo); - vmemo->setVMEProperty(property->coreIndex, value); + vmemo->setVMEProperty(property->coreIndex(), value); return; } @@ -488,44 +488,44 @@ void QObjectWrapper::setProperty(ExecutionEngine *engine, QObject *object, QQmlP int status = -1; \ int flags = 0; \ void *argv[] = { &o, 0, &status, &flags }; \ - QMetaObject::metacall(object, QMetaObject::WriteProperty, property->coreIndex, argv); + QMetaObject::metacall(object, QMetaObject::WriteProperty, property->coreIndex(), argv); if (value.isNull() && property->isQObject()) { PROPERTY_STORE(QObject*, 0); } else if (value.isUndefined() && property->isResettable()) { void *a[] = { 0 }; - QMetaObject::metacall(object, QMetaObject::ResetProperty, property->coreIndex, a); - } else if (value.isUndefined() && property->propType == qMetaTypeId<QVariant>()) { + QMetaObject::metacall(object, QMetaObject::ResetProperty, property->coreIndex(), a); + } else if (value.isUndefined() && property->propType() == qMetaTypeId<QVariant>()) { PROPERTY_STORE(QVariant, QVariant()); - } else if (value.isUndefined() && property->propType == QMetaType::QJsonValue) { + } else if (value.isUndefined() && property->propType() == QMetaType::QJsonValue) { PROPERTY_STORE(QJsonValue, QJsonValue(QJsonValue::Undefined)); - } else if (!newBinding && property->propType == qMetaTypeId<QJSValue>()) { + } else if (!newBinding && property->propType() == qMetaTypeId<QJSValue>()) { PROPERTY_STORE(QJSValue, QJSValue(scope.engine, value.asReturnedValue())); - } else if (value.isUndefined() && property->propType != qMetaTypeId<QQmlScriptString>()) { + } else if (value.isUndefined() && property->propType() != qMetaTypeId<QQmlScriptString>()) { QString error = QLatin1String("Cannot assign [undefined] to "); - if (!QMetaType::typeName(property->propType)) + if (!QMetaType::typeName(property->propType())) error += QLatin1String("[unknown property type]"); else - error += QLatin1String(QMetaType::typeName(property->propType)); + error += QLatin1String(QMetaType::typeName(property->propType())); scope.engine->throwError(error); return; } else if (value.as<FunctionObject>()) { // this is handled by the binding creation above - } else if (property->propType == QMetaType::Int && value.isNumber()) { + } else if (property->propType() == QMetaType::Int && value.isNumber()) { PROPERTY_STORE(int, value.asDouble()); - } else if (property->propType == QMetaType::QReal && value.isNumber()) { + } else if (property->propType() == QMetaType::QReal && value.isNumber()) { PROPERTY_STORE(qreal, qreal(value.asDouble())); - } else if (property->propType == QMetaType::Float && value.isNumber()) { + } else if (property->propType() == QMetaType::Float && value.isNumber()) { PROPERTY_STORE(float, float(value.asDouble())); - } else if (property->propType == QMetaType::Double && value.isNumber()) { + } else if (property->propType() == QMetaType::Double && value.isNumber()) { PROPERTY_STORE(double, double(value.asDouble())); - } else if (property->propType == QMetaType::QString && value.isString()) { + } else if (property->propType() == QMetaType::QString && value.isString()) { PROPERTY_STORE(QString, value.toQStringNoThrow()); } else if (property->isVarProperty()) { QQmlVMEMetaObject *vmemo = QQmlVMEMetaObject::get(object); Q_ASSERT(vmemo); - vmemo->setVMEProperty(property->coreIndex, value); - } else if (property->propType == qMetaTypeId<QQmlScriptString>() && (value.isUndefined() || value.isPrimitive())) { + vmemo->setVMEProperty(property->coreIndex(), value); + } else if (property->propType() == qMetaTypeId<QQmlScriptString>() && (value.isUndefined() || value.isPrimitive())) { QQmlScriptString ss(value.toQStringNoThrow(), 0 /* context */, object); if (value.isNumber()) { ss.d->numberValue = value.toNumber(); @@ -540,7 +540,7 @@ void QObjectWrapper::setProperty(ExecutionEngine *engine, QObject *object, QQmlP if (property->isQList()) v = scope.engine->toVariant(value, qMetaTypeId<QList<QObject *> >()); else - v = scope.engine->toVariant(value, property->propType); + v = scope.engine->toVariant(value, property->propType()); QQmlContextData *callingQmlContext = scope.engine->callingQmlContext(); if (!QQmlPropertyPrivate::write(object, *property, v, callingQmlContext)) { @@ -548,7 +548,7 @@ void QObjectWrapper::setProperty(ExecutionEngine *engine, QObject *object, QQmlP if (v.userType() == QVariant::Invalid) valueType = "null"; else valueType = QMetaType::typeName(v.userType()); - const char *targetTypeName = QMetaType::typeName(property->propType); + const char *targetTypeName = QMetaType::typeName(property->propType()); if (!targetTypeName) targetTypeName = "an unregistered type"; @@ -1323,34 +1323,34 @@ static const QQmlPropertyData * RelatedMethod(const QQmlObjectOrGadget &object, if (!current->isOverload()) return 0; - Q_ASSERT(!current->overrideIndexIsProperty); + Q_ASSERT(!current->overrideIndexIsProperty()); if (propertyCache) { - return propertyCache->method(current->overrideIndex); + return propertyCache->method(current->overrideIndex()); } else { const QMetaObject *mo = object.metaObject(); int methodOffset = mo->methodCount() - QMetaObject_methods(mo); - while (methodOffset > current->overrideIndex) { + while (methodOffset > current->overrideIndex()) { mo = mo->superClass(); methodOffset -= QMetaObject_methods(mo); } // If we've been called before with the same override index, then // we can't go any further... - if (&dummy == current && dummy.coreIndex == current->overrideIndex) + if (&dummy == current && dummy.coreIndex() == current->overrideIndex()) return 0; - QMetaMethod method = mo->method(current->overrideIndex); + QMetaMethod method = mo->method(current->overrideIndex()); dummy.load(method); // Look for overloaded methods QByteArray methodName = method.name(); - for (int ii = current->overrideIndex - 1; ii >= methodOffset; --ii) { + for (int ii = current->overrideIndex() - 1; ii >= methodOffset; --ii) { if (methodName == mo->method(ii).name()) { dummy.setOverload(true); - dummy.overrideIndexIsProperty = 0; - dummy.overrideIndex = ii; + dummy.setOverrideIndexIsProperty(0); + dummy.setOverrideIndex(ii); return &dummy; } } @@ -1380,9 +1380,9 @@ static QV4::ReturnedValue CallPrecise(const QQmlObjectOrGadget &object, const QQ if (data.isConstructor()) args = static_cast<const QQmlStaticMetaObject&>(object).constructorParameterTypes( - data.coreIndex, &storage, &unknownTypeError); + data.coreIndex(), &storage, &unknownTypeError); else - args = object.methodParameterTypes(data.coreIndex, &storage, &unknownTypeError); + args = object.methodParameterTypes(data.coreIndex(), &storage, &unknownTypeError); if (!args) { QString typeName = QString::fromLatin1(unknownTypeError); @@ -1395,11 +1395,11 @@ static QV4::ReturnedValue CallPrecise(const QQmlObjectOrGadget &object, const QQ return engine->throwError(error); } - return CallMethod(object, data.coreIndex, returnType, args[0], args + 1, engine, callArgs, callType); + return CallMethod(object, data.coreIndex(), returnType, args[0], args + 1, engine, callArgs, callType); } else { - return CallMethod(object, data.coreIndex, returnType, 0, 0, engine, callArgs, callType); + return CallMethod(object, data.coreIndex(), returnType, 0, 0, engine, callArgs, callType); } } @@ -1438,7 +1438,7 @@ static QV4::ReturnedValue CallOverloaded(const QQmlObjectOrGadget &object, const int methodArgumentCount = 0; int *methodArgTypes = 0; if (attempt->hasArguments()) { - int *args = object.methodParameterTypes(attempt->coreIndex, &storage, 0); + int *args = object.methodParameterTypes(attempt->coreIndex(), &storage, 0); if (!args) // Must be an unknown argument continue; @@ -1475,7 +1475,7 @@ static QV4::ReturnedValue CallOverloaded(const QQmlObjectOrGadget &object, const const QQmlPropertyData *candidate = &data; while (candidate) { error += QLatin1String("\n ") + - QString::fromUtf8(object.metaObject()->method(candidate->coreIndex) + QString::fromUtf8(object.metaObject()->method(candidate->coreIndex()) .methodSignature()); candidate = RelatedMethod(object, candidate, dummy, propertyCache); } @@ -1859,7 +1859,7 @@ void QObjectMethod::callInternal(CallData *callData, Scope &scope) const const QMetaMethod moMethod = mo->method(d()->index); method.load(moMethod); - if (method.coreIndex == -1) { + if (method.coreIndex() == -1) { scope.result = QV4::Encode::undefined(); return; } @@ -1870,8 +1870,8 @@ void QObjectMethod::callInternal(CallData *callData, Scope &scope) const for (int ii = d()->index - 1; ii >= methodOffset; --ii) { if (methodName == mo->method(ii).name()) { method.setOverload(true); - method.overrideIndexIsProperty = 0; - method.overrideIndex = ii; + method.setOverrideIndexIsProperty(0); + method.setOverrideIndex(ii); break; } } @@ -1883,7 +1883,7 @@ void QObjectMethod::callInternal(CallData *callData, Scope &scope) const QQmlV4Function *funcptr = &func; void *args[] = { 0, &funcptr }; - object.metacall(QMetaObject::InvokeMetaMethod, method.coreIndex, args); + object.metacall(QMetaObject::InvokeMetaMethod, method.coreIndex(), args); return; } @@ -1923,7 +1923,7 @@ void Heap::QMetaObjectWrapper::ensureConstructorsCache() { QMetaMethod method = metaObject->constructor(i); QQmlPropertyData d; d.load(method); - d.coreIndex = i; + d.setCoreIndex(i); constructors << d; } } @@ -2010,7 +2010,7 @@ ReturnedValue QMetaObjectWrapper::callOverloadedConstructor(QV4::ExecutionEngine int *methodArgTypes = 0; if (attempt.hasArguments()) { QQmlMetaObject::ArgTypeStorage storage; - int *args = object.constructorParameterTypes(attempt.coreIndex, &storage, 0); + int *args = object.constructorParameterTypes(attempt.coreIndex(), &storage, 0); if (!args) // Must be an unknown argument continue; @@ -2046,7 +2046,7 @@ ReturnedValue QMetaObjectWrapper::callOverloadedConstructor(QV4::ExecutionEngine for (int i = 0; i < numberOfConstructors; i++) { const QQmlPropertyData & candidate = d()->constructors.at(i); error += QLatin1String("\n ") + - QString::fromUtf8(d()->metaObject->constructor(candidate.coreIndex) + QString::fromUtf8(d()->metaObject->constructor(candidate.coreIndex()) .methodSignature()); } diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index 3b3e23c891..8ed7641610 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -275,7 +275,7 @@ protected: int propertyType = StaticPropType; // If the binding is specialized to a type, the if and switch below will be constant-folded. if (propertyType == QMetaType::UnknownType) - propertyType = pd->propType; + propertyType = pd->propType(); if (Q_LIKELY(!isUndefined && !vpd.isValid())) { switch (propertyType) { @@ -304,8 +304,8 @@ protected: break; default: if (const QV4::QQmlValueTypeWrapper *vtw = result.as<const QV4::QQmlValueTypeWrapper>()) { - if (vtw->d()->valueType->typeId == pd->propType) { - return vtw->write(m_target.data(), pd->coreIndex); + if (vtw->d()->valueType->typeId == pd->propType()) { + return vtw->write(m_target.data(), pd->coreIndex()); } } break; @@ -331,7 +331,7 @@ Q_NEVER_INLINE bool QQmlBinding::slowWrite(const QQmlPropertyData &core, QQmlEngine *engine = context()->engine; QV8Engine *v8engine = QQmlEnginePrivate::getV8Engine(engine); - int type = valueTypeData.isValid() ? valueTypeData.propType : core.propType; + int type = valueTypeData.isValid() ? valueTypeData.propType() : core.propType(); QQmlJavaScriptExpression::DeleteWatcher watcher(this); @@ -343,7 +343,7 @@ Q_NEVER_INLINE bool QQmlBinding::slowWrite(const QQmlPropertyData &core, value = QV8Engine::getV4(v8engine)->toVariant(result, qMetaTypeId<QList<QObject *> >()); } else if (result.isNull() && core.isQObject()) { value = QVariant::fromValue((QObject *)0); - } else if (core.propType == qMetaTypeId<QList<QUrl> >()) { + } else if (core.propType() == qMetaTypeId<QList<QUrl> >()) { value = QQmlPropertyPrivate::resolvedUrlSequence(QV8Engine::getV4(v8engine)->toVariant(result, qMetaTypeId<QList<QUrl> >()), context()); } else if (!isVarProperty && type != qMetaTypeId<QJSValue>()) { value = QV8Engine::getV4(v8engine)->toVariant(result, type); @@ -362,10 +362,10 @@ Q_NEVER_INLINE bool QQmlBinding::slowWrite(const QQmlPropertyData &core, QQmlVMEMetaObject *vmemo = QQmlVMEMetaObject::get(m_target.data()); Q_ASSERT(vmemo); - vmemo->setVMEProperty(core.coreIndex, result); + vmemo->setVMEProperty(core.coreIndex(), result); } else if (isUndefined && core.isResettable()) { void *args[] = { 0 }; - QMetaObject::metacall(m_target.data(), QMetaObject::ResetProperty, core.coreIndex, args); + QMetaObject::metacall(m_target.data(), QMetaObject::ResetProperty, core.coreIndex(), args); } else if (isUndefined && type == qMetaTypeId<QVariant>()) { QQmlPropertyPrivate::writeValueProperty(m_target.data(), core, valueTypeData, QVariant(), context(), flags); } else if (type == qMetaTypeId<QJSValue>()) { @@ -507,8 +507,8 @@ void QQmlBinding::setTarget(QObject *object, const QQmlPropertyData &core, const return; } - int coreIndex = core.coreIndex; - int valueTypeIndex = valueType ? valueType->coreIndex : -1; + int coreIndex = core.coreIndex(); + int valueTypeIndex = valueType ? valueType->coreIndex() : -1; for (bool isAlias = core.isAlias(); isAlias; ) { QQmlVMEMetaObject *vme = QQmlVMEMetaObject::getForProperty(object, coreIndex); @@ -532,7 +532,7 @@ void QQmlBinding::setTarget(QObject *object, const QQmlPropertyData &core, const m_target = object; isAlias = propertyData->isAlias(); - coreIndex = propertyData->coreIndex; + coreIndex = propertyData->coreIndex(); } m_targetIndex = QQmlPropertyIndex(coreIndex, valueTypeIndex); @@ -554,12 +554,12 @@ void QQmlBinding::getPropertyData(QQmlPropertyData **propertyData, QQmlPropertyD Q_ASSERT(*propertyData); if (Q_UNLIKELY(m_targetIndex.hasValueTypeIndex() && valueTypeData)) { - const QMetaObject *valueTypeMetaObject = QQmlValueTypeFactory::metaObjectForMetaType((*propertyData)->propType); + const QMetaObject *valueTypeMetaObject = QQmlValueTypeFactory::metaObjectForMetaType((*propertyData)->propType()); Q_ASSERT(valueTypeMetaObject); QMetaProperty vtProp = valueTypeMetaObject->property(m_targetIndex.valueTypeIndex()); valueTypeData->setFlags(QQmlPropertyData::flagsForProperty(vtProp)); - valueTypeData->propType = vtProp.userType(); - valueTypeData->coreIndex = m_targetIndex.valueTypeIndex(); + valueTypeData->setPropType(vtProp.userType()); + valueTypeData->setCoreIndex(m_targetIndex.valueTypeIndex()); } } @@ -625,9 +625,9 @@ protected: QQmlBinding *QQmlBinding::newBinding(QQmlEnginePrivate *engine, const QQmlPropertyData *property) { if (property && property->isQObject()) - return new QObjectPointerBinding(engine, property->propType); + return new QObjectPointerBinding(engine, property->propType()); - const int type = (property && property->isFullyResolved()) ? property->propType : QMetaType::UnknownType; + const int type = (property && property->isFullyResolved()) ? property->propType() : QMetaType::UnknownType; if (type == qMetaTypeId<QQmlBinding *>()) { return new QQmlBindingBinding; diff --git a/src/qml/qml/qqmlcontext.cpp b/src/qml/qml/qqmlcontext.cpp index 6621f48e20..018841b9b1 100644 --- a/src/qml/qml/qqmlcontext.cpp +++ b/src/qml/qml/qqmlcontext.cpp @@ -383,7 +383,7 @@ QVariant QQmlContext::contextProperty(const QString &name) const QQmlPropertyData *property = QQmlPropertyCache::property(data->engine, obj, name, data, local); - if (property) value = obj->metaObject()->property(property->coreIndex).read(obj); + if (property) value = obj->metaObject()->property(property->coreIndex()).read(obj); } if (!value.isValid() && parentContext()) value = parentContext()->contextProperty(name); diff --git a/src/qml/qml/qqmllist.cpp b/src/qml/qml/qqmllist.cpp index d0b7fb4853..a719956483 100644 --- a/src/qml/qml/qqmllist.cpp +++ b/src/qml/qml/qqmllist.cpp @@ -143,16 +143,16 @@ QQmlListReference::QQmlListReference(QObject *object, const char *property, QQml QQmlEnginePrivate *p = engine?QQmlEnginePrivate::get(engine):0; - int listType = p?p->listType(data->propType):QQmlMetaType::listType(data->propType); + int listType = p?p->listType(data->propType()):QQmlMetaType::listType(data->propType()); if (listType == -1) return; d = new QQmlListReferencePrivate; d->object = object; d->elementType = p?p->rawMetaObjectForType(listType):QQmlMetaType::qmlType(listType)->baseMetaObject(); - d->propertyType = data->propType; + d->propertyType = data->propType(); void *args[] = { &d->property, 0 }; - QMetaObject::metacall(object, QMetaObject::ReadProperty, data->coreIndex, args); + QMetaObject::metacall(object, QMetaObject::ReadProperty, data->coreIndex(), args); } /*! \internal */ diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 993331b0a0..f9794ec26a 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -281,7 +281,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const QQmlPropertyData::WriteFlags propertyWriteFlags = QQmlPropertyData::BypassInterceptor | QQmlPropertyData::RemoveBindingOnAliasWrite; QV4::Scope scope(v4); - int propertyType = property->propType; + int propertyType = property->propType(); if (property->isEnum()) { if (binding->flags & QV4::CompiledData::Binding::IsResolvedEnum) { @@ -302,7 +302,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const double n = binding->valueAsNumber(); if (double(int(n)) == n) { if (property->isVarProperty()) { - _vmeMetaObject->setVMEProperty(property->coreIndex, QV4::Primitive::fromInt32(int(n))); + _vmeMetaObject->setVMEProperty(property->coreIndex(), QV4::Primitive::fromInt32(int(n))); } else { int i = int(n); QVariant value(i); @@ -310,7 +310,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const } } else { if (property->isVarProperty()) { - _vmeMetaObject->setVMEProperty(property->coreIndex, QV4::Primitive::fromDouble(n)); + _vmeMetaObject->setVMEProperty(property->coreIndex(), QV4::Primitive::fromDouble(n)); } else { QVariant value(n); property->writeProperty(_qobject, &value, propertyWriteFlags); @@ -318,7 +318,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const } } else if (binding->type == QV4::CompiledData::Binding::Type_Boolean) { if (property->isVarProperty()) { - _vmeMetaObject->setVMEProperty(property->coreIndex, QV4::Primitive::fromBoolean(binding->valueAsBoolean())); + _vmeMetaObject->setVMEProperty(property->coreIndex(), QV4::Primitive::fromBoolean(binding->valueAsBoolean())); } else { QVariant value(binding->valueAsBoolean()); property->writeProperty(_qobject, &value, propertyWriteFlags); @@ -327,7 +327,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const QString stringValue = binding->valueAsString(qmlUnit); if (property->isVarProperty()) { QV4::ScopedString s(scope, v4->newString(stringValue)); - _vmeMetaObject->setVMEProperty(property->coreIndex, s); + _vmeMetaObject->setVMEProperty(property->coreIndex(), s); } else { QVariant value = QQmlStringConverters::variantFromString(stringValue); property->writeProperty(_qobject, &value, propertyWriteFlags); @@ -398,7 +398,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const uint colorValue = QQmlStringConverters::rgbaFromString(binding->valueAsString(qmlUnit), &ok); Q_ASSERT(ok); struct { void *data[4]; } buffer; - if (QQml_valueTypeProvider()->storeValueType(property->propType, &colorValue, &buffer, sizeof(buffer))) { + if (QQml_valueTypeProvider()->storeValueType(property->propType(), &colorValue, &buffer, sizeof(buffer))) { property->writeProperty(_qobject, &buffer, propertyWriteFlags); } } @@ -534,26 +534,26 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const break; default: { // generate single literal value assignment to a list property if required - if (property->propType == qMetaTypeId<QList<qreal> >()) { + if (property->propType() == qMetaTypeId<QList<qreal> >()) { Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_Number); QList<qreal> value; value.append(binding->valueAsNumber()); property->writeProperty(_qobject, &value, propertyWriteFlags); break; - } else if (property->propType == qMetaTypeId<QList<int> >()) { + } else if (property->propType() == qMetaTypeId<QList<int> >()) { Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_Number); double n = binding->valueAsNumber(); QList<int> value; value.append(int(n)); property->writeProperty(_qobject, &value, propertyWriteFlags); break; - } else if (property->propType == qMetaTypeId<QList<bool> >()) { + } else if (property->propType() == qMetaTypeId<QList<bool> >()) { Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_Boolean); QList<bool> value; value.append(binding->valueAsBoolean()); property->writeProperty(_qobject, &value, propertyWriteFlags); break; - } else if (property->propType == qMetaTypeId<QList<QUrl> >()) { + } else if (property->propType() == qMetaTypeId<QList<QUrl> >()) { Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_String); QString urlString = binding->valueAsString(qmlUnit); QUrl u = urlString.isEmpty() ? QUrl() : compilationUnit->url().resolved(QUrl(urlString)); @@ -561,13 +561,13 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const value.append(u); property->writeProperty(_qobject, &value, propertyWriteFlags); break; - } else if (property->propType == qMetaTypeId<QList<QString> >()) { + } else if (property->propType() == qMetaTypeId<QList<QString> >()) { Q_ASSERT(binding->evaluatesToString()); QList<QString> value; value.append(binding->valueAsString(qmlUnit)); property->writeProperty(_qobject, &value, propertyWriteFlags); break; - } else if (property->propType == qMetaTypeId<QJSValue>()) { + } else if (property->propType() == qMetaTypeId<QJSValue>()) { QJSValue value; if (binding->type == QV4::CompiledData::Binding::Type_Boolean) { value = QJSValue(binding->valueAsBoolean()); @@ -586,12 +586,12 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const // otherwise, try a custom type assignment QString stringValue = binding->valueAsString(qmlUnit); - QQmlMetaType::StringConverter converter = QQmlMetaType::customStringConverter(property->propType); + QQmlMetaType::StringConverter converter = QQmlMetaType::customStringConverter(property->propType()); Q_ASSERT(converter); QVariant value = (*converter)(stringValue); - QMetaProperty metaProperty = _qobject->metaObject()->property(property->coreIndex); - if (value.isNull() || ((int)metaProperty.type() != property->propType && metaProperty.userType() != property->propType)) { + QMetaProperty metaProperty = _qobject->metaObject()->property(property->coreIndex()); + if (value.isNull() || ((int)metaProperty.type() != property->propType() && metaProperty.userType() != property->propType())) { recordError(binding->location, tr("Cannot assign value %1 to property %2").arg(stringValue).arg(QString::fromUtf8(metaProperty.name()))); break; } @@ -623,7 +623,7 @@ void QQmlObjectCreator::setupBindings(bool applyDeferredBindings) if (_compiledObject->idNameIndex) { const QQmlPropertyData *idProperty = propertyData.last(); Q_ASSERT(!idProperty || !idProperty->isValid() || idProperty->name(_qobject) == QLatin1String("id")); - if (idProperty && idProperty->isValid() && idProperty->isWritable() && idProperty->propType == QMetaType::QString) { + if (idProperty && idProperty->isValid() && idProperty->isWritable() && idProperty->propType() == QMetaType::QString) { QV4::CompiledData::Binding idBinding; idBinding.propertyNameIndex = 0; // Not used idBinding.flags = 0; @@ -636,10 +636,10 @@ void QQmlObjectCreator::setupBindings(bool applyDeferredBindings) // ### this is best done through type-compile-time binding skip lists. if (_valueTypeProperty) { - QQmlAbstractBinding *binding = QQmlPropertyPrivate::binding(_bindingTarget, QQmlPropertyIndex(_valueTypeProperty->coreIndex)); + QQmlAbstractBinding *binding = QQmlPropertyPrivate::binding(_bindingTarget, QQmlPropertyIndex(_valueTypeProperty->coreIndex())); if (binding && !binding->isValueTypeProxy()) { - QQmlPropertyPrivate::removeBinding(_bindingTarget, QQmlPropertyIndex(_valueTypeProperty->coreIndex)); + QQmlPropertyPrivate::removeBinding(_bindingTarget, QQmlPropertyIndex(_valueTypeProperty->coreIndex())); } else if (binding) { QQmlValueTypeProxyBinding *proxy = static_cast<QQmlValueTypeProxyBinding *>(binding); @@ -652,7 +652,7 @@ void QQmlObjectCreator::setupBindings(bool applyDeferredBindings) for (quint32 i = 0; i < _compiledObject->nBindings; ++i, ++binding) { QQmlPropertyData *property = binding->propertyNameIndex != 0 ? _propertyCache->property(stringAt(binding->propertyNameIndex), _qobject, context) : defaultProperty; if (property) - bindingSkipList |= (1 << property->coreIndex); + bindingSkipList |= (1 << property->coreIndex()); } proxy->removeBindings(bindingSkipList); @@ -678,10 +678,10 @@ void QQmlObjectCreator::setupBindings(bool applyDeferredBindings) const QQmlPropertyData *property = propertyData.at(i); if (property && property->isQList()) { - if (property->coreIndex != currentListPropertyIndex) { + if (property->coreIndex() != currentListPropertyIndex) { void *argv[1] = { (void*)&_currentList }; - QMetaObject::metacall(_qobject, QMetaObject::ReadProperty, property->coreIndex, argv); - currentListPropertyIndex = property->coreIndex; + QMetaObject::metacall(_qobject, QMetaObject::ReadProperty, property->coreIndex(), argv); + currentListPropertyIndex = property->coreIndex(); } } else if (_currentList.object) { _currentList = QQmlListProperty<void>(); @@ -717,7 +717,7 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con } // ### resolve this at compile time - if (property && property->propType == qMetaTypeId<QQmlScriptString>()) { + if (property && property->propType() == qMetaTypeId<QQmlScriptString>()) { QQmlScriptString ss(binding->valueAsScriptString(qmlUnit), context->asQQmlContext(), _scopeObject); ss.d.data()->bindingId = binding->type == QV4::CompiledData::Binding::Type_Script ? binding->value.compiledScriptIndex : (quint32)QQmlBinding::Invalid; ss.d.data()->lineNumber = binding->location.line; @@ -730,7 +730,7 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con QQmlPropertyData::RemoveBindingOnAliasWrite; int propertyWriteStatus = -1; void *argv[] = { &ss, 0, &propertyWriteStatus, &propertyWriteFlags }; - QMetaObject::metacall(_qobject, QMetaObject::WriteProperty, property->coreIndex, argv); + QMetaObject::metacall(_qobject, QMetaObject::WriteProperty, property->coreIndex(), argv); return true; } @@ -753,20 +753,20 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con const QQmlPropertyData *valueTypeProperty = 0; QObject *bindingTarget = _bindingTarget; - if (QQmlValueTypeFactory::isValueType(property->propType)) { - valueType = QQmlValueTypeFactory::valueType(property->propType); + if (QQmlValueTypeFactory::isValueType(property->propType())) { + valueType = QQmlValueTypeFactory::valueType(property->propType()); if (!valueType) { recordError(binding->location, tr("Cannot set properties on %1 as it is null").arg(stringAt(binding->propertyNameIndex))); return false; } - valueType->read(_qobject, property->coreIndex); + valueType->read(_qobject, property->coreIndex()); groupObject = valueType; valueTypeProperty = property; } else { void *argv[1] = { &groupObject }; - QMetaObject::metacall(_qobject, QMetaObject::ReadProperty, property->coreIndex, argv); + QMetaObject::metacall(_qobject, QMetaObject::ReadProperty, property->coreIndex(), argv); if (!groupObject) { recordError(binding->location, tr("Cannot set properties on %1 as it is null").arg(stringAt(binding->propertyNameIndex))); return false; @@ -779,16 +779,16 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con return false; if (valueType) - valueType->write(_qobject, property->coreIndex, QQmlPropertyData::BypassInterceptor); + valueType->write(_qobject, property->coreIndex(), QQmlPropertyData::BypassInterceptor); return true; } } - if (_ddata->hasBindingBit(property->coreIndex) && !(binding->flags & QV4::CompiledData::Binding::IsSignalHandlerExpression) + if (_ddata->hasBindingBit(property->coreIndex()) && !(binding->flags & QV4::CompiledData::Binding::IsSignalHandlerExpression) && !(binding->flags & QV4::CompiledData::Binding::IsOnAssignment) && !_valueTypeProperty) - QQmlPropertyPrivate::removeBinding(_bindingTarget, QQmlPropertyIndex(property->coreIndex)); + QQmlPropertyPrivate::removeBinding(_bindingTarget, QQmlPropertyIndex(property->coreIndex())); if (binding->type == QV4::CompiledData::Binding::Type_Script) { QV4::Function *runtimeFunction = compilationUnit->runtimeFunctions[binding->value.compiledScriptIndex]; @@ -798,7 +798,7 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con QV4::ScopedFunctionObject function(scope, QV4::FunctionObject::createScriptFunction(qmlContext, runtimeFunction, /*createProto*/ false)); if (binding->flags & QV4::CompiledData::Binding::IsSignalHandlerExpression) { - int signalIndex = _propertyCache->methodIndexToSignalIndex(property->coreIndex); + int signalIndex = _propertyCache->methodIndexToSignalIndex(property->coreIndex()); QQmlBoundSignal *bs = new QQmlBoundSignal(_bindingTarget, signalIndex, _scopeObject, engine); QQmlBoundSignalExpression *expr = new QQmlBoundSignalExpression(_bindingTarget, signalIndex, context, _scopeObject, function); @@ -829,7 +829,7 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con if (!_valueTypeProperty) { QQmlData *targetDeclarativeData = QQmlData::get(_bindingTarget); Q_ASSERT(targetDeclarativeData); - targetDeclarativeData->setPendingBindingBit(_bindingTarget, property->coreIndex); + targetDeclarativeData->setPendingBindingBit(_bindingTarget, property->coreIndex()); } } } @@ -861,7 +861,7 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con QQmlPropertyIndex propertyIndex; if (property->isAlias()) { - QQmlPropertyIndex originalIndex(property->coreIndex, _valueTypeProperty ? _valueTypeProperty->coreIndex : -1); + QQmlPropertyIndex originalIndex(property->coreIndex(), _valueTypeProperty ? _valueTypeProperty->coreIndex() : -1); QQmlPropertyIndex propIndex; QQmlPropertyPrivate::findAliasTarget(target, originalIndex, &target, &propIndex); QQmlData *data = QQmlData::get(target); @@ -906,7 +906,7 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con return false; } - QMetaMethod signalMethod = _qobject->metaObject()->method(property->coreIndex); + QMetaMethod signalMethod = _qobject->metaObject()->method(property->coreIndex()); if (!QMetaObject::checkConnectArgs(signalMethod, method)) { recordError(binding->valueLocation, tr("Cannot connect mismatched signal/slot %1 %vs. %2") @@ -915,7 +915,7 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con return false; } - QQmlPropertyPrivate::connect(_qobject, property->coreIndex, createdSubObject, method.methodIndex()); + QQmlPropertyPrivate::connect(_qobject, property->coreIndex(), createdSubObject, method.methodIndex()); return true; } @@ -924,24 +924,24 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con int propertyWriteStatus = -1; void *argv[] = { 0, 0, &propertyWriteStatus, &propertyWriteFlags }; - if (const char *iid = QQmlMetaType::interfaceIId(property->propType)) { + if (const char *iid = QQmlMetaType::interfaceIId(property->propType())) { void *ptr = createdSubObject->qt_metacast(iid); if (ptr) { argv[0] = &ptr; - QMetaObject::metacall(_qobject, QMetaObject::WriteProperty, property->coreIndex, argv); + QMetaObject::metacall(_qobject, QMetaObject::WriteProperty, property->coreIndex(), argv); } else { recordError(binding->location, tr("Cannot assign object to interface property")); return false; } - } else if (property->propType == QMetaType::QVariant) { + } else if (property->propType() == QMetaType::QVariant) { if (property->isVarProperty()) { QV4::Scope scope(v4); QV4::ScopedValue wrappedObject(scope, QV4::QObjectWrapper::wrap(QV8Engine::getV4(engine), createdSubObject)); - _vmeMetaObject->setVMEProperty(property->coreIndex, wrappedObject); + _vmeMetaObject->setVMEProperty(property->coreIndex(), wrappedObject); } else { QVariant value = QVariant::fromValue(createdSubObject); argv[0] = &value; - QMetaObject::metacall(_qobject, QMetaObject::WriteProperty, property->coreIndex, argv); + QMetaObject::metacall(_qobject, QMetaObject::WriteProperty, property->coreIndex(), argv); } } else if (property->isQList()) { Q_ASSERT(_currentList.object); @@ -949,7 +949,7 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con void *itemToAdd = createdSubObject; const char *iid = 0; - int listItemType = QQmlEnginePrivate::get(engine)->listType(property->propType); + int listItemType = QQmlEnginePrivate::get(engine)->listType(property->propType()); if (listItemType != -1) iid = QQmlMetaType::interfaceIId(listItemType); if (iid) @@ -965,7 +965,7 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con } else { // pointer compatibility was tested in QQmlPropertyValidator at type compile time argv[0] = &createdSubObject; - QMetaObject::metacall(_qobject, QMetaObject::WriteProperty, property->coreIndex, argv); + QMetaObject::metacall(_qobject, QMetaObject::WriteProperty, property->coreIndex(), argv); } return true; } @@ -995,7 +995,7 @@ void QQmlObjectCreator::setupFunctions() continue; function = QV4::FunctionObject::createScriptFunction(qmlContext, runtimeFunction); - _vmeMetaObject->setVmeMethod(property->coreIndex, function); + _vmeMetaObject->setVmeMethod(property->coreIndex(), function); } } diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp index e287b68385..7b1e2ec4f6 100644 --- a/src/qml/qml/qqmlproperty.cpp +++ b/src/qml/qml/qqmlproperty.cpp @@ -291,9 +291,9 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name) if (property->isFunction()) return; // Not an object property - if (ii == (path.count() - 2) && QQmlValueTypeFactory::isValueType(property->propType)) { + if (ii == (path.count() - 2) && QQmlValueTypeFactory::isValueType(property->propType())) { // We're now at a value type property - const QMetaObject *valueTypeMetaObject = QQmlValueTypeFactory::metaObjectForMetaType(property->propType); + const QMetaObject *valueTypeMetaObject = QQmlValueTypeFactory::metaObjectForMetaType(property->propType()); if (!valueTypeMetaObject) return; // Not a value type int idx = valueTypeMetaObject->indexOfProperty(path.last().toUtf8().constData()); @@ -307,8 +307,8 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name) object = currentObject; core = *property; valueTypeData.setFlags(QQmlPropertyData::flagsForProperty(vtProp)); - valueTypeData.propType = vtProp.userType(); - valueTypeData.coreIndex = idx; + valueTypeData.setPropType(vtProp.userType()); + valueTypeData.setCoreIndex(idx); return; } else { @@ -355,9 +355,9 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name) while (d && d->isFunction()) d = ddata->propertyCache->overrideData(d); - if (d && d->notifyIndex != -1) { + if (d && d->notifyIndex() != -1) { object = currentObject; - core = *ddata->propertyCache->signal(d->notifyIndex); + core = *ddata->propertyCache->signal(d->notifyIndex()); return; } } @@ -394,7 +394,7 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name) int QQmlPropertyPrivate::signalIndex() const { Q_ASSERT(type() == QQmlProperty::SignalProperty); - QMetaMethod m = object->metaObject()->method(core.coreIndex); + QMetaMethod m = object->metaObject()->method(core.coreIndex()); return QMetaObjectPrivate::signalIndex(m); } @@ -470,11 +470,11 @@ const char *QQmlProperty::propertyTypeName() const if (!d) return 0; if (d->isValueType()) { - const QMetaObject *valueTypeMetaObject = QQmlValueTypeFactory::metaObjectForMetaType(d->core.propType); + const QMetaObject *valueTypeMetaObject = QQmlValueTypeFactory::metaObjectForMetaType(d->core.propType()); Q_ASSERT(valueTypeMetaObject); - return valueTypeMetaObject->property(d->valueTypeData.coreIndex).typeName(); + return valueTypeMetaObject->property(d->valueTypeData.coreIndex()).typeName(); } else if (d->object && type() & Property && d->core.isValid()) { - return d->object->metaObject()->property(d->core.coreIndex).typeName(); + return d->object->metaObject()->property(d->core.coreIndex()).typeName(); } else { return 0; } @@ -491,8 +491,8 @@ bool QQmlProperty::operator==(const QQmlProperty &other) const // category is intentially omitted here as it is generated // from the other members return d->object == other.d->object && - d->core.coreIndex == other.d->core.coreIndex && - d->valueTypeData.coreIndex == other.d->valueTypeData.coreIndex; + d->core.coreIndex() == other.d->core.coreIndex() && + d->valueTypeData.coreIndex() == other.d->valueTypeData.coreIndex(); } /*! @@ -513,9 +513,9 @@ int QQmlPropertyPrivate::propertyType() const { uint type = this->type(); if (isValueType()) { - return valueTypeData.propType; + return valueTypeData.propType(); } else if (type & QQmlProperty::Property) { - return core.propType; + return core.propType(); } else { return QVariant::Invalid; } @@ -604,7 +604,7 @@ bool QQmlProperty::isDesignable() const if (!d) return false; if (type() & Property && d->core.isValid() && d->object) - return d->object->metaObject()->property(d->core.coreIndex).isDesignable(); + return d->object->metaObject()->property(d->core.coreIndex()).isDesignable(); else return false; } @@ -644,10 +644,10 @@ QString QQmlProperty::name() const // ### if (!d->object) { } else if (d->isValueType()) { - const QMetaObject *valueTypeMetaObject = QQmlValueTypeFactory::metaObjectForMetaType(d->core.propType); + const QMetaObject *valueTypeMetaObject = QQmlValueTypeFactory::metaObjectForMetaType(d->core.propType()); Q_ASSERT(valueTypeMetaObject); - const char *vtName = valueTypeMetaObject->property(d->valueTypeData.coreIndex).name(); + const char *vtName = valueTypeMetaObject->property(d->valueTypeData.coreIndex()).name(); d->nameCache = d->core.name(d->object) + QLatin1Char('.') + QString::fromUtf8(vtName); } else if (type() & SignalProperty) { QString name = QLatin1String("on") + d->core.name(d->object); @@ -671,7 +671,7 @@ QMetaProperty QQmlProperty::property() const if (!d) return QMetaProperty(); if (type() & Property && d->core.isValid() && d->object) - return d->object->metaObject()->property(d->core.coreIndex); + return d->object->metaObject()->property(d->core.coreIndex()); else return QMetaProperty(); } @@ -685,7 +685,7 @@ QMetaMethod QQmlProperty::method() const if (!d) return QMetaMethod(); if (type() & SignalProperty && d->object) - return d->object->metaObject()->method(d->core.coreIndex); + return d->object->metaObject()->method(d->core.coreIndex()); else return QMetaMethod(); } @@ -700,7 +700,7 @@ QQmlPropertyPrivate::binding(const QQmlProperty &that) if (!that.d || !that.isProperty() || !that.d->object) return 0; - QQmlPropertyIndex thatIndex(that.d->core.coreIndex, that.d->valueTypeData.coreIndex); + QQmlPropertyIndex thatIndex(that.d->core.coreIndex(), that.d->valueTypeData.coreIndex()); return binding(that.d->object, thatIndex); } @@ -1020,16 +1020,16 @@ QVariant QQmlPropertyPrivate::readValueProperty() { if (isValueType()) { - QQmlValueType *valueType = QQmlValueTypeFactory::valueType(core.propType); + QQmlValueType *valueType = QQmlValueTypeFactory::valueType(core.propType()); Q_ASSERT(valueType); - valueType->read(object, core.coreIndex); - return valueType->metaObject()->property(valueTypeData.coreIndex).read(valueType); + valueType->read(object, core.coreIndex()); + return valueType->metaObject()->property(valueTypeData.coreIndex()).read(valueType); } else if (core.isQList()) { QQmlListProperty<QObject> prop; core.readProperty(object, &prop); - return QVariant::fromValue(QQmlListReferencePrivate::init(prop, core.propType, engine)); + return QVariant::fromValue(QQmlListReferencePrivate::init(prop, core.propType(), engine)); } else if (core.isQObject()) { @@ -1039,21 +1039,21 @@ QVariant QQmlPropertyPrivate::readValueProperty() } else { - if (!core.propType) // Unregistered type - return object->metaObject()->property(core.coreIndex).read(object); + if (!core.propType()) // Unregistered type + return object->metaObject()->property(core.coreIndex()).read(object); QVariant value; int status = -1; void *args[] = { 0, &value, &status }; - if (core.propType == QMetaType::QVariant) { + if (core.propType() == QMetaType::QVariant) { args[0] = &value; } else { - value = QVariant(core.propType, (void*)0); + value = QVariant(core.propType(), (void*)0); args[0] = value.data(); } core.readPropertyWithArgs(object, args); - if (core.propType != QMetaType::QVariant && args[0] != value.data()) - return QVariant((QVariant::Type)core.propType, args[0]); + if (core.propType() != QMetaType::QVariant && args[0] != value.data()) + return QVariant((QVariant::Type)core.propType(), args[0]); return value; } @@ -1157,10 +1157,10 @@ QQmlPropertyPrivate::writeValueProperty(QObject *object, bool rv = false; if (valueTypeData.isValid()) { - QQmlValueType *writeBack = QQmlValueTypeFactory::valueType(core.propType); - writeBack->read(object, core.coreIndex); + QQmlValueType *writeBack = QQmlValueTypeFactory::valueType(core.propType()); + writeBack->read(object, core.coreIndex()); rv = write(writeBack, valueTypeData, value, context, flags); - writeBack->write(object, core.coreIndex, flags); + writeBack->write(object, core.coreIndex(), flags); } else { rv = write(object, core, value, context, flags); } @@ -1173,11 +1173,11 @@ bool QQmlPropertyPrivate::write(QObject *object, const QVariant &value, QQmlContextData *context, QQmlPropertyData::WriteFlags flags) { - const int propertyType = property.propType; + const int propertyType = property.propType(); const int variantType = value.userType(); if (property.isEnum()) { - QMetaProperty prop = object->metaObject()->property(property.coreIndex); + QMetaProperty prop = object->metaObject()->property(property.coreIndex()); QVariant v = value; // Enum values come through the script engine as doubles if (variantType == QVariant::Double) { @@ -1186,7 +1186,7 @@ bool QQmlPropertyPrivate::write(QObject *object, if (qFuzzyIsNull(fractional)) v.convert(QVariant::Int); } - return writeEnumProperty(prop, property.coreIndex, object, v, flags); + return writeEnumProperty(prop, property.coreIndex(), object, v, flags); } QQmlEnginePrivate *enginePriv = QQmlEnginePrivate::get(context); @@ -1274,9 +1274,9 @@ bool QQmlPropertyPrivate::write(QObject *object, QQmlMetaObject listType; if (enginePriv) { - listType = enginePriv->rawMetaObjectForType(enginePriv->listType(property.propType)); + listType = enginePriv->rawMetaObjectForType(enginePriv->listType(property.propType())); } else { - QQmlType *type = QQmlMetaType::qmlType(QQmlMetaType::listType(property.propType)); + QQmlType *type = QQmlMetaType::qmlType(QQmlMetaType::listType(property.propType())); if (!type) return false; listType = type->baseMetaObject(); @@ -1491,7 +1491,7 @@ bool QQmlProperty::reset() const { if (isResettable()) { void *args[] = { 0 }; - QMetaObject::metacall(d->object, QMetaObject::ResetProperty, d->core.coreIndex, args); + QMetaObject::metacall(d->object, QMetaObject::ResetProperty, d->core.coreIndex(), args); return true; } else { return false; @@ -1516,7 +1516,7 @@ bool QQmlPropertyPrivate::write(const QQmlProperty &that, bool QQmlProperty::hasNotifySignal() const { if (type() & Property && d->object) { - return d->object->metaObject()->property(d->core.coreIndex).hasNotifySignal(); + return d->object->metaObject()->property(d->core.coreIndex()).hasNotifySignal(); } return false; } @@ -1546,7 +1546,7 @@ bool QQmlProperty::connectNotifySignal(QObject *dest, int method) const if (!(type() & Property) || !d->object) return false; - QMetaProperty prop = d->object->metaObject()->property(d->core.coreIndex); + QMetaProperty prop = d->object->metaObject()->property(d->core.coreIndex()); if (prop.hasNotifySignal()) { return QQmlPropertyPrivate::connect(d->object, prop.notifySignalIndex(), dest, method, Qt::DirectConnection); } else { @@ -1567,7 +1567,7 @@ bool QQmlProperty::connectNotifySignal(QObject *dest, const char *slot) const if (!(type() & Property) || !d->object) return false; - QMetaProperty prop = d->object->metaObject()->property(d->core.coreIndex); + QMetaProperty prop = d->object->metaObject()->property(d->core.coreIndex()); if (prop.hasNotifySignal()) { QByteArray signal('2' + prop.notifySignal().methodSignature()); return QObject::connect(d->object, signal.constData(), dest, slot); @@ -1581,7 +1581,7 @@ bool QQmlProperty::connectNotifySignal(QObject *dest, const char *slot) const */ int QQmlProperty::index() const { - return d ? d->core.coreIndex : -1; + return d ? d->core.coreIndex() : -1; } QQmlPropertyIndex QQmlPropertyPrivate::propertyIndex(const QQmlProperty &that) diff --git a/src/qml/qml/qqmlproperty_p.h b/src/qml/qml/qqmlproperty_p.h index 16d2bfef64..2565ec0ce6 100644 --- a/src/qml/qml/qqmlproperty_p.h +++ b/src/qml/qml/qqmlproperty_p.h @@ -83,7 +83,7 @@ public: QQmlPropertyIndex encodedIndex() const { return encodedIndex(core, valueTypeData); } static QQmlPropertyIndex encodedIndex(const QQmlPropertyData &core, const QQmlPropertyData &valueTypeData) - { return QQmlPropertyIndex(core.coreIndex, valueTypeData.coreIndex); } + { return QQmlPropertyIndex(core.coreIndex(), valueTypeData.coreIndex()); } inline QQmlContextData *effectiveContext() const; diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp index 38fddc8253..af9b8cc045 100644 --- a/src/qml/qml/qqmlpropertycache.cpp +++ b/src/qml/qml/qqmlpropertycache.cpp @@ -145,102 +145,102 @@ QQmlPropertyData::flagsForProperty(const QMetaProperty &p, QQmlEngine *engine) void QQmlPropertyData::lazyLoad(const QMetaProperty &p) { - coreIndex = p.propertyIndex(); - notifyIndex = QMetaObjectPrivate::signalIndex(p.notifySignal()); + setCoreIndex(p.propertyIndex()); + setNotifyIndex(QMetaObjectPrivate::signalIndex(p.notifySignal())); Q_ASSERT(p.revision() <= Q_INT16_MAX); - revision = p.revision(); + setRevision(p.revision()); - flags = fastFlagsForProperty(p); + _flags = fastFlagsForProperty(p); int type = static_cast<int>(p.type()); if (type == QMetaType::QObjectStar) { - propType = type; - flags.type = Flags::QObjectDerivedType; + setPropType(type); + _flags.type = Flags::QObjectDerivedType; } else if (type == QMetaType::QVariant) { - propType = type; - flags.type = Flags::QVariantType; + setPropType(type); + _flags.type = Flags::QVariantType; } else if (type == QVariant::UserType || type == -1) { - propTypeName = p.typeName(); - flags.notFullyResolved = true; + _flags.notFullyResolved = true; + setPropTypeName(p.typeName()); } else { - propType = type; + setPropType(type); } } void QQmlPropertyData::load(const QMetaProperty &p, QQmlEngine *engine) { - propType = p.userType(); - coreIndex = p.propertyIndex(); - notifyIndex = QMetaObjectPrivate::signalIndex(p.notifySignal()); - flags = fastFlagsForProperty(p); - flagsForPropertyType(propType, engine, flags); + setPropType(p.userType()); + setCoreIndex(p.propertyIndex()); + setNotifyIndex(QMetaObjectPrivate::signalIndex(p.notifySignal())); + _flags = fastFlagsForProperty(p); + flagsForPropertyType(propType(), engine, _flags); Q_ASSERT(p.revision() <= Q_INT16_MAX); - revision = p.revision(); + setRevision(p.revision()); } void QQmlPropertyData::load(const QMetaMethod &m) { - coreIndex = m.methodIndex(); - arguments = 0; + setCoreIndex(m.methodIndex()); + setArguments(nullptr); - propType = m.returnType(); + setPropType(m.returnType()); - flags.type = Flags::FunctionType; + _flags.type = Flags::FunctionType; if (m.methodType() == QMetaMethod::Signal) - flags.isSignal = true; + _flags.isSignal = true; else if (m.methodType() == QMetaMethod::Constructor) { - flags.isConstructor = true; - propType = QMetaType::QObjectStar; + _flags.isConstructor = true; + setPropType(QMetaType::QObjectStar); } if (m.parameterCount()) { - flags.hasArguments = true; - if ((m.parameterCount() == 1) && (m.parameterTypes().constFirst() == "QQmlV4Function*")) { - flags.isV4Function = true; + _flags.hasArguments = true; + if ((m.parameterCount() == 1) && (m.parameterTypes().first() == "QQmlV4Function*")) { + _flags.isV4Function = true; } } if (m.attributes() & QMetaMethod::Cloned) - flags.isCloned = true; + _flags.isCloned = true; Q_ASSERT(m.revision() <= Q_INT16_MAX); - revision = m.revision(); + setRevision(m.revision()); } void QQmlPropertyData::lazyLoad(const QMetaMethod &m) { - coreIndex = m.methodIndex(); - propType = QMetaType::Void; - arguments = 0; - flags.type = Flags::FunctionType; + setCoreIndex(m.methodIndex()); + setPropType(QMetaType::Void); + setArguments(nullptr); + _flags.type = Flags::FunctionType; if (m.methodType() == QMetaMethod::Signal) - flags.isSignal = true; + _flags.isSignal = true; else if (m.methodType() == QMetaMethod::Constructor) { - flags.isConstructor = true; - propType = QMetaType::QObjectStar; + _flags.isConstructor = true; + setPropType(QMetaType::QObjectStar); } const char *returnType = m.typeName(); if (!returnType) returnType = "\0"; if ((*returnType != 'v') || (qstrcmp(returnType+1, "oid") != 0)) { - propTypeName = returnType; - flags.notFullyResolved = true; + setPropTypeName(returnType); + _flags.notFullyResolved = true; } const int paramCount = m.parameterCount(); if (paramCount) { - flags.hasArguments = true; - if ((paramCount == 1) && (m.parameterTypes().constFirst() == "QQmlV4Function*")) { - flags.isV4Function = true; + _flags.hasArguments = true; + if ((paramCount == 1) && (m.parameterTypes().first() == "QQmlV4Function*")) { + _flags.isV4Function = true; } } if (m.attributes() & QMetaMethod::Cloned) - flags.isCloned = true; + _flags.isCloned = true; Q_ASSERT(m.revision() <= Q_INT16_MAX); - revision = m.revision(); + setRevision(m.revision()); } /*! @@ -343,10 +343,10 @@ void QQmlPropertyCache::appendProperty(const QString &name, QQmlPropertyData::Fl int coreIndex, int propType, int notifyIndex) { QQmlPropertyData data; - data.propType = propType; - data.coreIndex = coreIndex; - data.notifyIndex = notifyIndex; - data.flags = flags; + data.setPropType(propType); + data.setCoreIndex(coreIndex); + data.setNotifyIndex(notifyIndex); + data._flags = flags; QQmlPropertyData *old = findNamedProperty(name); if (old) @@ -363,20 +363,20 @@ void QQmlPropertyCache::appendSignal(const QString &name, QQmlPropertyData::Flag const QList<QByteArray> &names) { QQmlPropertyData data; - data.propType = QVariant::Invalid; - data.coreIndex = coreIndex; - data.flags = flags; - data.arguments = 0; + data.setPropType(QVariant::Invalid); + data.setCoreIndex(coreIndex); + data._flags = flags; + data.setArguments(nullptr); QQmlPropertyData handler = data; - handler.flags.isSignalHandler = true; + handler._flags.isSignalHandler = true; if (types) { int argumentCount = *types; QQmlPropertyCacheMethodArguments *args = createArgumentsObject(argumentCount, names); ::memcpy(args->arguments, types, (argumentCount + 1) * sizeof(int)); args->argumentsValid = true; - data.arguments = args; + data.setArguments(args); } QQmlPropertyData *old = findNamedProperty(name); @@ -402,16 +402,16 @@ void QQmlPropertyCache::appendMethod(const QString &name, QQmlPropertyData::Flag int argumentCount = names.count(); QQmlPropertyData data; - data.propType = QMetaType::QVariant; - data.coreIndex = coreIndex; + data.setPropType(QMetaType::QVariant); + data.setCoreIndex(coreIndex); QQmlPropertyCacheMethodArguments *args = createArgumentsObject(argumentCount, names); for (int ii = 0; ii < argumentCount; ++ii) args->arguments[ii + 1] = QMetaType::QVariant; args->argumentsValid = true; - data.arguments = args; + data.setArguments(args); - data.flags = flags; + data._flags = flags; QQmlPropertyData *old = findNamedProperty(name); if (old) @@ -570,20 +570,20 @@ void QQmlPropertyCache::append(const QMetaObject *metaObject, QQmlPropertyData *sigdata = 0; if (m.methodType() == QMetaMethod::Signal) - data->flags = signalFlags; + data->_flags = signalFlags; else - data->flags = methodFlags; + data->_flags = methodFlags; data->lazyLoad(m); - data->flags.isDirect = !dynamicMetaObject; + data->_flags.isDirect = !dynamicMetaObject; Q_ASSERT((allowedRevisionCache.count() - 1) < Q_INT16_MAX); - data->metaObjectOffset = allowedRevisionCache.count() - 1; + data->setMetaObjectOffset(allowedRevisionCache.count() - 1); if (data->isSignal()) { sigdata = &signalHandlerIndexCache[signalHandlerIndex - signalHandlerIndexCacheStart]; *sigdata = *data; - sigdata->flags.isSignalHandler = true; + sigdata->_flags.isSignalHandler = true; } QQmlPropertyData *old = 0; @@ -624,8 +624,8 @@ void QQmlPropertyCache::append(const QMetaObject *metaObject, if (old) { // We only overload methods in the same class, exactly like C++ - if (old->isFunction() && old->coreIndex >= methodOffset) - data->flags.isOverload = true; + if (old->isFunction() && old->coreIndex() >= methodOffset) + data->_flags.isOverload = true; data->markAsOverrideOf(old); } @@ -652,13 +652,13 @@ void QQmlPropertyCache::append(const QMetaObject *metaObject, QQmlPropertyData *data = &propertyIndexCache[ii - propertyIndexCacheStart]; - data->flags = propertyFlags; + data->_flags = propertyFlags; data->lazyLoad(p); - data->flags.isDirect = !dynamicMetaObject; + data->_flags.isDirect = !dynamicMetaObject; Q_ASSERT((allowedRevisionCache.count() - 1) < Q_INT16_MAX); - data->metaObjectOffset = allowedRevisionCache.count() - 1; + data->setMetaObjectOffset(allowedRevisionCache.count() - 1); QQmlPropertyData *old = 0; @@ -677,11 +677,11 @@ void QQmlPropertyCache::append(const QMetaObject *metaObject, QQmlAccessorProperties::Property *accessorProperty = accessorProperties.property(str); // Fast properties may not be overrides or revisioned - Q_ASSERT(accessorProperty == 0 || (old == 0 && data->revision == 0)); + Q_ASSERT(accessorProperty == 0 || (old == 0 && data->revision() == 0)); if (accessorProperty) { - data->flags.hasAccessors = true; - data->accessors = accessorProperty->accessors; + data->_flags.hasAccessors = true; + data->setAccessors(accessorProperty->accessors); } else if (old) { data->markAsOverrideOf(old); } @@ -692,10 +692,11 @@ void QQmlPropertyCache::resolve(QQmlPropertyData *data) const { Q_ASSERT(data->notFullyResolved()); - data->propType = QMetaType::type(data->propTypeName); + data->setPropType(QMetaType::type(data->propTypeName())); + data->_flags.notFullyResolved = false; if (!data->isFunction()) { - if (data->propType == QMetaType::UnknownType) { + if (data->propType() == QMetaType::UnknownType) { const QMetaObject *mo = _metaObject; QQmlPropertyCache *p = _parent; while (p && (!mo || _ownMetaObject)) { @@ -704,22 +705,20 @@ void QQmlPropertyCache::resolve(QQmlPropertyData *data) const } int propOffset = mo->propertyOffset(); - if (mo && data->coreIndex < propOffset + mo->propertyCount()) { - while (data->coreIndex < propOffset) { + if (mo && data->coreIndex() < propOffset + mo->propertyCount()) { + while (data->coreIndex() < propOffset) { mo = mo->superClass(); propOffset = mo->propertyOffset(); } int registerResult = -1; void *argv[] = { ®isterResult }; - mo->static_metacall(QMetaObject::RegisterPropertyMetaType, data->coreIndex - propOffset, argv); - data->propType = registerResult == -1 ? QMetaType::UnknownType : registerResult; + mo->static_metacall(QMetaObject::RegisterPropertyMetaType, data->coreIndex() - propOffset, argv); + data->setPropType(registerResult == -1 ? QMetaType::UnknownType : registerResult); } } - flagsForPropertyType(data->propType, engine->qmlEngine(), data->flags); + flagsForPropertyType(data->propType(), engine->qmlEngine(), data->_flags); } - - data->flags.notFullyResolved = false; } void QQmlPropertyCache::updateRecur(const QMetaObject *metaObject) @@ -873,25 +872,25 @@ QString QQmlPropertyData::name(QObject *object) const QString QQmlPropertyData::name(const QMetaObject *metaObject) const { - if (!metaObject || coreIndex == -1) + if (!metaObject || coreIndex() == -1) return QString(); if (isFunction()) { - QMetaMethod m = metaObject->method(coreIndex); + QMetaMethod m = metaObject->method(coreIndex()); return QString::fromUtf8(m.name().constData()); } else { - QMetaProperty p = metaObject->property(coreIndex); + QMetaProperty p = metaObject->property(coreIndex()); return QString::fromUtf8(p.name()); } } void QQmlPropertyData::markAsOverrideOf(QQmlPropertyData *predecessor) { - overrideIndexIsProperty = !predecessor->isFunction(); - overrideIndex = predecessor->coreIndex; + setOverrideIndexIsProperty(!predecessor->isFunction()); + setOverrideIndex(predecessor->coreIndex()); - predecessor->flags.isOverridden = true; + predecessor->_flags.isOverridden = true; } struct StaticQtMetaObject : public QObject @@ -1124,7 +1123,7 @@ void QQmlPropertyCache::toMetaObjectBuilder(QMetaObjectBuilder &builder) { struct Sort { static bool lt(const QPair<QString, QQmlPropertyData *> &lhs, const QPair<QString, QQmlPropertyData *> &rhs) { - return lhs.second->coreIndex < rhs.second->coreIndex; + return lhs.second->coreIndex() < rhs.second->coreIndex(); } }; struct Insert { static void in(QQmlPropertyCache *This, @@ -1135,7 +1134,7 @@ void QQmlPropertyCache::toMetaObjectBuilder(QMetaObjectBuilder &builder) return; if (data->isFunction()) { - if (data->coreIndex < This->methodIndexCacheStart) + if (data->coreIndex() < This->methodIndexCacheStart) return; QPair<QString, QQmlPropertyData *> entry = qMakePair((QString)iter.key(), data); @@ -1145,7 +1144,7 @@ void QQmlPropertyCache::toMetaObjectBuilder(QMetaObjectBuilder &builder) data = This->overrideData(data); if (data && !data->isFunction()) Insert::in(This, properties, methods, iter, data); } else { - if (data->coreIndex < This->propertyIndexCacheStart) + if (data->coreIndex() < This->propertyIndexCacheStart) return; QPair<QString, QQmlPropertyData *> entry = qMakePair((QString)iter.key(), data); @@ -1176,11 +1175,11 @@ void QQmlPropertyCache::toMetaObjectBuilder(QMetaObjectBuilder &builder) QQmlPropertyData *data = properties.at(ii).second; int notifierId = -1; - if (data->notifyIndex != -1) - notifierId = data->notifyIndex - signalHandlerIndexCacheStart; + if (data->notifyIndex() != -1) + notifierId = data->notifyIndex() - signalHandlerIndexCacheStart; QMetaPropertyBuilder property = builder.addProperty(properties.at(ii).first.toUtf8(), - QMetaType::typeName(data->propType), + QMetaType::typeName(data->propType()), notifierId); property.setReadable(true); @@ -1192,8 +1191,8 @@ void QQmlPropertyCache::toMetaObjectBuilder(QMetaObjectBuilder &builder) QQmlPropertyData *data = methods.at(ii).second; QByteArray returnType; - if (data->propType != 0) - returnType = QMetaType::typeName(data->propType); + if (data->propType() != 0) + returnType = QMetaType::typeName(data->propType()); QByteArray signature; // '+=' reserves extra capacity. Follow-up appending will be probably free. @@ -1201,7 +1200,7 @@ void QQmlPropertyCache::toMetaObjectBuilder(QMetaObjectBuilder &builder) QQmlPropertyCacheMethodArguments *arguments = 0; if (data->hasArguments()) { - arguments = (QQmlPropertyCacheMethodArguments *)data->arguments; + arguments = (QQmlPropertyCacheMethodArguments *)data->arguments(); Q_ASSERT(arguments->argumentsValid); for (int ii = 0; ii < arguments->arguments[0]; ++ii) { if (ii != 0) signature.append(','); @@ -1228,7 +1227,7 @@ void QQmlPropertyCache::toMetaObjectBuilder(QMetaObjectBuilder &builder) if (!_defaultPropertyName.isEmpty()) { QQmlPropertyData *dp = property(_defaultPropertyName, 0, 0); - if (dp && dp->coreIndex >= propertyIndexCacheStart) { + if (dp && dp->coreIndex() >= propertyIndexCacheStart) { Q_ASSERT(!dp->isFunction()); builder.addClassInfo("DefaultProperty", _defaultPropertyName.toUtf8()); } @@ -1452,7 +1451,7 @@ QList<QByteArray> QQmlPropertyCache::signalParameterNames(int index) const { QQmlPropertyData *signalData = signal(index); if (signalData && signalData->hasArguments()) { - QQmlPropertyCacheMethodArguments *args = (QQmlPropertyCacheMethodArguments *)signalData->arguments; + QQmlPropertyCacheMethodArguments *args = (QQmlPropertyCacheMethodArguments *)signalData->arguments(); if (args && args->names) return *args->names; const QMetaMethod &method = QMetaObjectPrivate::signal(firstCppMetaObject(), index); @@ -1554,9 +1553,9 @@ QQmlPropertyCache *QQmlMetaObject::propertyCache(QQmlEnginePrivate *e) const int QQmlMetaObject::methodReturnType(const QQmlPropertyData &data, QByteArray *unknownTypeError) const { - Q_ASSERT(!_m.isNull() && data.coreIndex >= 0); + Q_ASSERT(!_m.isNull() && data.coreIndex() >= 0); - int type = data.propType; + int type = data.propType(); const char *propTypeName = 0; @@ -1566,16 +1565,16 @@ int QQmlMetaObject::methodReturnType(const QQmlPropertyData &data, QByteArray *u if (_m.isT1()) { QQmlPropertyCache *c = _m.asT1(); - Q_ASSERT(data.coreIndex < c->methodIndexCacheStart + c->methodIndexCache.count()); + Q_ASSERT(data.coreIndex() < c->methodIndexCacheStart + c->methodIndexCache.count()); - while (data.coreIndex < c->methodIndexCacheStart) + while (data.coreIndex() < c->methodIndexCacheStart) c = c->_parent; const QMetaObject *metaObject = c->createMetaObject(); Q_ASSERT(metaObject); - m = metaObject->method(data.coreIndex); + m = metaObject->method(data.coreIndex()); } else { - m = _m.asT2()->method(data.coreIndex); + m = _m.asT2()->method(data.coreIndex()); } type = m.returnType(); @@ -1615,19 +1614,19 @@ int *QQmlMetaObject::methodParameterTypes(int index, ArgTypeStorage *argStorage, QQmlPropertyData *rv = const_cast<QQmlPropertyData *>(&c->methodIndexCache.at(index - c->methodIndexCacheStart)); - if (rv->arguments && static_cast<A *>(rv->arguments)->argumentsValid) - return static_cast<A *>(rv->arguments)->arguments; + if (rv->arguments() && static_cast<A *>(rv->arguments())->argumentsValid) + return static_cast<A *>(rv->arguments())->arguments; const QMetaObject *metaObject = c->createMetaObject(); Q_ASSERT(metaObject); QMetaMethod m = metaObject->method(index); int argc = m.parameterCount(); - if (!rv->arguments) { + if (!rv->arguments()) { A *args = c->createArgumentsObject(argc, m.parameterNames()); - rv->arguments = args; + rv->setArguments(args); } - A *args = static_cast<A *>(rv->arguments); + A *args = static_cast<A *>(rv->arguments()); QList<QByteArray> argTypeNames; // Only loaded if needed @@ -1651,7 +1650,7 @@ int *QQmlMetaObject::methodParameterTypes(int index, ArgTypeStorage *argStorage, args->arguments[ii + 1] = type; } args->argumentsValid = true; - return static_cast<A *>(rv->arguments)->arguments; + return static_cast<A *>(rv->arguments())->arguments; } else { QMetaMethod m = _m.asT2()->method(index); diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h index cc3ad62706..79fd77dd45 100644 --- a/src/qml/qml/qqmlpropertycache_p.h +++ b/src/qml/qml/qqmlpropertycache_p.h @@ -64,6 +64,8 @@ #include <private/qv4value_p.h> #include <private/qqmlaccessors_p.h> +#include <limits> + QT_BEGIN_NAMESPACE class QCryptographicHash; @@ -131,77 +133,123 @@ public: inline void copyPropertyTypeFlags(Flags from); }; - Flags getFlags() const { return 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; } - void setWritable(bool onoff) { flags.isWritable = onoff; } - bool isResettable() const { return flags.isResettable; } - bool isAlias() const { return flags.isAlias; } - bool isFinal() const { return flags.isFinal; } - bool isOverridden() const { return flags.isOverridden; } - bool isDirect() const { return flags.isDirect; } - bool hasAccessors() const { return flags.hasAccessors; } - bool isFunction() const { return flags.type == Flags::FunctionType; } - bool isQObject() const { return flags.type == Flags::QObjectDerivedType; } - bool isEnum() const { return flags.type == Flags::EnumType; } - bool isQList() const { return flags.type == Flags::QListType; } - bool isQmlBinding() const { return flags.type == Flags::QmlBindingType; } - bool isQJSValue() const { return flags.type == Flags::QJSValueType; } - bool isV4Handle() const { return flags.type == Flags::V4HandleType; } - bool isVarProperty() const { return flags.type == Flags::VarPropertyType; } - bool isQVariant() const { return flags.type == Flags::QVariantType; } - 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 isV4Function() const { return flags.isV4Function; } - bool isSignalHandler() const { return flags.isSignalHandler; } - bool isOverload() const { return flags.isOverload; } - void setOverload(bool onoff) { flags.isOverload = onoff; } - bool isCloned() const { return flags.isCloned; } - bool isConstructor() const { return flags.isConstructor; } - - bool hasOverride() const { return !(flags.hasAccessors) && - overrideIndex >= 0; } - bool hasRevision() const { return !(flags.hasAccessors) && revision != 0; } - - bool isFullyResolved() const { return !flags.notFullyResolved; } + Flags flags() const { return _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; } + void setWritable(bool onoff) { _flags.isWritable = onoff; } + bool isResettable() const { return _flags.isResettable; } + bool isAlias() const { return _flags.isAlias; } + bool isFinal() const { return _flags.isFinal; } + bool isOverridden() const { return _flags.isOverridden; } + bool isDirect() const { return _flags.isDirect; } + bool hasAccessors() const { return _flags.hasAccessors; } + bool isFunction() const { return _flags.type == Flags::FunctionType; } + bool isQObject() const { return _flags.type == Flags::QObjectDerivedType; } + bool isEnum() const { return _flags.type == Flags::EnumType; } + bool isQList() const { return _flags.type == Flags::QListType; } + bool isQmlBinding() const { return _flags.type == Flags::QmlBindingType; } + bool isQJSValue() const { return _flags.type == Flags::QJSValueType; } + bool isV4Handle() const { return _flags.type == Flags::V4HandleType; } + bool isVarProperty() const { return _flags.type == Flags::VarPropertyType; } + bool isQVariant() const { return _flags.type == Flags::QVariantType; } + 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 isV4Function() const { return _flags.isV4Function; } + bool isSignalHandler() const { return _flags.isSignalHandler; } + bool isOverload() const { return _flags.isOverload; } + void setOverload(bool onoff) { _flags.isOverload = onoff; } + bool isCloned() const { return _flags.isCloned; } + bool isConstructor() const { return _flags.isConstructor; } + + bool hasOverride() const { return !(_flags.hasAccessors) && + overrideIndex() >= 0; } + bool hasRevision() const { return !(_flags.hasAccessors) && revision() != 0; } + + bool isFullyResolved() const { return !_flags.notFullyResolved; } + + int propType() const { Q_ASSERT(isFullyResolved()); return _propType; } + void setPropType(int pt) { _propType = pt; } + + const char *propTypeName() const { Q_ASSERT(!isFullyResolved()); return _propTypeName; } + void setPropTypeName(const char *ptn) { _propTypeName = ptn; } + + int notifyIndex() const { return _notifyIndex; } + void setNotifyIndex(int idx) { _notifyIndex = idx; } + + QQmlPropertyCacheMethodArguments *arguments() const { return _arguments; } + void setArguments(QQmlPropertyCacheMethodArguments *args) { _arguments = args; } + + int revision() const { return _revision; } + void setRevision(int rev) + { + Q_ASSERT(rev >= std::numeric_limits<qint16>::min()); + Q_ASSERT(rev <= std::numeric_limits<qint16>::max()); + _revision = qint16(rev); + } + + int metaObjectOffset() const { return _metaObjectOffset; } + void setMetaObjectOffset(int off) + { + Q_ASSERT(off >= std::numeric_limits<qint16>::min()); + Q_ASSERT(off <= std::numeric_limits<qint16>::max()); + _metaObjectOffset = qint16(off); + } + bool overrideIndexIsProperty() const { return _overrideIndexIsProperty; } + void setOverrideIndexIsProperty(bool onoff) { _overrideIndexIsProperty = onoff; } + + int overrideIndex() const { return _overrideIndex; } + void setOverrideIndex(int idx) + { + Q_ASSERT(idx >= std::numeric_limits<qint16>::min()); + Q_ASSERT(idx <= std::numeric_limits<qint16>::max()); + _overrideIndex = idx; + } + + QQmlAccessors *accessors() const { return _accessors; } + void setAccessors(QQmlAccessors *acc) { _accessors = acc; } + + int coreIndex() const { return _coreIndex; } + void setCoreIndex(int idx) { _coreIndex = idx; } + +private: union { - int propType; // When !NotFullyResolved - const char *propTypeName; // When NotFullyResolved + int _propType; // When !NotFullyResolved + const char *_propTypeName; // When NotFullyResolved }; union { // The notify index is in the range returned by QObjectPrivate::signalIndex(). // This is different from QMetaMethod::methodIndex(). - int notifyIndex; // When !IsFunction - void *arguments; // When IsFunction && HasArguments + int _notifyIndex; // When !IsFunction + QQmlPropertyCacheMethodArguments *_arguments; // When IsFunction && HasArguments }; union { struct { // When !HasAccessors - qint16 revision; - qint16 metaObjectOffset; + qint16 _revision; + qint16 _metaObjectOffset; struct { // When !IsValueTypeVirtual - uint overrideIndexIsProperty : 1; - signed int overrideIndex : 31; + uint _overrideIndexIsProperty : 1; + signed int _overrideIndex : 31; }; }; struct { // When HasAccessors - QQmlAccessors *accessors; + QQmlAccessors *_accessors; }; }; - int coreIndex; -private: + int _coreIndex; + Flags _flags; + friend class QQmlPropertyData; friend class QQmlPropertyCache; - Flags flags; }; class QQmlPropertyData : public QQmlPropertyRawData @@ -236,20 +284,20 @@ public: inline void readPropertyWithArgs(QObject *target, void *args[]) const { if (hasAccessors()) { - accessors->read(target, args[0]); + accessors()->read(target, args[0]); } else { - QMetaObject::metacall(target, QMetaObject::ReadProperty, coreIndex, args); + QMetaObject::metacall(target, QMetaObject::ReadProperty, coreIndex(), args); } } bool writeProperty(QObject *target, void *value, WriteFlags flags) const { - if (flags.testFlag(BypassInterceptor) && hasAccessors() && accessors->write) { - accessors->write(target, value); + if (flags.testFlag(BypassInterceptor) && hasAccessors() && accessors()->write) { + accessors()->write(target, value); } else { int status = -1; void *argv[] = { value, 0, &status, &flags }; - QMetaObject::metacall(target, QMetaObject::WriteProperty, coreIndex, argv); + QMetaObject::metacall(target, QMetaObject::WriteProperty, coreIndex(), argv); } return true; } @@ -275,7 +323,7 @@ private: friend class QQmlPropertyCache; void lazyLoad(const QMetaProperty &); void lazyLoad(const QMetaMethod &); - bool notFullyResolved() const { return flags.notFullyResolved; } + bool notFullyResolved() const { return _flags.notFullyResolved; } }; class QQmlPropertyCacheMethodArguments; @@ -577,13 +625,13 @@ void QQmlPropertyRawData::Flags::copyPropertyTypeFlags(QQmlPropertyRawData::Flag QQmlPropertyData::QQmlPropertyData() { - propType = 0; - coreIndex = -1; - notifyIndex = -1; - overrideIndexIsProperty = false; - overrideIndex = -1; - revision = 0; - metaObjectOffset = -1; + setPropType(0); + setNotifyIndex(-1); + setOverrideIndexIsProperty(false); + setOverrideIndex(-1); + setRevision(0); + setMetaObjectOffset(-1); + setCoreIndex(-1); } QQmlPropertyData::QQmlPropertyData(const QQmlPropertyRawData &d) @@ -593,11 +641,11 @@ QQmlPropertyData::QQmlPropertyData(const QQmlPropertyRawData &d) bool QQmlPropertyData::operator==(const QQmlPropertyRawData &other) { - return flags == other.flags && - propType == other.propType && - coreIndex == other.coreIndex && - notifyIndex == other.notifyIndex && - revision == other.revision; + return _flags == other._flags && + propType() == other.propType() && + coreIndex() == other.coreIndex() && + notifyIndex() == other.notifyIndex() && + revision() == other.revision(); } inline QQmlPropertyData *QQmlPropertyCache::ensureResolved(QQmlPropertyData *p) const @@ -660,7 +708,7 @@ inline QQmlPropertyData *QQmlPropertyCache::signal(int index) const return _parent->signal(index); QQmlPropertyData *rv = const_cast<QQmlPropertyData *>(&methodIndexCache.at(index - signalHandlerIndexCacheStart)); - Q_ASSERT(rv->isSignal() || rv->coreIndex == -1); + Q_ASSERT(rv->isSignal() || rv->coreIndex() == -1); return ensureResolved(rv); } @@ -692,16 +740,16 @@ QQmlPropertyCache::overrideData(QQmlPropertyData *data) const if (!data->hasOverride()) return 0; - if (data->overrideIndexIsProperty) - return property(data->overrideIndex); + if (data->overrideIndexIsProperty()) + return property(data->overrideIndex()); else - return method(data->overrideIndex); + return method(data->overrideIndex()); } bool QQmlPropertyCache::isAllowedInRevision(QQmlPropertyData *data) const { - return (data->hasAccessors() || (data->metaObjectOffset == -1 && data->revision == 0)) || - (allowedRevisionCache[data->metaObjectOffset] >= data->revision); + return (data->hasAccessors() || (data->metaObjectOffset() == -1 && data->revision() == 0)) || + (allowedRevisionCache[data->metaObjectOffset()] >= data->revision()); } int QQmlPropertyCache::propertyCount() const diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index c4008d2a05..2566ab06b5 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -370,10 +370,10 @@ ReturnedValue QQmlValueTypeWrapper::get(const Managed *m, String *name, bool *ha if (result->isFunction()) // calling a Q_INVOKABLE function of a value type - return QV4::QObjectMethod::create(v4->rootContext(), r, result->coreIndex); + return QV4::QObjectMethod::create(v4->rootContext(), r, result->coreIndex()); #define VALUE_TYPE_LOAD(metatype, cpptype, constructor) \ - if (result->propType == metatype) { \ + if (result->propType() == metatype) { \ cpptype v; \ void *args[] = { &v, 0 }; \ metaObject->d.static_metacall(reinterpret_cast<QObject*>(gadget), QMetaObject::ReadProperty, index, args); \ @@ -382,7 +382,7 @@ ReturnedValue QQmlValueTypeWrapper::get(const Managed *m, String *name, bool *ha const QMetaObject *metaObject = r->d()->propertyCache->metaObject(); - int index = result->coreIndex; + int index = result->coreIndex(); QQmlMetaObject::resolveGadgetMethodOrPropertyIndex(QMetaObject::ReadProperty, &metaObject, &index); void *gadget = r->d()->gadgetPtr; @@ -395,10 +395,10 @@ ReturnedValue QQmlValueTypeWrapper::get(const Managed *m, String *name, bool *ha QVariant v; void *args[] = { Q_NULLPTR, Q_NULLPTR }; - if (result->propType == QMetaType::QVariant) { + if (result->propType() == QMetaType::QVariant) { args[0] = &v; } else { - v = QVariant(result->propType, static_cast<void *>(Q_NULLPTR)); + v = QVariant(result->propType(), static_cast<void *>(Q_NULLPTR)); args[0] = v.data(); } metaObject->d.static_metacall(reinterpret_cast<QObject*>(gadget), QMetaObject::ReadProperty, index, args); @@ -448,8 +448,8 @@ void QQmlValueTypeWrapper::put(Managed *m, String *name, const Value &value) QQmlPropertyData cacheData; cacheData.setWritable(true); - cacheData.propType = writeBackPropertyType; - cacheData.coreIndex = reference->d()->property; + cacheData.setPropType(writeBackPropertyType); + cacheData.setCoreIndex(reference->d()->property); QV4::Scoped<QQmlBindingFunction> bindingFunction(scope, (const Value &)f); bindingFunction->initBindingLocation(); @@ -459,11 +459,11 @@ void QQmlValueTypeWrapper::put(Managed *m, String *name, const Value &value) QQmlPropertyPrivate::setBinding(newBinding); return; } else { - QQmlPropertyPrivate::removeBinding(reference->d()->object, QQmlPropertyIndex(reference->d()->property, pd->coreIndex)); + QQmlPropertyPrivate::removeBinding(reference->d()->object, QQmlPropertyIndex(reference->d()->property, pd->coreIndex())); } } - QMetaProperty property = metaObject->property(pd->coreIndex); + QMetaProperty property = metaObject->property(pd->coreIndex()); Q_ASSERT(property.isValid()); QVariant v = v4->toVariant(value, property.userType()); diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp index 47c125355b..c8281f02c0 100644 --- a/src/qml/qml/qqmlvmemetaobject.cpp +++ b/src/qml/qml/qqmlvmemetaobject.cpp @@ -164,8 +164,8 @@ void QQmlVMEMetaObjectEndpoint::tryConnect() if (!pd) return; - if (pd->notifyIndex != -1) - connect(target, pd->notifyIndex, ctxt->engine); + if (pd->notifyIndex() != -1) + connect(target, pd->notifyIndex(), ctxt->engine); } metaObject.setFlag(); @@ -225,7 +225,7 @@ bool QQmlInterceptorMetaObject::intercept(QMetaObject::Call c, int id, void **a) continue; const int valueIndex = vi->m_propertyIndex.valueTypeIndex(); - int type = QQmlData::get(object)->propertyCache->property(id)->propType; + int type = QQmlData::get(object)->propertyCache->property(id)->propType(); if (type != QVariant::Invalid) { if (valueIndex != -1) { @@ -883,7 +883,7 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void * return -1; const QQmlPropertyData *pd = targetDData->propertyCache->property(coreIndex); // Value type property - QQmlValueType *valueType = QQmlValueTypeFactory::valueType(pd->propType); + QQmlValueType *valueType = QQmlValueTypeFactory::valueType(pd->propType()); Q_ASSERT(valueType); valueType->read(target, coreIndex); diff --git a/src/quick/items/qquickopenglshadereffect.cpp b/src/quick/items/qquickopenglshadereffect.cpp index 9d24a6c511..b974641cca 100644 --- a/src/quick/items/qquickopenglshadereffect.cpp +++ b/src/quick/items/qquickopenglshadereffect.cpp @@ -252,11 +252,11 @@ void QQuickOpenGLShaderEffectCommon::connectPropertySignals(QQuickItem *item, const UniformData &d = uniformData[shaderType].at(i); QQmlPropertyData *pd = propCache->property(QString::fromUtf8(d.name), nullptr, nullptr); if (pd && !pd->isFunction()) { - if (pd->notifyIndex == -1) { + if (pd->notifyIndex() == -1) { qWarning("QQuickOpenGLShaderEffect: property '%s' does not have notification method!", d.name.constData()); } else { auto *mapper = signalMappers[shaderType].at(i); - mapper->setSignalIndex(pd->notifyIndex); + mapper->setSignalIndex(pd->notifyIndex()); Q_ASSERT(item->metaObject() == itemMetaObject); QObjectPrivate::connectImpl(item, mapper->signalIndex(), item, nullptr, mapper, Qt::AutoConnection, nullptr, itemMetaObject); @@ -347,7 +347,7 @@ void QQuickOpenGLShaderEffectCommon::lookThroughShaderCode(QQuickItem *item, } else { if (QQmlPropertyData *pd = propCache->property(QString::fromUtf8(d.name), nullptr, nullptr)) { if (!pd->isFunction()) - d.propertyIndex = pd->coreIndex; + d.propertyIndex = pd->coreIndex(); } const int mappedId = uniformData[shaderType].size() | (shaderType << 16); mapper = new QtPrivate::MappedSlotObject([this, mappedId](){ diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 8a60b04494..ad06946b0b 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -4128,7 +4128,7 @@ void tst_qqmllanguage::preservePropertyCacheOnGroupObjects() QVERIFY(subCache); QQmlPropertyData *pd = subCache->property(QStringLiteral("newProperty"), /*object*/0, /*context*/0); QVERIFY(pd); - QCOMPARE(pd->propType, qMetaTypeId<int>()); + QCOMPARE(pd->propType(), qMetaTypeId<int>()); } void tst_qqmllanguage::propertyCacheInSync() diff --git a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp index 2916d8455c..824fe445c0 100644 --- a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp +++ b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp @@ -111,16 +111,16 @@ void tst_qqmlpropertycache::properties() QQmlPropertyData *data; QVERIFY((data = cacheProperty(cache, "propertyA"))); - QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyA")); + QCOMPARE(data->coreIndex(), metaObject->indexOfProperty("propertyA")); QVERIFY((data = cacheProperty(cache, "propertyB"))); - QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyB")); + QCOMPARE(data->coreIndex(), metaObject->indexOfProperty("propertyB")); QVERIFY((data = cacheProperty(cache, "propertyC"))); - QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyC")); + QCOMPARE(data->coreIndex(), metaObject->indexOfProperty("propertyC")); QVERIFY((data = cacheProperty(cache, "propertyD"))); - QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyD")); + QCOMPARE(data->coreIndex(), metaObject->indexOfProperty("propertyD")); } void tst_qqmlpropertycache::propertiesDerived() @@ -135,16 +135,16 @@ void tst_qqmlpropertycache::propertiesDerived() QQmlPropertyData *data; QVERIFY((data = cacheProperty(cache, "propertyA"))); - QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyA")); + QCOMPARE(data->coreIndex(), metaObject->indexOfProperty("propertyA")); QVERIFY((data = cacheProperty(cache, "propertyB"))); - QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyB")); + QCOMPARE(data->coreIndex(), metaObject->indexOfProperty("propertyB")); QVERIFY((data = cacheProperty(cache, "propertyC"))); - QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyC")); + QCOMPARE(data->coreIndex(), metaObject->indexOfProperty("propertyC")); QVERIFY((data = cacheProperty(cache, "propertyD"))); - QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyD")); + QCOMPARE(data->coreIndex(), metaObject->indexOfProperty("propertyD")); } void tst_qqmlpropertycache::methods() @@ -158,28 +158,28 @@ void tst_qqmlpropertycache::methods() QQmlPropertyData *data; QVERIFY((data = cacheProperty(cache, "slotA"))); - QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotA()")); + QCOMPARE(data->coreIndex(), metaObject->indexOfMethod("slotA()")); QVERIFY((data = cacheProperty(cache, "slotB"))); - QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotB()")); + QCOMPARE(data->coreIndex(), metaObject->indexOfMethod("slotB()")); QVERIFY((data = cacheProperty(cache, "signalA"))); - QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()")); + QCOMPARE(data->coreIndex(), metaObject->indexOfMethod("signalA()")); QVERIFY((data = cacheProperty(cache, "signalB"))); - QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()")); + QCOMPARE(data->coreIndex(), metaObject->indexOfMethod("signalB()")); QVERIFY((data = cacheProperty(cache, "propertyAChanged"))); - QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()")); + QCOMPARE(data->coreIndex(), metaObject->indexOfMethod("propertyAChanged()")); QVERIFY((data = cacheProperty(cache, "propertyBChanged"))); - QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()")); + QCOMPARE(data->coreIndex(), metaObject->indexOfMethod("propertyBChanged()")); QVERIFY((data = cacheProperty(cache, "propertyCChanged"))); - QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()")); + QCOMPARE(data->coreIndex(), metaObject->indexOfMethod("propertyCChanged()")); QVERIFY((data = cacheProperty(cache, "propertyDChanged"))); - QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()")); + QCOMPARE(data->coreIndex(), metaObject->indexOfMethod("propertyDChanged()")); } void tst_qqmlpropertycache::methodsDerived() @@ -194,28 +194,28 @@ void tst_qqmlpropertycache::methodsDerived() QQmlPropertyData *data; QVERIFY((data = cacheProperty(cache, "slotA"))); - QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotA()")); + QCOMPARE(data->coreIndex(), metaObject->indexOfMethod("slotA()")); QVERIFY((data = cacheProperty(cache, "slotB"))); - QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotB()")); + QCOMPARE(data->coreIndex(), metaObject->indexOfMethod("slotB()")); QVERIFY((data = cacheProperty(cache, "signalA"))); - QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()")); + QCOMPARE(data->coreIndex(), metaObject->indexOfMethod("signalA()")); QVERIFY((data = cacheProperty(cache, "signalB"))); - QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()")); + QCOMPARE(data->coreIndex(), metaObject->indexOfMethod("signalB()")); QVERIFY((data = cacheProperty(cache, "propertyAChanged"))); - QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()")); + QCOMPARE(data->coreIndex(), metaObject->indexOfMethod("propertyAChanged()")); QVERIFY((data = cacheProperty(cache, "propertyBChanged"))); - QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()")); + QCOMPARE(data->coreIndex(), metaObject->indexOfMethod("propertyBChanged()")); QVERIFY((data = cacheProperty(cache, "propertyCChanged"))); - QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()")); + QCOMPARE(data->coreIndex(), metaObject->indexOfMethod("propertyCChanged()")); QVERIFY((data = cacheProperty(cache, "propertyDChanged"))); - QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()")); + QCOMPARE(data->coreIndex(), metaObject->indexOfMethod("propertyDChanged()")); } void tst_qqmlpropertycache::signalHandlers() @@ -229,22 +229,22 @@ void tst_qqmlpropertycache::signalHandlers() QQmlPropertyData *data; QVERIFY((data = cacheProperty(cache, "onSignalA"))); - QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()")); + QCOMPARE(data->coreIndex(), metaObject->indexOfMethod("signalA()")); QVERIFY((data = cacheProperty(cache, "onSignalB"))); - QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()")); + QCOMPARE(data->coreIndex(), metaObject->indexOfMethod("signalB()")); QVERIFY((data = cacheProperty(cache, "onPropertyAChanged"))); - QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()")); + QCOMPARE(data->coreIndex(), metaObject->indexOfMethod("propertyAChanged()")); QVERIFY((data = cacheProperty(cache, "onPropertyBChanged"))); - QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()")); + QCOMPARE(data->coreIndex(), metaObject->indexOfMethod("propertyBChanged()")); QVERIFY((data = cacheProperty(cache, "onPropertyCChanged"))); - QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()")); + QCOMPARE(data->coreIndex(), metaObject->indexOfMethod("propertyCChanged()")); QVERIFY((data = cacheProperty(cache, "onPropertyDChanged"))); - QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()")); + QCOMPARE(data->coreIndex(), metaObject->indexOfMethod("propertyDChanged()")); } void tst_qqmlpropertycache::signalHandlersDerived() @@ -259,22 +259,22 @@ void tst_qqmlpropertycache::signalHandlersDerived() QQmlPropertyData *data; QVERIFY((data = cacheProperty(cache, "onSignalA"))); - QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()")); + QCOMPARE(data->coreIndex(), metaObject->indexOfMethod("signalA()")); QVERIFY((data = cacheProperty(cache, "onSignalB"))); - QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()")); + QCOMPARE(data->coreIndex(), metaObject->indexOfMethod("signalB()")); QVERIFY((data = cacheProperty(cache, "onPropertyAChanged"))); - QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()")); + QCOMPARE(data->coreIndex(), metaObject->indexOfMethod("propertyAChanged()")); QVERIFY((data = cacheProperty(cache, "onPropertyBChanged"))); - QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()")); + QCOMPARE(data->coreIndex(), metaObject->indexOfMethod("propertyBChanged()")); QVERIFY((data = cacheProperty(cache, "onPropertyCChanged"))); - QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()")); + QCOMPARE(data->coreIndex(), metaObject->indexOfMethod("propertyCChanged()")); QVERIFY((data = cacheProperty(cache, "onPropertyDChanged"))); - QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()")); + QCOMPARE(data->coreIndex(), metaObject->indexOfMethod("propertyDChanged()")); } class TestClass : public QObject |