diff options
author | Erik Verbruggen <erik.verbruggen@qt.io> | 2016-08-04 12:27:02 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2016-08-05 07:51:51 +0000 |
commit | edb1c204c3bc9ad01ccf7a8abb0e8a02fd89ed72 (patch) | |
tree | 0531a08e8a6df7af2a49b794852eb3023e82634f /src/qml/compiler/qqmlpropertycachecreator_p.h | |
parent | 48deab9b69afc8d613e2b22dacd138be7c8c51a8 (diff) |
QML: Change the property data flags into a bit field
This will make it easier in follow-up patches to add or remove flags. It
also shrinks the flags, because each type doesn't need its own bit (as
those are mutually exclusive).
Change-Id: I5ba6de5f330eb20c82aa16b4467ed6c952725979
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qqmlpropertycachecreator_p.h')
-rw-r--r-- | src/qml/compiler/qqmlpropertycachecreator_p.h | 57 |
1 files changed, 25 insertions, 32 deletions
diff --git a/src/qml/compiler/qqmlpropertycachecreator_p.h b/src/qml/compiler/qqmlpropertycachecreator_p.h index fe10085829..557a1364f1 100644 --- a/src/qml/compiler/qqmlpropertycachecreator_p.h +++ b/src/qml/compiler/qqmlpropertycachecreator_p.h @@ -341,8 +341,7 @@ inline QQmlCompileError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObj // Set up notify signals for properties - first normal, then alias for (auto p = obj->propertiesBegin(), end = obj->propertiesEnd(); p != end; ++p) { - quint32 flags = QQmlPropertyData::IsSignal | QQmlPropertyData::IsFunction | - QQmlPropertyData::IsVMESignal; + auto flags = QQmlPropertyData::defaultSignalFlags(); QString changedSigName = stringAt(p->nameIndex) + QLatin1String("Changed"); seenSignals.insert(changedSigName); @@ -351,8 +350,7 @@ inline QQmlCompileError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObj } for (auto a = obj->aliasesBegin(), end = obj->aliasesEnd(); a != end; ++a) { - quint32 flags = QQmlPropertyData::IsSignal | QQmlPropertyData::IsFunction | - QQmlPropertyData::IsVMESignal; + auto flags = QQmlPropertyData::defaultSignalFlags(); QString changedSigName = stringAt(a->nameIndex) + QLatin1String("Changed"); seenSignals.insert(changedSigName); @@ -402,10 +400,9 @@ inline QQmlCompileError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObj } } - quint32 flags = QQmlPropertyData::IsSignal | QQmlPropertyData::IsFunction | - QQmlPropertyData::IsVMESignal; + auto flags = QQmlPropertyData::defaultSignalFlags(); if (paramCount) - flags |= QQmlPropertyData::HasArguments; + flags.hasArguments = true; QString signalName = stringAt(s->nameIndex); if (seenSignals.contains(signalName)) @@ -419,7 +416,7 @@ inline QQmlCompileError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObj // Dynamic slots for (auto function = objectContainer->objectFunctionsBegin(obj), end = objectContainer->objectFunctionsEnd(obj); function != end; ++function) { - quint32 flags = QQmlPropertyData::IsFunction | QQmlPropertyData::IsVMEFunction; + auto flags = QQmlPropertyData::defaultSlotFlags(); const QString slotName = stringAt(function->nameIndex); if (seenSignals.contains(slotName)) @@ -429,7 +426,7 @@ inline QQmlCompileError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObj QList<QByteArray> parameterNames; for (auto formal = function->formalsBegin(), end = function->formalsEnd(); formal != end; ++formal) { - flags |= QQmlPropertyData::HasArguments; + flags.hasArguments = true; parameterNames << stringAt(*formal).toUtf8(); } @@ -442,16 +439,16 @@ inline QQmlCompileError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObj int propertyIdx = 0; for (auto p = obj->propertiesBegin(), end = obj->propertiesEnd(); p != end; ++p, ++propertyIdx) { int propertyType = 0; - quint32 propertyFlags = 0; + QQmlPropertyData::Flags propertyFlags; if (p->type == QV4::CompiledData::Property::Var) { propertyType = QMetaType::QVariant; - propertyFlags = QQmlPropertyData::IsVarProperty; + propertyFlags.type = QQmlPropertyData::Flags::VarPropertyType; } else if (p->type < builtinTypeCount) { propertyType = builtinTypes[p->type].metaType; if (p->type == QV4::CompiledData::Property::Variant) - propertyFlags |= QQmlPropertyData::IsQVariant; + propertyFlags.type = QQmlPropertyData::Flags::QVariantType; } else { Q_ASSERT(p->type == QV4::CompiledData::Property::CustomList || p->type == QV4::CompiledData::Property::Custom); @@ -485,13 +482,13 @@ inline QQmlCompileError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObj } if (p->type == QV4::CompiledData::Property::Custom) - propertyFlags |= QQmlPropertyData::IsQObjectDerived; + propertyFlags.type = QQmlPropertyData::Flags::QObjectDerivedType; else - propertyFlags |= QQmlPropertyData::IsQList; + propertyFlags.type = QQmlPropertyData::Flags::QListType; } if (!(p->flags & QV4::CompiledData::Property::IsReadOnly) && p->type != QV4::CompiledData::Property::CustomList) - propertyFlags |= QQmlPropertyData::IsWritable; + propertyFlags.isWritable = true; QString propertyName = stringAt(p->nameIndex); @@ -521,7 +518,7 @@ public: private: void appendAliasPropertiesInMetaObjectsWithinComponent(const CompiledObject &component, int firstObjectIndex); - void propertyDataForAlias(const CompiledObject &component, const QV4::CompiledData::Alias &alias, int *type, quint32 *propertyFlags); + void propertyDataForAlias(const CompiledObject &component, const QV4::CompiledData::Alias &alias, int *type, QQmlPropertyRawData::Flags *propertyFlags); void collectObjectsWithAliasesRecursively(int objectIndex, QVector<int> *objectsWithAliases) const; @@ -623,7 +620,9 @@ inline void QQmlPropertyCacheAliasCreator<ObjectContainer>::collectObjectsWithAl } template <typename ObjectContainer> -inline void QQmlPropertyCacheAliasCreator<ObjectContainer>::propertyDataForAlias(const CompiledObject &component, const QV4::CompiledData::Alias &alias, int *type, quint32 *propertyFlags) +inline void QQmlPropertyCacheAliasCreator<ObjectContainer>::propertyDataForAlias( + const CompiledObject &component, const QV4::CompiledData::Alias &alias, int *type, + QQmlPropertyData::Flags *propertyFlags) { const int targetObjectIndex = objectForId(component, alias.targetObjectId); Q_ASSERT(targetObjectIndex >= 0); @@ -634,7 +633,7 @@ inline void QQmlPropertyCacheAliasCreator<ObjectContainer>::propertyDataForAlias bool writable = false; bool resettable = false; - *propertyFlags = QQmlPropertyData::IsAlias; + propertyFlags->isAlias = true; if (alias.aliasToLocalAlias) { auto targetAlias = targetObject.aliasesBegin(); @@ -652,7 +651,7 @@ inline void QQmlPropertyCacheAliasCreator<ObjectContainer>::propertyDataForAlias else *type = typeRef->compilationUnit->metaTypeId; - *propertyFlags |= QQmlPropertyData::IsQObjectDerived; + propertyFlags->type = QQmlPropertyData::Flags::QObjectDerivedType; } else { int coreIndex = QQmlPropertyIndex::fromEncoded(alias.encodedMetaPropertyIndex).coreIndex(); int valueTypeIndex = QQmlPropertyIndex::fromEncoded(alias.encodedMetaPropertyIndex).valueTypeIndex(); @@ -678,27 +677,21 @@ inline void QQmlPropertyCacheAliasCreator<ObjectContainer>::propertyDataForAlias *type = QVariant::Int; } else { // Copy type flags - *propertyFlags |= targetProperty->getFlags() & QQmlPropertyData::PropTypeFlagMask; + propertyFlags->copyPropertyTypeFlags(targetProperty->getFlags()); if (targetProperty->isVarProperty()) - *propertyFlags |= QQmlPropertyData::IsQVariant; + propertyFlags->type = QQmlPropertyData::Flags::QVariantType; } } } - if (!(alias.flags & QV4::CompiledData::Property::IsReadOnly) && writable) - *propertyFlags |= QQmlPropertyData::IsWritable; - else - *propertyFlags &= ~QQmlPropertyData::IsWritable; - - if (resettable) - *propertyFlags |= QQmlPropertyData::IsResettable; - else - *propertyFlags &= ~QQmlPropertyData::IsResettable; + propertyFlags->isWritable = !(alias.flags & QV4::CompiledData::Property::IsReadOnly) && writable; + propertyFlags->isResettable = resettable; } template <typename ObjectContainer> -inline void QQmlPropertyCacheAliasCreator<ObjectContainer>::appendAliasesToPropertyCache(const CompiledObject &component, int objectIndex) +inline void QQmlPropertyCacheAliasCreator<ObjectContainer>::appendAliasesToPropertyCache( + const CompiledObject &component, int objectIndex) { const CompiledObject &object = *objectContainer->objectAt(objectIndex); if (!object.aliasCount()) @@ -715,7 +708,7 @@ inline void QQmlPropertyCacheAliasCreator<ObjectContainer>::appendAliasesToPrope Q_ASSERT(alias->flags & QV4::CompiledData::Alias::Resolved); int type = 0; - quint32 propertyFlags = 0; + QQmlPropertyData::Flags propertyFlags; propertyDataForAlias(component, *alias, &type, &propertyFlags); const QString propertyName = objectContainer->stringAt(alias->nameIndex); |