From 6b7c3ea49c3475a71c582dd8c4a54429e543ec1c Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 24 Jul 2014 11:53:59 +0200 Subject: [PATCH] Remove most calls to Value::managed() Change-Id: Id5b1cca542421d749711eff68520a4138ec95531 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4engine.cpp | 2 +- src/qml/jsruntime/qv4managed_p.h | 4 ++-- src/qml/jsruntime/qv4runtime.cpp | 2 +- src/qml/jsruntime/qv4runtime_p.h | 2 +- src/qml/jsruntime/qv4scopedvalue_p.h | 2 +- src/qml/jsruntime/qv4value_inl_p.h | 4 ++-- src/qml/jsruntime/qv4value_p.h | 6 ++++++ 7 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index ec1ea80..3e7421a 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -369,7 +369,7 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory) static_cast(uRIErrorPrototype.getPointer())->init(this, uRIErrorCtor.asObject()); static_cast(variantPrototype.getPointer())->init(); - static_cast(sequencePrototype.managed())->init(); + sequencePrototype.cast()->init(); // typed arrays diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h index c73ad10..c69eace 100644 --- a/src/qml/jsruntime/qv4managed_p.h +++ b/src/qml/jsruntime/qv4managed_p.h @@ -326,8 +326,8 @@ public: void setVTable(const ManagedVTable *vt); - bool isEqualTo(Managed *other) - { return internalClass()->vtable->isEqualTo(this, other); } + bool isEqualTo(const Managed *other) const + { return internalClass()->vtable->isEqualTo(const_cast(this), const_cast(other)); } static bool isEqualTo(Managed *m, Managed *other); diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 957f8cd..54b42c5 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -721,7 +721,7 @@ Bool RuntimeHelpers::strictEqual(const ValueRef x, const ValueRef y) if (x->isNumber()) return y->isNumber() && x->asDouble() == y->asDouble(); if (x->isManaged()) - return y->isManaged() && x->managed()->isEqualTo(y->managed()); + return y->isManaged() && x->cast()->isEqualTo(y->cast()); return false; } diff --git a/src/qml/jsruntime/qv4runtime_p.h b/src/qml/jsruntime/qv4runtime_p.h index 6042420..52a345f 100644 --- a/src/qml/jsruntime/qv4runtime_p.h +++ b/src/qml/jsruntime/qv4runtime_p.h @@ -470,7 +470,7 @@ inline Bool Runtime::compareEqual(const ValueRef left, const ValueRef right) if (!left->isManaged()) return false; if (left->isString() == right->isString()) - return left->managed()->isEqualTo(right->managed()); + return left->cast()->isEqualTo(right->cast()); } return RuntimeHelpers::equalHelper(left, right); diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h index 5cc8495..f62dfea 100644 --- a/src/qml/jsruntime/qv4scopedvalue_p.h +++ b/src/qml/jsruntime/qv4scopedvalue_p.h @@ -357,7 +357,7 @@ struct Scoped } T *operator->() { - return static_cast(ptr->managed()); + return ptr->cast(); } bool operator!() const { diff --git a/src/qml/jsruntime/qv4value_inl_p.h b/src/qml/jsruntime/qv4value_inl_p.h index 045eacc..7a6cdb4 100644 --- a/src/qml/jsruntime/qv4value_inl_p.h +++ b/src/qml/jsruntime/qv4value_inl_p.h @@ -56,13 +56,13 @@ inline bool Value::isString() const { if (!isManaged()) return false; - return managed() && managed()->internalClass()->vtable->isString; + return m && static_cast(m)->internalClass->vtable->isString; } inline bool Value::isObject() const { if (!isManaged()) return false; - return managed() && managed()->internalClass()->vtable->isObject; + return m && static_cast(m)->internalClass->vtable->isObject; } inline bool Value::isPrimitive() const diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index 9c6bd60..e87a900 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -329,6 +329,12 @@ struct Q_QML_PRIVATE_EXPORT Value inline ErrorObject *asErrorObject() const; template inline T *as() const; + template inline T *cast() { + return static_cast(managed()); + } + template inline const T *cast() const { + return static_cast(managed()); + } inline uint asArrayIndex() const; inline uint asArrayLength(bool *ok) const; -- 2.7.4