diff options
author | Benjamin Poulain <benjamin.poulain@nokia.com> | 2009-07-27 16:13:21 (GMT) |
---|---|---|
committer | Benjamin Poulain <benjamin.poulain@nokia.com> | 2009-07-27 16:39:10 (GMT) |
commit | a8dae30f3825d0527a38499e13bd8e36485aac47 (patch) | |
tree | 0f42ae104da8a59d3f50e277b83ac29750610c40 /src/script/api | |
parent | da769c4d4bd890e98173baf406f5455052f09c1f (diff) | |
download | Qt-a8dae30f3825d0527a38499e13bd8e36485aac47.zip Qt-a8dae30f3825d0527a38499e13bd8e36485aac47.tar.gz Qt-a8dae30f3825d0527a38499e13bd8e36485aac47.tar.bz2 |
Remove the uncaughtException, use the JSC exception instead
Use the exception from JSC::exec instead of
QScriptEngin::uncaughtException.
A few more tests are passing for qscriptvalue and qscriptqobject.
Reviewed-by: Kent Hansen
Diffstat (limited to 'src/script/api')
-rw-r--r-- | src/script/api/qscriptengine.cpp | 15 | ||||
-rw-r--r-- | src/script/api/qscriptengine_p.h | 1 | ||||
-rw-r--r-- | src/script/api/qscriptvalue.cpp | 23 |
3 files changed, 13 insertions, 26 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 7387078..fbc65d6 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -1045,9 +1045,6 @@ void QScriptEnginePrivate::releaseContextForFrame(JSC::ExecState *frame) void QScriptEnginePrivate::mark() { - if (uncaughtException && !uncaughtException.marked()) - uncaughtException.mark(); - if (customGlobalObject && !customGlobalObject->marked()) customGlobalObject->mark(); @@ -2068,7 +2065,6 @@ QScriptValue QScriptEngine::evaluate(const QString &program, const QString &file exec->clearException(); if (!exec->globalData().dynamicGlobalObject) exec->globalData().dynamicGlobalObject = d->globalObject; - d->uncaughtException = JSC::JSValue(); JSC::ScopeChain scopeChain = JSC::ScopeChain(exec->scopeChain()); JSC::Completion comp = JSC::evaluate(exec, scopeChain, JSC::makeSource(jscProgram, jscFileName, lineNumber)); @@ -2078,7 +2074,7 @@ QScriptValue QScriptEngine::evaluate(const QString &program, const QString &file } if (comp.complType() == JSC::Throw) { - d->uncaughtException = comp.value(); + exec->setException(comp.value()); return d->scriptValueFromJSCValue(comp.value()); } @@ -2158,7 +2154,8 @@ void QScriptEngine::popContext() bool QScriptEngine::hasUncaughtException() const { Q_D(const QScriptEngine); - return !!d->uncaughtException; + JSC::ExecState* exec = d->globalObject->globalExec(); + return exec->hadException(); } /*! @@ -2175,7 +2172,8 @@ bool QScriptEngine::hasUncaughtException() const QScriptValue QScriptEngine::uncaughtException() const { Q_D(const QScriptEngine); - return const_cast<QScriptEnginePrivate*>(d)->scriptValueFromJSCValue(d->uncaughtException); + JSC::ExecState* exec = d->globalObject->globalExec(); + return const_cast<QScriptEnginePrivate*>(d)->scriptValueFromJSCValue(exec->exception()); } /*! @@ -2190,7 +2188,7 @@ int QScriptEngine::uncaughtExceptionLineNumber() const { if (!hasUncaughtException()) return -1; - return uncaughtException().property(QLatin1String("line")).toInt32(); + return uncaughtException().property(QLatin1String("lineNumber")).toInt32(); } /*! @@ -2222,7 +2220,6 @@ void QScriptEngine::clearExceptions() Q_D(QScriptEngine); JSC::ExecState* exec = d->currentFrame; exec->clearException(); - d->uncaughtException = JSC::JSValue(); } /*! diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h index 24863a7..d1af106 100644 --- a/src/script/api/qscriptengine_p.h +++ b/src/script/api/qscriptengine_p.h @@ -163,7 +163,6 @@ public: JSC::JSObject *customGlobalObject; JSC::ExecState *currentFrame; QHash<JSC::ExecState*, QScriptContext*> contextForFrameHash; - JSC::JSValue uncaughtException; WTF::RefPtr<JSC::Structure> scriptObjectStructure; diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp index 1082fa3..7693af8 100644 --- a/src/script/api/qscriptvalue.cpp +++ b/src/script/api/qscriptvalue.cpp @@ -401,7 +401,7 @@ void QScriptValuePrivate::saveException(JSC::ExecState *exec, JSC::JSValue *val) void QScriptValuePrivate::restoreException(JSC::ExecState *exec, JSC::JSValue val) { - if (exec && !exec->hadException() && val) + if (exec && val) exec->setException(val); } @@ -1244,16 +1244,15 @@ QString QScriptValue::toString() const JSC::JSValue savedException; QScriptValuePrivate::saveException(exec, &savedException); JSC::UString str = d->jscValue.toString(exec); - if (exec && exec->hadException()) { + if (exec && exec->hadException() && !str.size()) { JSC::JSValue savedException2; QScriptValuePrivate::saveException(exec, &savedException2); - if (!str.size()) - str = savedException2.toString(exec); - if (!eng_p->uncaughtException) - eng_p->uncaughtException = savedException2; + str = savedException2.toString(exec); + QScriptValuePrivate::restoreException(exec, savedException2); } - QScriptValuePrivate::restoreException(exec, savedException); - return QString(reinterpret_cast<const QChar*>(str.data()), str.size()); + if (savedException) + QScriptValuePrivate::restoreException(exec, savedException); + return QScript::qtStringFromJSCUString(str); } case QScriptValuePrivate::Number: return QScript::qtStringFromJSCUString(JSC::UString::from(d->numberValue)); @@ -2009,8 +2008,6 @@ QScriptValue QScriptValue::call(const QScriptValue &thisObject, QScriptValuePrivate::saveException(exec, &savedException); JSC::JSValue result = JSC::call(exec, callee, callType, callData, jscThisObject, jscArgs); if (exec->hadException()) { - if (!eng_p->uncaughtException) - eng_p->uncaughtException = exec->exception(); result = exec->exception(); } else { QScriptValuePrivate::restoreException(exec, savedException); @@ -2090,8 +2087,6 @@ QScriptValue QScriptValue::call(const QScriptValue &thisObject, QScriptValuePrivate::saveException(exec, &savedException); JSC::JSValue result = JSC::call(exec, callee, callType, callData, jscThisObject, applyArgs); if (exec->hadException()) { - if (!eng_p->uncaughtException) - eng_p->uncaughtException = exec->exception(); result = exec->exception(); } else { QScriptValuePrivate::restoreException(exec, savedException); @@ -2142,8 +2137,6 @@ QScriptValue QScriptValue::construct(const QScriptValueList &args) QScriptValuePrivate::saveException(exec, &savedException); JSC::JSObject *result = JSC::construct(exec, callee, constructType, constructData, jscArgs); if (exec->hadException()) { - if (!eng_p->uncaughtException) - eng_p->uncaughtException = exec->exception(); result = JSC::asObject(exec->exception()); } else { QScriptValuePrivate::restoreException(exec, savedException); @@ -2201,8 +2194,6 @@ QScriptValue QScriptValue::construct(const QScriptValue &arguments) QScriptValuePrivate::saveException(exec, &savedException); JSC::JSObject *result = JSC::construct(exec, callee, constructType, constructData, applyArgs); if (exec->hadException()) { - if (!eng_p->uncaughtException) - eng_p->uncaughtException = exec->exception(); if (exec->exception().isObject()) result = JSC::asObject(exec->exception()); } else { |