drop now unused scripttools component

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-05-19 05:07:37 +03:00
parent 9c91805c50
commit 9285cf9105
196 changed files with 83 additions and 28783 deletions

View file

@ -97,7 +97,7 @@ endif()
set(KATIE_TYPE SHARED CACHE STRING "Build type")
# components and tools that will be build, changed depending on the requirements availability
set(KATIE_COMPONENTS "Core Gui Declarative Network Svg Xml Script ScriptTools Test UiTools")
set(KATIE_COMPONENTS "Core Gui Declarative Network Svg Xml Script Test UiTools")
set(KATIE_TOOLS "moc uic qscript qtconfig")
set(KATIE_HEADERS_PATH "${CMAKE_INSTALL_FULL_INCLUDEDIR}/katie" CACHE PATH "Headers installation path")
@ -445,7 +445,6 @@ add_subdirectory(src/imports)
add_subdirectory(src/network)
add_subdirectory(src/plugins)
add_subdirectory(src/script)
add_subdirectory(src/scripttools)
add_subdirectory(src/svg)
add_subdirectory(src/test)
add_subdirectory(src/uitools)

View file

@ -1,41 +0,0 @@
name = "advance";
group = "running";
shortDescription = "Continue the program up to the given location";
longDescription = "This command has the same syntax as the \"break\" command.";
seeAlso = [ "break", "tbreak" ];
argumentTypes = [ "script-filename" ];
function execute() {
if (arguments.length == 0) {
message("Missing argument(s).");
return;
}
var arg = arguments[0];
var colonIndex = arg.lastIndexOf(':');
if (colonIndex == -1) {
lineNumber = parseInt(arg);
if (isNaN(lineNumber)) {
message("Location must be of the form <file>:<line> or <line>.");
return;
}
var sid = getCurrentScriptId();
if (sid == -1) {
message("No script.");
return;
}
scheduleRunToLocation(sid, lineNumber);
} else {
fileName = arg.slice(0, colonIndex);
lineNumber = parseInt(arg.slice(colonIndex+1));
// ### resolve the script to see if it's loaded or not? (e.g. so we can issue a warning)
scheduleRunToLocation(fileName, lineNumber);
}
}
function handleResponse(resp) {
}

View file

@ -1,26 +0,0 @@
name = "backtrace";
group = "stack";
shortDescription = "Print backtrace of stack frames";
longDescription = "";
aliases = [ "bt" ];
seeAlso = [ "frame", "info" ];
function execute() {
scheduleGetBacktrace();
};
function handleResponse(resp) {
var strings = resp.result;
var msg = "";
for (var i = 0; i < strings.length; ++i) {
if (i > 0)
msg += "\n";
msg += "#" + i + " " + strings[i];
}
message(msg);
}

View file

@ -1,59 +0,0 @@
name = "break";
group = "breakpoints";
shortDescription = "Set a breakpoint at specified location";
longDescription = "break <file>:<line> : Sets a breakpoint at the given location.";
longDescription += "\nbreak <line> : Sets a breakpoint at the given line of the current file.";
argumentTypes = [ "script-filename" ];
aliases = [ "b" ];
seeAlso = [ "condition", "delete", "disable", "tbreak" ];
function execute() {
if (arguments.length == 0) {
message("Missing argument.");
return;
}
var arg = arguments[0];
var colonIndex = arg.lastIndexOf(':');
if (colonIndex == -1) {
lineNumber = parseInt(arg);
if (isNaN(lineNumber)) {
message("Breakpoint location must be of the form <file>:<line> or <line>.");
return;
}
var sid = getCurrentScriptId();
if (sid == -1) {
message("No script.");
return;
}
scheduleGetScriptData(sid);
scriptId = sid;
state = 1;
} else {
fileName = arg.slice(0, colonIndex);
lineNumber = parseInt(arg.slice(colonIndex+1));
// ### resolve the script to see if it's loaded or not? (e.g. so we can issue a warning)
scheduleSetBreakpoint({ fileName: fileName, lineNumber: lineNumber});
state = 2;
}
}
function handleResponse(resp) {
if (state == 1) {
fileName = resp.result.fileName;
if (fileName.length == 0)
fileName = "<anonymous script, id=" + scriptId + ">";
scheduleSetBreakpoint({ scriptId: scriptId, lineNumber: lineNumber});
state = 2;
} else if (state == 2) {
if (resp.error == 0) {
var id = resp.result;
message("Breakpoint " + id + ": " + fileName + ", line " + lineNumber + ".");
}
}
}

View file

@ -1,59 +0,0 @@
name = "clear";
group = "breakpoints";
shortDescription = "Clear breakpoint at specified location";
longDescription = "clear <file>:<line> : Clear breakpoints at the given location.";
longDescription += "\nclear <line> : Clear breakpoints at the given line of the current script.";
seeAlso = [ "delete" ];
argumentTypes = [ "script-filename" ];
function execute() {
if (arguments.length == 0) {
message("Missing argument.");
return;
}
var arg = arguments[0];
var colonIndex = arg.lastIndexOf(':');
if (colonIndex == -1) {
lineNumber = parseInt(arg);
if (isNaN(lineNumber)) {
message("Breakpoint location must be of the form <file>:<line> or <line>.");
return;
}
var sid = getCurrentScriptId();
if (sid == -1) {
message("No script.");
return;
}
scriptId = sid;
} else {
fileName = arg.slice(0, colonIndex);
lineNumber = parseInt(arg.slice(colonIndex+1));
}
scheduleGetBreakpoints();
state = 1;
}
function handleResponse(resp) {
if (state == 1) {
var breakpoints = resp.result;
if (breakpoints == undefined)
return;
for (var id in breakpoints) {
var data = breakpoints[id];
if ((data.lineNumber == lineNumber)
&& (data.fileName == fileName)
|| ((data.scriptId != -1) && (data.scriptId = scriptId))) {
scheduleDeleteBreakpoint(id);
message("Deleted breakpoint " + id + ".");
}
}
state = 2;
} else if (state == 2) {
}
}

View file

@ -1,14 +0,0 @@
name = "complete";
group = "void";
shortDescription = "List the completions for the rest of the line as a command";
longDescription = "";
function execute() {
var prefix = (arguments.length > 0) ? arguments[0] : "";
var completions = getCommandCompletions(prefix);
for (var i = 0; i < completions.length; ++i)
message(completions[i]);
}

View file

@ -1,52 +0,0 @@
name = "condition";
group = "breakpoints";
shortDescription = "Specify breakpoint condition";
longDescription = "condition <breakpoint-id> <expression> : Specify that the breakpoint with the given id should only be triggered if the given expression evaluates to true.";
argumentTypes = [ "breakpoint-id", "script" ];
seeAlso = [ "ignore" ];
function execute() {
if (arguments.length == 0) {
message("Missing arguments (breakpoint number and condition).");
return;
}
var arg = arguments[0];
var spaceIndex = arg.indexOf(' ');
if (spaceIndex == -1)
spaceIndex = arg.length;
var id = parseInt(arg.slice(0, spaceIndex));
if (isNaN(id)) {
message("First argument must be a number (breakpoint id).");
return;
}
var cond = arg.slice(spaceIndex+1);
if ((cond.length != 0) && !checkSyntax(cond)) {
message("The condition has a syntax error.");
return;
}
scheduleGetBreakpointData(id);
breakpointId = id;
condition = cond;
state = 1;
}
function handleResponse(resp) {
if (state == 1) {
var data = resp.result;
if (data == undefined) {
message("No breakpoint number " + breakpointId + ".");
return;
}
data.condition = condition;
scheduleSetBreakpointData(breakpointId, data);
state = 2;
} else if (state == 2) {
if (condition.length == 0)
message("Breakpoint " + breakpointId + " now unconditional.");
}
}

View file

@ -1,22 +0,0 @@
name = "continue";
group = "running";
shortDescription = "Continue evaluation";
longDescription = "Evaluation will continue until an uncaught exception occurs, "
longDescription += "a breakpoint is hit or evaluation is explicitly interrupted.";
aliases = [ "c", "fg" ];
seeAlso = [ "step", "interrupt" ];
function execute() {
scheduleContinue();
};
function handleResponse(resp) {
if (!resp.async) {
message("The target is not evaluating code.");
}
}

View file

@ -1,36 +0,0 @@
name = "delete";
group = "breakpoints";
shortDescription = "Delete breakpoint(s)";
longDescription = "delete <breakpoint-id> : Deletes the breakpoint with the given id.";
seeAlso = [ "clear", "disable" ];
function execute() {
if (arguments.length == 0) {
// delete all breakpoints
scheduleClearBreakpoints();
state = 1;
} else {
var id = parseInt(arguments[0]);
if (isNaN(id)) {
message("Breakpoint id expected.");
return;
}
scheduleDeleteBreakpoint(id);
breakpointId = id;
state = 2;
}
}
function handleResponse(resp) {
if (state == 1) {
} else if (state == 2) {
if (resp.error != 0) {
message("No breakpoint number " + breakpointId + ".");
return;
}
}
}

View file

@ -1,56 +0,0 @@
name = "disable";
group = "breakpoints";
shortDescription = "Disable breakpoint(s)";
longDescription = "disable <breakpoint-id> : Disables the breakpoint with the given id.";
seeAlso = [ "enable", "delete", "ignore" ];
function execute() {
if (arguments.length == 0) {
// disable all breakpoints
state = 1;
scheduleGetBreakpoints();
} else {
var id = parseInt(arguments[0]);
if (isNaN(id)) {
message("Breakpoint id expected.");
return;
}
scheduleGetBreakpointData(id);
breakpointId = id;
state = 3;
}
};
function handleResponse(resp) {
if (state == 1) {
var breakpoints = resp.result;
if (breakpoints == undefined)
return;
for (var id in breakpoints) {
var data = breakpoints[id];
if (data.enabled) {
data.enabled = false;
scheduleSetBreakpointData(id, data);
}
}
state = 2;
} else if (state == 2) {
state = 0;
} else if (state == 3) {
var data = resp.result;
if (data == undefined) {
message("No breakpoint number " + breakpointId + ".");
return;
} else if (data.enabled) {
data.enabled = false;
scheduleSetBreakpointData(breakpointId, data);
state = 4;
}
} else if (state == 4) {
state = 0;
}
}

View file

@ -1,33 +0,0 @@
name = "down";
group = "stack";
shortDescription = "Select and print the stack frame below the current one";
longDescription = "";
seeAlso = [ "up", "frame" ];
function execute() {
var idx = getCurrentFrameIndex();
if (idx == 0) {
warning("Already at bottom (innermost) frame.");
return;
}
setCurrentFrameIndex(idx - 1);
scheduleGetContextInfo(idx - 1);
state = 1;
}
function handleResponse(resp, id) {
if (state == 1) {
var info = resp.result;
setCurrentScriptId(info.scriptId);
setCurrentLineNumber(info.lineNumber);
scheduleGetBacktrace();
state = 2;
} else if (state == 2) {
var backtrace = resp.result;
message("#" + getCurrentFrameIndex() + " " + backtrace[getCurrentFrameIndex()]);
}
}

View file

@ -1,56 +0,0 @@
name = "enable";
group = "breakpoints";
shortDescription = "Enable breakpoint(s)";
longDescription = "enable <breakpoint-id> : Enable the breakpoint with the given id.";
seeAlso = [ "disable" ];
function execute() {
if (arguments.length == 0) {
// enable all breakpoints
state = 1;
scheduleGetBreakpoints();
} else {
var id = parseInt(arguments[0]);
if (isNaN(id)) {
message("Breakpoint id expected.");
return;
}
scheduleGetBreakpointData(id);
breakpointId = id;
state = 3;
}
};
function handleResponse(resp) {
if (state == 1) {
var breakpoints = resp.result;
if (breakpoints == undefined)
return;
for (var id in breakpoints) {
var data = breakpoints[id];
if (!data.enabled) {
data.enabled = true;
scheduleSetBreakpointData(id, data);
}
}
state = 2;
} else if (state == 2) {
state = 0;
} else if (state == 3) {
var data = resp.result;
if (data == undefined) {
message("No breakpoint number " + breakpointId + ".");
return;
} else if (!data.enabled) {
data.enabled = true;
scheduleSetBreakpointData(breakpointId, data);
state = 4;
}
} else if (state == 4) {
state = 0;
}
}

View file

@ -1,21 +0,0 @@
name = "eval";
group = "running";
shortDescription = "Evaluate program";
longDescription = "";
argumentTypes = [ "script" ];
function execute() {
if (arguments.length == 0) {
message("Missing argument (program).");
return;
}
setEvaluateAction(0);
scheduleEvaluate(getCurrentFrameIndex(), arguments[0], "console input (" + Date() + ")");
};
function handleResponse(resp, id) {
}

View file

@ -1,16 +0,0 @@
name = "finish";
group = "running";
shortDescription = "Execute until the current stack frame returns";
longDescription = "Upon return, the value returned is printed.";
seeAlso = [ "next", "continue" ];
function execute() {
scheduleStepOut();
};
function handleResponse(resp) {
}

View file

@ -1,36 +0,0 @@
name = "frame";
group = "stack";
shortDescription = "Select and print a stack frame";
longDescription = "";
aliases = [ "f" ];
function execute() {
if (arguments.length == 0)
requestedFrameIndex = getCurrentFrameIndex();
else
requestedFrameIndex = parseInt(arguments[0]);
scheduleGetContextInfo(requestedFrameIndex);
state = 1;
};
function handleResponse(resp, id) {
if (state == 1) {
var info = resp.result;
if (info == undefined) {
message("Frame index out of range.");
return;
}
setCurrentFrameIndex(requestedFrameIndex);
setCurrentScriptId(info.scriptId);
setCurrentLineNumber(info.lineNumber);
scheduleGetBacktrace();
state = 2;
} else if (state == 2) {
var backtrace = resp.result;
message("#" + getCurrentFrameIndex() + " " + backtrace[getCurrentFrameIndex()]);
}
}

View file

@ -1,71 +0,0 @@
name = "help";
group = "void";
shortDescription = "Print list of commands";
longDescription = "";
argumentTypes = [ "command-or-group-name" ];
function execute() {
if (arguments.length == 0) {
var groups = getCommandGroups();
message("List of command categories:");
message("");
for (var name in groups) {
if (name == "void")
continue;
var data = groups[name];
message(name + " :: " + data.shortDescription);
}
message("");
message("Type \"help\" followed by a category name for a list of commands in that category.");
message("Type \"help all\" for the list of all commands.");
message("Type \"help\" followed by a command name for full documentation.");
message("Command name abbreviations are allowed if they are unambiguous.");
} else {
var arg = arguments[0];
if (arg == "all") {
var groups = getCommandGroups();
for (var name in groups) {
if (name == "void")
continue;
message("Command category: " + name);
message("");
var commands = getCommandsInGroup(name);
for (var i = 0; i < commands.length; ++i) {
var data = commands[i];
message(data.name + " :: " + data.shortDescription);
}
message("");
}
} else {
var data = findCommand(arg);
if (data != undefined) {
message(data.shortDescription + ".");
if (data.longDescription.length != 0)
message(data.longDescription);
if (data.aliases.length != 0)
message("Aliases: " + data.aliases.join(", "));
if (data.seeAlso.length != 0)
message("See also: " + data.seeAlso.join(", "));
} else {
data = getCommandGroups()[arg];
if (data != undefined) {
message(data.shortDescription + ".");
message("");
message("List of commands:");
message("");
var commands = getCommandsInGroup(arg);
for (var i = 0; i < commands.length; ++i) {
var data = commands[i];
message(data.name + " :: " + data.shortDescription);
}
} else {
message("Undefined command \"" + arg + "\". Try \"help\".");
}
}
}
}
};

View file

@ -1,51 +0,0 @@
name = "ignore";
group = "breakpoints";
shortDescription = "Set ignore-count of a breakpoint";
longDescription = "ignore <breakpoint-id> <count> : Ignores the breakpoint with the given id the next count times it is hit.";
seeAlso = [ "condition" ];
function execute() {
if (arguments.length < 1) {
message("Missing arguments (breakpoing number and ignore-count).");
return;
}
if (arguments.length < 2) {
message("Missing argument (ignore-count).");
return;
}
var id = parseInt(arguments[0]);
if (isNaN(id)) {
message("First argument (breakpoint id) must be a number.");
return;
}
var count = parseInt(arguments[1]);
if (isNaN(count)) {
message("Second argument (ignore-count) must be a number.");
return;
}
scheduleGetBreakpointData(id);
breakpointId = id;
if (count < 0)
count = 0;
ignoreCount = count;
state = 1;
}
function handleResponse(resp) {
if (state == 1) {
var data = resp.result;
if (data == undefined) {
message("No breakpoint number " + breakpointId + ".");
return;
}
data.ignoreCount = ignoreCount;
scheduleSetBreakpointData(breakpointId, data);
state = 2;
} else if (state == 2) {
message("Breakpoint " + breakpointId + " will be ignored the next " + ignoreCount + " time(s).");
}
}

View file

@ -1,128 +0,0 @@
name = "info";
group = "status";
shortDescription = "Display information about something";
longDescription = "info scripts : Names of scripts being debugged";
longDescription += "\ninfo breakpoints : Status of breakpoints currently set";
longDescription += "\ninfo locals : Local variables of current stack frame";
argumentTypes = [ "subcommand-name" ];
subCommands = [ "breakpoints", "locals", "scripts" ];
function execute() {
var arg = arguments[0];
if (arg == undefined) {
message("\"info\" must be followed by the name of an info command.");
return;
} else if (arg == "scripts") {
scheduleGetScripts();
state = 1;
} else if (arg == "breakpoints") {
if (arguments.length > 1) {
var id = parseInt(arguments[1]);
if (isNaN(id)) {
message("Breakpoint id expected.");
return;
}
scheduleGetBreakpointData(id);
breakpointId = id;
state = 3;
} else {
scheduleGetBreakpoints();
state = 2;
}
} else if (arg == "locals") {
scheduleGetActivationObject(getCurrentFrameIndex());
state = 4;
} else {
warning("Undefined info command \"" + arg + "\". Try \"help info\".");
}
}
function breakpointString(id, data) {
var fn = data.fileName;
if (fn.length == 0)
fn = "<anonymous script, id=" + data.scriptId + ">";
var ret = id + "\t" + (data.enabled ? "yes" : "no")
+ "\t" + fn + ":" + data.lineNumber;
if (data.condition.length != 0) {
ret += "\n\tstop only if " + data.condition;
}
return ret;
}
function handleResponse(resp) {
if (state == 1) {
// info scripts
var scripts = resp.result;
if (scripts == undefined) {
message("No scripts loaded.");
return;
}
for (var id in scripts) {
var fn = scripts[id].fileName;
if (fn.length == 0)
fn = "<anonymous script, id=" + id + ">";
message("\t" + fn);
}
}
else if (state == 2) {
// info breakpoints
var breakpoints = resp.result;
if (breakpoints == undefined) {
message("No breakpoints set.");
return;
}
message("Id\tEnabled\tWhere");
for (var id in breakpoints) {
var data = breakpoints[id];
message(breakpointString(id, data));
}
} else if (state == 3) {
// info breakpoints N
var data = resp.result;
if (data == undefined) {
message("No breakpoint number " + breakpointId + ".");
return;
}
message("Id\tEnabled\tWhere");
message(breakpointString(breakpointId, data));
}
else if (state == 4) {
// info locals
var act = resp.result;
scheduleNewScriptValueIterator(act);
state = 5;
} else if (state == 5) {
var id = resp.result;
scheduleGetPropertiesByIterator(id, 100);
iteratorId = id;
state = 6;
} else if (state == 6) {
var props = resp.result;
if (props.length == 0) {
scheduleDeleteScriptValueIterator(iteratorId);
state = 7;
return;
}
var maxLength = 0;
for (var i = 0; i < props.length; ++i)
maxLength = Math.max(props[i].name.length, maxLength);
for (var i = 0; i < props.length; ++i) {
var prop = props[i];
var msg = prop.name;
var pad = maxLength - prop.name.length;
for (var j = 0; j < pad; ++j)
msg += ' ';
message(msg + " : " + prop.valueAsString);
}
scheduleGetPropertiesByIterator(iteratorId, 100);
} else if (state == 7) {
// done
}
}

View file

@ -1,14 +0,0 @@
name = "interrupt";
group = "running";
shortDescription = "Interrupt evaluation";
longDescription = "Interruption will occur as soon as a new script statement is reached.";
function execute() {
scheduleInterrupt();
}
function handleResponse(resp) {
}

View file

@ -1,90 +0,0 @@
name = "list";
group = "files";
shortDescription = "List lines of a script";
longDescription = "list <file>:<line> : Lists lines around the given location.";
longDescription += "\nlist <line> : Lists lines in the current file.";
argumentTypes = [ "script-filename" ];
listLineNumber = 1;
listScriptId = -1;
lastSessionId = -1;
lastFrameIndex = -1;
function execute() {
state = 0;
if (arguments.length > 0) {
var arg = arguments[0];
var colonIndex = arg.lastIndexOf(':');
var fileName;
var lineNumber;
if (colonIndex == -1) {
lineNumber = parseInt(arg);
if (isNaN(lineNumber)) {
fileName = arg;
lineNumber = 1;
}
} else if (colonIndex == 0) {
fileName = arg;
lineNumber = 1;
} else {
fileName = arg.slice(0, colonIndex);
lineNumber = parseInt(arg.slice(colonIndex+1));
}
listLineNumber = Math.max(lineNumber, 1);
if (fileName != undefined) {
scheduleResolveScript(fileName);
state = 1;
} else {
setCurrentLineNumber(listLineNumber);
execute();
}
} else {
if ((getSessionId() != lastSessionId)
|| (getCurrentFrameIndex() != lastFrameIndex)
|| (listScriptId == -1)) {
listScriptId = getCurrentScriptId();
listLineNumber = getCurrentLineNumber();
lastSessionId = getSessionId();
lastFrameIndex = getCurrentFrameIndex();
}
scheduleGetScriptData(listScriptId);
state = 2;
}
};
function handleResponse(resp) {
if (state == 1) {
var id = resp.result;
if (id == -1) {
message("That script isn't loaded.");
state = 0;
return;
}
listScriptId = id;
scheduleGetScriptData(listScriptId);
state = 2;
} else if (state == 2) {
var data = resp.result;
if (data == undefined) {
message("No script.");
state = 0;
return;
}
var base = data.baseLineNumber;
var lines = data.contents.split('\n');
var start = Math.max(listLineNumber - 5, base);
for (var i = start; i < start + 10; ++i) {
var ln = lines[i - base];
var msg = String(i);
if (ln != undefined)
msg += "\t" + ln;
message(msg);
}
listLineNumber += 10;
state = 0;
}
}

View file

@ -1,27 +0,0 @@
name = "next";
group = "running";
shortDescription = "Step program, proceeding through subroutine calls";
longDescription = "Like the \"step\" command as long as subroutine calls do not happen;";
longDescription += "\nwhen they do, the call is treated as one instruction.";
longDescription += "\nIf a number N is given as argument, this will be done N times before execution is stopped.";
aliases = [ "n" ];
seeAlso = [ "step", "continue", "finish", "advance" ];
function execute() {
var count = 1;
if (arguments.length != 0) {
var arg = arguments[0];
// ### evaluate the expression in the current frame?
var num = parseInt(arg);
if (!isNaN(num) && (num >= 1))
count = num;
}
scheduleStepOver(count);
};
function handleResponse(resp) {
}

View file

@ -1,23 +0,0 @@
// ### exactly the same as eval, but provided for convenience
name = "print";
group = "status";
shortDescription = "Print value of an expression";
longDescription = "";
argumentTypes = [ "script" ];
function execute() {
if (arguments.length == 0) {
message("Missing argument (expression).");
return;
}
setEvaluateAction(0);
scheduleEvaluate(getCurrentFrameIndex(), arguments[0], "console input (" + Date() + ")");
};
function handleResponse(resp, id) {
}

View file

@ -1,20 +0,0 @@
name = "return";
group = "running";
shortDescription = "Make selected stack frame return to its caller";
longDescription = "";
argumentTypes = [ "script" ];
function execute() {
// TODO:
// 1. schedule evaluate of the expression.
// 2. install event handler/filter, so that we're notified when the evaluate is done.
// - what if another event occurs while we evaluate? (e.g. an exception or breakpoint)
// - the event filter needs to uninstall itself, or the event needs to be consumed internally
// 3. in the event handler, schedule forced return with the result as argument.
setEvaluateAction(1);
scheduleEvaluate(getCurrentFrameIndex(), arguments[0], "console input (" + Date() + ")");
};

View file

@ -1,26 +0,0 @@
name = "step";
group = "running";
shortDescription = "Step program until a new statement is reached";
longDescription = "If a number N is given as argument, this will be done N times before execution is stopped.";
aliases = [ "s" ];
seeAlso = [ "next" ];
function execute() {
var count = 1;
if (arguments.length != 0) {
var arg = arguments[0];
// ### evaluate the expression in the current frame?
var num = parseInt(arg);
if (!isNaN(num) && (num >= 1))
count = num;
}
scheduleStepInto(count);
};
function handleResponse(resp) {
}

View file

@ -1,59 +0,0 @@
name = "tbreak";
group = "breakpoints";
shortDescription = "Set a temporary breakpoint";
longDescription = "The same as the \"break\" command, except that the breakpoint is automatically deleted as soon as it is triggered.";
seeAlso = [ "break", "ignore" ];
argumentTypes = [ "script-filename" ];
// ### merge with break.qs: only difference is the "singleShot: true" in call to scheduleSetBreakpoint()
// ### maybe an include() function so commands can share code?
function execute() {
if (arguments.length == 0) {
message("Missing argument.");
return;
}
var arg = arguments[0];
var colonIndex = arg.lastIndexOf(':');
if (colonIndex == -1) {
lineNumber = parseInt(arg);
if (isNaN(lineNumber)) {
message("Breakpoint location must be of the form <file>:<line> or <line>.");
return;
}
var sid = getCurrentScriptId();
if (sid == -1) {
message("No script.");
return;
}
scheduleGetScriptData(sid);
scriptId = sid;
state = 1;
} else {
fileName = arg.slice(0, colonIndex);
lineNumber = parseInt(arg.slice(colonIndex+1));
// ### resolve the script to see if it's loaded or not? (e.g. so we can issue a warning)
scheduleSetBreakpoint({ fileName: fileName, lineNumber: lineNumber, singleShot: true });
state = 2;
}
}
function handleResponse(resp) {
if (state == 1) {
fileName = resp.result.fileName;
if (fileName.length == 0)
fileName = "<anonymous script, id=" + scriptId + ">";
scheduleSetBreakpoint({ scriptId: scriptId, lineNumber: lineNumber, singleShot: true });
state = 2;
} else if (state == 2) {
if (resp.error == 0) {
var id = resp.result;
message("Breakpoint " + id + ": " + fileName + ", line " + lineNumber + ".");
}
}
}

View file

@ -1,37 +0,0 @@
name = "up";
group = "stack";
shortDescription = "Select and print the stack frame above the current one";
longDescription = "";
seeAlso = [ "down", "frame" ];
function execute() {
scheduleGetContextCount();
state = 1;
}
function handleResponse(resp) {
if (state == 1) {
var count = resp.result;
var idx = getCurrentFrameIndex() + 1;
if (idx == count) {
warning("Already at top (outermost) frame.");
return;
}
setCurrentFrameIndex(idx);
scheduleGetContextInfo(idx);
state = 2;
} else if (state == 2) {
var info = resp.result;
setCurrentScriptId(info.scriptId);
setCurrentLineNumber(info.lineNumber);
scheduleGetBacktrace();
state = 3;
} else if (state == 3) {
var backtrace = resp.result;
message("#" + getCurrentFrameIndex() + " " + backtrace[getCurrentFrameIndex()]);
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1 KiB

View file

@ -1,154 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://web.resource.org/cc/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="14"
height="14"
id="svg2270"
sodipodi:version="0.32"
inkscape:version="0.45.1"
version="1.0"
sodipodi:docbase="D:\depot\research\main\editor\images"
sodipodi:docname="breakpoint.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape">
<defs
id="defs2272">
<linearGradient
id="linearGradient7029">
<stop
style="stop-color:#ffffff;stop-opacity:1;"
offset="0"
id="stop7031" />
<stop
style="stop-color:#ffffff;stop-opacity:0;"
offset="1"
id="stop7033" />
</linearGradient>
<linearGradient
id="linearGradient17794">
<stop
style="stop-color:#f18383;stop-opacity:1;"
offset="0"
id="stop17798" />
<stop
id="stop8006"
offset="0.3807947"
style="stop-color:#ed6767;stop-opacity:1;" />
<stop
style="stop-color:#e62323;stop-opacity:1;"
offset="1"
id="stop17796" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient17794"
id="linearGradient24732"
gradientUnits="userSpaceOnUse"
x1="472.42236"
y1="436.79602"
x2="461.39169"
y2="424.95065" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient17794"
id="linearGradient2438"
gradientUnits="userSpaceOnUse"
x1="472.42236"
y1="436.79602"
x2="461.39169"
y2="424.95065" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient17794"
id="radialGradient6052"
cx="466.73566"
cy="431.19708"
fx="466.73566"
fy="431.19708"
r="9.3095722"
gradientTransform="matrix(1,0,0,1.0057859,0,-2.4948735)"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient7029"
id="linearGradient7035"
x1="6.75"
y1="0.5"
x2="6.75"
y2="12.5"
gradientUnits="userSpaceOnUse" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
gridtolerance="10000"
guidetolerance="10"
objecttolerance="10"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="32"
inkscape:cx="8.6877264"
inkscape:cy="6.3888789"
inkscape:document-units="px"
inkscape:current-layer="g25843"
width="14px"
height="14px"
inkscape:window-width="1280"
inkscape:window-height="998"
inkscape:window-x="0"
inkscape:window-y="0"
showgrid="true"
gridspacingx="0.5px"
gridspacingy="0.5px"
gridempspacing="2"
inkscape:grid-points="true" />
<metadata
id="metadata2275">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<g
id="g25843"
transform="matrix(0.7931251,0,0,0.7931251,-372.13374,-408.22195)">
<path
sodipodi:type="arc"
style="fill:url(#radialGradient6052);fill-opacity:1.0;stroke:#c80000;stroke-width:1.43637741;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path22737"
sodipodi:cx="466.73566"
sodipodi:cy="431.19708"
sodipodi:rx="8.5913839"
sodipodi:ry="8.6452484"
d="M 475.32704 431.19708 A 8.5913839 8.6452484 0 1 1 458.14427,431.19708 A 8.5913839 8.6452484 0 1 1 475.32704 431.19708 z"
transform="matrix(0.8805346,0,0,0.8750503,66.41784,145.57686)" />
<path
sodipodi:type="arc"
style="opacity:1;fill:url(#linearGradient7035);fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path6058"
sodipodi:cx="6.75"
sodipodi:cy="6.5"
sodipodi:rx="5.75"
sodipodi:ry="6"
d="M 12.5 6.5 A 5.75 6 0 1 1 1,6.5 A 5.75 6 0 1 1 12.5 6.5 z"
transform="matrix(0.9867408,0,0,0.6304178,470.73423,515.01579)" />
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 375 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1 KiB

View file

@ -1,154 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://web.resource.org/cc/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="14"
height="14"
id="svg2270"
sodipodi:version="0.32"
inkscape:version="0.45.1"
version="1.0"
sodipodi:docbase="D:\depot\research\main\editor\images"
sodipodi:docname="breakpoint.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape">
<defs
id="defs2272">
<linearGradient
id="linearGradient7029">
<stop
style="stop-color:#cfcfcf;stop-opacity:1;"
offset="0"
id="stop7031" />
<stop
style="stop-color:#cfcfcf;stop-opacity:0;"
offset="1"
id="stop7033" />
</linearGradient>
<linearGradient
id="linearGradient17794">
<stop
style="stop-color:#917373;stop-opacity:1;"
offset="0"
id="stop17798" />
<stop
id="stop8006"
offset="0.3807947"
style="stop-color:#8d5757;stop-opacity:1;" />
<stop
style="stop-color:#862323;stop-opacity:1;"
offset="1"
id="stop17796" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient17794"
id="linearGradient24732"
gradientUnits="userSpaceOnUse"
x1="472.42236"
y1="436.79602"
x2="461.39169"
y2="424.95065" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient17794"
id="linearGradient2438"
gradientUnits="userSpaceOnUse"
x1="472.42236"
y1="436.79602"
x2="461.39169"
y2="424.95065" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient17794"
id="radialGradient6052"
cx="466.73566"
cy="431.19708"
fx="466.73566"
fy="431.19708"
r="9.3095722"
gradientTransform="matrix(1,0,0,1.0057859,0,-2.4948735)"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient7029"
id="linearGradient7035"
x1="6.75"
y1="0.5"
x2="6.75"
y2="12.5"
gradientUnits="userSpaceOnUse" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
gridtolerance="10000"
guidetolerance="10"
objecttolerance="10"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="32"
inkscape:cx="8.6877264"
inkscape:cy="6.3888789"
inkscape:document-units="px"
inkscape:current-layer="g25843"
width="14px"
height="14px"
inkscape:window-width="1280"
inkscape:window-height="998"
inkscape:window-x="0"
inkscape:window-y="0"
showgrid="true"
gridspacingx="0.5px"
gridspacingy="0.5px"
gridempspacing="2"
inkscape:grid-points="true" />
<metadata
id="metadata2275">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<g
id="g25843"
transform="matrix(0.7931251,0,0,0.7931251,-372.13374,-408.22195)">
<path
sodipodi:type="arc"
style="fill:url(#radialGradient6052);fill-opacity:1.0;stroke:#872727;stroke-width:1.43637741;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path22737"
sodipodi:cx="466.73566"
sodipodi:cy="431.19708"
sodipodi:rx="8.5913839"
sodipodi:ry="8.6452484"
d="M 475.32704 431.19708 A 8.5913839 8.6452484 0 1 1 458.14427,431.19708 A 8.5913839 8.6452484 0 1 1 475.32704 431.19708 z"
transform="matrix(0.8805346,0,0,0.8750503,66.41784,145.57686)" />
<path
sodipodi:type="arc"
style="opacity:1;fill:url(#linearGradient7035);fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path6058"
sodipodi:cx="6.75"
sodipodi:cy="6.5"
sodipodi:rx="5.75"
sodipodi:ry="6"
d="M 12.5 6.5 A 5.75 6 0 1 1 1,6.5 A 5.75 6 0 1 1 12.5 6.5 z"
transform="matrix(0.9867408,0,0,0.6304178,470.73423,515.01579)" />
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 712 B

View file

@ -1,121 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://web.resource.org/cc/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="14"
height="14"
id="svg2243"
sodipodi:version="0.32"
inkscape:version="0.45.1"
version="1.0"
sodipodi:docbase="c:\depot\research\main\editor\images"
sodipodi:docname="location.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape">
<defs
id="defs2245">
<linearGradient
id="linearGradient3134">
<stop
style="stop-color:#dcdc23;stop-opacity:1;"
offset="0"
id="stop3136" />
<stop
id="stop5080"
offset="0.64285713"
style="stop-color:#e5d044;stop-opacity:1;" />
<stop
style="stop-color:#b89354;stop-opacity:1;"
offset="1"
id="stop3138" />
</linearGradient>
<linearGradient
id="linearGradient3137">
<stop
style="stop-color:#ffffff;stop-opacity:0.86274511;"
offset="0"
id="stop3139" />
<stop
style="stop-color:#ffffff;stop-opacity:0;"
offset="1"
id="stop3141" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3137"
id="linearGradient3143"
x1="6.5"
y1="3"
x2="6.515625"
y2="12.180227"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3134"
id="linearGradient3140"
x1="6.5"
y1="3.015625"
x2="6.484375"
y2="11.984375"
gradientUnits="userSpaceOnUse" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
gridtolerance="10000"
guidetolerance="10"
objecttolerance="10"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="64"
inkscape:cx="8.3920091"
inkscape:cy="7.4257237"
inkscape:document-units="px"
inkscape:current-layer="layer1"
width="14px"
height="14px"
showborder="true"
inkscape:window-width="1600"
inkscape:window-height="1174"
inkscape:window-x="0"
inkscape:window-y="0"
gridempspacing="2"
showgrid="true"
inkscape:grid-points="true"
gridspacingx="0.5px"
gridspacingy="0.5px" />
<metadata
id="metadata2248">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<path
style="fill:url(#linearGradient3140);fill-opacity:1.0;fill-rule:evenodd;stroke:#b18b1b;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 6.5,3 L 6.5,5.5 L 0.5,5.5 L 0.5,9.5 L 6.5,9.5 L 6.5,12 L 13.125,7.5 L 6.5,3 z "
id="path2216"
sodipodi:nodetypes="cccccccc" />
<path
style="fill:url(#linearGradient3143);fill-opacity:1.0;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;opacity:1"
d="M 6.5,3 L 6.5,5.5 L 0.5,5.5 L 0.5,7.5 C 7,6.5 7.5,9.5 13,7.5 L 6.5,3 z "
id="path5066"
sodipodi:nodetypes="cccccc" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 243 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 534 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 278 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 273 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 275 B

View file

@ -943,9 +943,6 @@ include/katie/QtScript/qscriptprogram.h
include/katie/QtScript/qscriptstring.h
include/katie/QtScript/qscriptvalue.h
include/katie/QtScript/qscriptvalueiterator.h
include/katie/QtScriptTools/QScriptEngineDebugger
include/katie/QtScriptTools/QtScriptTools
include/katie/QtScriptTools/qscriptenginedebugger.h
include/katie/QtSvg/QSvgRenderer
include/katie/QtSvg/QtSvg
include/katie/QtSvg/qsvgrenderer.h

View file

@ -393,7 +393,6 @@ classlist = [
"QScriptContextInfoList",
"QScriptEngine",
"QScriptEngineAgent",
"QScriptEngineDebugger",
"QScriptExtensionInterface",
"QScriptExtensionPlugin",
"QScriptProgram",
@ -666,7 +665,6 @@ classlist = [
"QtPlugin",
"QtPluginInstanceFunction",
"QtScript",
"QtScriptTools",
"QtSvg",
"QtTest",
"QtTestGui",

View file

@ -1621,28 +1621,6 @@ int qrand()
with meaningful parameter names in their signatures.
*/
Q_GLOBAL_STATIC(QStdVector<qInternalCallback>, qGlobalCallbacks)
void QInternal::registerCallback(qInternalCallback callback)
{
qGlobalCallbacks()->append(callback);
}
void QInternal::unregisterCallback(qInternalCallback callback)
{
qGlobalCallbacks()->removeAll(callback);
}
bool QInternal::activateCallbacks(void **parameters)
{
QStdVector<qInternalCallback> *callbacks = qGlobalCallbacks();
bool ret = false;
for (int i = 0; i < callbacks->size(); i++) {
ret |= (callbacks->at(i))(parameters);
}
return ret;
}
/*!
\macro Q_BYTE_ORDER
\relates <QtGlobal>

View file

@ -1106,8 +1106,6 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::ItemFlags)
Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::MatchFlags)
Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::TextInteractionFlags)
typedef bool (*qInternalCallback)(void **);
class Q_CORE_EXPORT QInternal {
public:
enum PaintDeviceFlags {
@ -1125,11 +1123,6 @@ public:
BottomDock,
DockCount
};
static void registerCallback(qInternalCallback);
static void unregisterCallback(qInternalCallback);
static bool activateCallbacks(void **);
};
QT_END_NAMESPACE

View file

@ -419,13 +419,6 @@ bool QCoreApplication::testAttribute(Qt::ApplicationAttribute attribute)
*/
bool QCoreApplication::notifyInternal(QObject *receiver, QEvent *event)
{
// only script debugger uses the callbacks
bool result = false;
void *cbdata[] = { receiver, event, &result };
if (Q_UNLIKELY(QInternal::activateCallbacks(cbdata))) {
return result;
}
// Qt enforces the rule that events can only be sent to objects in
// the current thread, so receiver->d_func()->threadData is
// equivalent to QThreadData::current(), just without the function

View file

@ -1,197 +0,0 @@
# add_definitions()
set(EXTRA_SCRIPTTOOLS_LIBS
KtCore KtXml KtGui KtScript
)
set(SCRIPTTOOLS_PUBLIC_HEADERS
QScriptEngineDebugger
)
include_directories(
${CMAKE_BINARY_DIR}/include
${CMAKE_BINARY_DIR}/privateinclude
${CMAKE_BINARY_DIR}/include/QtCore
${CMAKE_BINARY_DIR}/include/QtGui
${CMAKE_BINARY_DIR}/include/QtScript
${CMAKE_BINARY_DIR}/include/QtScriptTools
)
set(SCRIPTTOOLS_HEADERS
${SCRIPTTOOLS_HEADERS}
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggervalue_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggervalueproperty_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerobjectsnapshotdelta_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggercommand_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggercommandschedulerinterface_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggercommandschedulerfrontend_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerresponse_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerresponsehandlerinterface_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerevent_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggercommandexecutor_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerbackend_p_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerbackend_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggeragent_p_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggeragent_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerfrontend_p_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerfrontend_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptmessagehandlerinterface_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptstdmessagehandler_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptenginedebuggerfrontend_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerjob_p_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerjob_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggercommandschedulerjob_p_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggercommandschedulerjob_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerjobschedulerinterface_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggereventhandlerinterface_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptvalueproperty_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptobjectsnapshot_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptscriptdata_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptxmlparser_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptbreakpointdata_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebugger_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerconsole_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerconsolecommand_p_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerconsolecommand_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerconsolecommandjob_p_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerconsolecommandjob_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerconsolecommandgroupdata_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerconsolecommandmanager_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerconsolehistorianinterface_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptcompletionproviderinterface_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptcompletiontaskinterface_p_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptcompletiontaskinterface_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptcompletiontask_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscripttooltipproviderinterface_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerconsoleglobalobject_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerscriptedconsolecommand_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerconsolewidgetinterface_p_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerconsolewidgetinterface_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerconsolewidget_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerstackwidgetinterface_p_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerstackwidgetinterface_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerstackwidget_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerstackmodel_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerscriptswidgetinterface_p_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerscriptswidgetinterface_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerscriptswidget_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerscriptsmodel_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerlocalswidgetinterface_p_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerlocalswidgetinterface_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerlocalswidget_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerlocalsmodel_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggercodewidgetinterface_p_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggercodewidgetinterface_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggercodewidget_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggercodeviewinterface_p_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggercodeviewinterface_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggercodeview_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggercodefinderwidgetinterface_p_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggercodefinderwidgetinterface_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggercodefinderwidget_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebugoutputwidgetinterface_p_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebugoutputwidgetinterface_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebugoutputwidget_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptbreakpointswidgetinterface_p_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptbreakpointswidgetinterface_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptbreakpointswidget_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptbreakpointsmodel_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscripterrorlogwidgetinterface_p_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscripterrorlogwidgetinterface_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscripterrorlogwidget_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerwidgetfactoryinterface_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerstandardwidgetfactory_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptedit_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptsyntaxhighlighter_p.h
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptenginedebugger.h
${CMAKE_CURRENT_SOURCE_DIR}/qscripttoolscommon_p.h
${CMAKE_CURRENT_SOURCE_DIR}/qscripttoolsresources_p.h
)
set(SCRIPTTOOLS_SOURCES
${SCRIPTTOOLS_SOURCES}
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggervalue.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggervalueproperty.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggercommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerresponse.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerevent.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggercommandexecutor.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggercommandschedulerfrontend.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerbackend.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggeragent.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerfrontend.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptstdmessagehandler.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptenginedebuggerfrontend.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerjob.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggercommandschedulerjob.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptvalueproperty.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptobjectsnapshot.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptscriptdata.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptxmlparser.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptbreakpointdata.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebugger.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerconsole.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerconsolecommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerconsolecommandjob.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerconsolecommandgroupdata.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerconsolecommandmanager.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptcompletiontaskinterface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptcompletiontask.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerconsoleglobalobject.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerscriptedconsolecommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerconsolewidgetinterface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerconsolewidget.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerstackwidgetinterface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerstackwidget.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerstackmodel.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerscriptswidgetinterface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerscriptswidget.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerscriptsmodel.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerlocalswidgetinterface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerlocalswidget.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerlocalsmodel.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggercodewidgetinterface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggercodewidget.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggercodeviewinterface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggercodeview.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggercodefinderwidgetinterface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggercodefinderwidget.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebugoutputwidgetinterface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebugoutputwidget.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptbreakpointswidgetinterface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptbreakpointswidget.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptbreakpointsmodel.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscripterrorlogwidgetinterface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscripterrorlogwidget.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptdebuggerstandardwidgetfactory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptedit.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptsyntaxhighlighter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugging/qscriptenginedebugger.cpp
)
katie_generate_misc("${SCRIPTTOOLS_HEADERS}" QtScriptTools)
katie_generate_public("${SCRIPTTOOLS_PUBLIC_HEADERS}" QtScriptTools)
katie_generate_package(KtScriptTools "KtCore KtXml KtGui KtScript")
katie_setup_target(KtScriptTools ${SCRIPTTOOLS_SOURCES} ${SCRIPTTOOLS_HEADERS})
add_library(KtScriptTools ${KATIE_TYPE} ${KtScriptTools_SOURCES})
target_link_libraries(KtScriptTools PRIVATE ${EXTRA_SCRIPTTOOLS_LIBS})
set_target_properties(KtScriptTools PROPERTIES
VERSION ${KATIE_MAJOR}.${KATIE_MINOR}
SOVERSION ${KATIE_VERSION}
EXPORT_NAME ScriptTools
)
install(
TARGETS KtScriptTools
EXPORT KatieTargets
DESTINATION ${KATIE_LIBRARIES_PATH}
COMPONENT Runtime
)
install(
DIRECTORY ${CMAKE_BINARY_DIR}/include/QtScriptTools
DESTINATION ${KATIE_HEADERS_PATH}
COMPONENT Devel
)
katie_optimize_headers(${KATIE_HEADERS_PATH}/QtScriptTools)

View file

@ -1,372 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qscriptbreakpointdata_p.h"
#include <QtCore/qdatastream.h>
#include <QtCore/qstring.h>
#include <QtCore/qvariant.h>
QT_BEGIN_NAMESPACE
/*!
\since 4.5
\class QScriptBreakpointData
\internal
\brief The QScriptBreakpointData class contains data associated with a breakpoint.
*/
class QScriptBreakpointDataPrivate
{
public:
QScriptBreakpointDataPrivate();
~QScriptBreakpointDataPrivate();
void init(int ln);
qint64 scriptId;
QString fileName;
int lineNumber;
bool enabled;
bool singleShot;
int ignoreCount;
QString condition;
QVariant data;
int hitCount;
};
QScriptBreakpointDataPrivate::QScriptBreakpointDataPrivate()
{
}
QScriptBreakpointDataPrivate::~QScriptBreakpointDataPrivate()
{
}
void QScriptBreakpointDataPrivate::init(int ln)
{
scriptId = -1;
lineNumber = ln;
enabled = true;
singleShot = false;
ignoreCount = 0;
hitCount = 0;
}
/*!
Constructs an empty QScriptBreakpointData.
*/
QScriptBreakpointData::QScriptBreakpointData()
: d_ptr(new QScriptBreakpointDataPrivate)
{
d_ptr->init(/*lineNumber=*/-1);
}
/*!
Constructs a QScriptBreakpointData with the given \a lineNumber.
*/
QScriptBreakpointData::QScriptBreakpointData(qint64 scriptId, int lineNumber)
: d_ptr(new QScriptBreakpointDataPrivate)
{
d_ptr->init(lineNumber);
d_ptr->scriptId = scriptId;
}
/*!
Constructs a QScriptBreakpointData with the given \a lineNumber.
*/
QScriptBreakpointData::QScriptBreakpointData(const QString &fileName, int lineNumber)
: d_ptr(new QScriptBreakpointDataPrivate)
{
d_ptr->init(lineNumber);
d_ptr->fileName = fileName;
}
/*!
Constructs a QScriptBreakpointData that is a copy of \a other.
*/
QScriptBreakpointData::QScriptBreakpointData(const QScriptBreakpointData &other)
: d_ptr(new QScriptBreakpointDataPrivate)
{
Q_ASSERT(other.d_ptr != 0);
*d_ptr = *other.d_ptr;
}
/*!
Destroys this QScriptBreakpointData.
*/
QScriptBreakpointData::~QScriptBreakpointData()
{
}
/*!
Assigns \a other to this QScriptBreakpointData.
*/
QScriptBreakpointData &QScriptBreakpointData::operator=(const QScriptBreakpointData &other)
{
Q_ASSERT(d_ptr != 0);
Q_ASSERT(other.d_ptr != 0);
*d_ptr = *other.d_ptr;
return *this;
}
qint64 QScriptBreakpointData::scriptId() const
{
Q_D(const QScriptBreakpointData);
return d->scriptId;
}
void QScriptBreakpointData::setScriptId(qint64 id)
{
Q_D(QScriptBreakpointData);
d->scriptId = id;
}
QString QScriptBreakpointData::fileName() const
{
Q_D(const QScriptBreakpointData);
return d->fileName;
}
void QScriptBreakpointData::setFileName(const QString &fileName)
{
Q_D(QScriptBreakpointData);
d->fileName = fileName;
}
/*!
Returns the breakpoint line number.
*/
int QScriptBreakpointData::lineNumber() const
{
Q_D(const QScriptBreakpointData);
return d->lineNumber;
}
/*!
Sets the breakpoint line number to \a lineNumber.
*/
void QScriptBreakpointData::setLineNumber(int lineNumber)
{
Q_D(QScriptBreakpointData);
d->lineNumber = lineNumber;
}
/*!
Returns true if the breakpoint is enabled, false otherwise.
*/
bool QScriptBreakpointData::isEnabled() const
{
Q_D(const QScriptBreakpointData);
return d->enabled;
}
/*!
Sets the \a enabled state of the breakpoint.
*/
void QScriptBreakpointData::setEnabled(bool enabled)
{
Q_D(QScriptBreakpointData);
d->enabled = enabled;
}
/*!
Returns true if the breakpoint is single-shot, false otherwise.
*/
bool QScriptBreakpointData::isSingleShot() const
{
Q_D(const QScriptBreakpointData);
return d->singleShot;
}
/*!
Sets the \a singleShot state of the breakpoint.
*/
void QScriptBreakpointData::setSingleShot(bool singleShot)
{
Q_D(QScriptBreakpointData);
d->singleShot = singleShot;
}
/*!
Returns the ignore count of the breakpoint.
*/
int QScriptBreakpointData::ignoreCount() const
{
Q_D(const QScriptBreakpointData);
return d->ignoreCount;
}
/*!
Sets the ignore \a count of the breakpoint.
*/
void QScriptBreakpointData::setIgnoreCount(int count)
{
Q_D(QScriptBreakpointData);
d->ignoreCount = count;
}
/*!
If the ignore count is 0, this function increments the hit count and
returns true. Otherwise, it decrements the ignore count and returns
false.
*/
bool QScriptBreakpointData::hit()
{
Q_D(QScriptBreakpointData);
if (d->ignoreCount == 0) {
++d->hitCount;
return true;
}
--d->ignoreCount;
return false;
}
/*!
Returns the hit count of the breakpoint (the number of times the
breakpoint has been triggered).
*/
int QScriptBreakpointData::hitCount() const
{
Q_D(const QScriptBreakpointData);
return d->hitCount;
}
/*!
Returns the condition of the breakpoint.
*/
QString QScriptBreakpointData::condition() const
{
Q_D(const QScriptBreakpointData);
return d->condition;
}
/*!
Sets the \a condition of the breakpoint.
*/
void QScriptBreakpointData::setCondition(const QString &condition)
{
Q_D(QScriptBreakpointData);
d->condition = condition;
}
/*!
Returns custom data associated with the breakpoint.
*/
QVariant QScriptBreakpointData::data() const
{
Q_D(const QScriptBreakpointData);
return d->data;
}
/*!
Sets custom \a data associated with the breakpoint.
*/
void QScriptBreakpointData::setData(const QVariant &data)
{
Q_D(QScriptBreakpointData);
d->data = data;
}
bool QScriptBreakpointData::isValid() const
{
Q_D(const QScriptBreakpointData);
return (((d->scriptId != -1) || !d->fileName.isEmpty())
&& (d->lineNumber != -1));
}
/*!
Returns true if this QScriptBreakpointData is equal to the \a other
data, otherwise returns false.
*/
bool QScriptBreakpointData::operator==(const QScriptBreakpointData &other) const
{
Q_D(const QScriptBreakpointData);
const QScriptBreakpointDataPrivate *od = other.d_func();
if (d == od)
return true;
if (!d || !od)
return false;
return ((d->scriptId == od->scriptId)
&& (d->fileName == od->fileName)
&& (d->lineNumber == od->lineNumber)
&& (d->enabled == od->enabled)
&& (d->singleShot == od->singleShot)
&& (d->condition == od->condition)
&& (d->ignoreCount == od->ignoreCount)
&& (d->data == od->data)
&& (d->hitCount == od->hitCount));
}
/*!
Returns true if this QScriptBreakpointData is not equal to the \a
other data, otherwise returns false.
*/
bool QScriptBreakpointData::operator!=(const QScriptBreakpointData &other) const
{
return !(*this == other);
}
/*!
\fn QDataStream &operator<<(QDataStream &stream, const QScriptBreakpointData &data)
\relates QScriptBreakpointData
Writes the given \a data to the specified \a stream.
*/
QDataStream &operator<<(QDataStream &out, const QScriptBreakpointData &data)
{
const QScriptBreakpointDataPrivate *d = data.d_ptr.data();
out << d->scriptId;
out << d->fileName;
out << d->lineNumber;
out << d->enabled;
out << d->singleShot;
out << d->ignoreCount;
out << d->condition;
out << d->data;
out << d->hitCount;
return out;
}
/*!
\fn QDataStream &operator>>(QDataStream &stream, QScriptBreakpointData &data)
\relates QScriptBreakpointData
Reads a QScriptBreakpointData from the specified \a stream into the
given \a data.
*/
QDataStream &operator>>(QDataStream &in, QScriptBreakpointData &data)
{
QScriptBreakpointDataPrivate *d = data.d_ptr.data();
in >> d->scriptId;
in >> d->fileName;
in >> d->lineNumber;
in >> d->enabled;
in >> d->singleShot;
in >> d->ignoreCount;
in >> d->condition;
in >> d->data;
in >> d->hitCount;
return in;
}
QT_END_NAMESPACE

View file

@ -1,109 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTBREAKPOINTDATA_P_H
#define QSCRIPTBREAKPOINTDATA_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtCore/qobjectdefs.h>
#include <QtCore/qscopedpointer.h>
#include <QtCore/qmap.h>
QT_BEGIN_NAMESPACE
class QDataStream;
class QVariant;
class QScriptBreakpointDataPrivate;
class Q_AUTOTEST_EXPORT QScriptBreakpointData
{
public:
friend Q_AUTOTEST_EXPORT QDataStream &operator<<(QDataStream &, const QScriptBreakpointData &);
friend Q_AUTOTEST_EXPORT QDataStream &operator>>(QDataStream &, QScriptBreakpointData &);
QScriptBreakpointData();
QScriptBreakpointData(qint64 scriptId, int lineNumber);
QScriptBreakpointData(const QString &fileName, int lineNumber);
QScriptBreakpointData(const QScriptBreakpointData &other);
~QScriptBreakpointData();
QScriptBreakpointData &operator=(const QScriptBreakpointData &other);
bool isValid() const;
// location
qint64 scriptId() const;
void setScriptId(qint64 id);
QString fileName() const;
void setFileName(const QString &fileName);
int lineNumber() const;
void setLineNumber(int lineNumber);
// data
bool isEnabled() const;
void setEnabled(bool enabled);
bool isSingleShot() const;
void setSingleShot(bool singleShot);
int ignoreCount() const;
void setIgnoreCount(int count);
QString condition() const;
void setCondition(const QString &condition);
QVariant data() const;
void setData(const QVariant &data);
bool hit();
// statistics
int hitCount() const;
bool operator==(const QScriptBreakpointData &other) const;
bool operator!=(const QScriptBreakpointData &other) const;
private:
QScopedPointer<QScriptBreakpointDataPrivate> d_ptr;
Q_DECLARE_PRIVATE(QScriptBreakpointData)
};
typedef QMap<int, QScriptBreakpointData> QScriptBreakpointMap;
Q_AUTOTEST_EXPORT QDataStream &operator<<(QDataStream &, const QScriptBreakpointData &);
Q_AUTOTEST_EXPORT QDataStream &operator>>(QDataStream &, QScriptBreakpointData &);
QT_END_NAMESPACE
#endif

View file

@ -1,478 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qscriptbreakpointsmodel_p.h"
#include "qscriptdebuggerjobschedulerinterface_p.h"
#include "qscriptdebuggercommandschedulerjob_p.h"
#include "qscriptdebuggercommandschedulerfrontend_p.h"
#include "qabstractitemmodel_p.h"
#include <QtCore/qpair.h>
#include <QtCore/qcoreapplication.h>
#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
/*!
\since 4.5
\class QScriptBreakpointsModel
\internal
*/
class QScriptBreakpointsModelPrivate
: public QAbstractItemModelPrivate
{
Q_DECLARE_PUBLIC(QScriptBreakpointsModel)
public:
QScriptBreakpointsModelPrivate();
~QScriptBreakpointsModelPrivate();
QScriptDebuggerJobSchedulerInterface *jobScheduler;
QScriptDebuggerCommandSchedulerInterface *commandScheduler;
QList<QPair<int, QScriptBreakpointData> > breakpoints;
};
QScriptBreakpointsModelPrivate::QScriptBreakpointsModelPrivate()
{
}
QScriptBreakpointsModelPrivate::~QScriptBreakpointsModelPrivate()
{
}
QScriptBreakpointsModel::QScriptBreakpointsModel(
QScriptDebuggerJobSchedulerInterface *jobScheduler,
QScriptDebuggerCommandSchedulerInterface *commandScheduler,
QObject *parent)
: QAbstractItemModel(*new QScriptBreakpointsModelPrivate, parent)
{
Q_D(QScriptBreakpointsModel);
d->jobScheduler = jobScheduler;
d->commandScheduler = commandScheduler;
}
QScriptBreakpointsModel::~QScriptBreakpointsModel()
{
}
namespace
{
class SetBreakpointJob : public QScriptDebuggerCommandSchedulerJob
{
public:
SetBreakpointJob(const QScriptBreakpointData &data,
QScriptDebuggerCommandSchedulerInterface *scheduler)
: QScriptDebuggerCommandSchedulerJob(scheduler),
m_data(data)
{ }
void start()
{
QScriptDebuggerCommandSchedulerFrontend frontend(commandScheduler(), this);
frontend.scheduleSetBreakpoint(m_data);
}
void handleResponse(const QScriptDebuggerResponse &, int)
{
finish();
}
private:
QScriptBreakpointData m_data;
};
} // namespace
/*!
Sets a breakpoint defined by the given \a data.
A new row will be inserted into the model if the breakpoint could be
successfully set.
*/
void QScriptBreakpointsModel::setBreakpoint(const QScriptBreakpointData &data)
{
Q_D(QScriptBreakpointsModel);
QScriptDebuggerJob *job = new SetBreakpointJob(data, d->commandScheduler);
d->jobScheduler->scheduleJob(job);
}
namespace
{
class SetBreakpointDataJob : public QScriptDebuggerCommandSchedulerJob
{
public:
SetBreakpointDataJob(int id, const QScriptBreakpointData &data,
QScriptDebuggerCommandSchedulerInterface *scheduler)
: QScriptDebuggerCommandSchedulerJob(scheduler),
m_id(id), m_data(data)
{ }
void start()
{
QScriptDebuggerCommandSchedulerFrontend frontend(commandScheduler(), this);
frontend.scheduleSetBreakpointData(m_id, m_data);
}
void handleResponse(const QScriptDebuggerResponse &, int)
{
finish();
}
private:
int m_id;
QScriptBreakpointData m_data;
};
} // namespace
/*!
Sets the \a data associated with the breakpoint identified by \a id.
A dataChanged() signal will be emitted if the breakpoint data could
be successfully changed.
*/
void QScriptBreakpointsModel::setBreakpointData(int id, const QScriptBreakpointData &data)
{
Q_D(QScriptBreakpointsModel);
QScriptDebuggerJob *job = new SetBreakpointDataJob(id, data, d->commandScheduler);
d->jobScheduler->scheduleJob(job);
}
namespace
{
class DeleteBreakpointJob : public QScriptDebuggerCommandSchedulerJob
{
public:
DeleteBreakpointJob(int id, QScriptDebuggerCommandSchedulerInterface *scheduler)
: QScriptDebuggerCommandSchedulerJob(scheduler),
m_id(id)
{ }
void start()
{
QScriptDebuggerCommandSchedulerFrontend frontend(commandScheduler(), this);
frontend.scheduleDeleteBreakpoint(m_id);
}
void handleResponse(const QScriptDebuggerResponse &, int)
{
finish();
}
private:
int m_id;
};
} // namespace
/*!
Deletes the breakpoint with the given \a id.
The corresponding row in the model will be removed if the breakpoint
was successfully deleted.
*/
void QScriptBreakpointsModel::deleteBreakpoint(int id)
{
Q_D(QScriptBreakpointsModel);
QScriptDebuggerJob *job = new DeleteBreakpointJob(id, d->commandScheduler);
d->jobScheduler->scheduleJob(job);
}
/*!
Adds a breakpoint to the model. This function does not actually set
a breakpoint (i.e. it doesn't communicate with the debugger).
*/
void QScriptBreakpointsModel::addBreakpoint(int id, const QScriptBreakpointData &data)
{
Q_D(QScriptBreakpointsModel);
int rowIndex = d->breakpoints.size();
beginInsertRows(QModelIndex(), rowIndex, rowIndex);
d->breakpoints.append(qMakePair(id, data));
endInsertRows();
}
/*!
Modify the \a data of breakpoint \a id.
*/
void QScriptBreakpointsModel::modifyBreakpoint(int id, const QScriptBreakpointData &data)
{
Q_D(QScriptBreakpointsModel);
for (int i = 0; i < d->breakpoints.size(); ++i) {
if (d->breakpoints.at(i).first == id) {
d->breakpoints[i] = qMakePair(id, data);
emit dataChanged(createIndex(i, 0), createIndex(i, columnCount()-1));
break;
}
}
}
/*!
Remove the breakpoint identified by \a id from the model. This
function does not delete the breakpoint (i.e. it doesn't communicate
with the debugger).
*/
void QScriptBreakpointsModel::removeBreakpoint(int id)
{
Q_D(QScriptBreakpointsModel);
for (int i = 0; i < d->breakpoints.size(); ++i) {
if (d->breakpoints.at(i).first == id) {
beginRemoveRows(QModelIndex(), i, i);
d->breakpoints.removeAt(i);
endRemoveRows();
break;
}
}
}
/*!
Returns the id of the breakpoint at the given \a row.
*/
int QScriptBreakpointsModel::breakpointIdAt(int row) const
{
Q_D(const QScriptBreakpointsModel);
return d->breakpoints.at(row).first;
}
/*!
Returns the data for the breakpoint at the given \a row.
*/
QScriptBreakpointData QScriptBreakpointsModel::breakpointDataAt(int row) const
{
Q_D(const QScriptBreakpointsModel);
return d->breakpoints.at(row).second;
}
QScriptBreakpointData QScriptBreakpointsModel::breakpointData(int id) const
{
Q_D(const QScriptBreakpointsModel);
for (int i = 0; i < d->breakpoints.size(); ++i) {
if (d->breakpoints.at(i).first == id)
return d->breakpoints.at(i).second;
}
return QScriptBreakpointData();
}
/*!
Tries to find a breakpoint with the given \a scriptId and \a
lineNumber. Returns the id of the first breakpoint that matches, or
-1 if no such breakpoint is found.
*/
int QScriptBreakpointsModel::resolveBreakpoint(qint64 scriptId, int lineNumber) const
{
Q_D(const QScriptBreakpointsModel);
for (int i = 0; i < d->breakpoints.size(); ++i) {
if ((d->breakpoints.at(i).second.scriptId() == scriptId)
&& (d->breakpoints.at(i).second.lineNumber() == lineNumber)) {
return d->breakpoints.at(i).first;
}
}
return -1;
}
int QScriptBreakpointsModel::resolveBreakpoint(const QString &fileName, int lineNumber) const
{
Q_D(const QScriptBreakpointsModel);
for (int i = 0; i < d->breakpoints.size(); ++i) {
if ((d->breakpoints.at(i).second.fileName() == fileName)
&& (d->breakpoints.at(i).second.lineNumber() == lineNumber)) {
return d->breakpoints.at(i).first;
}
}
return -1;
}
/*!
\reimp
*/
QModelIndex QScriptBreakpointsModel::index(int row, int column, const QModelIndex &parent) const
{
Q_D(const QScriptBreakpointsModel);
if (parent.isValid())
return QModelIndex();
if ((row < 0) || (row >= d->breakpoints.size()))
return QModelIndex();
if ((column < 0) || (column >= columnCount()))
return QModelIndex();
return createIndex(row, column);
}
/*!
\reimp
*/
QModelIndex QScriptBreakpointsModel::parent(const QModelIndex &) const
{
return QModelIndex();
}
/*!
\reimp
*/
int QScriptBreakpointsModel::columnCount(const QModelIndex &parent) const
{
if (!parent.isValid())
return 6;
return 0;
}
/*!
\reimp
*/
int QScriptBreakpointsModel::rowCount(const QModelIndex &parent) const
{
Q_D(const QScriptBreakpointsModel);
if (!parent.isValid())
return d->breakpoints.size();
return 0;
}
/*!
\reimp
*/
QVariant QScriptBreakpointsModel::data(const QModelIndex &index, int role) const
{
Q_D(const QScriptBreakpointsModel);
if (!index.isValid() || (index.row() >= d->breakpoints.size()))
return QVariant();
const QPair<int, QScriptBreakpointData> &item = d->breakpoints.at(index.row());
if (role == Qt::DisplayRole) {
if (index.column() == 0)
return item.first;
else if (index.column() == 1) {
QString loc = item.second.fileName();
if (loc.isEmpty())
loc = QString::fromLatin1("<anonymous script, id=%0>").arg(item.second.scriptId());
loc.append(QString::fromLatin1(":%0").arg(item.second.lineNumber()));
return loc;
} else if (index.column() == 2) {
if (!item.second.condition().isEmpty())
return item.second.condition();
} else if (index.column() == 3) {
if (item.second.ignoreCount() != 0)
return item.second.ignoreCount();
} else if (index.column() == 5) {
return item.second.hitCount();
}
} else if (role == Qt::CheckStateRole) {
if (index.column() == 0) {
return item.second.isEnabled() ? Qt::Checked : Qt::Unchecked;
} else if (index.column() == 4) {
return item.second.isSingleShot() ? Qt::Checked : Qt::Unchecked;
}
} else if (role == Qt::EditRole) {
if (index.column() == 2)
return item.second.condition();
else if (index.column() == 3)
return item.second.ignoreCount();
}
return QVariant();
}
/*!
\reimp
*/
bool QScriptBreakpointsModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
Q_D(QScriptBreakpointsModel);
if (!index.isValid() || (index.row() >= d->breakpoints.size()))
return false;
const QPair<int, QScriptBreakpointData> &item = d->breakpoints.at(index.row());
QScriptBreakpointData modifiedData;
int col = index.column();
if ((col == 0) || (col == 4)) {
if (role == Qt::CheckStateRole) {
modifiedData = item.second;
if (col == 0)
modifiedData.setEnabled(value.toInt() == Qt::Checked);
else
modifiedData.setSingleShot(value.toInt() == Qt::Checked);
}
} else if (col == 2) {
if (role == Qt::EditRole) {
modifiedData = item.second;
modifiedData.setCondition(value.toString());
}
} else if (col == 3) {
if (role == Qt::EditRole) {
modifiedData = item.second;
modifiedData.setIgnoreCount(value.toInt());
}
}
if (!modifiedData.isValid())
return false;
QScriptDebuggerJob *job = new SetBreakpointDataJob(item.first, modifiedData, d->commandScheduler);
d->jobScheduler->scheduleJob(job);
return true;
}
/*!
\reimp
*/
QVariant QScriptBreakpointsModel::headerData(int section, Qt::Orientation orient, int role) const
{
if (orient == Qt::Horizontal) {
if (role == Qt::DisplayRole) {
if (section == 0)
return QCoreApplication::translate("QScriptBreakpointsModel", "ID");
else if (section == 1)
return QCoreApplication::translate("QScriptBreakpointsModel", "Location");
else if (section == 2)
return QCoreApplication::translate("QScriptBreakpointsModel", "Condition");
else if (section == 3)
return QCoreApplication::translate("QScriptBreakpointsModel", "Ignore-count");
else if (section == 4)
return QCoreApplication::translate("QScriptBreakpointsModel", "Single-shot");
else if (section == 5)
return QCoreApplication::translate("QScriptBreakpointsModel", "Hit-count");
}
}
return QVariant();
}
/*!
\reimp
*/
Qt::ItemFlags QScriptBreakpointsModel::flags(const QModelIndex &index) const
{
if (!index.isValid())
return 0;
Qt::ItemFlags ret = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
switch (index.column()) {
case 0:
ret |= Qt::ItemIsUserCheckable;
break;
case 1:
break;
case 2:
ret |= Qt::ItemIsEditable;
break;
case 3:
ret |= Qt::ItemIsEditable;
break;
case 4:
ret |= Qt::ItemIsUserCheckable;
break;
}
return ret;
}
QT_END_NAMESPACE
#include "moc_qscriptbreakpointsmodel_p.h"

View file

@ -1,87 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTBREAKPOINTSMODEL_P_H
#define QSCRIPTBREAKPOINTSMODEL_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtCore/qabstractitemmodel.h>
#include "qscriptbreakpointdata_p.h"
QT_BEGIN_NAMESPACE
class QScriptDebuggerJobSchedulerInterface;
class QScriptDebuggerCommandSchedulerInterface;
class QScriptBreakpointsModelPrivate;
class Q_AUTOTEST_EXPORT QScriptBreakpointsModel
: public QAbstractItemModel
{
Q_OBJECT
public:
QScriptBreakpointsModel(QScriptDebuggerJobSchedulerInterface *jobScheduler,
QScriptDebuggerCommandSchedulerInterface *commandScheduler,
QObject *parent = nullptr);
~QScriptBreakpointsModel();
void setBreakpoint(const QScriptBreakpointData &data);
void setBreakpointData(int id, const QScriptBreakpointData &data);
void deleteBreakpoint(int id);
void addBreakpoint(int id, const QScriptBreakpointData &data);
void modifyBreakpoint(int id, const QScriptBreakpointData &data);
void removeBreakpoint(int id);
int breakpointIdAt(int row) const;
QScriptBreakpointData breakpointDataAt(int row) const;
QScriptBreakpointData breakpointData(int id) const;
int resolveBreakpoint(qint64 scriptId, int lineNumber) const;
int resolveBreakpoint(const QString &fileName, int lineNumber) const;
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &child) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
QVariant headerData(int section, Qt::Orientation, int role = Qt::DisplayRole) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
private:
Q_DECLARE_PRIVATE(QScriptBreakpointsModel)
Q_DISABLE_COPY(QScriptBreakpointsModel)
};
QT_END_NAMESPACE
#endif

View file

@ -1,359 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qscriptbreakpointswidget_p.h"
#include "qscriptbreakpointswidgetinterface_p_p.h"
#include "qscriptbreakpointsmodel_p.h"
#include "qscriptdebuggerscriptsmodel_p.h"
#include "qscripttoolsresources_p.h"
#include <QtCore/qdebug.h>
#include <QtGui/qaction.h>
#include <QtGui/qcompleter.h>
#include <QtGui/qheaderview.h>
#include <QtGui/qlineedit.h>
#include <QtGui/qmessagebox.h>
#include <QtGui/qtoolbar.h>
#include <QtGui/qtoolbutton.h>
#include <QtGui/qtreeview.h>
#include <QtGui/qboxlayout.h>
#include <QtGui/qstyleditemdelegate.h>
#include <QtGui/qevent.h>
#include <QtScript/qscriptengine.h>
QT_BEGIN_NAMESPACE
class QScriptNewBreakpointWidget : public QWidget
{
Q_OBJECT
public:
QScriptNewBreakpointWidget(QWidget *parent = nullptr)
: QWidget(parent) {
QHBoxLayout *hboxLayout = new QHBoxLayout(this);
hboxLayout->setSpacing(6);
hboxLayout->setMargin(0);
toolClose = new QToolButton(this);
QPixmap pix;
pix.loadFromData(
scripttools_closetab_png, scripttools_closetab_png_len,
qt_images_format
);
toolClose->setIcon(QIcon(pix));
toolClose->setAutoRaise(true);
toolClose->setText(tr("Close"));
hboxLayout->addWidget(toolClose);
fileNameEdit = new QLineEdit();
setFocusProxy(fileNameEdit);
QRegExp locationRegExp(QLatin1String(".+:[0-9]+"));
QRegExpValidator *validator = new QRegExpValidator(locationRegExp, fileNameEdit);
fileNameEdit->setValidator(validator);
hboxLayout->addWidget(fileNameEdit);
toolOk = new QToolButton(this);
toolOk->setIcon(QIcon::fromTheme("list-add"));
toolOk->setAutoRaise(true);
toolOk->setEnabled(false);
hboxLayout->addWidget(toolOk);
QObject::connect(toolClose, SIGNAL(clicked()), this, SLOT(hide()));
QObject::connect(toolOk, SIGNAL(clicked()), this, SLOT(onOkClicked()));
QObject::connect(fileNameEdit, SIGNAL(textChanged(QString)),
this, SLOT(onTextChanged()));
QObject::connect(fileNameEdit, SIGNAL(returnPressed()),
this, SLOT(onOkClicked()));
}
void setCompleter(QCompleter *comp)
{ fileNameEdit->setCompleter(comp); }
Q_SIGNALS:
void newBreakpointRequest(const QString &fileName, int lineNumber);
protected:
void keyPressEvent(QKeyEvent *e)
{
if (e->key() == Qt::Key_Escape)
hide();
else
QWidget::keyPressEvent(e);
}
private Q_SLOTS:
void onOkClicked()
{
QString location = fileNameEdit->text();
fileNameEdit->clear();
QString fileName = location.left(location.lastIndexOf(QLatin1Char(':')));
int lineNumber = location.mid(fileName.length()+1).toInt();
emit newBreakpointRequest(fileName, lineNumber);
}
void onTextChanged()
{
toolOk->setEnabled(fileNameEdit->hasAcceptableInput());
}
private:
QLineEdit *fileNameEdit;
QToolButton *toolClose;
QToolButton *toolOk;
};
class QScriptBreakpointsWidgetPrivate
: public QScriptBreakpointsWidgetInterfacePrivate
{
Q_DECLARE_PUBLIC(QScriptBreakpointsWidget)
public:
QScriptBreakpointsWidgetPrivate();
~QScriptBreakpointsWidgetPrivate();
void _q_newBreakpoint();
void _q_deleteBreakpoint();
void _q_onCurrentChanged(const QModelIndex &index);
void _q_onNewBreakpointRequest(const QString &fileName, int lineNumber);
QTreeView *view;
QScriptNewBreakpointWidget *newBreakpointWidget;
QAction *deleteBreakpointAction;
QScriptDebuggerScriptsModel *scriptsModel;
};
QScriptBreakpointsWidgetPrivate::QScriptBreakpointsWidgetPrivate()
{
}
QScriptBreakpointsWidgetPrivate::~QScriptBreakpointsWidgetPrivate()
{
}
void QScriptBreakpointsWidgetPrivate::_q_newBreakpoint()
{
newBreakpointWidget->show();
newBreakpointWidget->setFocus(Qt::OtherFocusReason);
}
void QScriptBreakpointsWidgetPrivate::_q_deleteBreakpoint()
{
Q_Q(QScriptBreakpointsWidget);
QModelIndex index = view->currentIndex();
if (index.isValid()) {
int id = q->breakpointsModel()->breakpointIdAt(index.row());
q->breakpointsModel()->deleteBreakpoint(id);
}
}
void QScriptBreakpointsWidgetPrivate::_q_onCurrentChanged(const QModelIndex &index)
{
deleteBreakpointAction->setEnabled(index.isValid());
}
void QScriptBreakpointsWidgetPrivate::_q_onNewBreakpointRequest(const QString &fileName, int lineNumber)
{
QScriptBreakpointData data(fileName, lineNumber);
q_func()->breakpointsModel()->setBreakpoint(data);
}
class QScriptBreakpointsItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
QScriptBreakpointsItemDelegate(QObject *parent = nullptr)
: QStyledItemDelegate(parent) {}
QWidget *createEditor(QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
QWidget *editor = QStyledItemDelegate::createEditor(parent, option, index);
if (index.column() == 2) {
// condition
QLineEdit *le = qobject_cast<QLineEdit*>(editor);
if (le) {
QObject::connect(le, SIGNAL(textEdited(QString)),
this, SLOT(validateInput(QString)));
}
}
return editor;
}
bool eventFilter(QObject *editor, QEvent *event)
{
if (QLineEdit *le = qobject_cast<QLineEdit*>(editor)) {
if (event->type() == QEvent::KeyPress) {
int key = static_cast<QKeyEvent*>(event)->key();
if ((key == Qt::Key_Enter) || (key == Qt::Key_Return)) {
if (QScriptEngine::checkSyntax(le->text()).state() != QScriptSyntaxCheckResult::Valid) {
// ignore when script contains syntax error
return true;
}
}
}
}
return QStyledItemDelegate::eventFilter(editor, event);
}
void setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const
{
if (index.column() == 2) {
// check that the syntax is OK
QString condition = qobject_cast<QLineEdit*>(editor)->text();
if (QScriptEngine::checkSyntax(condition).state() != QScriptSyntaxCheckResult::Valid)
return;
}
QStyledItemDelegate::setModelData(editor, model, index);
}
private Q_SLOTS:
void validateInput(const QString &text)
{
QWidget *editor = qobject_cast<QWidget*>(sender());
QPalette pal = editor->palette();
QColor col;
bool ok = (QScriptEngine::checkSyntax(text).state() == QScriptSyntaxCheckResult::Valid);
if (ok) {
col = Qt::white;
} else {
QScriptSyntaxCheckResult result = QScriptEngine::checkSyntax(
text + QLatin1Char('\n'));
if (result.state() == QScriptSyntaxCheckResult::Intermediate)
col = QColor(255, 240, 192);
else
col = QColor(255, 102, 102);
}
pal.setColor(QPalette::Active, QPalette::Base, col);
editor->setPalette(pal);
}
};
QScriptBreakpointsWidget::QScriptBreakpointsWidget(QWidget *parent)
: QScriptBreakpointsWidgetInterface(*new QScriptBreakpointsWidgetPrivate, parent, 0)
{
Q_D(QScriptBreakpointsWidget);
d->view = new QTreeView();
// d->view->setEditTriggers(QAbstractItemView::NoEditTriggers);
d->view->setEditTriggers(QAbstractItemView::AllEditTriggers);
// d->view->setAlternatingRowColors(true);
d->view->setRootIsDecorated(false);
d->view->setSelectionBehavior(QAbstractItemView::SelectRows);
// d->view->header()->hide();
// d->view->header()->setDefaultAlignment(Qt::AlignLeft);
// d->view->header()->setResizeMode(QHeaderView::ResizeToContents);
d->view->setItemDelegate(new QScriptBreakpointsItemDelegate(this));
d->newBreakpointWidget = new QScriptNewBreakpointWidget();
d->newBreakpointWidget->hide();
QObject::connect(d->newBreakpointWidget, SIGNAL(newBreakpointRequest(QString,int)),
this, SLOT(_q_onNewBreakpointRequest(QString,int)));
QAction *newBreakpointAction = new QAction(QIcon::fromTheme("document-new"), tr("New"), this);
QObject::connect(newBreakpointAction, SIGNAL(triggered()),
this, SLOT(_q_newBreakpoint()));
d->deleteBreakpointAction = new QAction(QIcon::fromTheme("edit-delete"), tr("Delete"), this);
d->deleteBreakpointAction->setEnabled(false);
QObject::connect(d->deleteBreakpointAction, SIGNAL(triggered()),
this, SLOT(_q_deleteBreakpoint()));
#ifndef QT_NO_TOOLBAR
QToolBar *toolBar = new QToolBar();
toolBar->addAction(newBreakpointAction);
toolBar->addAction(d->deleteBreakpointAction);
#endif
QVBoxLayout *vbox = new QVBoxLayout(this);
vbox->setMargin(0);
#ifndef QT_NO_TOOLBAR
vbox->addWidget(toolBar);
#endif
vbox->addWidget(d->newBreakpointWidget);
vbox->addWidget(d->view);
}
QScriptBreakpointsWidget::~QScriptBreakpointsWidget()
{
}
/*!
\reimp
*/
QScriptBreakpointsModel *QScriptBreakpointsWidget::breakpointsModel() const
{
Q_D(const QScriptBreakpointsWidget);
return qobject_cast<QScriptBreakpointsModel*>(d->view->model());
}
/*!
\reimp
*/
void QScriptBreakpointsWidget::setBreakpointsModel(QScriptBreakpointsModel *model)
{
Q_D(QScriptBreakpointsWidget);
d->view->setModel(model);
d->view->header()->resizeSection(0, 50);
QObject::connect(d->view->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
this, SLOT(_q_onCurrentChanged(QModelIndex)));
}
/*!
\reimp
*/
QScriptDebuggerScriptsModel *QScriptBreakpointsWidget::scriptsModel() const
{
Q_D(const QScriptBreakpointsWidget);
return d->scriptsModel;
}
/*!
\reimp
*/
void QScriptBreakpointsWidget::setScriptsModel(QScriptDebuggerScriptsModel *model)
{
Q_D(QScriptBreakpointsWidget);
d->scriptsModel = model;
QCompleter *completer = new QCompleter(model, this);
completer->setCompletionRole(Qt::DisplayRole);
d->newBreakpointWidget->setCompleter(completer);
}
/*!
\reimp
*/
void QScriptBreakpointsWidget::keyPressEvent(QKeyEvent *e)
{
Q_D(QScriptBreakpointsWidget);
if (e->key() == Qt::Key_Delete) {
QModelIndex index = d->view->currentIndex();
if (!index.isValid())
return;
int id = breakpointsModel()->breakpointIdAt(index.row());
breakpointsModel()->deleteBreakpoint(id);
}
}
QT_END_NAMESPACE
#include "moc_qscriptbreakpointswidget.cpp"
#include "moc_qscriptbreakpointswidget_p.h"

View file

@ -1,70 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTBREAKPOINTSWIDGET_P_H
#define QSCRIPTBREAKPOINTSWIDGET_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include "qscriptbreakpointswidgetinterface_p.h"
QT_BEGIN_NAMESPACE
class QScriptBreakpointsWidgetPrivate;
class Q_AUTOTEST_EXPORT QScriptBreakpointsWidget:
public QScriptBreakpointsWidgetInterface
{
Q_OBJECT
public:
QScriptBreakpointsWidget(QWidget *parent = nullptr);
~QScriptBreakpointsWidget();
QScriptBreakpointsModel *breakpointsModel() const;
void setBreakpointsModel(QScriptBreakpointsModel *model);
QScriptDebuggerScriptsModel *scriptsModel() const;
void setScriptsModel(QScriptDebuggerScriptsModel *model);
protected:
void keyPressEvent(QKeyEvent *e);
private:
Q_PRIVATE_SLOT(d_func(), void _q_newBreakpoint())
Q_PRIVATE_SLOT(d_func(), void _q_deleteBreakpoint())
Q_PRIVATE_SLOT(d_func(), void _q_onCurrentChanged(const QModelIndex &))
Q_PRIVATE_SLOT(d_func(), void _q_onNewBreakpointRequest(const QString &, int))
Q_DECLARE_PRIVATE(QScriptBreakpointsWidget)
Q_DISABLE_COPY(QScriptBreakpointsWidget)
};
QT_END_NAMESPACE
#endif

View file

@ -1,47 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qscriptbreakpointswidgetinterface_p.h"
#include "qscriptbreakpointswidgetinterface_p_p.h"
QT_BEGIN_NAMESPACE
QScriptBreakpointsWidgetInterfacePrivate::QScriptBreakpointsWidgetInterfacePrivate()
{
}
QScriptBreakpointsWidgetInterfacePrivate::~QScriptBreakpointsWidgetInterfacePrivate()
{
}
QScriptBreakpointsWidgetInterface::~QScriptBreakpointsWidgetInterface()
{
}
QScriptBreakpointsWidgetInterface::QScriptBreakpointsWidgetInterface(
QScriptBreakpointsWidgetInterfacePrivate &dd,
QWidget *parent, Qt::WindowFlags flags)
: QWidget(dd, parent, flags)
{
}
QT_END_NAMESPACE
#include "moc_qscriptbreakpointswidgetinterface_p.h"

View file

@ -1,72 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTBREAKPOINTSWIDGETINTERFACE_P_H
#define QSCRIPTBREAKPOINTSWIDGETINTERFACE_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtGui/qwidget.h>
QT_BEGIN_NAMESPACE
class QScriptBreakpointsModel;
class QScriptDebuggerScriptsModel;
class QScriptBreakpointsWidgetInterfacePrivate;
class Q_AUTOTEST_EXPORT QScriptBreakpointsWidgetInterface:
public QWidget
{
Q_OBJECT
public:
~QScriptBreakpointsWidgetInterface();
virtual QScriptBreakpointsModel *breakpointsModel() const = 0;
virtual void setBreakpointsModel(QScriptBreakpointsModel *model) = 0;
virtual QScriptDebuggerScriptsModel *scriptsModel() const = 0;
virtual void setScriptsModel(QScriptDebuggerScriptsModel *model) = 0;
Q_SIGNALS:
void currentScriptChanged(qint64 scriptId);
protected:
QScriptBreakpointsWidgetInterface(
QScriptBreakpointsWidgetInterfacePrivate &dd,
QWidget *parent, Qt::WindowFlags flags);
private:
Q_DECLARE_PRIVATE(QScriptBreakpointsWidgetInterface)
Q_DISABLE_COPY(QScriptBreakpointsWidgetInterface)
};
QT_END_NAMESPACE
#endif

View file

@ -1,52 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTBREAKPOINTSWIDGETINTERFACE_P_P_H
#define QSCRIPTBREAKPOINTSWIDGETINTERFACE_P_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include "qwidget_p.h"
QT_BEGIN_NAMESPACE
class QScriptBreakpointsWidgetInterface;
class QScriptBreakpointsWidgetInterfacePrivate
: public QWidgetPrivate
{
Q_DECLARE_PUBLIC(QScriptBreakpointsWidgetInterface)
public:
QScriptBreakpointsWidgetInterfacePrivate();
~QScriptBreakpointsWidgetInterfacePrivate();
};
QT_END_NAMESPACE
#endif

View file

@ -1,58 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTCOMPLETIONPROVIDERINTERFACE_P_H
#define QSCRIPTCOMPLETIONPROVIDERINTERFACE_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtCore/qobjectdefs.h>
QT_BEGIN_NAMESPACE
class QScriptCompletionTaskInterface;
class Q_AUTOTEST_EXPORT QScriptCompletionProviderInterface
{
public:
enum Option {
ConsoleCommandCompletion = 1
};
virtual ~QScriptCompletionProviderInterface() {}
virtual QScriptCompletionTaskInterface *createCompletionTask(
const QString &contents, int cursorPosition,
int frameIndex, int options) = 0;
};
QT_END_NAMESPACE
#endif

View file

@ -1,273 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qscriptcompletiontask_p.h"
#include "qscriptcompletiontaskinterface_p_p.h"
#include "qscriptdebuggerconsole_p.h"
#include "qscriptdebuggerconsolecommand_p.h"
#include "qscriptdebuggerconsolecommandmanager_p.h"
#include "qscriptdebuggercommandschedulerjob_p.h"
#include "qscriptdebuggercommandschedulerfrontend_p.h"
#include "qscriptdebuggerjobschedulerinterface_p.h"
#include "qscriptdebuggerresponse_p.h"
#include "qscripttoolscommon_p.h"
#include "qobject_p.h"
#include <QtCore/qset.h>
#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
class QScriptCompletionTaskPrivate
: public QScriptCompletionTaskInterfacePrivate
{
Q_DECLARE_PUBLIC(QScriptCompletionTask)
public:
QScriptCompletionTaskPrivate();
~QScriptCompletionTaskPrivate();
void completeScriptExpression();
void emitFinished();
QString contents;
int cursorPosition;
int frameIndex;
QScriptDebuggerCommandSchedulerInterface *commandScheduler;
QScriptDebuggerJobSchedulerInterface *jobScheduler;
QScriptDebuggerConsole *console;
};
QScriptCompletionTaskPrivate::QScriptCompletionTaskPrivate()
: cursorPosition(0), frameIndex(0), commandScheduler(0),
jobScheduler(0), console(0)
{
}
QScriptCompletionTaskPrivate::~QScriptCompletionTaskPrivate()
{
}
class QScriptCompleteExpressionJob : public QScriptDebuggerCommandSchedulerJob
{
public:
QScriptCompleteExpressionJob(int frameIndex, const QStringList &path,
QScriptCompletionTaskPrivate *task,
QScriptDebuggerCommandSchedulerInterface *scheduler)
: QScriptDebuggerCommandSchedulerJob(scheduler),
m_frameIndex(frameIndex), m_path(path), m_task(task)
{}
void start()
{
QScriptDebuggerCommandSchedulerFrontend frontend(commandScheduler(), this);
frontend.scheduleGetCompletions(m_frameIndex, m_path);
}
void handleResponse(const QScriptDebuggerResponse &response, int /*commandId*/)
{
m_task->results = response.result().toStringList();
m_task->emitFinished();
finish();
}
private:
int m_frameIndex;
QStringList m_path;
QScriptCompletionTaskPrivate *m_task;
};
class QScriptCompleteScriptsJob : public QScriptDebuggerCommandSchedulerJob
{
public:
QScriptCompleteScriptsJob(const QString &prefix, QScriptCompletionTaskPrivate *task,
QScriptDebuggerCommandSchedulerInterface *scheduler)
: QScriptDebuggerCommandSchedulerJob(scheduler),
m_prefix(prefix), m_task(task)
{}
void start()
{
QScriptDebuggerCommandSchedulerFrontend frontend(commandScheduler(), this);
frontend.scheduleGetScripts();
}
void handleResponse(const QScriptDebuggerResponse &response, int /*commandId*/)
{
QScriptScriptMap scripts = response.resultAsScripts();
QScriptScriptMap::const_iterator it;
for (it = scripts.constBegin(); it != scripts.constEnd(); ++it) {
QString fileName = it.value().fileName();
if (isPrefixOf(m_prefix, fileName))
m_task->results.append(fileName);
}
m_task->emitFinished();
finish();
}
private:
QString m_prefix;
QScriptCompletionTaskPrivate *m_task;
};
void QScriptCompletionTaskPrivate::completeScriptExpression()
{
int pos = cursorPosition;
if ((pos > 0) && contents.at(pos-1).isNumber()) {
// completion of numbers is pointless
emitFinished();
return;
}
while ((pos > 0) && isAlmostIdentChar(contents.at(pos-1)))
--pos;
int pos2 = cursorPosition - 1;
while ((pos2+1 < contents.size()) && isAlmostIdentChar(contents.at(pos2+1)))
++pos2;
QString ident = contents.mid(pos, pos2 - pos + 1);
position = pos;
QStringList path;
path.append(ident);
while ((pos > 0) && (contents.at(pos-1) == QLatin1Char('.'))) {
--pos;
pos2 = pos;
while ((pos > 0) && isAlmostIdentChar(contents.at(pos-1)))
--pos;
path.prepend(contents.mid(pos, pos2 - pos));
}
length = path.last().length();
type = QScriptCompletionTask::ScriptIdentifierCompletion;
QScriptDebuggerJob *job = new QScriptCompleteExpressionJob(frameIndex, path, this, commandScheduler);
jobScheduler->scheduleJob(job);
}
void QScriptCompletionTaskPrivate::emitFinished()
{
emit q_func()->finished();
}
QScriptCompletionTask::QScriptCompletionTask(
const QString &contents, int cursorPosition, int frameIndex,
QScriptDebuggerCommandSchedulerInterface *commandScheduler,
QScriptDebuggerJobSchedulerInterface *jobScheduler,
QScriptDebuggerConsole *console,
QObject *parent)
: QScriptCompletionTaskInterface(
*new QScriptCompletionTaskPrivate, parent)
{
Q_D(QScriptCompletionTask);
d->contents = contents;
d->cursorPosition = cursorPosition;
if ((frameIndex == -1) && console)
d->frameIndex = console->currentFrameIndex();
else
d->frameIndex = frameIndex;
d->commandScheduler = commandScheduler;
d->jobScheduler = jobScheduler;
d->console = console;
}
QScriptCompletionTask::~QScriptCompletionTask()
{
}
void QScriptCompletionTask::start()
{
Q_D(QScriptCompletionTask);
d->type = NoCompletion;
// see if we're typing a command
// ### don't hardcode the command prefix
QRegExp cmdRx(QString::fromLatin1("^\\s*\\.([a-zA-Z]*)"));
int cmdIndex = cmdRx.indexIn(d->contents);
if ((cmdIndex != -1) && d->console) {
int len = cmdRx.matchedLength();
QString prefix = cmdRx.capturedTexts().at(1);
if ((d->cursorPosition >= cmdIndex) && (d->cursorPosition <= (cmdIndex+len))) {
// editing command --> get command completions
d->results = d->console->commandManager()->completions(prefix);
d->position = cmdRx.pos(1);
d->length = prefix.length();
d->type = CommandNameCompletion;
d->appendix = QString::fromLatin1(" ");
emit finished();
} else {
QScriptDebuggerConsoleCommand *cmd = d->console->commandManager()->findCommand(prefix);
if (!cmd) {
emit finished();
return;
}
// editing an argument
int argNum = 0;
QString arg;
int pos = cmdIndex + len;
while (pos < d->contents.size()) {
while ((pos < d->contents.size()) && d->contents.at(pos).isSpace())
++pos;
if (pos < d->contents.size()) {
int pos2 = pos + 1;
while ((pos2 < d->contents.size()) && !d->contents.at(pos2).isSpace())
++pos2;
if ((d->cursorPosition >= pos) && (d->cursorPosition <= pos2)) {
arg = d->contents.mid(pos, pos2 - pos);
break;
}
pos = pos2;
++argNum;
}
}
QString argType = cmd->argumentTypes().value(argNum);
if (!argType.isEmpty()) {
if (argType == QLatin1String("command-or-group-name")) {
d->results = d->console->commandManager()->completions(arg);
} else if (argType == QLatin1String("script-filename")) {
d->position = pos;
d->length = arg.length();
d->type = CommandArgumentCompletion;
QScriptDebuggerJob *job = new QScriptCompleteScriptsJob(arg, d, d->commandScheduler);
d->jobScheduler->scheduleJob(job);
} else if (argType == QLatin1String("subcommand-name")) {
for (int i = 0; i < cmd->subCommands().size(); ++i) {
QString name = cmd->subCommands().at(i);
if (isPrefixOf(arg, name))
d->results.append(name);
}
qStableSort(d->results);
} else if (argType == QLatin1String("script")) {
d->completeScriptExpression();
} else {
emit finished();
}
if ((d->type == NoCompletion) && !d->results.isEmpty()) {
d->position = pos;
d->length = arg.length();
d->type = CommandArgumentCompletion;
emit finished();
}
}
}
} else {
// assume it's an eval expression
d->completeScriptExpression();
}
}
QT_END_NAMESPACE
#include "moc_qscriptcompletiontask_p.h"

View file

@ -1,70 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTCOMPLETIONTASK_P_H
#define QSCRIPTCOMPLETIONTASK_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include "qscriptcompletiontaskinterface_p.h"
#include <QtCore/qlist.h>
#include <QtCore/qmap.h>
QT_BEGIN_NAMESPACE
class QScriptDebuggerCommandSchedulerInterface;
class QScriptDebuggerJobSchedulerInterface;
class QScriptDebuggerConsole;
class QScriptCompletionTaskPrivate;
class Q_AUTOTEST_EXPORT QScriptCompletionTask
: public QScriptCompletionTaskInterface
{
Q_OBJECT
public:
QScriptCompletionTask(
const QString &contents, int cursorPosition, int frameIndex,
QScriptDebuggerCommandSchedulerInterface *commandScheduler,
QScriptDebuggerJobSchedulerInterface *jobScheduler,
QScriptDebuggerConsole *console,
QObject *parent = nullptr);
~QScriptCompletionTask();
void start();
private:
Q_DECLARE_PRIVATE(QScriptCompletionTask)
Q_DISABLE_COPY(QScriptCompletionTask)
};
QT_END_NAMESPACE
#endif

View file

@ -1,91 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qscriptcompletiontaskinterface_p.h"
#include "qscriptcompletiontaskinterface_p_p.h"
#include "qobject_p.h"
QT_BEGIN_NAMESPACE
QScriptCompletionTaskInterfacePrivate::QScriptCompletionTaskInterfacePrivate()
{
type = QScriptCompletionTaskInterface::NoCompletion;
}
QScriptCompletionTaskInterfacePrivate::~QScriptCompletionTaskInterfacePrivate()
{
}
QScriptCompletionTaskInterface::~QScriptCompletionTaskInterface()
{
}
QScriptCompletionTaskInterface::QScriptCompletionTaskInterface(
QScriptCompletionTaskInterfacePrivate &dd, QObject *parent)
: QObject(dd, parent)
{
}
QScriptCompletionTaskInterface::CompletionType QScriptCompletionTaskInterface::completionType() const
{
Q_D(const QScriptCompletionTaskInterface);
return static_cast<QScriptCompletionTaskInterface::CompletionType>(d->type);
}
int QScriptCompletionTaskInterface::resultCount() const
{
Q_D(const QScriptCompletionTaskInterface);
return d->results.size();
}
QString QScriptCompletionTaskInterface::resultAt(int index) const
{
Q_D(const QScriptCompletionTaskInterface);
return d->results.value(index);
}
void QScriptCompletionTaskInterface::addResult(const QString &result)
{
Q_D(QScriptCompletionTaskInterface);
d->results.append(result);
}
int QScriptCompletionTaskInterface::position() const
{
Q_D(const QScriptCompletionTaskInterface);
return d->position;
}
int QScriptCompletionTaskInterface::length() const
{
Q_D(const QScriptCompletionTaskInterface);
return d->length;
}
QString QScriptCompletionTaskInterface::appendix() const
{
Q_D(const QScriptCompletionTaskInterface);
return d->appendix;
}
QT_END_NAMESPACE
#include "moc_qscriptcompletiontaskinterface_p.h"

View file

@ -1,86 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTCOMPLETIONTASKINTERFACE_P_H
#define QSCRIPTCOMPLETIONTASKINTERFACE_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtCore/qobject.h>
QT_BEGIN_NAMESPACE
class QString;
class QScriptCompletionTaskInterfacePrivate;
class Q_AUTOTEST_EXPORT QScriptCompletionTaskInterface
: public QObject
{
Q_OBJECT
public:
enum CompletionType {
NoCompletion,
CommandNameCompletion,
CommandArgumentCompletion,
ScriptIdentifierCompletion
};
~QScriptCompletionTaskInterface();
virtual void start() = 0;
CompletionType completionType() const;
int resultCount() const;
QString resultAt(int index) const;
int position() const;
int length() const;
QString appendix() const;
protected:
void addResult(const QString &result);
Q_SIGNALS:
void finished();
protected:
QScriptCompletionTaskInterface(
QScriptCompletionTaskInterfacePrivate &dd, QObject *parent);
private:
Q_DECLARE_PRIVATE(QScriptCompletionTaskInterface)
Q_DISABLE_COPY(QScriptCompletionTaskInterface)
};
QT_END_NAMESPACE
#endif

View file

@ -1,61 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTCOMPLETIONTASKINTERFACE_P_P_H
#define QSCRIPTCOMPLETIONTASKINTERFACE_P_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include "qobject_p.h"
#include <QtCore/qstring.h>
#include <QtCore/qstringlist.h>
QT_BEGIN_NAMESPACE
class QScriptCompletionTaskInterface;
class QScriptCompletionTaskInterfacePrivate
: public QObjectPrivate
{
Q_DECLARE_PUBLIC(QScriptCompletionTaskInterface)
public:
QScriptCompletionTaskInterfacePrivate();
virtual ~QScriptCompletionTaskInterfacePrivate();
int type;
QStringList results;
int position;
int length;
QString appendix;
};
QT_END_NAMESPACE
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,202 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTDEBUGGER_P_H
#define QSCRIPTDEBUGGER_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtCore/qobject.h>
QT_BEGIN_NAMESPACE
class QScriptDebuggerFrontend;
class QScriptDebuggerConsoleWidgetInterface;
class QScriptDebuggerScriptsWidgetInterface;
class QScriptDebuggerCodeWidgetInterface;
class QScriptDebuggerCodeFinderWidgetInterface;
class QScriptBreakpointsWidgetInterface;
class QScriptDebuggerStackWidgetInterface;
class QScriptDebuggerLocalsWidgetInterface;
class QScriptDebugOutputWidgetInterface;
class QScriptErrorLogWidgetInterface;
class QScriptDebuggerWidgetFactoryInterface;
class QAction;
class QEvent;
class QMenu;
#ifndef QT_NO_TOOLBAR
class QToolBar;
#endif
class QScriptDebuggerPrivate;
class Q_AUTOTEST_EXPORT QScriptDebugger : public QObject
{
Q_OBJECT
public:
// mirrors QScriptEngineDebugger::DebuggerWidget
enum DebuggerWidget {
ConsoleWidget,
StackWidget,
ScriptsWidget,
LocalsWidget,
CodeWidget,
CodeFinderWidget,
BreakpointsWidget,
DebugOutputWidget,
ErrorLogWidget
};
// mirrors QScriptEngineDebugger::DebuggerAction
enum DebuggerAction {
InterruptAction,
ContinueAction,
StepIntoAction,
StepOverAction,
StepOutAction,
RunToCursorAction,
RunToNewScriptAction,
ToggleBreakpointAction,
ClearDebugOutputAction,
ClearErrorLogAction,
ClearConsoleAction,
FindInScriptAction,
FindNextInScriptAction,
FindPreviousInScriptAction,
GoToLineAction
};
QScriptDebugger(QObject *parent = nullptr);
~QScriptDebugger();
QScriptDebuggerFrontend *frontend() const;
void setFrontend(QScriptDebuggerFrontend *frontend);
QWidget *widget(DebuggerWidget widget);
QAction *action(DebuggerAction action, QObject *parent);
QScriptDebuggerConsoleWidgetInterface *consoleWidget() const;
void setConsoleWidget(QScriptDebuggerConsoleWidgetInterface *consoleWidget);
QScriptDebuggerScriptsWidgetInterface *scriptsWidget() const;
void setScriptsWidget(QScriptDebuggerScriptsWidgetInterface *scriptsWidget);
QScriptDebuggerCodeWidgetInterface *codeWidget() const;
void setCodeWidget(QScriptDebuggerCodeWidgetInterface *codeWidget);
QScriptDebuggerCodeFinderWidgetInterface *codeFinderWidget() const;
void setCodeFinderWidget(QScriptDebuggerCodeFinderWidgetInterface *codeFinderWidget);
QScriptDebuggerStackWidgetInterface *stackWidget() const;
void setStackWidget(QScriptDebuggerStackWidgetInterface *stackWidget);
QScriptDebuggerLocalsWidgetInterface *localsWidget() const;
void setLocalsWidget(QScriptDebuggerLocalsWidgetInterface *localsWidget);
QScriptBreakpointsWidgetInterface *breakpointsWidget() const;
void setBreakpointsWidget(QScriptBreakpointsWidgetInterface *breakpointsWidget);
QScriptDebugOutputWidgetInterface *debugOutputWidget() const;
void setDebugOutputWidget(QScriptDebugOutputWidgetInterface *debugOutputWidget);
QScriptErrorLogWidgetInterface *errorLogWidget() const;
void setErrorLogWidget(QScriptErrorLogWidgetInterface *errorLogWidget);
QScriptDebuggerWidgetFactoryInterface *widgetFactory() const;
void setWidgetFactory(QScriptDebuggerWidgetFactoryInterface *factory);
QAction *interruptAction(QObject *parent) const;
QAction *continueAction(QObject *parent) const;
QAction *stepIntoAction(QObject *parent) const;
QAction *stepOverAction(QObject *parent) const;
QAction *stepOutAction(QObject *parent) const;
QAction *runToCursorAction(QObject *parent) const;
QAction *runToNewScriptAction(QObject *parent) const;
QAction *toggleBreakpointAction(QObject *parent) const;
QAction *findInScriptAction(QObject *parent) const;
QAction *findNextInScriptAction(QObject *parent) const;
QAction *findPreviousInScriptAction(QObject *parent) const;
QAction *goToLineAction(QObject *parent) const;
QAction *clearDebugOutputAction(QObject *parent) const;
QAction *clearConsoleAction(QObject *parent) const;
QAction *clearErrorLogAction(QObject *parent) const;
QMenu *createStandardMenu(QWidget *widgetParent, QObject *actionParent);
#ifndef QT_NO_TOOLBAR
QToolBar *createStandardToolBar(QWidget *widgetParent, QObject *actionParent);
#endif
bool eventFilter(QObject *, QEvent *e);
bool isInteractive() const;
Q_SIGNALS:
void stopped() const;
void started() const;
protected:
void timerEvent(QTimerEvent *e);
protected:
QScriptDebugger(QScriptDebuggerPrivate &dd, QObject *parent);
private:
Q_DECLARE_PRIVATE(QScriptDebugger)
Q_DISABLE_COPY(QScriptDebugger)
Q_PRIVATE_SLOT(d_func(), void _q_onLineEntered(const QString &))
Q_PRIVATE_SLOT(d_func(), void _q_onCurrentFrameChanged(int))
Q_PRIVATE_SLOT(d_func(), void _q_onCurrentScriptChanged(qint64))
Q_PRIVATE_SLOT(d_func(), void _q_onScriptLocationSelected(int))
Q_PRIVATE_SLOT(d_func(), void _q_interrupt())
Q_PRIVATE_SLOT(d_func(), void _q_continue())
Q_PRIVATE_SLOT(d_func(), void _q_stepInto())
Q_PRIVATE_SLOT(d_func(), void _q_stepOver())
Q_PRIVATE_SLOT(d_func(), void _q_stepOut())
Q_PRIVATE_SLOT(d_func(), void _q_runToCursor())
Q_PRIVATE_SLOT(d_func(), void _q_runToNewScript())
Q_PRIVATE_SLOT(d_func(), void _q_toggleBreakpoint())
Q_PRIVATE_SLOT(d_func(), void _q_clearDebugOutput())
Q_PRIVATE_SLOT(d_func(), void _q_clearErrorLog())
Q_PRIVATE_SLOT(d_func(), void _q_clearConsole())
Q_PRIVATE_SLOT(d_func(), void _q_findInScript())
Q_PRIVATE_SLOT(d_func(), void _q_findNextInScript())
Q_PRIVATE_SLOT(d_func(), void _q_findPreviousInScript())
Q_PRIVATE_SLOT(d_func(), void _q_onFindCodeRequest(const QString &, int))
Q_PRIVATE_SLOT(d_func(), void _q_goToLine())
};
QT_END_NAMESPACE
#endif

View file

@ -1,710 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qscriptdebuggeragent_p.h"
#include "qscriptdebuggeragent_p_p.h"
#include "qscriptdebuggerbackend_p_p.h"
#include <QtCore/qcoreapplication.h>
#include <QtCore/qset.h>
#include <QtScript/qscriptengine.h>
QT_BEGIN_NAMESPACE
/*!
\since 4.5
\class QScriptDebuggerAgent
\internal
This class implements a state machine that uses the low-level events
reported by the QScriptEngineAgent interface to implement debugging-
specific functionality such as stepping and breakpoints. It is used
internally by the QScriptDebuggerBackend class.
*/
QScriptDebuggerAgentPrivate::QScriptDebuggerAgentPrivate()
: state(NoState), stepDepth(0), stepCount(0),
targetScriptId(-1), targetLineNumber(-1), returnCounter(0),
nextBreakpointId(1), hitBreakpointId(0),
nextContextId(0), statementCounter(0)
{
}
QScriptDebuggerAgentPrivate::~QScriptDebuggerAgentPrivate()
{
}
QScriptDebuggerAgentPrivate *QScriptDebuggerAgentPrivate::get(
QScriptDebuggerAgent *q)
{
if (!q)
return 0;
return q->d_func();
}
/*!
Constructs a new agent for the given \a engine. The agent will
report debugging-related events (e.g. step completion) to the given
\a backend.
*/
QScriptDebuggerAgent::QScriptDebuggerAgent(
QScriptDebuggerBackendPrivate *backend, QScriptEngine *engine)
: QScriptEngineAgent(engine), d_ptr(new QScriptDebuggerAgentPrivate())
{
Q_D(QScriptDebuggerAgent);
d->backend = backend;
QScriptContext *ctx = engine->currentContext();
while (ctx) {
d->scriptIdStack.append(QList<qint64>());
d->contextIdStack.append(d->nextContextId);
++d->nextContextId;
ctx = ctx->parentContext();
}
}
/*!
Destroys this QScriptDebuggerAgent.
*/
QScriptDebuggerAgent::~QScriptDebuggerAgent()
{
Q_D(QScriptDebuggerAgent);
if (d->backend)
d->backend->agentDestroyed(this);
delete d;
}
/*!
Instructs the agent to perform a "step into" operation. This
function returns immediately. The agent will report step completion
at a later time, i.e. when script statements are evaluated.
*/
void QScriptDebuggerAgent::enterStepIntoMode(int count)
{
Q_D(QScriptDebuggerAgent);
d->state = QScriptDebuggerAgentPrivate::SteppingIntoState;
d->stepCount = count;
d->stepResult = QScriptValue();
}
/*!
Instructs the agent to perform a "step over" operation. This
function returns immediately. The agent will report step completion
at a later time, i.e. when script statements are evaluated.
*/
void QScriptDebuggerAgent::enterStepOverMode(int count)
{
Q_D(QScriptDebuggerAgent);
d->state = QScriptDebuggerAgentPrivate::SteppingOverState;
if (engine()->isEvaluating())
d->stepDepth = 0;
else
d->stepDepth = -1;
d->stepCount = count;
d->stepResult = QScriptValue();
}
/*!
Instructs the agent to perform a "step out" operation. This
function returns immediately. The agent will report step completion
at a later time, i.e. when script statements are evaluated.
*/
void QScriptDebuggerAgent::enterStepOutMode()
{
Q_D(QScriptDebuggerAgent);
d->state = QScriptDebuggerAgentPrivate::SteppingOutState;
if (engine()->isEvaluating())
d->stepDepth = 0;
else
d->stepDepth = -1;
}
/*!
Instructs the agent to continue evaluation.
This function returns immediately.
*/
void QScriptDebuggerAgent::enterContinueMode()
{
Q_D(QScriptDebuggerAgent);
d->state = QScriptDebuggerAgentPrivate::NoState;
}
/*!
Instructs the agent to interrupt evaluation.
This function returns immediately.
*/
void QScriptDebuggerAgent::enterInterruptMode()
{
Q_D(QScriptDebuggerAgent);
d->state = QScriptDebuggerAgentPrivate::InterruptingState;
}
/*!
Instructs the agent to continue evaluation until the location
described by \a fileName and \a lineNumber is reached. This
function returns immediately.
*/
void QScriptDebuggerAgent::enterRunToLocationMode(const QString &fileName, int lineNumber)
{
Q_D(QScriptDebuggerAgent);
d->targetFileName = fileName;
d->targetLineNumber = lineNumber;
d->targetScriptId = resolveScript(fileName);
d->state = QScriptDebuggerAgentPrivate::RunningToLocationState;
}
/*!
Instructs the agent to continue evaluation until the location
described by \a scriptId and \a lineNumber is reached. This
function returns immediately.
*/
void QScriptDebuggerAgent::enterRunToLocationMode(qint64 scriptId, int lineNumber)
{
Q_D(QScriptDebuggerAgent);
d->targetScriptId = scriptId;
d->targetFileName = QString();
d->targetLineNumber = lineNumber;
d->state = QScriptDebuggerAgentPrivate::RunningToLocationState;
}
void QScriptDebuggerAgent::enterReturnByForceMode(int contextIndex, const QScriptValue &value)
{
Q_D(QScriptDebuggerAgent);
d->returnCounter = contextIndex + 1;
d->returnValue = QScriptValue();
d->state = QScriptDebuggerAgentPrivate::ReturningByForceState;
// throw an exception; we will catch it when the proper frame is popped
engine()->currentContext()->throwValue(value);
}
/*!
Sets a breakpoint defined by the given \a data.
Returns an integer that uniquely identifies the new breakpoint,
or -1 if setting the breakpoint failed.
*/
int QScriptDebuggerAgent::setBreakpoint(const QScriptBreakpointData &data)
{
Q_D(QScriptDebuggerAgent);
qint64 scriptId = data.scriptId();
if (scriptId != -1) {
if (!d->scripts.contains(scriptId)) {
// that script has been unloaded, so invalidate the ID
scriptId = -1;
const_cast<QScriptBreakpointData&>(data).setScriptId(-1);
} else if (data.fileName().isEmpty()) {
QString fileName = d->scripts[scriptId].fileName();
const_cast<QScriptBreakpointData&>(data).setFileName(fileName);
}
}
int id = d->nextBreakpointId;
++d->nextBreakpointId;
if (scriptId != -1) {
d->resolvedBreakpoints[scriptId].append(id);
} else {
QString fileName = data.fileName();
bool resolved = false;
QScriptScriptMap::const_iterator it;
for (it = d->scripts.constBegin(); it != d->scripts.constEnd(); ++it) {
if (it.value().fileName() == fileName) {
d->resolvedBreakpoints[it.key()].append(id);
resolved = true;
break;
}
}
if (!resolved)
d->unresolvedBreakpoints[fileName].append(id);
}
d->breakpoints.insert(id, data);
return id;
}
/*!
Deletes the breakpoint with the given \a id.
Returns true if the breakpoint was deleted, false if
no such breakpoint exists.
*/
bool QScriptDebuggerAgent::deleteBreakpoint(int id)
{
Q_D(QScriptDebuggerAgent);
if (!d->breakpoints.contains(id))
return false;
d->breakpoints.remove(id);
bool found = false;
{
QHash<qint64, QList<int> >::iterator it;
it = d->resolvedBreakpoints.begin();
for ( ; !found && (it != d->resolvedBreakpoints.end()); ) {
QList<int> &lst = it.value();
Q_ASSERT(!lst.isEmpty());
for (int i = 0; i < lst.size(); ++i) {
if (lst.at(i) == id) {
lst.removeAt(i);
found = true;
break;
}
}
if (lst.isEmpty())
it = d->resolvedBreakpoints.erase(it);
else
++it;
}
}
if (!found) {
QHash<QString, QList<int> >::iterator it;
it = d->unresolvedBreakpoints.begin();
for ( ; !found && (it != d->unresolvedBreakpoints.end()); ) {
QList<int> &lst = it.value();
Q_ASSERT(!lst.isEmpty());
for (int i = 0; i < lst.size(); ++i) {
if (lst.at(i) == id) {
lst.removeAt(i);
found = true;
break;
}
}
if (lst.isEmpty())
it = d->unresolvedBreakpoints.erase(it);
else
++it;
}
}
return found;
}
/*!
Deletes all breakpoints.
*/
void QScriptDebuggerAgent::deleteAllBreakpoints()
{
Q_D(QScriptDebuggerAgent);
d->breakpoints.clear();
d->resolvedBreakpoints.clear();
d->unresolvedBreakpoints.clear();
}
/*!
Returns the data associated with the breakpoint with the given \a
id.
*/
QScriptBreakpointData QScriptDebuggerAgent::breakpointData(int id) const
{
Q_D(const QScriptDebuggerAgent);
return d->breakpoints.value(id);
}
/*!
Sets the data associated with the breakpoint with the given \a
id.
*/
bool QScriptDebuggerAgent::setBreakpointData(int id,
const QScriptBreakpointData &data)
{
Q_D(QScriptDebuggerAgent);
if (!d->breakpoints.contains(id))
return false;
d->breakpoints[id] = data;
return true;
}
/*!
Returns all breakpoints.
*/
QScriptBreakpointMap QScriptDebuggerAgent::breakpoints() const
{
Q_D(const QScriptDebuggerAgent);
return d->breakpoints;
}
/*!
Returns all scripts.
*/
QScriptScriptMap QScriptDebuggerAgent::scripts() const
{
Q_D(const QScriptDebuggerAgent);
return d->scripts;
}
/*!
Returns the data associated with the script with the given \a id.
*/
QScriptScriptData QScriptDebuggerAgent::scriptData(qint64 id) const
{
Q_D(const QScriptDebuggerAgent);
return d->scripts.value(id);
}
/*!
Checkpoints the current scripts.
*/
void QScriptDebuggerAgent::scriptsCheckpoint()
{
Q_D(QScriptDebuggerAgent);
d->previousCheckpointScripts = d->checkpointScripts;
d->checkpointScripts = d->scripts;
}
/*!
Returns the difference between the current checkpoint and the
previous checkpoint. The first item in the pair is a list containing
the identifiers of the scripts that were added. The second item in
the pair is a list containing the identifiers of the scripts that
were removed.
*/
QPair<QList<qint64>, QList<qint64> > QScriptDebuggerAgent::scriptsDelta() const
{
Q_D(const QScriptDebuggerAgent);
QSet<qint64> prevSet = d->previousCheckpointScripts.keys().toSet();
QSet<qint64> currSet = d->checkpointScripts.keys().toSet();
QSet<qint64> addedScriptIds = currSet - prevSet;
QSet<qint64> removedScriptIds = prevSet - currSet;
return qMakePair(addedScriptIds.toList(), removedScriptIds.toList());
}
/*!
Returns the identifier of the script that has the given \a fileName,
or -1 if there is no such script.
*/
qint64 QScriptDebuggerAgent::resolveScript(const QString &fileName) const
{
Q_D(const QScriptDebuggerAgent);
QScriptScriptMap::const_iterator it;
for (it = d->scripts.constBegin(); it != d->scripts.constEnd(); ++it) {
if (it.value().fileName() == fileName)
return it.key();
}
return -1;
}
QList<qint64> QScriptDebuggerAgent::contextIds() const
{
Q_D(const QScriptDebuggerAgent);
return d->contextIdStack;
}
QPair<QList<qint64>, QList<qint64> > QScriptDebuggerAgent::contextsCheckpoint()
{
Q_D(QScriptDebuggerAgent);
int i = d->checkpointContextIdStack.size() - 1;
int j = d->contextIdStack.size() - 1;
for ( ; (i >= 0) && (j >= 0); --i, --j) {
if (d->checkpointContextIdStack.at(i) != d->contextIdStack.at(j))
break;
}
QList<qint64> removed = d->checkpointContextIdStack.mid(0, i+1);
QList<qint64> added = d->contextIdStack.mid(0, j+1);
d->checkpointContextIdStack = d->contextIdStack;
return qMakePair(removed, added);
}
void QScriptDebuggerAgent::nullifyBackendPointer()
{
Q_D(QScriptDebuggerAgent);
d->backend = 0;
}
/*!
\reimp
*/
void QScriptDebuggerAgent::scriptLoad(qint64 id, const QString &program,
const QString &fileName, int baseLineNumber)
{
Q_D(QScriptDebuggerAgent);
QScriptScriptData data = QScriptScriptData(program, fileName, baseLineNumber);
d->scripts.insert(id, data);
if ((d->state == QScriptDebuggerAgentPrivate::RunningToLocationState)
&& (d->targetScriptId == -1)
&& ((d->targetFileName == fileName) || d->targetFileName.isEmpty())) {
d->targetScriptId = id;
}
if (!fileName.isEmpty()) {
QList<int> lst = d->unresolvedBreakpoints.take(fileName);
if (!lst.isEmpty())
d->resolvedBreakpoints.insert(id, lst);
}
}
/*!
\reimp
*/
void QScriptDebuggerAgent::scriptUnload(qint64 id)
{
Q_D(QScriptDebuggerAgent);
QScriptScriptData data = d->scripts.take(id);
QString fileName = data.fileName();
if ((d->state == QScriptDebuggerAgentPrivate::RunningToLocationState)
&& (d->targetScriptId == id)) {
d->targetScriptId = -1;
d->targetFileName = fileName;
}
if (!fileName.isEmpty()) {
QList<int> lst = d->resolvedBreakpoints.take(id);
if (!lst.isEmpty())
d->unresolvedBreakpoints.insert(fileName, lst);
}
}
/*!
\reimp
*/
void QScriptDebuggerAgent::contextPush()
{
Q_D(QScriptDebuggerAgent);
d->scriptIdStack.append(QList<qint64>());
d->contextIdStack.prepend(d->nextContextId);
++d->nextContextId;
}
/*!
\reimp
*/
void QScriptDebuggerAgent::contextPop()
{
Q_D(QScriptDebuggerAgent);
d->scriptIdStack.removeLast();
d->contextIdStack.removeFirst();
}
/*!
\reimp
*/
void QScriptDebuggerAgent::functionEntry(qint64 scriptId)
{
Q_D(QScriptDebuggerAgent);
QList<qint64> &ids = d->scriptIdStack.last();
ids.append(scriptId);
if ((d->state == QScriptDebuggerAgentPrivate::SteppingOverState)
|| (d->state == QScriptDebuggerAgentPrivate::SteppingOutState)) {
++d->stepDepth;
}
}
/*!
\reimp
*/
void QScriptDebuggerAgent::functionExit(qint64 scriptId,
const QScriptValue &returnValue)
{
Q_UNUSED(scriptId);
Q_D(QScriptDebuggerAgent);
QList<qint64> &ids = d->scriptIdStack.last();
ids.removeLast();
if (d->state == QScriptDebuggerAgentPrivate::SteppingOverState) {
--d->stepDepth;
} else if (d->state == QScriptDebuggerAgentPrivate::SteppingOutState) {
if (--d->stepDepth < 0) {
d->stepResult = returnValue;
d->state = QScriptDebuggerAgentPrivate::SteppedOutState;
}
} else if (d->state == QScriptDebuggerAgentPrivate::ReturningByForceState) {
if (--d->returnCounter == 0) {
d->returnValue = returnValue;
d->state = QScriptDebuggerAgentPrivate::ReturnedByForceState;
engine()->clearExceptions();
}
}
}
/*!
\reimp
*/
void QScriptDebuggerAgent::positionChange(qint64 scriptId,
int lineNumber, int columnNumber)
{
Q_D(QScriptDebuggerAgent);
if (engine()->processEventsInterval() == -1) {
// see if it's time to call processEvents()
if ((++d->statementCounter % 25000) == 0) {
if (!d->processEventsTimer.isNull()) {
if (d->processEventsTimer.elapsed() > 30) {
QCoreApplication::processEvents();
d->processEventsTimer.restart();
}
} else {
d->processEventsTimer.start();
}
}
}
// check breakpoints
{
QList<int> lst = d->resolvedBreakpoints.value(scriptId);
for (int i = 0; i < lst.size(); ++i) {
int id = lst.at(i);
QScriptBreakpointData &data = d->breakpoints[id];
if (!data.isEnabled())
continue;
if (data.lineNumber() != lineNumber)
continue;
if (!data.condition().isEmpty()) {
// ### careful, evaluate() can cause an exception
// ### disable callbacks in nested evaluate?
QScriptDebuggerAgentPrivate::State was = d->state;
d->state = QScriptDebuggerAgentPrivate::NoState;
QScriptValue ret = engine()->evaluate(
data.condition(),
QString::fromLatin1("Breakpoint %0 condition checker").arg(id));
if (!ret.isError())
d->state = was;
if (!ret.toBoolean())
continue;
}
if (!data.hit())
continue;
d->hitBreakpointId = id;
d->state = QScriptDebuggerAgentPrivate::BreakpointState;
}
}
switch (d->state) {
case QScriptDebuggerAgentPrivate::NoState:
case QScriptDebuggerAgentPrivate::SteppingOutState:
case QScriptDebuggerAgentPrivate::ReturningByForceState:
// Do nothing
break;
case QScriptDebuggerAgentPrivate::SteppingIntoState:
if (--d->stepCount == 0) {
d->state = QScriptDebuggerAgentPrivate::NoState;
if (d->backend)
d->backend->stepped(scriptId, lineNumber, columnNumber, QScriptValue());
}
break;
case QScriptDebuggerAgentPrivate::SteppingOverState:
if ((d->stepDepth > 0) || (--d->stepCount != 0))
break;
// fallthrough
case QScriptDebuggerAgentPrivate::SteppedOverState:
d->state = QScriptDebuggerAgentPrivate::NoState;
if (d->backend)
d->backend->stepped(scriptId, lineNumber, columnNumber, d->stepResult);
break;
case QScriptDebuggerAgentPrivate::SteppedOutState:
d->state = QScriptDebuggerAgentPrivate::NoState;
if (d->backend)
d->backend->stepped(scriptId, lineNumber, columnNumber, d->stepResult);
break;
case QScriptDebuggerAgentPrivate::RunningToLocationState:
if (((lineNumber == d->targetLineNumber) || (d->targetLineNumber == -1))
&& (scriptId == d->targetScriptId)) {
d->state = QScriptDebuggerAgentPrivate::NoState;
if (d->backend)
d->backend->locationReached(scriptId, lineNumber, columnNumber);
}
break;
case QScriptDebuggerAgentPrivate::InterruptingState:
d->state = QScriptDebuggerAgentPrivate::NoState;
if (d->backend)
d->backend->interrupted(scriptId, lineNumber, columnNumber);
break;
case QScriptDebuggerAgentPrivate::BreakpointState:
d->state = QScriptDebuggerAgentPrivate::NoState;
if (d->backend)
d->backend->breakpoint(scriptId, lineNumber, columnNumber, d->hitBreakpointId);
if (d->breakpoints.value(d->hitBreakpointId).isSingleShot())
deleteBreakpoint(d->hitBreakpointId);
break;
case QScriptDebuggerAgentPrivate::ReturnedByForceState:
d->state = QScriptDebuggerAgentPrivate::NoState;
if (d->backend)
d->backend->forcedReturn(scriptId, lineNumber, columnNumber, d->returnValue);
break;
case QScriptDebuggerAgentPrivate::SteppedIntoState:
case QScriptDebuggerAgentPrivate::ReachedLocationState:
case QScriptDebuggerAgentPrivate::InterruptedState:
// ### deal with the case when code is evaluated while we're already paused
// Q_ASSERT(false);
break;
}
}
/*!
\reimp
*/
void QScriptDebuggerAgent::exceptionThrow(qint64 scriptId,
const QScriptValue &exception,
bool hasHandler)
{
Q_D(QScriptDebuggerAgent);
if (d->state == QScriptDebuggerAgentPrivate::ReturningByForceState) {
// we threw this exception ourselves, so ignore it for now
// (see functionExit()).
return;
}
if (d->backend)
d->backend->exception(scriptId, exception, hasHandler);
}
/*!
\reimp
*/
void QScriptDebuggerAgent::exceptionCatch(qint64 scriptId,
const QScriptValue &exception)
{
Q_UNUSED(scriptId);
Q_UNUSED(exception);
}
/*!
\reimp
*/
bool QScriptDebuggerAgent::supportsExtension(Extension extension) const
{
return (extension == DebuggerInvocationRequest);
}
/*!
\reimp
*/
QVariant QScriptDebuggerAgent::extension(Extension extension,
const QVariant &argument)
{
Q_UNUSED(extension);
Q_D(QScriptDebuggerAgent);
Q_ASSERT(extension == DebuggerInvocationRequest);
QVariantList lst = argument.toList();
qint64 scriptId = lst.at(0).toLongLong();
int lineNumber = lst.at(1).toInt();
int columnNumber = lst.at(2).toInt();
d->state = QScriptDebuggerAgentPrivate::NoState;
if (d->backend) {
d->backend->debuggerInvocationRequest(
scriptId, lineNumber, columnNumber);
}
return QVariant();
}
QT_END_NAMESPACE

View file

@ -1,115 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTDEBUGGERAGENT_P_H
#define QSCRIPTDEBUGGERAGENT_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtScript/qscriptengineagent.h>
#include <QtCore/qpair.h>
#include "qscriptbreakpointdata_p.h"
#include "qscriptscriptdata_p.h"
QT_BEGIN_NAMESPACE
class QScriptDebuggerBackendPrivate;
class QScriptDebuggerAgentPrivate;
class Q_AUTOTEST_EXPORT QScriptDebuggerAgent : public QScriptEngineAgent
{
public:
QScriptDebuggerAgent(QScriptDebuggerBackendPrivate *backend,
QScriptEngine *engine);
~QScriptDebuggerAgent();
void enterStepIntoMode(int count = 1);
void enterStepOverMode(int count = 1);
void enterStepOutMode();
void enterContinueMode();
void enterInterruptMode();
void enterRunToLocationMode(const QString &fileName, int lineNumber);
void enterRunToLocationMode(qint64 scriptId, int lineNumber);
void enterReturnByForceMode(int contextIndex, const QScriptValue &value);
int setBreakpoint(const QScriptBreakpointData &data);
bool deleteBreakpoint(int id);
void deleteAllBreakpoints();
QScriptBreakpointData breakpointData(int id) const;
bool setBreakpointData(int id, const QScriptBreakpointData &data);
QScriptBreakpointMap breakpoints() const;
QScriptScriptMap scripts() const;
QScriptScriptData scriptData(qint64 id) const;
void scriptsCheckpoint();
QPair<QList<qint64>, QList<qint64> > scriptsDelta() const;
qint64 resolveScript(const QString &fileName) const;
QList<qint64> contextIds() const;
QPair<QList<qint64>, QList<qint64> > contextsCheckpoint();
void nullifyBackendPointer();
// reimplemented
void scriptLoad(qint64 id, const QString &program,
const QString &fileName, int baseLineNumber);
void scriptUnload(qint64 id);
void contextPush();
void contextPop();
void functionEntry(qint64 scriptId);
void functionExit(qint64 scriptId,
const QScriptValue &returnValue);
void positionChange(qint64 scriptId,
int lineNumber, int columnNumber);
void exceptionThrow(qint64 scriptId,
const QScriptValue &exception,
bool hasHandler);
void exceptionCatch(qint64 scriptId,
const QScriptValue &exception);
bool supportsExtension(Extension extension) const;
QVariant extension(Extension extension,
const QVariant &argument = QVariant());
private:
QScriptDebuggerAgentPrivate *d_ptr;
Q_DECLARE_PRIVATE(QScriptDebuggerAgent)
Q_DISABLE_COPY(QScriptDebuggerAgent)
};
QT_END_NAMESPACE
#endif

View file

@ -1,106 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTDEBUGGERAGENT_P_P_H
#define QSCRIPTDEBUGGERAGENT_P_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtScript/qscriptvalue.h>
#include <QtCore/qdatetime.h>
#include <QtCore/qhash.h>
#include <QtCore/qmap.h>
#include <QtCore/qlist.h>
#include "qscriptscriptdata_p.h"
#include "qscriptbreakpointdata_p.h"
QT_BEGIN_NAMESPACE
class QScriptDebuggerAgent;
class QScriptDebuggerAgentPrivate
{
public:
enum State {
NoState,
SteppingIntoState,
SteppedIntoState,
SteppingOverState,
SteppedOverState,
SteppingOutState,
SteppedOutState,
RunningToLocationState,
ReachedLocationState,
InterruptingState,
InterruptedState,
BreakpointState,
ReturningByForceState,
ReturnedByForceState
};
QScriptDebuggerAgentPrivate();
~QScriptDebuggerAgentPrivate();
static QScriptDebuggerAgentPrivate *get(QScriptDebuggerAgent *);
State state;
int stepDepth;
int stepCount;
int targetScriptId;
QString targetFileName;
int targetLineNumber;
QScriptValue stepResult;
int returnCounter;
QScriptValue returnValue;
int nextBreakpointId;
QHash<qint64, QList<int> > resolvedBreakpoints;
QHash<QString, QList<int> > unresolvedBreakpoints;
QScriptBreakpointMap breakpoints;
int hitBreakpointId;
QScriptScriptMap scripts;
QScriptScriptMap checkpointScripts;
QScriptScriptMap previousCheckpointScripts;
QList<QList<qint64> > scriptIdStack;
QList<qint64> contextIdStack;
QList<qint64> checkpointContextIdStack;
qint64 nextContextId;
QTime processEventsTimer;
int statementCounter;
QScriptDebuggerBackendPrivate *backend;
};
QT_END_NAMESPACE
#endif

View file

@ -1,972 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qscriptdebuggerbackend_p.h"
#include "qscriptdebuggerbackend_p_p.h"
#include "qscriptdebuggeragent_p.h"
#include "qscriptdebuggercommandexecutor_p.h"
#include "qscriptdebuggerevent_p.h"
#include "qscriptdebuggervalue_p.h"
#include "qscriptscriptdata_p.h"
#include "qscriptbreakpointdata_p.h"
#include "qscriptobjectsnapshot_p.h"
#include "qscripttoolscommon_p.h"
#include <QtScript/qscriptengine.h>
#include <QtScript/qscriptcontextinfo.h>
#include <QtScript/qscriptvalueiterator.h>
#include <QtCore/qcoreapplication.h>
#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
/*!
\since 4.5
\class QScriptDebuggerBackend
\internal
\brief The QScriptDebuggerBackend class is the base class of debugger back-ends.
QScriptDebuggerBackend builds on the QScriptDebuggerAgent class.
This class is usually used together with the QScriptDebuggerFrontend
class, in order to form a (front-end, back-end) pair.
Call attachTo() to attach to a QScriptEngine object. Call detach()
to detach from the current engine.
Call stepInto() to step into the next script statement; call stepOver()
to step over the next script statement; and call stepOut() to step out
of the currently executing script function. An event() will be generated
when the stepping is completed.
Call runToLocation() to execute script statements until a certain
location has been reached. An event() will be generated when the location
has been reached.
Call interruptEvaluation() to request that evaluation should be
interrupted. An event() will be generated upon the next script
statement that is reached.
Call continueEvalution() to allow script evaluation to continue.
Call setBreakpoint() to set a breakpoint. A breakpoint event() will
be generated when a breakpoint is hit. Call deleteBreakpoint() to
delete a breakpoint. Call modifyBreakpoint() to change the state of
an existing breakpoint.
Call contextCount() to obtain the number of active contexts
(frames). Call context() to obtain a pointer to a QScriptContext.
\section1 Subclassing
When subclassing QScriptDebuggerBackend, you must implement the pure
virtual event() function. This function typically forwards the event
to a QScriptDebuggerFrontend object. For most type of events,
event() should block until the back-end is instructed to resume
execution (e.g. until continueEvalution() is called). You must
implement resume(), which is responsible for making event() return.
\sa QScriptDebuggerFrontend, QScriptDebuggerEvent
*/
// helper class that's used to handle our custom Qt events
class QScriptDebuggerBackendEventReceiver : public QObject
{
public:
QScriptDebuggerBackendEventReceiver(QScriptDebuggerBackendPrivate *backend,
QObject *parent = nullptr)
: QObject(parent), m_backend(backend) {}
~QScriptDebuggerBackendEventReceiver() {}
bool event(QEvent *e)
{
return m_backend->event(e);
}
private:
QScriptDebuggerBackendPrivate *m_backend;
};
QScriptDebuggerBackendPrivate::QScriptDebuggerBackendPrivate()
: agent(0), commandExecutor(0),
pendingEvaluateContextIndex(-1), pendingEvaluateLineNumber(-1),
ignoreExceptions(false),
nextScriptValueIteratorId(0), nextScriptObjectSnapshotId(0),
eventReceiver(0),
q_ptr(0) // q_ptr will be set later by QScriptDebuggerBackend constructor
{
}
QScriptDebuggerBackendPrivate::~QScriptDebuggerBackendPrivate()
{
if (agent)
agent->nullifyBackendPointer();
delete commandExecutor;
delete eventReceiver;
qDeleteAll(scriptValueIterators);
qDeleteAll(scriptObjectSnapshots);
}
void QScriptDebuggerBackendPrivate::postEvent(QEvent *e)
{
if (!eventReceiver) {
eventReceiver = new QScriptDebuggerBackendEventReceiver(this);
Q_ASSERT(agent != 0);
eventReceiver->moveToThread(agent->engine()->thread());
}
QCoreApplication::postEvent(eventReceiver, e);
}
bool QScriptDebuggerBackendPrivate::event(QEvent *e)
{
if (e->type() == QEvent::User+1) {
QScriptDebuggerEventEvent *de = static_cast<QScriptDebuggerEventEvent*>(e);
q_func()->event(de->event());
return true;
}
return false;
}
void QScriptDebuggerBackendPrivate::agentDestroyed(QScriptDebuggerAgent *ag)
{
// Since agents are owned by the script engine, this in practice means
// that the engine has been destroyed. Invalidate our pointer so we
// don't crash later.
if (agent == ag)
agent = 0;
}
/*!
The agent calls this function when it has completed a step
operation.
*/
void QScriptDebuggerBackendPrivate::stepped(qint64 scriptId,
int lineNumber,
int columnNumber,
const QScriptValue &result)
{
Q_Q(QScriptDebuggerBackend);
QScriptDebuggerEvent e(QScriptDebuggerEvent::SteppingFinished,
scriptId, lineNumber, columnNumber);
e.setFileName(agent->scriptData(scriptId).fileName());
QScriptDebuggerValue value(result);
e.setScriptValue(value);
if (!result.isUndefined())
e.setMessage(result.toString()); // for convenience -- we always need it
q->event(e);
}
/*!
The agent calls this function when it has run to a particular
location.
*/
void QScriptDebuggerBackendPrivate::locationReached(qint64 scriptId,
int lineNumber,
int columnNumber)
{
Q_Q(QScriptDebuggerBackend);
QScriptDebuggerEvent e(QScriptDebuggerEvent::LocationReached,
scriptId, lineNumber, columnNumber);
e.setFileName(agent->scriptData(scriptId).fileName());
q->event(e);
}
/*!
The agent calls this function when evaluation has been interrupted.
*/
void QScriptDebuggerBackendPrivate::interrupted(qint64 scriptId,
int lineNumber,
int columnNumber)
{
Q_Q(QScriptDebuggerBackend);
QScriptDebuggerEvent e(QScriptDebuggerEvent::Interrupted,
scriptId, lineNumber, columnNumber);
e.setFileName(agent->scriptData(scriptId).fileName());
q->event(e);
}
/*!
The agent calls this function when a breakpoint has been triggered.
*/
void QScriptDebuggerBackendPrivate::breakpoint(qint64 scriptId,
int lineNumber,
int columnNumber,
int breakpointId)
{
Q_Q(QScriptDebuggerBackend);
QScriptDebuggerEvent e(QScriptDebuggerEvent::Breakpoint,
scriptId, lineNumber, columnNumber);
e.setFileName(agent->scriptData(scriptId).fileName());
e.setBreakpointId(breakpointId);
q->event(e);
}
/*!
The agent calls this function when an uncaught exception has
occurred.
*/
void QScriptDebuggerBackendPrivate::exception(qint64 scriptId,
const QScriptValue &exception,
bool hasHandler)
{
Q_Q(QScriptDebuggerBackend);
if (ignoreExceptions) {
// don't care (it's caught by us)
return;
}
QScriptDebuggerEvent e(QScriptDebuggerEvent::Exception);
e.setScriptId(scriptId);
e.setFileName(agent->scriptData(scriptId).fileName());
e.setMessage(exception.toString());
e.setHasExceptionHandler(hasHandler);
int lineNumber = -1;
QString fileName;
if (exception.property(QLatin1String("lineNumber")).isNumber())
lineNumber = exception.property(QLatin1String("lineNumber")).toInt32();
if (exception.property(QLatin1String("fileName")).isString())
fileName = exception.property(QLatin1String("fileName")).toString();
if (lineNumber == -1) {
QScriptContextInfo info(q->engine()->currentContext());
lineNumber = info.lineNumber();
fileName = info.fileName();
}
if (lineNumber != -1)
e.setLineNumber(lineNumber);
if (!fileName.isEmpty())
e.setFileName(fileName);
QScriptDebuggerValue value(exception);
e.setScriptValue(value);
q->event(e);
}
QScriptValue QScriptDebuggerBackendPrivate::trace(QScriptContext *context,
QScriptEngine *engine)
{
QScriptValue data = context->callee().data();
QScriptDebuggerBackendPrivate *self = qscriptvalue_cast<QScriptDebuggerBackendPrivate*>(data);
if (!self)
return engine->undefinedValue();
QString str;
for (int i = 0; i < context->argumentCount(); ++i) {
if (i > 0)
str.append(QLatin1Char(' '));
str.append(context->argument(i).toString());
}
QScriptDebuggerEvent e(QScriptDebuggerEvent::Trace);
e.setMessage(str);
self->q_func()->event(e);
return engine->undefinedValue();
}
QScriptValue QScriptDebuggerBackendPrivate::qsassert(QScriptContext *context,
QScriptEngine *engine)
{
QScriptValue arg = context->argument(0);
if (arg.toBoolean())
return arg;
QScriptContextInfo info(context->parentContext());
QString msg;
QString fileName = info.fileName();
if (fileName.isEmpty())
fileName = QString::fromLatin1("<anonymous script, id=%0>").arg(info.scriptId());
msg.append(fileName);
msg.append(QLatin1Char(':'));
msg.append(QString::number(info.lineNumber()));
msg.append(QString::fromLatin1(": Assertion failed"));
for (int i = 1; i < context->argumentCount(); ++i) {
if (i == 1)
msg.append(QLatin1Char(':'));
msg.append(QLatin1Char(' '));
msg.append(context->argument(i).toString());
}
QScriptValue err = context->throwError(msg);
err.setProperty(QString::fromLatin1("name"), QScriptValue(engine, QString::fromLatin1("AssertionError")));
return err;
}
QScriptValue QScriptDebuggerBackendPrivate::fileName(QScriptContext *context,
QScriptEngine *engine)
{
QScriptContextInfo info(context->parentContext());
QString fn = info.fileName();
if (fn.isEmpty())
return engine->undefinedValue();
return QScriptValue(engine, fn);
}
QScriptValue QScriptDebuggerBackendPrivate::lineNumber(QScriptContext *context,
QScriptEngine *engine)
{
QScriptContextInfo info(context->parentContext());
return QScriptValue(engine, info.lineNumber());
}
/*!
The agent calls this function when the engine has reached a
"debugger" statement.
*/
void QScriptDebuggerBackendPrivate::debuggerInvocationRequest(
qint64 scriptId, int lineNumber, int columnNumber)
{
Q_Q(QScriptDebuggerBackend);
QScriptDebuggerEvent e(QScriptDebuggerEvent::DebuggerInvocationRequest,
scriptId, lineNumber, columnNumber);
e.setFileName(agent->scriptData(scriptId).fileName());
q->event(e);
}
void QScriptDebuggerBackendPrivate::forcedReturn(
qint64 scriptId, int lineNumber, int columnNumber,
const QScriptValue &value)
{
Q_Q(QScriptDebuggerBackend);
QScriptDebuggerEvent e(QScriptDebuggerEvent::ForcedReturn,
scriptId, lineNumber, columnNumber);
e.setFileName(agent->scriptData(scriptId).fileName());
e.setScriptValue(QScriptDebuggerValue(value));
q->event(e);
}
/*!
Creates a QScriptDebuggerBackend object.
*/
QScriptDebuggerBackend::QScriptDebuggerBackend()
: d_ptr(new QScriptDebuggerBackendPrivate)
{
d_ptr->q_ptr = this;
}
/*!
Destroys this QScriptDebuggerBackend.
*/
QScriptDebuggerBackend::~QScriptDebuggerBackend()
{
detach();
}
/*!
\internal
*/
QScriptDebuggerBackend::QScriptDebuggerBackend(QScriptDebuggerBackendPrivate &dd)
: d_ptr(&dd)
{
d_ptr->q_ptr = this;
}
/*!
Attaches this backend to the given \a engine.
The backend automatically detaches from the old engine, if any.
This function installs its own agent on the \a engine using
QScriptEngine::setAgent(); any existing agent will be replaced.
\sa detach(). engine()
*/
void QScriptDebuggerBackend::attachTo(QScriptEngine *engine)
{
Q_D(QScriptDebuggerBackend);
detach();
d->agent = new QScriptDebuggerAgent(d, engine);
QScriptValue global = engine->globalObject();
d->origTraceFunction = global.property(QString::fromLatin1("print"));
global.setProperty(QString::fromLatin1("print"), traceFunction());
// global.setProperty(QString::fromLatin1("qAssert"), assertFunction());
d->origFileNameFunction = global.property(QString::fromLatin1("__FILE__"));
global.setProperty(QString::fromLatin1("__FILE__"), fileNameFunction(),
QScriptValue::PropertyGetter | QScriptValue::ReadOnly);
d->origLineNumberFunction = global.property(QString::fromLatin1("__LINE__"));
global.setProperty(QString::fromLatin1("__LINE__"), lineNumberFunction(),
QScriptValue::PropertyGetter | QScriptValue::ReadOnly);
engine->setAgent(d->agent);
}
/*!
Detaches this backend from the current script engine.
The backend's state (including breakpoints and information on loaded
scripts) will be invalidated.
\sa attach()
*/
void QScriptDebuggerBackend::detach()
{
Q_D(QScriptDebuggerBackend);
if (d->agent) {
QScriptEngine *eng = d->agent->engine();
if (eng && eng->agent() == d->agent) {
eng->setAgent(0);
QScriptValue global = eng->globalObject();
global.setProperty(QString::fromLatin1("print"), d->origTraceFunction);
d->origTraceFunction = QScriptValue();
// global.setProperty(QString::fromLatin1("qAssert"), QScriptValue());
global.setProperty(QString::fromLatin1("__FILE__"), QScriptValue(),
QScriptValue::PropertyGetter);
global.setProperty(QString::fromLatin1("__FILE__"), d->origFileNameFunction);
d->origFileNameFunction = QScriptValue();
global.setProperty(QString::fromLatin1("__LINE__"), QScriptValue(),
QScriptValue::PropertyGetter);
global.setProperty(QString::fromLatin1("__LINE__"), d->origLineNumberFunction);
d->origLineNumberFunction = QScriptValue();
d->agent->nullifyBackendPointer();
d->agent = 0; // agent is owned by engine
}
}
d->pendingEvaluateLineNumber = -1;
d->ignoreExceptions = false;
d->nextScriptValueIteratorId = 0;
qDeleteAll(d->scriptValueIterators);
d->scriptValueIterators.clear();
qDeleteAll(d->scriptObjectSnapshots);
d->scriptObjectSnapshots.clear();
}
/*!
Returns the script engine that this backend is attached to, or 0 if
the backend is not attached to an engine.
\sa attachTo()
*/
QScriptEngine *QScriptDebuggerBackend::engine() const
{
Q_D(const QScriptDebuggerBackend);
if (!d->agent)
return 0;
return d->agent->engine();
}
/*!
Steps into the next script statement.
When stepping is complete, an event() will be generated.
*/
void QScriptDebuggerBackend::stepInto(int count)
{
Q_D(QScriptDebuggerBackend);
if (d->agent) {
d->agent->enterStepIntoMode(count);
resume();
}
}
/*!
Steps over the next script statement.
When stepping is complete, an event() will be generated.
*/
void QScriptDebuggerBackend::stepOver(int count)
{
Q_D(QScriptDebuggerBackend);
if (d->agent) {
d->agent->enterStepOverMode(count);
resume();
}
}
/*!
Steps out of the current script function.
When stepping is complete, an event() will be generated.
*/
void QScriptDebuggerBackend::stepOut()
{
Q_D(QScriptDebuggerBackend);
if (d->agent) {
d->agent->enterStepOutMode();
resume();
}
}
/*!
Continues script evaluation. Evaluation will proceed without
interruption until either 1) an uncaught exception occurs, 2) a
breakpoint is triggered, or 3) interruptEvaluation() is called.
In each case, a proper event() will be generated.
*/
void QScriptDebuggerBackend::continueEvalution()
{
Q_D(QScriptDebuggerBackend);
if (d->agent) {
d->agent->enterContinueMode();
resume();
}
}
/*!
Interrupts script evaluation. When the next script statement is
reached, an event() will be generated.
*/
void QScriptDebuggerBackend::interruptEvaluation()
{
Q_D(QScriptDebuggerBackend);
if (d->agent)
d->agent->enterInterruptMode();
}
/*!
Continues evaluation until the location defined by the given \a
fileName and \a lineNumber is reached. When the location is reached,
an event() will be generated.
*/
void QScriptDebuggerBackend::runToLocation(const QString &fileName, int lineNumber)
{
Q_D(QScriptDebuggerBackend);
if (d->agent) {
d->agent->enterRunToLocationMode(fileName, lineNumber);
resume();
}
}
/*!
Continues evaluation until the location defined by the given \a
scriptId and \a lineNumber is reached. When the location is reached,
an event() will be generated.
*/
void QScriptDebuggerBackend::runToLocation(qint64 scriptId, int lineNumber)
{
Q_D(QScriptDebuggerBackend);
if (d->agent) {
d->agent->enterRunToLocationMode(scriptId, lineNumber);
resume();
}
}
void QScriptDebuggerBackend::returnToCaller(int contextIndex, const QScriptValue &value)
{
Q_D(QScriptDebuggerBackend);
if (d->agent) {
d->agent->enterReturnByForceMode(contextIndex, value);
resume();
}
}
/*!
Evaluates the given \a program. When evaluation is complete, an
event() is generated.
*/
void QScriptDebuggerBackend::evaluate(int contextIndex, const QString &program,
const QString &fileName, int lineNumber)
{
Q_D(QScriptDebuggerBackend);
d->pendingEvaluateContextIndex = contextIndex;
d->pendingEvaluateProgram = program;
d->pendingEvaluateFileName = fileName;
d->pendingEvaluateLineNumber = lineNumber;
if (!engine()->isEvaluating())
doPendingEvaluate(/*postEvent=*/true);
else
resume();
}
/*!
Executes the pending evaluate, if any.
*/
void QScriptDebuggerBackend::doPendingEvaluate(bool postEvent)
{
Q_D(QScriptDebuggerBackend);
QString program = d->pendingEvaluateProgram;
if (program.isEmpty())
return;
int contextIndex = d->pendingEvaluateContextIndex;
QScriptContext *ctx = context(contextIndex);
Q_ASSERT(ctx != 0);
QString fileName = d->pendingEvaluateFileName;
int lineNumber = d->pendingEvaluateLineNumber;
d->pendingEvaluateProgram = QString();
d->pendingEvaluateFileName = QString();
d->pendingEvaluateLineNumber = -1;
d->pendingEvaluateContextIndex = -1;
// push a new context and initialize its scope chain etc.
{
QScriptContext *evalContext = engine()->pushContext();
QScriptValueList scopeChain = ctx->scopeChain();
if (scopeChain.isEmpty())
scopeChain.append(engine()->globalObject());
while (!scopeChain.isEmpty())
evalContext->pushScope(scopeChain.takeLast());
evalContext->setActivationObject(ctx->activationObject());
evalContext->setThisObject(ctx->thisObject());
}
d->agent->enterContinueMode();
// set a flag so that any exception that happens in
// the evaluate() is not sent to the debugger
d->ignoreExceptions = true;
bool hadException = engine()->hasUncaughtException();
QScriptValue ret = engine()->evaluate(program, fileName, lineNumber);
d->ignoreExceptions = false;
if (!hadException && engine()->hasUncaughtException())
engine()->clearExceptions();
engine()->popContext();
QScriptDebuggerValue retret(ret);
QScriptDebuggerEvent e(QScriptDebuggerEvent::InlineEvalFinished);
e.setScriptValue(retret);
if (!ret.isUndefined())
e.setMessage(ret.toString()); // for convenience -- we always need it
e.setNestedEvaluate(engine()->isEvaluating());
if (postEvent) {
QScriptDebuggerEventEvent *de = new QScriptDebuggerEventEvent(e);
d->postEvent(de);
} else {
event(e);
}
}
/*!
Sets a breakpoint defined by the given \a data, and returns a unique
identifier for the new breakpoint.
If the conditions of the breakpoint is satisfied at some point
during script evaluation, a breakpoint event() will be generated.
\sa deleteBreakpoint(), breakpoints()
*/
int QScriptDebuggerBackend::setBreakpoint(const QScriptBreakpointData &data)
{
Q_D(QScriptDebuggerBackend);
if (!d->agent)
return -1;
if (!data.isValid())
return -1;
return d->agent->setBreakpoint(data);
}
/*!
Deletes the breakpoint identified by the given \a id. Returns true
if the breakpoint was deleted (i.e. the \a id was valid), otherwise
returns false.
\sa setBreakpoint()
*/
bool QScriptDebuggerBackend::deleteBreakpoint(int id)
{
Q_D(QScriptDebuggerBackend);
if (!d->agent)
return false;
return d->agent->deleteBreakpoint(id);
}
/*!
Deletes all breakpoints.
*/
void QScriptDebuggerBackend::deleteAllBreakpoints()
{
Q_D(QScriptDebuggerBackend);
if (d->agent)
d->agent->deleteAllBreakpoints();
}
/*!
Returns the data associated with the breakpoint identified by the
given \a id.
*/
QScriptBreakpointData QScriptDebuggerBackend::breakpointData(int id) const
{
Q_D(const QScriptDebuggerBackend);
if (!d->agent)
return QScriptBreakpointData();
return d->agent->breakpointData(id);
}
/*!
Sets the \a data associated with the breakpoint identified by the
given \a id.
*/
bool QScriptDebuggerBackend::setBreakpointData(int id, const QScriptBreakpointData &data)
{
Q_D(QScriptDebuggerBackend);
if (d->agent)
return d->agent->setBreakpointData(id, data);
return false;
}
/*!
Returns this backend's breakpoints.
\sa setBreakpoint()
*/
QScriptBreakpointMap QScriptDebuggerBackend::breakpoints() const
{
Q_D(const QScriptDebuggerBackend);
if (!d->agent)
return QScriptBreakpointMap();
return d->agent->breakpoints();
}
/*!
Returns the scripts that this backend knows about.
\sa scriptData()
*/
QScriptScriptMap QScriptDebuggerBackend::scripts() const
{
Q_D(const QScriptDebuggerBackend);
if (!d->agent)
return QScriptScriptMap();
return d->agent->scripts();
}
/*!
Returns the data for the script identified by the given \a id.
\sa scripts()
*/
QScriptScriptData QScriptDebuggerBackend::scriptData(qint64 id) const
{
Q_D(const QScriptDebuggerBackend);
if (!d->agent)
return QScriptScriptData();
return d->agent->scriptData(id);
}
/*!
Makes a checkpoint of the currently loaded scripts.
\sa scriptsDelta()
*/
void QScriptDebuggerBackend::scriptsCheckpoint()
{
Q_D(QScriptDebuggerBackend);
if (d->agent)
d->agent->scriptsCheckpoint();
}
/*!
Returns the difference between the latest scripts checkpoint and the
previous checkpoint. The first item in the pair is a list
containing the identifiers of the scripts that were added. The
second item in the pair is a list containing the identifiers of the
scripts that were removed.
\sa scriptsCheckpoint()
*/
QScriptScriptsDelta QScriptDebuggerBackend::scriptsDelta() const
{
Q_D(const QScriptDebuggerBackend);
if (!d->agent)
return QPair<QList<qint64>, QList<qint64> >();
return d->agent->scriptsDelta();
}
qint64 QScriptDebuggerBackend::resolveScript(const QString &fileName) const
{
Q_D(const QScriptDebuggerBackend);
if (!d->agent)
return -1;
return d->agent->resolveScript(fileName);
}
/*!
Returns the number of contexts (frames).
*/
int QScriptDebuggerBackend::contextCount() const
{
if (!engine())
return 0;
return contextIds().count();
}
/*!
Returns the context for the frame with the given \a index.
*/
QScriptContext *QScriptDebuggerBackend::context(int index) const
{
if (index < 0)
return 0;
QScriptContext *ctx = engine()->currentContext();
while (ctx) {
if (index == 0)
return ctx;
ctx = ctx->parentContext();
--index;
}
return 0;
}
/*!
Returns a backtrace of the current execution.
*/
QStringList QScriptDebuggerBackend::backtrace() const
{
if (!engine())
return QStringList();
return engine()->currentContext()->backtrace();
}
QList<qint64> QScriptDebuggerBackend::contextIds() const
{
Q_D(const QScriptDebuggerBackend);
if (!d->agent)
return QList<qint64>();
return d->agent->contextIds();
}
QScriptContextsDelta QScriptDebuggerBackend::contextsCheckpoint()
{
Q_D(QScriptDebuggerBackend);
if (!d->agent)
return QScriptContextsDelta();
return d->agent->contextsCheckpoint();
}
int QScriptDebuggerBackend::newScriptObjectSnapshot()
{
Q_D(QScriptDebuggerBackend);
int id = d->nextScriptObjectSnapshotId;
++d->nextScriptObjectSnapshotId;
d->scriptObjectSnapshots[id] = new QScriptObjectSnapshot();
return id;
}
QScriptObjectSnapshot *QScriptDebuggerBackend::scriptObjectSnapshot(int id) const
{
Q_D(const QScriptDebuggerBackend);
return d->scriptObjectSnapshots.value(id);
}
void QScriptDebuggerBackend::deleteScriptObjectSnapshot(int id)
{
Q_D(QScriptDebuggerBackend);
QScriptObjectSnapshot *snap = d->scriptObjectSnapshots.take(id);
delete snap;
}
int QScriptDebuggerBackend::newScriptValueIterator(const QScriptValue &object)
{
Q_D(QScriptDebuggerBackend);
int id = d->nextScriptValueIteratorId;
++d->nextScriptValueIteratorId;
d->scriptValueIterators[id] = new QScriptValueIterator(object);
return id;
}
QScriptValueIterator *QScriptDebuggerBackend::scriptValueIterator(int id) const
{
Q_D(const QScriptDebuggerBackend);
return d->scriptValueIterators.value(id);
}
void QScriptDebuggerBackend::deleteScriptValueIterator(int id)
{
Q_D(QScriptDebuggerBackend);
QScriptValueIterator *it = d->scriptValueIterators.take(id);
delete it;
}
bool QScriptDebuggerBackend::ignoreExceptions() const
{
Q_D(const QScriptDebuggerBackend);
return d->ignoreExceptions;
}
void QScriptDebuggerBackend::setIgnoreExceptions(bool ignore)
{
Q_D(QScriptDebuggerBackend);
d->ignoreExceptions = ignore;
}
/*!
Returns a trace function. The trace function has similar semantics
to the built-in print() function; however, instead of writing text
to standard output, it generates a trace event containing the text.
*/
QScriptValue QScriptDebuggerBackend::traceFunction() const
{
Q_D(const QScriptDebuggerBackend);
if (!engine())
return QScriptValue();
QScriptValue fun = engine()->newFunction(QScriptDebuggerBackendPrivate::trace);
fun.setData(qScriptValueFromValue(engine(), const_cast<QScriptDebuggerBackendPrivate*>(d)));
return fun;
}
QScriptValue QScriptDebuggerBackend::assertFunction() const
{
if (!engine())
return QScriptValue();
QScriptValue fun = engine()->newFunction(QScriptDebuggerBackendPrivate::qsassert);
return fun;
}
QScriptValue QScriptDebuggerBackend::fileNameFunction() const
{
if (!engine())
return QScriptValue();
QScriptValue fun = engine()->newFunction(QScriptDebuggerBackendPrivate::fileName);
return fun;
}
QScriptValue QScriptDebuggerBackend::lineNumberFunction() const
{
if (!engine())
return QScriptValue();
QScriptValue fun = engine()->newFunction(QScriptDebuggerBackendPrivate::lineNumber);
return fun;
}
QScriptDebuggerCommandExecutor *QScriptDebuggerBackend::commandExecutor() const
{
Q_D(const QScriptDebuggerBackend);
if (d->commandExecutor)
return d->commandExecutor;
QScriptDebuggerBackendPrivate *dd = const_cast<QScriptDebuggerBackendPrivate*>(d);
dd->commandExecutor = new QScriptDebuggerCommandExecutor();
return dd->commandExecutor;
}
void QScriptDebuggerBackend::setCommandExecutor(QScriptDebuggerCommandExecutor *executor)
{
Q_D(QScriptDebuggerBackend);
d->commandExecutor = executor;
}
/*!
\fn void QScriptDebuggerBackend::resume()
This function is called when control should be returned back to the
back-end, i.e. when script evaluation should be resumed after an
event has been delivered.
Subclasses must reimplement this function to make event() return.
\sa event()
*/
/*!
\fn void QScriptDebuggerBackend::event(const QScriptDebuggerEvent &event)
This function is called when the back-end has generated the given \a event.
Subclasses must reimplement this function to handle the
event. Typically the event is forwarded to a
QScriptDebuggerFrontend, which will in turn forward it to its
QScriptDebuggerClient. The client may then query the front-end for
information about the execution state, and call e.g.
continueEvalution() to resume execution. This function should block
until resume() is called.
\sa resume()
*/
QT_END_NAMESPACE

View file

@ -1,136 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTDEBUGGERBACKEND_P_H
#define QSCRIPTDEBUGGERBACKEND_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtCore/qobjectdefs.h>
#include <QtCore/qpair.h>
#include "qscriptbreakpointdata_p.h"
#include "qscriptscriptdata_p.h"
QT_BEGIN_NAMESPACE
class QScriptContext;
class QScriptEngine;
class QScriptDebuggerCommandExecutor;
class QScriptDebuggerEvent;
class QScriptValue;
class QScriptValueIterator;
class QScriptObjectSnapshot;
class QStringList;
typedef QPair<QList<qint64>, QList<qint64> > QScriptScriptsDelta;
typedef QPair<QList<qint64>, QList<qint64> > QScriptContextsDelta;
class QScriptDebuggerBackendPrivate;
class Q_AUTOTEST_EXPORT QScriptDebuggerBackend
{
public:
QScriptDebuggerBackend();
virtual ~QScriptDebuggerBackend();
void attachTo(QScriptEngine *engine);
void detach();
QScriptEngine *engine() const;
void stepInto(int count = 1);
void stepOver(int count = 1);
void stepOut();
void continueEvalution();
void interruptEvaluation();
void runToLocation(const QString &fileName, int lineNumber);
void runToLocation(qint64 scriptId, int lineNumber);
void returnToCaller(int contextIndex, const QScriptValue &value);
void evaluate(int contextIndex, const QString &program,
const QString &fileName, int lineNumber);
int setBreakpoint(const QScriptBreakpointData &data);
bool deleteBreakpoint(int id);
void deleteAllBreakpoints();
QScriptBreakpointData breakpointData(int id) const;
bool setBreakpointData(int id, const QScriptBreakpointData &data);
QScriptBreakpointMap breakpoints() const;
QScriptScriptMap scripts() const;
QScriptScriptData scriptData(qint64 id) const;
void scriptsCheckpoint();
QScriptScriptsDelta scriptsDelta() const;
qint64 resolveScript(const QString &fileName) const;
int contextCount() const;
QScriptContext *context(int index) const;
QStringList backtrace() const;
QList<qint64> contextIds() const;
QScriptContextsDelta contextsCheckpoint();
int newScriptObjectSnapshot();
QScriptObjectSnapshot *scriptObjectSnapshot(int id) const;
void deleteScriptObjectSnapshot(int id);
int newScriptValueIterator(const QScriptValue &object);
QScriptValueIterator *scriptValueIterator(int id) const;
void deleteScriptValueIterator(int id);
QScriptValue traceFunction() const;
QScriptValue assertFunction() const;
QScriptValue fileNameFunction() const;
QScriptValue lineNumberFunction() const;
void doPendingEvaluate(bool postEvent);
bool ignoreExceptions() const;
void setIgnoreExceptions(bool ignore);
QScriptDebuggerCommandExecutor *commandExecutor() const;
void setCommandExecutor(QScriptDebuggerCommandExecutor *executor);
virtual void resume() = 0;
protected:
virtual void event(const QScriptDebuggerEvent &event) = 0;
protected:
QScriptDebuggerBackend(QScriptDebuggerBackendPrivate &dd);
QScopedPointer<QScriptDebuggerBackendPrivate> d_ptr;
private:
Q_DECLARE_PRIVATE(QScriptDebuggerBackend)
Q_DISABLE_COPY(QScriptDebuggerBackend)
};
QT_END_NAMESPACE
#endif

View file

@ -1,117 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTDEBUGGERBACKEND_P_P_H
#define QSCRIPTDEBUGGERBACKEND_P_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtCore/qobjectdefs.h>
#include <QtCore/qhash.h>
#include <QtCore/qlist.h>
#include <QtScript/qscriptvalue.h>
#include "qscriptdebuggerbackend_p.h"
QT_BEGIN_NAMESPACE
class QEvent;
class QString;
class QScriptContext;
class QScriptEngine;
class QScriptValueIterator;
class QScriptObjectSnapshot;
class QScriptDebuggerAgent;
class QScriptDebuggerCommandExecutor;
class QScriptDebuggerBackend;
class Q_AUTOTEST_EXPORT QScriptDebuggerBackendPrivate
{
Q_DECLARE_PUBLIC(QScriptDebuggerBackend)
public:
QScriptDebuggerBackendPrivate();
virtual ~QScriptDebuggerBackendPrivate();
void postEvent(QEvent *e);
virtual bool event(QEvent *e);
// events reported by agent
virtual void stepped(qint64 scriptId, int lineNumber, int columnNumber,
const QScriptValue &result);
virtual void locationReached(qint64 scriptId, int lineNumber, int columnNumber);
virtual void interrupted(qint64 scriptId, int lineNumber, int columnNumber);
virtual void breakpoint(qint64 scriptId, int lineNumber, int columnNumber,
int breakpointId);
virtual void exception(qint64 scriptId, const QScriptValue &exception,
bool hasHandler);
virtual void debuggerInvocationRequest(qint64 scriptId, int lineNumber,
int columnNumber);
virtual void forcedReturn(qint64 scriptId, int lineNumber, int columnNumber,
const QScriptValue &value);
static QScriptValue trace(QScriptContext *context,
QScriptEngine *engine);
static QScriptValue qsassert(QScriptContext *context,
QScriptEngine *engine);
static QScriptValue fileName(QScriptContext *context,
QScriptEngine *engine);
static QScriptValue lineNumber(QScriptContext *context,
QScriptEngine *engine);
void agentDestroyed(QScriptDebuggerAgent *);
QScriptDebuggerAgent *agent;
QScriptDebuggerCommandExecutor *commandExecutor;
int pendingEvaluateContextIndex;
QString pendingEvaluateProgram;
QString pendingEvaluateFileName;
int pendingEvaluateLineNumber;
bool ignoreExceptions;
int nextScriptValueIteratorId;
QMap<int, QScriptValueIterator*> scriptValueIterators;
int nextScriptObjectSnapshotId;
QMap<int, QScriptObjectSnapshot*> scriptObjectSnapshots;
QObject *eventReceiver;
QScriptDebuggerBackend *q_ptr;
QScriptValue origTraceFunction;
QScriptValue origFileNameFunction;
QScriptValue origLineNumberFunction;
};
QT_END_NAMESPACE
#endif

View file

@ -1,230 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qscriptdebuggercodefinderwidget_p.h"
#include "qscriptdebuggercodefinderwidgetinterface_p_p.h"
#include "qscripttoolsresources_p.h"
#include <QtGui/qboxlayout.h>
#include <QtGui/qlineedit.h>
#include <QtGui/qcheckbox.h>
#include <QtGui/qlabel.h>
#include <QtGui/qtoolbutton.h>
#include <QtGui/qevent.h>
#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
class QScriptDebuggerCodeFinderWidgetPrivate
: public QScriptDebuggerCodeFinderWidgetInterfacePrivate
{
Q_DECLARE_PUBLIC(QScriptDebuggerCodeFinderWidget)
public:
QScriptDebuggerCodeFinderWidgetPrivate();
~QScriptDebuggerCodeFinderWidgetPrivate();
// private slots
void _q_updateButtons();
void _q_onTextChanged(const QString &);
void _q_next();
void _q_previous();
int findOptions() const;
QLineEdit *editFind;
QCheckBox *checkCase;
QLabel *labelWrapped;
QToolButton *toolNext;
QToolButton *toolClose;
QToolButton *toolPrevious;
QCheckBox *checkWholeWords;
};
QScriptDebuggerCodeFinderWidgetPrivate::QScriptDebuggerCodeFinderWidgetPrivate()
{
}
QScriptDebuggerCodeFinderWidgetPrivate::~QScriptDebuggerCodeFinderWidgetPrivate()
{
}
void QScriptDebuggerCodeFinderWidgetPrivate::_q_updateButtons()
{
if (editFind->text().isEmpty()) {
toolPrevious->setEnabled(false);
toolNext->setEnabled(false);
} else {
toolPrevious->setEnabled(true);
toolNext->setEnabled(true);
}
}
int QScriptDebuggerCodeFinderWidgetPrivate::findOptions() const
{
int flags = 0;
if (checkCase->isChecked())
flags |= QTextDocument::FindCaseSensitively;
if (checkWholeWords->isChecked())
flags |= QTextDocument::FindWholeWords;
return flags;
}
void QScriptDebuggerCodeFinderWidgetPrivate::_q_onTextChanged(const QString &text)
{
emit q_func()->findRequest(text, findOptions() | 0x100);
}
void QScriptDebuggerCodeFinderWidgetPrivate::_q_next()
{
emit q_func()->findRequest(editFind->text(), findOptions());
}
void QScriptDebuggerCodeFinderWidgetPrivate::_q_previous()
{
emit q_func()->findRequest(editFind->text(), findOptions() | QTextDocument::FindBackward);
}
QScriptDebuggerCodeFinderWidget::QScriptDebuggerCodeFinderWidget(QWidget *parent)
: QScriptDebuggerCodeFinderWidgetInterface(
*new QScriptDebuggerCodeFinderWidgetPrivate, parent, 0)
{
Q_D(QScriptDebuggerCodeFinderWidget);
QHBoxLayout *hboxLayout = new QHBoxLayout(this);
hboxLayout->setSpacing(6);
hboxLayout->setMargin(0);
d->toolClose = new QToolButton(this);
QPixmap pix;
pix.loadFromData(
scripttools_closetab_png, scripttools_closetab_png_len,
qt_images_format
);
d->toolClose->setIcon(QIcon(pix));
d->toolClose->setAutoRaise(true);
d->toolClose->setText(tr("Close"));
hboxLayout->addWidget(d->toolClose);
d->editFind = new QLineEdit(this);
d->editFind->setMinimumSize(QSize(150, 0));
connect(d->editFind, SIGNAL(textChanged(QString)),
this, SLOT(_q_updateButtons()));
connect(d->editFind, SIGNAL(returnPressed()),
this, SLOT(_q_next()));
hboxLayout->addWidget(d->editFind);
d->toolPrevious = new QToolButton(this);
d->toolPrevious->setAutoRaise(true);
d->toolPrevious->setText(tr("Previous"));
d->toolPrevious->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
d->toolPrevious->setIcon(QIcon::fromTheme("go-previous"));
hboxLayout->addWidget(d->toolPrevious);
d->toolNext = new QToolButton(this);
d->toolNext->setAutoRaise(true);
d->toolNext->setText(tr("Next"));
d->toolNext->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
d->toolNext->setIcon(QIcon::fromTheme("go-next"));
hboxLayout->addWidget(d->toolNext);
d->checkCase = new QCheckBox(tr("Case Sensitive"), this);
hboxLayout->addWidget(d->checkCase);
d->checkWholeWords = new QCheckBox(tr("Whole words"), this);
hboxLayout->addWidget(d->checkWholeWords);
d->labelWrapped = new QLabel(this);
d->labelWrapped->setMinimumSize(QSize(0, 20));
d->labelWrapped->setMaximumSize(QSize(115, 20));
d->labelWrapped->setTextFormat(Qt::RichText);
d->labelWrapped->setScaledContents(true);
d->labelWrapped->setAlignment(Qt::AlignLeft|Qt::AlignVCenter);
d->labelWrapped->setText(tr("Search wrapped"));
hboxLayout->addWidget(d->labelWrapped);
QSpacerItem *spacerItem = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
hboxLayout->addItem(spacerItem);
setMinimumWidth(minimumSizeHint().width());
d->labelWrapped->hide();
d->_q_updateButtons();
setFocusProxy(d->editFind);
QObject::connect(d->toolClose, SIGNAL(clicked()), this, SLOT(hide()));
QObject::connect(d->editFind, SIGNAL(textChanged(QString)),
this, SLOT(_q_onTextChanged(QString)));
QObject::connect(d->toolNext, SIGNAL(clicked()), this, SLOT(_q_next()));
QObject::connect(d->toolPrevious, SIGNAL(clicked()), this, SLOT(_q_previous()));
}
QScriptDebuggerCodeFinderWidget::~QScriptDebuggerCodeFinderWidget()
{
}
int QScriptDebuggerCodeFinderWidget::findOptions() const
{
Q_D(const QScriptDebuggerCodeFinderWidget);
return d->findOptions();
}
QString QScriptDebuggerCodeFinderWidget::text() const
{
Q_D(const QScriptDebuggerCodeFinderWidget);
return d->editFind->text();
}
void QScriptDebuggerCodeFinderWidget::setText(const QString &text)
{
Q_D(const QScriptDebuggerCodeFinderWidget);
d->editFind->setText(text);
}
void QScriptDebuggerCodeFinderWidget::setOK(bool ok)
{
Q_D(QScriptDebuggerCodeFinderWidget);
QPalette p = d->editFind->palette();
QColor c;
if (ok)
c = Qt::white;
else
c = QColor(255, 102, 102);
p.setColor(QPalette::Active, QPalette::Base, c);
d->editFind->setPalette(p);
if (!ok)
d->labelWrapped->hide();
}
void QScriptDebuggerCodeFinderWidget::setWrapped(bool wrapped)
{
Q_D(QScriptDebuggerCodeFinderWidget);
d->labelWrapped->setVisible(wrapped);
}
void QScriptDebuggerCodeFinderWidget::keyPressEvent(QKeyEvent *e)
{
if (e->key() == Qt::Key_Escape)
hide();
else
QScriptDebuggerCodeFinderWidgetInterface::keyPressEvent(e);
}
QT_END_NAMESPACE
#include "moc_qscriptdebuggercodefinderwidget_p.h"

View file

@ -1,72 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTDEBUGGERCODEFINDERWIDGET_P_H
#define QSCRIPTDEBUGGERCODEFINDERWIDGET_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include "qscriptdebuggercodefinderwidgetinterface_p.h"
QT_BEGIN_NAMESPACE
class QScriptDebuggerCodeFinderWidgetPrivate;
class Q_AUTOTEST_EXPORT QScriptDebuggerCodeFinderWidget:
public QScriptDebuggerCodeFinderWidgetInterface
{
Q_OBJECT
public:
QScriptDebuggerCodeFinderWidget(QWidget *parent = nullptr);
~QScriptDebuggerCodeFinderWidget();
int findOptions() const;
QString text() const;
void setText(const QString &text);
void setOK(bool ok);
void setWrapped(bool wrapped);
protected:
void keyPressEvent(QKeyEvent *e);
private:
Q_DECLARE_PRIVATE(QScriptDebuggerCodeFinderWidget)
Q_DISABLE_COPY(QScriptDebuggerCodeFinderWidget)
Q_PRIVATE_SLOT(d_func(), void _q_updateButtons())
Q_PRIVATE_SLOT(d_func(), void _q_onTextChanged(const QString &))
Q_PRIVATE_SLOT(d_func(), void _q_next())
Q_PRIVATE_SLOT(d_func(), void _q_previous())
};
QT_END_NAMESPACE
#endif

View file

@ -1,47 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qscriptdebuggercodefinderwidgetinterface_p.h"
#include "qscriptdebuggercodefinderwidgetinterface_p_p.h"
QT_BEGIN_NAMESPACE
QScriptDebuggerCodeFinderWidgetInterfacePrivate::QScriptDebuggerCodeFinderWidgetInterfacePrivate()
{
}
QScriptDebuggerCodeFinderWidgetInterfacePrivate::~QScriptDebuggerCodeFinderWidgetInterfacePrivate()
{
}
QScriptDebuggerCodeFinderWidgetInterface::~QScriptDebuggerCodeFinderWidgetInterface()
{
}
QScriptDebuggerCodeFinderWidgetInterface::QScriptDebuggerCodeFinderWidgetInterface(
QScriptDebuggerCodeFinderWidgetInterfacePrivate &dd,
QWidget *parent, Qt::WindowFlags flags)
: QWidget(dd, parent, flags)
{
}
QT_END_NAMESPACE
#include "moc_qscriptdebuggercodefinderwidgetinterface_p.h"

View file

@ -1,73 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTDEBUGGERCODEFINDERWIDGETINTERFACE_P_H
#define QSCRIPTDEBUGGERCODEFINDERWIDGETINTERFACE_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtGui/qwidget.h>
#include <QtGui/qtextdocument.h>
QT_BEGIN_NAMESPACE
class QScriptDebuggerCodeFinderWidgetInterfacePrivate;
class Q_AUTOTEST_EXPORT QScriptDebuggerCodeFinderWidgetInterface:
public QWidget
{
Q_OBJECT
public:
~QScriptDebuggerCodeFinderWidgetInterface();
virtual int findOptions() const = 0;
virtual QString text() const = 0;
virtual void setText(const QString &text) = 0;
virtual void setOK(bool ok) = 0;
virtual void setWrapped(bool wrapped) = 0;
Q_SIGNALS:
void findRequest(const QString &exp, int options);
protected:
QScriptDebuggerCodeFinderWidgetInterface(
QScriptDebuggerCodeFinderWidgetInterfacePrivate &dd,
QWidget *parent, Qt::WindowFlags flags);
private:
Q_DECLARE_PRIVATE(QScriptDebuggerCodeFinderWidgetInterface)
Q_DISABLE_COPY(QScriptDebuggerCodeFinderWidgetInterface)
};
QT_END_NAMESPACE
#endif

View file

@ -1,52 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTDEBUGGERCODEFINDERWIDGETINTERFACE_P_P_H
#define QSCRIPTDEBUGGERCODEFINDERWIDGETINTERFACE_P_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include "qwidget_p.h"
QT_BEGIN_NAMESPACE
class QScriptDebuggerCodeFinderWidgetInterface;
class QScriptDebuggerCodeFinderWidgetInterfacePrivate
: public QWidgetPrivate
{
Q_DECLARE_PUBLIC(QScriptDebuggerCodeFinderWidgetInterface)
public:
QScriptDebuggerCodeFinderWidgetInterfacePrivate();
~QScriptDebuggerCodeFinderWidgetInterfacePrivate();
};
QT_END_NAMESPACE
#endif

View file

@ -1,231 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qscriptdebuggercodeview_p.h"
#include "qscriptdebuggercodeviewinterface_p_p.h"
#include "qscripttoolscommon_p.h"
#include "qscriptedit_p.h"
#include <QtGui/qboxlayout.h>
#include <QtGui/qtextobject.h>
#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
class QScriptDebuggerCodeViewPrivate
: public QScriptDebuggerCodeViewInterfacePrivate
{
Q_DECLARE_PUBLIC(QScriptDebuggerCodeView)
public:
QScriptDebuggerCodeViewPrivate();
~QScriptDebuggerCodeViewPrivate();
QScriptEdit *editor;
};
QScriptDebuggerCodeViewPrivate::QScriptDebuggerCodeViewPrivate()
{
}
QScriptDebuggerCodeViewPrivate::~QScriptDebuggerCodeViewPrivate()
{
}
QScriptDebuggerCodeView::QScriptDebuggerCodeView(QWidget *parent)
: QScriptDebuggerCodeViewInterface(*new QScriptDebuggerCodeViewPrivate, parent, 0)
{
Q_D(QScriptDebuggerCodeView);
d->editor = new QScriptEdit();
d->editor->setReadOnly(true);
d->editor->setBackgroundVisible(false);
QObject::connect(d->editor, SIGNAL(breakpointToggleRequest(int,bool)),
this, SIGNAL(breakpointToggleRequest(int,bool)));
QObject::connect(d->editor, SIGNAL(breakpointEnableRequest(int,bool)),
this, SIGNAL(breakpointEnableRequest(int,bool)));
QVBoxLayout *vbox = new QVBoxLayout(this);
vbox->setMargin(0);
vbox->addWidget(d->editor);
}
QScriptDebuggerCodeView::~QScriptDebuggerCodeView()
{
}
QString QScriptDebuggerCodeView::text() const
{
Q_D(const QScriptDebuggerCodeView);
return d->editor->toPlainText();
}
void QScriptDebuggerCodeView::setText(const QString &text)
{
Q_D(QScriptDebuggerCodeView);
d->editor->setPlainText(text);
}
int QScriptDebuggerCodeView::cursorLineNumber() const
{
Q_D(const QScriptDebuggerCodeView);
return d->editor->currentLineNumber();
}
void QScriptDebuggerCodeView::gotoLine(int lineNumber)
{
Q_D(QScriptDebuggerCodeView);
d->editor->gotoLine(lineNumber);
}
int QScriptDebuggerCodeView::find(const QString &exp, int options)
{
Q_D(QScriptDebuggerCodeView);
QPlainTextEdit *ed = (QPlainTextEdit*)d->editor;
QTextCursor cursor = ed->textCursor();
if (options & 0x100) {
// start searching from the beginning of selection
if (cursor.hasSelection()) {
int len = cursor.selectedText().length();
cursor.clearSelection();
cursor.setPosition(cursor.position() - len);
ed->setTextCursor(cursor);
}
options &= ~0x100;
}
int ret = 0;
if (ed->find(exp, QTextDocument::FindFlags(options))) {
ret |= 0x1;
} else {
QTextCursor curse = cursor;
curse.movePosition(QTextCursor::Start);
ed->setTextCursor(curse);
if (ed->find(exp, QTextDocument::FindFlags(options)))
ret |= 0x1 | 0x2;
else
ed->setTextCursor(cursor);
}
return ret;
}
void QScriptDebuggerCodeView::setExecutionLineNumber(int lineNumber, bool error)
{
Q_D(QScriptDebuggerCodeView);
d->editor->setExecutionLineNumber(lineNumber, error);
}
void QScriptDebuggerCodeView::setExecutableLineNumbers(const QSet<int> &lineNumbers)
{
Q_D(QScriptDebuggerCodeView);
d->editor->setExecutableLineNumbers(lineNumbers);
}
int QScriptDebuggerCodeView::baseLineNumber() const
{
Q_D(const QScriptDebuggerCodeView);
return d->editor->baseLineNumber();
}
void QScriptDebuggerCodeView::setBaseLineNumber(int lineNumber)
{
Q_D(QScriptDebuggerCodeView);
d->editor->setBaseLineNumber(lineNumber);
}
void QScriptDebuggerCodeView::setBreakpoint(int lineNumber)
{
Q_D(QScriptDebuggerCodeView);
d->editor->setBreakpoint(lineNumber);
}
void QScriptDebuggerCodeView::deleteBreakpoint(int lineNumber)
{
Q_D(QScriptDebuggerCodeView);
d->editor->deleteBreakpoint(lineNumber);
}
void QScriptDebuggerCodeView::setBreakpointEnabled(int lineNumber, bool enable)
{
Q_D(QScriptDebuggerCodeView);
d->editor->setBreakpointEnabled(lineNumber, enable);
}
/*!
\reimp
*/
bool QScriptDebuggerCodeView::event(QEvent *e)
{
Q_D(QScriptDebuggerCodeView);
if (e->type() == QEvent::ToolTip) {
if (d->editor->executionLineNumber() == -1)
return false;
QHelpEvent *he = static_cast<QHelpEvent*>(e);
QPoint pt = he->pos();
pt.rx() -= d->editor->extraAreaWidth();
pt.ry() -= 8;
QTextCursor cursor = d->editor->cursorForPosition(pt);
QTextBlock block = cursor.block();
QString contents = block.text();
if (contents.isEmpty())
return false;
int linePosition = cursor.position() - block.position();
if (linePosition < 0)
linePosition = 0;
// ### generalize -- same as in completiontask
int pos = linePosition;
if ((pos > 0) && contents.at(pos-1).isNumber()) {
// tooltips for numbers is pointless
return false;
}
while ((pos > 0) && isIdentChar(contents.at(pos-1)))
--pos;
if ((pos > 0) && ((contents.at(pos-1) == QLatin1Char('\''))
|| (contents.at(pos-1) == QLatin1Char('\"')))) {
// ignore string literals
return false;
}
int pos2 = linePosition - 1;
while ((pos2+1 < contents.size()) && isIdentChar(contents.at(pos2+1)))
++pos2;
QString ident = contents.mid(pos, pos2 - pos + 1);
QStringList path;
path.append(ident);
while ((pos > 0) && (contents.at(pos-1) == QLatin1Char('.'))) {
--pos;
pos2 = pos;
while ((pos > 0) && isIdentChar(contents.at(pos-1)))
--pos;
path.prepend(contents.mid(pos, pos2 - pos));
}
if (!path.isEmpty()) {
int lineNumber = cursor.blockNumber() + d->editor->baseLineNumber();
emit toolTipRequest(he->globalPos(), lineNumber, path);
}
}
return false;
}
QT_END_NAMESPACE
#include "moc_qscriptdebuggercodeview_p.h"

View file

@ -1,76 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTDEBUGGERCODEVIEW_P_H
#define QSCRIPTDEBUGGERCODEVIEW_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include "qscriptdebuggercodeviewinterface_p.h"
QT_BEGIN_NAMESPACE
class QScriptDebuggerCodeViewPrivate;
class Q_AUTOTEST_EXPORT QScriptDebuggerCodeView:
public QScriptDebuggerCodeViewInterface
{
Q_OBJECT
public:
QScriptDebuggerCodeView(QWidget *parent = nullptr);
~QScriptDebuggerCodeView();
QString text() const;
void setText(const QString &text);
int cursorLineNumber() const;
void gotoLine(int lineNumber);
int find(const QString &exp, int options = 0);
void setExecutionLineNumber(int lineNumber, bool error);
void setExecutableLineNumbers(const QSet<int> &lineNumbers);
int baseLineNumber() const;
void setBaseLineNumber(int lineNumber);
void setBreakpoint(int lineNumber);
void deleteBreakpoint(int lineNumber);
void setBreakpointEnabled(int lineNumber, bool enable);
bool event(QEvent *e);
private:
Q_DECLARE_PRIVATE(QScriptDebuggerCodeView)
Q_DISABLE_COPY(QScriptDebuggerCodeView)
};
QT_END_NAMESPACE
#endif

View file

@ -1,47 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qscriptdebuggercodeviewinterface_p.h"
#include "qscriptdebuggercodeviewinterface_p_p.h"
QT_BEGIN_NAMESPACE
QScriptDebuggerCodeViewInterfacePrivate::QScriptDebuggerCodeViewInterfacePrivate()
{
}
QScriptDebuggerCodeViewInterfacePrivate::~QScriptDebuggerCodeViewInterfacePrivate()
{
}
QScriptDebuggerCodeViewInterface::~QScriptDebuggerCodeViewInterface()
{
}
QScriptDebuggerCodeViewInterface::QScriptDebuggerCodeViewInterface(
QScriptDebuggerCodeViewInterfacePrivate &dd,
QWidget *parent, Qt::WindowFlags flags)
: QWidget(dd, parent, flags)
{
}
QT_END_NAMESPACE
#include "moc_qscriptdebuggercodeviewinterface_p.h"

View file

@ -1,86 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTDEBUGGERCODEVIEWINTERFACE_P_H
#define QSCRIPTDEBUGGERCODEVIEWINTERFACE_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtGui/qwidget.h>
QT_BEGIN_NAMESPACE
class QPoint;
class QStringList;
class QScriptDebuggerCodeViewInterfacePrivate;
class Q_AUTOTEST_EXPORT QScriptDebuggerCodeViewInterface:
public QWidget
{
Q_OBJECT
public:
~QScriptDebuggerCodeViewInterface();
virtual QString text() const = 0;
virtual void setText(const QString &text) = 0;
virtual int cursorLineNumber() const = 0;
virtual void gotoLine(int lineNumber) = 0;
virtual int find(const QString &exp, int options = 0) = 0;
virtual void setExecutionLineNumber(int lineNumber, bool error) = 0;
virtual void setExecutableLineNumbers(const QSet<int> &lineNumbers) = 0;
virtual int baseLineNumber() const = 0;
virtual void setBaseLineNumber(int lineNumber) = 0;
virtual void setBreakpoint(int lineNumber) = 0;
virtual void deleteBreakpoint(int lineNumber) = 0;
virtual void setBreakpointEnabled(int lineNumber, bool enable) = 0;
Q_SIGNALS:
void breakpointToggleRequest(int lineNumber, bool on);
void breakpointEnableRequest(int lineNumber, bool enable);
void toolTipRequest(const QPoint &pos, int lineNumber, const QStringList &path);
protected:
QScriptDebuggerCodeViewInterface(
QScriptDebuggerCodeViewInterfacePrivate &dd,
QWidget *parent, Qt::WindowFlags flags);
private:
Q_DECLARE_PRIVATE(QScriptDebuggerCodeViewInterface)
Q_DISABLE_COPY(QScriptDebuggerCodeViewInterface)
};
QT_END_NAMESPACE
#endif

View file

@ -1,52 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTDEBUGGERCODEVIEWINTERFACE_P_P_H
#define QSCRIPTDEBUGGERCODEVIEWINTERFACE_P_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include "qwidget_p.h"
QT_BEGIN_NAMESPACE
class QScriptDebuggerCodeViewInterface;
class QScriptDebuggerCodeViewInterfacePrivate
: public QWidgetPrivate
{
Q_DECLARE_PUBLIC(QScriptDebuggerCodeViewInterface)
public:
QScriptDebuggerCodeViewInterfacePrivate();
~QScriptDebuggerCodeViewInterfacePrivate();
};
QT_END_NAMESPACE
#endif

View file

@ -1,285 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qscriptdebuggercodewidget_p.h"
#include "qscriptdebuggercodewidgetinterface_p_p.h"
#include "qscriptdebuggercodeview_p.h"
#include "qscriptdebuggerscriptsmodel_p.h"
#include "qscriptbreakpointsmodel_p.h"
#include "qscripttooltipproviderinterface_p.h"
#include <QtCore/qdebug.h>
#include <QtGui/qboxlayout.h>
#include <QtGui/qstackedwidget.h>
QT_BEGIN_NAMESPACE
class QScriptDebuggerCodeWidgetPrivate
: public QScriptDebuggerCodeWidgetInterfacePrivate
{
Q_DECLARE_PUBLIC(QScriptDebuggerCodeWidget)
public:
QScriptDebuggerCodeWidgetPrivate();
~QScriptDebuggerCodeWidgetPrivate();
qint64 scriptId(QScriptDebuggerCodeViewInterface *view) const;
// private slots
void _q_onBreakpointToggleRequest(int lineNumber, bool on);
void _q_onBreakpointEnableRequest(int lineNumber, bool enable);
void _q_onBreakpointsAboutToBeRemoved(const QModelIndex&, int, int);
void _q_onBreakpointsInserted(const QModelIndex&, int, int);
void _q_onBreakpointsDataChanged(const QModelIndex &, const QModelIndex &);
void _q_onScriptsChanged();
void _q_onToolTipRequest(const QPoint &pos, int lineNumber, const QStringList &path);
QScriptDebuggerScriptsModel *scriptsModel;
QStackedWidget *viewStack;
QHash<qint64, QScriptDebuggerCodeViewInterface*> viewHash;
QScriptBreakpointsModel *breakpointsModel;
QScriptToolTipProviderInterface *toolTipProvider;
};
QScriptDebuggerCodeWidgetPrivate::QScriptDebuggerCodeWidgetPrivate()
{
scriptsModel = 0;
breakpointsModel = 0;
toolTipProvider = 0;
}
QScriptDebuggerCodeWidgetPrivate::~QScriptDebuggerCodeWidgetPrivate()
{
}
qint64 QScriptDebuggerCodeWidgetPrivate::scriptId(QScriptDebuggerCodeViewInterface *view) const
{
if (!view)
return -1;
return viewHash.key(view);
}
void QScriptDebuggerCodeWidgetPrivate::_q_onBreakpointToggleRequest(int lineNumber, bool on)
{
QScriptDebuggerCodeViewInterface *view = qobject_cast<QScriptDebuggerCodeViewInterface*>(q_func()->sender());
qint64 sid = scriptId(view);
Q_ASSERT(sid != -1);
if (on) {
QScriptBreakpointData data(sid, lineNumber);
data.setFileName(scriptsModel->scriptData(sid).fileName());
breakpointsModel->setBreakpoint(data);
} else {
int bpid = breakpointsModel->resolveBreakpoint(sid, lineNumber);
if (bpid == -1)
bpid = breakpointsModel->resolveBreakpoint(scriptsModel->scriptData(sid).fileName(), lineNumber);
Q_ASSERT(bpid != -1);
breakpointsModel->deleteBreakpoint(bpid);
}
}
void QScriptDebuggerCodeWidgetPrivate::_q_onBreakpointEnableRequest(int lineNumber, bool enable)
{
QScriptDebuggerCodeViewInterface *view = qobject_cast<QScriptDebuggerCodeViewInterface*>(q_func()->sender());
qint64 sid = scriptId(view);
int bpid = breakpointsModel->resolveBreakpoint(sid, lineNumber);
if (bpid == -1)
bpid = breakpointsModel->resolveBreakpoint(scriptsModel->scriptData(sid).fileName(), lineNumber);
Q_ASSERT(bpid != -1);
QScriptBreakpointData data = breakpointsModel->breakpointData(bpid);
data.setEnabled(enable);
breakpointsModel->setBreakpointData(bpid, data);
}
void QScriptDebuggerCodeWidgetPrivate::_q_onBreakpointsAboutToBeRemoved(
const QModelIndex &, int first, int last)
{
for (int i = first; i <= last; ++i) {
QScriptBreakpointData data = breakpointsModel->breakpointDataAt(i);
qint64 scriptId = data.scriptId();
if (scriptId == -1) {
scriptId = scriptsModel->resolveScript(data.fileName());
if (scriptId == -1)
continue;
}
QScriptDebuggerCodeViewInterface *view = viewHash.value(scriptId);
if (!view)
continue;
view->deleteBreakpoint(data.lineNumber());
}
}
void QScriptDebuggerCodeWidgetPrivate::_q_onBreakpointsInserted(
const QModelIndex &, int first, int last)
{
for (int i = first; i <= last; ++i) {
QScriptBreakpointData data = breakpointsModel->breakpointDataAt(i);
qint64 scriptId = data.scriptId();
if (scriptId == -1) {
scriptId = scriptsModel->resolveScript(data.fileName());
if (scriptId == -1)
continue;
}
QScriptDebuggerCodeViewInterface *view = viewHash.value(scriptId);
if (!view)
continue;
view->setBreakpoint(data.lineNumber());
}
}
void QScriptDebuggerCodeWidgetPrivate::_q_onBreakpointsDataChanged(
const QModelIndex &tl, const QModelIndex &br)
{
for (int i = tl.row(); i <= br.row(); ++i) {
QScriptBreakpointData data = breakpointsModel->breakpointDataAt(i);
qint64 scriptId = data.scriptId();
if (scriptId == -1) {
scriptId = scriptsModel->resolveScript(data.fileName());
if (scriptId == -1)
continue;
}
QScriptDebuggerCodeViewInterface *view = viewHash.value(scriptId);
if (!view)
continue;
view->setBreakpointEnabled(data.lineNumber(), data.isEnabled());
}
}
void QScriptDebuggerCodeWidgetPrivate::_q_onScriptsChanged()
{
// kill editors for scripts that have been removed
QHash<qint64, QScriptDebuggerCodeViewInterface*>::iterator it;
for (it = viewHash.begin(); it != viewHash.end(); ) {
if (!scriptsModel->scriptData(it.key()).isValid()) {
it = viewHash.erase(it);
} else
++it;
}
}
void QScriptDebuggerCodeWidgetPrivate::_q_onToolTipRequest(
const QPoint &pos, int lineNumber, const QStringList &path)
{
toolTipProvider->showToolTip(pos, /*frameIndex=*/-1, lineNumber, path);
}
QScriptDebuggerCodeWidget::QScriptDebuggerCodeWidget(QWidget *parent)
: QScriptDebuggerCodeWidgetInterface(*new QScriptDebuggerCodeWidgetPrivate, parent, 0)
{
Q_D(QScriptDebuggerCodeWidget);
QVBoxLayout *vbox = new QVBoxLayout(this);
vbox->setMargin(0);
d->viewStack = new QStackedWidget();
vbox->addWidget(d->viewStack);
}
QScriptDebuggerCodeWidget::~QScriptDebuggerCodeWidget()
{
}
QScriptDebuggerScriptsModel *QScriptDebuggerCodeWidget::scriptsModel() const
{
Q_D(const QScriptDebuggerCodeWidget);
return d->scriptsModel;
}
void QScriptDebuggerCodeWidget::setScriptsModel(QScriptDebuggerScriptsModel *model)
{
Q_D(QScriptDebuggerCodeWidget);
d->scriptsModel = model;
QObject::connect(model, SIGNAL(layoutChanged()),
this, SLOT(_q_onScriptsChanged()));
}
qint64 QScriptDebuggerCodeWidget::currentScriptId() const
{
Q_D(const QScriptDebuggerCodeWidget);
return d->scriptId(currentView());
}
void QScriptDebuggerCodeWidget::setCurrentScript(qint64 scriptId)
{
Q_D(QScriptDebuggerCodeWidget);
if (scriptId == -1) {
// ### show "native script"
return;
}
QScriptDebuggerCodeViewInterface *view = d->viewHash.value(scriptId);
if (!view) {
Q_ASSERT(d->scriptsModel != 0);
QScriptScriptData data = d->scriptsModel->scriptData(scriptId);
if (!data.isValid())
return;
view = new QScriptDebuggerCodeView(); // ### use factory, so user can provide his own view
view->setBaseLineNumber(data.baseLineNumber());
view->setText(data.contents());
view->setExecutableLineNumbers(d->scriptsModel->executableLineNumbers(scriptId));
QObject::connect(view, SIGNAL(breakpointToggleRequest(int,bool)),
this, SLOT(_q_onBreakpointToggleRequest(int,bool)));
QObject::connect(view, SIGNAL(breakpointEnableRequest(int,bool)),
this, SLOT(_q_onBreakpointEnableRequest(int,bool)));
QObject::connect(view, SIGNAL(toolTipRequest(QPoint,int,QStringList)),
this, SLOT(_q_onToolTipRequest(QPoint,int,QStringList)));
d->viewStack->addWidget(view);
d->viewHash.insert(scriptId, view);
}
d->viewStack->setCurrentWidget(view);
}
void QScriptDebuggerCodeWidget::invalidateExecutionLineNumbers()
{
Q_D(QScriptDebuggerCodeWidget);
QHash<qint64, QScriptDebuggerCodeViewInterface*>::const_iterator it;
for (it = d->viewHash.constBegin(); it != d->viewHash.constEnd(); ++it)
it.value()->setExecutionLineNumber(-1, /*error=*/false);
}
QScriptBreakpointsModel *QScriptDebuggerCodeWidget::breakpointsModel() const
{
Q_D(const QScriptDebuggerCodeWidget);
return d->breakpointsModel;
}
void QScriptDebuggerCodeWidget::setBreakpointsModel(QScriptBreakpointsModel *model)
{
Q_D(QScriptDebuggerCodeWidget);
d->breakpointsModel = model;
QObject::connect(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
this, SLOT(_q_onBreakpointsAboutToBeRemoved(QModelIndex,int,int)));
QObject::connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)),
this, SLOT(_q_onBreakpointsInserted(QModelIndex,int,int)));
QObject::connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
this, SLOT(_q_onBreakpointsDataChanged(QModelIndex,QModelIndex)));
}
void QScriptDebuggerCodeWidget::setToolTipProvider(QScriptToolTipProviderInterface *toolTipProvider)
{
Q_D(QScriptDebuggerCodeWidget);
d->toolTipProvider = toolTipProvider;
}
QScriptDebuggerCodeViewInterface *QScriptDebuggerCodeWidget::currentView() const
{
Q_D(const QScriptDebuggerCodeWidget);
return qobject_cast<QScriptDebuggerCodeViewInterface*>(d->viewStack->currentWidget());
}
QT_END_NAMESPACE
#include "moc_qscriptdebuggercodewidget_p.h"

View file

@ -1,79 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTDEBUGGERCODEWIDGET_P_H
#define QSCRIPTDEBUGGERCODEWIDGET_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include "qscriptdebuggercodewidgetinterface_p.h"
QT_BEGIN_NAMESPACE
class QScriptDebuggerCodeWidgetPrivate;
class Q_AUTOTEST_EXPORT QScriptDebuggerCodeWidget:
public QScriptDebuggerCodeWidgetInterface
{
Q_OBJECT
public:
QScriptDebuggerCodeWidget(QWidget *parent = nullptr);
~QScriptDebuggerCodeWidget();
QScriptDebuggerScriptsModel *scriptsModel() const;
void setScriptsModel(QScriptDebuggerScriptsModel *model);
void setToolTipProvider(QScriptToolTipProviderInterface *toolTipProvider);
qint64 currentScriptId() const;
void setCurrentScript(qint64 scriptId);
void invalidateExecutionLineNumbers();
QScriptBreakpointsModel *breakpointsModel() const;
void setBreakpointsModel(QScriptBreakpointsModel *model);
QScriptDebuggerCodeViewInterface *currentView() const;
private:
Q_DECLARE_PRIVATE(QScriptDebuggerCodeWidget)
Q_DISABLE_COPY(QScriptDebuggerCodeWidget)
Q_PRIVATE_SLOT(d_func(), void _q_onBreakpointToggleRequest(int,bool))
Q_PRIVATE_SLOT(d_func(), void _q_onBreakpointEnableRequest(int,bool))
Q_PRIVATE_SLOT(d_func(), void _q_onBreakpointsAboutToBeRemoved(const QModelIndex &,int,int))
Q_PRIVATE_SLOT(d_func(), void _q_onBreakpointsInserted(const QModelIndex &,int,int))
Q_PRIVATE_SLOT(d_func(), void _q_onBreakpointsDataChanged(const QModelIndex &, const QModelIndex &))
Q_PRIVATE_SLOT(d_func(), void _q_onScriptsChanged())
Q_PRIVATE_SLOT(d_func(), void _q_onToolTipRequest(const QPoint &, int, const QStringList &))
};
QT_END_NAMESPACE
#endif

View file

@ -1,47 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qscriptdebuggercodewidgetinterface_p.h"
#include "qscriptdebuggercodewidgetinterface_p_p.h"
QT_BEGIN_NAMESPACE
QScriptDebuggerCodeWidgetInterfacePrivate::QScriptDebuggerCodeWidgetInterfacePrivate()
{
}
QScriptDebuggerCodeWidgetInterfacePrivate::~QScriptDebuggerCodeWidgetInterfacePrivate()
{
}
QScriptDebuggerCodeWidgetInterface::~QScriptDebuggerCodeWidgetInterface()
{
}
QScriptDebuggerCodeWidgetInterface::QScriptDebuggerCodeWidgetInterface(
QScriptDebuggerCodeWidgetInterfacePrivate &dd,
QWidget *parent, Qt::WindowFlags flags)
: QWidget(dd, parent, flags)
{
}
QT_END_NAMESPACE
#include "moc_qscriptdebuggercodewidgetinterface_p.h"

View file

@ -1,81 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTDEBUGGERCODEWIDGETINTERFACE_P_H
#define QSCRIPTDEBUGGERCODEWIDGETINTERFACE_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtGui/qwidget.h>
QT_BEGIN_NAMESPACE
class QScriptDebuggerScriptsModel;
class QScriptBreakpointsModel;
class QScriptToolTipProviderInterface;
class QScriptDebuggerCodeViewInterface;
class QScriptDebuggerCodeWidgetInterfacePrivate;
class Q_AUTOTEST_EXPORT QScriptDebuggerCodeWidgetInterface:
public QWidget
{
Q_OBJECT
public:
~QScriptDebuggerCodeWidgetInterface();
virtual QScriptDebuggerScriptsModel *scriptsModel() const = 0;
virtual void setScriptsModel(QScriptDebuggerScriptsModel *model) = 0;
virtual QScriptBreakpointsModel *breakpointsModel() const = 0;
virtual void setBreakpointsModel(QScriptBreakpointsModel *model) = 0;
virtual void setToolTipProvider(QScriptToolTipProviderInterface *toolTipProvider) = 0;
virtual qint64 currentScriptId() const = 0;
virtual void setCurrentScript(qint64 scriptId) = 0;
virtual void invalidateExecutionLineNumbers() = 0;
virtual QScriptDebuggerCodeViewInterface *currentView() const = 0;
protected:
QScriptDebuggerCodeWidgetInterface(
QScriptDebuggerCodeWidgetInterfacePrivate &dd,
QWidget *parent, Qt::WindowFlags flags);
private:
Q_DECLARE_PRIVATE(QScriptDebuggerCodeWidgetInterface)
Q_DISABLE_COPY(QScriptDebuggerCodeWidgetInterface)
};
QT_END_NAMESPACE
#endif

View file

@ -1,52 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTDEBUGGERCODEWIDGETINTERFACE_P_P_H
#define QSCRIPTDEBUGGERCODEWIDGETINTERFACE_P_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include "qwidget_p.h"
QT_BEGIN_NAMESPACE
class QScriptDebuggerCodeWidgetInterface;
class QScriptDebuggerCodeWidgetInterfacePrivate
: public QWidgetPrivate
{
Q_DECLARE_PUBLIC(QScriptDebuggerCodeWidgetInterface)
public:
QScriptDebuggerCodeWidgetInterfacePrivate();
~QScriptDebuggerCodeWidgetInterfacePrivate();
};
QT_END_NAMESPACE
#endif

View file

@ -1,687 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qscriptdebuggercommand_p.h"
#include "qscriptbreakpointdata_p.h"
#include "qscriptdebuggervalue_p.h"
#include "qscripttoolscommon_p.h"
#include <QtCore/qhash.h>
#include <QtCore/qdatastream.h>
#include <QtCore/qstringlist.h>
QT_BEGIN_NAMESPACE
/*!
\since 4.5
\class QScriptDebuggerCommand
\internal
\brief The QScriptDebuggerCommand class represents a command issued to a QScriptDebuggerFrontend.
A debugger command is described by a command type and zero or more
attributes. Such commands are generated internally by the
QScriptDebuggerFrontend class (through the scheduleXXX commands). A
command is typically passed on to a QScriptDebuggerCommandExecutor
that applies the command to a QScriptDebuggerBackend.
*/
class QScriptDebuggerCommandPrivate
{
public:
QScriptDebuggerCommandPrivate();
~QScriptDebuggerCommandPrivate();
QScriptDebuggerCommand::Type type;
QHash<QScriptDebuggerCommand::Attribute, QVariant> attributes;
};
QScriptDebuggerCommandPrivate::QScriptDebuggerCommandPrivate()
: type(QScriptDebuggerCommand::None)
{
}
QScriptDebuggerCommandPrivate::~QScriptDebuggerCommandPrivate()
{
}
/*!
Constructs a QScriptDebuggerCommand of type None.
*/
QScriptDebuggerCommand::QScriptDebuggerCommand()
: d_ptr(new QScriptDebuggerCommandPrivate)
{
d_ptr->type = None;
}
/*!
Constructs a QScriptDebuggerCommand of the given \a type, with no
attributes defined.
*/
QScriptDebuggerCommand::QScriptDebuggerCommand(Type type)
: d_ptr(new QScriptDebuggerCommandPrivate)
{
d_ptr->type = type;
}
/*!
Constructs a QScriptDebuggerCommand that is a copy of the \a other
command.
*/
QScriptDebuggerCommand::QScriptDebuggerCommand(const QScriptDebuggerCommand &other)
: d_ptr(new QScriptDebuggerCommandPrivate)
{
*d_ptr = *other.d_ptr;
}
/*!
Destroys this QScriptDebuggerCommand.
*/
QScriptDebuggerCommand::~QScriptDebuggerCommand()
{
}
/*!
Assigns the \a other value to this QScriptDebuggerCommand.
*/
QScriptDebuggerCommand &QScriptDebuggerCommand::operator=(const QScriptDebuggerCommand &other)
{
*d_ptr = *other.d_ptr;
return *this;
}
/*!
Returns the type of this command.
*/
QScriptDebuggerCommand::Type QScriptDebuggerCommand::type() const
{
Q_D(const QScriptDebuggerCommand);
return d->type;
}
/*!
Returns the value of the given \a attribute, or \a defaultValue
if the attribute is not defined.
*/
QVariant QScriptDebuggerCommand::attribute(Attribute attribute,
const QVariant &defaultValue) const
{
Q_D(const QScriptDebuggerCommand);
return d->attributes.value(attribute, defaultValue);
}
/*!
Sets the \a value of the given \a attribute.
*/
void QScriptDebuggerCommand::setAttribute(Attribute attribute,
const QVariant &value)
{
Q_D(QScriptDebuggerCommand);
if (!value.isValid())
d->attributes.remove(attribute);
else
d->attributes[attribute] = value;
}
QHash<QScriptDebuggerCommand::Attribute, QVariant> QScriptDebuggerCommand::attributes() const
{
Q_D(const QScriptDebuggerCommand);
return d->attributes;
}
/*!
Returns the FileName attribute of this command converted to a string.
This function is provided for convenience.
\sa attribute()
*/
QString QScriptDebuggerCommand::fileName() const
{
Q_D(const QScriptDebuggerCommand);
return d->attributes.value(FileName).toString();
}
void QScriptDebuggerCommand::setFileName(const QString &fileName)
{
Q_D(QScriptDebuggerCommand);
d->attributes[FileName] = fileName;
}
/*!
Returns the LineNumber attribute of this command converted to an int.
This function is provided for convenience.
\sa attribute()
*/
int QScriptDebuggerCommand::lineNumber() const
{
Q_D(const QScriptDebuggerCommand);
return d->attributes.value(LineNumber, -1).toInt();
}
void QScriptDebuggerCommand::setLineNumber(int lineNumber)
{
Q_D(QScriptDebuggerCommand);
d->attributes[LineNumber] = lineNumber;
}
/*!
Returns the ScriptID attribute of this command converted to a qint64.
This function is provided for convenience.
\sa attribute()
*/
qint64 QScriptDebuggerCommand::scriptId() const
{
Q_D(const QScriptDebuggerCommand);
return d->attributes.value(ScriptID, -1).toLongLong();
}
void QScriptDebuggerCommand::setScriptId(qint64 id)
{
Q_D(QScriptDebuggerCommand);
d->attributes[ScriptID] = id;
}
QString QScriptDebuggerCommand::program() const
{
Q_D(const QScriptDebuggerCommand);
return d->attributes.value(Program).toString();
}
void QScriptDebuggerCommand::setProgram(const QString &program)
{
Q_D(QScriptDebuggerCommand);
d->attributes[Program] = program;
}
int QScriptDebuggerCommand::breakpointId() const
{
Q_D(const QScriptDebuggerCommand);
return d->attributes.value(BreakpointID, -1).toInt();
}
void QScriptDebuggerCommand::setBreakpointId(int id)
{
Q_D(QScriptDebuggerCommand);
d->attributes[BreakpointID] = id;
}
QScriptBreakpointData QScriptDebuggerCommand::breakpointData() const
{
Q_D(const QScriptDebuggerCommand);
return qvariant_cast<QScriptBreakpointData>(d->attributes.value(BreakpointData));
}
void QScriptDebuggerCommand::setBreakpointData(const QScriptBreakpointData &data)
{
Q_D(QScriptDebuggerCommand);
d->attributes[BreakpointData] = QVariant::fromValue(data);
}
QScriptDebuggerValue QScriptDebuggerCommand::scriptValue() const
{
Q_D(const QScriptDebuggerCommand);
return qvariant_cast<QScriptDebuggerValue>(d->attributes.value(ScriptValue));
}
void QScriptDebuggerCommand::setScriptValue(const QScriptDebuggerValue &value)
{
Q_D(QScriptDebuggerCommand);
d->attributes[ScriptValue] = QVariant::fromValue(value);
}
int QScriptDebuggerCommand::contextIndex() const
{
Q_D(const QScriptDebuggerCommand);
return d->attributes.value(ContextIndex, -1).toInt();
}
void QScriptDebuggerCommand::setContextIndex(int index)
{
Q_D(QScriptDebuggerCommand);
d->attributes[ContextIndex] = index;
}
int QScriptDebuggerCommand::iteratorId() const
{
Q_D(const QScriptDebuggerCommand);
return d->attributes.value(IteratorID, -1).toInt();
}
void QScriptDebuggerCommand::setIteratorId(int id)
{
Q_D(QScriptDebuggerCommand);
d->attributes[IteratorID] = id;
}
QString QScriptDebuggerCommand::name() const
{
Q_D(const QScriptDebuggerCommand);
return d->attributes.value(Name).toString();
}
void QScriptDebuggerCommand::setName(const QString &name)
{
Q_D(QScriptDebuggerCommand);
d->attributes[Name] = name;
}
QScriptDebuggerValue QScriptDebuggerCommand::subordinateScriptValue() const
{
Q_D(const QScriptDebuggerCommand);
return qvariant_cast<QScriptDebuggerValue>(d->attributes.value(SubordinateScriptValue));
}
void QScriptDebuggerCommand::setSubordinateScriptValue(const QScriptDebuggerValue &value)
{
Q_D(QScriptDebuggerCommand);
d->attributes[SubordinateScriptValue] = QVariant::fromValue(value);
}
int QScriptDebuggerCommand::snapshotId() const
{
Q_D(const QScriptDebuggerCommand);
return d->attributes.value(SnapshotID, -1).toInt();
}
void QScriptDebuggerCommand::setSnapshotId(int id)
{
Q_D(QScriptDebuggerCommand);
d->attributes[SnapshotID] = id;
}
/*!
Returns true if this QScriptDebuggerCommand is equal to the \a other
command, otherwise returns false.
*/
bool QScriptDebuggerCommand::operator==(const QScriptDebuggerCommand &other) const
{
Q_D(const QScriptDebuggerCommand);
const QScriptDebuggerCommandPrivate *od = other.d_func();
if (d == od)
return true;
if (!d || !od)
return false;
return ((d->type == od->type)
&& (d->attributes == od->attributes));
}
/*!
Returns true if this QScriptDebuggerCommand is not equal to the \a
other command, otherwise returns false.
*/
bool QScriptDebuggerCommand::operator!=(const QScriptDebuggerCommand &other) const
{
return !(*this == other);
}
QScriptDebuggerCommand QScriptDebuggerCommand::interruptCommand()
{
QScriptDebuggerCommand cmd(Interrupt);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::continueCommand()
{
QScriptDebuggerCommand cmd(Continue);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::stepIntoCommand(int count)
{
QScriptDebuggerCommand cmd(StepInto);
cmd.setAttribute(StepCount, count);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::stepOverCommand(int count)
{
QScriptDebuggerCommand cmd(StepOver);
cmd.setAttribute(StepCount, count);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::stepOutCommand()
{
QScriptDebuggerCommand cmd(StepOut);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::runToLocationCommand(const QString &fileName, int lineNumber)
{
QScriptDebuggerCommand cmd(RunToLocation);
cmd.setFileName(fileName);
cmd.setLineNumber(lineNumber);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::runToLocationCommand(qint64 scriptId, int lineNumber)
{
QScriptDebuggerCommand cmd(RunToLocationByID);
cmd.setScriptId(scriptId);
cmd.setLineNumber(lineNumber);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::forceReturnCommand(int contextIndex, const QScriptDebuggerValue &value)
{
QScriptDebuggerCommand cmd(ForceReturn);
cmd.setContextIndex(contextIndex);
cmd.setScriptValue(value);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::resumeCommand()
{
QScriptDebuggerCommand cmd(Resume);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::setBreakpointCommand(const QString &fileName, int lineNumber)
{
QScriptDebuggerCommand cmd(SetBreakpoint);
cmd.setBreakpointData(QScriptBreakpointData(fileName, lineNumber));
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::setBreakpointCommand(const QScriptBreakpointData &data)
{
QScriptDebuggerCommand cmd(SetBreakpoint);
cmd.setBreakpointData(data);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::deleteBreakpointCommand(int id)
{
QScriptDebuggerCommand cmd(DeleteBreakpoint);
cmd.setBreakpointId(id);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::deleteAllBreakpointsCommand()
{
QScriptDebuggerCommand cmd(DeleteAllBreakpoints);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::getBreakpointsCommand()
{
QScriptDebuggerCommand cmd(GetBreakpoints);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::getBreakpointDataCommand(int id)
{
QScriptDebuggerCommand cmd(GetBreakpointData);
cmd.setBreakpointId(id);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::setBreakpointDataCommand(int id, const QScriptBreakpointData &data)
{
QScriptDebuggerCommand cmd(SetBreakpointData);
cmd.setBreakpointId(id);
cmd.setBreakpointData(data);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::getScriptsCommand()
{
QScriptDebuggerCommand cmd(GetScripts);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::getScriptDataCommand(qint64 id)
{
QScriptDebuggerCommand cmd(GetScriptData);
cmd.setScriptId(id);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::scriptsCheckpointCommand()
{
QScriptDebuggerCommand cmd(ScriptsCheckpoint);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::getScriptsDeltaCommand()
{
QScriptDebuggerCommand cmd(GetScriptsDelta);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::resolveScriptCommand(const QString &fileName)
{
QScriptDebuggerCommand cmd(ResolveScript);
cmd.setFileName(fileName);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::getBacktraceCommand()
{
QScriptDebuggerCommand cmd(GetBacktrace);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::getContextCountCommand()
{
QScriptDebuggerCommand cmd(GetContextCount);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::getContextStateCommand(int contextIndex)
{
QScriptDebuggerCommand cmd(GetContextState);
cmd.setContextIndex(contextIndex);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::getContextInfoCommand(int contextIndex)
{
QScriptDebuggerCommand cmd(GetContextInfo);
cmd.setContextIndex(contextIndex);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::getContextIdCommand(int contextIndex)
{
QScriptDebuggerCommand cmd(GetContextID);
cmd.setContextIndex(contextIndex);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::getThisObjectCommand(int contextIndex)
{
QScriptDebuggerCommand cmd(GetThisObject);
cmd.setContextIndex(contextIndex);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::getActivationObjectCommand(int contextIndex)
{
QScriptDebuggerCommand cmd(GetActivationObject);
cmd.setContextIndex(contextIndex);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::getScopeChainCommand(int contextIndex)
{
QScriptDebuggerCommand cmd(GetScopeChain);
cmd.setContextIndex(contextIndex);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::contextsCheckpoint()
{
QScriptDebuggerCommand cmd(ContextsCheckpoint);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::getPropertyExpressionValue(
int contextIndex, int lineNumber, const QStringList &path)
{
QScriptDebuggerCommand cmd(GetPropertyExpressionValue);
cmd.setContextIndex(contextIndex);
cmd.setLineNumber(lineNumber);
cmd.setAttribute(UserAttribute, path);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::getCompletions(
int contextIndex, const QStringList &path)
{
QScriptDebuggerCommand cmd(GetCompletions);
cmd.setContextIndex(contextIndex);
cmd.setAttribute(UserAttribute, path);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::newScriptObjectSnapshotCommand()
{
QScriptDebuggerCommand cmd(NewScriptObjectSnapshot);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::scriptObjectSnapshotCaptureCommand(int id, const QScriptDebuggerValue &object)
{
Q_ASSERT(object.type() == QScriptDebuggerValue::ObjectValue);
QScriptDebuggerCommand cmd(ScriptObjectSnapshotCapture);
cmd.setSnapshotId(id);
cmd.setScriptValue(object);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::deleteScriptObjectSnapshotCommand(int id)
{
QScriptDebuggerCommand cmd(DeleteScriptObjectSnapshot);
cmd.setSnapshotId(id);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::newScriptValueIteratorCommand(const QScriptDebuggerValue &object)
{
QScriptDebuggerCommand cmd(NewScriptValueIterator);
Q_ASSERT(object.type() == QScriptDebuggerValue::ObjectValue);
cmd.setScriptValue(object);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::getPropertiesByIteratorCommand(int id, int count)
{
Q_UNUSED(count);
QScriptDebuggerCommand cmd(GetPropertiesByIterator);
cmd.setIteratorId(id);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::deleteScriptValueIteratorCommand(int id)
{
QScriptDebuggerCommand cmd(DeleteScriptValueIterator);
cmd.setIteratorId(id);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::evaluateCommand(
int contextIndex, const QString &program, const QString &fileName, int lineNumber)
{
QScriptDebuggerCommand cmd(Evaluate);
cmd.setContextIndex(contextIndex);
cmd.setProgram(program);
cmd.setFileName(fileName);
cmd.setLineNumber(lineNumber);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::scriptValueToStringCommand(const QScriptDebuggerValue &value)
{
QScriptDebuggerCommand cmd(ScriptValueToString);
cmd.setScriptValue(value);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::setScriptValuePropertyCommand(
const QScriptDebuggerValue &object, const QString &name,
const QScriptDebuggerValue &value)
{
QScriptDebuggerCommand cmd(SetScriptValueProperty);
cmd.setScriptValue(object);
cmd.setName(name);
cmd.setSubordinateScriptValue(value);
return cmd;
}
QScriptDebuggerCommand QScriptDebuggerCommand::clearExceptionsCommand()
{
QScriptDebuggerCommand cmd(ClearExceptions);
return cmd;
}
/*!
\fn QDataStream &operator<<(QDataStream &stream, const QScriptDebuggerCommand &command)
\relates QScriptDebuggerCommand
Writes the given \a command to the specified \a stream.
*/
QDataStream &operator<<(QDataStream &out, const QScriptDebuggerCommand &command)
{
const QScriptDebuggerCommandPrivate *d = command.d_ptr.data();
out << (quint32)d->type;
out << (qint32)d->attributes.size();
QHash<QScriptDebuggerCommand::Attribute, QVariant>::const_iterator it;
for (it = d->attributes.constBegin(); it != d->attributes.constEnd(); ++it) {
out << (quint32)it.key();
out << it.value();
}
return out;
}
/*!
\fn QDataStream &operator>>(QDataStream &stream, QScriptDebuggerCommand &command)
\relates QScriptDebuggerCommand
Reads a QScriptDebuggerCommand from the specified \a stream into the
given \a command.
*/
QDataStream &operator>>(QDataStream &in, QScriptDebuggerCommand &command)
{
QScriptDebuggerCommandPrivate *d = command.d_ptr.data();
quint32 type;
in >> type;
d->type = QScriptDebuggerCommand::Type(type);
qint32 attribCount;
in >> attribCount;
QHash<QScriptDebuggerCommand::Attribute, QVariant> attribs;
for (qint32 i = 0; i < attribCount; ++i) {
quint32 key;
in >> key;
QVariant value;
in >> value;
attribs[QScriptDebuggerCommand::Attribute(key)] = value;
}
d->attributes = attribs;
return in;
}
QT_END_NAMESPACE

View file

@ -1,248 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTDEBUGGERCOMMAND_P_H
#define QSCRIPTDEBUGGERCOMMAND_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtCore/qobjectdefs.h>
#include <QtCore/qscopedpointer.h>
#include <QtCore/qhash.h>
#include <QtCore/qvariant.h>
QT_BEGIN_NAMESPACE
class QDataStream;
class QScriptBreakpointData;
class QScriptDebuggerValue;
class QScriptDebuggerCommandPrivate;
class Q_AUTOTEST_EXPORT QScriptDebuggerCommand
{
public:
friend Q_AUTOTEST_EXPORT QDataStream &operator<<(QDataStream &, const QScriptDebuggerCommand &);
friend Q_AUTOTEST_EXPORT QDataStream &operator>>(QDataStream &, QScriptDebuggerCommand &);
enum Type {
None,
Interrupt,
Continue,
StepInto,
StepOver,
StepOut,
RunToLocation,
RunToLocationByID,
ForceReturn,
Resume,
SetBreakpoint,
DeleteBreakpoint,
DeleteAllBreakpoints,
GetBreakpoints,
GetBreakpointData,
SetBreakpointData,
GetScripts,
GetScriptData,
ScriptsCheckpoint,
GetScriptsDelta,
ResolveScript,
GetBacktrace,
GetContextCount,
GetContextInfo,
GetContextState,
GetContextID,
GetThisObject,
GetActivationObject,
GetScopeChain,
ContextsCheckpoint,
GetPropertyExpressionValue,
GetCompletions,
NewScriptObjectSnapshot,
ScriptObjectSnapshotCapture,
DeleteScriptObjectSnapshot,
NewScriptValueIterator,
GetPropertiesByIterator,
DeleteScriptValueIterator,
Evaluate,
SetScriptValueProperty,
ScriptValueToString,
ClearExceptions,
UserCommand = 1000,
MaxUserCommand = 32767
};
enum Attribute {
ScriptID,
FileName,
LineNumber,
Program,
BreakpointID,
BreakpointData,
ContextIndex,
ScriptValue,
StepCount,
IteratorID,
Name,
SubordinateScriptValue,
SnapshotID,
UserAttribute = 1000,
MaxUserAttribute = 32767
};
QScriptDebuggerCommand();
QScriptDebuggerCommand(Type type);
QScriptDebuggerCommand(const QScriptDebuggerCommand &other);
~QScriptDebuggerCommand();
Type type() const;
QVariant attribute(Attribute attribute, const QVariant &defaultValue = QVariant()) const;
void setAttribute(Attribute attribute, const QVariant &value);
QHash<Attribute, QVariant> attributes() const;
QString fileName() const;
void setFileName(const QString &fileName);
int lineNumber() const;
void setLineNumber(int lineNumber);
qint64 scriptId() const;
void setScriptId(qint64 id);
QString program() const;
void setProgram(const QString &program);
int breakpointId() const;
void setBreakpointId(int id);
QScriptBreakpointData breakpointData() const;
void setBreakpointData(const QScriptBreakpointData &data);
QScriptDebuggerValue scriptValue() const;
void setScriptValue(const QScriptDebuggerValue &value);
int contextIndex() const;
void setContextIndex(int index);
int iteratorId() const;
void setIteratorId(int id);
QString name() const;
void setName(const QString &name);
QScriptDebuggerValue subordinateScriptValue() const;
void setSubordinateScriptValue(const QScriptDebuggerValue &value);
int snapshotId() const;
void setSnapshotId(int id);
QScriptDebuggerCommand &operator=(const QScriptDebuggerCommand &other);
bool operator==(const QScriptDebuggerCommand &other) const;
bool operator!=(const QScriptDebuggerCommand &other) const;
static QScriptDebuggerCommand interruptCommand();
static QScriptDebuggerCommand continueCommand();
static QScriptDebuggerCommand stepIntoCommand(int count = 1);
static QScriptDebuggerCommand stepOverCommand(int count = 1);
static QScriptDebuggerCommand stepOutCommand();
static QScriptDebuggerCommand runToLocationCommand(const QString &fileName, int lineNumber);
static QScriptDebuggerCommand runToLocationCommand(qint64 scriptId, int lineNumber);
static QScriptDebuggerCommand forceReturnCommand(int contextIndex, const QScriptDebuggerValue &value);
static QScriptDebuggerCommand resumeCommand();
static QScriptDebuggerCommand setBreakpointCommand(const QString &fileName, int lineNumber);
static QScriptDebuggerCommand setBreakpointCommand(const QScriptBreakpointData &data);
static QScriptDebuggerCommand deleteBreakpointCommand(int id);
static QScriptDebuggerCommand deleteAllBreakpointsCommand();
static QScriptDebuggerCommand getBreakpointsCommand();
static QScriptDebuggerCommand getBreakpointDataCommand(int id);
static QScriptDebuggerCommand setBreakpointDataCommand(int id, const QScriptBreakpointData &data);
static QScriptDebuggerCommand getScriptsCommand();
static QScriptDebuggerCommand getScriptDataCommand(qint64 id);
static QScriptDebuggerCommand scriptsCheckpointCommand();
static QScriptDebuggerCommand getScriptsDeltaCommand();
static QScriptDebuggerCommand resolveScriptCommand(const QString &fileName);
static QScriptDebuggerCommand getBacktraceCommand();
static QScriptDebuggerCommand getContextCountCommand();
static QScriptDebuggerCommand getContextStateCommand(int contextIndex);
static QScriptDebuggerCommand getContextInfoCommand(int contextIndex);
static QScriptDebuggerCommand getContextIdCommand(int contextIndex);
static QScriptDebuggerCommand getThisObjectCommand(int contextIndex);
static QScriptDebuggerCommand getActivationObjectCommand(int contextIndex);
static QScriptDebuggerCommand getScopeChainCommand(int contextIndex);
static QScriptDebuggerCommand contextsCheckpoint();
static QScriptDebuggerCommand getPropertyExpressionValue(int contextIndex, int lineNumber,
const QStringList &path);
static QScriptDebuggerCommand getCompletions(int contextIndex, const QStringList &path);
static QScriptDebuggerCommand newScriptObjectSnapshotCommand();
static QScriptDebuggerCommand scriptObjectSnapshotCaptureCommand(int id, const QScriptDebuggerValue &object);
static QScriptDebuggerCommand deleteScriptObjectSnapshotCommand(int id);
static QScriptDebuggerCommand newScriptValueIteratorCommand(const QScriptDebuggerValue &object);
static QScriptDebuggerCommand getPropertiesByIteratorCommand(int id, int count);
static QScriptDebuggerCommand deleteScriptValueIteratorCommand(int id);
static QScriptDebuggerCommand evaluateCommand(int contextIndex, const QString &program,
const QString &fileName = QString(),
int lineNumber = 1);
static QScriptDebuggerCommand setScriptValuePropertyCommand(const QScriptDebuggerValue &object,
const QString &name,
const QScriptDebuggerValue &value);
static QScriptDebuggerCommand scriptValueToStringCommand(const QScriptDebuggerValue &value);
static QScriptDebuggerCommand clearExceptionsCommand();
private:
QScopedPointer<QScriptDebuggerCommandPrivate> d_ptr;
Q_DECLARE_PRIVATE(QScriptDebuggerCommand)
};
Q_AUTOTEST_EXPORT QDataStream &operator<<(QDataStream &, const QScriptDebuggerCommand &);
Q_AUTOTEST_EXPORT QDataStream &operator>>(QDataStream &, QScriptDebuggerCommand &);
QT_END_NAMESPACE
#endif

View file

@ -1,492 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qscriptdebuggercommandexecutor_p.h"
#include "qscriptdebuggerbackend_p.h"
#include "qscriptdebuggercommand_p.h"
#include "qscriptdebuggerresponse_p.h"
#include "qscriptdebuggervalue_p.h"
#include "qscriptdebuggervalueproperty_p.h"
#include "qscriptbreakpointdata_p.h"
#include "qscriptobjectsnapshot_p.h"
#include "qscriptdebuggerobjectsnapshotdelta_p.h"
#include "qscripttoolscommon_p.h"
#include <QtCore/qstringlist.h>
#include <QtScript/qscriptengine.h>
#include <QtScript/qscriptcontextinfo.h>
#include <QtScript/qscriptvalueiterator.h>
#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
/*!
\since 4.5
\class QScriptDebuggerCommandExecutor
\internal
\brief The QScriptDebuggerCommandExecutor applies debugger commands to a back-end.
The execute() function takes a command (typically produced by a
QScriptDebuggerFrontend) and applies it to a QScriptDebuggerBackend.
\sa QScriptDebuggerCommmand
*/
class QScriptDebuggerCommandExecutorPrivate
{
public:
QScriptDebuggerCommandExecutorPrivate();
~QScriptDebuggerCommandExecutorPrivate();
};
QScriptDebuggerCommandExecutorPrivate::QScriptDebuggerCommandExecutorPrivate()
{
}
QScriptDebuggerCommandExecutorPrivate::~QScriptDebuggerCommandExecutorPrivate()
{
}
QScriptDebuggerCommandExecutor::QScriptDebuggerCommandExecutor()
: d_ptr(new QScriptDebuggerCommandExecutorPrivate())
{
}
QScriptDebuggerCommandExecutor::~QScriptDebuggerCommandExecutor()
{
}
/*!
Applies the given \a command to the given \a backend.
*/
QScriptDebuggerResponse QScriptDebuggerCommandExecutor::execute(
QScriptDebuggerBackend *backend,
const QScriptDebuggerCommand &command)
{
QScriptDebuggerResponse response;
switch (command.type()) {
case QScriptDebuggerCommand::None:
break;
case QScriptDebuggerCommand::Interrupt:
backend->interruptEvaluation();
break;
case QScriptDebuggerCommand::Continue:
if (backend->engine()->isEvaluating()) {
backend->continueEvalution();
response.setAsync(true);
}
break;
case QScriptDebuggerCommand::StepInto: {
QVariant attr = command.attribute(QScriptDebuggerCommand::StepCount);
int count = attr.isValid() ? attr.toInt() : 1;
backend->stepInto(count);
response.setAsync(true);
} break;
case QScriptDebuggerCommand::StepOver: {
QVariant attr = command.attribute(QScriptDebuggerCommand::StepCount);
int count = attr.isValid() ? attr.toInt() : 1;
backend->stepOver(count);
response.setAsync(true);
} break;
case QScriptDebuggerCommand::StepOut:
backend->stepOut();
response.setAsync(true);
break;
case QScriptDebuggerCommand::RunToLocation:
backend->runToLocation(command.fileName(), command.lineNumber());
response.setAsync(true);
break;
case QScriptDebuggerCommand::RunToLocationByID:
backend->runToLocation(command.scriptId(), command.lineNumber());
response.setAsync(true);
break;
case QScriptDebuggerCommand::ForceReturn: {
int contextIndex = command.contextIndex();
QScriptDebuggerValue value = command.scriptValue();
QScriptEngine *engine = backend->engine();
QScriptValue realValue = value.toScriptValue(engine);
backend->returnToCaller(contextIndex, realValue);
response.setAsync(true);
} break;
case QScriptDebuggerCommand::Resume:
backend->resume();
response.setAsync(true);
break;
case QScriptDebuggerCommand::SetBreakpoint: {
QScriptBreakpointData data = command.breakpointData();
if (!data.isValid())
data = QScriptBreakpointData(command.fileName(), command.lineNumber());
int id = backend->setBreakpoint(data);
response.setResult(id);
} break;
case QScriptDebuggerCommand::DeleteBreakpoint: {
int id = command.breakpointId();
if (!backend->deleteBreakpoint(id))
response.setError(QScriptDebuggerResponse::InvalidBreakpointID);
} break;
case QScriptDebuggerCommand::DeleteAllBreakpoints:
backend->deleteAllBreakpoints();
break;
case QScriptDebuggerCommand::GetBreakpoints: {
QScriptBreakpointMap bps = backend->breakpoints();
if (!bps.isEmpty())
response.setResult(bps);
} break;
case QScriptDebuggerCommand::GetBreakpointData: {
int id = command.breakpointId();
QScriptBreakpointData data = backend->breakpointData(id);
if (data.isValid())
response.setResult(data);
else
response.setError(QScriptDebuggerResponse::InvalidBreakpointID);
} break;
case QScriptDebuggerCommand::SetBreakpointData: {
int id = command.breakpointId();
QScriptBreakpointData data = command.breakpointData();
if (!backend->setBreakpointData(id, data))
response.setError(QScriptDebuggerResponse::InvalidBreakpointID);
} break;
case QScriptDebuggerCommand::GetScripts: {
QScriptScriptMap scripts = backend->scripts();
if (!scripts.isEmpty())
response.setResult(scripts);
} break;
case QScriptDebuggerCommand::GetScriptData: {
qint64 id = command.scriptId();
QScriptScriptData data = backend->scriptData(id);
if (data.isValid())
response.setResult(data);
else
response.setError(QScriptDebuggerResponse::InvalidScriptID);
} break;
case QScriptDebuggerCommand::ScriptsCheckpoint:
backend->scriptsCheckpoint();
response.setResult(QVariant::fromValue(backend->scriptsDelta()));
break;
case QScriptDebuggerCommand::GetScriptsDelta:
response.setResult(QVariant::fromValue(backend->scriptsDelta()));
break;
case QScriptDebuggerCommand::ResolveScript:
response.setResult(backend->resolveScript(command.fileName()));
break;
case QScriptDebuggerCommand::GetBacktrace:
response.setResult(backend->backtrace());
break;
case QScriptDebuggerCommand::GetContextCount:
response.setResult(backend->contextCount());
break;
case QScriptDebuggerCommand::GetContextState: {
QScriptContext *ctx = backend->context(command.contextIndex());
if (ctx)
response.setResult(static_cast<int>(ctx->state()));
else
response.setError(QScriptDebuggerResponse::InvalidContextIndex);
} break;
case QScriptDebuggerCommand::GetContextID: {
int idx = command.contextIndex();
if ((idx >= 0) && (idx < backend->contextCount()))
response.setResult(backend->contextIds()[idx]);
else
response.setError(QScriptDebuggerResponse::InvalidContextIndex);
} break;
case QScriptDebuggerCommand::GetContextInfo: {
QScriptContext *ctx = backend->context(command.contextIndex());
if (ctx)
response.setResult(QScriptContextInfo(ctx));
else
response.setError(QScriptDebuggerResponse::InvalidContextIndex);
} break;
case QScriptDebuggerCommand::GetThisObject: {
QScriptContext *ctx = backend->context(command.contextIndex());
if (ctx)
response.setResult(ctx->thisObject());
else
response.setError(QScriptDebuggerResponse::InvalidContextIndex);
} break;
case QScriptDebuggerCommand::GetActivationObject: {
QScriptContext *ctx = backend->context(command.contextIndex());
if (ctx)
response.setResult(ctx->activationObject());
else
response.setError(QScriptDebuggerResponse::InvalidContextIndex);
} break;
case QScriptDebuggerCommand::GetScopeChain: {
QScriptContext *ctx = backend->context(command.contextIndex());
if (ctx) {
QScriptDebuggerValueList dest;
QScriptValueList src = ctx->scopeChain();
for (int i = 0; i < src.size(); ++i)
dest.append(src.at(i));
response.setResult(dest);
} else {
response.setError(QScriptDebuggerResponse::InvalidContextIndex);
}
} break;
case QScriptDebuggerCommand::ContextsCheckpoint: {
response.setResult(QVariant::fromValue(backend->contextsCheckpoint()));
} break;
case QScriptDebuggerCommand::GetPropertyExpressionValue: {
QScriptContext *ctx = backend->context(command.contextIndex());
int lineNumber = command.lineNumber();
QVariant attr = command.attribute(QScriptDebuggerCommand::UserAttribute);
QStringList path = attr.toStringList();
if (!ctx || path.isEmpty())
break;
QScriptContextInfo ctxInfo(ctx);
if (ctx->callee().isValid()
&& ((lineNumber < ctxInfo.functionStartLineNumber())
|| (lineNumber > ctxInfo.functionEndLineNumber()))) {
break;
}
QScriptValueList objects;
int pathIndex = 0;
if (path.at(0) == QLatin1String("this")) {
objects.append(ctx->thisObject());
++pathIndex;
} else {
objects << ctx->scopeChain();
}
for (int i = 0; i < objects.size(); ++i) {
QScriptValue val = objects.at(i);
for (int j = pathIndex; val.isValid() && (j < path.size()); ++j) {
val = val.property(path.at(j));
}
if (val.isValid()) {
bool hadException = (ctx->state() == QScriptContext::ExceptionState);
QString str = val.toString();
if (!hadException && backend->engine()->hasUncaughtException())
backend->engine()->clearExceptions();
response.setResult(str);
break;
}
}
} break;
case QScriptDebuggerCommand::GetCompletions: {
QScriptContext *ctx = backend->context(command.contextIndex());
QVariant attr = command.attribute(QScriptDebuggerCommand::UserAttribute);
QStringList path = attr.toStringList();
if (!ctx || path.isEmpty())
break;
QScriptValueList objects;
QString prefix = path.last();
QSet<QString> matches;
if (path.size() > 1) {
const QString &topLevelIdent = path.at(0);
QScriptValue obj;
if (topLevelIdent == QLatin1String("this")) {
obj = ctx->thisObject();
} else {
QScriptValueList scopeChain;
scopeChain = ctx->scopeChain();
for (int i = 0; i < scopeChain.size(); ++i) {
QScriptValue oo = scopeChain.at(i).property(topLevelIdent);
if (oo.isObject()) {
obj = oo;
break;
}
}
}
for (int i = 1; obj.isObject() && (i < path.size()-1); ++i)
obj = obj.property(path.at(i));
if (obj.isValid())
objects.append(obj);
} else {
objects << ctx->scopeChain();
QStringList keywords;
keywords.append(QString::fromLatin1("this"));
keywords.append(QString::fromLatin1("true"));
keywords.append(QString::fromLatin1("false"));
keywords.append(QString::fromLatin1("null"));
for (int i = 0; i < keywords.size(); ++i) {
const QString &kwd = keywords.at(i);
if (isPrefixOf(prefix, kwd))
matches.insert(kwd);
}
}
for (int i = 0; i < objects.size(); ++i) {
QScriptValue obj = objects.at(i);
while (obj.isObject()) {
QScriptValueIterator it(obj);
while (it.hasNext()) {
it.next();
QString propertyName = it.name();
if (isPrefixOf(prefix, propertyName))
matches.insert(propertyName);
}
obj = obj.prototype();
}
}
QStringList matchesList = matches.toList();
qStableSort(matchesList);
response.setResult(matchesList);
} break;
case QScriptDebuggerCommand::NewScriptObjectSnapshot: {
int id = backend->newScriptObjectSnapshot();
response.setResult(id);
} break;
case QScriptDebuggerCommand::ScriptObjectSnapshotCapture: {
int id = command.snapshotId();
QScriptObjectSnapshot *snap = backend->scriptObjectSnapshot(id);
Q_ASSERT(snap != 0);
QScriptDebuggerValue object = command.scriptValue();
Q_ASSERT(object.type() == QScriptDebuggerValue::ObjectValue);
QScriptEngine *engine = backend->engine();
QScriptValue realObject = object.toScriptValue(engine);
Q_ASSERT(realObject.isObject());
QScriptObjectSnapshot::Delta delta = snap->capture(realObject);
QScriptDebuggerObjectSnapshotDelta result;
result.removedProperties = delta.removedProperties;
bool didIgnoreExceptions = backend->ignoreExceptions();
backend->setIgnoreExceptions(true);
for (int i = 0; i < delta.changedProperties.size(); ++i) {
const QScriptValueProperty &src = delta.changedProperties.at(i);
bool hadException = engine->hasUncaughtException();
QString str = src.value().toString();
if (!hadException && engine->hasUncaughtException())
engine->clearExceptions();
QScriptDebuggerValueProperty dest(src.name(), src.value(), str, src.flags());
result.changedProperties.append(dest);
}
for (int j = 0; j < delta.addedProperties.size(); ++j) {
const QScriptValueProperty &src = delta.addedProperties.at(j);
bool hadException = engine->hasUncaughtException();
QString str = src.value().toString();
if (!hadException && engine->hasUncaughtException())
engine->clearExceptions();
QScriptDebuggerValueProperty dest(src.name(), src.value(), str, src.flags());
result.addedProperties.append(dest);
}
backend->setIgnoreExceptions(didIgnoreExceptions);
response.setResult(QVariant::fromValue(result));
} break;
case QScriptDebuggerCommand::DeleteScriptObjectSnapshot: {
int id = command.snapshotId();
backend->deleteScriptObjectSnapshot(id);
} break;
case QScriptDebuggerCommand::NewScriptValueIterator: {
QScriptDebuggerValue object = command.scriptValue();
Q_ASSERT(object.type() == QScriptDebuggerValue::ObjectValue);
QScriptEngine *engine = backend->engine();
QScriptValue realObject = object.toScriptValue(engine);
Q_ASSERT(realObject.isObject());
int id = backend->newScriptValueIterator(realObject);
response.setResult(id);
} break;
case QScriptDebuggerCommand::GetPropertiesByIterator: {
int id = command.iteratorId();
int count = 1000;
QScriptValueIterator *it = backend->scriptValueIterator(id);
Q_ASSERT(it != 0);
QScriptDebuggerValuePropertyList props;
for (int i = 0; (i < count) && it->hasNext(); ++i) {
it->next();
QString name = it->name();
QScriptValue value = it->value();
QString valueAsString = value.toString();
QScriptValue::PropertyFlags flags = it->flags();
QScriptDebuggerValueProperty prp(name, value, valueAsString, flags);
props.append(prp);
}
response.setResult(props);
} break;
case QScriptDebuggerCommand::DeleteScriptValueIterator: {
int id = command.iteratorId();
backend->deleteScriptValueIterator(id);
} break;
case QScriptDebuggerCommand::Evaluate: {
int contextIndex = command.contextIndex();
QString program = command.program();
QString fileName = command.fileName();
int lineNumber = command.lineNumber();
backend->evaluate(contextIndex, program, fileName, lineNumber);
response.setAsync(true);
} break;
case QScriptDebuggerCommand::ScriptValueToString: {
QScriptDebuggerValue value = command.scriptValue();
QScriptEngine *engine = backend->engine();
QScriptValue realValue = value.toScriptValue(engine);
response.setResult(realValue.toString());
} break;
case QScriptDebuggerCommand::SetScriptValueProperty: {
QScriptDebuggerValue object = command.scriptValue();
QScriptEngine *engine = backend->engine();
QScriptValue realObject = object.toScriptValue(engine);
QScriptDebuggerValue value = command.subordinateScriptValue();
QScriptValue realValue = value.toScriptValue(engine);
QString name = command.name();
realObject.setProperty(name, realValue);
} break;
case QScriptDebuggerCommand::ClearExceptions:
backend->engine()->clearExceptions();
break;
case QScriptDebuggerCommand::UserCommand:
case QScriptDebuggerCommand::MaxUserCommand:
break;
}
return response;
}
QT_END_NAMESPACE

View file

@ -1,67 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTDEBUGGERCOMMANDEXECUTOR_P_H
#define QSCRIPTDEBUGGERCOMMANDEXECUTOR_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtCore/qobjectdefs.h>
#include <QtCore/qscopedpointer.h>
QT_BEGIN_NAMESPACE
class QScriptDebuggerBackend;
class QScriptDebuggerCommand;
class QScriptDebuggerResponse;
class QScriptDebuggerCommandExecutorPrivate;
class Q_AUTOTEST_EXPORT QScriptDebuggerCommandExecutor
{
public:
QScriptDebuggerCommandExecutor();
virtual ~QScriptDebuggerCommandExecutor();
virtual QScriptDebuggerResponse execute(
QScriptDebuggerBackend *backend,
const QScriptDebuggerCommand &command);
protected:
QScriptDebuggerCommandExecutor(QScriptDebuggerCommandExecutorPrivate &dd);
QScopedPointer<QScriptDebuggerCommandExecutorPrivate> d_ptr;
private:
Q_DECLARE_PRIVATE(QScriptDebuggerCommandExecutor)
Q_DISABLE_COPY(QScriptDebuggerCommandExecutor)
};
QT_END_NAMESPACE
#endif

View file

@ -1,300 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qscriptdebuggercommandschedulerfrontend_p.h"
#include "qscriptdebuggercommandschedulerinterface_p.h"
#include "qscriptdebuggercommand_p.h"
QT_BEGIN_NAMESPACE
QScriptDebuggerCommandSchedulerFrontend::QScriptDebuggerCommandSchedulerFrontend(
QScriptDebuggerCommandSchedulerInterface *scheduler,
QScriptDebuggerResponseHandlerInterface *responseHandler)
: m_scheduler(scheduler), m_responseHandler(responseHandler)
{
}
QScriptDebuggerCommandSchedulerFrontend::~QScriptDebuggerCommandSchedulerFrontend()
{
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleCommand(const QScriptDebuggerCommand &command)
{
return m_scheduler->scheduleCommand(command, m_responseHandler);
}
/*!
Instructs the front-end to break at the next script statement, and
returns a unique identifier associated with this command.
When the next script statement is encountered, the client will be
notified, and the front-end will be ready to accept commands.
\sa scheduleContinue()
*/
int QScriptDebuggerCommandSchedulerFrontend::scheduleInterrupt()
{
return scheduleCommand(QScriptDebuggerCommand::interruptCommand());
}
/*!
Instructs the front-end to continue evaluation, and returns a unique
identifier associated with this command.
\sa scheduleBreak()
*/
int QScriptDebuggerCommandSchedulerFrontend::scheduleContinue()
{
return scheduleCommand(QScriptDebuggerCommand::continueCommand());
}
/*!
Instructs the front-end to step into the next script statement, and
returns a unique identifier associated with this command.
Evaluation will automatically be continued, and the client()'s event()
function will be called when the statement has been stepped into.
*/
int QScriptDebuggerCommandSchedulerFrontend::scheduleStepInto(int count)
{
return scheduleCommand(QScriptDebuggerCommand::stepIntoCommand(count));
}
/*!
Instructs the front-end to step over the next script statement, and
returns a unique identifier associated with this command.
Evaluation will automatically be continued, and the client()'s event()
function will be called when the statement has been stepped over.
*/
int QScriptDebuggerCommandSchedulerFrontend::scheduleStepOver(int count)
{
return scheduleCommand(QScriptDebuggerCommand::stepOverCommand(count));
}
/*!
Instructs the front-end to step out of the current script function, and
returns a unique identifier associated with this command.
Evaluation will automatically be continued, and the client()'s
event() function will be called when the script function has been
stepped out of.
*/
int QScriptDebuggerCommandSchedulerFrontend::scheduleStepOut()
{
return scheduleCommand(QScriptDebuggerCommand::stepOutCommand());
}
/*!
Instructs the front-end to continue evaluation until the location
specified by the given \a fileName and \a lineNumber is reached.
*/
int QScriptDebuggerCommandSchedulerFrontend::scheduleRunToLocation(const QString &fileName, int lineNumber)
{
return scheduleCommand(QScriptDebuggerCommand::runToLocationCommand(fileName, lineNumber));
}
/*!
Instructs the front-end to continue evaluation until the location
specified by the given \a scriptId and \a lineNumber is reached.
*/
int QScriptDebuggerCommandSchedulerFrontend::scheduleRunToLocation(qint64 scriptId, int lineNumber)
{
return scheduleCommand(QScriptDebuggerCommand::runToLocationCommand(scriptId, lineNumber));
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleForceReturn(int contextIndex, const QScriptDebuggerValue &value)
{
return scheduleCommand(QScriptDebuggerCommand::forceReturnCommand(contextIndex, value));
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleSetBreakpoint(const QString &fileName, int lineNumber)
{
return scheduleCommand(QScriptDebuggerCommand::setBreakpointCommand(fileName, lineNumber));
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleSetBreakpoint(const QScriptBreakpointData &data)
{
return scheduleCommand(QScriptDebuggerCommand::setBreakpointCommand(data));
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleDeleteBreakpoint(int id)
{
return scheduleCommand(QScriptDebuggerCommand::deleteBreakpointCommand(id));
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleDeleteAllBreakpoints()
{
return scheduleCommand(QScriptDebuggerCommand::deleteAllBreakpointsCommand());
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleGetBreakpoints()
{
return scheduleCommand(QScriptDebuggerCommand::getBreakpointsCommand());
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleGetBreakpointData(int id)
{
return scheduleCommand(QScriptDebuggerCommand::getBreakpointDataCommand(id));
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleSetBreakpointData(int id, const QScriptBreakpointData &data)
{
return scheduleCommand(QScriptDebuggerCommand::setBreakpointDataCommand(id, data));
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleGetScripts()
{
return scheduleCommand(QScriptDebuggerCommand::getScriptsCommand());
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleGetScriptData(qint64 id)
{
return scheduleCommand(QScriptDebuggerCommand::getScriptDataCommand(id));
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleScriptsCheckpoint()
{
return scheduleCommand(QScriptDebuggerCommand::scriptsCheckpointCommand());
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleGetScriptsDelta()
{
return scheduleCommand(QScriptDebuggerCommand::getScriptsDeltaCommand());
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleResolveScript(const QString &fileName)
{
return scheduleCommand(QScriptDebuggerCommand::resolveScriptCommand(fileName));
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleGetBacktrace()
{
return scheduleCommand(QScriptDebuggerCommand::getBacktraceCommand());
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleGetContextCount()
{
return scheduleCommand(QScriptDebuggerCommand::getContextCountCommand());
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleGetContextState(int contextIndex)
{
return scheduleCommand(QScriptDebuggerCommand::getContextStateCommand(contextIndex));
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleGetContextInfo(int contextIndex)
{
return scheduleCommand(QScriptDebuggerCommand::getContextInfoCommand(contextIndex));
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleGetContextId(int contextIndex)
{
return scheduleCommand(QScriptDebuggerCommand::getContextIdCommand(contextIndex));
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleGetThisObject(int contextIndex)
{
return scheduleCommand(QScriptDebuggerCommand::getThisObjectCommand(contextIndex));
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleGetActivationObject(int contextIndex)
{
return scheduleCommand(QScriptDebuggerCommand::getActivationObjectCommand(contextIndex));
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleGetScopeChain(int contextIndex)
{
return scheduleCommand(QScriptDebuggerCommand::getScopeChainCommand(contextIndex));
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleContextsCheckpoint()
{
return scheduleCommand(QScriptDebuggerCommand::contextsCheckpoint());
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleGetPropertyExpressionValue(
int contextIndex, int lineNumber, const QStringList &path)
{
return scheduleCommand(QScriptDebuggerCommand::getPropertyExpressionValue(contextIndex, lineNumber, path));
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleGetCompletions(int contextIndex, const QStringList &path)
{
return scheduleCommand(QScriptDebuggerCommand::getCompletions(contextIndex, path));
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleEvaluate(int contextIndex,
const QString &program,
const QString &fileName,
int lineNumber)
{
return scheduleCommand(QScriptDebuggerCommand::evaluateCommand(contextIndex, program, fileName, lineNumber));
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleNewScriptValueIterator(const QScriptDebuggerValue &object)
{
return scheduleCommand(QScriptDebuggerCommand::newScriptValueIteratorCommand(object));
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleGetPropertiesByIterator(int id, int count)
{
return scheduleCommand(QScriptDebuggerCommand::getPropertiesByIteratorCommand(id, count));
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleDeleteScriptValueIterator(int id)
{
return scheduleCommand(QScriptDebuggerCommand::deleteScriptValueIteratorCommand(id));
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleScriptValueToString(const QScriptDebuggerValue &value)
{
return scheduleCommand(QScriptDebuggerCommand::scriptValueToStringCommand(value));
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleSetScriptValueProperty(const QScriptDebuggerValue &object,
const QString &name,
const QScriptDebuggerValue &value)
{
return scheduleCommand(QScriptDebuggerCommand::setScriptValuePropertyCommand(object, name, value));
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleClearExceptions()
{
return scheduleCommand(QScriptDebuggerCommand::clearExceptionsCommand());
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleNewScriptObjectSnapshot()
{
return scheduleCommand(QScriptDebuggerCommand::newScriptObjectSnapshotCommand());
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleScriptObjectSnapshotCapture(int id, const QScriptDebuggerValue &object)
{
return scheduleCommand(QScriptDebuggerCommand::scriptObjectSnapshotCaptureCommand(id, object));
}
int QScriptDebuggerCommandSchedulerFrontend::scheduleDeleteScriptObjectSnapshot(int id)
{
return scheduleCommand(QScriptDebuggerCommand::deleteScriptObjectSnapshotCommand(id));
}
QT_END_NAMESPACE

View file

@ -1,128 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTDEBUGGERCOMMANDSCHEDULERFRONTEND_P_H
#define QSCRIPTDEBUGGERCOMMANDSCHEDULERFRONTEND_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtCore/qobjectdefs.h>
#include <QtCore/qstring.h>
QT_BEGIN_NAMESPACE
class QScriptDebuggerCommandSchedulerInterface;
class QScriptDebuggerResponseHandlerInterface;
class QScriptDebuggerCommand;
class QScriptDebuggerValue;
class QScriptBreakpointData;
class Q_AUTOTEST_EXPORT QScriptDebuggerCommandSchedulerFrontend
{
public:
QScriptDebuggerCommandSchedulerFrontend(
QScriptDebuggerCommandSchedulerInterface *scheduler,
QScriptDebuggerResponseHandlerInterface *responseHandler);
~QScriptDebuggerCommandSchedulerFrontend();
// execution control
int scheduleInterrupt();
int scheduleContinue();
int scheduleStepInto(int count = 1);
int scheduleStepOver(int count = 1);
int scheduleStepOut();
int scheduleRunToLocation(const QString &fileName, int lineNumber);
int scheduleRunToLocation(qint64 scriptId, int lineNumber);
int scheduleForceReturn(int contextIndex, const QScriptDebuggerValue &value);
// breakpoints
int scheduleSetBreakpoint(const QString &fileName, int lineNumber);
int scheduleSetBreakpoint(const QScriptBreakpointData &data);
int scheduleDeleteBreakpoint(int id);
int scheduleDeleteAllBreakpoints();
int scheduleGetBreakpoints();
int scheduleGetBreakpointData(int id);
int scheduleSetBreakpointData(int id, const QScriptBreakpointData &data);
// scripts
int scheduleGetScripts();
int scheduleGetScriptData(qint64 id);
int scheduleScriptsCheckpoint();
int scheduleGetScriptsDelta();
int scheduleResolveScript(const QString &fileName);
// stack
int scheduleGetBacktrace();
int scheduleGetContextCount();
int scheduleGetContextState(int contextIndex);
int scheduleGetContextInfo(int contextIndex);
int scheduleGetContextId(int contextIndex);
int scheduleGetThisObject(int contextIndex);
int scheduleGetActivationObject(int contextIndex);
int scheduleGetScopeChain(int contextIndex);
int scheduleContextsCheckpoint();
int scheduleGetPropertyExpressionValue(int contextIndex, int lineNumber,
const QStringList &path);
int scheduleGetCompletions(int contextIndex, const QStringList &path);
// iteration
int scheduleNewScriptValueIterator(const QScriptDebuggerValue &object);
int scheduleGetPropertiesByIterator(int id, int count);
int scheduleDeleteScriptValueIterator(int id);
// evaluation
int scheduleEvaluate(int contextIndex, const QString &program,
const QString &fileName = QString(),
int lineNumber = 1);
int scheduleScriptValueToString(const QScriptDebuggerValue &value);
int scheduleSetScriptValueProperty(const QScriptDebuggerValue &object,
const QString &name,
const QScriptDebuggerValue &value);
int scheduleClearExceptions();
int scheduleNewScriptObjectSnapshot();
int scheduleScriptObjectSnapshotCapture(int id, const QScriptDebuggerValue &object);
int scheduleDeleteScriptObjectSnapshot(int id);
private:
int scheduleCommand(const QScriptDebuggerCommand &command);
QScriptDebuggerCommandSchedulerInterface *m_scheduler;
QScriptDebuggerResponseHandlerInterface *m_responseHandler;
Q_DISABLE_COPY(QScriptDebuggerCommandSchedulerFrontend)
};
QT_END_NAMESPACE
#endif

View file

@ -1,55 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTDEBUGGERCOMMANDSCHEDULERINTERFACE_P_H
#define QSCRIPTDEBUGGERCOMMANDSCHEDULERINTERFACE_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtCore/qobjectdefs.h>
QT_BEGIN_NAMESPACE
class QScriptDebuggerCommand;
class QScriptDebuggerResponseHandlerInterface;
class Q_AUTOTEST_EXPORT QScriptDebuggerCommandSchedulerInterface
{
public:
virtual ~QScriptDebuggerCommandSchedulerInterface() {}
virtual int scheduleCommand(
const QScriptDebuggerCommand &command,
QScriptDebuggerResponseHandlerInterface *responseHandler) = 0;
};
QT_END_NAMESPACE
#endif

View file

@ -1,62 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qscriptdebuggercommandschedulerjob_p.h"
#include "qscriptdebuggercommandschedulerjob_p_p.h"
QT_BEGIN_NAMESPACE
QScriptDebuggerCommandSchedulerJobPrivate::QScriptDebuggerCommandSchedulerJobPrivate()
{
}
QScriptDebuggerCommandSchedulerJobPrivate::~QScriptDebuggerCommandSchedulerJobPrivate()
{
}
QScriptDebuggerCommandSchedulerJob::QScriptDebuggerCommandSchedulerJob(
QScriptDebuggerCommandSchedulerInterface *commandScheduler)
: QScriptDebuggerJob(*new QScriptDebuggerCommandSchedulerJobPrivate)
{
Q_D(QScriptDebuggerCommandSchedulerJob);
d->commandScheduler = commandScheduler;
}
QScriptDebuggerCommandSchedulerJob::~QScriptDebuggerCommandSchedulerJob()
{
}
QScriptDebuggerCommandSchedulerJob::QScriptDebuggerCommandSchedulerJob(
QScriptDebuggerCommandSchedulerJobPrivate &dd,
QScriptDebuggerCommandSchedulerInterface *commandScheduler)
: QScriptDebuggerJob(dd)
{
Q_D(QScriptDebuggerCommandSchedulerJob);
d->commandScheduler = commandScheduler;
}
QScriptDebuggerCommandSchedulerInterface *QScriptDebuggerCommandSchedulerJob::commandScheduler() const
{
Q_D(const QScriptDebuggerCommandSchedulerJob);
return d->commandScheduler;
}
QT_END_NAMESPACE

View file

@ -1,67 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTDEBUGGERCOMMANDSCHEDULERJOB_P_H
#define QSCRIPTDEBUGGERCOMMANDSCHEDULERJOB_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include "qscriptdebuggerjob_p.h"
#include "qscriptdebuggerresponsehandlerinterface_p.h"
QT_BEGIN_NAMESPACE
class QScriptDebuggerCommandSchedulerInterface;
class QScriptDebuggerCommandSchedulerJobPrivate;
class Q_AUTOTEST_EXPORT QScriptDebuggerCommandSchedulerJob
: public QScriptDebuggerJob,
public QScriptDebuggerResponseHandlerInterface
{
public:
QScriptDebuggerCommandSchedulerJob(QScriptDebuggerCommandSchedulerInterface *commandScheduler);
~QScriptDebuggerCommandSchedulerJob();
QScriptDebuggerCommandSchedulerInterface *commandScheduler() const;
protected:
QScriptDebuggerCommandSchedulerJob(
QScriptDebuggerCommandSchedulerJobPrivate &dd,
QScriptDebuggerCommandSchedulerInterface *commandScheduler);
private:
Q_DECLARE_PRIVATE(QScriptDebuggerCommandSchedulerJob)
Q_DISABLE_COPY(QScriptDebuggerCommandSchedulerJob)
};
QT_END_NAMESPACE
#endif

View file

@ -1,56 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTDEBUGGERCOMMANDSCHEDULERJOB_P_P_H
#define QSCRIPTDEBUGGERCOMMANDSCHEDULERJOB_P_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include "qscriptdebuggerjob_p_p.h"
QT_BEGIN_NAMESPACE
class QScriptDebuggerCommandSchedulerInterface;
class QScriptDebuggerCommandSchedulerJob;
class QScriptDebuggerCommandSchedulerJobPrivate
: public QScriptDebuggerJobPrivate
{
Q_DECLARE_PUBLIC(QScriptDebuggerCommandSchedulerJob)
public:
QScriptDebuggerCommandSchedulerJobPrivate();
~QScriptDebuggerCommandSchedulerJobPrivate();
QScriptDebuggerCommandSchedulerInterface *commandScheduler;
};
QT_END_NAMESPACE
#endif

View file

@ -1,598 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qscriptdebuggerconsole_p.h"
#include "qscriptdebuggerconsolecommandjob_p.h"
#include "qscriptdebuggerconsolecommandmanager_p.h"
#include "qscriptdebuggerscriptedconsolecommand_p.h"
#include "qscriptmessagehandlerinterface_p.h"
#include "qscriptbreakpointdata_p.h"
#include "qscriptdebuggerresponse_p.h"
#include "qscriptdebuggervalueproperty_p.h"
#include "qscriptscriptdata_p.h"
#include "qscripttoolscommon_p.h"
#include "qscripttoolsresources_p.h"
#include <QtCore/qdir.h>
#include <QtCore/qfileinfo.h>
#include <QtCore/qstring.h>
#include <QtCore/qstringlist.h>
#include <QtCore/qdebug.h>
#include <QtScript/qscriptcontextinfo.h>
#include <QtScript/qscriptengine.h>
QT_BEGIN_NAMESPACE
static QScriptValue debuggerResponseToScriptValue(QScriptEngine *eng, const QScriptDebuggerResponse &in)
{
QScriptValue out = eng->newObject();
out.setProperty(QString::fromLatin1("result"), eng->toScriptValue(in.result()));
out.setProperty(QString::fromLatin1("error"), QScriptValue(eng, in.error()));
out.setProperty(QString::fromLatin1("async"), QScriptValue(eng, in.async()));
return out;
}
static void debuggerResponseFromScriptValue(const QScriptValue &, QScriptDebuggerResponse &)
{
Q_ASSERT(false);
}
static QScriptValue breakpointDataToScriptValue(QScriptEngine *eng, const QScriptBreakpointData &in)
{
QScriptValue out = eng->newObject();
out.setProperty(QString::fromLatin1("scriptId"), QScriptValue(eng, qsreal(in.scriptId())));
out.setProperty(QString::fromLatin1("fileName"), QScriptValue(eng, in.fileName()));
out.setProperty(QString::fromLatin1("lineNumber"), QScriptValue(eng, in.lineNumber()));
out.setProperty(QString::fromLatin1("enabled"), QScriptValue(eng, in.isEnabled()));
out.setProperty(QString::fromLatin1("singleShot"), QScriptValue(eng, in.isSingleShot()));
out.setProperty(QString::fromLatin1("ignoreCount"), QScriptValue(eng, in.ignoreCount()));
out.setProperty(QString::fromLatin1("condition"), QScriptValue(eng, in.condition()));
return out;
}
static void breakpointDataFromScriptValue(const QScriptValue &in, QScriptBreakpointData &out)
{
QScriptValue scriptId = in.property(QString::fromLatin1("scriptId"));
if (scriptId.isValid())
out.setScriptId((qint64)scriptId.toNumber());
out.setFileName(in.property(QString::fromLatin1("fileName")).toString());
out.setLineNumber(in.property(QString::fromLatin1("lineNumber")).toInt32());
QScriptValue enabled = in.property(QString::fromLatin1("enabled"));
if (enabled.isValid())
out.setEnabled(enabled.toBoolean());
QScriptValue singleShot = in.property(QString::fromLatin1("singleShot"));
if (singleShot.isValid())
out.setSingleShot(singleShot.toBoolean());
out.setIgnoreCount(in.property(QString::fromLatin1("ignoreCount")).toInt32());
out.setCondition(in.property(QString::fromLatin1("condition")).toString());
}
static QScriptValue breakpointMapToScriptValue(QScriptEngine *eng, const QScriptBreakpointMap &in)
{
QScriptValue out = eng->newObject();
QScriptBreakpointMap::const_iterator it;
for (it = in.constBegin(); it != in.constEnd(); ++it) {
out.setProperty(QString::number(it.key()), eng->toScriptValue(it.value()));
}
return out;
}
static void breakpointMapFromScriptValue(const QScriptValue &, QScriptBreakpointMap &)
{
Q_ASSERT(false);
}
static QScriptValue scriptDataToScriptValue(QScriptEngine *eng, const QScriptScriptData &in)
{
QScriptValue out = eng->newObject();
out.setProperty(QString::fromLatin1("contents"), QScriptValue(eng, in.contents()));
out.setProperty(QString::fromLatin1("fileName"), QScriptValue(eng, in.fileName()));
out.setProperty(QString::fromLatin1("baseLineNumber"), QScriptValue(eng, in.baseLineNumber()));
return out;
}
static void scriptDataFromScriptValue(const QScriptValue &in, QScriptScriptData &out)
{
QString contents = in.property(QString::fromLatin1("contents")).toString();
QString fileName = in.property(QString::fromLatin1("fileName")).toString();
int baseLineNumber = in.property(QString::fromLatin1("baseLineNumber")).toInt32();
QScriptScriptData tmp(contents, fileName, baseLineNumber);
out = tmp;
}
static QScriptValue scriptMapToScriptValue(QScriptEngine *eng, const QScriptScriptMap &in)
{
QScriptValue out = eng->newObject();
QScriptScriptMap::const_iterator it;
for (it = in.constBegin(); it != in.constEnd(); ++it) {
out.setProperty(QString::number(it.key()), eng->toScriptValue(it.value()));
}
return out;
}
static void scriptMapFromScriptValue(const QScriptValue &, QScriptScriptMap &)
{
Q_ASSERT(false);
}
static QScriptValue consoleCommandToScriptValue(
QScriptEngine *eng, QScriptDebuggerConsoleCommand* const &in)
{
if (!in)
return eng->undefinedValue();
QScriptValue out = eng->newObject();
out.setProperty(QString::fromLatin1("name"), QScriptValue(eng, in->name()));
out.setProperty(QString::fromLatin1("group"), QScriptValue(eng, in->group()));
out.setProperty(QString::fromLatin1("shortDescription"), QScriptValue(eng, in->shortDescription()));
out.setProperty(QString::fromLatin1("longDescription"), QScriptValue(eng, in->longDescription()));
out.setProperty(QString::fromLatin1("aliases"), eng->toScriptValue(in->aliases()));
out.setProperty(QString::fromLatin1("seeAlso"), eng->toScriptValue(in->seeAlso()));
return out;
}
static void consoleCommandFromScriptValue(
const QScriptValue &, QScriptDebuggerConsoleCommand* &)
{
Q_ASSERT(false);
}
static QScriptValue consoleCommandGroupDataToScriptValue(
QScriptEngine *eng, const QScriptDebuggerConsoleCommandGroupData &in)
{
QScriptValue out = eng->newObject();
out.setProperty(QString::fromLatin1("longDescription"), QScriptValue(eng, in.longDescription()));
out.setProperty(QString::fromLatin1("shortDescription"), QScriptValue(eng, in.shortDescription()));
return out;
}
static void consoleCommandGroupDataFromScriptValue(
const QScriptValue &, QScriptDebuggerConsoleCommandGroupData &)
{
Q_ASSERT(false);
}
static QScriptValue consoleCommandGroupMapToScriptValue(
QScriptEngine *eng, const QScriptDebuggerConsoleCommandGroupMap &in)
{
QScriptValue out = eng->newObject();
QScriptDebuggerConsoleCommandGroupMap::const_iterator it;
for (it = in.constBegin(); it != in.constEnd(); ++it) {
out.setProperty(it.key(), eng->toScriptValue(it.value()));
}
return out;
}
static void consoleCommandGroupMapFromScriptValue(
const QScriptValue &, QScriptDebuggerConsoleCommandGroupMap &)
{
Q_ASSERT(false);
}
static QScriptValue contextInfoToScriptValue(QScriptEngine *eng, const QScriptContextInfo &in)
{
QScriptValue out = eng->newObject();
out.setProperty(QString::fromLatin1("scriptId"), QScriptValue(eng, qsreal(in.scriptId())));
out.setProperty(QString::fromLatin1("fileName"), QScriptValue(eng, in.fileName()));
out.setProperty(QString::fromLatin1("lineNumber"), QScriptValue(eng, in.lineNumber()));
out.setProperty(QString::fromLatin1("functionName"), QScriptValue(eng, in.functionName()));
return out;
}
static void contextInfoFromScriptValue(const QScriptValue &, QScriptContextInfo &)
{
Q_ASSERT(false);
}
static QScriptValue debuggerScriptValuePropertyToScriptValue(QScriptEngine *eng, const QScriptDebuggerValueProperty &in)
{
QScriptValue out = eng->newObject();
out.setProperty(QString::fromLatin1("name"), QScriptValue(eng, in.name()));
out.setProperty(QString::fromLatin1("value"), eng->toScriptValue(in.value()));
out.setProperty(QString::fromLatin1("valueAsString"), QScriptValue(eng, in.valueAsString()));
out.setProperty(QString::fromLatin1("flags"), QScriptValue(eng, static_cast<int>(in.flags())));
return out;
}
static void debuggerScriptValuePropertyFromScriptValue(const QScriptValue &in, QScriptDebuggerValueProperty &out)
{
QString name = in.property(QString::fromLatin1("name")).toString();
QScriptDebuggerValue value = qscriptvalue_cast<QScriptDebuggerValue>(in.property(QString::fromLatin1("value")));
QString valueAsString = in.property(QString::fromLatin1("valueAsString")).toString();
int flags = in.property(QString::fromLatin1("flags")).toInt32();
QScriptDebuggerValueProperty tmp(name, value, valueAsString, QScriptValue::PropertyFlags(flags));
out = tmp;
}
/*!
\since 4.5
\class QScriptDebuggerConsole
\internal
\brief The QScriptDebuggerConsole class provides the core functionality of a debugger console.
*/
class QScriptDebuggerConsolePrivate
{
Q_DECLARE_PUBLIC(QScriptDebuggerConsole)
public:
QScriptDebuggerConsolePrivate(QScriptDebuggerConsole*);
~QScriptDebuggerConsolePrivate();
void loadScriptedCommands(QScriptMessageHandlerInterface *messageHandler);
QScriptDebuggerConsoleCommandJob *createJob(
const QString &command,
QScriptMessageHandlerInterface *messageHandler,
QScriptDebuggerCommandSchedulerInterface *commandScheduler);
QScriptEngine *commandEngine;
QScriptDebuggerConsoleCommandManager *commandManager;
QString commandPrefix;
QString input;
QStringList commandHistory;
int currentFrameIndex;
qint64 currentScriptId;
int currentLineNumber;
int evaluateAction;
qint64 sessionId;
QScriptDebuggerConsole *q_ptr;
};
QScriptDebuggerConsolePrivate::QScriptDebuggerConsolePrivate(QScriptDebuggerConsole* parent)
: q_ptr(parent)
{
sessionId = 0;
currentFrameIndex = 0;
currentScriptId = -1;
currentLineNumber = -1;
evaluateAction = 0;
commandPrefix = QLatin1String(".");
commandManager = new QScriptDebuggerConsoleCommandManager();
commandEngine = new QScriptEngine;
qScriptRegisterMetaType<QScriptBreakpointData>(commandEngine, breakpointDataToScriptValue, breakpointDataFromScriptValue);
qScriptRegisterMetaType<QScriptBreakpointMap>(commandEngine, breakpointMapToScriptValue, breakpointMapFromScriptValue);
qScriptRegisterMetaType<QScriptScriptData>(commandEngine, scriptDataToScriptValue, scriptDataFromScriptValue);
qScriptRegisterMetaType<QScriptScriptMap>(commandEngine, scriptMapToScriptValue, scriptMapFromScriptValue);
qScriptRegisterMetaType<QScriptContextInfo>(commandEngine, contextInfoToScriptValue, contextInfoFromScriptValue);
qScriptRegisterMetaType<QScriptDebuggerValueProperty>(commandEngine, debuggerScriptValuePropertyToScriptValue, debuggerScriptValuePropertyFromScriptValue);
qScriptRegisterSequenceMetaType<QScriptDebuggerValuePropertyList>(commandEngine);
qScriptRegisterMetaType<QScriptDebuggerResponse>(commandEngine, debuggerResponseToScriptValue, debuggerResponseFromScriptValue);
qScriptRegisterMetaType<QScriptDebuggerConsoleCommand*>(commandEngine, consoleCommandToScriptValue, consoleCommandFromScriptValue);
qScriptRegisterSequenceMetaType<QScriptDebuggerConsoleCommandList>(commandEngine);
qScriptRegisterMetaType<QScriptDebuggerConsoleCommandGroupData>(commandEngine, consoleCommandGroupDataToScriptValue, consoleCommandGroupDataFromScriptValue);
qScriptRegisterMetaType<QScriptDebuggerConsoleCommandGroupMap>(commandEngine, consoleCommandGroupMapToScriptValue, consoleCommandGroupMapFromScriptValue);
// ### can't do this, if it's an object ID the conversion will be incorrect since
// ### the object ID refers to an object in a different engine!
// qScriptRegisterMetaType(commandEngine, debuggerScriptValueToScriptValue, debuggerScriptValueFromScriptValue);
}
QScriptDebuggerConsolePrivate::~QScriptDebuggerConsolePrivate()
{
delete commandManager;
delete commandEngine;
}
/*!
Loads command definitions from scripts.
*/
void QScriptDebuggerConsolePrivate::loadScriptedCommands(
QScriptMessageHandlerInterface *messageHandler)
{
static const struct ScriptsTblData {
const unsigned char* script;
const unsigned int scriptlen;
const char* scriptname;
} ScriptsTbl[] = {
{ scripts_advance_qs, scripts_advance_qs_len, "advance.qs" },
{ scripts_backtrace_qs, scripts_backtrace_qs_len, "backtrace.qs" },
{ scripts_break_qs, scripts_break_qs_len, "break.qs" },
{ scripts_clear_qs, scripts_clear_qs_len, "clear.qs" },
{ scripts_complete_qs, scripts_complete_qs_len, "complete.qs" },
{ scripts_condition_qs, scripts_condition_qs_len, "condition.qs" },
{ scripts_continue_qs, scripts_continue_qs_len, "continue.qs" },
{ scripts_delete_qs, scripts_delete_qs_len, "delete.qs" },
{ scripts_disable_qs, scripts_disable_qs_len, "disable.qs" },
{ scripts_down_qs, scripts_down_qs_len, "down.qs" },
{ scripts_enable_qs, scripts_enable_qs_len, "enable.qs" },
{ scripts_eval_qs, scripts_eval_qs_len, "eval.qs" },
{ scripts_finish_qs, scripts_finish_qs_len, "finish.qs" },
{ scripts_frame_qs, scripts_frame_qs_len, "frame.qs" },
{ scripts_help_qs, scripts_help_qs_len, "help.qs" },
{ scripts_ignore_qs, scripts_ignore_qs_len, "ignore.qs" },
{ scripts_info_qs, scripts_info_qs_len, "info.qs" },
{ scripts_interrupt_qs, scripts_interrupt_qs_len, "interrupt.qs" },
{ scripts_list_qs, scripts_list_qs_len, "list.qs" },
{ scripts_next_qs, scripts_next_qs_len, "next.qs" },
{ scripts_print_qs, scripts_print_qs_len, "print.qs" },
{ scripts_return_qs, scripts_return_qs_len, "return.qs" },
{ scripts_step_qs, scripts_step_qs_len, "step.qs" },
{ scripts_tbreak_qs, scripts_tbreak_qs_len, "tbreak.qs" },
{ scripts_up_qs, scripts_up_qs_len, "up.qs" }
};
static const qint16 ScriptsTblSize = sizeof(ScriptsTbl) / sizeof(ScriptsTblData);
for (int i = 0; i < ScriptsTblSize; ++i) {
QString program = QString::fromLocal8Bit(
reinterpret_cast<const char*>(ScriptsTbl[i].script),
ScriptsTbl[i].scriptlen
);
QString fileName = QString::fromLocal8Bit(ScriptsTbl[i].scriptname);
QScriptDebuggerScriptedConsoleCommand *command;
command = QScriptDebuggerScriptedConsoleCommand::parse(
program, fileName, commandEngine, messageHandler);
if (!command)
continue;
commandManager->addCommand(command);
}
}
/*!
Creates a job that will execute the given debugger \a command.
Returns the new job, or 0 if the command is undefined.
*/
QScriptDebuggerConsoleCommandJob *QScriptDebuggerConsolePrivate::createJob(
const QString &command, QScriptMessageHandlerInterface *messageHandler,
QScriptDebuggerCommandSchedulerInterface *commandScheduler)
{
QString name;
int i = command.indexOf(QLatin1Char(' '));
if (i == -1) {
name = command;
i = name.size();
} else {
name = command.left(i);
}
if (name.isEmpty())
return 0;
QScriptDebuggerConsoleCommand *cmd = commandManager->findCommand(name);
if (!cmd) {
// try to auto-complete
QStringList completions = commandManager->completions(name);
if (!completions.isEmpty()) {
if (completions.size() > 1) {
QString msg;
msg.append(QString::fromLatin1("Ambiguous command \"%0\": ")
.arg(name));
for (int j = 0; j < completions.size(); ++j) {
if (j > 0)
msg.append(QLatin1String(", "));
msg.append(completions.at(j));
}
msg.append(QLatin1Char('.'));
messageHandler->message(QtWarningMsg, msg);
return 0;
}
cmd = commandManager->findCommand(completions.at(0));
Q_ASSERT(cmd != 0);
}
if (!cmd) {
messageHandler->message(
QtWarningMsg,
QString::fromLatin1("Undefined command \"%0\". Try \"help\".")
.arg(name));
return 0;
}
}
QStringList args;
QString tmp = command.mid(i+1);
if (cmd->argumentTypes().contains(QString::fromLatin1("script"))) {
if (!tmp.isEmpty())
args.append(tmp);
} else {
args = tmp.split(QLatin1Char(' '), QString::SkipEmptyParts);
}
return cmd->createJob(args, q_func(), messageHandler, commandScheduler);
}
QScriptDebuggerConsole::QScriptDebuggerConsole()
: d_ptr(new QScriptDebuggerConsolePrivate(this))
{
}
QScriptDebuggerConsole::~QScriptDebuggerConsole()
{
}
void QScriptDebuggerConsole::loadScriptedCommands(QScriptMessageHandlerInterface *messageHandler)
{
Q_D(QScriptDebuggerConsole);
d->loadScriptedCommands(messageHandler);
}
QScriptDebuggerConsoleCommandManager *QScriptDebuggerConsole::commandManager() const
{
Q_D(const QScriptDebuggerConsole);
return d->commandManager;
}
bool QScriptDebuggerConsole::hasIncompleteInput() const
{
Q_D(const QScriptDebuggerConsole);
return !d->input.isEmpty();
}
QString QScriptDebuggerConsole::incompleteInput() const
{
Q_D(const QScriptDebuggerConsole);
return d->input;
}
void QScriptDebuggerConsole::setIncompleteInput(const QString &input)
{
Q_D(QScriptDebuggerConsole);
d->input = input;
}
QString QScriptDebuggerConsole::commandPrefix() const
{
Q_D(const QScriptDebuggerConsole);
return d->commandPrefix;
}
/*!
Consumes the given line of \a input. If the input starts with the
command prefix, it is regarded as a debugger command; otherwise the
input is evaluated as a plain script.
*/
QScriptDebuggerConsoleCommandJob *QScriptDebuggerConsole::consumeInput(
const QString &input, QScriptMessageHandlerInterface *messageHandler,
QScriptDebuggerCommandSchedulerInterface *commandScheduler)
{
Q_D(QScriptDebuggerConsole);
static const int maximumHistoryCount = 100;
QString cmd;
if (d->input.isEmpty() && input.isEmpty()) {
if (d->commandHistory.isEmpty())
return 0;
cmd = d->commandHistory.first();
} else {
cmd = input;
}
if (d->input.isEmpty() && cmd.startsWith(d->commandPrefix)) {
if (!input.isEmpty()) {
d->commandHistory.prepend(cmd);
if (d->commandHistory.size() > maximumHistoryCount)
d->commandHistory.removeLast();
}
cmd.remove(0, d->commandPrefix.length());
return d->createJob(cmd, messageHandler, commandScheduler);
}
d->input += cmd;
d->input += QLatin1Char('\n');
QScriptSyntaxCheckResult check = QScriptEngine::checkSyntax(d->input);
if (check.state() == QScriptSyntaxCheckResult::Intermediate)
return 0;
d->input.chop(1); // remove the last \n
cmd = QString();
cmd.append(d->commandPrefix);
cmd.append(QString::fromLatin1("eval "));
cmd.append(d->input);
d->commandHistory.prepend(cmd);
if (d->commandHistory.size() > maximumHistoryCount)
d->commandHistory.removeLast();
d->input.clear();
cmd.remove(0, d->commandPrefix.length());
return d->createJob(cmd, messageHandler, commandScheduler);
}
int QScriptDebuggerConsole::currentFrameIndex() const
{
Q_D(const QScriptDebuggerConsole);
return d->currentFrameIndex;
}
void QScriptDebuggerConsole::setCurrentFrameIndex(int index)
{
Q_D(QScriptDebuggerConsole);
d->currentFrameIndex = index;
}
qint64 QScriptDebuggerConsole::currentScriptId() const
{
Q_D(const QScriptDebuggerConsole);
return d->currentScriptId;
}
void QScriptDebuggerConsole::setCurrentScriptId(qint64 id)
{
Q_D(QScriptDebuggerConsole);
d->currentScriptId = id;
}
int QScriptDebuggerConsole::currentLineNumber() const
{
Q_D(const QScriptDebuggerConsole);
return d->currentLineNumber;
}
void QScriptDebuggerConsole::setCurrentLineNumber(int lineNumber)
{
Q_D(QScriptDebuggerConsole);
d->currentLineNumber = lineNumber;
}
int QScriptDebuggerConsole::evaluateAction() const
{
Q_D(const QScriptDebuggerConsole);
return d->evaluateAction;
}
void QScriptDebuggerConsole::setEvaluateAction(int action)
{
Q_D(QScriptDebuggerConsole);
d->evaluateAction = action;
}
qint64 QScriptDebuggerConsole::sessionId() const
{
Q_D(const QScriptDebuggerConsole);
return d->sessionId;
}
void QScriptDebuggerConsole::bumpSessionId()
{
Q_D(QScriptDebuggerConsole);
++d->sessionId;
}
void QScriptDebuggerConsole::showDebuggerInfoMessage(
QScriptMessageHandlerInterface *messageHandler)
{
messageHandler->message(
QtDebugMsg,
QString::fromLatin1(
"Welcome to the Qt Script debugger.\n"
"Debugger commands start with a . (period).\n"
"Any other input will be evaluated by the script interpreter.\n"
"Type \".help\" for help.\n"));
}
/*!
\reimp
*/
int QScriptDebuggerConsole::historyCount() const
{
Q_D(const QScriptDebuggerConsole);
return d->commandHistory.size();
}
/*!
\reimp
*/
QString QScriptDebuggerConsole::historyAt(int index) const
{
Q_D(const QScriptDebuggerConsole);
return d->commandHistory.value(index);
}
/*!
\reimp
*/
void QScriptDebuggerConsole::changeHistoryAt(int index, const QString &newHistory)
{
Q_D(QScriptDebuggerConsole);
d->commandHistory[index] = newHistory;
}
QT_END_NAMESPACE

View file

@ -1,100 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTDEBUGGERCONSOLE_P_H
#define QSCRIPTDEBUGGERCONSOLE_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtCore/qobjectdefs.h>
#include <QtCore/qscopedpointer.h>
#include "qscriptdebuggerconsolehistorianinterface_p.h"
QT_BEGIN_NAMESPACE
class QString;
class QScriptDebuggerConsoleCommandJob;
class QScriptMessageHandlerInterface;
class QScriptDebuggerCommandSchedulerInterface;
class QScriptDebuggerConsoleCommandManager;
class QScriptDebuggerConsolePrivate;
class Q_AUTOTEST_EXPORT QScriptDebuggerConsole
: public QScriptDebuggerConsoleHistorianInterface
{
public:
QScriptDebuggerConsole();
~QScriptDebuggerConsole();
void loadScriptedCommands(QScriptMessageHandlerInterface *messageHandler);
void showDebuggerInfoMessage(QScriptMessageHandlerInterface *messageHandler);
QScriptDebuggerConsoleCommandManager *commandManager() const;
QScriptDebuggerConsoleCommandJob *consumeInput(
const QString &input,
QScriptMessageHandlerInterface *messageHandler,
QScriptDebuggerCommandSchedulerInterface *commandScheduler);
bool hasIncompleteInput() const;
QString incompleteInput() const;
void setIncompleteInput(const QString &input);
QString commandPrefix() const;
int historyCount() const;
QString historyAt(int index) const;
void changeHistoryAt(int index, const QString &newHistory);
int currentFrameIndex() const;
void setCurrentFrameIndex(int index);
qint64 currentScriptId() const;
void setCurrentScriptId(qint64 id);
int currentLineNumber() const;
void setCurrentLineNumber(int lineNumber);
int evaluateAction() const;
void setEvaluateAction(int action);
qint64 sessionId() const;
void bumpSessionId();
private:
QScopedPointer<QScriptDebuggerConsolePrivate> d_ptr;
Q_DECLARE_PRIVATE(QScriptDebuggerConsole)
Q_DISABLE_COPY(QScriptDebuggerConsole)
};
QT_END_NAMESPACE
#endif

View file

@ -1,125 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qscriptdebuggerconsolecommand_p.h"
#include "qscriptdebuggerconsolecommand_p_p.h"
#include <QtCore/qstringlist.h>
QT_BEGIN_NAMESPACE
/*!
\since 4.5
\class QScriptDebuggerConsoleCommand
\internal
\brief The QScriptDebuggerConsoleCommand class is the base class of console commands.
\sa QScriptDebuggerConsoleCommandManager
*/
QScriptDebuggerConsoleCommandPrivate::QScriptDebuggerConsoleCommandPrivate()
{
}
QScriptDebuggerConsoleCommandPrivate::~QScriptDebuggerConsoleCommandPrivate()
{
}
QScriptDebuggerConsoleCommand::QScriptDebuggerConsoleCommand()
: d_ptr(new QScriptDebuggerConsoleCommandPrivate)
{
}
QScriptDebuggerConsoleCommand::~QScriptDebuggerConsoleCommand()
{
}
QScriptDebuggerConsoleCommand::QScriptDebuggerConsoleCommand(QScriptDebuggerConsoleCommandPrivate &dd)
: d_ptr(&dd)
{
}
/*!
\fn QString QScriptDebuggerConsoleCommand::name() const
Returns the name of this console command.
*/
/*!
\fn QString QScriptDebuggerConsoleCommand::group() const
Returns the group that this console command belongs to.
*/
/*!
\fn QString QScriptDebuggerConsoleCommand::shortDescription() const
Returns a short (one line) description of the command.
*/
/*!
\fn QString QScriptDebuggerConsoleCommand::longDescription() const
Returns a detailed description of how to use the command.
*/
/*!
\fn QScriptDebuggerConsoleCommandJob *QScriptDebuggerConsoleCommand::createJob(
const QStringList &arguments,
QScriptDebuggerConsole *console,
QScriptMessageHandlerInterface *messageHandler,
QScriptDebuggerCommandSchedulerInterface *scheduler) = 0
Creates a job that will execute this command with the given \a
arguments. If the command cannot be executed (e.g. because one or
more arguments are invalid), a suitable error message should be
output to the \a messageHandler, and 0 should be returned.
*/
/*!
Returns a list of names of commands that may also be of interest to
users of this command.
*/
QStringList QScriptDebuggerConsoleCommand::seeAlso() const
{
return QStringList();
}
/*!
Returns a list of aliases for this command.
*/
QStringList QScriptDebuggerConsoleCommand::aliases() const
{
return QStringList();
}
QStringList QScriptDebuggerConsoleCommand::argumentTypes() const
{
return QStringList();
}
QStringList QScriptDebuggerConsoleCommand::subCommands() const
{
return QStringList();
}
QT_END_NAMESPACE

View file

@ -1,85 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTDEBUGGERCONSOLECOMMAND_P_H
#define QSCRIPTDEBUGGERCONSOLECOMMAND_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtCore/qobjectdefs.h>
#include <QtCore/qscopedpointer.h>
#include <QtCore/qlist.h>
QT_BEGIN_NAMESPACE
class QString;
class QStringList;
class QScriptDebuggerConsole;
class QScriptDebuggerConsoleCommandJob;
class QScriptMessageHandlerInterface;
class QScriptDebuggerCommandSchedulerInterface;
class QScriptDebuggerConsoleCommandPrivate;
class Q_AUTOTEST_EXPORT QScriptDebuggerConsoleCommand
{
public:
QScriptDebuggerConsoleCommand();
virtual ~QScriptDebuggerConsoleCommand();
virtual QString name() const = 0;
virtual QString group() const = 0;
virtual QString shortDescription() const = 0;
virtual QString longDescription() const = 0;
virtual QStringList seeAlso() const;
virtual QStringList aliases() const;
virtual QStringList argumentTypes() const;
virtual QStringList subCommands() const;
virtual QScriptDebuggerConsoleCommandJob *createJob(
const QStringList &arguments,
QScriptDebuggerConsole *console,
QScriptMessageHandlerInterface *messageHandler,
QScriptDebuggerCommandSchedulerInterface *scheduler) = 0;
protected:
QScriptDebuggerConsoleCommand(QScriptDebuggerConsoleCommandPrivate &dd);
QScopedPointer<QScriptDebuggerConsoleCommandPrivate> d_ptr;
private:
Q_DECLARE_PRIVATE(QScriptDebuggerConsoleCommand)
Q_DISABLE_COPY(QScriptDebuggerConsoleCommand)
};
typedef QList<QScriptDebuggerConsoleCommand*> QScriptDebuggerConsoleCommandList;
QT_END_NAMESPACE
#endif

View file

@ -1,50 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTDEBUGGERCONSOLECOMMAND_P_P_H
#define QSCRIPTDEBUGGERCONSOLECOMMAND_P_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtCore/qobjectdefs.h>
QT_BEGIN_NAMESPACE
class QScriptDebuggerConsoleCommand;
class QScriptDebuggerConsoleCommandPrivate
{
public:
QScriptDebuggerConsoleCommandPrivate();
virtual ~QScriptDebuggerConsoleCommandPrivate();
};
QT_END_NAMESPACE
#endif

View file

@ -1,106 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qscriptdebuggerconsolecommandgroupdata_p.h"
#include <QtCore/qstring.h>
#include <QtCore/qshareddata.h>
QT_BEGIN_NAMESPACE
/*!
\since 4.5
\class QScriptDebuggerConsoleCommandGroupData
\internal
\brief The QScriptDebuggerConsoleCommandGroupData class holds data associated with a console command group.
*/
class QScriptDebuggerConsoleCommandGroupDataPrivate : public QSharedData
{
public:
QScriptDebuggerConsoleCommandGroupDataPrivate();
~QScriptDebuggerConsoleCommandGroupDataPrivate();
QString shortDescription;
QString longDescription;
};
QScriptDebuggerConsoleCommandGroupDataPrivate::QScriptDebuggerConsoleCommandGroupDataPrivate()
{
}
QScriptDebuggerConsoleCommandGroupDataPrivate::~QScriptDebuggerConsoleCommandGroupDataPrivate()
{
}
QScriptDebuggerConsoleCommandGroupData::QScriptDebuggerConsoleCommandGroupData()
: d_ptr(0)
{
}
QScriptDebuggerConsoleCommandGroupData::QScriptDebuggerConsoleCommandGroupData(
const QString &shortDescription, const QString &longDescription)
: d_ptr(new QScriptDebuggerConsoleCommandGroupDataPrivate)
{
d_ptr->shortDescription = shortDescription;
d_ptr->longDescription = longDescription;
d_ptr->ref.ref();
}
QScriptDebuggerConsoleCommandGroupData::QScriptDebuggerConsoleCommandGroupData(
const QScriptDebuggerConsoleCommandGroupData &other)
: d_ptr(other.d_ptr.data())
{
if (d_ptr)
d_ptr->ref.ref();
}
QScriptDebuggerConsoleCommandGroupData::~QScriptDebuggerConsoleCommandGroupData()
{
}
QScriptDebuggerConsoleCommandGroupData &QScriptDebuggerConsoleCommandGroupData::operator=(
const QScriptDebuggerConsoleCommandGroupData &other)
{
d_ptr.assign(other.d_ptr.data());
return *this;
}
QString QScriptDebuggerConsoleCommandGroupData::shortDescription() const
{
Q_D(const QScriptDebuggerConsoleCommandGroupData);
return d->shortDescription;
}
QString QScriptDebuggerConsoleCommandGroupData::longDescription() const
{
Q_D(const QScriptDebuggerConsoleCommandGroupData);
return d->longDescription;
}
bool QScriptDebuggerConsoleCommandGroupData::isValid() const
{
Q_D(const QScriptDebuggerConsoleCommandGroupData);
return (d != 0);
}
QT_END_NAMESPACE

View file

@ -1,75 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTDEBUGGERCONSOLECOMMANDGROUPDATA_P_H
#define QSCRIPTDEBUGGERCONSOLECOMMANDGROUPDATA_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Katie API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include "qobjectdefs.h"
#include "qscopedpointer_p.h"
#include "qmap.h"
QT_BEGIN_NAMESPACE
class QString;
class QScriptDebuggerConsoleCommandGroupDataPrivate;
class Q_AUTOTEST_EXPORT QScriptDebuggerConsoleCommandGroupData
{
public:
QScriptDebuggerConsoleCommandGroupData();
QScriptDebuggerConsoleCommandGroupData(
const QString &shortDescription,
const QString &longDescription);
QScriptDebuggerConsoleCommandGroupData(
const QScriptDebuggerConsoleCommandGroupData &other);
~QScriptDebuggerConsoleCommandGroupData();
QString shortDescription() const;
QString longDescription() const;
bool isValid() const;
QScriptDebuggerConsoleCommandGroupData &operator=(
const QScriptDebuggerConsoleCommandGroupData &other);
private:
QScopedSharedPointer<QScriptDebuggerConsoleCommandGroupDataPrivate> d_ptr;
private:
Q_DECLARE_PRIVATE(QScriptDebuggerConsoleCommandGroupData)
};
typedef QMap<QString, QScriptDebuggerConsoleCommandGroupData> QScriptDebuggerConsoleCommandGroupMap;
QT_END_NAMESPACE
#endif

View file

@ -1,65 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtSCriptTools module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qscriptdebuggerconsolecommandjob_p.h"
#include "qscriptdebuggerconsolecommandjob_p_p.h"
#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
QScriptDebuggerConsoleCommandJobPrivate::QScriptDebuggerConsoleCommandJobPrivate()
{
}
QScriptDebuggerConsoleCommandJobPrivate::~QScriptDebuggerConsoleCommandJobPrivate()
{
}
QScriptDebuggerConsoleCommandJob::QScriptDebuggerConsoleCommandJob(
QScriptDebuggerConsole *console,
QScriptMessageHandlerInterface *messageHandler,
QScriptDebuggerCommandSchedulerInterface *scheduler)
: QScriptDebuggerCommandSchedulerJob(*new QScriptDebuggerConsoleCommandJobPrivate,
scheduler)
{
Q_D(QScriptDebuggerConsoleCommandJob);
d->console = console;
d->messageHandler = messageHandler;
}
QScriptDebuggerConsoleCommandJob::~QScriptDebuggerConsoleCommandJob()
{
}
QScriptDebuggerConsoleCommandJob::QScriptDebuggerConsoleCommandJob(
QScriptDebuggerConsoleCommandJobPrivate &dd,
QScriptDebuggerConsole *console,
QScriptMessageHandlerInterface *messageHandler,
QScriptDebuggerCommandSchedulerInterface *scheduler)
: QScriptDebuggerCommandSchedulerJob(dd, scheduler)
{
Q_D(QScriptDebuggerConsoleCommandJob);
d->console = console;
d->messageHandler = messageHandler;
}
QT_END_NAMESPACE

Some files were not shown because too many files have changed in this diff Show more