aboutsummaryrefslogtreecommitdiffstats
path: root/src/particles/qquickv4particledata.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/particles/qquickv4particledata.cpp')
-rw-r--r--src/particles/qquickv4particledata.cpp265
1 files changed, 0 insertions, 265 deletions
diff --git a/src/particles/qquickv4particledata.cpp b/src/particles/qquickv4particledata.cpp
index 7988259140..14b327d04a 100644
--- a/src/particles/qquickv4particledata.cpp
+++ b/src/particles/qquickv4particledata.cpp
@@ -3,7 +3,6 @@
#include <math.h>
#include "qquickv4particledata_p.h"
-#include "qquickparticlesystem_p.h"//for QQuickParticleData
#include <QDebug>
#include <private/qv4engine_p.h>
#include <private/qv4functionobject_p.h>
@@ -231,268 +230,4 @@ QT_BEGIN_NAMESPACE
The currentSize of the particle, interpolating between startSize and endSize based on the currentTime.
*/
-namespace QV4 {
-namespace Heap {
-struct QV4ParticleData : QV4::Object::Data {
- void init(QQuickParticleData *datum, QQuickParticleSystem* particleSystem)
- {
- Object::init();
- this->datum = datum;
- this->particleSystem = particleSystem;
- }
- QQuickParticleData* datum;//TODO: Guard needed?
- QQuickParticleSystem* particleSystem;
-};
-}
-}
-
-//### Particle data handles are not locked to within certain scopes like QQuickContext2D, but there's no way to reload either...
-struct QV4ParticleData : public QV4::Object
-{
- V4_OBJECT2(QV4ParticleData, QV4::Object)
-};
-
-DEFINE_OBJECT_VTABLE(QV4ParticleData);
-
-class QV4ParticleDataDeletable : public QV4::ExecutionEngine::Deletable
-{
-public:
- QV4ParticleDataDeletable(QV4::ExecutionEngine *engine);
- ~QV4ParticleDataDeletable() override;
-
- QV4::PersistentValue proto;
-};
-
-static QV4::ReturnedValue particleData_discard(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)
-{
- QV4::Scope scope(b);
- QV4::Scoped<QV4ParticleData> r(scope, *thisObject);
-
- if (!r || !r->d()->datum)
- RETURN_RESULT(scope.engine->throwError(QStringLiteral("Not a valid ParticleData object")));
-
- r->d()->datum->lifeSpan = 0; //Don't kill(), because it could still be in the middle of being created
- RETURN_RESULT(QV4::Encode::undefined());
-}
-
-static QV4::ReturnedValue particleData_lifeLeft(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)
-{
- QV4::Scope scope(b);
- QV4::Scoped<QV4ParticleData> r(scope, *thisObject);
-
- if (!r || !r->d()->datum)
- RETURN_RESULT(scope.engine->throwError(QStringLiteral("Not a valid ParticleData object")));
-
- RETURN_RESULT(QV4::Encode(r->d()->datum->lifeLeft(r->d()->particleSystem)));
-}
-
-static QV4::ReturnedValue particleData_curSize(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)
-{
- QV4::Scope scope(b);
- QV4::Scoped<QV4ParticleData> r(scope, *thisObject);
-
- if (!r || !r->d()->datum)
- RETURN_RESULT(scope.engine->throwError(QStringLiteral("Not a valid ParticleData object")));
-
- RETURN_RESULT(QV4::Encode(r->d()->datum->curSize(r->d()->particleSystem)));
-}
-#define COLOR_GETTER_AND_SETTER(VAR, NAME) static QV4::ReturnedValue particleData_get_ ## NAME (const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) \
-{ \
- QV4::Scope scope(b); \
- QV4::Scoped<QV4ParticleData> r(scope, *thisObject); \
- if (!r || !r->d()->datum) \
- RETURN_RESULT(scope.engine->throwError(QStringLiteral("Not a valid ParticleData object"))); \
-\
- RETURN_RESULT(QV4::Encode((r->d()->datum->color. VAR )/255.0));\
-}\
-\
-static QV4::ReturnedValue particleData_set_ ## NAME (const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)\
-{\
- QV4::Scope scope(b); \
- QV4::Scoped<QV4ParticleData> r(scope, *thisObject); \
- if (!r || !r->d()->datum)\
- RETURN_RESULT(scope.engine->throwError(QStringLiteral("Not a valid ParticleData object")));\
-\
- double d = argc ? argv[0].toNumber() : 0; \
- r->d()->datum->color. VAR = qMin(255, qMax(0, (int)::floor(d * 255.0)));\
- RETURN_UNDEFINED(); \
-}
-
-
-#define SEMIBOOL_GETTER_AND_SETTER(VARIABLE) static QV4::ReturnedValue particleData_get_ ## VARIABLE (const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) \
-{ \
- QV4::Scope scope(b); \
- QV4::Scoped<QV4ParticleData> r(scope, *thisObject); \
- if (!r || !r->d()->datum) \
- RETURN_RESULT(scope.engine->throwError(QStringLiteral("Not a valid ParticleData object"))); \
-\
- RETURN_RESULT(QV4::Encode(r->d()->datum-> VARIABLE));\
-}\
-\
-static QV4::ReturnedValue particleData_set_ ## VARIABLE (const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)\
-{\
- QV4::Scope scope(b); \
- QV4::Scoped<QV4ParticleData> r(scope, *thisObject); \
- if (!r || !r->d()->datum)\
- RETURN_RESULT(scope.engine->throwError(QStringLiteral("Not a valid ParticleData object")));\
-\
- r->d()->datum-> VARIABLE = (argc && argv[0].toBoolean()) ? 1.0 : 0.0;\
- RETURN_UNDEFINED(); \
-}
-
-#define FLOAT_GETTER_AND_SETTER(VARIABLE) static QV4::ReturnedValue particleData_get_ ## VARIABLE (const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) \
-{ \
- QV4::Scope scope(b); \
- QV4::Scoped<QV4ParticleData> r(scope, *thisObject); \
- if (!r || !r->d()->datum) \
- RETURN_RESULT(scope.engine->throwError(QStringLiteral("Not a valid ParticleData object"))); \
-\
- RETURN_RESULT(QV4::Encode(r->d()->datum-> VARIABLE));\
-}\
-\
-static QV4::ReturnedValue particleData_set_ ## VARIABLE (const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)\
-{\
- QV4::Scope scope(b); \
- QV4::Scoped<QV4ParticleData> r(scope, *thisObject); \
- if (!r || !r->d()->datum)\
- RETURN_RESULT(scope.engine->throwError(QStringLiteral("Not a valid ParticleData object")));\
-\
- r->d()->datum-> VARIABLE = argc ? argv[0].toNumber() : qt_qnan();\
- RETURN_UNDEFINED(); \
-}
-
-#define FAKE_FLOAT_GETTER_AND_SETTER(VARIABLE, GETTER, SETTER) static QV4::ReturnedValue particleData_get_ ## VARIABLE (const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) \
-{ \
- QV4::Scope scope(b); \
- QV4::Scoped<QV4ParticleData> r(scope, *thisObject); \
- if (!r || !r->d()->datum) \
- RETURN_RESULT(scope.engine->throwError(QStringLiteral("Not a valid ParticleData object"))); \
-\
- RETURN_RESULT(QV4::Encode(r->d()->datum-> GETTER (r->d()->particleSystem)));\
-}\
-\
-static QV4::ReturnedValue particleData_set_ ## VARIABLE (const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)\
-{\
- QV4::Scope scope(b); \
- QV4::Scoped<QV4ParticleData> r(scope, *thisObject); \
- if (!r || !r->d()->datum)\
- RETURN_RESULT(scope.engine->throwError(QStringLiteral("Not a valid ParticleData object")));\
-\
- r->d()->datum-> SETTER (argc ? argv[0].toNumber() : qt_qnan(), r->d()->particleSystem);\
- RETURN_UNDEFINED(); \
-}
-
-#define REGISTER_ACCESSOR(PROTO, ENGINE, VARIABLE, NAME) \
- PROTO ->defineAccessorProperty( QStringLiteral( #NAME ), particleData_get_ ## VARIABLE , particleData_set_ ## VARIABLE )
-
-COLOR_GETTER_AND_SETTER(r, red)
-COLOR_GETTER_AND_SETTER(g, green)
-COLOR_GETTER_AND_SETTER(b, blue)
-COLOR_GETTER_AND_SETTER(a, alpha)
-SEMIBOOL_GETTER_AND_SETTER(autoRotate)
-SEMIBOOL_GETTER_AND_SETTER(update)
-FLOAT_GETTER_AND_SETTER(x)
-FLOAT_GETTER_AND_SETTER(y)
-FLOAT_GETTER_AND_SETTER(t)
-FLOAT_GETTER_AND_SETTER(lifeSpan)
-FLOAT_GETTER_AND_SETTER(size)
-FLOAT_GETTER_AND_SETTER(endSize)
-FLOAT_GETTER_AND_SETTER(vx)
-FLOAT_GETTER_AND_SETTER(vy)
-FLOAT_GETTER_AND_SETTER(ax)
-FLOAT_GETTER_AND_SETTER(ay)
-FLOAT_GETTER_AND_SETTER(xx)
-FLOAT_GETTER_AND_SETTER(xy)
-FLOAT_GETTER_AND_SETTER(yx)
-FLOAT_GETTER_AND_SETTER(yy)
-FLOAT_GETTER_AND_SETTER(rotation)
-FLOAT_GETTER_AND_SETTER(rotationVelocity)
-FLOAT_GETTER_AND_SETTER(animIdx)
-FLOAT_GETTER_AND_SETTER(frameDuration)
-FLOAT_GETTER_AND_SETTER(frameAt)
-FLOAT_GETTER_AND_SETTER(frameCount)
-FLOAT_GETTER_AND_SETTER(animT)
-FAKE_FLOAT_GETTER_AND_SETTER(curX, curX, setInstantaneousX)
-FAKE_FLOAT_GETTER_AND_SETTER(curVX, curVX, setInstantaneousVX)
-FAKE_FLOAT_GETTER_AND_SETTER(curAX, curAX, setInstantaneousAX)
-FAKE_FLOAT_GETTER_AND_SETTER(curY, curY, setInstantaneousY)
-FAKE_FLOAT_GETTER_AND_SETTER(curVY, curVY, setInstantaneousVY)
-FAKE_FLOAT_GETTER_AND_SETTER(curAY, curAY, setInstantaneousAY)
-
-QV4ParticleDataDeletable::QV4ParticleDataDeletable(QV4::ExecutionEngine *v4)
-{
- QV4::Scope scope(v4);
- QV4::ScopedObject p(scope, v4->newObject());
-
- p->defineDefaultProperty(QStringLiteral("discard"), particleData_discard);
- p->defineDefaultProperty(QStringLiteral("lifeLeft"), particleData_lifeLeft);
- p->defineDefaultProperty(QStringLiteral("currentSize"), particleData_curSize);
-
- REGISTER_ACCESSOR(p, v4, x, initialX);
- REGISTER_ACCESSOR(p, v4, y, initialY);
- REGISTER_ACCESSOR(p, v4, t, t);
- REGISTER_ACCESSOR(p, v4, lifeSpan, lifeSpan);
- REGISTER_ACCESSOR(p, v4, size, startSize);
- REGISTER_ACCESSOR(p, v4, endSize, endSize);
- REGISTER_ACCESSOR(p, v4, vx, initialVX);
- REGISTER_ACCESSOR(p, v4, vy, initialVY);
- REGISTER_ACCESSOR(p, v4, ax, initialAX);
- REGISTER_ACCESSOR(p, v4, ay, initialAY);
- REGISTER_ACCESSOR(p, v4, xx, xDeformationVectorX);
- REGISTER_ACCESSOR(p, v4, xy, xDeformationVectorY);
- REGISTER_ACCESSOR(p, v4, yx, yDeformationVectorX);
- REGISTER_ACCESSOR(p, v4, yy, yDeformationVectorY);
- REGISTER_ACCESSOR(p, v4, rotation, rotation);
- REGISTER_ACCESSOR(p, v4, rotationVelocity, rotationVelocity);
- REGISTER_ACCESSOR(p, v4, autoRotate, autoRotate);
- REGISTER_ACCESSOR(p, v4, animIdx, animationIndex);
- REGISTER_ACCESSOR(p, v4, frameDuration, frameDuration);
- REGISTER_ACCESSOR(p, v4, frameAt, frameAt);
- REGISTER_ACCESSOR(p, v4, frameCount, frameCount);
- REGISTER_ACCESSOR(p, v4, animT, animationT);
- REGISTER_ACCESSOR(p, v4, update, update);
- REGISTER_ACCESSOR(p, v4, curX, x);
- REGISTER_ACCESSOR(p, v4, curVX, vx);
- REGISTER_ACCESSOR(p, v4, curAX, ax);
- REGISTER_ACCESSOR(p, v4, curY, y);
- REGISTER_ACCESSOR(p, v4, curVY, vy);
- REGISTER_ACCESSOR(p, v4, curAY, ay);
- REGISTER_ACCESSOR(p, v4, red, red);
- REGISTER_ACCESSOR(p, v4, green, green);
- REGISTER_ACCESSOR(p, v4, blue, blue);
- REGISTER_ACCESSOR(p, v4, alpha, alpha);
-
- proto = p;
-}
-
-QV4ParticleDataDeletable::~QV4ParticleDataDeletable()
-{
-}
-
-V4_DEFINE_EXTENSION(QV4ParticleDataDeletable, particleV4Data);
-
-
-QQuickV4ParticleData::QQuickV4ParticleData(QV4::ExecutionEngine* v4, QQuickParticleData* datum,
- QQuickParticleSystem *system)
-{
- if (!v4 || !datum)
- return;
-
- QV4::Scope scope(v4);
- QV4ParticleDataDeletable *d = particleV4Data(scope.engine);
- QV4::ScopedObject o(scope, v4->memoryManager->allocate<QV4ParticleData>(datum, system));
- QV4::ScopedObject p(scope, d->proto.value());
- o->setPrototypeUnchecked(p);
- m_v4Value = o;
-}
-
-QQuickV4ParticleData::~QQuickV4ParticleData()
-{
-}
-
-QV4::ReturnedValue QQuickV4ParticleData::v4Value() const
-{
- return m_v4Value.value();
-}
-
QT_END_NAMESPACE