aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-05-08 16:22:39 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2013-05-08 19:57:01 +0200
commit995d65f3f4f348757363ba2a3a3c3444aa281b4e (patch)
treecae5c176847609abc33f51c065aa38b38cd6b9b9 /src/qml/qml
parent2b0d3bf812273e762e7aa27a58909ade59590c0f (diff)
Cleanup v8 dependencies from QQmlV8Function
... and rename it to QQmlV4Function Change-Id: Iad72347babf62691e26306877d4f229fda127eb7 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/qqmlcomponent.cpp38
-rw-r--r--src/qml/qml/qqmlcomponent.h6
-rw-r--r--src/qml/qml/v8/qv8engine_p.h41
-rw-r--r--src/qml/qml/v8/qv8qobjectwrapper.cpp11
4 files changed, 48 insertions, 48 deletions
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index 52777b023f..471d5fca8b 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -1177,7 +1177,7 @@ static void QQmlComponent_setQmlParent(QObject *me, QObject *parent)
/*!
\internal
*/
-void QQmlComponent::createObject(QQmlV8Function *args)
+void QQmlComponent::createObject(QQmlV4Function *args)
{
Q_D(QQmlComponent);
Q_ASSERT(d->engine);
@@ -1186,14 +1186,14 @@ void QQmlComponent::createObject(QQmlV8Function *args)
QObject *parent = 0;
v8::Handle<v8::Object> valuemap;
- if (args->Length() >= 1)
- parent = args->engine()->toQObject((*args)[0]->v4Value());
+ if (args->length() >= 1)
+ parent = args->engine()->toQObject((*args)[0]);
- if (args->Length() >= 2) {
+ if (args->length() >= 2) {
v8::Handle<v8::Value> v = (*args)[1];
if (!v->IsObject() || v->IsArray()) {
qmlInfo(this) << tr("createObject: value is not an object");
- args->returnValue(QV4::Value::nullValue());
+ args->setReturnValue(QV4::Value::nullValue());
return;
}
valuemap = v8::Handle<v8::Object>::Cast(v);
@@ -1208,7 +1208,7 @@ void QQmlComponent::createObject(QQmlV8Function *args)
QObject *rv = beginCreate(ctxt);
if (!rv) {
- args->returnValue(QV4::Value::nullValue());
+ args->setReturnValue(QV4::Value::nullValue());
return;
}
@@ -1220,7 +1220,7 @@ void QQmlComponent::createObject(QQmlV8Function *args)
if (!valuemap.IsEmpty()) {
QQmlComponentExtension *e = componentExtension(v8engine);
- QV4::Value f = v8engine->evaluateScript(QString::fromLatin1(INITIALPROPERTIES_SOURCE), args->qmlGlobal()->v4Value().asObject());
+ QV4::Value f = v8engine->evaluateScript(QString::fromLatin1(INITIALPROPERTIES_SOURCE), args->qmlGlobal().asObject());
QV4::Value args[] = { object->v4Value(), valuemap->v4Value() };
f.asFunctionObject()->call(v4engine->current, QV4::Value::fromObject(v4engine->globalObject), args, 2);
}
@@ -1232,9 +1232,9 @@ void QQmlComponent::createObject(QQmlV8Function *args)
QQmlData::get(rv)->indestructible = false;
if (!rv)
- args->returnValue(QV4::Value::nullValue());
+ args->setReturnValue(QV4::Value::nullValue());
else
- args->returnValue(object);
+ args->setReturnValue(object->v4Value());
}
/*!
@@ -1296,7 +1296,7 @@ void QQmlComponent::createObject(QQmlV8Function *args)
/*!
\internal
*/
-void QQmlComponent::incubateObject(QQmlV8Function *args)
+void QQmlComponent::incubateObject(QQmlV4Function *args)
{
Q_D(QQmlComponent);
Q_ASSERT(d->engine);
@@ -1307,23 +1307,23 @@ void QQmlComponent::incubateObject(QQmlV8Function *args)
v8::Handle<v8::Object> valuemap;
QQmlIncubator::IncubationMode mode = QQmlIncubator::Asynchronous;
- if (args->Length() >= 1)
- parent = args->engine()->toQObject((*args)[0]->v4Value());
+ if (args->length() >= 1)
+ parent = args->engine()->toQObject((*args)[0]);
- if (args->Length() >= 2) {
+ if (args->length() >= 2) {
v8::Handle<v8::Value> v = (*args)[1];
if (v->IsNull()) {
} else if (!v->IsObject() || v->IsArray()) {
qmlInfo(this) << tr("createObject: value is not an object");
- args->returnValue(QV4::Value::nullValue());
+ args->setReturnValue(QV4::Value::nullValue());
return;
} else {
valuemap = v8::Handle<v8::Object>::Cast(v);
}
}
- if (args->Length() >= 3) {
- quint32 v = (*args)[2]->Uint32Value();
+ if (args->length() >= 3) {
+ quint32 v = (*args)[2].toUInt32();
if (v == 0)
mode = QQmlIncubator::Asynchronous;
else if (v == 1)
@@ -1338,7 +1338,7 @@ void QQmlComponent::incubateObject(QQmlV8Function *args)
if (!valuemap.IsEmpty()) {
r->valuemap = valuemap->v4Value();
- r->qmlGlobal = args->qmlGlobal()->v4Value();
+ r->qmlGlobal = args->qmlGlobal();
}
r->parent = parent;
r->me = o->v4Value();
@@ -1347,9 +1347,9 @@ void QQmlComponent::incubateObject(QQmlV8Function *args)
if (r->status() == QQmlIncubator::Null) {
r->dispose();
- args->returnValue(QV4::Value::nullValue());
+ args->setReturnValue(QV4::Value::nullValue());
} else {
- args->returnValue(o);
+ args->setReturnValue(o->v4Value());
}
}
diff --git a/src/qml/qml/qqmlcomponent.h b/src/qml/qml/qqmlcomponent.h
index aefad475b4..9877f59fb6 100644
--- a/src/qml/qml/qqmlcomponent.h
+++ b/src/qml/qml/qqmlcomponent.h
@@ -56,7 +56,7 @@ class QByteArray;
class QQmlEngine;
class QQmlComponent;
class QQmlIncubator;
-class QQmlV8Function;
+class QQmlV4Function;
class QQmlCompiledData;
class QQmlComponentPrivate;
class QQmlComponentAttached;
@@ -120,8 +120,8 @@ Q_SIGNALS:
protected:
QQmlComponent(QQmlComponentPrivate &dd, QObject* parent);
- Q_INVOKABLE void createObject(QQmlV8Function *);
- Q_INVOKABLE void incubateObject(QQmlV8Function *);
+ Q_INVOKABLE void createObject(QQmlV4Function *);
+ Q_INVOKABLE void incubateObject(QQmlV4Function *);
private:
QQmlComponent(QQmlEngine *, QQmlCompiledData *, int, QObject *parent);
diff --git a/src/qml/qml/v8/qv8engine_p.h b/src/qml/qml/v8/qv8engine_p.h
index 9781375657..7473a71937 100644
--- a/src/qml/qml/v8/qv8engine_p.h
+++ b/src/qml/qml/v8/qv8engine_p.h
@@ -80,6 +80,7 @@
#include "qv8sequencewrapper_p.h"
#include "qv4jsonwrapper_p.h"
#include <private/qv4value_p.h>
+#include <private/qv4object_p.h>
QT_BEGIN_NAMESPACE
@@ -174,32 +175,32 @@ inline T *v8_resource_check(v8::Handle<v8::Object> object) {
// valid during the call. If the return value isn't set within myMethod(), the will return
// undefined.
class QV8Engine;
-class QQmlV8Function
+class QQmlV4Function
{
public:
- int Length() const { return _ac; }
- v8::Handle<v8::Value> operator[](int idx) { return (*_a)->Get(idx); }
- QQmlContextData *context() { return _c; }
- v8::Handle<v8::Object> qmlGlobal() { return *_g; }
- void returnValue(v8::Handle<v8::Value> rv) { *_r = rv; }
- QV8Engine *engine() const { return _e; }
+ int length() const { return argc; }
+ QV4::Value operator[](int idx) { return args.asObject()->getIndexed(idx); }
+ QQmlContextData *context() { return ctx; }
+ QV4::Value qmlGlobal() { return global; }
+ void setReturnValue(const QV4::Value &rv) { *retVal = rv; }
+ QV8Engine *engine() const { return e; }
private:
friend class QV8QObjectWrapper;
- QQmlV8Function();
- QQmlV8Function(const QQmlV8Function &);
- QQmlV8Function &operator=(const QQmlV8Function &);
+ QQmlV4Function();
+ QQmlV4Function(const QQmlV4Function &);
+ QQmlV4Function &operator=(const QQmlV4Function &);
- QQmlV8Function(int length, v8::Handle<v8::Object> &args,
- v8::Handle<v8::Value> &rv, v8::Handle<v8::Object> &global,
+ QQmlV4Function(int length, const QV4::Value &args,
+ QV4::Value *rv, const QV4::Value &global,
QQmlContextData *c, QV8Engine *e)
- : _ac(length), _a(&args), _r(&rv), _g(&global), _c(c), _e(e) {}
-
- int _ac;
- v8::Handle<v8::Object> *_a;
- v8::Handle<v8::Value> *_r;
- v8::Handle<v8::Object> *_g;
- QQmlContextData *_c;
- QV8Engine *_e;
+ : argc(length), args(args), retVal(rv), global(global), ctx(c), e(e) {}
+
+ int argc;
+ QV4::Value args;
+ QV4::Value *retVal;
+ QV4::Value global;
+ QQmlContextData *ctx;
+ QV8Engine *e;
};
class Q_QML_PRIVATE_EXPORT QQmlV4Handle
diff --git a/src/qml/qml/v8/qv8qobjectwrapper.cpp b/src/qml/qml/v8/qv8qobjectwrapper.cpp
index d998c25236..a0d866b6ac 100644
--- a/src/qml/qml/v8/qv8qobjectwrapper.cpp
+++ b/src/qml/qml/v8/qv8qobjectwrapper.cpp
@@ -2018,19 +2018,18 @@ QV4::Value QV8QObjectWrapper::Invoke(const v8::Arguments &args)
}
if (method.isV8Function()) {
- v8::Handle<v8::Value> rv;
- v8::Handle<v8::Object> qmlglobal = args[2]->ToObject();
+ QV4::Value rv = QV4::Value::undefinedValue();
+ v8::Handle<v8::Value> qmlglobal = args[2];
- QQmlV8Function func(argCount, arguments, rv, qmlglobal,
+ QQmlV4Function func(argCount, arguments->v4Value(), &rv, qmlglobal->v4Value(),
resource->engine->contextWrapper()->context(qmlglobal),
resource->engine);
- QQmlV8Function *funcptr = &func;
+ QQmlV4Function *funcptr = &func;
void *args[] = { 0, &funcptr };
QMetaObject::metacall(object, QMetaObject::InvokeMetaMethod, method.coreIndex, args);
- if (rv.IsEmpty()) return QV4::Value::undefinedValue();
- return rv->v4Value();
+ return rv;
}
CallArgs callArgs(argCount, &arguments);