diff options
author | Lars Knoll <lars.knoll@theqtcompany.com> | 2015-01-15 11:36:57 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@digia.com> | 2015-01-23 08:07:32 +0100 |
commit | 002a5d4303b3b182ae4abc4a752c49787c1c2821 (patch) | |
tree | 69c7666ed1061c7acacee1d76597c06405459c80 /src/qml/jsapi | |
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 <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsapi')
-rw-r--r-- | src/qml/jsapi/qjsvalue.cpp | 18 | ||||
-rw-r--r-- | src/qml/jsapi/qjsvalueiterator.cpp | 2 |
2 files changed, 10 insertions, 10 deletions
diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp index 5310b56af1..ac47e2b5c2 100644 --- a/src/qml/jsapi/qjsvalue.cpp +++ b/src/qml/jsapi/qjsvalue.cpp @@ -861,16 +861,16 @@ QJSValue& QJSValue::operator=(const QJSValue& other) return *this; } -static bool js_equal(const QString &string, QV4::ValueRef value) +static bool js_equal(const QString &string, const QV4::Value &value) { - if (value->isString()) - return string == value->stringValue()->toQString(); - if (value->isNumber()) - return RuntimeHelpers::stringToNumber(string) == value->asDouble(); - if (value->isBoolean()) - return RuntimeHelpers::stringToNumber(string) == double(value->booleanValue()); - if (value->isObject()) { - Scope scope(value->objectValue()->engine()); + if (value.isString()) + return string == value.stringValue()->toQString(); + if (value.isNumber()) + return RuntimeHelpers::stringToNumber(string) == value.asDouble(); + if (value.isBoolean()) + return RuntimeHelpers::stringToNumber(string) == double(value.booleanValue()); + if (value.isObject()) { + Scope scope(value.objectValue()->engine()); ScopedValue p(scope, RuntimeHelpers::toPrimitive(value, PREFERREDTYPE_HINT)); return js_equal(string, p); } diff --git a/src/qml/jsapi/qjsvalueiterator.cpp b/src/qml/jsapi/qjsvalueiterator.cpp index 6f78f71f48..968864fbc6 100644 --- a/src/qml/jsapi/qjsvalueiterator.cpp +++ b/src/qml/jsapi/qjsvalueiterator.cpp @@ -195,7 +195,7 @@ QJSValue QJSValueIterator::value() const if (!d_ptr->currentName && d_ptr->currentIndex == UINT_MAX) return QJSValue(); - QV4::ScopedValue v(scope, obj->getValue(obj, &d_ptr->currentProperty, d_ptr->currentAttributes)); + QV4::ScopedValue v(scope, obj->getValue(*obj, &d_ptr->currentProperty, d_ptr->currentAttributes)); if (scope.hasException()) { engine->catchException(); return QJSValue(); |