Convert ObjectIterator to new storage scheme
authorLars Knoll <lars.knoll@digia.com>
Tue, 29 Apr 2014 09:10:35 +0000 (11:10 +0200)
committerSimon Hausmann <simon.hausmann@digia.com>
Tue, 22 Jul 2014 11:49:03 +0000 (13:49 +0200)
Change-Id: I35631089e6791349ade08c6ed063f1e8ab1bdaea
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/qml/jsapi/qjsvalueiterator.cpp
src/qml/jsruntime/qv4objectiterator.cpp
src/qml/jsruntime/qv4objectiterator_p.h

index f186dde..7e2ea5d 100644 (file)
@@ -108,8 +108,8 @@ QJSValueIterator::QJSValueIterator(const QJSValue& object)
         return;
     QV4::Scope scope(v4);
     QV4::Scoped<QV4::ForEachIteratorObject> it(scope, d_ptr->iterator.value());
-    it->data.it.flags =  QV4::ObjectIterator::NoFlags;
-    it->data.it.next(d_ptr->nextName, &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes);
+    it->d()->it.flags =  QV4::ObjectIterator::NoFlags;
+    it->d()->it.next(d_ptr->nextName, &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes);
 }
 
 /*!
@@ -155,7 +155,7 @@ bool QJSValueIterator::next()
         return false;
     QV4::Scope scope(v4);
     QV4::Scoped<QV4::ForEachIteratorObject> it(scope, d_ptr->iterator.value());
-    it->data.it.next(d_ptr->nextName, &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes);
+    it->d()->it.next(d_ptr->nextName, &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes);
     return !!d_ptr->currentName || d_ptr->currentIndex != UINT_MAX;
 }
 
@@ -229,8 +229,8 @@ QJSValueIterator& QJSValueIterator::operator=(QJSValue& object)
     QV4::ScopedObject o(scope, jsp->value);
     d_ptr->iterator = v4->newForEachIteratorObject(v4->currentContext(), o)->asReturnedValue();
     QV4::Scoped<QV4::ForEachIteratorObject> it(scope, d_ptr->iterator.value());
-    it->data.it.flags =  QV4::ObjectIterator::NoFlags;
-    it->data.it.next(d_ptr->nextName, &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes);
+    it->d()->it.flags =  QV4::ObjectIterator::NoFlags;
+    it->d()->it.next(d_ptr->nextName, &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes);
     return *this;
 }
 
index e5f693c..b0219cd 100644 (file)
@@ -197,7 +197,7 @@ DEFINE_OBJECT_VTABLE(ForEachIteratorObject);
 void ForEachIteratorObject::markObjects(Managed *that, ExecutionEngine *e)
 {
     ForEachIteratorObject *o = static_cast<ForEachIteratorObject *>(that);
-    o->workArea[0].mark(e);
-    o->workArea[1].mark(e);
+    o->d()->workArea[0].mark(e);
+    o->d()->workArea[1].mark(e);
     Object::markObjects(that, e);
 }
index b914990..0590974 100644 (file)
@@ -83,29 +83,31 @@ struct Q_QML_EXPORT ObjectIterator
 };
 
 struct ForEachIteratorObject: Object {
-    V4_OBJECT
-    Q_MANAGED_TYPE(ForeachIteratorObject)
-    struct Data {
-        Data(Value *scratch1, Value *scratch2, const ObjectRef o, uint flags)
-            : it(scratch1, scratch2, o, flags) {}
-        Data(Scope &scope, const ObjectRef o, uint flags)
-            : it (scope, o, flags) {}
+    struct Data : Object::Data {
+        Data(const ObjectRef o, uint flags)
+            : it(workArea, workArea + 1, o, flags) {}
         ObjectIterator it;
+        Value workArea[2];
     };
-    Data data;
+    struct _Data {
+        _Data(const ObjectRef o, uint flags)
+            : it(workArea, workArea + 1, o, flags) {}
+        ObjectIterator it;
+        Value workArea[2];
+    } __data;
+    V4_OBJECT_NEW
+    Q_MANAGED_TYPE(ForeachIteratorObject)
 
     ForEachIteratorObject(ExecutionContext *ctx, const ObjectRef o)
-        : Object(ctx->engine), data(workArea, workArea + 1,
-                                    o, ObjectIterator::EnumerableOnly|ObjectIterator::WithProtoChain) {
+        : Object(ctx->engine)
+        , __data(o, ObjectIterator::EnumerableOnly|ObjectIterator::WithProtoChain) {
         setVTable(staticVTable());
     }
 
-    ReturnedValue nextPropertyName() { return data.it.nextPropertyNameAsString(); }
+    ReturnedValue nextPropertyName() { return d()->it.nextPropertyNameAsString(); }
 
 protected:
     static void markObjects(Managed *that, ExecutionEngine *e);
-
-    Value workArea[2];
 };