ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/XmlTools2/trunk/xmlpatch.cpp
(Generate patch)

Comparing XmlTools2/trunk/xmlpatch.cpp (file contents):
Revision 956 by s10k, Wed Feb 12 22:15:52 2014 UTC vs.
Revision 958 by s10k, Sat Feb 15 01:36:05 2014 UTC

# Line 244 | Line 244 | void XmlPatch::executeCustomCommandOpera
244  
245          QScriptEngine engine;
246          QScriptValue engineResult; // variable to check for js_errors
247 +        double elapsed_secs; // elapsed seconds that a user script took
248 +        clock_t begin; // seconds that a script started
249  
250          // Add echo function so user can debug the code
251          QScriptValue echoFunction = engine.newFunction(echo);
# Line 268 | Line 270 | void XmlPatch::executeCustomCommandOpera
270  
271          engine.globalObject().setProperty("$xmlData",currXmlFileString);
272  
273 +        if(this->verboseEnabled){
274 +            begin = clock();
275 +        }
276 +
277          // main needs to be called so the user code is evaluated
278 +        // alternatively you can do: myFunc=engine.evaluate('(function main(){})'); myFunc.call();
279 +        // Note the () around the function
280          engineResult=engine.evaluate("main(); function main() {"+jsString+"}"); // main funtion allows to use return to exit prematurely from user code
281  
282 +        if(this->verboseEnabled){
283 +            elapsed_secs = double(clock() - begin) / CLOCKS_PER_SEC;
284 +
285 +            // Warn the user if the script took much time
286 +            if(elapsed_secs>SLOW_SCRIPT_TIME){
287 +                std::cout << "Warning: Slow javascript code detected.\n" <<
288 +                             "Warning: Script execution seconds: " << elapsed_secs
289 +                          << std::endl;
290 +            }
291 +        }
292 +
293          if (engine.hasUncaughtException()) {
294              displayJsException(engine,engineResult);
295          }
# Line 432 | Line 451 | void XmlPatch::checkAndProcessValidComma
451  
452              // Add --no-backups and --no-verbose if patch was called with that arguments
453              if(!this->backupsEnabled){
454 <                command.append(" --no-backups");
454 >                command.append(" --no-backups ");
455              }
456  
457              if(!this->verboseEnabled){
458 <                command.append(" --no-verbose");
458 >                command.append(" --no-verbose ");
459              }
460  
461              command.replace("'","\""); //replace apostrophe by quotes, to avoid problems

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)