From 7b7297470cde5645b2ea1db4cec7ac4bec87c1a3 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 13 Feb 2015 10:02:28 +0100 Subject: Cleanup some of the casting code Get rid of value_cast, and move the Managed::as() method into Value. Change-Id: I440ac44ae77f4fda1a8a837383fe631f432f6532 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4scopedvalue_p.h | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'src/qml/jsruntime/qv4scopedvalue_p.h') diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h index 908248f0f0..b469567866 100644 --- a/src/qml/jsruntime/qv4scopedvalue_p.h +++ b/src/qml/jsruntime/qv4scopedvalue_p.h @@ -202,7 +202,7 @@ struct Scoped { enum _Convert { Convert }; - inline void setPointer(Managed *p) { + inline void setPointer(const Managed *p) { ptr->m = p ? p->m : 0; #if QT_POINTER_SIZE == 4 ptr->tag = QV4::Value::Managed_Type; @@ -225,7 +225,7 @@ struct Scoped Scoped(const Scope &scope, const Value &v) { ptr = scope.engine->jsStackTop++; - setPointer(value_cast(v)); + setPointer(v.as()); #ifndef QT_NO_DEBUG ++scope.size; #endif @@ -235,7 +235,7 @@ struct Scoped Value v; v = o; ptr = scope.engine->jsStackTop++; - setPointer(value_cast(v)); + setPointer(v.as()); #ifndef QT_NO_DEBUG ++scope.size; #endif @@ -243,7 +243,7 @@ struct Scoped Scoped(const Scope &scope, const ScopedValue &v) { ptr = scope.engine->jsStackTop++; - setPointer(value_cast(*v.ptr)); + setPointer(v.ptr->as()); #ifndef QT_NO_DEBUG ++scope.size; #endif @@ -261,7 +261,7 @@ struct Scoped Scoped(const Scope &scope, const Value *v) { ptr = scope.engine->jsStackTop++; - setPointer(v ? value_cast(*v) : 0); + setPointer(v ? v->as() : 0); #ifndef QT_NO_DEBUG ++scope.size; #endif @@ -287,7 +287,7 @@ struct Scoped Scoped(const Scope &scope, const ReturnedValue &v) { ptr = scope.engine->jsStackTop++; - setPointer(value_cast(QV4::Value::fromReturnedValue(v))); + setPointer(QV4::Value::fromReturnedValue(v).as()); #ifndef QT_NO_DEBUG ++scope.size; #endif @@ -302,9 +302,7 @@ struct Scoped } Scoped &operator=(Heap::Base *o) { - Value v; - v = o; - setPointer(value_cast(v)); + setPointer(Value::fromHeapObject(o).as()); return *this; } Scoped &operator=(typename T::Data *t) { @@ -312,16 +310,16 @@ struct Scoped return *this; } Scoped &operator=(const Value &v) { - setPointer(value_cast(v)); + setPointer(v.as()); return *this; } Scoped &operator=(Value *v) { - setPointer(v ? value_cast(*v) : 0); + setPointer(v ? v->as() : 0); return *this; } Scoped &operator=(const ReturnedValue &v) { - setPointer(value_cast(QV4::Value::fromReturnedValue(v))); + setPointer(QV4::Value::fromReturnedValue(v).as()); return *this; } -- cgit v1.2.3