summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Poulain <benjamin.poulain@nokia.com>2009-07-27 16:13:21 (GMT)
committerBenjamin Poulain <benjamin.poulain@nokia.com>2009-07-27 16:39:10 (GMT)
commita8dae30f3825d0527a38499e13bd8e36485aac47 (patch)
tree0f42ae104da8a59d3f50e277b83ac29750610c40
parentda769c4d4bd890e98173baf406f5455052f09c1f (diff)
downloadQt-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
-rw-r--r--src/script/api/qscriptengine.cpp15
-rw-r--r--src/script/api/qscriptengine_p.h1
-rw-r--r--src/script/api/qscriptvalue.cpp23
-rw-r--r--src/script/bridge/qscriptqobject.cpp4
-rw-r--r--tests/auto/qscriptvalue/tst_qscriptvalue.cpp4
5 files changed, 14 insertions, 33 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 {
diff --git a/src/script/bridge/qscriptqobject.cpp b/src/script/bridge/qscriptqobject.cpp
index 43c97aa..5ea5df1 100644
--- a/src/script/bridge/qscriptqobject.cpp
+++ b/src/script/bridge/qscriptqobject.cpp
@@ -1248,12 +1248,11 @@ void QObjectDelegate::put(QScriptObject *object, JSC::ExecState* exec,
JSC::JSValue value, JSC::PutPropertySlot &slot)
{
QByteArray name = qtStringFromJSCUString(propertyName.ustring()).toLatin1();
- QScriptEnginePrivate *const eng = static_cast<QScript::GlobalObject*>(exec->lexicalGlobalObject())->engine;
QObject *qobject = data->value;
if (!qobject) {
QString message = QString::fromLatin1("cannot access member `%0' of deleted QObject")
.arg(QString::fromLatin1(name));
- eng->uncaughtException = JSC::throwError(exec, JSC::GeneralError, qtStringToJSCUString(message));
+ JSC::throwError(exec, JSC::GeneralError, qtStringToJSCUString(message));
return;
}
@@ -1988,7 +1987,6 @@ void QObjectConnectionManager::execute(int slotIndex, void **argv)
JSC::call(exec, slot, callType, callData, thisObject, jscArgs);
if (exec->hadException()) {
- engine->uncaughtException = exec->exception();
engine->emitSignalHandlerException();
}
}
diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
index 0036d95..f272b7f 100644
--- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
+++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
@@ -1924,16 +1924,12 @@ void tst_QScriptValue::getSetProperty()
QVERIFY(!eng.hasUncaughtException());
QScriptValue ret = object5.property("foo");
QVERIFY(ret.isError());
- QEXPECT_FAIL("", "hasUncaughtException() should return true", Continue);
QVERIFY(eng.hasUncaughtException());
- QEXPECT_FAIL("", "uncaughtException() and return value should be the same", Continue);
QVERIFY(ret.strictlyEquals(eng.uncaughtException()));
eng.evaluate("Object"); // clear exception state...
QVERIFY(!eng.hasUncaughtException());
object5.setProperty("foo", str);
- QEXPECT_FAIL("", "hasUncaughtException() should return true", Continue);
QVERIFY(eng.hasUncaughtException());
- QEXPECT_FAIL("", "Should produce an error message", Continue);
QCOMPARE(eng.uncaughtException().toString(), QLatin1String("Error: set foo"));
}