new feature: «for»-loop; updated buildsystem
This commit is contained in:
@@ -2234,7 +2234,11 @@ class For: public Command {
|
||||
" <...>"
|
||||
"\n\n"
|
||||
"Executes the given commands with the variable set to the specifier values,"
|
||||
"repeated once per given value. Without values, it is simply a no operation.\n\n";
|
||||
"repeated once per given value. The variable is treated like a local variale"
|
||||
" in the loop.\n\n"
|
||||
"Without values, if there is a global variable with the same name as the"
|
||||
" local variable the global variable is parsed as if it were the line after"
|
||||
" the dash (->).\n\n";
|
||||
"If you quote the values, then quote all values with the same"
|
||||
" quotes. If you need a comma within a value, you must quote.";
|
||||
}
|
||||
@@ -2242,17 +2246,28 @@ class For: public Command {
|
||||
return tag()+" "+_variable+" "+_vals.join(" ");
|
||||
}
|
||||
std::shared_ptr<Command> parse(Script*, QString args,
|
||||
QStringList&, QString, int, int) {
|
||||
QStringList& in, QString file, int line, int indent) {
|
||||
std::shared_ptr<For> cmd(new For());
|
||||
if (!args.size()) throw BadArgument(tag()+" requires a <variable>");
|
||||
QStringList allargs(args.split("->"));
|
||||
...
|
||||
cmd->_variable = allargs.takeFirst().trimmed();
|
||||
cmd->_vals = commaSeparatedList(allargs.join(' '));
|
||||
cmd->_script = std::shared_ptr<Script>(new Script);
|
||||
cmd->_script->parse(subCommandBlock(in), file, line+1, indent+1);
|
||||
return cmd;
|
||||
}
|
||||
bool execute(Script* script, QWebFrame* frame) {
|
||||
Logger log(this, script);
|
||||
Q_FOREACH(QString i, _vals.size()?_vals:commaSeparatedList(script->variable(_variable))) {
|
||||
if (!runScript(this, _script, script, frame, QStringList()<<_variable, QStringList()<<i))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private:
|
||||
QString _variable;
|
||||
QStringList _vals;
|
||||
std::shared_ptr<Script> _script;
|
||||
};
|
||||
|
||||
/* Template:
|
||||
@@ -2377,6 +2392,7 @@ inline void Script::initPrototypes() {
|
||||
add(new TestSuite);
|
||||
add(new TestCase);
|
||||
add(new Check);
|
||||
add(new For);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user