diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-05-20 23:51:45 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2013-05-21 10:11:43 +0200 |
commit | 7fe54ee6d6eb44c630038229eb9a4bb1780eec77 (patch) | |
tree | 20e0278387688936a060eaed33273ca7bb5e89c5 /tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | |
parent | e1a6612d3a4528fee8854c274232fc4966d65237 (diff) |
Convert the remaining TryCatch statements to use QV4::Exception
v8::Script::Run doesn't catch the exception anymore. Instead we handle
this on the calling side, removing all needs for v8::TryCatch.
Change-Id: I946269a6734f50c728c4f153c00cd19db48f1a6a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp')
-rw-r--r-- | tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 75 |
1 files changed, 41 insertions, 34 deletions
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 58072e87a0..41639d5b7b 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -2170,16 +2170,22 @@ static inline bool evaluate_error(QV8Engine *engine, v8::Handle<v8::Object> o, c { QString functionSource = QLatin1String("(function(object) { return ") + QLatin1String(source) + QLatin1String(" })"); - v8::TryCatch tc; + v8::Handle<v8::Script> program = v8::Script::Compile(engine->toString(functionSource)); - if (tc.HasCaught()) - return false; - v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(program->Run()); - if (function.IsEmpty()) + + QV4::ExecutionContext *ctx = QV8Engine::getV4(engine)->current; + + try { + v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(program->Run()); + if (!function->v4Value().asFunctionObject()) + return false; + v8::Handle<v8::Value> args[] = { o }; + function->Call(engine->global(), 1, args); + } catch (QV4::Exception &e) { + e.accept(ctx); return false; - v8::Handle<v8::Value> args[] = { o }; - function->Call(engine->global(), 1, args); - return tc.HasCaught(); + } + return true; } static inline bool evaluate_value(QV8Engine *engine, v8::Handle<v8::Object> o, @@ -2187,21 +2193,21 @@ static inline bool evaluate_value(QV8Engine *engine, v8::Handle<v8::Object> o, { QString functionSource = QLatin1String("(function(object) { return ") + QLatin1String(source) + QLatin1String(" })"); - v8::TryCatch tc; - v8::Handle<v8::Script> program = v8::Script::Compile(engine->toString(functionSource)); - if (tc.HasCaught()) - return false; - v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(program->Run()); - if (function.IsEmpty()) - return false; - v8::Handle<v8::Value> args[] = { o }; - v8::Handle<v8::Value> value = function->Call(engine->global(), 1, args); - - if (tc.HasCaught()) - return false; + QV4::ExecutionContext *ctx = QV8Engine::getV4(engine)->current; + v8::Handle<v8::Script> program = v8::Script::Compile(engine->toString(functionSource)); + try { + v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(program->Run()); + if (!function->v4Value().asFunctionObject()) + return false; + v8::Handle<v8::Value> args[] = { o }; - return value->StrictEquals(result); + v8::Handle<v8::Value> value = function->Call(engine->global(), 1, args); + return value->StrictEquals(result); + } catch (QV4::Exception &e) { + e.accept(ctx); + } + return false; } static inline v8::Handle<v8::Value> evaluate(QV8Engine *engine, v8::Handle<v8::Object> o, @@ -2209,20 +2215,21 @@ static inline v8::Handle<v8::Value> evaluate(QV8Engine *engine, v8::Handle<v8::O { QString functionSource = QLatin1String("(function(object) { return ") + QLatin1String(source) + QLatin1String(" })"); - v8::TryCatch tc; + + QV4::ExecutionContext *ctx = QV8Engine::getV4(engine)->current; v8::Handle<v8::Script> program = v8::Script::Compile(engine->toString(functionSource)); - if (tc.HasCaught()) - return v8::Handle<v8::Value>(); - v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(program->Run()); - if (function.IsEmpty()) - return v8::Handle<v8::Value>(); - v8::Handle<v8::Value> args[] = { o }; - - v8::Handle<v8::Value> value = function->Call(engine->global(), 1, args); - - if (tc.HasCaught()) - return v8::Handle<v8::Value>(); - return value; + try { + v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(program->Run()); + if (!function->v4Value().asFunctionObject()) + return v8::Handle<v8::Value>(); + v8::Handle<v8::Value> args[] = { o }; + + v8::Handle<v8::Value> value = function->Call(engine->global(), 1, args); + return value; + } catch (QV4::Exception &e) { + e.accept(ctx); + } + return v8::Handle<v8::Value>(); } #define EVALUATE_ERROR(source) evaluate_error(engine, object, source) |