diff options
author | Lars Knoll <[email protected]> | 2015-01-15 11:36:57 +0100 |
---|---|---|
committer | Lars Knoll <[email protected]> | 2015-01-23 08:07:32 +0100 |
commit | 002a5d4303b3b182ae4abc4a752c49787c1c2821 (patch) | |
tree | 69c7666ed1061c7acacee1d76597c06405459c80 /src/qml/jsruntime/qv4jsonobject.cpp | |
parent | fddc75e862032163af36d2282051758647b62d15 (diff) |
Get rid of most uses of ValueRef
Instead pass a const Value & into the functions
With our new inheritance structure, we can get rid of ValueRef
and instead simply pass a pointer to a Value again. Pointers to
Values are safe to use again now, as they are now guaranteed to
be in a place where the GC knows about them.
Change-Id: I44c606fde764db3993b8128fd6fb781d3a298e53
Reviewed-by: Simon Hausmann <[email protected]>
Diffstat (limited to 'src/qml/jsruntime/qv4jsonobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4jsonobject.cpp | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp index aa16b62716..ffeaa1b1db 100644 --- a/src/qml/jsruntime/qv4jsonobject.cpp +++ b/src/qml/jsruntime/qv4jsonobject.cpp @@ -752,8 +752,7 @@ QString Stringify::Str(const QString &key, ValueRef v) if (o) { if (!o->asFunctionObject()) { if (o->asArrayObject()) { - ScopedArrayObject a(scope, o); - return JA(a); + return JA(static_cast<ArrayObject *>(o.getPointer())); } else { return JO(o); } @@ -973,29 +972,28 @@ ReturnedValue JsonObject::fromJsonValue(ExecutionEngine *engine, const QJsonValu return Encode::undefined(); } -QJsonValue JsonObject::toJsonValue(const ValueRef value, - V4ObjectSet &visitedObjects) +QJsonValue JsonObject::toJsonValue(const Value &value, V4ObjectSet &visitedObjects) { - if (value->isNumber()) - return QJsonValue(value->toNumber()); - else if (value->isBoolean()) - return QJsonValue((bool)value->booleanValue()); - else if (value->isNull()) + if (value.isNumber()) + return QJsonValue(value.toNumber()); + else if (value.isBoolean()) + return QJsonValue((bool)value.booleanValue()); + else if (value.isNull()) return QJsonValue(QJsonValue::Null); - else if (value->isUndefined()) + else if (value.isUndefined()) return QJsonValue(QJsonValue::Undefined); - else if (value->isString()) - return QJsonValue(value->toQString()); + else if (value.isString()) + return QJsonValue(value.toQString()); - Q_ASSERT(value->isObject()); - Scope scope(value->asObject()->engine()); + Q_ASSERT(value.isObject()); + Scope scope(value.asObject()->engine()); ScopedArrayObject a(scope, value); if (a) return toJsonArray(a, visitedObjects); ScopedObject o(scope, value); if (o) return toJsonObject(o, visitedObjects); - return QJsonValue(value->toQString()); + return QJsonValue(value.toQString()); } QV4::ReturnedValue JsonObject::fromJsonObject(ExecutionEngine *engine, const QJsonObject &object) |