Move data for objects in QtQuick into the Heap namespace
authorLars Knoll <lars.knoll@theqtcompany.com>
Fri, 7 Nov 2014 02:13:29 +0000 (03:13 +0100)
committerSimon Hausmann <simon.hausmann@digia.com>
Tue, 11 Nov 2014 02:10:59 +0000 (03:10 +0100)
Change-Id: Ic9d5946a8e60d235b8442b964dd1478363626441
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/quick/items/context2d/qquickcontext2d.cpp
src/quick/items/qquickview.cpp
src/quick/items/qquickview_p.h
src/quick/items/qquickwindowmodule.cpp

index ed95506..99e3d09 100644 (file)
@@ -473,18 +473,45 @@ public:
 
 V8_DEFINE_EXTENSION(QQuickContext2DEngineData, engineData)
 
+namespace QV4 {
+namespace Heap {
+
+struct QQuickJSContext2D : Object {
+    QQuickJSContext2D(QV4::ExecutionEngine *engine);
+    QQuickContext2D* context;
+};
+
+struct QQuickJSContext2DPrototype : Object {
+    QQuickJSContext2DPrototype(ExecutionEngine *e)
+        : Object(e) {}
+};
+
+struct QQuickContext2DStyle : Object {
+    QQuickContext2DStyle(QV4::ExecutionEngine *e);
+
+    QBrush brush;
+    bool patternRepeatX:1;
+    bool patternRepeatY:1;
+};
+
+struct QQuickJSContext2DPixelData : Object {
+    QQuickJSContext2DPixelData(QV4::ExecutionEngine *engine);
+
+    QImage image;
+};
+
+struct QQuickJSContext2DImageData : Object {
+    QQuickJSContext2DImageData(QV4::ExecutionEngine *engine);
+
+    QV4::Value pixelData;
+};
+
+}
+}
 
 struct QQuickJSContext2D : public QV4::Object
 {
-    struct Data : QV4::Heap::Object {
-         Data(QV4::ExecutionEngine *engine)
-             : QV4::Heap::Object(engine)
-         {
-             setVTable(staticVTable());
-         }
-        QQuickContext2D* context;
-    };
-    V4_OBJECT(QV4::Object)
+    V4_OBJECT2(QQuickJSContext2D, QV4::Object)
 
     static QV4::ReturnedValue method_get_globalAlpha(QV4::CallContext *ctx);
     static QV4::ReturnedValue method_set_globalAlpha(QV4::CallContext *ctx);
@@ -527,12 +554,18 @@ struct QQuickJSContext2D : public QV4::Object
     static QV4::ReturnedValue method_set_textBaseline(QV4::CallContext *ctx);
 };
 
+QV4::Heap::QQuickJSContext2D::QQuickJSContext2D(QV4::ExecutionEngine *engine)
+    : QV4::Heap::Object(engine)
+{
+    setVTable(::QQuickJSContext2D::staticVTable());
+}
+
 DEFINE_OBJECT_VTABLE(QQuickJSContext2D);
 
 
 struct QQuickJSContext2DPrototype : public QV4::Object
 {
-    V4_OBJECT(QV4::Object)
+    V4_OBJECT2(QQuickJSContext2DPrototype, QV4::Object)
 public:
     static QQuickJSContext2DPrototype *create(QV4::ExecutionEngine *engine)
     {
@@ -639,19 +672,7 @@ DEFINE_OBJECT_VTABLE(QQuickJSContext2DPrototype);
 
 struct QQuickContext2DStyle : public QV4::Object
 {
-    struct Data : QV4::Heap::Object {
-        Data(QV4::ExecutionEngine *e)
-          : QV4::Heap::Object(e)
-        {
-            patternRepeatX = false;
-            patternRepeatY = false;
-            setVTable(staticVTable());
-        }
-        QBrush brush;
-        bool patternRepeatX:1;
-        bool patternRepeatY:1;
-    };
-    V4_OBJECT(QV4::Object)
+    V4_OBJECT2(QQuickContext2DStyle, QV4::Object)
 
     static QV4::ReturnedValue gradient_proto_addColorStop(QV4::CallContext *ctx);
 protected:
@@ -661,6 +682,14 @@ protected:
     }
 };
 
+QV4::Heap::QQuickContext2DStyle::QQuickContext2DStyle(QV4::ExecutionEngine *e)
+  : QV4::Heap::Object(e)
+{
+    patternRepeatX = false;
+    patternRepeatY = false;
+    setVTable(::QQuickContext2DStyle::staticVTable());
+}
+
 DEFINE_OBJECT_VTABLE(QQuickContext2DStyle);
 
 QImage qt_image_convolute_filter(const QImage& src, const QVector<qreal>& weights, int radius = 0)
@@ -860,18 +889,7 @@ static QString qt_composite_mode_to_string(QPainter::CompositionMode op)
 
 struct QQuickJSContext2DPixelData : public QV4::Object
 {
-    struct Data : QV4::Heap::Object {
-        Data(QV4::ExecutionEngine *engine)
-            : QV4::Heap::Object(engine)
-        {
-            setVTable(staticVTable());
-            QV4::Scope scope(engine);
-            QV4::ScopedObject o(scope, this);
-            o->setArrayType(QV4::Heap::ArrayData::Custom);
-        }
-        QImage image;
-    };
-    V4_OBJECT(QV4::Object)
+    V4_OBJECT2(QQuickJSContext2DPixelData, QV4::Object)
 
     static void destroy(QV4::Managed *that) {
         static_cast<QQuickJSContext2DPixelData *>(that)->d()->~Data();
@@ -882,27 +900,20 @@ struct QQuickJSContext2DPixelData : public QV4::Object
     static QV4::ReturnedValue proto_get_length(QV4::CallContext *ctx);
 };
 
+QV4::Heap::QQuickJSContext2DPixelData::QQuickJSContext2DPixelData(QV4::ExecutionEngine *engine)
+    : QV4::Heap::Object(engine)
+{
+    setVTable(::QQuickJSContext2DPixelData::staticVTable());
+    QV4::Scope scope(engine);
+    QV4::ScopedObject o(scope, this);
+    o->setArrayType(QV4::Heap::ArrayData::Custom);
+}
+
 DEFINE_OBJECT_VTABLE(QQuickJSContext2DPixelData);
 
 struct QQuickJSContext2DImageData : public QV4::Object
 {
-    struct Data : QV4::Heap::Object {
-        Data(QV4::ExecutionEngine *engine)
-            : QV4::Heap::Object(engine)
-        {
-            setVTable(staticVTable());
-            pixelData = QV4::Primitive::undefinedValue();
-
-            QV4::Scope scope(engine);
-            QV4::ScopedObject o(scope, this);
-
-            o->defineAccessorProperty(QStringLiteral("width"), method_get_width, 0);
-            o->defineAccessorProperty(QStringLiteral("height"), method_get_height, 0);
-            o->defineAccessorProperty(QStringLiteral("data"), method_get_data, 0);
-        }
-        QV4::Value pixelData;
-    };
-    V4_OBJECT(QV4::Object)
+    V4_OBJECT2(QQuickJSContext2DImageData, QV4::Object)
 
     static QV4::ReturnedValue method_get_width(QV4::CallContext *ctx);
     static QV4::ReturnedValue method_get_height(QV4::CallContext *ctx);
@@ -914,6 +925,20 @@ struct QQuickJSContext2DImageData : public QV4::Object
     }
 };
 
+QV4::Heap::QQuickJSContext2DImageData::QQuickJSContext2DImageData(QV4::ExecutionEngine *engine)
+    : QV4::Heap::Object(engine)
+{
+    setVTable(::QQuickJSContext2DImageData::staticVTable());
+    pixelData = QV4::Primitive::undefinedValue();
+
+    QV4::Scope scope(engine);
+    QV4::ScopedObject o(scope, this);
+
+    o->defineAccessorProperty(QStringLiteral("width"), ::QQuickJSContext2DImageData::method_get_width, 0);
+    o->defineAccessorProperty(QStringLiteral("height"), ::QQuickJSContext2DImageData::method_get_height, 0);
+    o->defineAccessorProperty(QStringLiteral("data"), ::QQuickJSContext2DImageData::method_get_data, 0);
+}
+
 DEFINE_OBJECT_VTABLE(QQuickJSContext2DImageData);
 
 static QV4::ReturnedValue qt_create_image_data(qreal w, qreal h, QV8Engine* engine, const QImage& image)
index 907d568..004880b 100644 (file)
 
 QT_BEGIN_NAMESPACE
 
-DEFINE_OBJECT_VTABLE(QQuickRootItemMarker);
+DEFINE_OBJECT_VTABLE(QV4::QQuickRootItemMarker);
 
-QV4::Returned<QQuickRootItemMarker> *QQuickRootItemMarker::create(QQmlEngine *engine, QQuickWindow *window)
+QV4::Returned<QV4::QQuickRootItemMarker> *QV4::QQuickRootItemMarker::create(QQmlEngine *engine, QQuickWindow *window)
 {
     QV4::ExecutionEngine *e = QQmlEnginePrivate::getV4Engine(engine);
     return e->memoryManager->alloc<QQuickRootItemMarker>(e, window);
 }
 
-void QQuickRootItemMarker::markObjects(QV4::Heap::Base *that, QV4::ExecutionEngine *e)
+void QV4::QQuickRootItemMarker::markObjects(QV4::Heap::Base *that, QV4::ExecutionEngine *e)
 {
     QQuickItem *root = static_cast<QQuickRootItemMarker::Data *>(that)->window->contentItem();
     if (root) {
@@ -82,7 +82,7 @@ void QQuickViewPrivate::init(QQmlEngine* e)
     {
         QV4::ExecutionEngine *v4 = QQmlEnginePrivate::getV4Engine(engine.data());
         QV4::Scope scope(v4);
-        QV4::Scoped<QQuickRootItemMarker> v(scope, QQuickRootItemMarker::create(engine.data(), q));
+        QV4::Scoped<QV4::QQuickRootItemMarker> v(scope, QV4::QQuickRootItemMarker::create(engine.data(), q));
         rootItemMarker = v;
     }
 
index c1b018b..f192711 100644 (file)
@@ -94,19 +94,20 @@ public:
     QV4::PersistentValue rootItemMarker;
 };
 
-struct QQuickRootItemMarker : public QV4::Object
+namespace QV4 {
+namespace Heap {
+
+struct QQuickRootItemMarker : Object {
+    inline QQuickRootItemMarker(QV4::ExecutionEngine *engine, QQuickWindow *window);
+
+    QQuickWindow *window;
+};
+
+}
+
+struct QQuickRootItemMarker : public Object
 {
-    struct Data : QV4::Heap::Object {
-        Data(QV4::ExecutionEngine *engine, QQuickWindow *window)
-            : QV4::Heap::Object(engine)
-            , window(window)
-        {
-            setVTable(staticVTable());
-        }
-
-        QQuickWindow *window;
-    };
-    V4_OBJECT(QV4::Object)
+    V4_OBJECT2(QQuickRootItemMarker, Object)
 
     static QV4::Returned<QQuickRootItemMarker> *create(QQmlEngine *engine, QQuickWindow *window);
 
@@ -114,6 +115,16 @@ struct QQuickRootItemMarker : public QV4::Object
 
 };
 
+inline
+Heap::QQuickRootItemMarker::QQuickRootItemMarker(QV4::ExecutionEngine *engine, QQuickWindow *window)
+    : Heap::Object(engine)
+    , window(window)
+{
+    setVTable(QV4::QQuickRootItemMarker::staticVTable());
+}
+
+}
+
 QT_END_NAMESPACE
 
 #endif // QQUICKVIEW_P_H
index bf41bc1..065c50c 100644 (file)
@@ -100,7 +100,7 @@ protected:
         {
             QV4::ExecutionEngine *v4 = QQmlEnginePrivate::getV4Engine(e);
             QV4::Scope scope(v4);
-            QV4::ScopedObject v(scope, QQuickRootItemMarker::create(e, this));
+            QV4::ScopedObject v(scope, QV4::QQuickRootItemMarker::create(e, this));
             rootItemMarker = v;
         }
     }