aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2014-01-24 22:13:06 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-31 11:13:48 +0100
commitd96478044ae0dfbcc35113e3941aa79604ba83a0 (patch)
treebe3950a5ae4e5b241c33c74e3b1bc88ccc683213
parent28f422ebf516aefb34f1602aeef8f87432cc4fb9 (diff)
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 <simon.hausmann@digia.com>
-rw-r--r--src/qml/jsruntime/qv4objectiterator.cpp10
-rw-r--r--src/qml/jsruntime/qv4objectiterator_p.h7
-rw-r--r--src/qml/jsruntime/qv4scopedvalue_p.h11
-rw-r--r--src/qml/jsruntime/qv4value_p.h1
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<SafeObject *>(scope.alloc(1)))
- , current(*static_cast<SafeObject *>(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<T>(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<String> SafeString;
-typedef Safe<Object> SafeObject;
template<typename T>
T *value_cast(const Value &v)