aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/types
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-05-22 16:51:34 +0200
committerLars Knoll <lars.knoll@digia.com>2013-05-23 15:42:24 +0200
commit31b700b9ddf38283ca06cf78db4a80d674b74661 (patch)
treec947874ad9e5284c35cab7f3af73a5d4dcd8d12f /src/qml/types
parentb71fa87e000c5d72d4b2a7146e450dc41dc69055 (diff)
Replace QV8QObjectResource with QV4::QObjectWrapper
Use a proper sub-class instead of external object resources, as a first step towards porting the QObject bindings away from V8. This also replaces the function template / constructor approach and the faster getter optimization with a plain virtual get in the V4::Object. Property lookup in QObject bindings will be subject to future optimizations that will work very differently once we enable the faster V4 lookup mechanism in QML. Change-Id: Ib7c2eead5323c22290c2924de786d9cfcf308c03 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/types')
-rw-r--r--src/qml/types/qqmllistmodel.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp
index 6666f63387..98d828c382 100644
--- a/src/qml/types/qqmllistmodel.cpp
+++ b/src/qml/types/qqmllistmodel.cpp
@@ -453,9 +453,8 @@ void ListModel::set(int elementIndex, v8::Handle<v8::Object> object, QVector<int
QDateTime dt = propertyValue->v4Value().asDateObject()->toQDateTime();
roleIndex = e->setDateTimeProperty(r, dt);
} else if (propertyValue->IsObject()) {
- QV8ObjectResource *r = (QV8ObjectResource *) propertyValue->ToObject()->GetExternalResource();
- if (r && r->resourceType() == QV8ObjectResource::QObjectType) {
- QObject *o = QV8QObjectWrapper::toQObject(r);
+ if (QV4::QObjectWrapper *wrapper = propertyValue->v4Value().asQObjectWrapper()) {
+ QObject *o = wrapper->object;
const ListLayout::Role &role = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::QObject);
if (role.type == ListLayout::Role::QObject)
roleIndex = e->setQObjectProperty(role, o);
@@ -529,9 +528,8 @@ void ListModel::set(int elementIndex, v8::Handle<v8::Object> object, QV8Engine *
e->setDateTimePropertyFast(r, dt);
}
} else if (propertyValue->IsObject()) {
- QV8ObjectResource *r = (QV8ObjectResource *) propertyValue->ToObject()->GetExternalResource();
- if (r && r->resourceType() == QV8ObjectResource::QObjectType) {
- QObject *o = QV8QObjectWrapper::toQObject(r);
+ if (QV4::QObjectWrapper *wrapper = propertyValue->v4Value().asQObjectWrapper()) {
+ QObject *o = wrapper->object;
const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::QObject);
if (r.type == ListLayout::Role::QObject)
e->setQObjectPropertyFast(r, o);
@@ -1190,9 +1188,9 @@ int ListElement::setJsProperty(const ListLayout::Role &role, v8::Handle<v8::Valu
QDateTime dt = d->v4Value().asDateObject()->toQDateTime();;
roleIndex = setDateTimeProperty(role, dt);
} else if (d->IsObject()) {
- QV8ObjectResource *r = (QV8ObjectResource *) d->ToObject()->GetExternalResource();
- if (role.type == ListLayout::Role::QObject && r && r->resourceType() == QV8ObjectResource::QObjectType) {
- QObject *o = QV8QObjectWrapper::toQObject(r);
+ QV4::QObjectWrapper *wrapper = d->v4Value().asQObjectWrapper();
+ if (role.type == ListLayout::Role::QObject && wrapper) {
+ QObject *o = wrapper->object;
roleIndex = setQObjectProperty(role, o);
} else if (role.type == ListLayout::Role::VariantMap) {
roleIndex = setVariantMapProperty(role, d->ToObject(), eng);