aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/v8/qv8engine_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-09-24 13:53:54 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-26 09:05:22 +0200
commit0f204625dc6720d40df22ca352af995af5448525 (patch)
treeedb78721935e2b0d34927b3dc358c3b171dc43b1 /src/qml/qml/v8/qv8engine_p.h
parenta57085f00b146798a0cca0d52dfa127232c3e659 (diff)
Fix QQmlV4Function API to be GC safe
Change-Id: Id4f79c22fc48ada1c8a9a858e1b7b3d1cf14d120 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml/v8/qv8engine_p.h')
-rw-r--r--src/qml/qml/v8/qv8engine_p.h33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/qml/qml/v8/qv8engine_p.h b/src/qml/qml/v8/qv8engine_p.h
index 90c4745d49..d7490036f3 100644
--- a/src/qml/qml/v8/qv8engine_p.h
+++ b/src/qml/qml/v8/qv8engine_p.h
@@ -125,28 +125,28 @@ class QV8Engine;
class QQmlV4Function
{
public:
- int length() const { return argc; }
- QV4::Value operator[](int idx) { return idx < argc ? args[idx] : QV4::Value::undefinedValue(); }
+ int length() const { return callData->argc; }
+ QV4::ReturnedValue operator[](int idx) { return (idx < callData->argc ? callData->args[idx] : QV4::Value::undefinedValue()).asReturnedValue(); }
QQmlContextData *context() { return ctx; }
- QV4::Value qmlGlobal() { return global; }
- void setReturnValue(const QV4::Value &rv) { *retVal = rv; }
- void setReturnValue(QV4::ReturnedValue rv) { *retVal = QV4::Value::fromReturnedValue(rv); }
+ QV4::ReturnedValue qmlGlobal() { return callData->thisObject.asReturnedValue(); }
+ void setReturnValue(QV4::ReturnedValue rv) { retVal = rv; }
QV8Engine *engine() const { return e; }
+ QV4::ExecutionEngine *v4engine() const;
private:
friend struct QV4::QObjectMethod;
QQmlV4Function();
QQmlV4Function(const QQmlV4Function &);
QQmlV4Function &operator=(const QQmlV4Function &);
- QQmlV4Function(int length, const QV4::Value *args,
- QV4::Value *rv, const QV4::Value &global,
- QQmlContextData *c, QV8Engine *e)
- : argc(length), args(args), retVal(rv), global(global), ctx(c), e(e) {}
+ QQmlV4Function(QV4::CallData *callData, QV4::ValueRef retVal,
+ const QV4::ValueRef global, QQmlContextData *c, QV8Engine *e)
+ : callData(callData), retVal(retVal), ctx(c), e(e)
+ {
+ callData->thisObject.val = global.asReturnedValue();
+ }
- int argc;
- const QV4::Value *args;
- QV4::Value *retVal;
- QV4::Value global;
+ QV4::CallData *callData;
+ QV4::ValueRef retVal;
QQmlContextData *ctx;
QV8Engine *e;
};
@@ -288,7 +288,7 @@ private:
Q_DISABLE_COPY(QV8Engine)
};
-QV8Engine::Deletable *QV8Engine::extensionData(int index) const
+inline QV8Engine::Deletable *QV8Engine::extensionData(int index) const
{
if (index < m_extensionData.count())
return m_extensionData[index];
@@ -296,6 +296,11 @@ QV8Engine::Deletable *QV8Engine::extensionData(int index) const
return 0;
}
+inline QV4::ExecutionEngine *QQmlV4Function::v4engine() const
+{
+ return QV8Engine::getV4(e);
+}
+
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QQmlV4Handle)