本文整理汇总了C++中QScriptContext::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ QScriptContext::toString方法的具体用法?C++ QScriptContext::toString怎么用?C++ QScriptContext::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScriptContext
的用法示例。
在下文中一共展示了QScriptContext::toString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: executeCommand
bool ScriptDebuggerPrivate::executeCommand(const QString &command, const QStringList &args)
{
if (command == QLatin1String("c")
|| command == QLatin1String("continue")) {
setMode(Run);
return true;
} else if (command == QLatin1String("s")
|| command == QLatin1String("step")) {
setMode(StepInto);
return true;
} else if (command == QLatin1String("n")
|| command == QLatin1String("next")) {
setMode(StepOver);
m_stepDepth = 0;
return true;
} else if (command == QLatin1String("f")
|| command == QLatin1String("frame")) {
bool ok = false;
int index = args.value(0).toInt(&ok);
if (ok) {
if (index < 0 || index >= frameCount()) {
errorMessage("No such frame.");
} else {
setCurrentFrameIndex(index);
QScriptContext *ctx = currentFrameContext();
message(QString::fromLatin1("#%0 %1").arg(index).arg(ctx->toString()));
}
}
} else if (command == QLatin1String("bt")
|| command == QLatin1String("backtrace")) {
QScriptContext *ctx = engine()->currentContext();
int index = -1;
while (ctx) {
++index;
QString line = ctx->toString();
message(QString::fromLatin1("#%0 %1").arg(index).arg(line));
ctx = ctx->parentContext();
}
} else if (command == QLatin1String("up")) {
int index = currentFrameIndex() + 1;
if (index == frameCount()) {
errorMessage(QString::fromLatin1("Initial frame selected; you cannot go up."));
} else {
setCurrentFrameIndex(index);
QScriptContext *ctx = currentFrameContext();
message(QString::fromLatin1("#%0 %1").arg(index).arg(ctx->toString()));
}
} else if (command == QLatin1String("down")) {
int index = currentFrameIndex() - 1;
if (index < 0) {
errorMessage(QString::fromLatin1("Bottom (innermost) frame selected; you cannot go down."));
} else {
setCurrentFrameIndex(index);
QScriptContext *ctx = currentFrameContext();
message(QString::fromLatin1("#%0 %1").arg(index).arg(ctx->toString()));
}
} else if (command == QLatin1String("b")
|| command == QLatin1String("break")) {
QString str = args.value(0);
int colonIndex = str.indexOf(QLatin1Char(':'));
if (colonIndex != -1) {
// filename:line form
QString fileName = str.left(colonIndex);
int lineNumber = str.mid(colonIndex+1).toInt();
int id = m_bpManager->setBreakpoint(fileName, lineNumber);
message(QString::fromLatin1("Breakpoint %0 at %1, line %2.").arg(id+1).arg(fileName).arg(lineNumber));
} else {
// function
QScriptValue fun = engine()->globalObject().property(str);
if (fun.isFunction()) {
int id = m_bpManager->setBreakpoint(fun);
message(QString::fromLatin1("Breakpoint %0 at %1().").arg(id+1).arg(str));
}
}
} else if (command == QLatin1String("d")
|| command == QLatin1String("delete")) {
int id = args.value(0).toInt() - 1;
m_bpManager->removeBreakpoint(id);
} else if (command == QLatin1String("disable")) {
int id = args.value(0).toInt() - 1;
m_bpManager->setBreakpointEnabled(id, false);
} else if (command == QLatin1String("enable")) {
int id = args.value(0).toInt() - 1;
m_bpManager->setBreakpointEnabled(id, true);
} else if (command == QLatin1String("list")) {
QScriptContext *ctx = currentFrameContext();
ScriptInfo *progInfo = scriptInfo(ctx);
if (!progInfo) {
errorMessage("No source text available for this frame.");
} else {
QScriptContextInfo ctxInfo(ctx);
bool ok;
int line = args.value(0).toInt(&ok);
if (ok) {
line = qMax(1, line - 5);
} else {
line = listLineNumber();
if (line == -1)
line = qMax(progInfo->lineNumber(), ctxInfo.lineNumber() - 5);
}
//.........这里部分代码省略.........