Remove v8engine from qmlcomponent and canvas2d
authorLars Knoll <lars.knoll@theqtcompany.com>
Wed, 31 Dec 2014 15:03:34 +0000 (16:03 +0100)
committerSimon Hausmann <simon.hausmann@digia.com>
Thu, 8 Jan 2015 21:09:23 +0000 (22:09 +0100)
Change-Id: I575ba208de24ffe90bd02905aba67b0b08c5115e
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/qml/jsruntime/qv4sequenceobject.cpp
src/qml/qml/qqmlcomponent.cpp
src/qml/qml/qqmltypewrapper.cpp
src/quick/items/context2d/qquickcanvascontext_p.h
src/quick/items/context2d/qquickcanvasitem.cpp
src/quick/items/context2d/qquickcontext2d.cpp
src/quick/items/context2d/qquickcontext2d_p.h

index fa6af45..a60a446 100644 (file)
@@ -51,7 +51,7 @@ using namespace QV4;
 // helper function to generate valid warnings if errors occur during sequence operations.
 static void generateWarning(QV4::ExecutionEngine *v4, const QString& description)
 {
-    QQmlEngine *engine = v4->v8Engine->engine();
+    QQmlEngine *engine = v4->qmlEngine();
     if (!engine)
         return;
     QQmlError retn;
index 96623f2..fd43898 100644 (file)
@@ -1075,9 +1075,8 @@ namespace QV4 {
 namespace Heap {
 
 struct QmlIncubatorObject : Object {
-    QmlIncubatorObject(QV8Engine *engine, QQmlIncubator::IncubationMode = QQmlIncubator::Asynchronous);
+    QmlIncubatorObject(QV4::ExecutionEngine *engine, QQmlIncubator::IncubationMode = QQmlIncubator::Asynchronous);
     QScopedPointer<QQmlComponentIncubator> incubator;
-    QV8Engine *v8;
     QPointer<QObject> parent;
     QV4::Value valuemap;
     QV4::Value qmlGlobal;
@@ -1363,7 +1362,7 @@ void QQmlComponent::incubateObject(QQmlV4Function *args)
 
     QQmlComponentExtension *e = componentExtension(args->v4engine());
 
-    QV4::Scoped<QV4::QmlIncubatorObject> r(scope, v4->memoryManager->alloc<QV4::QmlIncubatorObject>(args->v4engine()->v8Engine, mode));
+    QV4::Scoped<QV4::QmlIncubatorObject> r(scope, v4->memoryManager->alloc<QV4::QmlIncubatorObject>(args->v4engine(), mode));
     QV4::ScopedObject p(scope, e->incubationProto.value());
     r->setPrototype(p);
 
@@ -1387,8 +1386,7 @@ void QQmlComponent::incubateObject(QQmlV4Function *args)
 void QQmlComponentPrivate::initializeObjectWithInitialProperties(const QV4::ValueRef qmlGlobal, const QV4::ValueRef valuemap, QObject *toCreate)
 {
     QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);
-    QV8Engine *v8engine = ep->v8engine();
-    QV4::ExecutionEngine *v4engine = QV8Engine::getV4(v8engine);
+    QV4::ExecutionEngine *v4engine = QV8Engine::getV4(ep->v8engine());
     QV4::Scope scope(v4engine);
 
     QV4::ScopedValue object(scope, QV4::QObjectWrapper::wrap(v4engine, toCreate));
@@ -1396,8 +1394,8 @@ void QQmlComponentPrivate::initializeObjectWithInitialProperties(const QV4::Valu
 
     if (!valuemap->isUndefined()) {
         QV4::ScopedObject qmlGlobalObj(scope, qmlGlobal);
-        QV4::ScopedFunctionObject  f(scope, QV4::Script::evaluate(QV8Engine::getV4(v8engine),
-                                                                    QString::fromLatin1(INITIALPROPERTIES_SOURCE), qmlGlobalObj));
+        QV4::ScopedFunctionObject f(scope, QV4::Script::evaluate(v4engine,
+                                                                 QString::fromLatin1(INITIALPROPERTIES_SOURCE), qmlGlobalObj));
         QV4::ScopedCallData callData(scope, 2);
         callData->thisObject = v4engine->globalObject();
         callData->args[0] = object;
@@ -1477,9 +1475,8 @@ QQmlComponentExtension::~QQmlComponentExtension()
 {
 }
 
-QV4::Heap::QmlIncubatorObject::QmlIncubatorObject(QV8Engine *engine, QQmlIncubator::IncubationMode m)
-    : QV4::Heap::Object(QV8Engine::getV4(engine))
-    , v8(engine)
+QV4::Heap::QmlIncubatorObject::QmlIncubatorObject(ExecutionEngine *engine, QQmlIncubator::IncubationMode m)
+    : QV4::Heap::Object(engine)
     , valuemap(QV4::Primitive::undefinedValue())
     , qmlGlobal(QV4::Primitive::undefinedValue())
     , statusChanged(QV4::Primitive::undefinedValue())
@@ -1494,7 +1491,7 @@ void QV4::QmlIncubatorObject::setInitialState(QObject *o)
     QQmlComponent_setQmlParent(o, d()->parent);
 
     if (!d()->valuemap.isUndefined()) {
-        QV4::ExecutionEngine *v4 = QV8Engine::getV4(d()->v8);
+        QV4::ExecutionEngine *v4 = engine();
         QV4::Scope scope(v4);
 
         QV4::ScopedFunctionObject f(scope, QV4::Script::evaluate(v4, QString::fromLatin1(INITIALPROPERTIES_SOURCE), d()->qmlGlobal.asObject()));
@@ -1517,7 +1514,7 @@ void QV4::QmlIncubatorObject::markObjects(QV4::Heap::Base *that, QV4::ExecutionE
 
 void QV4::QmlIncubatorObject::statusChanged(QQmlIncubator::Status s)
 {
-    QV4::Scope scope(QV8Engine::getV4(d()->v8));
+    QV4::Scope scope(engine());
     // hold the incubated object in a scoped value to prevent it's destruction before this method returns
     QV4::ScopedObject incubatedObject(scope, QV4::QObjectWrapper::wrap(scope.engine, d()->incubator->object()));
 
@@ -1535,7 +1532,7 @@ void QV4::QmlIncubatorObject::statusChanged(QQmlIncubator::Status s)
         f->call(callData);
         if (scope.hasException()) {
             QQmlError error = scope.engine->catchExceptionAsQmlError();
-            QQmlEnginePrivate::warning(QQmlEnginePrivate::get(d()->v8->engine()), error);
+            QQmlEnginePrivate::warning(QQmlEnginePrivate::get(scope.engine->qmlEngine()), error);
         }
     }
 }
index 6cdc83a..44bb30b 100644 (file)
@@ -238,8 +238,7 @@ void QmlTypeWrapper::put(Managed *m, String *name, const ValueRef value)
         return;
 
     QV4::Scope scope(v4);
-    QV8Engine *v8engine = v4->v8Engine;
-    QQmlContextData *context = v8engine->callingContext();
+    QQmlContextData *context = v4->v8Engine->callingContext();
 
     QQmlType *type = w->d()->type;
     if (type && !type->isSingleton() && w->d()->object) {
@@ -248,7 +247,7 @@ void QmlTypeWrapper::put(Managed *m, String *name, const ValueRef value)
         if (ao)
             QV4::QObjectWrapper::setQmlProperty(v4, context, ao, name, QV4::QObjectWrapper::IgnoreRevision, value);
     } else if (type && type->isSingleton()) {
-        QQmlEngine *e = v8engine->engine();
+        QQmlEngine *e = scope.engine->qmlEngine();
         QQmlType::SingletonInstanceInfo *siinfo = type->singletonInstanceInfo();
         siinfo->init(e);
 
index e036e0b..04b2aa9 100644 (file)
@@ -60,7 +60,7 @@ public:
     virtual void prepare(const QSize& canvasSize, const QSize& tileSize, const QRect& canvasWindow, const QRect& dirtyRect, bool smooth, bool antialiasing);
     virtual void flush();
 
-    virtual void setV8Engine(QV8Engine *engine) = 0;
+    virtual void setV4Engine(QV4::ExecutionEngine *engine) = 0;
     virtual QV4::ReturnedValue v4value() const = 0;
 
     virtual QImage toImage(const QRectF& bounds) = 0;
index c31b772..2688c72 100644 (file)
@@ -1142,7 +1142,7 @@ void QQuickCanvasItem::initializeContext(QQuickCanvasContext *context, const QVa
 
     d->context = context;
     d->context->init(this, args);
-    d->context->setV8Engine(QQmlEnginePrivate::getV8Engine(qmlEngine(this)));
+    d->context->setV4Engine(QQmlEnginePrivate::get(qmlEngine(this))->v4engine());
     connect(d->context, SIGNAL(textureChanged()), SLOT(update()));
     connect(d->context, SIGNAL(textureChanged()), SIGNAL(painted()));
     emit contextChanged();
index 5a4ce7e..a0fc283 100644 (file)
@@ -935,9 +935,8 @@ QV4::Heap::QQuickJSContext2DImageData::QQuickJSContext2DImageData(QV4::Execution
 
 DEFINE_OBJECT_VTABLE(QQuickJSContext2DImageData);
 
-static QV4::ReturnedValue qt_create_image_data(qreal w, qreal h, QV8Engine* engine, const QImage& image)
+static QV4::ReturnedValue qt_create_image_data(qreal w, qreal h, QV4::ExecutionEngine *v4, const QImage& image)
 {
-    QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine);
     QV4::Scope scope(v4);
     QQuickContext2DEngineData *ed = engineData(scope.engine);
     QV4::Scoped<QQuickJSContext2DPixelData> pixelData(scope, scope.engine->memoryManager->alloc<QQuickJSContext2DPixelData>(v4));
@@ -3188,8 +3187,6 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createImageData(QV4::CallC
     QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject.as<QQuickJSContext2D>());
     CHECK_CONTEXT(r)
 
-    QV8Engine *engine = scope.engine->v8Engine;
-
     if (ctx->d()->callData->argc == 1) {
         QV4::ScopedValue arg0(scope, ctx->d()->callData->args[0]);
         QV4::Scoped<QQuickJSContext2DImageData> imgData(scope, arg0);
@@ -3198,11 +3195,11 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createImageData(QV4::CallC
             if (pa) {
                 qreal w = pa->d()->image.width();
                 qreal h = pa->d()->image.height();
-                return qt_create_image_data(w, h, engine, QImage());
+                return qt_create_image_data(w, h, scope.engine, QImage());
             }
         } else if (arg0->isString()) {
             QImage image = r->d()->context->createPixmap(QUrl(arg0->toQStringNoThrow()))->image();
-            return qt_create_image_data(image.width(), image.height(), engine, image);
+            return qt_create_image_data(image.width(), image.height(), scope.engine, image);
         }
     } else if (ctx->d()->callData->argc == 2) {
         qreal w = ctx->d()->callData->args[0].toNumber();
@@ -3212,7 +3209,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createImageData(QV4::CallC
             V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "createImageData(): invalid arguments");
 
         if (w > 0 && h > 0)
-            return qt_create_image_data(w, h, engine, QImage());
+            return qt_create_image_data(w, h, scope.engine, QImage());
         else
             V4THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "createImageData(): invalid arguments");
     }
@@ -3229,7 +3226,6 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_getImageData(QV4::CallCont
     QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject.as<QQuickJSContext2D>());
     CHECK_CONTEXT(r)
 
-    QV8Engine *engine = scope.engine->v8Engine;
     if (ctx->d()->callData->argc >= 4) {
         qreal x = ctx->d()->callData->args[0].toNumber();
         qreal y = ctx->d()->callData->args[1].toNumber();
@@ -3242,7 +3238,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_getImageData(QV4::CallCont
             V4THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "getImageData(): Invalid arguments");
 
         QImage image = r->d()->context->canvas()->toImage(QRectF(x, y, w, h));
-        return qt_create_image_data(w, h, engine, image);
+        return qt_create_image_data(w, h, scope.engine, image);
     }
     return QV4::Encode::null();
 }
@@ -4014,7 +4010,7 @@ QMutex QQuickContext2D::mutex;
 QQuickContext2D::QQuickContext2D(QObject *parent)
     : QQuickCanvasContext(parent)
     , m_buffer(new QQuickContext2DCommandBuffer)
-    , m_v8engine(0)
+    , m_v4engine(0)
     , m_surface(0)
     , m_glContext(0)
     , m_thread(0)
@@ -4302,18 +4298,17 @@ void QQuickContext2D::reset()
     m_buffer->clearRect(QRectF(0, 0, m_canvas->width(), m_canvas->height()));
 }
 
-void QQuickContext2D::setV8Engine(QV8Engine *engine)
+void QQuickContext2D::setV4Engine(QV4::ExecutionEngine *engine)
 {
-    if (m_v8engine != engine) {
-        m_v8engine = engine;
+    if (m_v4engine != engine) {
+        m_v4engine = engine;
 
-        if (m_v8engine == 0)
+        if (m_v4engine == 0)
             return;
 
-        QQuickContext2DEngineData *ed = engineData(QV8Engine::getV4(engine));
-        QV4::ExecutionEngine *v4Engine = QV8Engine::getV4(engine);
-        QV4::Scope scope(v4Engine);
-        QV4::Scoped<QQuickJSContext2D> wrapper(scope, v4Engine->memoryManager->alloc<QQuickJSContext2D>(v4Engine));
+        QQuickContext2DEngineData *ed = engineData(engine);
+        QV4::Scope scope(engine);
+        QV4::Scoped<QQuickJSContext2D> wrapper(scope, engine->memoryManager->alloc<QQuickJSContext2D>(engine));
         QV4::ScopedObject p(scope, ed->contextPrototype.value());
         wrapper->setPrototype(p);
         wrapper->d()->context = this;
index dcfe6cf..9360489 100644 (file)
@@ -173,7 +173,7 @@ public:
     QImage toImage(const QRectF& bounds);
 
     QV4::ReturnedValue v4value() const;
-    void setV8Engine(QV8Engine *eng);
+    void setV4Engine(QV4::ExecutionEngine *eng);
 
     QQuickCanvasItem* canvas() const { return m_canvas; }
     QQuickContext2DCommandBuffer* buffer() const { return m_buffer; }
@@ -234,7 +234,7 @@ public:
     QV4::PersistentValue m_fillStyle;
     QV4::PersistentValue m_strokeStyle;
     QV4::PersistentValue m_v4path;
-    QV8Engine *m_v8engine;
+    QV4::ExecutionEngine *m_v4engine;
     QScopedPointer<QOffscreenSurface> m_surface;
     QOpenGLContext *m_glContext;
     QV4::PersistentValue m_v4value;