From 6a216bd820eddf64003bb525a849abe62a733807 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Sun, 26 Apr 2015 10:56:38 +0200 Subject: Get rid of StringValue usage in QJSValueIterator Change-Id: I86badf9944b335041d16423be9a5434d1098cbb0 Reviewed-by: Simon Hausmann --- src/qml/jsapi/qjsvalueiterator.cpp | 23 ++++++++++------------- src/qml/jsapi/qjsvalueiterator_p.h | 4 ++-- 2 files changed, 12 insertions(+), 15 deletions(-) (limited to 'src/qml/jsapi') diff --git a/src/qml/jsapi/qjsvalueiterator.cpp b/src/qml/jsapi/qjsvalueiterator.cpp index 1ee4121f5c..2b9de0124b 100644 --- a/src/qml/jsapi/qjsvalueiterator.cpp +++ b/src/qml/jsapi/qjsvalueiterator.cpp @@ -52,9 +52,6 @@ QJSValueIteratorPrivate::QJSValueIteratorPrivate(const QJSValue &v) QV4::Scope scope(e); QV4::ScopedObject o(scope, QJSValuePrivate::getValue(&v)); iterator.set(e, e->newForEachIteratorObject(o)); - - currentName = (QV4::String *)0; - nextName = (QV4::String *)0; } @@ -103,7 +100,7 @@ QJSValueIterator::QJSValueIterator(const QJSValue& object) it->d()->it.flags = QV4::ObjectIterator::NoFlags; QV4::ScopedString nm(scope); it->d()->it.next(nm.getRef(), &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes); - d_ptr->nextName = nm; + d_ptr->nextName.set(v4, nm.asReturnedValue()); } /*! @@ -125,7 +122,7 @@ bool QJSValueIterator::hasNext() const QV4::Value *val = QJSValuePrivate::getValue(&d_ptr->value); if (!val || !val->isObject()) return false; - return !!d_ptr->nextName || d_ptr->nextIndex != UINT_MAX; + return d_ptr->nextName.as() || d_ptr->nextIndex != UINT_MAX; } /*! @@ -153,8 +150,8 @@ bool QJSValueIterator::next() QV4::Scoped it(scope, d_ptr->iterator.value()); QV4::ScopedString nm(scope); it->d()->it.next(nm.getRef(), &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes); - d_ptr->nextName = nm; - return !!d_ptr->currentName || d_ptr->currentIndex != UINT_MAX; + d_ptr->nextName.set(v4, nm.asReturnedValue()); + return d_ptr->currentName.as() || d_ptr->currentIndex != UINT_MAX; } /*! @@ -168,8 +165,8 @@ QString QJSValueIterator::name() const QV4::Value *val = QJSValuePrivate::getValue(&d_ptr->value); if (!val || !val->isObject()) return QString(); - if (!!d_ptr->currentName) - return d_ptr->currentName->toQString(); + if (QV4::String *s = d_ptr->currentName.as()) + return s->toQString(); if (d_ptr->currentIndex < UINT_MAX) return QString::number(d_ptr->currentIndex); return QString(); @@ -192,7 +189,7 @@ QJSValue QJSValueIterator::value() const if (!obj) return QJSValue(); - if (!d_ptr->currentName && d_ptr->currentIndex == UINT_MAX) + if (!d_ptr->currentName.as() && d_ptr->currentIndex == UINT_MAX) return QJSValue(); QV4::ScopedValue v(scope, obj->getValue(*obj, &d_ptr->currentProperty, d_ptr->currentAttributes)); @@ -214,8 +211,8 @@ QJSValueIterator& QJSValueIterator::operator=(QJSValue& object) d_ptr->value = object; d_ptr->currentIndex = UINT_MAX; d_ptr->nextIndex = UINT_MAX; - d_ptr->currentName = (QV4::String *)0; - d_ptr->nextName = (QV4::String *)0; + d_ptr->currentName.clear(); + d_ptr->nextName.clear(); QV4::ExecutionEngine *v4 = d_ptr->iterator.engine(); if (!v4) { d_ptr->iterator.clear(); @@ -229,7 +226,7 @@ QJSValueIterator& QJSValueIterator::operator=(QJSValue& object) it->d()->it.flags = QV4::ObjectIterator::NoFlags; QV4::ScopedString nm(scope); it->d()->it.next(nm.getRef(), &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes); - d_ptr->nextName = nm; + d_ptr->nextName.set(v4, nm.asReturnedValue()); return *this; } diff --git a/src/qml/jsapi/qjsvalueiterator_p.h b/src/qml/jsapi/qjsvalueiterator_p.h index c17fedf73e..0f5f98dd86 100644 --- a/src/qml/jsapi/qjsvalueiterator_p.h +++ b/src/qml/jsapi/qjsvalueiterator_p.h @@ -51,12 +51,12 @@ public: // ### GC QV4::Property currentProperty; QV4::PropertyAttributes currentAttributes; - QV4::StringValue currentName; + QV4::PersistentValue currentName; uint currentIndex; // ### GC QV4::Property nextProperty; QV4::PropertyAttributes nextAttributes; - QV4::StringValue nextName; + QV4::PersistentValue nextName; uint nextIndex; }; -- cgit v1.2.3