aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2023-09-22 08:50:12 +0200
committerUlf Hermann <ulf.hermann@qt.io>2023-09-28 16:23:00 +0200
commitf9271771cf6179a8b51ca90a2f863d6983c8fe0c (patch)
tree228ab3c2ada350adcb44ebf99086be4e22aa6155 /src/qml/qml
parentd374a98682c8f8e3601af8f643e5ad1baa383147 (diff)
QQmlPropertyCache: Make space for an extra flag
Some of the types were unused and there is no reason to keep a gap for types we don't use anymore. By tightening this, we reduce the number of types to <= 8. Therefore we only need 3 bits to store the type and gain one bit for other purposes. Task-number: QTBUG-113258 Change-Id: Ic6934bfc4b75a368f7ccecbe852060602f93c909 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/qqmlpropertycache.cpp14
-rw-r--r--src/qml/qml/qqmlpropertycachecreator_p.h14
-rw-r--r--src/qml/qml/qqmlpropertydata_p.h36
3 files changed, 29 insertions, 35 deletions
diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp
index e99c26cec8..ae181b23dc 100644
--- a/src/qml/qml/qqmlpropertycache.cpp
+++ b/src/qml/qml/qqmlpropertycache.cpp
@@ -54,17 +54,13 @@ QQmlPropertyData::flagsForProperty(const QMetaProperty &p)
const QMetaType metaType = p.metaType();
int propType = metaType.id();
if (p.isEnumType()) {
- flags.type = QQmlPropertyData::Flags::EnumType;
+ flags.setType(QQmlPropertyData::Flags::EnumType);
} else if (metaType.flags() & QMetaType::PointerToQObject) {
- flags.type = QQmlPropertyData::Flags::QObjectDerivedType;
+ flags.setType(QQmlPropertyData::Flags::QObjectDerivedType);
} else if (propType == QMetaType::QVariant) {
- flags.type = QQmlPropertyData::Flags::QVariantType;
- } else if (propType < static_cast<int>(QMetaType::User)) {
- // nothing to do
- } else if (propType == qMetaTypeId<QJSValue>()) {
- flags.type = QQmlPropertyData::Flags::QJSValueType;
+ flags.setType(QQmlPropertyData::Flags::QVariantType);
} else if (metaType.flags() & QMetaType::IsQmlList) {
- flags.type = QQmlPropertyData::Flags::QListType;
+ flags.setType(QQmlPropertyData::Flags::QListType);
}
return flags;
@@ -88,7 +84,7 @@ void QQmlPropertyData::load(const QMetaMethod &m)
setPropType(m.returnMetaType());
- m_flags.type = Flags::FunctionType;
+ m_flags.setType(Flags::FunctionType);
if (m.methodType() == QMetaMethod::Signal) {
m_flags.setIsSignal(true);
} else if (m.methodType() == QMetaMethod::Constructor) {
diff --git a/src/qml/qml/qqmlpropertycachecreator_p.h b/src/qml/qml/qqmlpropertycachecreator_p.h
index ae3c669939..4d64ce6146 100644
--- a/src/qml/qml/qqmlpropertycachecreator_p.h
+++ b/src/qml/qml/qqmlpropertycachecreator_p.h
@@ -652,9 +652,9 @@ inline QQmlError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObject(
const QV4::CompiledData::CommonType type = p->commonType();
if (p->isList())
- propertyFlags.type = QQmlPropertyData::Flags::QListType;
+ propertyFlags.setType(QQmlPropertyData::Flags::QListType);
else if (type == QV4::CompiledData::CommonType::Var)
- propertyFlags.type = QQmlPropertyData::Flags::VarPropertyType;
+ propertyFlags.setType(QQmlPropertyData::Flags::VarPropertyType);
if (type != QV4::CompiledData::CommonType::Invalid) {
propertyType = p->isList()
@@ -707,11 +707,9 @@ inline QQmlError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObject(
}
if (p->isList())
- propertyFlags.type = QQmlPropertyData::Flags::QListType;
+ propertyFlags.setType(QQmlPropertyData::Flags::QListType);
else if (propertyType.flags().testFlag(QMetaType::PointerToQObject))
- propertyFlags.type = QQmlPropertyData::Flags::QObjectDerivedType;
- else
- propertyFlags.type = QQmlPropertyData::Flags::ValueType;
+ propertyFlags.setType(QQmlPropertyData::Flags::QObjectDerivedType);
}
if (!p->isReadOnly() && !propertyType.flags().testFlag(QMetaType::IsQmlList))
@@ -890,7 +888,7 @@ inline QQmlError QQmlPropertyCacheAliasCreator<ObjectContainer>::propertyDataFor
*version = typeRef->version();
- propertyFlags->type = QQmlPropertyData::Flags::QObjectDerivedType;
+ propertyFlags->setType(QQmlPropertyData::Flags::QObjectDerivedType);
} else {
int coreIndex = QQmlPropertyIndex::fromEncoded(alias.encodedMetaPropertyIndex).coreIndex();
int valueTypeIndex = QQmlPropertyIndex::fromEncoded(
@@ -941,7 +939,7 @@ inline QQmlError QQmlPropertyCacheAliasCreator<ObjectContainer>::propertyDataFor
propertyFlags->copyPropertyTypeFlags(targetProperty->flags());
if (targetProperty->isVarProperty())
- propertyFlags->type = QQmlPropertyData::Flags::QVariantType;
+ propertyFlags->setType(QQmlPropertyData::Flags::QVariantType);
}
}
}
diff --git a/src/qml/qml/qqmlpropertydata_p.h b/src/qml/qml/qqmlpropertydata_p.h
index 8ca2a19d6f..74f8afc281 100644
--- a/src/qml/qml/qqmlpropertydata_p.h
+++ b/src/qml/qml/qqmlpropertydata_p.h
@@ -37,20 +37,18 @@ public:
struct Flags {
friend class QQmlPropertyData;
- enum Types {
+ enum Type {
OtherType = 0,
FunctionType = 1, // Is an invokable
QObjectDerivedType = 2, // Property type is a QObject* derived type
EnumType = 3, // Property type is an enum
QListType = 4, // Property type is a QML list
- /*QmlBindingType = 5; was: Property type is a QQmlBinding*; now unused */
- QJSValueType = 6, // Property type is a QScriptValue
- // Gap, used to be V4HandleType
- VarPropertyType = 8, // Property type is a "var" property of VMEMO
- QVariantType = 9, // Property is a QVariant
- ValueType = 10 // Property type is a custom value type
+ VarPropertyType = 5, // Property type is a "var" property of VMEMO
+ QVariantType = 6, // Property is a QVariant
+ // One spot left for an extra type in the 3 bits used to store this.
};
+ private:
// The _otherBits (which "pad" the Flags struct to align it nicely) are used
// to store the relative property index. It will only get used when said index fits. See
// trySetStaticMetaCallFunction for details.
@@ -68,7 +66,6 @@ public:
// for non-functions)
//
// Lastly, isDirect and isOverridden apply to both functions and non-functions
- private:
unsigned isConst : 1; // Property: has CONST flag/Method: is const
unsigned isVMEFunction : 1; // Function was added by QML
unsigned isWritableORhasArguments : 1; // Has WRITE function OR Function takes arguments
@@ -83,14 +80,13 @@ public:
unsigned isRequiredORisCloned : 1; // Has REQUIRED flag OR The function was marked as cloned
unsigned isConstructorORisBindable : 1; // The function was marked is a constructor OR property is backed by QProperty<T>
unsigned isOverridden : 1; // Is overridden by a extension property
- public:
- unsigned type : 4; // stores an entry of Types
-
- // Apply only to IsFunctions
+ unsigned reserved : 1;
+ unsigned type : 3; // stores an entry of Types
// Internal QQmlPropertyCache flags
- unsigned overrideIndexIsProperty: 1;
+ unsigned overrideIndexIsProperty : 1;
+ public:
inline Flags();
inline bool operator==(const Flags &other) const;
inline void copyPropertyTypeFlags(Flags from);
@@ -177,6 +173,9 @@ public:
isConstructorORisBindable = b;
}
+ void setType(Type newType) {
+ type = newType;
+ }
};
@@ -205,7 +204,6 @@ public:
bool isQObject() const { return m_flags.type == Flags::QObjectDerivedType; }
bool isEnum() const { return m_flags.type == Flags::EnumType; }
bool isQList() const { return m_flags.type == Flags::QListType; }
- bool isQJSValue() const { return m_flags.type == Flags::QJSValueType; }
bool isVarProperty() const { return m_flags.type == Flags::VarPropertyType; }
bool isQVariant() const { return m_flags.type == Flags::QVariantType; }
bool isVMEFunction() const { return isFunction() && m_flags.isVMEFunction; }
@@ -360,7 +358,7 @@ public:
static Flags defaultSignalFlags()
{
Flags f;
- f.type = Flags::FunctionType;
+ f.setType(Flags::FunctionType);
f.setIsSignal(true);
f.setIsVMESignal(true);
return f;
@@ -369,7 +367,7 @@ public:
static Flags defaultSlotFlags()
{
Flags f;
- f.type = Flags::FunctionType;
+ f.setType(Flags::FunctionType);
f.setIsVMEFunction(true);
return f;
}
@@ -428,9 +426,12 @@ QQmlPropertyData::Flags::Flags()
, isRequiredORisCloned(false)
, isConstructorORisBindable(false)
, isOverridden(false)
+ , reserved(false)
, type(OtherType)
, overrideIndexIsProperty(false)
-{}
+{
+ Q_UNUSED(reserved)
+}
bool QQmlPropertyData::Flags::operator==(const QQmlPropertyData::Flags &other) const
{
@@ -454,7 +455,6 @@ void QQmlPropertyData::Flags::copyPropertyTypeFlags(QQmlPropertyData::Flags from
case QObjectDerivedType:
case EnumType:
case QListType:
- case QJSValueType:
case QVariantType:
type = from.type;
}