Convert v8::Array usage in particles to V4
authorSimon Hausmann <simon.hausmann@digia.com>
Wed, 12 Jun 2013 13:02:42 +0000 (15:02 +0200)
committerLars Knoll <lars.knoll@digia.com>
Wed, 12 Jun 2013 13:56:12 +0000 (15:56 +0200)
Change-Id: Ib3c39903bf8f8507d68f94baea81b3bf642ce8f6
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/particles/qquickcustomaffector.cpp
src/particles/qquickparticleemitter.cpp
src/particles/qquicktrailemitter.cpp

index 37db984..40d0df1 100644 (file)
@@ -143,13 +143,16 @@ void QQuickCustomAffector::affectSystem(qreal dt)
     if (m_onceOff)
         dt = 1.0;
 
-    v8::Handle<v8::Array> array = v8::Array::New(toAffect.size());
+    QQmlEngine *qmlEngine = ::qmlEngine(this);
+    QV4::ExecutionEngine *v4 = QV8Engine::getV4(qmlEngine->handle());
+
+    QV4::ArrayObject *array = v4->newArrayObject(toAffect.size());
     for (int i=0; i<toAffect.size(); i++)
-        array->Set(i, toAffect[i]->v4Value().toValue());
+        array->putIndexed(i, toAffect[i]->v4Value().toValue());
 
     if (dt >= simulationCutoff || dt <= simulationDelta) {
         affectProperties(toAffect, dt);
-        emit affectParticles(QQmlV4Handle(array->v4Value()), dt);
+        emit affectParticles(QQmlV4Handle(QV4::Value::fromObject(array)), dt);
     } else {
         int realTime = m_system->timeInt;
         m_system->timeInt -= dt * 1000.0;
@@ -157,12 +160,12 @@ void QQuickCustomAffector::affectSystem(qreal dt)
             m_system->timeInt += simulationDelta * 1000.0;
             dt -= simulationDelta;
             affectProperties(toAffect, simulationDelta);
-            emit affectParticles(QQmlV4Handle(array->v4Value()), simulationDelta);
+            emit affectParticles(QQmlV4Handle(QV4::Value::fromObject(array)), simulationDelta);
         }
         m_system->timeInt = realTime;
         if (dt > 0.0) {
             affectProperties(toAffect, dt);
-            emit affectParticles(QQmlV4Handle(array->v4Value()), dt);
+            emit affectParticles(QQmlV4Handle(QV4::Value::fromObject(array)), dt);
         }
     }
 
index 630565f..cc410fb 100644 (file)
@@ -477,13 +477,16 @@ void QQuickParticleEmitter::emitWindow(int timeStamp)
             m_system->emitParticle(d);
 
     if (isEmitConnected()) {
+        QQmlEngine *qmlEngine = ::qmlEngine(this);
+        QV4::ExecutionEngine *v4 = QV8Engine::getV4(qmlEngine->handle());
+
         //Done after emitParticle so that the Painter::load is done first, this allows you to customize its static variables
         //We then don't need to request another reload, because the first reload isn't scheduled until we get back to the render thread
-        v8::Handle<v8::Array> array = v8::Array::New(toEmit.size());
+        QV4::ArrayObject *array = v4->newArrayObject(toEmit.size());
         for (int i=0; i<toEmit.size(); i++)
-            array->Set(i, toEmit[i]->v4Value().toValue());
+            array->putIndexed(i, toEmit[i]->v4Value().toValue());
 
-        emitParticles(QQmlV4Handle(array->v4Value()));//A chance for arbitrary JS changes
+        emitParticles(QQmlV4Handle(QV4::Value::fromObject(array)));//A chance for arbitrary JS changes
     }
 
     m_last_emission = pt;
index 85cc23c..4f4a05d 100644 (file)
@@ -269,14 +269,17 @@ void QQuickTrailEmitter::emitWindow(int timeStamp)
             m_system->emitParticle(d);
 
         if (isEmitConnected() || isEmitFollowConnected()) {
-            v8::Handle<v8::Array> array = v8::Array::New(toEmit.size());
+            QQmlEngine *qmlEngine = ::qmlEngine(this);
+            QV4::ExecutionEngine *v4 = QV8Engine::getV4(qmlEngine->handle());
+
+            QV4::ArrayObject *array = v4->newArrayObject(toEmit.size());
             for (int i=0; i<toEmit.size(); i++)
-                array->Set(i, toEmit[i]->v4Value().toValue());
+                array->putIndexed(i, toEmit[i]->v4Value().toValue());
 
             if (isEmitFollowConnected())
-                emitFollowParticles(QQmlV4Handle(array->v4Value()), d->v4Value());//A chance for many arbitrary JS changes
+                emitFollowParticles(QQmlV4Handle(QV4::Value::fromObject(array)), d->v4Value());//A chance for many arbitrary JS changes
             else if (isEmitConnected())
-                emitParticles(QQmlV4Handle(array->v4Value()));//A chance for arbitrary JS changes
+                emitParticles(QQmlV4Handle(QV4::Value::fromObject(array)));//A chance for arbitrary JS changes
         }
         m_lastEmission[d->index] = pt;
     }