summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Radomski <github@mintwerk.de>2017-07-19 14:41:34 (GMT)
committerStefan Radomski <github@mintwerk.de>2017-07-19 14:41:34 (GMT)
commitaa341b878e6d4a2be8890ca5f890e46b87cf2d7d (patch)
treef35363f7ca5be90f5a4ca1d93210e96698f89d59
parent9db80409b3ca048c4b404a43d2c224f374c0090a (diff)
downloaduscxml-aa341b878e6d4a2be8890ca5f890e46b87cf2d7d.zip
uscxml-aa341b878e6d4a2be8890ca5f890e46b87cf2d7d.tar.gz
uscxml-aa341b878e6d4a2be8890ca5f890e46b87cf2d7d.tar.bz2
Beautified code
-rw-r--r--src/apps/uscxml-browser.cpp124
-rw-r--r--src/apps/uscxml-transform.cpp102
-rw-r--r--src/uscxml/Interpreter.cpp2
-rw-r--r--src/uscxml/Interpreter.h6
-rw-r--r--src/uscxml/interpreter/BasicContentExecutor.cpp160
-rw-r--r--src/uscxml/interpreter/ContentExecutorImpl.h2
-rw-r--r--src/uscxml/interpreter/FastMicroStep.cpp150
-rw-r--r--src/uscxml/interpreter/InterpreterImpl.cpp14
-rw-r--r--src/uscxml/interpreter/InterpreterImpl.h16
-rw-r--r--src/uscxml/interpreter/InterpreterMonitor.h574
-rw-r--r--src/uscxml/plugins/DataModel.cpp2
-rw-r--r--src/uscxml/plugins/DataModel.h4
-rw-r--r--src/uscxml/plugins/DataModelImpl.h22
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp4
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h2
-rw-r--r--src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp58
-rw-r--r--src/uscxml/plugins/datamodel/lua/LuaDataModel.h2
-rw-r--r--src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp4
-rw-r--r--test/src/test-snippets.cpp28
19 files changed, 638 insertions, 638 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;
}
diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp
index f3aedee..6146546 100644
--- a/src/uscxml/Interpreter.cpp
+++ b/src/uscxml/Interpreter.cpp
@@ -272,7 +272,7 @@ std::list<InterpreterIssue> Interpreter::validate() {
}
LambdaMonitor& Interpreter::on() {
- return _impl->on();
+ return _impl->on();
}
#if 1
diff --git a/src/uscxml/Interpreter.h b/src/uscxml/Interpreter.h
index aff77a2..7cf8a0e 100644
--- a/src/uscxml/Interpreter.h
+++ b/src/uscxml/Interpreter.h
@@ -236,9 +236,9 @@ public:
std::shared_ptr<InterpreterImpl> getImpl() const {
return _impl;
}
-
- LambdaMonitor& on();
-
+
+ LambdaMonitor& on();
+
#if 0
// "Ambiguous user-defined-conversion" with operator bool() on MSVC from Visual Studio 12
explicit operator MicroStepCallbacks*() {
diff --git a/src/uscxml/interpreter/BasicContentExecutor.cpp b/src/uscxml/interpreter/BasicContentExecutor.cpp
index 9ea2b6a..87c2180 100644
--- a/src/uscxml/interpreter/BasicContentExecutor.cpp
+++ b/src/uscxml/interpreter/BasicContentExecutor.cpp
@@ -593,89 +593,89 @@ void BasicContentExecutor::processParams(std::multimap<std::string, Data>& param
paramMap.insert(make_pair(name, d));
}
}
-
+
Data BasicContentExecutor::elementAsData(XERCESC_NS::DOMElement* element, bool asExpression) {
- // element with expr
- if (HAS_ATTR(element, kXMLCharExpr)) {
- std::string expr = ATTR(element, kXMLCharExpr);
- if (_callbacks->isLegalDataValue(expr)) {
- return Data(expr, Data::INTERPRETED);
- } else {
- ERROR_EXECUTION_THROW2("Expression '" + expr + "' is not a legal data value", element);
- }
- }
-
- // element with external src - this ought to behave just as with child nodes below
- if (HAS_ATTR(element, kXMLCharSource)) {
-
- // remove any old child elements
- while(element->getFirstElementChild() != NULL) {
- element->removeChild(element->getFirstElementChild());
- }
-
- std::string src = ATTR(element, kXMLCharSource);
- URL url(ATTR(element, kXMLCharSource));
- if (!url.isAbsolute()) {
- url = URL::resolve(url, _callbacks->getBaseURL());
- }
- std::string content = url.getInContent();
-
- // append as XML?
- try {
- std::unique_ptr<XERCESC_NS::XercesDOMParser> parser(new XERCESC_NS::XercesDOMParser());
- parser->setValidationScheme(XERCESC_NS::XercesDOMParser::Val_Always);
- parser->setDoNamespaces(true);
- parser->useScanner(XERCESC_NS::XMLUni::fgWFXMLScanner);
-
- std::unique_ptr<XERCESC_NS::ErrorHandler> errHandler(new XERCESC_NS::HandlerBase());
- parser->setErrorHandler(errHandler.get());
-
- XERCESC_NS::MemBufInputSource is((XMLByte*)content.c_str(), content.size(), X("fake"));
- is.setPublicId(X(url));
-
- parser->parse(is);
- XERCESC_NS::DOMNode* newNode = element->getOwnerDocument()->importNode(parser->getDocument()->getDocumentElement(), true);
-
- // we need to save the DOM somewhere .. Data::adoptedDoc was not good enough
- element->appendChild(newNode);
- goto SOURCE_APPEND_DONE;
- } catch (...) {
- }
-
- // append as text (are we leaking?)
- XERCESC_NS::DOMText* textNode = element->getOwnerDocument()->createTextNode(X(content));
- element->appendChild(textNode);
- }
+ // element with expr
+ if (HAS_ATTR(element, kXMLCharExpr)) {
+ std::string expr = ATTR(element, kXMLCharExpr);
+ if (_callbacks->isLegalDataValue(expr)) {
+ return Data(expr, Data::INTERPRETED);
+ } else {
+ ERROR_EXECUTION_THROW2("Expression '" + expr + "' is not a legal data value", element);
+ }
+ }
+
+ // element with external src - this ought to behave just as with child nodes below
+ if (HAS_ATTR(element, kXMLCharSource)) {
+
+ // remove any old child elements
+ while(element->getFirstElementChild() != NULL) {
+ element->removeChild(element->getFirstElementChild());
+ }
+
+ std::string src = ATTR(element, kXMLCharSource);
+ URL url(ATTR(element, kXMLCharSource));
+ if (!url.isAbsolute()) {
+ url = URL::resolve(url, _callbacks->getBaseURL());
+ }
+ std::string content = url.getInContent();
+
+ // append as XML?
+ try {
+ std::unique_ptr<XERCESC_NS::XercesDOMParser> parser(new XERCESC_NS::XercesDOMParser());
+ parser->setValidationScheme(XERCESC_NS::XercesDOMParser::Val_Always);
+ parser->setDoNamespaces(true);
+ parser->useScanner(XERCESC_NS::XMLUni::fgWFXMLScanner);
+
+ std::unique_ptr<XERCESC_NS::ErrorHandler> errHandler(new XERCESC_NS::HandlerBase());
+ parser->setErrorHandler(errHandler.get());
+
+ XERCESC_NS::MemBufInputSource is((XMLByte*)content.c_str(), content.size(), X("fake"));
+ is.setPublicId(X(url));
+
+ parser->parse(is);
+ XERCESC_NS::DOMNode* newNode = element->getOwnerDocument()->importNode(parser->getDocument()->getDocumentElement(), true);
+
+ // we need to save the DOM somewhere .. Data::adoptedDoc was not good enough
+ element->appendChild(newNode);
+ goto SOURCE_APPEND_DONE;
+ } catch (...) {
+ }
+
+ // append as text (are we leaking?)
+ XERCESC_NS::DOMText* textNode = element->getOwnerDocument()->createTextNode(X(content));
+ element->appendChild(textNode);
+ }
SOURCE_APPEND_DONE:
- if (element->hasChildNodes()) {
- // XML elements e.g. for content with invoke
- std::list<DOMNode*> elementChildren = DOMUtils::filterChildType(DOMNode::ELEMENT_NODE, element);
- if (elementChildren.size() > 0) {
- // always return parent element, even with a single child node
- return Data(static_cast<DOMNode*>(element));
- }
-
- // expression in text element
- std::list<DOMNode*> textChildren = DOMUtils::filterChildType(DOMNode::TEXT_NODE, element);
- if (textChildren.size() > 0) {
- std::stringstream contentSS;
- for (auto textIter = textChildren.begin(); textIter != textChildren.end(); textIter++) {
- contentSS << X((*textIter)->getNodeValue());
- }
-
- try {
- Data d = _callbacks->getAsData(contentSS.str());
- if (!d.empty())
- return d;
- } catch(...) {}
-
- // anything else is considered verbatim - space normalize?
- return Data(spaceNormalize(contentSS.str()), Data::VERBATIM);
- }
- }
-
- return Data();
+ if (element->hasChildNodes()) {
+ // XML elements e.g. for content with invoke
+ std::list<DOMNode*> elementChildren = DOMUtils::filterChildType(DOMNode::ELEMENT_NODE, element);
+ if (elementChildren.size() > 0) {
+ // always return parent element, even with a single child node
+ return Data(static_cast<DOMNode*>(element));
+ }
+
+ // expression in text element
+ std::list<DOMNode*> textChildren = DOMUtils::filterChildType(DOMNode::TEXT_NODE, element);
+ if (textChildren.size() > 0) {
+ std::stringstream contentSS;
+ for (auto textIter = textChildren.begin(); textIter != textChildren.end(); textIter++) {
+ contentSS << X((*textIter)->getNodeValue());
+ }
+
+ try {
+ Data d = _callbacks->getAsData(contentSS.str());
+ if (!d.empty())
+ return d;
+ } catch(...) {}
+
+ // anything else is considered verbatim - space normalize?
+ return Data(spaceNormalize(contentSS.str()), Data::VERBATIM);
+ }
+ }
+
+ return Data();
}
}
diff --git a/src/uscxml/interpreter/ContentExecutorImpl.h b/src/uscxml/interpreter/ContentExecutorImpl.h
index 0c080ca..8221591 100644
--- a/src/uscxml/interpreter/ContentExecutorImpl.h
+++ b/src/uscxml/interpreter/ContentExecutorImpl.h
@@ -62,7 +62,7 @@ public:
virtual Data evalAsData(const std::string& expr) = 0;
virtual void eval(const std::string& expr) = 0;
virtual Data getAsData(const std::string& expr) = 0;
- virtual bool isLegalDataValue(const std::string& expr) = 0;
+ virtual bool isLegalDataValue(const std::string& expr) = 0;
virtual void assign(const std::string& location, const Data& data, const std::map<std::string, std::string>& attrs) = 0;
diff --git a/src/uscxml/interpreter/FastMicroStep.cpp b/src/uscxml/interpreter/FastMicroStep.cpp
index 1258279..78aada9 100644
--- a/src/uscxml/interpreter/FastMicroStep.cpp
+++ b/src/uscxml/interpreter/FastMicroStep.cpp
@@ -511,7 +511,7 @@ COMPLETION_STABLISHED:
// std::list<Transition*> transSpontaneous;
// std::list<Transition*> transEventful;
-
+
for (i = 0; i < _transitions.size(); i++) {
_transitions[i] = new Transition(i);
_transitions[i]->element = tmp.front();
@@ -583,9 +583,9 @@ TARGET_SET_ESTABLISHED:
if (!HAS_ATTR(_transitions[i]->element, kXMLCharEvent)) {
_transitions[i]->type |= USCXML_TRANS_SPONTANEOUS;
// transSpontaneous.push_back(_transitions[i]);
- } else {
+ } else {
// transEventful.push_back(_transitions[i]);
- }
+ }
if (iequals(TAGNAME_CAST(_transitions[i]->element->getParentNode()), _xmlPrefix.str() + "history")) {
_transitions[i]->type |= USCXML_TRANS_HISTORY;
@@ -618,81 +618,81 @@ TARGET_SET_ESTABLISHED:
* This bound by cache locality!
* Before you change anything, do benchmark!
*/
-
+
#if 0
#define exit1 _exitSets[t1->postFixOrder]
#define exit2 _exitSets[t2->postFixOrder]
- for (size_t set = 0; set < 2; set++) {
- std::list<Transition*>::const_iterator transBegin;
- std::list<Transition*>::const_iterator transEnd;
- if (set == 0) {
- transBegin = transEventful.begin();
- transEnd = transEventful.end();
- } else {
- transBegin = transSpontaneous.begin();
- transEnd = transSpontaneous.end();
- }
-
- for (auto t1Iter = transBegin; t1Iter != transEnd; t1Iter++) {
- Transition* t1 = *t1Iter;
- auto anc1 = _states[t1->source]->ancestors;
- const uint32_t source1 = t1->source;
-
- for (auto t2Iter = t1Iter; t2Iter != transEnd; t2Iter++) {
- Transition* t2 = *t2Iter;
-
- if (exit1.first == 0 && exit2.first == 0) {
- goto COMPATIBLE_TRANS;
- }
-
- if (exit1.first <= exit2.first && exit1.second >= exit2.first) {
- goto CONFLICTING_TRANS;
- }
-
- if (exit2.first <= exit1.first && exit2.second >= exit1.first) {
- goto CONFLICTING_TRANS;
- }
-
- COMPATIBLE_TRANS:
- if (t2->source == source1) {
- goto CONFLICTING_TRANS;
- }
-
- if (anc1[t2->source]) {
- goto CONFLICTING_TRANS;
- }
-
- if (_states[t2->source]->ancestors[source1]) {
- goto CONFLICTING_TRANS;
- }
-
- t1->conflicts[t2->postFixOrder] = false;
- // _transitions[j]->conflicts[i] = false;
- continue;
-
- CONFLICTING_TRANS:
- t1->conflicts[t2->postFixOrder] = true;
- // _transitions[j]->conflicts[i] = true;
-
- continue;
-
- }
- }
-
- for (auto t1Iter = transBegin; t1Iter != transEnd; t1Iter++) {
- Transition* t1 = *t1Iter;
- // conflicts matrix is symmetric
- for (auto t2Iter = transBegin; t2Iter != t1Iter; t2Iter++) {
- Transition* t2 = *t2Iter;
-
- t1->conflicts[t2->postFixOrder] = t2->conflicts[t1->postFixOrder];
- }
- }
-
- }
-
-
+ for (size_t set = 0; set < 2; set++) {
+ std::list<Transition*>::const_iterator transBegin;
+ std::list<Transition*>::const_iterator transEnd;
+ if (set == 0) {
+ transBegin = transEventful.begin();
+ transEnd = transEventful.end();
+ } else {
+ transBegin = transSpontaneous.begin();
+ transEnd = transSpontaneous.end();
+ }
+
+ for (auto t1Iter = transBegin; t1Iter != transEnd; t1Iter++) {
+ Transition* t1 = *t1Iter;
+ auto anc1 = _states[t1->source]->ancestors;
+ const uint32_t source1 = t1->source;
+
+ for (auto t2Iter = t1Iter; t2Iter != transEnd; t2Iter++) {
+ Transition* t2 = *t2Iter;
+
+ if (exit1.first == 0 && exit2.first == 0) {
+ goto COMPATIBLE_TRANS;
+ }
+
+ if (exit1.first <= exit2.first && exit1.second >= exit2.first) {
+ goto CONFLICTING_TRANS;
+ }
+
+ if (exit2.first <= exit1.first && exit2.second >= exit1.first) {
+ goto CONFLICTING_TRANS;
+ }
+
+COMPATIBLE_TRANS:
+ if (t2->source == source1) {
+ goto CONFLICTING_TRANS;
+ }
+
+ if (anc1[t2->source]) {
+ goto CONFLICTING_TRANS;
+ }
+
+ if (_states[t2->source]->ancestors[source1]) {
+ goto CONFLICTING_TRANS;
+ }
+
+ t1->conflicts[t2->postFixOrder] = false;
+ // _transitions[j]->conflicts[i] = false;
+ continue;
+
+CONFLICTING_TRANS:
+ t1->conflicts[t2->postFixOrder] = true;
+ // _transitions[j]->conflicts[i] = true;
+
+ continue;
+
+ }
+ }
+
+ for (auto t1Iter = transBegin; t1Iter != transEnd; t1Iter++) {
+ Transition* t1 = *t1Iter;
+ // conflicts matrix is symmetric
+ for (auto t2Iter = transBegin; t2Iter != t1Iter; t2Iter++) {
+ Transition* t2 = *t2Iter;
+
+ t1->conflicts[t2->postFixOrder] = t2->conflicts[t1->postFixOrder];
+ }
+ }
+
+ }
+
+
#else
#define anc1 _states[_transitions[i]->source]->ancestors
#define exit1 _exitSets[i]
@@ -748,7 +748,7 @@ CONFLICTING_TRANS:
}
}
#endif
-
+
// initialize bitarrays for step()
_exitSet = boost::dynamic_bitset<BITSET_BLOCKTYPE>(_states.size(), false);
_entrySet = boost::dynamic_bitset<BITSET_BLOCKTYPE>(_states.size(), false);
diff --git a/src/uscxml/interpreter/InterpreterImpl.cpp b/src/uscxml/interpreter/InterpreterImpl.cpp
index 1caa3f0..185ad75 100644
--- a/src/uscxml/interpreter/InterpreterImpl.cpp
+++ b/src/uscxml/interpreter/InterpreterImpl.cpp
@@ -103,8 +103,8 @@ InterpreterImpl::~InterpreterImpl() {
if (_document)
delete _document;
- if (_lambdaMonitor)
- delete _lambdaMonitor;
+ if (_lambdaMonitor)
+ delete _lambdaMonitor;
{
std::lock_guard<std::recursive_mutex> lock(_instanceMutex);
@@ -626,11 +626,11 @@ void InterpreterImpl::enqueueAtParent(const Event& event) {
}
LambdaMonitor& InterpreterImpl::on() {
- if (_lambdaMonitor == NULL) {
- _lambdaMonitor = new LambdaMonitor();
- addMonitor(_lambdaMonitor);
- }
- return *_lambdaMonitor;
+ if (_lambdaMonitor == NULL) {
+ _lambdaMonitor = new LambdaMonitor();
+ addMonitor(_lambdaMonitor);
+ }
+ return *_lambdaMonitor;
}
}
diff --git a/src/uscxml/interpreter/InterpreterImpl.h b/src/uscxml/interpreter/InterpreterImpl.h
index 1f87fd2..cb31988 100644
--- a/src/uscxml/interpreter/InterpreterImpl.h
+++ b/src/uscxml/interpreter/InterpreterImpl.h
@@ -196,9 +196,9 @@ public:
return _dataModel.getAsData(expr);
}
- virtual bool isLegalDataValue(const std::string& expr) {
- return _dataModel.isLegalDataValue(expr);
- }
+ virtual bool isLegalDataValue(const std::string& expr) {
+ return _dataModel.isLegalDataValue(expr);
+ }
virtual void assign(const std::string& location, const Data& data, const std::map<std::string, std::string>& attrs);
@@ -273,13 +273,13 @@ public:
return _document;
}
- LambdaMonitor& on();
-
+ LambdaMonitor& on();
+
protected:
static void addInstance(std::shared_ptr<InterpreterImpl> instance);
-
- LambdaMonitor* _lambdaMonitor = NULL;
-
+
+ LambdaMonitor* _lambdaMonitor = NULL;
+
Binding _binding;
ActionLanguage _al;
diff --git a/src/uscxml/interpreter/InterpreterMonitor.h b/src/uscxml/interpreter/InterpreterMonitor.h
index ed62675..64c281c 100644
--- a/src/uscxml/interpreter/InterpreterMonitor.h
+++ b/src/uscxml/interpreter/InterpreterMonitor.h
@@ -66,46 +66,46 @@ public:
virtual ~InterpreterMonitor() {}
virtual void beforeProcessingEvent(const std::string& sessionId,
- const Event& event) {}
+ const Event& event) {}
virtual void beforeMicroStep(const std::string& sessionId) {}
virtual void beforeExitingState(const std::string& sessionId,
- const std::string& stateName,
- const XERCESC_NS::DOMElement* state) {}
+ const std::string& stateName,
+ const XERCESC_NS::DOMElement* state) {}
virtual void afterExitingState(const std::string& sessionId,
- const std::string& stateName,
- const XERCESC_NS::DOMElement* state) {}
+ const std::string& stateName,
+ const XERCESC_NS::DOMElement* state) {}
virtual void beforeExecutingContent(const std::string& sessionId,
- const XERCESC_NS::DOMElement* execContent) {}
+ const XERCESC_NS::DOMElement* execContent) {}
virtual void afterExecutingContent(const std::string& sessionId,
- const XERCESC_NS::DOMElement* execContent) {}
+ const XERCESC_NS::DOMElement* execContent) {}
virtual void beforeUninvoking(const std::string& sessionId,
- const XERCESC_NS::DOMElement* invokeElem,
- const std::string& invokeid) {}
+ const XERCESC_NS::DOMElement* invokeElem,
+ const std::string& invokeid) {}
virtual void afterUninvoking(const std::string& sessionId,
- const XERCESC_NS::DOMElement* invokeElem,
- const std::string& invokeid) {}
+ const XERCESC_NS::DOMElement* invokeElem,
+ const std::string& invokeid) {}
virtual void beforeTakingTransition(const std::string& sessionId,
- const XERCESC_NS::DOMElement* transition) {}
+ const XERCESC_NS::DOMElement* transition) {}
virtual void afterTakingTransition(const std::string& sessionId,
- const XERCESC_NS::DOMElement* transition) {}
+ const XERCESC_NS::DOMElement* transition) {}
virtual void beforeEnteringState(const std::string& sessionId,
- const std::string& stateName,
- const XERCESC_NS::DOMElement* state) {}
+ const std::string& stateName,
+ const XERCESC_NS::DOMElement* state) {}
virtual void afterEnteringState(const std::string& sessionId,
- const std::string& stateName,
- const XERCESC_NS::DOMElement* state) {}
+ const std::string& stateName,
+ const XERCESC_NS::DOMElement* state) {}
virtual void beforeInvoking(const std::string& sessionId,
- const XERCESC_NS::DOMElement* invokeElem,
- const std::string& invokeid) {}
+ const XERCESC_NS::DOMElement* invokeElem,
+ const std::string& invokeid) {}
virtual void afterInvoking(const std::string& sessionId,
- const XERCESC_NS::DOMElement* invokeElem,
- const std::string& invokeid) {}
+ const XERCESC_NS::DOMElement* invokeElem,
+ const std::string& invokeid) {}
virtual void afterMicroStep(const std::string& sessionId) {}
virtual void onStableConfiguration(const std::string& sessionId) {}
@@ -114,7 +114,7 @@ public:
virtual void afterCompletion(const std::string& sessionId) {}
virtual void reportIssue(const std::string& sessionId,
- const InterpreterIssue& issue) {}
+ const InterpreterIssue& issue) {}
void copyToInvokers(bool copy) {
_copyToInvokers = copy;
@@ -149,273 +149,273 @@ protected:
class USCXML_API LambdaMonitor : public InterpreterMonitor {
public:
- void processEvent(std::function<void (const std::string& sessionId,
- const Event& event)> callback) {
- _beforeProcessingEvent = callback;
- }
-
-
- void microStep(std::function<void (const std::string& sessionId)> callback,
- bool after = false) {
- if (after) {
- _afterMicroStep = callback;
- } else {
- _beforeMicroStep = callback;
- }
-
- }
-
- void exitState(std::function<void (const std::string& sessionId,
- const std::string& stateName,
- const XERCESC_NS::DOMElement* state)> callback,
- bool after = false) {
- if (after) {
- _afterExitingState = callback;
- } else {
- _beforeExitingState = callback;
- }
- }
-
- void executeContent(std::function<void (const std::string& sessionId,
- const XERCESC_NS::DOMElement* execContent)> callback,
- bool after = false) {
- if (after) {
- _afterExecutingContent = callback;
- } else {
- _beforeExecutingContent = callback;
- }
- }
-
- void uninvoke(std::function<void (const std::string& sessionId,
- const XERCESC_NS::DOMElement* invokeElem,
- const std::string& invokeid)> callback,
- bool after = false) {
- if (after) {
- _afterUninvoking = callback;
- } else {
- _beforeUninvoking = callback;
- }
- }
-
- void transition(std::function<void (const std::string& sessionId,
- const XERCESC_NS::DOMElement* transition)> callback,
- bool after = false) {
- if (after) {
- _afterTakingTransition = callback;
- } else {
- _beforeTakingTransition = callback;
- }
- }
-
- void enterState(std::function<void (const std::string& sessionId,
- const std::string& stateName,
- const XERCESC_NS::DOMElement* state)> callback,
- bool after = false) {
- _beforeEnteringState = callback;
- if (after) {
- _afterEnteringState = callback;
- } else {
- _beforeEnteringState = callback;
- }
-
- }
-
- void invoke(std::function<void (const std::string& sessionId,
- const XERCESC_NS::DOMElement* invokeElem,
- const std::string& invokeid)> callback,
- bool after = false) {
- if (after) {
- _afterInvoking = callback;
- } else {
- _beforeInvoking = callback;
- }
- }
-
- void stableConfiguration(std::function<void (const std::string& sessionId)> callback) {
- _onStableConfiguration = callback;
- }
-
- void completion(std::function<void (const std::string& sessionId)> callback,
- bool after = false) {
- if (after) {
- _afterCompletion = callback;
- } else {
- _beforeCompletion = callback;
- }
-
- }
-
- void reportIssue(std::function<void (const std::string& sessionId,
- const InterpreterIssue& issue)> callback) {
- _reportIssue = callback;
- }
+ void processEvent(std::function<void (const std::string& sessionId,
+ const Event& event)> callback) {
+ _beforeProcessingEvent = callback;
+ }
+
+
+ void microStep(std::function<void (const std::string& sessionId)> callback,
+ bool after = false) {
+ if (after) {
+ _afterMicroStep = callback;
+ } else {
+ _beforeMicroStep = callback;
+ }
+
+ }
+
+ void exitState(std::function<void (const std::string& sessionId,
+ const std::string& stateName,
+ const XERCESC_NS::DOMElement* state)> callback,
+ bool after = false) {
+ if (after) {
+ _afterExitingState = callback;
+ } else {
+ _beforeExitingState = callback;
+ }
+ }
+
+ void executeContent(std::function<void (const std::string& sessionId,
+ const XERCESC_NS::DOMElement* execContent)> callback,
+ bool after = false) {
+ if (after) {
+ _afterExecutingContent = callback;
+ } else {
+ _beforeExecutingContent = callback;
+ }
+ }
+
+ void uninvoke(std::function<void (const std::string& sessionId,
+ const XERCESC_NS::DOMElement* invokeElem,
+ const std::string& invokeid)> callback,
+ bool after = false) {
+ if (after) {
+ _afterUninvoking = callback;
+ } else {
+ _beforeUninvoking = callback;
+ }
+ }
+
+ void transition(std::function<void (const std::string& sessionId,
+ const XERCESC_NS::DOMElement* transition)> callback,
+ bool after = false) {
+ if (after) {
+ _afterTakingTransition = callback;
+ } else {
+ _beforeTakingTransition = callback;
+ }
+ }
+
+ void enterState(std::function<void (const std::string& sessionId,
+ const std::string& stateName,
+ const XERCESC_NS::DOMElement* state)> callback,
+ bool after = false) {
+ _beforeEnteringState = callback;
+ if (after) {
+ _afterEnteringState = callback;
+ } else {
+ _beforeEnteringState = callback;
+ }
+
+ }
+
+ void invoke(std::function<void (const std::string& sessionId,
+ const XERCESC_NS::DOMElement* invokeElem,
+ const std::string& invokeid)> callback,
+ bool after = false) {
+ if (after) {
+ _afterInvoking = callback;
+ } else {
+ _beforeInvoking = callback;
+ }
+ }
+
+ void stableConfiguration(std::function<void (const std::string& sessionId)> callback) {
+ _onStableConfiguration = callback;
+ }
+
+ void completion(std::function<void (const std::string& sessionId)> callback,
+ bool after = false) {
+ if (after) {
+ _afterCompletion = callback;
+ } else {
+ _beforeCompletion = callback;
+ }
+
+ }
+
+ void reportIssue(std::function<void (const std::string& sessionId,
+ const InterpreterIssue& issue)> callback) {
+ _reportIssue = callback;
+ }
protected:
-
- std::function<void (const std::string& sessionId,
- const Event& event)> _beforeProcessingEvent;
-
- std::function<void (const std::string& sessionId)> _beforeMicroStep;
-
- std::function<void (const std::string& sessionId,
- const std::string& stateName,
- const XERCESC_NS::DOMElement* state)> _beforeExitingState;
-
- std::function<void (const std::string& sessionId,
- const std::string& stateName,
- const XERCESC_NS::DOMElement* state)> _afterExitingState;
-
- std::function<void (const std::string& sessionId,
- const XERCESC_NS::DOMElement* execContent)> _beforeExecutingContent;
- std::function<void (const std::string& sessionId,
- const XERCESC_NS::DOMElement* execContent)> _afterExecutingContent;
-
- std::function<void (const std::string& sessionId,
- const XERCESC_NS::DOMElement* invokeElem,
- const std::string& invokeid)> _beforeUninvoking;
- std::function<void (const std::string& sessionId,
- const XERCESC_NS::DOMElement* invokeElem,
- const std::string& invokeid)> _afterUninvoking;
-
- std::function<void (const std::string& sessionId,
- const XERCESC_NS::DOMElement* transition)> _beforeTakingTransition;
- std::function<void (const std::string& sessionId,
- const XERCESC_NS::DOMElement* transition)> _afterTakingTransition;
-
- std::function<void (const std::string& sessionId,
- const std::string& stateName,
- const XERCESC_NS::DOMElement* state)> _beforeEnteringState;
- std::function<void (const std::string& sessionId,
- const std::string& stateName,
- const XERCESC_NS::DOMElement* state)> _afterEnteringState;
-
- std::function<void (const std::string& sessionId,
- const XERCESC_NS::DOMElement* invokeElem,
- const std::string& invokeid)> _beforeInvoking;
- std::function<void (const std::string& sessionId,
- const XERCESC_NS::DOMElement* invokeElem,
- const std::string& invokeid)> _afterInvoking;
-
- std::function<void (const std::string& sessionId)> _afterMicroStep;
- std::function<void (const std::string& sessionId)> _onStableConfiguration;
-
- std::function<void (const std::string& sessionId)> _beforeCompletion;
- std::function<void (const std::string& sessionId)> _afterCompletion;
-
- std::function<void (const std::string& sessionId,
- const InterpreterIssue& issue)> _reportIssue;
-
-
-
- void beforeProcessingEvent(const std::string& sessionId,
- const Event& event) {
- if (_beforeProcessingEvent)
- _beforeProcessingEvent(sessionId, event);
- }
- void beforeMicroStep(const std::string& sessionId) {
- if (_beforeMicroStep)
- _beforeMicroStep(sessionId);
- }
-
- void beforeExitingState(const std::string& sessionId,
- const std::string& stateName,
- const XERCESC_NS::DOMElement* state) {
- if (_beforeExitingState)
- _beforeExitingState(sessionId, stateName, state);
- }
-
- void afterExitingState(const std::string& sessionId,
- const std::string& stateName,
- const XERCESC_NS::DOMElement* state) {
- if (_afterExitingState)
- _afterExitingState(sessionId, stateName, state);
- }
-
- void beforeExecutingContent(const std::string& sessionId,
- const XERCESC_NS::DOMElement* execContent) {
- if (_beforeExecutingContent)
- _beforeExecutingContent(sessionId, execContent);
- }
- void afterExecutingContent(const std::string& sessionId,
- const XERCESC_NS::DOMElement* execContent) {
- if (_afterExecutingContent)
- _afterExecutingContent(sessionId, execContent);
-
- }
-
- void beforeUninvoking(const std::string& sessionId,
- const XERCESC_NS::DOMElement* invokeElem,
- const std::string& invokeid) {
- if (_beforeUninvoking)
- _beforeUninvoking(sessionId, invokeElem, invokeid);
- }
- void afterUninvoking(const std::string& sessionId,
- const XERCESC_NS::DOMElement* invokeElem,
- const std::string& invokeid) {
- if (_afterUninvoking)
- _afterUninvoking(sessionId, invokeElem, invokeid);
- }
-
- void beforeTakingTransition(const std::string& sessionId,
- const XERCESC_NS::DOMElement* transition) {
- if (_beforeTakingTransition)
- _beforeTakingTransition(sessionId, transition);
- }
- void afterTakingTransition(const std::string& sessionId,
- const XERCESC_NS::DOMElement* transition) {
- if (_afterTakingTransition)
- _afterTakingTransition(sessionId, transition);
- }
-
- void beforeEnteringState(const std::string& sessionId,
- const std::string& stateName,
- const XERCESC_NS::DOMElement* state) {
- if (_beforeEnteringState)
- _beforeEnteringState(sessionId, stateName, state);
- }
- void afterEnteringState(const std::string& sessionId,
- const std::string& stateName,
- const XERCESC_NS::DOMElement* state) {
- if (_afterEnteringState)
- _afterEnteringState(sessionId, stateName, state);
- }
-
- void beforeInvoking(const std::string& sessionId,
- const XERCESC_NS::DOMElement* invokeElem,
- const std::string& invokeid) {
- if (_beforeInvoking)
- _beforeInvoking(sessionId, invokeElem, invokeid);
- }
- void afterInvoking(const std::string& sessionId,
- const XERCESC_NS::DOMElement* invokeElem,
- const std::string& invokeid) {
- if (_afterInvoking)
- _afterInvoking(sessionId, invokeElem, invokeid);
- }
-
- void afterMicroStep(const std::string& sessionId) {
- if (_afterMicroStep)
- _afterMicroStep(sessionId);
- }
- void onStableConfiguration(const std::string& sessionId) {
- if (_onStableConfiguration)
- _onStableConfiguration(sessionId);
- }
-
- void beforeCompletion(const std::string& sessionId) {
- if (_beforeCompletion)
- _beforeCompletion(sessionId);
- }
- void afterCompletion(const std::string& sessionId) {
- if (_afterCompletion)
- _afterCompletion(sessionId);
- }
-
- void reportIssue(const std::string& sessionId,
- const InterpreterIssue& issue) {
- if (_reportIssue)
- _reportIssue(sessionId, issue);
- }
+
+ std::function<void (const std::string& sessionId,
+ const Event& event)> _beforeProcessingEvent;
+
+ std::function<void (const std::string& sessionId)> _beforeMicroStep;
+
+ std::function<void (const std::string& sessionId,
+ const std::string& stateName,
+ const XERCESC_NS::DOMElement* state)> _beforeExitingState;
+
+ std::function<void (const std::string& sessionId,
+ const std::string& stateName,
+ const XERCESC_NS::DOMElement* state)> _afterExitingState;
+
+ std::function<void (const std::string& sessionId,
+ const XERCESC_NS::DOMElement* execContent)> _beforeExecutingContent;
+ std::function<void (const std::string& sessionId,
+ const XERCESC_NS::DOMElement* execContent)> _afterExecutingContent;
+
+ std::function<void (const std::string& sessionId,
+ const XERCESC_NS::DOMElement* invokeElem,
+ const std::string& invokeid)> _beforeUninvoking;
+ std::function<void (const std::string& sessionId,
+ const XERCESC_NS::DOMElement* invokeElem,
+ const std::string& invokeid)> _afterUninvoking;
+
+ std::function<void (const std::string& sessionId,
+ const XERCESC_NS::DOMElement* transition)> _beforeTakingTransition;
+ std::function<void (const std::string& sessionId,
+ const XERCESC_NS::DOMElement* transition)> _afterTakingTransition;
+
+ std::function<void (const std::string& sessionId,
+ const std::string& stateName,
+ const XERCESC_NS::DOMElement* state)> _beforeEnteringState;
+ std::function<void (const std::string& sessionId,
+ const std::string& stateName,
+ const XERCESC_NS::DOMElement* state)> _afterEnteringState;
+
+ std::function<void (const std::string& sessionId,
+ const XERCESC_NS::DOMElement* invokeElem,
+ const std::string& invokeid)> _beforeInvoking;
+ std::function<void (const std::string& sessionId,
+ const XERCESC_NS::DOMElement* invokeElem,
+ const std::string& invokeid)> _afterInvoking;
+
+ std::function<void (const std::string& sessionId)> _afterMicroStep;
+ std::function<void (const std::string& sessionId)> _onStableConfiguration;
+
+ std::function<void (const std::string& sessionId)> _beforeCompletion;
+ std::function<void (const std::string& sessionId)> _afterCompletion;
+
+ std::function<void (const std::string& sessionId,
+ const InterpreterIssue& issue)> _reportIssue;
+
+
+
+ void beforeProcessingEvent(const std::string& sessionId,
+ const Event& event) {
+ if (_beforeProcessingEvent)
+ _beforeProcessingEvent(sessionId, event);
+ }
+ void beforeMicroStep(const std::string& sessionId) {
+ if (_beforeMicroStep)
+ _beforeMicroStep(sessionId);
+ }
+
+ void beforeExitingState(const std::string& sessionId,
+ const std::string& stateName,
+ const XERCESC_NS::DOMElement* state) {
+ if (_beforeExitingState)
+ _beforeExitingState(sessionId, stateName, state);
+ }
+
+ void afterExitingState(const std::string& sessionId,
+ const std::string& stateName,
+ const XERCESC_NS::DOMElement* state) {
+ if (_afterExitingState)
+ _afterExitingState(sessionId, stateName, state);
+ }
+
+ void beforeExecutingContent(const std::string& sessionId,
+ const XERCESC_NS::DOMElement* execContent) {
+ if (_beforeExecutingContent)
+ _beforeExecutingContent(sessionId, execContent);
+ }
+ void afterExecutingContent(const std::string& sessionId,
+ const XERCESC_NS::DOMElement* execContent) {
+ if (_afterExecutingContent)
+ _afterExecutingContent(sessionId, execContent);
+
+ }
+
+ void beforeUninvoking(const std::string& sessionId,
+ const XERCESC_NS::DOMElement* invokeElem,
+ const std::string& invokeid) {
+ if (_beforeUninvoking)
+ _beforeUninvoking(sessionId, invokeElem, invokeid);
+ }
+ void afterUninvoking(const std::string& sessionId,
+ const XERCESC_NS::DOMElement* invokeElem,
+ const std::string& invokeid) {
+ if (_afterUninvoking)
+ _afterUninvoking(sessionId, invokeElem, invokeid);
+ }
+
+ void beforeTakingTransition(const std::string& sessionId,
+ const XERCESC_NS::DOMElement* transition) {
+ if (_beforeTakingTransition)
+ _beforeTakingTransition(sessionId, transition);
+ }
+ void afterTakingTransition(const std::string& sessionId,
+ const XERCESC_NS::DOMElement* transition) {
+ if (_afterTakingTransition)
+ _afterTakingTransition(sessionId, transition);
+ }
+
+ void beforeEnteringState(const std::string& sessionId,
+ const std::string& stateName,
+ const XERCESC_NS::DOMElement* state) {
+ if (_beforeEnteringState)
+ _beforeEnteringState(sessionId, stateName, state);
+ }
+ void afterEnteringState(const std::string& sessionId,
+ const std::string& stateName,
+ const XERCESC_NS::DOMElement* state) {
+ if (_afterEnteringState)
+ _afterEnteringState(sessionId, stateName, state);
+ }
+
+ void beforeInvoking(const std::string& sessionId,
+ const XERCESC_NS::DOMElement* invokeElem,
+ const std::string& invokeid) {
+ if (_beforeInvoking)
+ _beforeInvoking(sessionId, invokeElem, invokeid);
+ }
+ void afterInvoking(const std::string& sessionId,
+ const XERCESC_NS::DOMElement* invokeElem,
+ const std::string& invokeid) {
+ if (_afterInvoking)
+ _afterInvoking(sessionId, invokeElem, invokeid);
+ }
+
+ void afterMicroStep(const std::string& sessionId) {
+ if (_afterMicroStep)
+ _afterMicroStep(sessionId);
+ }
+ void onStableConfiguration(const std::string& sessionId) {
+ if (_onStableConfiguration)
+ _onStableConfiguration(sessionId);
+ }
+
+ void beforeCompletion(const std::string& sessionId) {
+ if (_beforeCompletion)
+ _beforeCompletion(sessionId);
+ }
+ void afterCompletion(const std::string& sessionId) {
+ if (_afterCompletion)
+ _afterCompletion(sessionId);
+ }
+
+ void reportIssue(const std::string& sessionId,
+ const InterpreterIssue& issue) {
+ if (_reportIssue)
+ _reportIssue(sessionId, issue);
+ }
};
}
diff --git a/src/uscxml/plugins/DataModel.cpp b/src/uscxml/plugins/DataModel.cpp
index 19a01c9..1b12e88 100644
--- a/src/uscxml/plugins/DataModel.cpp
+++ b/src/uscxml/plugins/DataModel.cpp
@@ -31,7 +31,7 @@ bool DataModel::isValidSyntax(const std::string& expr) {
}
bool DataModel::isLegalDataValue(const std::string& expr) {
- return _impl->isLegalDataValue(expr);
+ return _impl->isLegalDataValue(expr);
}
void DataModel::setEvent(const Event& event) {
diff --git a/src/uscxml/plugins/DataModel.h b/src/uscxml/plugins/DataModel.h
index 6812553..b5ab31c 100644
--- a/src/uscxml/plugins/DataModel.h
+++ b/src/uscxml/plugins/DataModel.h
@@ -46,8 +46,8 @@ public:
virtual std::list<std::string> getNames();
/// @copydoc DataModelImpl::isValidSyntax()
virtual bool isValidSyntax(const std::string& expr);
- /// @copydoc DataModelImpl::isLegalDataValue()
- virtual bool isLegalDataValue(const std::string& expr);
+ /// @copydoc DataModelImpl::isLegalDataValue()
+ virtual bool isLegalDataValue(const std::string& expr);
/// @copydoc DataModelImpl::setEvent()
virtual void setEvent(const Event& event);
diff --git a/src/uscxml/plugins/DataModelImpl.h b/src/uscxml/plugins/DataModelImpl.h
index b378a96..afb41bc 100644
--- a/src/uscxml/plugins/DataModelImpl.h
+++ b/src/uscxml/plugins/DataModelImpl.h
@@ -117,7 +117,7 @@ public:
/**
* Determine whether a given string constitutes valid syntax in the
* data-model's language. This is only used to identify InterpreterIssues
- * but may be useful to implement isLegalDataValue() as well.
+ * but may be useful to implement isLegalDataValue() as well.
* @param expr A string, supposedly containing an expression of the data-model.
* @return Whether expr is in L(DM).
*/
@@ -125,16 +125,16 @@ public:
return true; // overwrite when datamodel supports it
}
- /**
- * Determine whether a given string constitutes a legal data value that can appear
- * at the right-hand side of an assignment.
- *
- * @param expr A string, supposedly containing a legal data value.
- * @return Whether expr is a legal data value.
- */
- virtual bool isLegalDataValue(const std::string& expr) {
- return true; // overwrite when datamodel supports it
- }
+ /**
+ * Determine whether a given string constitutes a legal data value that can appear
+ * at the right-hand side of an assignment.
+ *
+ * @param expr A string, supposedly containing a legal data value.
+ * @return Whether expr is a legal data value.
+ */
+ virtual bool isLegalDataValue(const std::string& expr) {
+ return true; // overwrite when datamodel supports it
+ }
/**
* Set the given event as `_event` in the data-model's global scope.
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp
index 3932961..69ed632 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp
@@ -669,9 +669,9 @@ bool JSCDataModel::isValidSyntax(const std::string& expr) {
}
bool JSCDataModel::isLegalDataValue(const std::string& expr) {
- return isValidSyntax("var __tmp = " + expr);
+ return isValidSyntax("var __tmp = " + expr);
}
-
+
bool JSCDataModel::isDeclared(const std::string& expr) {
JSStringRef scriptJS = JSStringCreateWithUTF8CString(expr.c_str());
JSValueRef exception = NULL;
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h
index 38b0ca5..dbe37e6 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h
@@ -64,7 +64,7 @@ public:
return names;
}
- virtual bool isLegalDataValue(const std::string& expr);
+ virtual bool isLegalDataValue(const std::string& expr);
virtual bool isValidSyntax(const std::string& expr);
virtual void setEvent(const Event& event);
diff --git a/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp b/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp
index 15cbf9d..ad4fb40 100644
--- a/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp
@@ -63,17 +63,17 @@ using namespace XERCESC_NS;
#else
#include "LuaEvent.cpp.inc"
#endif
-
+
namespace uscxml {
-
+
#ifdef BUILD_AS_PLUGINS
- PLUMA_CONNECTOR
- bool pluginConnect(pluma::Host& host) {
- host.add( new LuaDataModelProvider() );
- return true;
- }
+PLUMA_CONNECTOR
+bool pluginConnect(pluma::Host& host) {
+ host.add( new LuaDataModelProvider() );
+ return true;
+}
#endif
-
+
static int luaEval(lua_State* luaState, const std::string& expr) {
int preStack = lua_gettop(luaState);
int error = luaL_loadstring(luaState, expr.c_str()) || lua_pcall(luaState, 0, LUA_MULTRET, 0);
@@ -97,12 +97,12 @@ static Data getLuaAsData(lua_State* _luaState, const luabridge::LuaRef& lua) {
data.type = Data::INTERPRETED;
} else if(lua.isLightUserdata() || lua.isUserdata()) {
#ifndef NO_XERCESC
- int err = SWIG_Lua_ConvertPtr(_luaState, 0, (void**)&(data.node), SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMNode, SWIG_POINTER_DISOWN);
- if (err == SWIG_ERROR)
- data.node = NULL;
+ int err = SWIG_Lua_ConvertPtr(_luaState, 0, (void**)&(data.node), SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMNode, SWIG_POINTER_DISOWN);
+ if (err == SWIG_ERROR)
+ data.node = NULL;
#endif
-
- } else if(lua.isThread()) {
+
+ } else if(lua.isThread()) {
// not sure what to do
} else if(lua.type() == LUA_TBOOLEAN) {
// why is there no isBoolean in luabridge?
@@ -121,7 +121,7 @@ static Data getLuaAsData(lua_State* _luaState, const luabridge::LuaRef& lua) {
} else if(lua.isString()) {
data.atom = lua.cast<std::string>();
data.type = Data::VERBATIM;
- } else if(lua.isTable()) {
+ } else if(lua.isTable()) {
// check whether it is to be interpreted as a map or an array
bool isArray = true;
std::map<std::string, luabridge::LuaRef> luaItems;
@@ -161,13 +161,13 @@ static luabridge::LuaRef getDataAsLua(lua_State* _luaState, const Data& data) {
if (data.node) {
#ifndef NO_XERCESC
- SWIG_Lua_NewPointerObj(_luaState, data.node, SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMNode, SWIG_POINTER_DISOWN);
- luaData = luabridge::LuaRef::fromStack(_luaState, 1);
- return luaData;
+ SWIG_Lua_NewPointerObj(_luaState, data.node, SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMNode, SWIG_POINTER_DISOWN);
+ luaData = luabridge::LuaRef::fromStack(_luaState, 1);
+ return luaData;
#else
- ERROR_EXECUTION_THROW("No DOM support in Lua datamodel");
+ ERROR_EXECUTION_THROW("No DOM support in Lua datamodel");
#endif
- }
+ }
if (data.compound.size() > 0) {
luaData = luabridge::newTable(_luaState);
std::map<std::string, Data>::const_iterator compoundIter = data.compound.begin();
@@ -257,8 +257,8 @@ void LuaDataModel::setup() {
_luaState = luaL_newstate();
luaL_openlibs(_luaState);
- SWIG_init(_luaState);
-
+ SWIG_init(_luaState);
+
#if 0
try {
const luabridge::LuaRef& requireFunc = luabridge::getGlobal(_luaState, "require");
@@ -277,7 +277,7 @@ void LuaDataModel::setup() {
LOG(_callbacks->getLogger(), USCXML_INFO) << e.what() << std::endl;
}
#endif
-
+
luabridge::getGlobalNamespace(_luaState).beginClass<LuaDataModel>("DataModel").endClass();
luabridge::setGlobal(_luaState, this, "__datamodel");
@@ -351,10 +351,10 @@ void LuaDataModel::setEvent(const Event& event) {
if (event.data.node) {
#ifndef NO_XERCESC
- SWIG_Lua_NewPointerObj(_luaState, event.data.node, SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMNode, SWIG_POINTER_DISOWN);
- luaEvent["data"] = luabridge::LuaRef::fromStack(_luaState, 1);
+ SWIG_Lua_NewPointerObj(_luaState, event.data.node, SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMNode, SWIG_POINTER_DISOWN);
+ luaEvent["data"] = luabridge::LuaRef::fromStack(_luaState, 1);
#else
- ERROR_EXECUTION_THROW("No DOM support in Lua datamodel");
+ ERROR_EXECUTION_THROW("No DOM support in Lua datamodel");
#endif
} else {
// _event.data is KVP
@@ -409,7 +409,7 @@ void LuaDataModel::eval(const std::string& content) {
}
bool LuaDataModel::isLegalDataValue(const std::string& expr) {
- return isValidSyntax("local __tmp = " + expr);
+ return isValidSyntax("local __tmp = " + expr);
}
bool LuaDataModel::isValidSyntax(const std::string& expr) {
@@ -510,9 +510,9 @@ void LuaDataModel::assign(const std::string& location, const Data& data, const s
if (data.node) {
#ifndef NO_XERCESC
- SWIG_Lua_NewPointerObj(_luaState, data.node, SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMNode, SWIG_POINTER_DISOWN);
- lua_setglobal(_luaState, "__tmpAssign");
- eval(location + "= __tmpAssign");
+ SWIG_Lua_NewPointerObj(_luaState, data.node, SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMNode, SWIG_POINTER_DISOWN);
+ lua_setglobal(_luaState, "__tmpAssign");
+ eval(location + "= __tmpAssign");
#else
ERROR_EXECUTION_THROW("Cannot assign xml nodes in lua datamodel");
#endif
diff --git a/src/uscxml/plugins/datamodel/lua/LuaDataModel.h b/src/uscxml/plugins/datamodel/lua/LuaDataModel.h
index 84633f1..9b4917b 100644
--- a/src/uscxml/plugins/datamodel/lua/LuaDataModel.h
+++ b/src/uscxml/plugins/datamodel/lua/LuaDataModel.h
@@ -62,7 +62,7 @@ public:
}
virtual bool isValidSyntax(const std::string& expr);
- virtual bool isLegalDataValue(const std::string& expr);
+ virtual bool isLegalDataValue(const std::string& expr);
virtual void setEvent(const Event& event);
diff --git a/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp b/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp
index 9f4f22f..c12491b 100644
--- a/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp
@@ -707,8 +707,8 @@ void PromelaDataModel::setEvent(const Event& event) {
void PromelaDataModel::assign(const std::string& location, const Data& data, const std::map<std::string, std::string>& attr) {
PromelaParser parser(location);
if (data.atom.size() > 0 && data.type == Data::INTERPRETED) {
- // e.g. Var1 = Var1 + 1
- setVariable(parser.ast, evalAsData(data.atom));
+ // e.g. Var1 = Var1 + 1
+ setVariable(parser.ast, evalAsData(data.atom));
} else {
setVariable(parser.ast, data);
}
diff --git a/test/src/test-snippets.cpp b/test/src/test-snippets.cpp
index 5eb680f..4f67734 100644
--- a/test/src/test-snippets.cpp
+++ b/test/src/test-snippets.cpp
@@ -34,29 +34,29 @@ void microstep_snippet() {
}
void lambda_snippet() {
- InterpreterState state = uscxml::USCXML_UNDEF;
- Interpreter scxml = Interpreter::fromURL("https://raw.githubusercontent.com/tklab-tud/uscxml/master/test/w3c/null/test436.scxml");
+ InterpreterState state = uscxml::USCXML_UNDEF;
+ Interpreter scxml = Interpreter::fromURL("https://raw.githubusercontent.com/tklab-tud/uscxml/master/test/w3c/null/test436.scxml");
- scxml.on().enterState([](const std::string& sessionId,
- const std::string& stateName,
- const xercesc_3_1::DOMElement* state) {
- std::cout << "Entered " << stateName << std::endl;
- });
+ scxml.on().enterState([](const std::string& sessionId,
+ const std::string& stateName,
+ const xercesc_3_1::DOMElement* state) {
+ std::cout << "Entered " << stateName << std::endl;
+ });
- scxml.on().exitState([](const std::string& sessionId,
- const std::string& stateName,
- const xercesc_3_1::DOMElement* state) {
- std::cout << "Exited " << stateName << std::endl;
- });
+ scxml.on().exitState([](const std::string& sessionId,
+ const std::string& stateName,
+ const xercesc_3_1::DOMElement* state) {
+ std::cout << "Exited " << stateName << std::endl;
+ });
- while((state = scxml.step()) != uscxml::USCXML_FINISHED) {}
+ while((state = scxml.step()) != uscxml::USCXML_FINISHED) {}
}
int main(int argc, char** argv) {
try {
- lambda_snippet();
+ lambda_snippet();
microstep_snippet();
} catch (...) {
exit(EXIT_FAILURE);