diff options
author | Stefan Radomski <github@mintwerk.de> | 2017-07-19 14:41:34 (GMT) |
---|---|---|
committer | Stefan Radomski <github@mintwerk.de> | 2017-07-19 14:41:34 (GMT) |
commit | aa341b878e6d4a2be8890ca5f890e46b87cf2d7d (patch) | |
tree | f35363f7ca5be90f5a4ca1d93210e96698f89d59 /src/apps | |
parent | 9db80409b3ca048c4b404a43d2c224f374c0090a (diff) | |
download | uscxml-aa341b878e6d4a2be8890ca5f890e46b87cf2d7d.zip uscxml-aa341b878e6d4a2be8890ca5f890e46b87cf2d7d.tar.gz uscxml-aa341b878e6d4a2be8890ca5f890e46b87cf2d7d.tar.bz2 |
Beautified code
Diffstat (limited to 'src/apps')
-rw-r--r-- | src/apps/uscxml-browser.cpp | 124 | ||||
-rw-r--r-- | src/apps/uscxml-transform.cpp | 102 |
2 files changed, 113 insertions, 113 deletions
diff --git a/src/apps/uscxml-browser.cpp b/src/apps/uscxml-browser.cpp index dd0633b..bda1efe 100644 --- a/src/apps/uscxml-browser.cpp +++ b/src/apps/uscxml-browser.cpp @@ -25,32 +25,32 @@ int main(int argc, char** argv) { InterpreterOptions::printUsageAndExit(argv[0]); } - if (!options.validate) { - // setup HTTP server - HTTPServer::SSLConfig* sslConf = NULL; - if (options.certificate.length() > 0) { - sslConf = new HTTPServer::SSLConfig(); - sslConf->privateKey = options.certificate; - sslConf->publicKey = options.certificate; - sslConf->port = options.httpsPort; - - } else if (options.privateKey.length() > 0 && options.publicKey.length() > 0) { - sslConf = new HTTPServer::SSLConfig(); - sslConf->privateKey = options.privateKey; - sslConf->publicKey = options.publicKey; - sslConf->port = options.httpsPort; - - } - HTTPServer::getInstance(options.httpPort, options.wsPort, sslConf); - } - - if (options.pluginPath.length() > 0) { - Factory::setDefaultPluginPath(options.pluginPath); - } - - if (options.verbose) { - Factory::getInstance()->listComponents(); - } + if (!options.validate) { + // setup HTTP server + HTTPServer::SSLConfig* sslConf = NULL; + if (options.certificate.length() > 0) { + sslConf = new HTTPServer::SSLConfig(); + sslConf->privateKey = options.certificate; + sslConf->publicKey = options.certificate; + sslConf->port = options.httpsPort; + + } else if (options.privateKey.length() > 0 && options.publicKey.length() > 0) { + sslConf = new HTTPServer::SSLConfig(); + sslConf->privateKey = options.privateKey; + sslConf->publicKey = options.publicKey; + sslConf->port = options.httpsPort; + + } + HTTPServer::getInstance(options.httpPort, options.wsPort, sslConf); + } + + if (options.pluginPath.length() > 0) { + Factory::setDefaultPluginPath(options.pluginPath); + } + + if (options.verbose) { + Factory::getInstance()->listComponents(); + } // instantiate and configure interpreters std::list<Interpreter> interpreters; @@ -73,7 +73,7 @@ int main(int argc, char** argv) { if (issues.size() == 0) { LOGD(USCXML_DEBUG) << "No issues found" << std::endl; } - + } if (options.verbose) { @@ -92,41 +92,41 @@ int main(int argc, char** argv) { } } - if (options.validate) { - return EXIT_SUCCESS; - } - - if (options.withDebugger) { - DebuggerServlet* debugger; - debugger = new DebuggerServlet(); - debugger->copyToInvokers(true); - HTTPServer::getInstance()->registerServlet("/debug", debugger); - for (auto interpreter : interpreters) { - interpreter.addMonitor(debugger); - } - } - + if (options.validate) { + return EXIT_SUCCESS; + } + + if (options.withDebugger) { + DebuggerServlet* debugger; + debugger = new DebuggerServlet(); + debugger->copyToInvokers(true); + HTTPServer::getInstance()->registerServlet("/debug", debugger); + for (auto interpreter : interpreters) { + interpreter.addMonitor(debugger); + } + } + // run interpreters - if (interpreters.size() > 0) { - try { - std::list<Interpreter>::iterator interpreterIter = interpreters.begin(); - while (interpreters.size() > 0) { - while(interpreterIter != interpreters.end()) { - InterpreterState state = interpreterIter->step(); - if (state == USCXML_FINISHED) { - interpreterIter = interpreters.erase(interpreterIter); - } else { - interpreterIter++; - } - } - interpreterIter = interpreters.begin(); - } - } catch (Event e) { - LOGD(USCXML_ERROR) << e << std::endl; - } - } else if (options.withDebugger) { - while(true) - std::this_thread::sleep_for(std::chrono::seconds(1)); - } + if (interpreters.size() > 0) { + try { + std::list<Interpreter>::iterator interpreterIter = interpreters.begin(); + while (interpreters.size() > 0) { + while(interpreterIter != interpreters.end()) { + InterpreterState state = interpreterIter->step(); + if (state == USCXML_FINISHED) { + interpreterIter = interpreters.erase(interpreterIter); + } else { + interpreterIter++; + } + } + interpreterIter = interpreters.begin(); + } + } catch (Event e) { + LOGD(USCXML_ERROR) << e << std::endl; + } + } else if (options.withDebugger) { + while(true) + std::this_thread::sleep_for(std::chrono::seconds(1)); + } return EXIT_SUCCESS; } diff --git a/src/apps/uscxml-transform.cpp b/src/apps/uscxml-transform.cpp index e99ed68..572fb27 100644 --- a/src/apps/uscxml-transform.cpp +++ b/src/apps/uscxml-transform.cpp @@ -40,8 +40,8 @@ void printUsageAndExit(const char* progName) { printf("Options\n"); printf("\t-t c : convert to C program\n"); printf("\t-t pml : convert to spin/promela program\n"); - printf("\t-t vhdl : convert to VHDL hardware description\n"); - printf("\t-t java : convert to Java classes\n"); + printf("\t-t vhdl : convert to VHDL hardware description\n"); + printf("\t-t java : convert to Java classes\n"); printf("\t-t flat : flatten to SCXML state-machine\n"); printf("\t-a FILE : write annotated SCXML document for transformation\n"); printf("\t-X {PARAMETER} : pass additional parameters to the transformation\n"); @@ -60,8 +60,8 @@ int main(int argc, char** argv) { bool verbose = false; std::string outType; std::string pluginPath; - std::string inputFile; - std::string annotatedFile; + std::string inputFile; + std::string annotatedFile; std::string outputFile; std::list<std::string> options; std::multimap<std::string, std::string> extensions; @@ -112,7 +112,7 @@ int main(int argc, char** argv) { inputFile = optarg; break; case 'a': - annotatedFile = optarg; + annotatedFile = optarg; break; case 'X': { std::list<std::string> extension = tokenize(optarg, '='); @@ -125,7 +125,7 @@ int main(int argc, char** argv) { break; case 'o': outputFile = optarg; - extensions.insert(std::pair<std::string, std::string>("outputFile", outputFile)); + extensions.insert(std::pair<std::string, std::string>("outputFile", outputFile)); break; case 'l': break; @@ -190,8 +190,8 @@ int main(int argc, char** argv) { outType != "scxml" && outType != "pml" && outType != "c" && - outType != "vhdl" && - outType != "java" && + outType != "vhdl" && + outType != "java" && outType != "min" && std::find(options.begin(), options.end(), "priority") == options.end() && std::find(options.begin(), options.end(), "domain") == options.end() && @@ -218,7 +218,7 @@ int main(int argc, char** argv) { ss << line; } URL tmp("anonymous.scxml"); - tmp = URL::resolveWithCWD(tmp); + tmp = URL::resolveWithCWD(tmp); interpreter = Interpreter::fromXML(ss.str(), tmp); } else { interpreter = Interpreter::fromURL(inputFile); @@ -231,8 +231,8 @@ int main(int argc, char** argv) { if (!interpreter) { URL tmp(inputFile); - tmp = URL::resolveWithCWD(tmp); - std::string content = tmp.getInContent(); + tmp = URL::resolveWithCWD(tmp); + std::string content = tmp.getInContent(); std::string inlineBeginMarker = "INLINE SCXML BEGIN\n"; std::string inlineEndMarker = "\nINLINE SCXML END"; @@ -267,12 +267,12 @@ int main(int argc, char** argv) { } } - Transformer transformer; + Transformer transformer; if (outType == "c") { transformer = ChartToC::transform(interpreter); transformer.setExtensions(extensions); transformer.setOptions(options); - + if (outputFile.size() == 0 || outputFile == "-") { transformer.writeTo(std::cout); } else { @@ -283,25 +283,25 @@ int main(int argc, char** argv) { } } - if (outType == "java") { - transformer = ChartToJava::transform(interpreter); - transformer.setExtensions(extensions); - transformer.setOptions(options); - - if (outputFile.size() == 0 || outputFile == "-") { - transformer.writeTo(std::cout); - } else { - std::ofstream outStream; - outStream.open(outputFile.c_str()); - transformer.writeTo(outStream); - outStream.close(); - } - } + if (outType == "java") { + transformer = ChartToJava::transform(interpreter); + transformer.setExtensions(extensions); + transformer.setOptions(options); + + if (outputFile.size() == 0 || outputFile == "-") { + transformer.writeTo(std::cout); + } else { + std::ofstream outStream; + outStream.open(outputFile.c_str()); + transformer.writeTo(outStream); + outStream.close(); + } + } if (outType == "vhdl") { - transformer = ChartToVHDL::transform(interpreter); - transformer.setExtensions(extensions); - transformer.setOptions(options); + transformer = ChartToVHDL::transform(interpreter); + transformer.setExtensions(extensions); + transformer.setOptions(options); if (outputFile.size() == 0 || outputFile == "-") { transformer.writeTo(std::cout); @@ -314,18 +314,18 @@ int main(int argc, char** argv) { } if (outType == "pml") { - transformer = ChartToPromela::transform(interpreter); - transformer.setExtensions(extensions); - transformer.setOptions(options); - - if (outputFile.size() == 0 || outputFile == "-") { - transformer.writeTo(std::cout); - } else { - std::ofstream outStream; - outStream.open(outputFile.c_str()); - transformer.writeTo(outStream); - outStream.close(); - } + transformer = ChartToPromela::transform(interpreter); + transformer.setExtensions(extensions); + transformer.setOptions(options); + + if (outputFile.size() == 0 || outputFile == "-") { + transformer.writeTo(std::cout); + } else { + std::ofstream outStream; + outStream.open(outputFile.c_str()); + transformer.writeTo(outStream); + outStream.close(); + } } // if (outType == "tex") { @@ -364,22 +364,22 @@ int main(int argc, char** argv) { // exit(EXIT_SUCCESS); // } - if (annotatedFile.size() > 0) { - std::ofstream outStream; - outStream.open(annotatedFile.c_str()); - outStream << (*transformer.getImpl()->getDocument()); - outStream.close(); + if (annotatedFile.size() > 0) { + std::ofstream outStream; + outStream.open(annotatedFile.c_str()); + outStream << (*transformer.getImpl()->getDocument()); + outStream.close(); - } + } } catch (Event e) { std::cout << e << std::endl; - return EXIT_FAILURE; + return EXIT_FAILURE; } catch (const std::exception &e) { std::cout << e.what() << std::endl; - return EXIT_FAILURE; + return EXIT_FAILURE; } - return EXIT_SUCCESS; + return EXIT_SUCCESS; } |