From 34511e1001471ed4041794640aefe508f50ad01c Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Mon, 10 Aug 2009 12:12:33 +0200 Subject: implement QScriptContext::backtrace() Doesn't pass the test yet, but at least it returns something that might be useful on occasion. --- src/script/api/qscriptcontext.cpp | 36 ++---------------------- tests/auto/qscriptcontext/tst_qscriptcontext.cpp | 2 +- 2 files changed, 3 insertions(+), 35 deletions(-) diff --git a/src/script/api/qscriptcontext.cpp b/src/script/api/qscriptcontext.cpp index bce7687..66d4c3e 100644 --- a/src/script/api/qscriptcontext.cpp +++ b/src/script/api/qscriptcontext.cpp @@ -548,43 +548,11 @@ QScriptContext::ExecutionState QScriptContext::state() const QStringList QScriptContext::backtrace() const { QStringList result; - qWarning("QScriptContext::backtrace() not implemented"); -#if 0 - const QScriptContextPrivate *ctx = this; + const QScriptContext *ctx = this; while (ctx) { - QString s; - QString functionName = ctx->functionName(); - if (!functionName.isEmpty()) - s += functionName; - else { - if (ctx->parentContext()) { - if (ctx->callee().isFunction() - && ctx->callee().toFunction()->type() != QScriptFunction::Script) { - s += QLatin1String(""); - } else { - s += QLatin1String(""); - } - } else { - s += QLatin1String(""); - } - } - s += QLatin1Char('('); - for (int i = 0; i < ctx->argc; ++i) { - if (i > 0) - s += QLatin1Char(','); - QScriptValueImpl arg = ctx->args[i]; - if (arg.isObject()) - s += QLatin1String("[object Object]"); // don't do a function call - else - s += arg.toString(); - } - s += QLatin1String(")@"); - s += ctx->fileName(); - s += QString::fromLatin1(":%0").arg(ctx->currentLine); - result.append(s); + result.append(ctx->toString()); ctx = ctx->parentContext(); } -#endif return result; } diff --git a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp index 48403aa..eed0cb1 100644 --- a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp +++ b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp @@ -561,7 +561,7 @@ void tst_QScriptContext::backtrace() QVERIFY(ret.isArray()); QStringList slist = qscriptvalue_cast(ret); - QEXPECT_FAIL("", "", Continue); + QEXPECT_FAIL("", "Backtrace is not correct", Continue); QCOMPARE(slist, expected); } -- cgit v0.12