aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlvmemetaobject.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2019-07-04 14:43:10 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2019-07-05 16:31:45 +0200
commite203418096e66f2173d05788e5cb18e79141e772 (patch)
treea686a081985b9c120d83f6399af8b65fc7669aaa /src/qml/qml/qqmlvmemetaobject.cpp
parent2024df6604dbb78f5eee6f61e73fb0d2fc3bb008 (diff)
Reduce the size of Property fields in type compilation data
We can shave off 4 bytes of each property declaration by sharing the bits for the custom type name index or the builtin type enum. Change-Id: I77071cbef66c5a83b3e7e281dba3a435d3c68b39 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlvmemetaobject.cpp')
-rw-r--r--src/qml/qml/qqmlvmemetaobject.cpp51
1 files changed, 26 insertions, 25 deletions
diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp
index e26dc4d9aa..d210b049df 100644
--- a/src/qml/qml/qqmlvmemetaobject.cpp
+++ b/src/qml/qml/qqmlvmemetaobject.cpp
@@ -639,7 +639,8 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void *
id -= propOffset();
if (id < propertyCount) {
- const QV4::CompiledData::Property::Type t = static_cast<QV4::CompiledData::Property::Type>(qint32(compiledObject->propertyTable()[id].type));
+ const QV4::CompiledData::Property &property = compiledObject->propertyTable()[id];
+ const QV4::CompiledData::Property::Type t = property.builtinType();
// the context can be null if accessing var properties from cpp after re-parenting an item.
QQmlEnginePrivate *ep = (ctxt == nullptr || ctxt->engine == nullptr) ? nullptr : QQmlEnginePrivate::get(ctxt->engine);
@@ -678,22 +679,9 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void *
case QV4::CompiledData::Property::Point:
*reinterpret_cast<QPointF *>(a[0]) = readPropertyAsPointF(id);
break;
- case QV4::CompiledData::Property::Custom:
- *reinterpret_cast<QObject **>(a[0]) = readPropertyAsQObject(id);
- break;
case QV4::CompiledData::Property::Variant:
*reinterpret_cast<QVariant *>(a[0]) = readPropertyAsVariant(id);
break;
- case QV4::CompiledData::Property::CustomList: {
- QList<QObject *> *list = readPropertyAsList(id);
- QQmlListProperty<QObject> *p = static_cast<QQmlListProperty<QObject> *>(a[0]);
- *p = QQmlListProperty<QObject>(object, list,
- list_append, list_count, list_at,
- list_clear);
- p->dummy1 = this;
- p->dummy2 = reinterpret_cast<void *>(quintptr(methodOffset() + id));
- break;
- }
case QV4::CompiledData::Property::Font:
case QV4::CompiledData::Property::Time:
case QV4::CompiledData::Property::Color:
@@ -718,6 +706,18 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void *
*reinterpret_cast<QVariant *>(a[0]) = QVariant();
}
break;
+ case QV4::CompiledData::Property::InvalidBuiltin:
+ if (property.isList) {
+ QList<QObject *> *list = readPropertyAsList(id);
+ QQmlListProperty<QObject> *p = static_cast<QQmlListProperty<QObject> *>(a[0]);
+ *p = QQmlListProperty<QObject>(object, list,
+ list_append, list_count, list_at,
+ list_clear);
+ p->dummy1 = this;
+ p->dummy2 = reinterpret_cast<void *>(quintptr(methodOffset() + id));
+ } else {
+ *reinterpret_cast<QObject **>(a[0]) = readPropertyAsQObject(id);
+ }
}
} else if (c == QMetaObject::WriteProperty) {
@@ -763,17 +763,9 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void *
needActivate = *reinterpret_cast<QPointF *>(a[0]) != readPropertyAsPointF(id);
writeProperty(id, *reinterpret_cast<QPointF *>(a[0]));
break;
- case QV4::CompiledData::Property::Custom:
- needActivate = *reinterpret_cast<QObject **>(a[0]) != readPropertyAsQObject(id);
- writeProperty(id, *reinterpret_cast<QObject **>(a[0]));
- break;
case QV4::CompiledData::Property::Variant:
writeProperty(id, *reinterpret_cast<QVariant *>(a[0]));
break;
- case QV4::CompiledData::Property::CustomList:
- // Writing such a property is not supported. Content is added through the list property
- // methods.
- break;
case QV4::CompiledData::Property::Font:
case QV4::CompiledData::Property::Time:
case QV4::CompiledData::Property::Color:
@@ -798,6 +790,15 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void *
if (ep)
writeProperty(id, *reinterpret_cast<QVariant *>(a[0]));
break;
+ case QV4::CompiledData::Property::InvalidBuiltin:
+ if (property.isList) {
+ // Writing such a property is not supported. Content is added through the list property
+ // methods.
+ } else {
+ needActivate = *reinterpret_cast<QObject **>(a[0]) != readPropertyAsQObject(id);
+ writeProperty(id, *reinterpret_cast<QObject **>(a[0]));
+ }
+
}
if (needActivate)
@@ -965,7 +966,7 @@ QV4::ReturnedValue QQmlVMEMetaObject::method(int index) const
QV4::ReturnedValue QQmlVMEMetaObject::readVarProperty(int id) const
{
- Q_ASSERT(compiledObject && compiledObject->propertyTable()[id].type == QV4::CompiledData::Property::Var);
+ Q_ASSERT(compiledObject && compiledObject->propertyTable()[id].builtinType() == QV4::CompiledData::Property::Var);
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (md)
@@ -990,7 +991,7 @@ QVariant QQmlVMEMetaObject::readPropertyAsVariant(int id) const
void QQmlVMEMetaObject::writeVarProperty(int id, const QV4::Value &value)
{
- Q_ASSERT(compiledObject && compiledObject->propertyTable()[id].type == QV4::CompiledData::Property::Var);
+ Q_ASSERT(compiledObject && compiledObject->propertyTable()[id].builtinType() == QV4::CompiledData::Property::Var);
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (!md)
@@ -1030,7 +1031,7 @@ void QQmlVMEMetaObject::writeVarProperty(int id, const QV4::Value &value)
void QQmlVMEMetaObject::writeProperty(int id, const QVariant &value)
{
- if (compiledObject && compiledObject->propertyTable()[id].type == QV4::CompiledData::Property::Var) {
+ if (compiledObject && compiledObject->propertyTable()[id].builtinType() == QV4::CompiledData::Property::Var) {
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (!md)
return;