From d96478044ae0dfbcc35113e3941aa79604ba83a0 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 24 Jan 2014 22:13:06 +0100 Subject: Get rid of the SafeObject class Having SafeValue is enough, and we can pass an ObjectRef instead of a SafeObject * for function calls. Change-Id: I4e1435105403f8091b43eeda01303f9602c74235 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4objectiterator.cpp | 10 +++++----- src/qml/jsruntime/qv4objectiterator_p.h | 7 ++++--- src/qml/jsruntime/qv4scopedvalue_p.h | 11 +++++++++++ src/qml/jsruntime/qv4value_p.h | 1 - 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/qml/jsruntime/qv4objectiterator.cpp b/src/qml/jsruntime/qv4objectiterator.cpp index 0e35996710..707bea0c45 100644 --- a/src/qml/jsruntime/qv4objectiterator.cpp +++ b/src/qml/jsruntime/qv4objectiterator.cpp @@ -46,9 +46,9 @@ using namespace QV4; -ObjectIterator::ObjectIterator(SafeObject *scratch1, SafeObject *scratch2, const ObjectRef o, uint flags) - : object(*scratch1) - , current(*scratch2) +ObjectIterator::ObjectIterator(ObjectRef scratch1, ObjectRef scratch2, const ObjectRef o, uint flags) + : object(scratch1) + , current(scratch2) , arrayNode(0) , arrayIndex(0) , memberIndex(0) @@ -64,8 +64,8 @@ ObjectIterator::ObjectIterator(SafeObject *scratch1, SafeObject *scratch2, const } ObjectIterator::ObjectIterator(Scope &scope, const ObjectRef o, uint flags) - : object(*static_cast(scope.alloc(1))) - , current(*static_cast(scope.alloc(1))) + : object(ObjectRef::fromValuePointer(scope.alloc(1))) + , current(ObjectRef::fromValuePointer(scope.alloc(1))) , arrayNode(0) , arrayIndex(0) , memberIndex(0) diff --git a/src/qml/jsruntime/qv4objectiterator_p.h b/src/qml/jsruntime/qv4objectiterator_p.h index 08a740fc37..6d0b5fcc80 100644 --- a/src/qml/jsruntime/qv4objectiterator_p.h +++ b/src/qml/jsruntime/qv4objectiterator_p.h @@ -74,7 +74,7 @@ struct Q_QML_EXPORT ObjectIterator uint memberIndex; uint flags; - ObjectIterator(SafeObject *scratch1, SafeObject *scratch2, const ObjectRef o, uint flags); + ObjectIterator(ObjectRef scratch1, ObjectRef scratch2, const ObjectRef o, uint flags); ObjectIterator(Scope &scope, const ObjectRef o, uint flags); void next(StringRef name, uint *index, Property *pd, PropertyAttributes *attributes = 0); ReturnedValue nextPropertyName(ValueRef value); @@ -87,7 +87,8 @@ struct ForEachIteratorObject: Object { Q_MANAGED_TYPE(ForeachIteratorObject) ObjectIterator it; ForEachIteratorObject(ExecutionContext *ctx, const ObjectRef o) - : Object(ctx->engine), it(workArea, workArea + 1, o, ObjectIterator::EnumerableOnly|ObjectIterator::WithProtoChain) { + : Object(ctx->engine), it(ObjectRef::fromValuePointer(workArea), ObjectRef::fromValuePointer(workArea + 1), + o, ObjectIterator::EnumerableOnly|ObjectIterator::WithProtoChain) { setVTable(staticVTable()); } @@ -96,7 +97,7 @@ struct ForEachIteratorObject: Object { protected: static void markObjects(Managed *that, ExecutionEngine *e); - SafeObject workArea[2]; + SafeValue workArea[2]; }; diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h index 38431d2c44..37a61eb2fe 100644 --- a/src/qml/jsruntime/qv4scopedvalue_p.h +++ b/src/qml/jsruntime/qv4scopedvalue_p.h @@ -458,6 +458,9 @@ struct Referenced { Referenced(SafeValue &v) { ptr = value_cast(v) ? &v : 0; } + static Referenced fromValuePointer(SafeValue *s) { + return Referenced(s); + } Referenced &operator=(const Referenced &o) { *ptr = *o.ptr; return *this; } @@ -512,6 +515,14 @@ struct Referenced { static Referenced null() { return Referenced(Null); } bool isNull() const { return !ptr; } private: + Referenced(SafeValue *v) { + ptr = v; +#if QT_POINTER_SIZE == 8 + ptr->val = 0; +#else + *ptr = Value::fromManaged(0); +#endif + } enum _Null { Null }; Referenced(_Null) { ptr = 0; } SafeValue *ptr; diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index 4b16114174..2cc6a0b32b 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -456,7 +456,6 @@ struct Safe : public SafeValue void mark(ExecutionEngine *e) { if (managed()) managed()->mark(e); } }; typedef Safe SafeString; -typedef Safe SafeObject; template T *value_cast(const Value &v) -- cgit v1.2.3