aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmljavascriptexpression.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-05-20 18:55:49 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2013-05-21 09:59:45 +0200
commit61902215393c27041739d4cd8544e502ca7f8270 (patch)
tree252e39f79a1b1353ad1e48b3d7e32bc47a4af43d /src/qml/qml/qqmljavascriptexpression.cpp
parentc7c6f955df2733f4ded7340c073ce418c15c30e9 (diff)
Move QQmlJavascriptExression::evaluate over to v4
Change-Id: Ic4093dc5413f43af55a74a0e0f8c316ac1c6d974 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml/qqmljavascriptexpression.cpp')
-rw-r--r--src/qml/qml/qqmljavascriptexpression.cpp49
1 files changed, 28 insertions, 21 deletions
diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp
index 759955f335..3c0e8d8919 100644
--- a/src/qml/qml/qqmljavascriptexpression.cpp
+++ b/src/qml/qml/qqmljavascriptexpression.cpp
@@ -43,6 +43,7 @@
#include <private/qqmlexpression_p.h>
#include <private/qv4value_p.h>
+#include <private/qv4functionobject_p.h>
QT_BEGIN_NAMESPACE
@@ -120,22 +121,23 @@ void QQmlJavaScriptExpression::resetNotifyOnValueChanged()
v8::Handle<v8::Value>
QQmlJavaScriptExpression::evaluate(QQmlContextData *context,
- v8::Handle<v8::Function> function, bool *isUndefined)
+ const QV4::Value &function, bool *isUndefined)
{
return evaluate(context, function, 0, 0, isUndefined);
}
v8::Handle<v8::Value>
QQmlJavaScriptExpression::evaluate(QQmlContextData *context,
- v8::Handle<v8::Function> function,
- int argc, v8::Handle<v8::Value> args[],
+ const QV4::Value &function,
+ int argc, QV4::Value *args,
bool *isUndefined)
{
Q_ASSERT(context && context->engine);
- if (function.IsEmpty() || function->IsUndefined()) {
- if (isUndefined) *isUndefined = true;
- return v8::Handle<v8::Value>();
+ if (function.isEmpty() || function.isUndefined()) {
+ if (isUndefined)
+ *isUndefined = true;
+ return QV4::Value::emptyValue();
}
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context->engine);
@@ -166,30 +168,35 @@ QQmlJavaScriptExpression::evaluate(QQmlContextData *context,
ep->sharedScope = scopeObject();
}
- v8::Handle<v8::Value> result;
- {
- v8::TryCatch try_catch;
- v8::Handle<v8::Object> This = v8::Value::fromV4Value(ep->v8engine()->global());
+ QV4::Value result;
+ QV4::ExecutionEngine *v4 = QV8Engine::getV4(ep->v8engine());
+ QV4::ExecutionContext *ctx = v4->current;
+ try {
+ QV4::Value This = ep->v8engine()->global();
if (scopeObject() && requiresThisObject()) {
- v8::Handle<v8::Value> value = ep->v8engine()->newQObject(scopeObject());
- if (value->IsObject()) This = v8::Handle<v8::Object>::Cast(value);
+ QV4::Value value = ep->v8engine()->newQObject(scopeObject());
+ if (value.isObject())
+ This = value;
}
- result = function->Call(This, argc, args);
+ result = function.asFunctionObject()->call(ctx, This, args, argc);
if (isUndefined)
- *isUndefined = try_catch.HasCaught() || result->IsUndefined();
+ *isUndefined = result.isUndefined();
- if (watcher.wasDeleted()) {
- } else if (try_catch.HasCaught()) {
- v8::Handle<v8::Message> message = try_catch.Message();
- if (!message.IsEmpty()) {
- delayedError()->setMessage(message);
+ if (!watcher.wasDeleted() && hasDelayedError())
+ delayedError()->clearError();
+ } catch (QV4::Exception &e) {
+ e.accept(ctx);
+ if (isUndefined)
+ *isUndefined = true;
+ if (!watcher.wasDeleted()) {
+ if (!e.value().isEmpty()) {
+ // ### line number
+ delayedError()->setErrorDescription(e.value().toQString());
} else {
if (hasDelayedError()) delayedError()->clearError();
}
- } else {
- if (hasDelayedError()) delayedError()->clearError();
}
}