diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-05-31 13:05:37 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2013-05-31 15:46:27 +0200 |
commit | e14b9dbee1260f799d1d2e175d106dbed79b6c49 (patch) | |
tree | 127bd9fb574a5d62155e93ead4fdcffc3314e664 /src/qml/qml/qqmlvaluetypewrapper.cpp | |
parent | 0ced7dfd6991cd33222e7c5a3c05e56d2c67e9d5 (diff) |
Start converting casting of Managed to subtypes to a better scheme
There is now a template based as<Foo>() method available in
Managed, that'll allow casting to the proper subclass. It uses
the pointer to the vtable and compares it to the classes static
vtable for type checking. Like this we can avoid that Managed has
to know about all subclasses.
Change-Id: Ic966bbe00d85224b8d96cc0ff00f69a6ac67129e
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml/qqmlvaluetypewrapper.cpp')
-rw-r--r-- | src/qml/qml/qqmlvaluetypewrapper.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index ddc22daa5e..03e4639ae8 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -181,7 +181,7 @@ QVariant QmlValueTypeWrapper::toVariant() const void QmlValueTypeWrapper::destroy(Managed *that) { - QmlValueTypeWrapper *w = that->asQmlValueTypeWrapper(); + QmlValueTypeWrapper *w = that->as<QmlValueTypeWrapper>(); assert(w); if (w->objectType == Reference) static_cast<QmlValueTypeReference *>(w)->~QmlValueTypeReference(); @@ -191,13 +191,13 @@ void QmlValueTypeWrapper::destroy(Managed *that) bool QmlValueTypeWrapper::isEqualTo(Managed *m, Managed *other) { - QV4::QmlValueTypeWrapper *lv = m->asQmlValueTypeWrapper(); + QV4::QmlValueTypeWrapper *lv = m->as<QmlValueTypeWrapper>(); assert(lv); if (QV4::VariantObject *rv = other->asVariantObject()) return lv->isEqual(rv->data); - if (QV4::QmlValueTypeWrapper *v = other->asQmlValueTypeWrapper()) + if (QV4::QmlValueTypeWrapper *v = other->as<QmlValueTypeWrapper>()) return lv->isEqual(v->toVariant()); return false; @@ -227,7 +227,7 @@ Value QmlValueTypeWrapper::method_toString(SimpleCallContext *ctx) Object *o = ctx->thisObject.asObject(); if (!o) ctx->throwTypeError(); - QmlValueTypeWrapper *w = o->asQmlValueTypeWrapper(); + QmlValueTypeWrapper *w = o->as<QmlValueTypeWrapper>(); if (!w) ctx->throwTypeError(); @@ -248,7 +248,7 @@ Value QmlValueTypeWrapper::method_toString(SimpleCallContext *ctx) Value QmlValueTypeWrapper::get(Managed *m, ExecutionContext *ctx, String *name, bool *hasProperty) { - QmlValueTypeWrapper *r = m->asQmlValueTypeWrapper(); + QmlValueTypeWrapper *r = m->as<QmlValueTypeWrapper>(); if (!r) ctx->throwTypeError(); @@ -311,7 +311,7 @@ Value QmlValueTypeWrapper::get(Managed *m, ExecutionContext *ctx, String *name, void QmlValueTypeWrapper::put(Managed *m, ExecutionContext *ctx, String *name, const Value &value) { - QmlValueTypeWrapper *r = m->asQmlValueTypeWrapper(); + QmlValueTypeWrapper *r = m->as<QmlValueTypeWrapper>(); if (!r) ctx->throwTypeError(); |