diff options
| author | Lars Knoll <lars.knoll@theqtcompany.com> | 2014-11-07 02:57:01 +0100 |
|---|---|---|
| committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-11-11 03:10:51 +0100 |
| commit | 766c878618934d64bb8b459f29aa489bf99de14f (patch) | |
| tree | 1ca0c54c54fb334b95befe8b3af0c363b977c904 | |
| parent | 9681f6caa1cb7e43227066b0c0bd3ef76c6f60e2 (diff) | |
Move data for remaining objects in QtQml into the Heap namespace
Change-Id: Iefef658dc246b5087d5061d964f08378b56c6cef
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
| -rw-r--r-- | src/qml/qml/qqmlcomponent.cpp | 71 | ||||
| -rw-r--r-- | src/qml/types/qqmldelegatemodel.cpp | 113 |
2 files changed, 106 insertions, 78 deletions
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index ddb9633427..a408072d38 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1070,18 +1070,25 @@ void QQmlComponent::create(QQmlIncubator &incubator, QQmlContext *context, class QQmlComponentIncubator; +namespace QV4 { + +namespace Heap { + +struct QmlIncubatorObject : Object { + QmlIncubatorObject(QV8Engine *engine, QQmlIncubator::IncubationMode = QQmlIncubator::Asynchronous); + QScopedPointer<QQmlComponentIncubator> incubator; + QV8Engine *v8; + QPointer<QObject> parent; + QV4::Value valuemap; + QV4::Value qmlGlobal; + QV4::Value statusChanged; +}; + +} + struct QmlIncubatorObject : public QV4::Object { - struct Data : QV4::Heap::Object { - Data(QV8Engine *engine, QQmlIncubator::IncubationMode = QQmlIncubator::Asynchronous); - QScopedPointer<QQmlComponentIncubator> incubator; - QV8Engine *v8; - QPointer<QObject> parent; - QV4::Value valuemap; - QV4::Value qmlGlobal; - QV4::Value statusChanged; - }; - V4_OBJECT(QV4::Object) + V4_OBJECT2(QmlIncubatorObject, Object) static QV4::ReturnedValue method_get_statusChanged(QV4::CallContext *ctx); static QV4::ReturnedValue method_set_statusChanged(QV4::CallContext *ctx); @@ -1096,29 +1103,31 @@ struct QmlIncubatorObject : public QV4::Object void setInitialState(QObject *); }; -DEFINE_OBJECT_VTABLE(QmlIncubatorObject); +} + +DEFINE_OBJECT_VTABLE(QV4::QmlIncubatorObject); class QQmlComponentIncubator : public QQmlIncubator { public: - QQmlComponentIncubator(QmlIncubatorObject::Data *inc, IncubationMode mode) + QQmlComponentIncubator(QV4::Heap::QmlIncubatorObject *inc, IncubationMode mode) : QQmlIncubator(mode) , incubatorObject(inc) {} virtual void statusChanged(Status s) { QV4::Scope scope(incubatorObject->internalClass->engine); - QV4::Scoped<QmlIncubatorObject> i(scope, incubatorObject); + QV4::Scoped<QV4::QmlIncubatorObject> i(scope, incubatorObject); i->statusChanged(s); } virtual void setInitialState(QObject *o) { QV4::Scope scope(incubatorObject->internalClass->engine); - QV4::Scoped<QmlIncubatorObject> i(scope, incubatorObject); + QV4::Scoped<QV4::QmlIncubatorObject> i(scope, incubatorObject); i->setInitialState(o); } - QmlIncubatorObject::Data *incubatorObject; + QV4::Heap::QmlIncubatorObject *incubatorObject; }; @@ -1354,7 +1363,7 @@ void QQmlComponent::incubateObject(QQmlV4Function *args) QQmlComponentExtension *e = componentExtension(args->engine()); - QV4::Scoped<QmlIncubatorObject> r(scope, v4->memoryManager->alloc<QmlIncubatorObject>(args->engine(), mode)); + QV4::Scoped<QV4::QmlIncubatorObject> r(scope, v4->memoryManager->alloc<QV4::QmlIncubatorObject>(args->engine(), mode)); QV4::ScopedObject p(scope, e->incubationProto.value()); r->setPrototype(p.getPointer()); @@ -1403,15 +1412,15 @@ QQmlComponentExtension::QQmlComponentExtension(QV8Engine *engine) QV4::Scope scope(v4); QV4::Scoped<QV4::Object> proto(scope, v4->newObject()); proto->defineAccessorProperty(QStringLiteral("onStatusChanged"), - QmlIncubatorObject::method_get_statusChanged, QmlIncubatorObject::method_set_statusChanged); - proto->defineAccessorProperty(QStringLiteral("status"), QmlIncubatorObject::method_get_status, 0); - proto->defineAccessorProperty(QStringLiteral("object"), QmlIncubatorObject::method_get_object, 0); - proto->defineDefaultProperty(QStringLiteral("forceCompletion"), QmlIncubatorObject::method_forceCompletion); + QV4::QmlIncubatorObject::method_get_statusChanged, QV4::QmlIncubatorObject::method_set_statusChanged); + proto->defineAccessorProperty(QStringLiteral("status"), QV4::QmlIncubatorObject::method_get_status, 0); + proto->defineAccessorProperty(QStringLiteral("object"), QV4::QmlIncubatorObject::method_get_object, 0); + proto->defineDefaultProperty(QStringLiteral("forceCompletion"), QV4::QmlIncubatorObject::method_forceCompletion); incubationProto = proto; } -QV4::ReturnedValue QmlIncubatorObject::method_get_object(QV4::CallContext *ctx) +QV4::ReturnedValue QV4::QmlIncubatorObject::method_get_object(QV4::CallContext *ctx) { QV4::Scope scope(ctx); QV4::Scoped<QmlIncubatorObject> o(scope, ctx->d()->callData->thisObject.as<QmlIncubatorObject>()); @@ -1421,7 +1430,7 @@ QV4::ReturnedValue QmlIncubatorObject::method_get_object(QV4::CallContext *ctx) return QV4::QObjectWrapper::wrap(ctx->d()->engine, o->d()->incubator->object()); } -QV4::ReturnedValue QmlIncubatorObject::method_forceCompletion(QV4::CallContext *ctx) +QV4::ReturnedValue QV4::QmlIncubatorObject::method_forceCompletion(QV4::CallContext *ctx) { QV4::Scope scope(ctx); QV4::Scoped<QmlIncubatorObject> o(scope, ctx->d()->callData->thisObject.as<QmlIncubatorObject>()); @@ -1433,7 +1442,7 @@ QV4::ReturnedValue QmlIncubatorObject::method_forceCompletion(QV4::CallContext * return QV4::Encode::undefined(); } -QV4::ReturnedValue QmlIncubatorObject::method_get_status(QV4::CallContext *ctx) +QV4::ReturnedValue QV4::QmlIncubatorObject::method_get_status(QV4::CallContext *ctx) { QV4::Scope scope(ctx); QV4::Scoped<QmlIncubatorObject> o(scope, ctx->d()->callData->thisObject.as<QmlIncubatorObject>()); @@ -1443,7 +1452,7 @@ QV4::ReturnedValue QmlIncubatorObject::method_get_status(QV4::CallContext *ctx) return QV4::Encode(o->d()->incubator->status()); } -QV4::ReturnedValue QmlIncubatorObject::method_get_statusChanged(QV4::CallContext *ctx) +QV4::ReturnedValue QV4::QmlIncubatorObject::method_get_statusChanged(QV4::CallContext *ctx) { QV4::Scope scope(ctx); QV4::Scoped<QmlIncubatorObject> o(scope, ctx->d()->callData->thisObject.as<QmlIncubatorObject>()); @@ -1453,7 +1462,7 @@ QV4::ReturnedValue QmlIncubatorObject::method_get_statusChanged(QV4::CallContext return o->d()->statusChanged.asReturnedValue(); } -QV4::ReturnedValue QmlIncubatorObject::method_set_statusChanged(QV4::CallContext *ctx) +QV4::ReturnedValue QV4::QmlIncubatorObject::method_set_statusChanged(QV4::CallContext *ctx) { QV4::Scope scope(ctx); QV4::Scoped<QmlIncubatorObject> o(scope, ctx->d()->callData->thisObject.as<QmlIncubatorObject>()); @@ -1469,19 +1478,19 @@ QQmlComponentExtension::~QQmlComponentExtension() { } -QmlIncubatorObject::Data::Data(QV8Engine *engine, QQmlIncubator::IncubationMode m) +QV4::Heap::QmlIncubatorObject::QmlIncubatorObject(QV8Engine *engine, QQmlIncubator::IncubationMode m) : QV4::Heap::Object(QV8Engine::getV4(engine)) , v8(engine) , valuemap(QV4::Primitive::undefinedValue()) , qmlGlobal(QV4::Primitive::undefinedValue()) , statusChanged(QV4::Primitive::undefinedValue()) { - setVTable(staticVTable()); + setVTable(QV4::QmlIncubatorObject::staticVTable()); incubator.reset(new QQmlComponentIncubator(this, m)); } -void QmlIncubatorObject::setInitialState(QObject *o) +void QV4::QmlIncubatorObject::setInitialState(QObject *o) { QQmlComponent_setQmlParent(o, d()->parent); @@ -1498,12 +1507,12 @@ void QmlIncubatorObject::setInitialState(QObject *o) } } -void QmlIncubatorObject::destroy(Managed *that) +void QV4::QmlIncubatorObject::destroy(Managed *that) { static_cast<QmlIncubatorObject *>(that)->d()->~Data(); } -void QmlIncubatorObject::markObjects(QV4::Heap::Base *that, QV4::ExecutionEngine *e) +void QV4::QmlIncubatorObject::markObjects(QV4::Heap::Base *that, QV4::ExecutionEngine *e) { QmlIncubatorObject::Data *o = static_cast<QmlIncubatorObject::Data *>(that); o->valuemap.mark(e); @@ -1512,7 +1521,7 @@ void QmlIncubatorObject::markObjects(QV4::Heap::Base *that, QV4::ExecutionEngine Object::markObjects(that, e); } -void QmlIncubatorObject::statusChanged(QQmlIncubator::Status s) +void QV4::QmlIncubatorObject::statusChanged(QQmlIncubator::Status s) { QV4::Scope scope(QV8Engine::getV4(d()->v8)); // hold the incubated object in a scoped value to prevent it's destruction before this method returns diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index 769dea993a..383379295f 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -52,21 +52,34 @@ QT_BEGIN_NAMESPACE class QQmlDelegateModelItem; -struct DelegateModelGroupFunction: QV4::FunctionObject -{ - struct Data : QV4::Heap::FunctionObject { - Data(QV4::ExecutionContext *scope, uint flag, QV4::ReturnedValue (*code)(QQmlDelegateModelItem *item, uint flag, const QV4::ValueRef arg)) - : QV4::Heap::FunctionObject(scope, QStringLiteral("DelegateModelGroupFunction")) - , flag(flag) - , code(code) - { - setVTable(staticVTable()); - } +namespace QV4 { + +namespace Heap { + +struct DelegateModelGroupFunction : FunctionObject { + DelegateModelGroupFunction(QV4::ExecutionContext *scope, uint flag, QV4::ReturnedValue (*code)(QQmlDelegateModelItem *item, uint flag, const QV4::ValueRef arg)); + + uint flag; + QV4::ReturnedValue (*code)(QQmlDelegateModelItem *item, uint flag, const QV4::ValueRef arg); +}; + +struct QQmlDelegateModelGroupChange : Object { + QQmlDelegateModelGroupChange(QV4::ExecutionEngine *engine); + + QQmlChangeSet::Change change; +}; + +struct QQmlDelegateModelGroupChangeArray : Object { + QQmlDelegateModelGroupChangeArray(QV4::ExecutionEngine *engine, const QVector<QQmlChangeSet::Change> &changes); + QVector<QQmlChangeSet::Change> changes; +}; + - uint flag; - QV4::ReturnedValue (*code)(QQmlDelegateModelItem *item, uint flag, const QV4::ValueRef arg); - }; - V4_OBJECT(QV4::FunctionObject) +} + +struct DelegateModelGroupFunction : QV4::FunctionObject +{ + V4_OBJECT2(DelegateModelGroupFunction, FunctionObject) static QV4::Returned<DelegateModelGroupFunction> *create(QV4::ExecutionContext *scope, uint flag, QV4::ReturnedValue (*code)(QQmlDelegateModelItem *item, uint flag, const QV4::ValueRef arg)) { @@ -92,7 +105,17 @@ struct DelegateModelGroupFunction: QV4::FunctionObject } }; -DEFINE_OBJECT_VTABLE(DelegateModelGroupFunction); +Heap::DelegateModelGroupFunction::DelegateModelGroupFunction(QV4::ExecutionContext *scope, uint flag, QV4::ReturnedValue (*code)(QQmlDelegateModelItem *item, uint flag, const QV4::ValueRef arg)) + : QV4::Heap::FunctionObject(scope, QStringLiteral("DelegateModelGroupFunction")) + , flag(flag) + , code(code) +{ + setVTable(QV4::DelegateModelGroupFunction::staticVTable()); +} + +} + +DEFINE_OBJECT_VTABLE(QV4::DelegateModelGroupFunction); @@ -1695,26 +1718,26 @@ void QQmlDelegateModelItemMetaType::initializePrototype() s = v4->newString(QStringLiteral("isUnresolved")); QV4::ScopedFunctionObject f(scope); - p->setGetter((f = DelegateModelGroupFunction::create(v4->rootContext, 30, QQmlDelegateModelItem::get_member))); + p->setGetter((f = QV4::DelegateModelGroupFunction::create(v4->rootContext, 30, QQmlDelegateModelItem::get_member))); p->setSetter(0); proto->insertMember(s.getPointer(), p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); s = v4->newString(QStringLiteral("inItems")); - p->setGetter((f = DelegateModelGroupFunction::create(v4->rootContext, QQmlListCompositor::Default, QQmlDelegateModelItem::get_member))); - p->setSetter((f = DelegateModelGroupFunction::create(v4->rootContext, QQmlListCompositor::Default, QQmlDelegateModelItem::set_member))); + p->setGetter((f = QV4::DelegateModelGroupFunction::create(v4->rootContext, QQmlListCompositor::Default, QQmlDelegateModelItem::get_member))); + p->setSetter((f = QV4::DelegateModelGroupFunction::create(v4->rootContext, QQmlListCompositor::Default, QQmlDelegateModelItem::set_member))); proto->insertMember(s.getPointer(), p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); s = v4->newString(QStringLiteral("inPersistedItems")); - p->setGetter((f = DelegateModelGroupFunction::create(v4->rootContext, QQmlListCompositor::Persisted, QQmlDelegateModelItem::get_member))); - p->setSetter((f = DelegateModelGroupFunction::create(v4->rootContext, QQmlListCompositor::Persisted, QQmlDelegateModelItem::set_member))); + p->setGetter((f = QV4::DelegateModelGroupFunction::create(v4->rootContext, QQmlListCompositor::Persisted, QQmlDelegateModelItem::get_member))); + p->setSetter((f = QV4::DelegateModelGroupFunction::create(v4->rootContext, QQmlListCompositor::Persisted, QQmlDelegateModelItem::set_member))); proto->insertMember(s.getPointer(), p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); s = v4->newString(QStringLiteral("itemsIndex")); - p->setGetter((f = DelegateModelGroupFunction::create(v4->rootContext, QQmlListCompositor::Default, QQmlDelegateModelItem::get_index))); + p->setGetter((f = QV4::DelegateModelGroupFunction::create(v4->rootContext, QQmlListCompositor::Default, QQmlDelegateModelItem::get_index))); proto->insertMember(s.getPointer(), p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); s = v4->newString(QStringLiteral("persistedItemsIndex")); - p->setGetter((f = DelegateModelGroupFunction::create(v4->rootContext, QQmlListCompositor::Persisted, QQmlDelegateModelItem::get_index))); + p->setGetter((f = QV4::DelegateModelGroupFunction::create(v4->rootContext, QQmlListCompositor::Persisted, QQmlDelegateModelItem::get_index))); p->setSetter(0); proto->insertMember(s.getPointer(), p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); @@ -1722,14 +1745,14 @@ void QQmlDelegateModelItemMetaType::initializePrototype() QString propertyName = QStringLiteral("in") + groupNames.at(i); propertyName.replace(2, 1, propertyName.at(2).toUpper()); s = v4->newString(propertyName); - p->setGetter((f = DelegateModelGroupFunction::create(v4->rootContext, i + 1, QQmlDelegateModelItem::get_member))); - p->setSetter((f = DelegateModelGroupFunction::create(v4->rootContext, i + 1, QQmlDelegateModelItem::set_member))); + p->setGetter((f = QV4::DelegateModelGroupFunction::create(v4->rootContext, i + 1, QQmlDelegateModelItem::get_member))); + p->setSetter((f = QV4::DelegateModelGroupFunction::create(v4->rootContext, i + 1, QQmlDelegateModelItem::set_member))); proto->insertMember(s.getPointer(), p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); } for (int i = 2; i < groupNames.count(); ++i) { const QString propertyName = groupNames.at(i) + QStringLiteral("Index"); s = v4->newString(propertyName); - p->setGetter((f = DelegateModelGroupFunction::create(v4->rootContext, i + 1, QQmlDelegateModelItem::get_index))); + p->setGetter((f = QV4::DelegateModelGroupFunction::create(v4->rootContext, i + 1, QQmlDelegateModelItem::get_index))); p->setSetter(0); proto->insertMember(s.getPointer(), p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); } @@ -3211,15 +3234,7 @@ void QQmlPartsModel::emitModelUpdated(const QQmlChangeSet &changeSet, bool reset struct QQmlDelegateModelGroupChange : QV4::Object { - struct Data : QV4::Heap::Object { - Data(QV4::ExecutionEngine *engine) - : QV4::Heap::Object(engine) - { - setVTable(staticVTable()); - } - QQmlChangeSet::Change change; - }; - V4_OBJECT(QV4::Object) + V4_OBJECT2(QQmlDelegateModelGroupChange, QV4::Object) static QV4::Returned<QQmlDelegateModelGroupChange> *create(QV4::ExecutionEngine *e) { return e->memoryManager->alloc<QQmlDelegateModelGroupChange>(e); @@ -3250,23 +3265,17 @@ struct QQmlDelegateModelGroupChange : QV4::Object } }; +QV4::Heap::QQmlDelegateModelGroupChange::QQmlDelegateModelGroupChange(QV4::ExecutionEngine *engine) + : QV4::Heap::Object(engine) +{ + setVTable(::QQmlDelegateModelGroupChange::staticVTable()); +} + DEFINE_OBJECT_VTABLE(QQmlDelegateModelGroupChange); struct QQmlDelegateModelGroupChangeArray : public QV4::Object { - struct Data : QV4::Heap::Object { - Data(QV4::ExecutionEngine *engine, const QVector<QQmlChangeSet::Change> &changes) - : QV4::Heap::Object(engine) - , changes(changes) - { - setVTable(staticVTable()); - QV4::Scope scope(engine); - QV4::ScopedObject o(scope, this); - o->setArrayType(QV4::Heap::ArrayData::Custom); - } - QVector<QQmlChangeSet::Change> changes; - }; - V4_OBJECT(QV4::Object) + V4_OBJECT2(QQmlDelegateModelGroupChangeArray, QV4::Object) public: static QV4::Returned<QQmlDelegateModelGroupChangeArray> *create(QV4::ExecutionEngine *engine, const QVector<QQmlChangeSet::Change> &changes) { @@ -3320,6 +3329,16 @@ public: }; +QV4::Heap::QQmlDelegateModelGroupChangeArray::QQmlDelegateModelGroupChangeArray(QV4::ExecutionEngine *engine, const QVector<QQmlChangeSet::Change> &changes) + : QV4::Heap::Object(engine) + , changes(changes) +{ + setVTable(::QQmlDelegateModelGroupChangeArray::staticVTable()); + QV4::Scope scope(engine); + QV4::ScopedObject o(scope, this); + o->setArrayType(QV4::Heap::ArrayData::Custom); +} + DEFINE_OBJECT_VTABLE(QQmlDelegateModelGroupChangeArray); QQmlDelegateModelEngineData::QQmlDelegateModelEngineData(QV8Engine *e) |
