| 211 |
|
UtilXmlTools::displaySuccessMessage(1,"@COMMAND"); |
| 212 |
|
} |
| 213 |
|
|
| 214 |
+ |
QScriptValue echo(QScriptContext *context, QScriptEngine *engine) |
| 215 |
+ |
{ |
| 216 |
+ |
std::cout << context->argument(0).toString().toUtf8().constData() << std::endl; |
| 217 |
+ |
|
| 218 |
+ |
return ""; |
| 219 |
+ |
} |
| 220 |
+ |
|
| 221 |
|
void XmlPatch::executeCustomCommandOperation(const QString &jsString, const QString &filesWildcard){ |
| 222 |
|
|
| 223 |
|
QStringList filesToProcess; |
| 235 |
|
QFile rexmlfile(":/resources/libs/rexml.js"); |
| 236 |
|
QFile jsxmlfile(":/resources/libs/jsxml.js"); |
| 237 |
|
|
| 238 |
+ |
// Add echo function so user can debug the code |
| 239 |
+ |
QScriptValue echoFunction = engine.newFunction(echo); |
| 240 |
+ |
engine.globalObject().setProperty("echo", echoFunction); |
| 241 |
+ |
|
| 242 |
|
filesToProcess=UtilXmlTools::getAllXmlFilesByWildcard(filesWildcard); |
| 243 |
|
|
| 244 |
|
if(filesToProcess.isEmpty()){ |
| 273 |
|
|
| 274 |
|
engine.globalObject().setProperty("$xmlData",currXmlFileString); |
| 275 |
|
|
| 276 |
< |
engineResult=engine.evaluate(jsString); |
| 276 |
> |
// main needs to be called so the user code is evaluated |
| 277 |
> |
engineResult=engine.evaluate("main(); function main() {"+jsString+"}"); // main funtion allows to use return to exit prematurely from user code |
| 278 |
|
|
| 279 |
|
#ifdef _USE_OLD_JS_ENGINE |
| 280 |
|
if (engine.hasUncaughtException()) { |