Commit 19c6f620 authored by Lars Knoll's avatar Lars Knoll Committed by Simon Hausmann
Browse files

Convert some v8::Persistent to v4


Change-Id: Ic6613b020dbbb1ee75e2096707d8fb1aa228083d
Reviewed-by: default avatarSimon Hausmann <simon.hausmann@digia.com>
parent d8ef02be
dev 5.10 5.11 5.12 5.12.1 5.12.10 5.12.11 5.12.12 5.12.2 5.12.3 5.12.4 5.12.5 5.12.6 5.12.7 5.12.8 5.12.9 5.13 5.13.0 5.13.1 5.13.2 5.14 5.14.0 5.14.1 5.14.2 5.15 5.15.0 5.15.1 5.15.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 5.9.8 6.0 6.0.0 6.1 6.1.0 6.1.1 6.1.2 6.1.3 6.2 6.2.0 6.2.1 6.2.2 old/5.2 wip/cmake wip/dbus wip/gc wip/itemviews wip/nacl wip/new-backend wip/pointerhandler wip/propertycache-refactor wip/qquickdeliveryagent wip/scenegraphng wip/tizen wip/webassembly v5.15.0-alpha1 v5.14.1 v5.14.0 v5.14.0-rc2 v5.14.0-rc1 v5.14.0-beta3 v5.14.0-beta2 v5.14.0-beta1 v5.14.0-alpha1 v5.13.2 v5.13.1 v5.13.0 v5.13.0-rc3 v5.13.0-rc2 v5.13.0-rc1 v5.13.0-beta4 v5.13.0-beta3 v5.13.0-beta2 v5.13.0-beta1 v5.13.0-alpha1 v5.12.7 v5.12.6 v5.12.5 v5.12.4 v5.12.3 v5.12.2 v5.12.1 v5.12.0 v5.12.0-rc2 v5.12.0-rc1 v5.12.0-beta4 v5.12.0-beta3 v5.12.0-beta2 v5.12.0-beta1 v5.12.0-alpha1 v5.11.3 v5.11.2 v5.11.1 v5.11.0 v5.11.0-rc2 v5.11.0-rc1 v5.11.0-beta4 v5.11.0-beta3 v5.11.0-beta2 v5.11.0-beta1 v5.11.0-alpha1 v5.10.1 v5.10.0 v5.10.0-rc3 v5.10.0-rc2 v5.10.0-rc1 v5.10.0-beta4 v5.10.0-beta3 v5.10.0-beta2 v5.10.0-beta1 v5.10.0-alpha1 v5.9.9 v5.9.8 v5.9.7 v5.9.6 v5.9.5 v5.9.4 v5.9.3 v5.9.2 v5.9.1 v5.9.0 v5.9.0-rc2 v5.9.0-rc1 v5.9.0-beta4 v5.9.0-beta3 v5.9.0-beta2 v5.9.0-beta1 v5.9.0-alpha1 v5.8.0 v5.8.0-rc1 v5.8.0-beta1 v5.8.0-alpha1 v5.7.1 v5.7.0 v5.7.0-rc1 v5.7.0-beta1 v5.7.0-alpha1 v5.6.3 v5.6.2 v5.6.1 v5.6.1-1 v5.6.0 v5.6.0-rc1 v5.6.0-beta1 v5.6.0-alpha1 v5.5.1 v5.5.0 v5.5.0-rc1 v5.5.0-beta1 v5.5.0-alpha1 v5.4.2 v5.4.1 v5.4.0 v5.4.0-rc1 v5.4.0-beta1 v5.4.0-alpha1 v5.3.2 v5.3.1 v5.3.0 v5.3.0-rc1 v5.3.0-beta1 v5.3.0-alpha1 v5.2.1 v5.2.0 v5.2.0-rc1 v5.2.0-beta1 v5.2.0-alpha1
No related merge requests found
Showing with 26 additions and 23 deletions
...@@ -112,7 +112,7 @@ QQmlBinding::QQmlBinding(const QString &str, QObject *obj, QQmlContext *ctxt) ...@@ -112,7 +112,7 @@ QQmlBinding::QQmlBinding(const QString &str, QObject *obj, QQmlContext *ctxt)
QString code = rewriteBinding(str); QString code = rewriteBinding(str);
m_expression = str.toUtf8(); m_expression = str.toUtf8();
v8function = evalFunction(context(), obj, code, QString(), 0); v4function = evalFunction(context(), obj, code, QString(), 0)->v4Value();
} }
QQmlBinding::QQmlBinding(const QQmlScriptString &script, QObject *obj, QQmlContext *ctxt) QQmlBinding::QQmlBinding(const QQmlScriptString &script, QObject *obj, QQmlContext *ctxt)
...@@ -159,7 +159,7 @@ QQmlBinding::QQmlBinding(const QQmlScriptString &script, QObject *obj, QQmlConte ...@@ -159,7 +159,7 @@ QQmlBinding::QQmlBinding(const QQmlScriptString &script, QObject *obj, QQmlConte
m_lineNumber = scriptPrivate->lineNumber; m_lineNumber = scriptPrivate->lineNumber;
m_columnNumber = scriptPrivate->columnNumber; m_columnNumber = scriptPrivate->columnNumber;
v8function = evalFunction(context(), scopeObject(), code, QString(), m_lineNumber); v4function = evalFunction(context(), scopeObject(), code, QString(), m_lineNumber)->v4Value();
} }
QQmlBinding::QQmlBinding(const QString &str, QObject *obj, QQmlContextData *ctxt) QQmlBinding::QQmlBinding(const QString &str, QObject *obj, QQmlContextData *ctxt)
...@@ -174,7 +174,7 @@ QQmlBinding::QQmlBinding(const QString &str, QObject *obj, QQmlContextData *ctxt ...@@ -174,7 +174,7 @@ QQmlBinding::QQmlBinding(const QString &str, QObject *obj, QQmlContextData *ctxt
QString code = rewriteBinding(str); QString code = rewriteBinding(str);
m_expression = str.toUtf8(); m_expression = str.toUtf8();
v8function = evalFunction(ctxt, obj, code, QString(), 0); v4function = evalFunction(ctxt, obj, code, QString(), 0)->v4Value();
} }
QQmlBinding::QQmlBinding(const QString &str, bool isRewritten, QObject *obj, QQmlBinding::QQmlBinding(const QString &str, bool isRewritten, QObject *obj,
...@@ -197,7 +197,7 @@ QQmlBinding::QQmlBinding(const QString &str, bool isRewritten, QObject *obj, ...@@ -197,7 +197,7 @@ QQmlBinding::QQmlBinding(const QString &str, bool isRewritten, QObject *obj,
m_expression = str.toUtf8(); m_expression = str.toUtf8();
v8function = evalFunction(ctxt, obj, code, url, m_lineNumber); v4function = evalFunction(ctxt, obj, code, url, m_lineNumber)->v4Value();
} }
/*! /*!
...@@ -217,12 +217,11 @@ QQmlBinding::QQmlBinding(void *functionPtr, QObject *obj, QQmlContextData *ctxt, ...@@ -217,12 +217,11 @@ QQmlBinding::QQmlBinding(void *functionPtr, QObject *obj, QQmlContextData *ctxt,
QQmlAbstractExpression::setContext(ctxt); QQmlAbstractExpression::setContext(ctxt);
setScopeObject(obj); setScopeObject(obj);
v8function = qPersistentNew<v8::Function>(*(v8::Handle<v8::Function> *)functionPtr); v4function = (*(v8::Handle<v8::Function> *)functionPtr)->v4Value();
} }
QQmlBinding::~QQmlBinding() QQmlBinding::~QQmlBinding()
{ {
qPersistentDispose(v8function);
} }
void QQmlBinding::setEvaluateFlags(EvaluateFlags flags) void QQmlBinding::setEvaluateFlags(EvaluateFlags flags)
...@@ -280,7 +279,7 @@ void QQmlBinding::update(QQmlPropertyPrivate::WriteFlags flags) ...@@ -280,7 +279,7 @@ void QQmlBinding::update(QQmlPropertyPrivate::WriteFlags flags)
bool isUndefined = false; bool isUndefined = false;
v8::Local<v8::Value> result = v8::Local<v8::Value> result =
QQmlJavaScriptExpression::evaluate(context(), v8function, &isUndefined); QQmlJavaScriptExpression::evaluate(context(), **v4function, &isUndefined);
trace.event("writing binding result"); trace.event("writing binding result");
...@@ -321,7 +320,7 @@ QVariant QQmlBinding::evaluate() ...@@ -321,7 +320,7 @@ QVariant QQmlBinding::evaluate()
bool isUndefined = false; bool isUndefined = false;
v8::Local<v8::Value> result = v8::Local<v8::Value> result =
QQmlJavaScriptExpression::evaluate(context(), v8function, &isUndefined); QQmlJavaScriptExpression::evaluate(context(), **v4function, &isUndefined);
ep->dereferenceScarceResources(); ep->dereferenceScarceResources();
......
...@@ -131,7 +131,7 @@ protected: ...@@ -131,7 +131,7 @@ protected:
~QQmlBinding(); ~QQmlBinding();
private: private:
v8::Persistent<v8::Function> v8function; QV4::PersistentValue v4function;
inline bool updatingFlag() const; inline bool updatingFlag() const;
inline void setUpdatingFlag(bool); inline void setUpdatingFlag(bool);
......
...@@ -134,8 +134,6 @@ QQmlCompiledData::~QQmlCompiledData() ...@@ -134,8 +134,6 @@ QQmlCompiledData::~QQmlCompiledData()
void QQmlCompiledData::clear() void QQmlCompiledData::clear()
{ {
for (int ii = 0; ii < programs.count(); ++ii)
qPersistentDispose(programs[ii].bindings);
} }
/*! /*!
......
...@@ -111,7 +111,7 @@ public: ...@@ -111,7 +111,7 @@ public:
: program(p), cdata(c) {} : program(p), cdata(c) {}
QByteArray program; QByteArray program;
v8::Persistent<v8::Array> bindings; QV4::PersistentValue bindings;
QQmlCompiledData *cdata; QQmlCompiledData *cdata;
}; };
......
...@@ -50,6 +50,8 @@ ...@@ -50,6 +50,8 @@
#include <private/qqmltrace_p.h> #include <private/qqmltrace_p.h>
#include <private/qqmlprofilerservice_p.h> #include <private/qqmlprofilerservice_p.h>
#include <private/qv4object_p.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
QQmlAbstractBinding::VTable QV8Bindings_Binding_vtable = { QQmlAbstractBinding::VTable QV8Bindings_Binding_vtable = {
...@@ -86,7 +88,8 @@ void QV8Bindings::Binding::setEnabled(QQmlAbstractBinding *_This, bool e, ...@@ -86,7 +88,8 @@ void QV8Bindings::Binding::setEnabled(QQmlAbstractBinding *_This, bool e,
void QV8Bindings::refresh() void QV8Bindings::refresh()
{ {
int count = functions()->Length(); QV4::ArrayObject *f = functions();
int count = f ? f->arrayLength() : 0;
for (int ii = 0; ii < count; ++ii) for (int ii = 0; ii < count; ++ii)
bindings[ii].refresh(); bindings[ii].refresh();
} }
...@@ -170,10 +173,12 @@ void QV8Bindings::Binding::update(QQmlPropertyPrivate::WriteFlags flags) ...@@ -170,10 +173,12 @@ void QV8Bindings::Binding::update(QQmlPropertyPrivate::WriteFlags flags)
DeleteWatcher watcher(this); DeleteWatcher watcher(this);
ep->referenceScarceResources(); ep->referenceScarceResources();
v8::Local<v8::Value> result = QV4::ArrayObject *f = parent->functions();
v8::Local<v8::Value> result = f ?
evaluate(context, evaluate(context,
v8::Handle<v8::Function>::Cast(parent->functions()->Get(instruction->value)), f->getIndexed(f->internalClass->engine->current, instruction->value),
&isUndefined); &isUndefined)
: v8::Local<v8::Value>::New(QV4::Value::undefinedValue());
trace.event("writing V8 result"); trace.event("writing V8 result");
bool needsErrorLocationData = false; bool needsErrorLocationData = false;
...@@ -240,7 +245,7 @@ QV8Bindings::QV8Bindings(QQmlCompiledData::V8Program *program, ...@@ -240,7 +245,7 @@ QV8Bindings::QV8Bindings(QQmlCompiledData::V8Program *program,
{ {
QV8Engine *engine = QQmlEnginePrivate::getV8Engine(context->engine); QV8Engine *engine = QQmlEnginePrivate::getV8Engine(context->engine);
if (program->bindings.IsEmpty()) { if (program->bindings->isDeleted()) {
v8::Local<v8::Script> script; v8::Local<v8::Script> script;
bool compileFailed = false; bool compileFailed = false;
{ {
...@@ -260,20 +265,21 @@ QV8Bindings::QV8Bindings(QQmlCompiledData::V8Program *program, ...@@ -260,20 +265,21 @@ QV8Bindings::QV8Bindings(QQmlCompiledData::V8Program *program,
if (!message.IsEmpty()) if (!message.IsEmpty())
QQmlExpressionPrivate::exceptionToError(message, error); QQmlExpressionPrivate::exceptionToError(message, error);
QQmlEnginePrivate::get(engine->engine())->warning(error); QQmlEnginePrivate::get(engine->engine())->warning(error);
program->bindings = qPersistentNew(v8::Array::New()); program->bindings = QV4::Value::nullValue();
} }
} }
if (!compileFailed) { if (!compileFailed) {
v8::Local<v8::Value> result = script->Run(engine->contextWrapper()->sharedContext()); v8::Local<v8::Value> result = script->Run(engine->contextWrapper()->sharedContext());
if (result->IsArray()) { if (result->IsArray()) {
program->bindings = qPersistentNew(v8::Local<v8::Array>::Cast(result)); program->bindings = result->v4Value();
program->program.clear(); // We don't need the source anymore program->program.clear(); // We don't need the source anymore
} }
} }
} }
int bindingsCount = functions()->Length(); QV4::ArrayObject *f = functions();
int bindingsCount = f ? f->arrayLength() : 0;
if (bindingsCount) bindings = new QV8Bindings::Binding[bindingsCount]; if (bindingsCount) bindings = new QV8Bindings::Binding[bindingsCount];
setContext(context); setContext(context);
...@@ -319,9 +325,9 @@ const QString &QV8Bindings::urlString() const ...@@ -319,9 +325,9 @@ const QString &QV8Bindings::urlString() const
return program->cdata->name; return program->cdata->name;
} }
v8::Persistent<v8::Array> &QV8Bindings::functions() const QV4::ArrayObject *QV8Bindings::functions() const
{ {
return program->bindings; return program->bindings->asArrayObject();
} }
......
...@@ -136,7 +136,7 @@ private: ...@@ -136,7 +136,7 @@ private:
const QUrl &url() const; const QUrl &url() const;
const QString &urlString() const; const QString &urlString() const;
v8::Persistent<v8::Array> &functions() const; QV4::ArrayObject *functions() const;
QQmlCompiledData::V8Program *program; QQmlCompiledData::V8Program *program;
Binding *bindings; Binding *bindings;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment