Ignore:
Timestamp:
Mar 2, 2014, 4:41:56 PM (8 years ago)
Author:
s10k
Message:

XmlTools
Some more little optimizations and updated readme

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XmlTools2/trunk/xmlcustomcode.cpp

    r964 r967  
    3737            // alternatively you can do: myFunc=engine.evaluate('(function main(){})'); myFunc.call();
    3838            // Note the () around the function
    39             this->getXmlDataFunctions.append(new QScriptValue(this->scriptEngines[i]->evaluate("(function getXmlData() { return $xmlData; })")));
    40             this->setXmlDataFunctions.append(new QScriptValue(this->scriptEngines[i]->evaluate("(function setXmlData(newXmlData) { $xmlData=newXmlData; })")));
     39            this->getXmlDataFunctions.append(new QScriptValue(this->scriptEngines.at(i)->evaluate("(function getXmlData() { return $xmlData; })")));
     40            this->setXmlDataFunctions.append(new QScriptValue(this->scriptEngines.at(i)->evaluate("(function setXmlData(newXmlData) { $xmlData=newXmlData; })")));
    4141
    4242            // Add echo function so user can debug the code
    43             QScriptValue echoFunction = this->scriptEngines[i]->newFunction(echo);
    44             this->scriptEngines[i]->globalObject().setProperty("echo", echoFunction);
     43            QScriptValue echoFunction = this->scriptEngines.at(i)->newFunction(echo);
     44            this->scriptEngines.at(i)->globalObject().setProperty("echo", echoFunction);
    4545
    4646            // Add the js library for XmlEditing
    47             this->scriptEngines[i]->evaluate(jsxmlString);
     47            this->scriptEngines.at(i)->evaluate(jsxmlString);
    4848        }
    4949    }
     
    5454    // Reconstruct script functions
    5555    for(int i=0; i<this->numThreads; i++){
    56         *this->jsFunctions[i]=this->scriptEngines[i]->evaluate("(function main() {"+jsString+"})");
     56        *this->jsFunctions[i]=this->scriptEngines.at(i)->evaluate("(function main() {"+jsString+"})");
    5757    }
    5858
     
    6363    clock_t begin; // seconds that a script started
    6464
    65     // Single tread if small files
     65    // Single tread if small number of files
    6666    if(filesToProcess.size()<CUSTOM_FILES_PER_THREAD){
    6767        // Process all XmlFiles
    6868        for(int i=0; i<filesToProcess.size(); i++){
    6969
    70             customCodeUnwinding(filesToProcess.at(i),currXmlFileString,*this->scriptEngines[0],begin,elapsed_secs,engineResult,
    71                     *this->jsFunctions[0],*this->getXmlDataFunctions[0],*this->setXmlDataFunctions[0],backupsEnabled,verboseEnabled);
     70            customCodeUnwinding(filesToProcess.at(i),currXmlFileString,*this->scriptEngines.at(0),begin,elapsed_secs,engineResult,
     71                    *this->jsFunctions.at(0),*this->getXmlDataFunctions.at(0),*this->setXmlDataFunctions.at(0),backupsEnabled,verboseEnabled);
    7272        }
    7373    }
     
    8585            clock_t beginThread; // seconds that a script started
    8686
    87             customCodeUnwinding(filesToProcess.at(i),currXmlFileStringThread,*this->scriptEngines[tid],beginThread,elapsedSecsThread,engineResultThread,
    88                                 *this->jsFunctions[tid],*this->getXmlDataFunctions[tid],*this->setXmlDataFunctions[tid],backupsEnabled,verboseEnabled);
     87            customCodeUnwinding(filesToProcess.at(i),currXmlFileStringThread,*this->scriptEngines.at(tid),beginThread,elapsedSecsThread,engineResultThread,
     88                                *this->jsFunctions.at(tid),*this->getXmlDataFunctions.at(tid),*this->setXmlDataFunctions.at(tid),backupsEnabled,verboseEnabled);
    8989
    90             customCodeUnwinding(filesToProcess.at(i+1),currXmlFileStringThread,*this->scriptEngines[tid],beginThread,elapsedSecsThread,engineResultThread,
    91                                 *this->jsFunctions[tid],*this->getXmlDataFunctions[tid],*this->setXmlDataFunctions[tid],backupsEnabled,verboseEnabled);
     90            customCodeUnwinding(filesToProcess.at(i+1),currXmlFileStringThread,*this->scriptEngines.at(tid),beginThread,elapsedSecsThread,engineResultThread,
     91                                *this->jsFunctions.at(tid),*this->getXmlDataFunctions.at(tid),*this->setXmlDataFunctions.at(tid),backupsEnabled,verboseEnabled);
    9292        }
    9393
     
    9898            for(int i=alreadyProcessedFiles; i<filesToProcess.size(); i++){
    9999
    100                 customCodeUnwinding(filesToProcess.at(i),currXmlFileString,*this->scriptEngines[0],begin,elapsed_secs,engineResult,
    101                         *this->jsFunctions[0],*this->getXmlDataFunctions[0],*this->setXmlDataFunctions[0],backupsEnabled,verboseEnabled);
     100                customCodeUnwinding(filesToProcess.at(i),currXmlFileString,*this->scriptEngines.at(0),begin,elapsed_secs,engineResult,
     101                        *this->jsFunctions.at(0),*this->getXmlDataFunctions.at(0),*this->setXmlDataFunctions.at(0),backupsEnabled,verboseEnabled);
    102102            }
    103103        }
Note: See TracChangeset for help on using the changeset viewer.