diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-05-21 00:05:52 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2013-05-21 10:13:52 +0200 |
commit | ff52a87fe35352c15e8d96caa244b3987a625b02 (patch) | |
tree | a1f44f21467b83cf096937387c0375c295eaa5cc /src/qml/qml | |
parent | 7fe54ee6d6eb44c630038229eb9a4bb1780eec77 (diff) |
Get rid of v8::TryCatch and v8::Message
They are now unused, so let's remove them from the v8 API.
Change-Id: I9c1b39632cb88785ae6fdda671580e0426ae97ba
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml')
-rw-r--r-- | src/qml/qml/qqmljavascriptexpression.cpp | 24 | ||||
-rw-r--r-- | src/qml/qml/qqmljavascriptexpression_p.h | 1 | ||||
-rw-r--r-- | src/qml/qml/v4/qv4v8.cpp | 90 | ||||
-rw-r--r-- | src/qml/qml/v4/qv4v8_p.h | 96 |
4 files changed, 0 insertions, 211 deletions
diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index e5525e59a3..bd74fd1471 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -305,30 +305,6 @@ void QQmlJavaScriptExpression::exceptionToError(const QV4::Exception &e, QQmlErr error.setDescription(e.value().toQString()); } -void QQmlJavaScriptExpression::exceptionToError(v8::Handle<v8::Message> message, QQmlError &error) -{ - Q_ASSERT(!message.IsEmpty()); - - v8::Handle<v8::Value> name = message->GetScriptResourceName(); - v8::Handle<v8::String> description = message->Get(); - int lineNumber = message->GetLineNumber(); - - v8::Handle<v8::String> file = name->IsString()?name->ToString():v8::Handle<v8::String>(); - if (file.IsEmpty() || file->Length() == 0) - error.setUrl(QUrl()); - else - error.setUrl(QUrl(file->v4Value().toQString())); - - error.setLine(lineNumber); - error.setColumn(-1); - - QString qDescription = description->v4Value().toQString(); - if (qDescription.startsWith(QLatin1String("Uncaught "))) - qDescription = qDescription.mid(9 /* strlen("Uncaught ") */); - - error.setDescription(qDescription); -} - // Callee owns the persistent handle QV4::PersistentValue QQmlJavaScriptExpression::evalFunction(QQmlContextData *ctxt, QObject *scope, diff --git a/src/qml/qml/qqmljavascriptexpression_p.h b/src/qml/qml/qqmljavascriptexpression_p.h index be14681569..d7db55d4f6 100644 --- a/src/qml/qml/qqmljavascriptexpression_p.h +++ b/src/qml/qml/qqmljavascriptexpression_p.h @@ -147,7 +147,6 @@ public: QQmlDelayedError *delayedError(); static void exceptionToError(const QV4::Exception &e, QQmlError &); - static void exceptionToError(v8::Handle<v8::Message>, QQmlError &); static QV4::PersistentValue evalFunction(QQmlContextData *ctxt, QObject *scope, const QString &code, const QString &filename, quint16 line, diff --git a/src/qml/qml/v4/qv4v8.cpp b/src/qml/qml/v4/qv4v8.cpp index b0d710da87..4c7aa23e59 100644 --- a/src/qml/qml/v4/qv4v8.cpp +++ b/src/qml/qml/v4/qv4v8.cpp @@ -123,7 +123,6 @@ struct V8AccessorGetter: FunctionObject { try { result = getter->getter(getter->name.value(), info)->v4Value(); } catch (QV4::Exception &e) { - Isolate::GetCurrent()->setException(e.value()); e.accept(context); } return result; @@ -160,7 +159,6 @@ struct V8AccessorSetter: FunctionObject { try { setter->setter(setter->name.value(), args[0], info); } catch (QV4::Exception &e) { - Isolate::GetCurrent()->setException(e.value()); e.accept(context); } return QV4::Value::undefinedValue(); @@ -266,7 +264,6 @@ Handle<Value> Script::Run(Handle<Object> qml) result = eval->evalCall(engine->current, QV4::Value::undefinedValue(), &arg, 1, /*directCall*/ false); } catch (QV4::Exception &e) { - Isolate::GetCurrent()->setException(e.value()); e.accept(ctx); return Handle<Value>(); } @@ -285,22 +282,6 @@ void Script::SetData(Handle<String> data) } -Handle<String> Message::Get() const -{ - return QV4::Value::fromString(currentEngine()->current, m_message); -} - -Handle<Value> Message::GetScriptResourceName() const -{ - return Value::fromV4Value(QV4::Value::fromString(currentEngine()->current, m_resourceName)); -} - -int Message::GetLineNumber() const -{ - return m_lineNumber; -} - - Handle<StackFrame> StackTrace::GetFrame(uint32_t index) const { if (index >= (uint)frames.size()) @@ -765,7 +746,6 @@ bool Object::Set(Handle<Value> key, Handle<Value> value, PropertyAttribute attri o->put(ctx, ValuePtr(&key)->toString(ctx), *ValuePtr(&value)); // ### attribs } catch (QV4::Exception &e) { - Isolate::GetCurrent()->setException(e.value()); e.accept(ctx); result = false; } @@ -782,7 +762,6 @@ bool Object::Set(uint32_t index, Handle<Value> value) o->putIndexed(ctx, index, *ValuePtr(&value)); // ### attribs } catch (QV4::Exception &e) { - Isolate::GetCurrent()->setException(e.value()); e.accept(ctx); result = false; } @@ -798,7 +777,6 @@ Handle<Value> Object::Get(Handle<Value> key) try { prop = o->get(ctx, ValuePtr(&key)->toString(ctx)); } catch (QV4::Exception &e) { - Isolate::GetCurrent()->setException(e.value()); e.accept(ctx); return Handle<Value>(); } @@ -814,7 +792,6 @@ Handle<Value> Object::Get(uint32_t key) try { prop = o->getIndexed(ctx, key); } catch (QV4::Exception &e) { - Isolate::GetCurrent()->setException(e.value()); e.accept(ctx); return Handle<Value>(); } @@ -837,7 +814,6 @@ bool Object::Delete(Handle<String> key) try { result = o->deleteProperty(ctx, ValuePtr(&key)->asString()); } catch (QV4::Exception &e) { - Isolate::GetCurrent()->setException(e.value()); e.accept(ctx); } return result; @@ -860,7 +836,6 @@ bool Object::Delete(uint32_t index) try { result = o->deleteIndexedProperty(ctx, index); } catch (QV4::Exception &e) { - Isolate::GetCurrent()->setException(e.value()); e.accept(ctx); } return result; @@ -1028,7 +1003,6 @@ Handle<Value> Object::CallAsFunction(Handle<Object> recv, int argc, Handle<Value argc); return retval; } catch (QV4::Exception &e) { - Isolate::GetCurrent()->setException(e.value()); e.accept(context); } return Handle<Object>(); @@ -1046,7 +1020,6 @@ Handle<Value> Object::CallAsConstructor(int argc, Handle<Value> argv[]) argc); return retval; } catch (QV4::Exception &e) { - Isolate::GetCurrent()->setException(e.value()); e.accept(context); } return Handle<Object>(); @@ -1098,7 +1071,6 @@ Handle<Object> Function::NewInstance() const try { result = f->construct(context, 0, 0); } catch (QV4::Exception &e) { - Isolate::GetCurrent()->setException(e.value()); e.accept(context); return Handle<Object>(); } @@ -1114,7 +1086,6 @@ Handle<Object> Function::NewInstance(int argc, Handle<Value> argv[]) const try { result = f->construct(context, reinterpret_cast<QV4::Value*>(argv), argc); } catch (QV4::Exception &e) { - Isolate::GetCurrent()->setException(e.value()); e.accept(context); return Handle<Object>(); } @@ -1132,7 +1103,6 @@ Handle<Value> Function::Call(Handle<Object> thisObj, int argc, Handle<Value> arg result = f->call(context, *ConstValuePtr(&thisObj), reinterpret_cast<QV4::Value*>(argv), argc); } catch (QV4::Exception &e) { - Isolate::GetCurrent()->setException(e.value()); e.accept(context); return Handle<Value>(); } @@ -1941,7 +1911,6 @@ Handle<Value> Exception::Error(Handle<String> message) static QThreadStorage<Isolate*> currentIsolate; Isolate::Isolate() - : tryCatch(0) { } @@ -1949,14 +1918,6 @@ Isolate::~Isolate() { } -void Isolate::setException(const QV4::Value &ex) -{ - if (tryCatch) { - tryCatch->hasCaughtException = true; - tryCatch->exception = ex; - } -} - ExecutionEngine *Isolate::GetEngine() { return Isolate::GetCurrent()->m_engine; @@ -2007,57 +1968,6 @@ void V8::RemoveGCPrologueCallback(GCPrologueCallback) assert(!"RemoveGCPrologueCallback();"); } -//void V8::AddImplicitReferences(Persistent<Object> parent, QV4::PersistentValue *children, size_t length) -//{ -// // not required currently as we don't have weak Persistent references. -// // not having them will lead to some leaks in QQmlVMEMetaObejct, but shouldn't matter otherwise -// assert(!"AddImplicitReferences();"); -//} - - -TryCatch::TryCatch() -{ - Isolate *i = Isolate::GetCurrent(); - - hasCaughtException = false; - parent = i->tryCatch; - i->tryCatch = this; -} - -TryCatch::~TryCatch() -{ - Isolate *i = Isolate::GetCurrent(); - i->tryCatch = parent; -} - -bool TryCatch::HasCaught() const -{ - return hasCaughtException; -} - -Handle<Value> TryCatch::ReThrow() -{ - Q_UNIMPLEMENTED(); - Q_UNREACHABLE(); -} - -Handle<Value> TryCatch::Exception() const -{ - return exception; -} - -Handle<Message> TryCatch::Message() const -{ - Q_UNIMPLEMENTED(); - return Handle<v8::Message>(new v8::Message(exception->v4Value().toQString(), QString(), 0)); -} - -void TryCatch::Reset() -{ - hasCaughtException = false; -} - - Handle<Value> Context::GetCallingScriptData() { Q_UNIMPLEMENTED(); diff --git a/src/qml/qml/v4/qv4v8_p.h b/src/qml/qml/v4/qv4v8_p.h index 45b6ca58a5..bae65cef79 100644 --- a/src/qml/qml/v4/qv4v8_p.h +++ b/src/qml/qml/v4/qv4v8_p.h @@ -562,34 +562,6 @@ private: DEFINE_REFCOUNTED_HANDLE_OPERATIONS(Script) /** - * An error message. - */ -class V8EXPORT Message : public QSharedData { - public: - Message(const QString &message, const QString &resourceName, int lineNumber) - : m_message(message), m_resourceName(resourceName), m_lineNumber(lineNumber) {} - - Handle<String> Get() const; - /** - * Returns the resource name for the script from where the function causing - * the error originates. - */ - Handle<Value> GetScriptResourceName() const; - - /** - * Returns the number, 1-based, of the line where the error occurred. - */ - int GetLineNumber() const; - -private: - QString m_message; - QString m_resourceName; - int m_lineNumber; -}; - -DEFINE_REFCOUNTED_HANDLE_OPERATIONS(Message) - -/** * Representation of a JavaScript stack trace. The information collected is a * snapshot of the execution stack and the information remains valid after * execution continues. @@ -1976,15 +1948,11 @@ class V8EXPORT Isolate { */ static Isolate* GetCurrent(); - void setException(const QV4::Value &ex); - static QV4::ExecutionEngine *GetEngine(); static void SetEngine(QV4::ExecutionEngine *e); private: friend class Context; - friend class TryCatch; - TryCatch *tryCatch; QV4::ExecutionEngine *m_engine; }; @@ -2030,70 +1998,6 @@ class V8EXPORT V8 { }; -/** - * An external exception handler. - */ -class V8EXPORT TryCatch { - public: - /** - * Creates a new try/catch block and registers it with v8. - */ - TryCatch(); - - /** - * Unregisters and deletes this try/catch block. - */ - ~TryCatch(); - - /** - * Returns true if an exception has been caught by this try/catch block. - */ - bool HasCaught() const; - - /** - * Throws the exception caught by this TryCatch in a way that avoids - * it being caught again by this same TryCatch. As with ThrowException - * it is illegal to execute any JavaScript operations after calling - * ReThrow; the caller must return immediately to where the exception - * is caught. - */ - Handle<Value> ReThrow(); - - /** - * Returns the exception caught by this try/catch block. If no exception has - * been caught an empty handle is returned. - * - * The returned handle is valid until this TryCatch block has been destroyed. - */ - Handle<Value> Exception() const; - - /** - * Returns the message associated with this exception. If there is - * no message associated an empty handle is returned. - * - * The returned handle is valid until this TryCatch block has been - * destroyed. - */ - Handle<v8::Message> Message() const; - - /** - * Clears any exceptions that may have been caught by this try/catch block. - * After this method has been called, HasCaught() will return false. - * - * It is not necessary to clear a try/catch block before using it again; if - * another exception is thrown the previously caught exception will just be - * overwritten. However, it is often a good idea since it makes it easier - * to determine which operation threw a given exception. - */ - void Reset(); - -private: - friend class Isolate; - TryCatch *parent; - bool hasCaughtException; - Handle<Value> exception; -}; - /** * A sandboxed execution context with its own set of built-in objects |