summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Radomski <sradomski@mintwerk.de>2016-02-23 11:28:18 (GMT)
committerStefan Radomski <sradomski@mintwerk.de>2016-02-23 11:28:18 (GMT)
commit7212d5a3dbbd2845d09df96b2c345132c8a24931 (patch)
tree194bf3525bc7b607013301b79dde6c9950ccbf2e
parent8e62f3801b98bf4b7f7f85b848b2fe6339c99162 (diff)
downloaduscxml-7212d5a3dbbd2845d09df96b2c345132c8a24931.zip
uscxml-7212d5a3dbbd2845d09df96b2c345132c8a24931.tar.gz
uscxml-7212d5a3dbbd2845d09df96b2c345132c8a24931.tar.bz2
Some refactoring for improved compile times
-rw-r--r--apps/uscxml-analyze.cpp4
-rw-r--r--apps/uscxml-browser.cpp2
-rw-r--r--apps/uscxml-dot.cpp2
-rw-r--r--apps/uscxml-transform.cpp6
-rw-r--r--src/bindings/swig/uscxml_beautify.i2
-rw-r--r--src/bindings/swig/wrapped/WrappedInterpreterMonitor.h2
-rw-r--r--src/uscxml/CMakeLists.txt9
-rw-r--r--src/uscxml/Interpreter.cpp271
-rw-r--r--src/uscxml/Interpreter.h33
-rw-r--r--src/uscxml/concurrency/tinythread.h2
-rw-r--r--src/uscxml/debug/Breakpoint.cpp4
-rw-r--r--src/uscxml/debug/Breakpoint.h2
-rw-r--r--src/uscxml/debug/Complexity.cpp4
-rw-r--r--src/uscxml/debug/Debugger.cpp2
-rw-r--r--src/uscxml/debug/InterpreterIssue.cpp52
-rw-r--r--src/uscxml/debug/InterpreterIssue.h1
-rw-r--r--src/uscxml/debug/SCXMLDotWriter.cpp12
-rw-r--r--src/uscxml/dom/DOMUtils.cpp (renamed from src/uscxml/DOMUtils.cpp)84
-rw-r--r--src/uscxml/dom/DOMUtils.h (renamed from src/uscxml/DOMUtils.h)52
-rw-r--r--src/uscxml/dom/NameSpacingParser.cpp71
-rw-r--r--src/uscxml/dom/NameSpacingParser.h67
-rw-r--r--src/uscxml/interpreter/InterpreterDraft6.cpp24
-rw-r--r--src/uscxml/interpreter/InterpreterFast.cpp2
-rw-r--r--src/uscxml/interpreter/InterpreterRC.cpp28
-rw-r--r--src/uscxml/messages/Data.cpp7
-rw-r--r--src/uscxml/messages/Event.cpp5
-rw-r--r--src/uscxml/messages/MMIMessages.cpp2
-rw-r--r--src/uscxml/messages/MMIMessages.h1
-rw-r--r--src/uscxml/plugins/DataModel.h13
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp10
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h3
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/Storage.cpp2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/Storage.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/TypedArray.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp8
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h2
-rw-r--r--src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp9
-rw-r--r--src/uscxml/plugins/datamodel/lua/LuaDataModel.h3
-rw-r--r--src/uscxml/plugins/datamodel/null/NULLDataModel.cpp2
-rw-r--r--src/uscxml/plugins/datamodel/null/NULLDataModel.h3
-rw-r--r--src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp6
-rw-r--r--src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h3
-rw-r--r--src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp5
-rw-r--r--src/uscxml/plugins/datamodel/promela/PromelaDataModel.h3
-rw-r--r--src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp12
-rw-r--r--src/uscxml/plugins/datamodel/xpath/XPathDataModel.h4
-rw-r--r--src/uscxml/plugins/element/fetch/FetchElement.cpp2
-rw-r--r--src/uscxml/plugins/element/file/FileElement.cpp3
-rw-r--r--src/uscxml/plugins/element/mmi/MMIEvents.h4
-rw-r--r--src/uscxml/plugins/element/postpone/PostponeElement.cpp2
-rw-r--r--src/uscxml/plugins/element/respond/RespondElement.cpp6
-rw-r--r--src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp2
-rw-r--r--src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp5
-rw-r--r--src/uscxml/plugins/invoker/xhtml/XHTMLInvoker.cpp2
-rw-r--r--src/uscxml/plugins/ioprocessor/basichttp/BasicHTTPIOProcessor.cpp4
-rw-r--r--src/uscxml/server/HTTPServer.cpp3
-rw-r--r--src/uscxml/transform/ChartAnnotator.cpp24
-rw-r--r--src/uscxml/transform/ChartAnnotator.h (renamed from src/uscxml/Message.cpp)40
-rw-r--r--src/uscxml/transform/ChartToC.cpp209
-rw-r--r--src/uscxml/transform/ChartToC.h2
-rw-r--r--src/uscxml/transform/ChartToFSM.cpp59
-rw-r--r--src/uscxml/transform/ChartToFSM.h2
-rw-r--r--src/uscxml/transform/ChartToFlatSCXML.cpp16
-rw-r--r--src/uscxml/transform/ChartToMinimalSCXML.cpp10
-rw-r--r--src/uscxml/transform/ChartToMinimalSCXML.h2
-rw-r--r--src/uscxml/transform/ChartToPromela.cpp119
-rw-r--r--src/uscxml/transform/ChartToPromela.h2
-rw-r--r--src/uscxml/transform/ChartToTex.h2
-rw-r--r--src/uscxml/transform/ChartToVHDL.cpp10
-rw-r--r--src/uscxml/transform/ChartToVHDL.h2
-rw-r--r--src/uscxml/transform/FlatStateIdentifier.h2
-rw-r--r--src/uscxml/util/String.cpp176
-rw-r--r--src/uscxml/util/String.h34
-rw-r--r--test/CMakeLists.txt38
-rw-r--r--test/ctest/CTestCustom.ctest.in9
-rw-r--r--test/src/test-arabica-namespaces.cpp13
-rw-r--r--test/src/test-arabica-xpath.cpp2
-rw-r--r--test/src/test-c-inline.c3
-rw-r--r--test/src/test-c-inline.c.scxml.c26
-rw-r--r--test/src/test-c-machine.cpp2
-rw-r--r--test/src/test-predicates.cpp37
-rw-r--r--test/src/test-promela-parser.cpp1
-rw-r--r--test/src/test-w3c.cpp4
84 files changed, 984 insertions, 742 deletions
diff --git a/apps/uscxml-analyze.cpp b/apps/uscxml-analyze.cpp
index 69e403a..33a536a 100644
--- a/apps/uscxml-analyze.cpp
+++ b/apps/uscxml-analyze.cpp
@@ -2,7 +2,7 @@
#include "uscxml/Interpreter.h"
#include "uscxml/debug/Complexity.h"
#include "uscxml/transform/ChartToFSM.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
#include <glog/logging.h>
#include <fstream>
#include <iostream>
@@ -95,7 +95,7 @@ int main(int argc, char** argv) {
pluginPath = optarg;
break;
case 'a':
- aspects = InterpreterImpl::tokenize(optarg, ',');
+ aspects = tokenize(optarg, ',');
break;
case 'l':
break;
diff --git a/apps/uscxml-browser.cpp b/apps/uscxml-browser.cpp
index 10f52cc..2f416bb 100644
--- a/apps/uscxml-browser.cpp
+++ b/apps/uscxml-browser.cpp
@@ -1,6 +1,6 @@
#include "uscxml/config.h"
#include "uscxml/Interpreter.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
#ifndef BUILD_MINIMAL
# include "uscxml/debug/DebuggerServlet.h"
diff --git a/apps/uscxml-dot.cpp b/apps/uscxml-dot.cpp
index e72b2d4..0fcd548 100644
--- a/apps/uscxml-dot.cpp
+++ b/apps/uscxml-dot.cpp
@@ -1,6 +1,6 @@
#include "uscxml/config.h"
#include "uscxml/Interpreter.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
#include "uscxml/debug/SCXMLDotWriter.h"
#include <glog/logging.h>
#include "getopt.h"
diff --git a/apps/uscxml-transform.cpp b/apps/uscxml-transform.cpp
index a5aa9ec..3ef7a83 100644
--- a/apps/uscxml-transform.cpp
+++ b/apps/uscxml-transform.cpp
@@ -6,7 +6,7 @@
#include "uscxml/transform/ChartToTex.h"
#include "uscxml/transform/ChartToMinimalSCXML.h"
#include "uscxml/transform/ChartToPromela.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
#include <glog/logging.h>
#include <boost/algorithm/string.hpp>
@@ -165,10 +165,10 @@ int main(int argc, char** argv) {
inputFile = optarg;
break;
case 'a':
- options = InterpreterImpl::tokenize(optarg, ',');
+ options = tokenize(optarg, ',');
break;
case 'X': {
- std::list<std::string> extension = InterpreterImpl::tokenize(optarg, '=');
+ std::list<std::string> extension = tokenize(optarg, '=');
if (extension.size() != 2)
printUsageAndExit(argv[0]);
std::string key = boost::trim_copy(*(extension.begin()));
diff --git a/src/bindings/swig/uscxml_beautify.i b/src/bindings/swig/uscxml_beautify.i
index 0350426..eb37fb1 100644
--- a/src/bindings/swig/uscxml_beautify.i
+++ b/src/bindings/swig/uscxml_beautify.i
@@ -118,6 +118,8 @@
%{
#include <glog/logging.h>
+ #include "uscxml/dom/NameSpacingParser.h"
+
%}
%extend uscxml::Data {
diff --git a/src/bindings/swig/wrapped/WrappedInterpreterMonitor.h b/src/bindings/swig/wrapped/WrappedInterpreterMonitor.h
index a63bad5..ed67f7b 100644
--- a/src/bindings/swig/wrapped/WrappedInterpreterMonitor.h
+++ b/src/bindings/swig/wrapped/WrappedInterpreterMonitor.h
@@ -31,7 +31,7 @@
#include "../../../uscxml/Message.h"
#include "../../../uscxml/Factory.h"
#include "../../../uscxml/Interpreter.h"
-#include "../../../uscxml/DOMUtils.h"
+#include "../../../uscxml/dom/DOMUtils.h"
namespace uscxml {
diff --git a/src/uscxml/CMakeLists.txt b/src/uscxml/CMakeLists.txt
index 8e27980..4e76148 100644
--- a/src/uscxml/CMakeLists.txt
+++ b/src/uscxml/CMakeLists.txt
@@ -18,6 +18,15 @@ file(GLOB_RECURSE USCXML_UTIL
source_group("Interpreter" FILES ${USCXML_UTIL})
list (APPEND USCXML_FILES ${USCXML_UTIL})
+file(GLOB_RECURSE USCXML_DOM
+ dom/*.cpp
+ dom/*.hpp
+ dom/*.c
+ dom/*.h
+)
+source_group("Interpreter" FILES ${USCXML_DOM})
+list (APPEND USCXML_FILES ${USCXML_DOM})
+
file(GLOB_RECURSE USCXML_CONCURRENCY
concurrency/*.cpp
concurrency/*.h
diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp
index 2510ef4..7353104 100644
--- a/src/uscxml/Interpreter.cpp
+++ b/src/uscxml/Interpreter.cpp
@@ -22,7 +22,8 @@
#include "uscxml/Interpreter.h"
#include "uscxml/URL.h"
#include "uscxml/UUID.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
+#include "uscxml/dom/NameSpacingParser.h"
#include "uscxml/transform/FlatStateIdentifier.h"
#include "uscxml/transform/ChartToFSM.h" // only for testing
@@ -485,7 +486,7 @@ Interpreter Interpreter::fromXML(const std::string& xml, const std::string& sour
std::auto_ptr<std::istream> ssPtr(ss);
Arabica::SAX::InputSource<std::string> inputSource;
inputSource.setByteStream(ssPtr);
- return fromInputSource(inputSource, sourceURL);
+ return fromInputSource(&inputSource, sourceURL);
}
@@ -502,7 +503,7 @@ Interpreter Interpreter::fromURL(const std::string& url) {
if (iequals(absUrl.scheme(), "file")) {
Arabica::SAX::InputSource<std::string> inputSource;
inputSource.setSystemId(absUrl.asString());
- interpreter = fromInputSource(inputSource, absUrl);
+ interpreter = fromInputSource(&inputSource, absUrl);
} else {
// use curl for everything !file - even for http as arabica won't follow redirects
std::stringstream ss;
@@ -520,9 +521,10 @@ Interpreter Interpreter::fromURL(const std::string& url) {
return interpreter;
}
-Interpreter Interpreter::fromInputSource(Arabica::SAX::InputSource<std::string>& source, const std::string& sourceURL) {
+Interpreter Interpreter::fromInputSource(void* source, const std::string& sourceURL) {
tthread::lock_guard<tthread::recursive_mutex> lock(_instanceMutex);
+ Arabica::SAX::InputSource<std::string> sourceRef = *(Arabica::SAX::InputSource<std::string>*)source;
// remove old instances
std::map<std::string, boost::weak_ptr<InterpreterImpl> >::iterator instIter = _instances.begin();
while(instIter != _instances.end()) {
@@ -538,7 +540,7 @@ Interpreter Interpreter::fromInputSource(Arabica::SAX::InputSource<std::string>&
_instances[interpreterImpl->getSessionId()] = interpreterImpl;
NameSpacingParser parser;
- if (parser.parse(source) && parser.getDocument() && parser.getDocument().hasChildNodes()) {
+ if (parser.parse(sourceRef) && parser.getDocument() && parser.getDocument().hasChildNodes()) {
interpreterImpl->setNameSpaceInfo(parser.nameSpace);
interpreterImpl->_document = parser.getDocument();
interpreterImpl->_sourceURL = sourceURL;
@@ -680,11 +682,11 @@ void InterpreterImpl::exitInterpreter() {
statesToExit.sort();
for (int i = 0; i < statesToExit.size(); i++) {
- Arabica::XPath::NodeSet<std::string> onExitElems = filterChildElements(_nsInfo.xmlNSPrefix + "onexit", statesToExit[i]);
+ Arabica::XPath::NodeSet<std::string> onExitElems = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "onexit", statesToExit[i]);
for (int j = 0; j < onExitElems.size(); j++) {
executeContent(Element<std::string>(onExitElems[j]));
}
- Arabica::XPath::NodeSet<std::string> invokeElems = filterChildElements(_nsInfo.xmlNSPrefix + "invoke", statesToExit[i]);
+ Arabica::XPath::NodeSet<std::string> invokeElems = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "invoke", statesToExit[i]);
// TODO: we ought to cancel all remaining invokers just to be sure with the persist extension
for (int j = 0; j < invokeElems.size(); j++) {
cancelInvoke(Element<std::string>(invokeElems[j]));
@@ -888,7 +890,7 @@ InterpreterState InterpreterImpl::step(int waitForMS) {
// when we reach a stable configuration, invoke
for (unsigned int i = 0; i < _statesToInvoke.size(); i++) {
- NodeSet<std::string> invokes = filterChildElements(_nsInfo.xmlNSPrefix + "invoke", _statesToInvoke[i]);
+ NodeSet<std::string> invokes = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "invoke", _statesToInvoke[i]);
for (unsigned int j = 0; j < invokes.size(); j++) {
Element<std::string> invokeElem = Element<std::string>(invokes[j]);
if (!HAS_ATTR(invokeElem, "persist") || !stringIsTrue(ATTR(invokeElem, "persist"))) {
@@ -1066,7 +1068,7 @@ void InterpreterImpl::stabilize() {
// when we reach a stable configuration, invoke
for (unsigned int i = 0; i < _statesToInvoke.size(); i++) {
- NodeSet<std::string> invokes = filterChildElements(_nsInfo.xmlNSPrefix + "invoke", _statesToInvoke[i]);
+ NodeSet<std::string> invokes = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "invoke", _statesToInvoke[i]);
for (unsigned int j = 0; j < invokes.size(); j++) {
Element<std::string> invokeElem = Element<std::string>(invokes[j]);
if (!HAS_ATTR(invokeElem, "persist") || !stringIsTrue(ATTR(invokeElem, "persist"))) {
@@ -1091,7 +1093,7 @@ Arabica::XPath::NodeSet<std::string> InterpreterImpl::selectTransitions(const st
unsigned int index = 0;
while(states.size() > index) {
- NodeSet<std::string> transitions = filterChildElements(_nsInfo.xmlNSPrefix + "transition", states[index]);
+ NodeSet<std::string> transitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", states[index]);
for (unsigned int k = 0; k < transitions.size(); k++) {
if (isEnabledTransition(Element<std::string>(transitions[k]), event)) {
enabledTransitions.push_back(transitions[k]);
@@ -1126,7 +1128,7 @@ Arabica::XPath::NodeSet<std::string> InterpreterImpl::selectEventlessTransitions
unsigned int index = 0;
while(states.size() > index) {
bool foundTransition = false;
- NodeSet<std::string> transitions = filterChildElements(_nsInfo.xmlNSPrefix + "transition", states[index]);
+ NodeSet<std::string> transitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", states[index]);
for (unsigned int k = 0; k < transitions.size(); k++) {
Element<std::string> transElem(transitions[k]);
if (!HAS_ATTR(transElem, "event") && hasConditionMatch(transElem)) {
@@ -1172,7 +1174,7 @@ Arabica::XPath::NodeSet<std::string> InterpreterImpl::selectTransitions(const st
for (unsigned int i = 0; i < atomicStates.size(); i++) {
Element<std::string> state(atomicStates[i]);
while(true) {
- NodeSet<std::string> transitions = filterChildElements(_nsInfo.xmlNSPrefix + "transition", state);
+ NodeSet<std::string> transitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", state);
for (unsigned int k = 0; k < transitions.size(); k++) {
if (isEnabledTransition(Element<std::string>(transitions[k]), event)) {
enabledTransitions.push_back(transitions[k]);
@@ -1225,7 +1227,7 @@ Arabica::XPath::NodeSet<std::string> InterpreterImpl::selectEventlessTransitions
for (unsigned int i = 0; i < atomicStates.size(); i++) {
Element<std::string> state(atomicStates[i]);
while(true) {
- NodeSet<std::string> transitions = filterChildElements(_nsInfo.xmlNSPrefix + "transition", state);
+ NodeSet<std::string> transitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", state);
for (unsigned int k = 0; k < transitions.size(); k++) {
Element<std::string> transElem(transitions[k]);
if (!HAS_ATTR(transElem, "event") && hasConditionMatch(transElem)) {
@@ -1273,7 +1275,7 @@ bool InterpreterImpl::isEnabledTransition(const Element<std::string>& transition
return false;
}
- std::list<std::string> eventNames = tokenizeIdRefs(eventName);
+ std::list<std::string> eventNames = tokenize(eventName);
std::list<std::string>::iterator eventIter = eventNames.begin();
while(eventIter != eventNames.end()) {
if(nameMatch(*eventIter, event) && hasConditionMatch(transition)) {
@@ -1612,7 +1614,7 @@ void InterpreterImpl::resolveXIncludes(std::list<std::string> includeChain,
goto TRY_WITH_FALLBACK;
}
TRY_WITH_FALLBACK: {
- NodeSet<std::string> fallbacks = filterChildElements(xIncludeNS + "fallback", xinclude);
+ NodeSet<std::string> fallbacks = DOMUtils::filterChildElements(xIncludeNS + "fallback", xinclude);
if (fallbacks.size() > 0) {
LOG(WARNING) << "Using xi:fallback for '" << DOMUtils::xPathForNode(xinclude) << "'";
// move the fallbacks children in place
@@ -1629,7 +1631,7 @@ REMOVE_AND_RECURSE:
xinclude.getParentNode().removeChild(xinclude);
for (int i = 0; i < newNodes.size(); i++) {
_baseURL[newNodes[i]] = URL::asBaseURL(src);
- Arabica::XPath::NodeSet<std::string> xincludes = filterChildElements(xIncludeNS + "include", newNodes[i], true);
+ Arabica::XPath::NodeSet<std::string> xincludes = DOMUtils::filterChildElements(xIncludeNS + "include", newNodes[i], true);
for (int j = 0; j < xincludes.size(); j++) {
resolveXIncludes(includeChain, mergedNS, xIncludeNS, URL::asBaseURL(src), Element<std::string>(xincludes[j]));
}
@@ -1689,7 +1691,7 @@ void InterpreterImpl::init() {
}
} else {
// initialize current data elements
- NodeSet<std::string> topDataElems = filterChildElements(_nsInfo.xmlNSPrefix + "data", filterChildElements(_nsInfo.xmlNSPrefix + "datamodel", _scxml));
+ NodeSet<std::string> topDataElems = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "data", DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "datamodel", _scxml));
for (unsigned int i = 0; i < topDataElems.size(); i++) {
if (topDataElems[i].getNodeType() == Node_base::ELEMENT_NODE)
initializeData(Element<std::string>(topDataElems[i]));
@@ -1697,7 +1699,7 @@ void InterpreterImpl::init() {
}
// executeGlobalScriptElements
- NodeSet<std::string> globalScriptElems = filterChildElements(_nsInfo.xmlNSPrefix + "script", _scxml);
+ NodeSet<std::string> globalScriptElems = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "script", _scxml);
for (unsigned int i = 0; i < globalScriptElems.size(); i++) {
executeContent(Element<std::string>(globalScriptElems[i]));
}
@@ -1774,7 +1776,7 @@ void InterpreterImpl::internalDoneSend(const Arabica::DOM::Element<std::string>&
if (doneData) {
processParamChilds(doneData, event.params);
- Arabica::XPath::NodeSet<std::string> contents = filterChildElements(_nsInfo.xmlNSPrefix + "content", doneData);
+ Arabica::XPath::NodeSet<std::string> contents = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "content", doneData);
if (contents.size() > 1)
LOG(ERROR) << "Only a single content element is allowed for send elements - using first one";
if (contents.size() > 0) {
@@ -1907,7 +1909,7 @@ void InterpreterImpl::processDOMorText(const Arabica::DOM::Element<std::string>&
}
void InterpreterImpl::processParamChilds(const Arabica::DOM::Element<std::string>& element, std::multimap<std::string, Data>& params) {
- NodeSet<std::string> paramElems = filterChildElements(_nsInfo.xmlNSPrefix + "param", element);
+ NodeSet<std::string> paramElems = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "param", element);
for (int i = 0; i < paramElems.size(); i++) {
try {
Element<std::string> paramElem = Element<std::string>(paramElems[i]);
@@ -2045,7 +2047,7 @@ void InterpreterImpl::send(const Arabica::DOM::Element<std::string>& element) {
try {
// namelist
if (HAS_ATTR(element, "namelist")) {
- std::list<std::string> names = tokenizeIdRefs(ATTR(element, "namelist"));
+ std::list<std::string> names = tokenize(ATTR(element, "namelist"));
for (std::list<std::string>::const_iterator nameIter = names.begin(); nameIter != names.end(); nameIter++) {
if (!_dataModel.isLocation(*nameIter)) {
LOG(ERROR) << "Error in send element " << DOMUtils::xPathForNode(element) << " namelist:" << std::endl << "'" << *nameIter << "' is not a location expression" << std::endl;
@@ -2072,7 +2074,7 @@ void InterpreterImpl::send(const Arabica::DOM::Element<std::string>& element) {
}
try {
// content
- NodeSet<std::string> contents = filterChildElements(_nsInfo.xmlNSPrefix + "content", element);
+ NodeSet<std::string> contents = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "content", element);
if (contents.size() > 1)
LOG(ERROR) << "Only a single content element is allowed for send elements " << DOMUtils::xPathForNode(element) << " - using first one";
if (contents.size() > 0) {
@@ -2201,7 +2203,7 @@ void InterpreterImpl::invoke(const Arabica::DOM::Element<std::string>& element)
// namelist
if (HAS_ATTR(element, "namelist")) {
- std::list<std::string> names = tokenizeIdRefs(ATTR(element, "namelist"));
+ std::list<std::string> names = tokenize(ATTR(element, "namelist"));
for (std::list<std::string>::const_iterator nameIter = names.begin(); nameIter != names.end(); nameIter++) {
if (!_dataModel.isLocation(*nameIter)) {
LOG(ERROR) << "Error in send element " << DOMUtils::xPathForNode(element) << " namelist:" << std::endl << "'" << *nameIter << "' is not a location expression" << std::endl;
@@ -2229,7 +2231,7 @@ void InterpreterImpl::invoke(const Arabica::DOM::Element<std::string>& element)
// content
try {
- NodeSet<std::string> contents = filterChildElements(_nsInfo.xmlNSPrefix + "content", element);
+ NodeSet<std::string> contents = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "content", element);
if (contents.size() > 1)
LOG(ERROR) << "Only a single content element is allowed for send elements - using first one";
if (contents.size() > 0) {
@@ -2372,92 +2374,6 @@ void InterpreterImpl::cancelInvoke(const Arabica::DOM::Element<std::string>& ele
//receiveInternal(Event("done.invoke." + invokeId, Event::PLATFORM));
}
-// see: http://www.w3.org/TR/scxml/#EventDescriptors
-bool InterpreterImpl::nameMatch(const std::string& eventDescs, const std::string& eventName) {
-#if 1
- if(eventDescs.length() == 0 || eventName.length() == 0)
- return false;
-
- // naive case of single descriptor and exact match
- if (iequals(eventDescs, eventName))
- return true;
-
- size_t start = 0;
- std::string eventDesc;
- for (int i = 0; i < eventDescs.size(); i++) {
- if (isspace(eventDescs[i])) {
- if (i > 0 && start < i - 1) {
- eventDesc = eventDescs.substr(start, i - start);
- }
- while(isspace(eventDescs[++i])); // skip whitespaces
- start = i;
- } else if (i + 1 == eventDescs.size()) {
- eventDesc = eventDescs.substr(start, i + 1 - start);
- }
-
- if (eventDesc.size() > 0) {
- // remove optional trailing .* for CCXML compatibility
- if (eventDesc.find("*", eventDesc.size() - 1) != std::string::npos)
- eventDesc = eventDesc.substr(0, eventDesc.size() - 1);
- if (eventDesc.find(".", eventDesc.size() - 1) != std::string::npos)
- eventDesc = eventDesc.substr(0, eventDesc.size() - 1);
-
- // was eventDesc the * wildcard
- if (eventDesc.size() == 0)
- return true;
-
- // eventDesc has to be a real prefix of event now and therefore shorter
- if (eventDesc.size() > eventName.size())
- goto NEXT_DESC;
-
- // are they already equal?
- if (iequals(eventDesc, eventName))
- return true;
-
- if (eventName.find(eventDesc) == 0) {
- if (eventName.find(".", eventDesc.size()) == eventDesc.size())
- return true;
- }
-NEXT_DESC:
- eventDesc = "";
- }
- }
- return false;
-#else
- const char* dPtr = eventDescs.c_str();
- const char* ePtr = eventName.c_str();
- while(*dPtr != 0) {
-
- if (*dPtr == '*' && *ePtr != 0) // something following
- return true;
-
- // descriptor differs from event name
- if (*dPtr != *ePtr) {
- // move to next descriptor
- while(*dPtr != ' ' && *dPtr != 0) {
- dPtr++;
- }
- if (*dPtr == 0)
- return false;
- dPtr++;
- ePtr = eventName.c_str();
- } else {
- // move both pointers one character
- dPtr++;
- ePtr++;
-
- }
-
- // descriptor is done, return match
- if (((*dPtr == 0 || *dPtr == ' ') && (*ePtr == 0 || *ePtr == ' ')) || // exact match, end of string
- (*dPtr == ' ' && *ePtr == '.') || (*dPtr == 0 && *ePtr == '.')) // prefix match
- return true;
- }
- return false;
-#endif
-}
-
-
bool InterpreterImpl::hasConditionMatch(const Arabica::DOM::Element<std::string>& conditional) {
if (HAS_ATTR(conditional, "cond") && ATTR(conditional, "cond").length() > 0) {
try {
@@ -2530,7 +2446,7 @@ void InterpreterImpl::executeContent(const Arabica::DOM::Element<std::string>& c
try {
// content
processParamChilds(content, raised.params);
- NodeSet<std::string> contents = filterChildElements(_nsInfo.xmlNSPrefix + "content", content);
+ NodeSet<std::string> contents = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "content", content);
if (contents.size() > 1)
LOG(ERROR) << "Only a single content element is allowed for raise elements " << DOMUtils::xPathForNode(content) << " - using first one";
if (contents.size() > 0) {
@@ -2772,7 +2688,7 @@ void InterpreterImpl::finalizeAndAutoForwardCurrentEvent() {
invokeIter != _invokers.end();
invokeIter++) {
if (iequals(invokeIter->first, _currEvent.invokeid)) {
- Arabica::XPath::NodeSet<std::string> finalizes = filterChildElements(_nsInfo.xmlNSPrefix + "finalize", invokeIter->second.getElement());
+ Arabica::XPath::NodeSet<std::string> finalizes = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "finalize", invokeIter->second.getElement());
for (int k = 0; k < finalizes.size(); k++) {
Element<std::string> finalizeElem = Element<std::string>(finalizes[k]);
executeContent(finalizeElem);
@@ -3024,13 +2940,13 @@ Arabica::XPath::NodeSet<std::string> InterpreterImpl::getInitialStates(Arabica::
// initial attribute at element
Arabica::DOM::Element<std::string> stateElem = (Arabica::DOM::Element<std::string>)state;
if (stateElem.hasAttribute("initial")) {
- return getStates(tokenizeIdRefs(stateElem.getAttribute("initial")));
+ return getStates(tokenize(stateElem.getAttribute("initial")));
}
// initial element as child - but not the implicit generated one
- NodeSet<std::string> initElems = filterChildElements(_nsInfo.xmlNSPrefix + "initial", state);
+ NodeSet<std::string> initElems = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "initial", state);
if(initElems.size() > 0 && !iequals(ATTR_CAST(initElems[0], "generated"), "true")) {
- NodeSet<std::string> initTrans = filterChildElements(_nsInfo.xmlNSPrefix + "transition", initElems[0]);
+ NodeSet<std::string> initTrans = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", initElems[0]);
if (initTrans.size() > 0) {
return getTargetStates(Element<std::string>(initTrans[0]));
}
@@ -3084,7 +3000,7 @@ NodeSet<std::string> InterpreterImpl::getReachableStates() {
// reachable per target attribute in transitions
for (int i = 0; i < reachable.size(); i++) {
Element<std::string> state = Element<std::string>(reachable[i]);
- NodeSet<std::string> transitions = InterpreterImpl::filterChildElements(_nsInfo.xmlNSPrefix + "transition", state, false);
+ NodeSet<std::string> transitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", state, false);
for (int j = 0; j < transitions.size(); j++) {
Element<std::string> transition = Element<std::string>(transitions[j]);
try {
@@ -3151,7 +3067,7 @@ NodeSet<std::string> InterpreterImpl::getTargetStates(const Arabica::DOM::Elemen
}
std::string targetId = ((Arabica::DOM::Element<std::string>)transition).getAttribute("target");
- std::list<std::string> targetIds = InterpreterImpl::tokenizeIdRefs(ATTR(transition, "target"));
+ std::list<std::string> targetIds = tokenize(ATTR(transition, "target"));
for (std::list<std::string>::const_iterator targetIter = targetIds.begin(); targetIter != targetIds.end(); targetIter++) {
Arabica::DOM::Node<std::string> state = getState(*targetIter);
if (state) {
@@ -3171,125 +3087,6 @@ NodeSet<std::string> InterpreterImpl::getTargetStates(const Arabica::XPath::Node
return targets;
}
-#define ISWHITESPACE(char) (isspace(char))
-
-std::list<std::string> InterpreterImpl::tokenize(const std::string& line, const char sep, bool trimWhiteSpace) {
- std::list<std::string> tokens;
-
- // appr. 3x faster than stringstream
- size_t start = 0;
- for (int i = 0; i < line.size(); i++) {
- if (line[i] == sep || (trimWhiteSpace && ISWHITESPACE(line[i]))) {
- if (i > 0 && start < i) {
- tokens.push_back(line.substr(start, i - start));
- }
- while(line[i] == sep || (trimWhiteSpace && ISWHITESPACE(line[i]))) {
- i++; // skip multiple occurences of seperator and whitespaces
- }
- start = i;
- } else if (i + 1 == line.size()) {
- tokens.push_back(line.substr(start, i + 1 - start));
- }
- }
-
- return tokens;
-}
-
-std::string InterpreterImpl::spaceNormalize(const std::string& text) {
- std::stringstream content;
-
-#if 1
- // 195ms with test-performance-events.scml
- std::string seperator;
-
- size_t start = 0;
- for (int i = 0; i < text.size(); i++) {
- if (isspace(text[i])) {
- if (i > 0 && start < i) {
- content << seperator << text.substr(start, i - start);
- seperator = " ";
- }
- while(isspace(text[++i])); // skip whitespaces
- start = i;
- } else if (i + 1 == text.size()) {
- content << seperator << text.substr(start, i + 1 - start);
- }
- }
-// std::cerr << ">>" << content.str() << "<<" << std::endl;
-
-#else
-
-// 291ms with test-performance-events.scml
- std::istringstream iss(text);
- std::string seperator;
- do {
- std::string token;
- iss >> token;
- if (token.length() > 0) {
- content << seperator << token;
- seperator = " ";
- }
- } while (iss);
-
-#endif
- return content.str();
-}
-
-
-NodeSet<std::string> InterpreterImpl::filterChildElements(const std::string& tagName, const NodeSet<std::string>& nodeSet, bool recurse) {
- NodeSet<std::string> filteredChildElems;
- for (unsigned int i = 0; i < nodeSet.size(); i++) {
- filteredChildElems.push_back(filterChildElements(tagName, nodeSet[i], recurse));
- }
- return filteredChildElems;
-}
-
-NodeSet<std::string> InterpreterImpl::filterChildElements(const std::string& tagName, const Node<std::string>& node, bool recurse) {
- NodeSet<std::string> filteredChildElems;
-
- if (!node)
- return filteredChildElems;
-
- NodeList<std::string> childs = node.getChildNodes();
- for (unsigned int i = 0; i < childs.getLength(); i++) {
- if (childs.item(i).getNodeType() != Node_base::ELEMENT_NODE)
- continue;
-// std::cerr << TAGNAME(childs.item(i)) << std::endl;
- if(iequals(TAGNAME_CAST(childs.item(i)), tagName)) {
- filteredChildElems.push_back(childs.item(i));
- }
- if (recurse) {
- filteredChildElems.push_back(filterChildElements(tagName, childs.item(i), recurse));
- }
- }
- return filteredChildElems;
-}
-
-
-NodeSet<std::string> InterpreterImpl::filterChildType(const Node_base::Type type, const NodeSet<std::string>& nodeSet, bool recurse) {
- NodeSet<std::string> filteredChildType;
- for (unsigned int i = 0; i < nodeSet.size(); i++) {
- filteredChildType.push_back(filterChildType(type, nodeSet[i], recurse));
- }
- return filteredChildType;
-}
-
-NodeSet<std::string> InterpreterImpl::filterChildType(const Node_base::Type type, const Node<std::string>& node, bool recurse) {
- NodeSet<std::string> filteredChildTypes;
-
- if (!node)
- return filteredChildTypes;
-
- NodeList<std::string> childs = node.getChildNodes();
- for (unsigned int i = 0; i < childs.getLength(); i++) {
- if (childs.item(i).getNodeType() == type)
- filteredChildTypes.push_back(childs.item(i));
- if (recurse) {
- filteredChildTypes.push_back(filterChildType(type, childs.item(i), recurse));
- }
- }
- return filteredChildTypes;
-}
/*
* If state2 is null, returns the set of all ancestors of state1 in ancestry order
@@ -3724,7 +3521,7 @@ void InterpreterImpl::handleDOMEvent(Arabica::DOM::Events::Event<std::string>& e
// remove modified states from cache
Node<std::string> target = Arabica::DOM::Node<std::string>(event.getTarget());
- NodeSet<std::string> childs = InterpreterImpl::filterChildElements(_nsInfo.xmlNSPrefix + "state", target);
+ NodeSet<std::string> childs = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "state", target);
for (int i = 0; i < childs.size(); i++) {
if (HAS_ATTR_CAST(childs[i], "id")) {
_cachedStates.erase(ATTR_CAST(childs[i], "id"));
diff --git a/src/uscxml/Interpreter.h b/src/uscxml/Interpreter.h
index ce9354a..c3395d0 100644
--- a/src/uscxml/Interpreter.h
+++ b/src/uscxml/Interpreter.h
@@ -23,6 +23,7 @@
// this has to be the first include or MSVC will run amok
#include "uscxml/config.h"
#include "uscxml/Common.h"
+#include "uscxml/util/String.h"
#include <iostream> // arabica xpath uses cerr without iostream
#include <boost/shared_ptr.hpp>
@@ -34,11 +35,6 @@
#include <XPath/XPath.hpp>
#include <DOM/Document.hpp>
-#include <DOM/SAX2DOM/SAX2DOM.hpp>
-#include <SAX/helpers/CatchErrorHandler.hpp>
-#include <DOM/Events/EventTarget.hpp>
-#include <DOM/Events/EventListener.hpp>
-
#include "uscxml/concurrency/BlockingQueue.h"
#include "uscxml/messages/Data.h"
#include "uscxml/messages/SendRequest.h"
@@ -50,11 +46,13 @@
#include "uscxml/plugins/Invoker.h"
#include "uscxml/plugins/ExecutableContent.h"
-#ifdef BUILD_PROFILING
-#include "uscxml/concurrency/Timer.h"
-#define TIME_BLOCK Measurement msm(&timer);
-#else
-#define TIME_BLOCK (0);
+#ifndef TIME_BLOCK
+# ifdef BUILD_PROFILING
+# include "uscxml/concurrency/Timer.h"
+# define TIME_BLOCK Measurement msm(&timer);
+# else
+# define TIME_BLOCK
+# endif
#endif
#define ERROR_PLATFORM_THROW(msg) \
@@ -399,18 +397,6 @@ public:
virtual Arabica::XPath::NodeSet<std::string> getTargetStates(const Arabica::XPath::NodeSet<std::string>& transitions);
virtual Arabica::DOM::Node<std::string> getSourceState(const Arabica::DOM::Element<std::string>& transition);
- static Arabica::XPath::NodeSet<std::string> filterChildElements(const std::string& tagname, const Arabica::DOM::Node<std::string>& node, bool recurse = false);
- static Arabica::XPath::NodeSet<std::string> filterChildElements(const std::string& tagName, const Arabica::XPath::NodeSet<std::string>& nodeSet, bool recurse = false);
- static Arabica::XPath::NodeSet<std::string> filterChildType(const Arabica::DOM::Node_base::Type type, const Arabica::DOM::Node<std::string>& node, bool recurse = false);
- static Arabica::XPath::NodeSet<std::string> filterChildType(const Arabica::DOM::Node_base::Type type, const Arabica::XPath::NodeSet<std::string>& nodeSet, bool recurse = false);
-
- static std::list<std::string> tokenizeIdRefs(const std::string& idRefs) {
- return tokenize(idRefs, ' ', true);
- }
- static std::list<std::string> tokenize(const std::string& line, const char seperator = ' ', bool trimWhiteSpace = false);
-
- static std::string spaceNormalize(const std::string& text);
- static bool nameMatch(const std::string& eventDescs, const std::string& event);
Arabica::DOM::Node<std::string> findLCCA(const Arabica::XPath::NodeSet<std::string>& states);
virtual Arabica::XPath::NodeSet<std::string> getProperAncestors(const Arabica::DOM::Node<std::string>& s1, const Arabica::DOM::Node<std::string>& s2);
@@ -827,7 +813,8 @@ protected:
return _impl->setInvokeRequest(req);
}
- static Interpreter fromInputSource(Arabica::SAX::InputSource<std::string>& source, const std::string& sourceURL);
+ // we use a void ptr here as Arabica::SAX::InputSource complicates includes
+ static Interpreter fromInputSource(void* source, const std::string& sourceURL);
boost::shared_ptr<InterpreterImpl> _impl;
static std::map<std::string, boost::weak_ptr<InterpreterImpl> > _instances;
diff --git a/src/uscxml/concurrency/tinythread.h b/src/uscxml/concurrency/tinythread.h
index cf313d5..e5e5e25 100644
--- a/src/uscxml/concurrency/tinythread.h
+++ b/src/uscxml/concurrency/tinythread.h
@@ -25,7 +25,7 @@ freely, subject to the following restrictions:
#define _TINYTHREAD_H_
#include "uscxml/Common.h"
-#include <ostream>
+//#include <ostream>
/// @file
/// @mainpage TinyThread++ API Reference
diff --git a/src/uscxml/debug/Breakpoint.cpp b/src/uscxml/debug/Breakpoint.cpp
index e66e0fb..d7eb2af 100644
--- a/src/uscxml/debug/Breakpoint.cpp
+++ b/src/uscxml/debug/Breakpoint.cpp
@@ -19,7 +19,7 @@
#include "uscxml/debug/Breakpoint.h"
#include "uscxml/Interpreter.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
namespace uscxml {
@@ -223,7 +223,7 @@ bool Breakpoint::matches(Interpreter interpreter, const Breakpoint& other) const
return false;
}
- if(eventName.length() > 0 && !InterpreterImpl::nameMatch(eventName, other.eventName)) {
+ if(eventName.length() > 0 && !nameMatch(eventName, other.eventName)) {
return false;
}
diff --git a/src/uscxml/debug/Breakpoint.h b/src/uscxml/debug/Breakpoint.h
index 71308aa..d7df03d 100644
--- a/src/uscxml/debug/Breakpoint.h
+++ b/src/uscxml/debug/Breakpoint.h
@@ -21,9 +21,9 @@
#define BREAKPOINT_H_VR7K7T1X
#include <string> // for string
+#include "uscxml/Common.h" // for USCXML_API
#include "uscxml/Interpreter.h"
#include "DOM/Element.hpp" // for Element
-#include "uscxml/Common.h" // for USCXML_API
#include "uscxml/messages/Data.h" // for Data
namespace uscxml {
diff --git a/src/uscxml/debug/Complexity.cpp b/src/uscxml/debug/Complexity.cpp
index 29d7706..a7f9f93 100644
--- a/src/uscxml/debug/Complexity.cpp
+++ b/src/uscxml/debug/Complexity.cpp
@@ -18,7 +18,7 @@
*/
#include "Complexity.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
#include <boost/algorithm/string.hpp>
@@ -97,7 +97,7 @@ std::map<size_t, size_t> Complexity::getTransitionHistogramm(const Arabica::DOM:
if (nameSpace.size() == 0 && elemIter->getPrefix().size() > 0)
nameSpace = elemIter->getPrefix() + ":";
}
- NodeSet<std::string> transitions = InterpreterImpl::filterChildElements(nameSpace + "transition", configNodeSet);
+ NodeSet<std::string> transitions = DOMUtils::filterChildElements(nameSpace + "transition", configNodeSet);
histogram[transitions.size()]++;
}
diff --git a/src/uscxml/debug/Debugger.cpp b/src/uscxml/debug/Debugger.cpp
index cb4d522..1a7d977 100644
--- a/src/uscxml/debug/Debugger.cpp
+++ b/src/uscxml/debug/Debugger.cpp
@@ -18,7 +18,7 @@
*/
#include "uscxml/debug/Debugger.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
#include "uscxml/debug/DebugSession.h"
namespace uscxml {
diff --git a/src/uscxml/debug/InterpreterIssue.cpp b/src/uscxml/debug/InterpreterIssue.cpp
index 6b97182..1fcfc00 100644
--- a/src/uscxml/debug/InterpreterIssue.cpp
+++ b/src/uscxml/debug/InterpreterIssue.cpp
@@ -20,7 +20,7 @@
#include <string>
#include "InterpreterIssue.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
#include "uscxml/debug/Complexity.h"
#include "uscxml/Interpreter.h"
#include "uscxml/Factory.h"
@@ -299,7 +299,7 @@ std::list<InterpreterIssue> InterpreterIssue::forInterpreter(InterpreterImpl* in
// check for valid transition with history states
if (LOCALNAME(state) == "history") {
- NodeSet<std::string> transitions = InterpreterImpl::filterChildElements(_nsInfo.xmlNSPrefix + "transition", state, false);
+ NodeSet<std::string> transitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", state, false);
if (transitions.size() > 1) {
issues.push_back(InterpreterIssue("History pseudo-state with id '" + stateId + "' has multiple transitions", state, InterpreterIssue::USCXML_ISSUE_FATAL));
} else if (transitions.size() == 0) {
@@ -350,7 +350,7 @@ std::list<InterpreterIssue> InterpreterIssue::forInterpreter(InterpreterImpl* in
// check for valid target
if (HAS_ATTR(transition, "target")) {
- std::list<std::string> targetIds = InterpreterImpl::tokenizeIdRefs(ATTR(transition, "target"));
+ std::list<std::string> targetIds = tokenize(ATTR(transition, "target"));
if (targetIds.size() == 0) {
issues.push_back(InterpreterIssue("Transition has empty target state list", transition, InterpreterIssue::USCXML_ISSUE_FATAL));
}
@@ -367,7 +367,7 @@ std::list<InterpreterIssue> InterpreterIssue::forInterpreter(InterpreterImpl* in
// check for redundancy of transition
for (int i = 0; i < allStates.size(); i++) {
Element<std::string> state = Element<std::string>(allStates[i]);
- NodeSet<std::string> transitions = InterpreterImpl::filterChildElements(_nsInfo.xmlNSPrefix + "transition", state, false);
+ NodeSet<std::string> transitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", state, false);
transitions.to_document_order();
@@ -386,11 +386,11 @@ std::list<InterpreterIssue> InterpreterIssue::forInterpreter(InterpreterImpl* in
} else if (HAS_ATTR(transition, "event")) {
// does the earlier transition match all our events?
- std::list<std::string> events = InterpreterImpl::tokenizeIdRefs(ATTR(transition, "event"));
+ std::list<std::string> events = tokenize(ATTR(transition, "event"));
bool allMatched = true;
for (std::list<std::string>::iterator eventIter = events.begin(); eventIter != events.end(); eventIter++) {
- if (!InterpreterImpl::nameMatch(ATTR(earlierTransition, "event"), *eventIter)) {
+ if (!nameMatch(ATTR(earlierTransition, "event"), *eventIter)) {
allMatched = false;
break;
}
@@ -438,12 +438,12 @@ NEXT_TRANSITION:
if (HAS_ATTR(state, "initial")) {
NodeSet<std::string> childs;
- childs.push_back(InterpreterImpl::filterChildElements(_nsInfo.xmlNSPrefix + "state", state, true));
- childs.push_back(InterpreterImpl::filterChildElements(_nsInfo.xmlNSPrefix + "parallel", state, true));
- childs.push_back(InterpreterImpl::filterChildElements(_nsInfo.xmlNSPrefix + "final", state, true));
- childs.push_back(InterpreterImpl::filterChildElements(_nsInfo.xmlNSPrefix + "history", state, true));
+ childs.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "state", state, true));
+ childs.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "parallel", state, true));
+ childs.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "final", state, true));
+ childs.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "history", state, true));
- std::list<std::string> intials = InterpreterImpl::tokenizeIdRefs(ATTR(state, "initial"));
+ std::list<std::string> intials = tokenize(ATTR(state, "initial"));
for (std::list<std::string>::iterator initIter = intials.begin(); initIter != intials.end(); initIter++) {
if (seenStates.find(*initIter) == seenStates.end()) {
issues.push_back(InterpreterIssue("Initial attribute has invalid target state with id '" + *initIter + "'", state, InterpreterIssue::USCXML_ISSUE_FATAL));
@@ -489,7 +489,7 @@ NEXT_TRANSITION:
setIter != targetIdSets.end();
setIter++) {
NodeSet<std::string> targets;
- std::list<std::string> targetIds = InterpreterImpl::tokenizeIdRefs(setIter->second);
+ std::list<std::string> targetIds = tokenize(setIter->second);
for (std::list<std::string>::iterator tgtIter = targetIds.begin(); tgtIter != targetIds.end(); tgtIter++) {
if (seenStates.find(*tgtIter) == seenStates.end())
goto NEXT_SET;
@@ -506,11 +506,11 @@ NEXT_SET:
// check for valid initial transition
{
NodeSet<std::string> initTrans;
-// initTrans.push_back(InterpreterImpl::filterChildElements(_nsInfo.xmlNSPrefix + "transition", histories, true));
+// initTrans.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", histories, true));
for (int i = 0; i < initials.size(); i++) {
Element<std::string> initial = Element<std::string>(initials[i]);
- NodeSet<std::string> initTransitions = InterpreterImpl::filterChildElements(_nsInfo.xmlNSPrefix + "transition", initial, true);
+ NodeSet<std::string> initTransitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", initial, true);
if (initTransitions.size() != 1) {
issues.push_back(InterpreterIssue("Initial element must define exactly one transition", initial, InterpreterIssue::USCXML_ISSUE_FATAL));
}
@@ -539,12 +539,12 @@ NEXT_SET:
continue; // syntax will catch this one
NodeSet<std::string> childs;
- childs.push_back(InterpreterImpl::filterChildElements(_nsInfo.xmlNSPrefix + "state", state, true));
- childs.push_back(InterpreterImpl::filterChildElements(_nsInfo.xmlNSPrefix + "parallel", state, true));
- childs.push_back(InterpreterImpl::filterChildElements(_nsInfo.xmlNSPrefix + "final", state, true));
- childs.push_back(InterpreterImpl::filterChildElements(_nsInfo.xmlNSPrefix + "history", state, true));
+ childs.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "state", state, true));
+ childs.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "parallel", state, true));
+ childs.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "final", state, true));
+ childs.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "history", state, true));
- std::list<std::string> intials = InterpreterImpl::tokenizeIdRefs(ATTR(transition, "target"));
+ std::list<std::string> intials = tokenize(ATTR(transition, "target"));
for (std::list<std::string>::iterator initIter = intials.begin(); initIter != intials.end(); initIter++) {
// the 'target' of a <transition> inside an <initial> or <history> element: all the states must be descendants of the containing <state> or <parallel> element
if (!InterpreterImpl::isMember(seenStates[*initIter], childs)) {
@@ -602,7 +602,7 @@ NEXT_SET:
for (int i = 0; i < allExecContentContainers.size(); i++) {
Element<std::string> block = Element<std::string>(allExecContentContainers[i]);
- NodeSet<std::string> execContents = InterpreterImpl::filterChildType(Node_base::ELEMENT_NODE, block);
+ NodeSet<std::string> execContents = DOMUtils::filterChildType(Node_base::ELEMENT_NODE, block);
for (int j = 0; j < execContents.size(); j++) {
Element<std::string> execContent = Element<std::string>(execContents[j]);
// SCXML specific executable content, always available
@@ -723,8 +723,8 @@ NEXT_SET:
issues.push_back(InterpreterIssue("Send element cannot have delay with target _internal", send, InterpreterIssue::USCXML_ISSUE_WARNING));
}
- NodeSet<std::string> contentChilds = InterpreterImpl::filterChildElements(_nsInfo.xmlNSPrefix + "content", send, false);
- NodeSet<std::string> paramChilds = InterpreterImpl::filterChildElements(_nsInfo.xmlNSPrefix + "param", send, false);
+ NodeSet<std::string> contentChilds = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "content", send, false);
+ NodeSet<std::string> paramChilds = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "param", send, false);
if (HAS_ATTR(send, "namelist") && contentChilds.size() > 0) {
issues.push_back(InterpreterIssue("Send element cannot have namelist attribute and content child", send, InterpreterIssue::USCXML_ISSUE_WARNING));
@@ -753,18 +753,18 @@ NEXT_SET:
if (HAS_ATTR(invoke, "id") && HAS_ATTR(invoke, "idlocation")) {
issues.push_back(InterpreterIssue("Invoke element cannot have both id and idlocation attribute", invoke, InterpreterIssue::USCXML_ISSUE_WARNING));
}
- if (HAS_ATTR(invoke, "namelist") && InterpreterImpl::filterChildElements(_nsInfo.xmlNSPrefix + "param", invoke, false).size() > 0) {
+ if (HAS_ATTR(invoke, "namelist") && DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "param", invoke, false).size() > 0) {
issues.push_back(InterpreterIssue("Invoke element cannot have namelist attribute and param child", invoke, InterpreterIssue::USCXML_ISSUE_WARNING));
}
- if (HAS_ATTR(invoke, "src") && InterpreterImpl::filterChildElements(_nsInfo.xmlNSPrefix + "content", invoke, false).size() > 0) {
+ if (HAS_ATTR(invoke, "src") && DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "content", invoke, false).size() > 0) {
issues.push_back(InterpreterIssue("Invoke element cannot have src attribute and content child", invoke, InterpreterIssue::USCXML_ISSUE_WARNING));
}
}
for (int i = 0; i < doneDatas.size(); i++) {
Element<std::string> donedata = Element<std::string>(doneDatas[i]);
- if (InterpreterImpl::filterChildElements(_nsInfo.xmlNSPrefix + "content", donedata, false).size() > 0 &&
- InterpreterImpl::filterChildElements(_nsInfo.xmlNSPrefix + "param", donedata, false).size() > 0) {
+ if (DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "content", donedata, false).size() > 0 &&
+ DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "param", donedata, false).size() > 0) {
issues.push_back(InterpreterIssue("Donedata element cannot have param child and content child", donedata, InterpreterIssue::USCXML_ISSUE_WARNING));
}
diff --git a/src/uscxml/debug/InterpreterIssue.h b/src/uscxml/debug/InterpreterIssue.h
index 5959d07..61b3b6a 100644
--- a/src/uscxml/debug/InterpreterIssue.h
+++ b/src/uscxml/debug/InterpreterIssue.h
@@ -22,6 +22,7 @@
#include "uscxml/Common.h"
#include <list>
+#include <iostream>
#include <DOM/Node.hpp>
namespace uscxml {
diff --git a/src/uscxml/debug/SCXMLDotWriter.cpp b/src/uscxml/debug/SCXMLDotWriter.cpp
index 82faaa4..a6ec0b6 100644
--- a/src/uscxml/debug/SCXMLDotWriter.cpp
+++ b/src/uscxml/debug/SCXMLDotWriter.cpp
@@ -21,7 +21,7 @@
#include "uscxml/UUID.h"
#include "SCXMLDotWriter.h"
#include "../transform/FlatStateIdentifier.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
#include <boost/algorithm/string.hpp> // replace_all
#include <iomanip>
@@ -199,7 +199,7 @@ void SCXMLDotWriter::assembleGraph(const Element<std::string>& state, int32_t ch
}
- NodeSet<std::string> childElems = InterpreterImpl::filterChildType(Node_base::ELEMENT_NODE, state);
+ NodeSet<std::string> childElems = DOMUtils::filterChildType(Node_base::ELEMENT_NODE, state);
for (int i = 0; i < childElems.size(); i++) {
Element<std::string> childElem(childElems[i]);
@@ -225,7 +225,7 @@ void SCXMLDotWriter::assembleGraph(const Element<std::string>& state, int32_t ch
std::list<std::string> eventNames;
if (HAS_ATTR(childElem, "event"))
- eventNames = InterpreterImpl::tokenizeIdRefs(ATTR(childElem, "event"));
+ eventNames = tokenize(ATTR(childElem, "event"));
if (eventNames.size() == 0)
_graph[nodeId].events.insert(std::make_pair("", childElem));
for (std::list<std::string>::iterator evIter = eventNames.begin(); evIter != eventNames.end(); evIter++) {
@@ -399,7 +399,7 @@ void SCXMLDotWriter::writeStateElement(std::ostream& os, const Element<std::stri
}
// write history states
- NodeSet<std::string> histories = InterpreterImpl::filterChildElements(_xmlNSPrefix + "history", stateElem);
+ NodeSet<std::string> histories = DOMUtils::filterChildElements(_xmlNSPrefix + "history", stateElem);
for (int i = 0; i < histories.size(); i++) {
os << " <tr><td port=\"" << portEscape(ATTR_CAST(histories[i], "id")) << "\" balign=\"left\" colspan=\"" << (nrOutPorts == 0 ? 1 : 2) << "\"><b>history: </b>" << ATTR_CAST(histories[i], "id") << "</td></tr>" << std::endl;
@@ -421,7 +421,7 @@ void SCXMLDotWriter::writeStateElement(std::ostream& os, const Element<std::stri
}
// recurse into children and search others to draw
- NodeSet<std::string> childElems = InterpreterImpl::filterChildType(Node_base::ELEMENT_NODE, stateElem);
+ NodeSet<std::string> childElems = DOMUtils::filterChildType(Node_base::ELEMENT_NODE, stateElem);
for (int i = 0; i < childElems.size(); i++) {
Element<std::string> childElem(childElems[i]);
if (InterpreterImpl::isState(Element<std::string>(childElem))) {
@@ -538,7 +538,7 @@ void SCXMLDotWriter::writePerTargetPorts(std::ostream& os, const DotState& dotSt
for (iter_t::const_iterator transIter = targetKeyRange.first; transIter != targetKeyRange.second; ++transIter) {
const Element<std::string>& transElem = transIter->second;
- std::list<std::string> events = InterpreterImpl::tokenizeIdRefs(ATTR(transElem, "event"));
+ std::list<std::string> events = tokenize(ATTR(transElem, "event"));
eventNames.insert(events.begin(), events.end());
if (events.size() == 0) {
diff --git a/src/uscxml/DOMUtils.cpp b/src/uscxml/dom/DOMUtils.cpp
index 414b5e7..137d0ef 100644
--- a/src/uscxml/DOMUtils.cpp
+++ b/src/uscxml/dom/DOMUtils.cpp
@@ -17,12 +17,13 @@
* @endcond
*/
-#include <uscxml/Common.h>
+#include "uscxml/Common.h"
#include "uscxml/UUID.h"
-#include "uscxml/DOMUtils.h"
-#include <uscxml/Convenience.h>
+#include "uscxml/dom/DOMUtils.h"
+#include "uscxml/Convenience.h"
+
#include <glog/logging.h>
-#include <SAX/helpers/InputSourceResolver.hpp>
+#include <boost/algorithm/string.hpp>
namespace uscxml {
@@ -227,44 +228,61 @@ std::list<Arabica::DOM::Node<std::string> > DOMUtils::getElementsByType(const Ar
return result;
}
-NameSpacingParser NameSpacingParser::fromFile(const std::string& file) {
- Arabica::SAX::InputSource<std::string> inputSource;
- inputSource.setSystemId(file);
- return fromInputSource(inputSource);
-}
-NameSpacingParser NameSpacingParser::fromXML(const std::string& xml) {
- std::stringstream* ss = new std::stringstream();
- (*ss) << xml;
- // we need an auto_ptr for arabica to assume ownership
- std::auto_ptr<std::istream> ssPtr(ss);
- Arabica::SAX::InputSource<std::string> inputSource;
- inputSource.setByteStream(ssPtr);
- return fromInputSource(inputSource);
+NodeSet<std::string> DOMUtils::filterChildElements(const std::string& tagName, const NodeSet<std::string>& nodeSet, bool recurse) {
+ NodeSet<std::string> filteredChildElems;
+ for (unsigned int i = 0; i < nodeSet.size(); i++) {
+ filteredChildElems.push_back(filterChildElements(tagName, nodeSet[i], recurse));
+ }
+ return filteredChildElems;
}
-NameSpacingParser NameSpacingParser::fromInputSource(Arabica::SAX::InputSource<std::string>& source) {
- NameSpacingParser parser;
- if(!parser.parse(source) || !parser.getDocument().hasChildNodes()) {
- if(parser._errorHandler.errorsReported()) {
-// LOG(ERROR) << "could not parse input:";
-// LOG(ERROR) << parser._errorHandler.errors() << std::endl;
- } else {
- Arabica::SAX::InputSourceResolver resolver(source, Arabica::default_string_adaptor<std::string>());
- if (!resolver.resolve()) {
- LOG(ERROR) << source.getSystemId() << ": no such file";
- }
+NodeSet<std::string> DOMUtils::filterChildElements(const std::string& tagName, const Node<std::string>& node, bool recurse) {
+ NodeSet<std::string> filteredChildElems;
+
+ if (!node)
+ return filteredChildElems;
+
+ NodeList<std::string> childs = node.getChildNodes();
+ for (unsigned int i = 0; i < childs.getLength(); i++) {
+ if (childs.item(i).getNodeType() != Node_base::ELEMENT_NODE)
+ continue;
+ // std::cerr << TAGNAME(childs.item(i)) << std::endl;
+ if(iequals(TAGNAME_CAST(childs.item(i)), tagName)) {
+ filteredChildElems.push_back(childs.item(i));
+ }
+ if (recurse) {
+ filteredChildElems.push_back(filterChildElements(tagName, childs.item(i), recurse));
}
}
- return parser;
+ return filteredChildElems;
}
-NameSpacingParser::NameSpacingParser() {
- setErrorHandler(_errorHandler);
+
+NodeSet<std::string> DOMUtils::filterChildType(const Node_base::Type type, const NodeSet<std::string>& nodeSet, bool recurse) {
+ NodeSet<std::string> filteredChildType;
+ for (unsigned int i = 0; i < nodeSet.size(); i++) {
+ filteredChildType.push_back(filterChildType(type, nodeSet[i], recurse));
+ }
+ return filteredChildType;
}
-void NameSpacingParser::startPrefixMapping(const std::string& prefix, const std::string& uri) {
- nameSpace.insert(std::make_pair(uri, prefix));
+NodeSet<std::string> DOMUtils::filterChildType(const Node_base::Type type, const Node<std::string>& node, bool recurse) {
+ NodeSet<std::string> filteredChildTypes;
+
+ if (!node)
+ return filteredChildTypes;
+
+ NodeList<std::string> childs = node.getChildNodes();
+ for (unsigned int i = 0; i < childs.getLength(); i++) {
+ if (childs.item(i).getNodeType() == type)
+ filteredChildTypes.push_back(childs.item(i));
+ if (recurse) {
+ filteredChildTypes.push_back(filterChildType(type, childs.item(i), recurse));
+ }
+ }
+ return filteredChildTypes;
}
+
} \ No newline at end of file
diff --git a/src/uscxml/DOMUtils.h b/src/uscxml/dom/DOMUtils.h
index ab99759..5c61f6d 100644
--- a/src/uscxml/DOMUtils.h
+++ b/src/uscxml/dom/DOMUtils.h
@@ -21,9 +21,9 @@
#define DOMUTILS_H_WK0WAEA7
#include "uscxml/Common.h"
-#include <DOM/SAX2DOM/SAX2DOM.hpp>
-#include <SAX/helpers/DefaultHandler.hpp>
-#include <SAX/helpers/CatchErrorHandler.hpp>
+#include <vector>
+#include <iostream>
+#include <DOM/Document.hpp>
#include <DOM/io/Stream.hpp> // operator<< for nodes
#include <XPath/XPath.hpp>
@@ -73,6 +73,23 @@ public:
static Arabica::XPath::NodeSet<std::string> inDocumentOrder(const std::set<std::string>& elements,
const Arabica::DOM::Element<std::string>& root,
const bool includeEmbeddedDoc = false);
+
+ static Arabica::XPath::NodeSet<std::string> filterChildElements(const std::string& tagname,
+ const Arabica::DOM::Node<std::string>& node,
+ bool recurse = false);
+
+ static Arabica::XPath::NodeSet<std::string> filterChildElements(const std::string& tagName,
+ const Arabica::XPath::NodeSet<std::string>& nodeSet,
+ bool recurse = false);
+
+ static Arabica::XPath::NodeSet<std::string> filterChildType(const Arabica::DOM::Node_base::Type type,
+ const Arabica::DOM::Node<std::string>& node,
+ bool recurse = false);
+
+ static Arabica::XPath::NodeSet<std::string> filterChildType(const Arabica::DOM::Node_base::Type type,
+ const Arabica::XPath::NodeSet<std::string>& nodeSet,
+ bool recurse = false);
+
protected:
static void inPostFixOrder(const std::set<std::string>& elements,
const Arabica::DOM::Element<std::string>& root,
@@ -84,38 +101,9 @@ protected:
const bool includeEmbeddedDoc,
Arabica::XPath::NodeSet<std::string>& nodes);
-};
-class ScriptEntityResolver : public Arabica::SAX::EntityResolver<std::string> {
- virtual InputSourceT resolveEntity(const std::string& publicId, const std::string& systemId) {
- Arabica::SAX::InputSource<std::string> is;
- return is;
- }
};
-class USCXML_API NameSpacingParser : public Arabica::SAX2DOM::Parser<std::string> {
-public:
- NameSpacingParser();
- NameSpacingParser(const NameSpacingParser& other) {}
- static NameSpacingParser fromFile(const std::string& file);
- static NameSpacingParser fromXML(const std::string& xml);
- static NameSpacingParser fromInputSource(Arabica::SAX::InputSource<std::string>& source);
-
- void startPrefixMapping(const std::string& prefix, const std::string& uri);
-
- std::map<std::string, std::string> nameSpace;
-
- virtual bool errorsReported() {
- return _errorHandler.errorsReported();
- }
-
- virtual const std::string& errors() {
- return _errorHandler.errors();
- }
-
-private:
- Arabica::SAX::CatchErrorHandler<std::string> _errorHandler;
-};
}
diff --git a/src/uscxml/dom/NameSpacingParser.cpp b/src/uscxml/dom/NameSpacingParser.cpp
new file mode 100644
index 0000000..0e26b55
--- /dev/null
+++ b/src/uscxml/dom/NameSpacingParser.cpp
@@ -0,0 +1,71 @@
+/**
+ * @file
+ * @author 2016 Stefan Radomski (stefan.radomski@cs.tu-darmstadt.de)
+ * @copyright Simplified BSD
+ *
+ * @cond
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the FreeBSD license as published by the FreeBSD
+ * project.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the FreeBSD license along with this
+ * program. If not, see <http://www.opensource.org/licenses/bsd-license>.
+ * @endcond
+ */
+
+#include "uscxml/dom/NameSpacingParser.h"
+#include <uscxml/Convenience.h>
+#include <glog/logging.h>
+#include <SAX/helpers/InputSourceResolver.hpp>
+
+namespace uscxml {
+
+using namespace Arabica::XPath;
+using namespace Arabica::DOM;
+
+NameSpacingParser NameSpacingParser::fromFile(const std::string& file) {
+ Arabica::SAX::InputSource<std::string> inputSource;
+ inputSource.setSystemId(file);
+ return fromInputSource(inputSource);
+}
+
+NameSpacingParser NameSpacingParser::fromXML(const std::string& xml) {
+ std::stringstream* ss = new std::stringstream();
+ (*ss) << xml;
+ // we need an auto_ptr for arabica to assume ownership
+ std::auto_ptr<std::istream> ssPtr(ss);
+ Arabica::SAX::InputSource<std::string> inputSource;
+ inputSource.setByteStream(ssPtr);
+ return fromInputSource(inputSource);
+}
+
+NameSpacingParser NameSpacingParser::fromInputSource(Arabica::SAX::InputSource<std::string>& source) {
+ NameSpacingParser parser;
+ if(!parser.parse(source) || !parser.getDocument().hasChildNodes()) {
+ if(parser._errorHandler.errorsReported()) {
+// LOG(ERROR) << "could not parse input:";
+// LOG(ERROR) << parser._errorHandler.errors() << std::endl;
+ } else {
+ Arabica::SAX::InputSourceResolver resolver(source, Arabica::default_string_adaptor<std::string>());
+ if (!resolver.resolve()) {
+ LOG(ERROR) << source.getSystemId() << ": no such file";
+ }
+ }
+ }
+ return parser;
+}
+
+NameSpacingParser::NameSpacingParser() {
+ setErrorHandler(_errorHandler);
+}
+
+void NameSpacingParser::startPrefixMapping(const std::string& prefix, const std::string& uri) {
+ nameSpace.insert(std::make_pair(uri, prefix));
+}
+
+
+} \ No newline at end of file
diff --git a/src/uscxml/dom/NameSpacingParser.h b/src/uscxml/dom/NameSpacingParser.h
new file mode 100644
index 0000000..1aa85a2
--- /dev/null
+++ b/src/uscxml/dom/NameSpacingParser.h
@@ -0,0 +1,67 @@
+/**
+ * @file
+ * @author 2016 Stefan Radomski (stefan.radomski@cs.tu-darmstadt.de)
+ * @copyright Simplified BSD
+ *
+ * @cond
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the FreeBSD license as published by the FreeBSD
+ * project.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the FreeBSD license along with this
+ * program. If not, see <http://www.opensource.org/licenses/bsd-license>.
+ * @endcond
+ */
+
+#ifndef NAMESPACINGPARSER_H_BD6902F6
+#define NAMESPACINGPARSER_H_BD6902F6
+
+#include "uscxml/Common.h"
+#include <iostream>
+#include <XPath/XPath.hpp>
+#include <DOM/io/Stream.hpp> // operator<< for nodes
+#include <DOM/SAX2DOM/SAX2DOM.hpp>
+#include <SAX/helpers/DefaultHandler.hpp>
+#include <SAX/helpers/CatchErrorHandler.hpp>
+
+namespace uscxml {
+
+class ScriptEntityResolver : public Arabica::SAX::EntityResolver<std::string> {
+ virtual InputSourceT resolveEntity(const std::string& publicId, const std::string& systemId) {
+ Arabica::SAX::InputSource<std::string> is;
+ return is;
+ }
+};
+
+class USCXML_API NameSpacingParser : public Arabica::SAX2DOM::Parser<std::string> {
+public:
+ NameSpacingParser();
+ NameSpacingParser(const NameSpacingParser& other) {}
+ static NameSpacingParser fromFile(const std::string& file);
+ static NameSpacingParser fromXML(const std::string& xml);
+ static NameSpacingParser fromInputSource(Arabica::SAX::InputSource<std::string>& source);
+
+ void startPrefixMapping(const std::string& prefix, const std::string& uri);
+
+ std::map<std::string, std::string> nameSpace;
+
+ virtual bool errorsReported() {
+ return _errorHandler.errorsReported();
+ }
+
+ virtual const std::string& errors() {
+ return _errorHandler.errors();
+ }
+
+private:
+ Arabica::SAX::CatchErrorHandler<std::string> _errorHandler;
+};
+
+}
+
+
+#endif /* end of include guard: NAMESPACINGPARSER_H_BD6902F6 */
diff --git a/src/uscxml/interpreter/InterpreterDraft6.cpp b/src/uscxml/interpreter/InterpreterDraft6.cpp
index f79049d..a8bf97b 100644
--- a/src/uscxml/interpreter/InterpreterDraft6.cpp
+++ b/src/uscxml/interpreter/InterpreterDraft6.cpp
@@ -22,7 +22,7 @@
#include <glog/logging.h>
#include "uscxml/UUID.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
#define VERBOSE 0
@@ -208,7 +208,7 @@ void InterpreterDraft6::exitStates(const Arabica::XPath::NodeSet<std::string>& e
#endif
for (int i = 0; i < statesToExit.size(); i++) {
- NodeSet<std::string> histories = filterChildElements(_nsInfo.xmlNSPrefix + "history", statesToExit[i]);
+ NodeSet<std::string> histories = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "history", statesToExit[i]);
for (int j = 0; j < histories.size(); j++) {
Element<std::string> historyElem = (Element<std::string>)histories[j];
std::string historyType = (historyElem.hasAttribute("type") ? historyElem.getAttribute("type") : "shallow");
@@ -237,7 +237,7 @@ void InterpreterDraft6::exitStates(const Arabica::XPath::NodeSet<std::string>& e
for (int i = 0; i < statesToExit.size(); i++) {
USCXML_MONITOR_CALLBACK3(beforeExitingState, Element<std::string>(statesToExit[i]), (i + 1 < statesToExit.size()))
- NodeSet<std::string> onExits = filterChildElements(_nsInfo.xmlNSPrefix + "onExit", statesToExit[i]);
+ NodeSet<std::string> onExits = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "onExit", statesToExit[i]);
for (int j = 0; j < onExits.size(); j++) {
Element<std::string> onExitElem = (Element<std::string>)onExits[j];
executeContent(onExitElem);
@@ -245,7 +245,7 @@ void InterpreterDraft6::exitStates(const Arabica::XPath::NodeSet<std::string>& e
USCXML_MONITOR_CALLBACK3(afterExitingState, Element<std::string>(statesToExit[i]), (i + 1 < statesToExit.size()))
- NodeSet<std::string> invokes = filterChildElements(_nsInfo.xmlNSPrefix + "invoke", statesToExit[i]);
+ NodeSet<std::string> invokes = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "invoke", statesToExit[i]);
for (int j = 0; j < invokes.size(); j++) {
Element<std::string> invokeElem = (Element<std::string>)invokes[j];
if (HAS_ATTR(invokeElem, "persist") && stringIsTrue(ATTR(invokeElem, "persist"))) {
@@ -384,7 +384,7 @@ void InterpreterDraft6::enterStates(const Arabica::XPath::NodeSet<std::string>&
// extension for flattened interpreters
for (unsigned int k = 0; k < statesToEnter.size(); k++) {
- NodeSet<std::string> invokes = filterChildElements(_nsInfo.xmlNSPrefix + "invoke", statesToEnter[k]);
+ NodeSet<std::string> invokes = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "invoke", statesToEnter[k]);
for (unsigned int j = 0; j < invokes.size(); j++) {
Element<std::string> invokeElem = Element<std::string>(invokes[j]);
if (HAS_ATTR(invokeElem, "persist") && stringIsTrue(ATTR(invokeElem, "persist"))) {
@@ -396,7 +396,7 @@ void InterpreterDraft6::enterStates(const Arabica::XPath::NodeSet<std::string>&
USCXML_MONITOR_CALLBACK3(beforeEnteringState, stateElem, (i + 1 < statesToEnter.size()))
// extension for flattened SCXML documents, we will need an explicit uninvoke element
- NodeSet<std::string> uninvokes = filterChildElements(_nsInfo.xmlNSPrefix + "uninvoke", statesToEnter[i]);
+ NodeSet<std::string> uninvokes = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "uninvoke", statesToEnter[i]);
for (int j = 0; j < uninvokes.size(); j++) {
Element<std::string> uninvokeElem = (Element<std::string>)uninvokes[j];
cancelInvoke(uninvokeElem);
@@ -406,9 +406,9 @@ void InterpreterDraft6::enterStates(const Arabica::XPath::NodeSet<std::string>&
_statesToInvoke.push_back(stateElem);
if (_binding == LATE && !isMember(stateElem, _alreadyEntered)) {
- NodeSet<std::string> dataModelElems = filterChildElements(_nsInfo.xmlNSPrefix + "datamodel", stateElem);
+ NodeSet<std::string> dataModelElems = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "datamodel", stateElem);
if(dataModelElems.size() > 0 && _dataModel) {
- Arabica::XPath::NodeSet<std::string> dataElems = filterChildElements(_nsInfo.xmlNSPrefix + "data", dataModelElems[0]);
+ Arabica::XPath::NodeSet<std::string> dataElems = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "data", dataModelElems[0]);
for (int j = 0; j < dataElems.size(); j++) {
if (dataElems[j].getNodeType() == Node_base::ELEMENT_NODE)
initializeData(Element<std::string>(dataElems[j]));
@@ -417,7 +417,7 @@ void InterpreterDraft6::enterStates(const Arabica::XPath::NodeSet<std::string>&
_alreadyEntered.push_back(stateElem);
}
// execute onentry executable content
- NodeSet<std::string> onEntryElems = filterChildElements(_nsInfo.xmlNSPrefix + "onEntry", stateElem);
+ NodeSet<std::string> onEntryElems = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "onEntry", stateElem);
executeContent(onEntryElems, false);
USCXML_MONITOR_CALLBACK3(afterEnteringState, stateElem, (i + 1 < statesToEnter.size()))
@@ -443,7 +443,7 @@ void InterpreterDraft6::enterStates(const Arabica::XPath::NodeSet<std::string>&
if (isFinal(stateElem)) {
Arabica::DOM::Element<std::string> doneData;
- Arabica::XPath::NodeSet<std::string> doneDatas = filterChildElements(_nsInfo.xmlNSPrefix + "donedata", stateElem);
+ Arabica::XPath::NodeSet<std::string> doneDatas = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "donedata", stateElem);
if (doneDatas.size() > 0) {
// only process first donedata element
doneData = Element<std::string>(doneDatas[0]);
@@ -518,7 +518,7 @@ void InterpreterDraft6::addStatesToEnter(const Element<std::string>& state,
}
} else {
defaultHistoryContent.push_back(getParentState(state));
- NodeSet<std::string> transitions = filterChildElements(_nsInfo.xmlNSPrefix + "transition", state);
+ NodeSet<std::string> transitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", state);
for (int i = 0; i < transitions.size(); i++) {
NodeSet<std::string> targets = getTargetStates(Element<std::string>(transitions[i]));
for (int j = 0; j < targets.size(); j++) {
@@ -561,7 +561,7 @@ void InterpreterDraft6::handleDOMEvent(Arabica::DOM::Events::Event<std::string>&
if (event.getType().compare("DOMAttrModified") == 0) // we do not care about attributes
return;
Node<std::string> target = Arabica::DOM::Node<std::string>(event.getTarget());
- NodeSet<std::string> transitions = InterpreterImpl::filterChildElements(_nsInfo.xmlNSPrefix + "transition", target, true);
+ NodeSet<std::string> transitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", target, true);
for (int i = 0; i < transitions.size(); i++) {
const Element<std::string> transElem = Element<std::string>(transitions[i]);
if (_transWithinParallel.find(transElem) != _transWithinParallel.end())
diff --git a/src/uscxml/interpreter/InterpreterFast.cpp b/src/uscxml/interpreter/InterpreterFast.cpp
index 94fcdce..ab5dce0 100644
--- a/src/uscxml/interpreter/InterpreterFast.cpp
+++ b/src/uscxml/interpreter/InterpreterFast.cpp
@@ -24,7 +24,7 @@
#include <glog/logging.h>
#include "uscxml/UUID.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
namespace uscxml {
diff --git a/src/uscxml/interpreter/InterpreterRC.cpp b/src/uscxml/interpreter/InterpreterRC.cpp
index e1f4ada..d959e3d 100644
--- a/src/uscxml/interpreter/InterpreterRC.cpp
+++ b/src/uscxml/interpreter/InterpreterRC.cpp
@@ -24,7 +24,7 @@
#include <glog/logging.h>
#include "uscxml/UUID.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
#define VERBOSE 0
#define VERBOSE_STATE_SELECTION 0
@@ -66,7 +66,7 @@ Arabica::XPath::NodeSet<std::string> InterpreterRC::removeConflictingTransitions
}
if (!t1Preempted) {
- // remove transitionsToRemove from filteredTransitions
+ // remove transitionsToRemove from DOMUtils::filteredTransitions
std::list<Node<std::string> > tmp;
for (int i = 0; i < filteredTransitions.size(); i++) {
if (!isMember(filteredTransitions[i], transitionsToRemove)) {
@@ -119,7 +119,7 @@ void InterpreterRC::exitStates(const Arabica::XPath::NodeSet<std::string>& enabl
for (int i = 0; i < statesToExit.size(); i++) {
- NodeSet<std::string> histories = filterChildElements(_nsInfo.xmlNSPrefix + "history", statesToExit[i]);
+ NodeSet<std::string> histories = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "history", statesToExit[i]);
for (int j = 0; j < histories.size(); j++) {
Element<std::string> historyElem = (Element<std::string>)histories[j];
std::string historyType = (historyElem.hasAttribute("type") ? historyElem.getAttribute("type") : "shallow");
@@ -140,7 +140,7 @@ void InterpreterRC::exitStates(const Arabica::XPath::NodeSet<std::string>& enabl
for (int i = 0; i < statesToExit.size(); i++) {
USCXML_MONITOR_CALLBACK3(beforeExitingState, Element<std::string>(statesToExit[i]), (i + 1 < statesToExit.size()))
- NodeSet<std::string> onExits = filterChildElements(_nsInfo.xmlNSPrefix + "onExit", statesToExit[i]);
+ NodeSet<std::string> onExits = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "onExit", statesToExit[i]);
for (int j = 0; j < onExits.size(); j++) {
Element<std::string> onExitElem = (Element<std::string>)onExits[j];
executeContent(onExitElem);
@@ -148,7 +148,7 @@ void InterpreterRC::exitStates(const Arabica::XPath::NodeSet<std::string>& enabl
USCXML_MONITOR_CALLBACK3(afterExitingState, Element<std::string>(statesToExit[i]), (i + 1 < statesToExit.size()))
- NodeSet<std::string> invokes = filterChildElements(_nsInfo.xmlNSPrefix + "invoke", statesToExit[i]);
+ NodeSet<std::string> invokes = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "invoke", statesToExit[i]);
for (int j = 0; j < invokes.size(); j++) {
Element<std::string> invokeElem = (Element<std::string>)invokes[j];
if (HAS_ATTR(invokeElem, "persist") && stringIsTrue(ATTR(invokeElem, "persist"))) {
@@ -254,9 +254,9 @@ void InterpreterRC::enterStates(const Arabica::XPath::NodeSet<std::string>& enab
_statesToInvoke.push_back(s);
if (_binding == LATE && !isMember(s, _alreadyEntered)) {
- NodeSet<std::string> dataModelElems = filterChildElements(_nsInfo.xmlNSPrefix + "datamodel", s);
+ NodeSet<std::string> dataModelElems = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "datamodel", s);
if(dataModelElems.size() > 0 && _dataModel) {
- Arabica::XPath::NodeSet<std::string> dataElems = filterChildElements(_nsInfo.xmlNSPrefix + "data", dataModelElems[0]);
+ Arabica::XPath::NodeSet<std::string> dataElems = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "data", dataModelElems[0]);
for (int j = 0; j < dataElems.size(); j++) {
if (dataElems[j].getNodeType() == Node_base::ELEMENT_NODE)
initializeData(Element<std::string>(dataElems[j]));
@@ -265,7 +265,7 @@ void InterpreterRC::enterStates(const Arabica::XPath::NodeSet<std::string>& enab
_alreadyEntered.push_back(s);
}
// execute onentry executable content
- NodeSet<std::string> onEntryElems = filterChildElements(_nsInfo.xmlNSPrefix + "onEntry", s);
+ NodeSet<std::string> onEntryElems = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "onEntry", s);
executeContent(onEntryElems, false);
if (isMember(s, statesForDefaultEntry)) {
@@ -280,7 +280,7 @@ void InterpreterRC::enterStates(const Arabica::XPath::NodeSet<std::string>& enab
if (HAS_ATTR(_scxml, "flat") && stringIsTrue(ATTR(_scxml, "flat"))) {
// extension for flattened interpreters
- NodeSet<std::string> invokes = filterChildElements(_nsInfo.xmlNSPrefix + "invoke", s);
+ NodeSet<std::string> invokes = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "invoke", s);
for (unsigned int j = 0; j < invokes.size(); j++) {
Element<std::string> invokeElem = Element<std::string>(invokes[j]);
if (HAS_ATTR(invokeElem, "persist") && stringIsTrue(ATTR(invokeElem, "persist"))) {
@@ -289,7 +289,7 @@ void InterpreterRC::enterStates(const Arabica::XPath::NodeSet<std::string>& enab
}
// extension for flattened SCXML documents, we will need an explicit uninvoke element
- NodeSet<std::string> uninvokes = filterChildElements(_nsInfo.xmlNSPrefix + "uninvoke", s);
+ NodeSet<std::string> uninvokes = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "uninvoke", s);
for (int j = 0; j < uninvokes.size(); j++) {
Element<std::string> uninvokeElem = (Element<std::string>)uninvokes[j];
cancelInvoke(uninvokeElem);
@@ -305,7 +305,7 @@ void InterpreterRC::enterStates(const Arabica::XPath::NodeSet<std::string>& enab
Element<std::string> parent = (Element<std::string>)s.getParentNode();
Arabica::DOM::Element<std::string> doneData;
- Arabica::XPath::NodeSet<std::string> doneDatas = filterChildElements(_nsInfo.xmlNSPrefix + "donedata", s);
+ Arabica::XPath::NodeSet<std::string> doneDatas = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "donedata", s);
if (doneDatas.size() > 0) {
// only process first donedata element
doneData = Element<std::string>(doneDatas[0]);
@@ -408,7 +408,7 @@ Arabica::XPath::NodeSet<std::string> InterpreterRC::getEffectiveTargetStates(con
if (_historyValue.find(ATTR(s, "id")) != _historyValue.end()) {
targets.push_back(_historyValue[ATTR(s, "id")]);
} else {
- NodeSet<std::string> histTrans = filterChildElements(_nsInfo.xmlNSPrefix + "transition", s);
+ NodeSet<std::string> histTrans = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", s);
// TODO: what if there are many history transitions?
if (histTrans.size() > 0)
targets.push_back(getEffectiveTargetStates(Element<std::string>(histTrans[0])));
@@ -489,7 +489,7 @@ void InterpreterRC::addDescendantStatesToEnter(const Arabica::DOM::Element<std::
}
} else {
- NodeSet<std::string> transitions = filterChildElements(_nsInfo.xmlNSPrefix + "transition", state);
+ NodeSet<std::string> transitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", state);
if (transitions.size() > 0) {
// TODO: what if there are many history transitions?
// std::cout << "HIST: " << ATTR_CAST(getParentState(state), "id") << std::endl;
@@ -653,7 +653,7 @@ void InterpreterRC::handleDOMEvent(Arabica::DOM::Events::Event<std::string>& eve
return;
// Node<std::string> target = Arabica::DOM::Node<std::string>(event.getTarget());
-// NodeSet<std::string> transitions = InterpreterImpl::filterChildElements(_nsInfo.xmlNSPrefix + "transition", target, true);
+// NodeSet<std::string> transitions = DOMUtils::DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", target, true);
// if (transitions.size() > 0)
_exitSet.clear();
diff --git a/src/uscxml/messages/Data.cpp b/src/uscxml/messages/Data.cpp
index 7afad43..53d4571 100644
--- a/src/uscxml/messages/Data.cpp
+++ b/src/uscxml/messages/Data.cpp
@@ -22,7 +22,12 @@
#include <boost/algorithm/string.hpp>
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
+#include "uscxml/dom/NameSpacingParser.h"
+#include <DOM/SAX2DOM/SAX2DOM.hpp>
+#include <SAX/helpers/DefaultHandler.hpp>
+#include <SAX/helpers/CatchErrorHandler.hpp>
+
#include "glog/logging.h"
#ifdef HAS_STRING_H
diff --git a/src/uscxml/messages/Event.cpp b/src/uscxml/messages/Event.cpp
index fda24dd..072c1b9 100644
--- a/src/uscxml/messages/Event.cpp
+++ b/src/uscxml/messages/Event.cpp
@@ -18,7 +18,10 @@
*/
#include "uscxml/messages/Event.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
+#include <DOM/SAX2DOM/SAX2DOM.hpp>
+#include <SAX/helpers/DefaultHandler.hpp>
+#include <SAX/helpers/CatchErrorHandler.hpp>
namespace uscxml {
diff --git a/src/uscxml/messages/MMIMessages.cpp b/src/uscxml/messages/MMIMessages.cpp
index 35e8b66..1c6cc7d 100644
--- a/src/uscxml/messages/MMIMessages.cpp
+++ b/src/uscxml/messages/MMIMessages.cpp
@@ -26,7 +26,7 @@
#include <DOM/SAX2DOM/SAX2DOM.hpp>
#include <SAX/helpers/InputSourceResolver.hpp>
-#include <uscxml/DOMUtils.h>
+#include <uscxml/dom/DOMUtils.h>
#include <boost/algorithm/string.hpp>
diff --git a/src/uscxml/messages/MMIMessages.h b/src/uscxml/messages/MMIMessages.h
index 4f3947e..3538816 100644
--- a/src/uscxml/messages/MMIMessages.h
+++ b/src/uscxml/messages/MMIMessages.h
@@ -22,6 +22,7 @@
#define MMI_WITH_OPERATOR_EVENT 1
+#include <iostream>
#include <DOM/Node.hpp>
#include <DOM/Document.hpp>
#include <uscxml/Interpreter.h>
diff --git a/src/uscxml/plugins/DataModel.h b/src/uscxml/plugins/DataModel.h
index f229a94..1a64d28 100644
--- a/src/uscxml/plugins/DataModel.h
+++ b/src/uscxml/plugins/DataModel.h
@@ -22,13 +22,16 @@
#include "uscxml/config.h"
#include "uscxml/Common.h"
+#include "uscxml/InterpreterInfo.h"
#include "uscxml/plugins/EventHandler.h"
-#ifdef BUILD_PROFILING
-#include "uscxml/concurrency/Timer.h"
-#define TIME_BLOCK Measurement msm(&timer);
-#else
-#define TIME_BLOCK (0);
+#ifndef TIME_BLOCK
+# ifdef BUILD_PROFILING
+# include "uscxml/concurrency/Timer.h"
+# define TIME_BLOCK Measurement msm(&timer);
+# else
+# define TIME_BLOCK
+# endif
#endif
#include <list>
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h
index cb196ff..0b49c92 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h
@@ -20,7 +20,7 @@
#ifndef JSCDOM_H_1RC5LCG8
#define JSCDOM_H_1RC5LCG8
-#include "uscxml/Interpreter.h"
+#include "uscxml/InterpreterInfo.h"
#include <JavaScriptCore/JavaScriptCore.h>
#include <XPath/XPath.hpp>
#include "../Storage.h"
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp
index 86bafd3..d3eb0ef 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp
@@ -19,6 +19,8 @@
#include "uscxml/Common.h"
#include "uscxml/config.h"
+#include "uscxml/URL.h"
+#include "uscxml/util/String.h"
#include "JSCDataModel.h"
#include "JSCDOM.h"
@@ -41,7 +43,7 @@
#include "dom/JSCDataView.h"
#include "uscxml/Message.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
#include <glog/logging.h>
#ifdef BUILD_AS_PLUGINS
@@ -94,7 +96,7 @@ void JSCDataModel::addExtension(DataModelExtension* ext) {
_extensions.insert(ext);
JSObjectRef currScope = JSContextGetGlobalObject(_ctx);
- std::list<std::string> locPath = InterpreterImpl::tokenize(ext->provides(), '.');
+ std::list<std::string> locPath = tokenize(ext->provides(), '.');
std::list<std::string>::iterator locIter = locPath.begin();
while(true) {
std::string pathComp = *locIter;
@@ -309,7 +311,7 @@ void JSCDataModel::setEvent(const Event& event) {
handleException(exception);
} else {
JSStringRef propName = JSStringCreateWithUTF8CString("data");
- JSStringRef contentStr = JSStringCreateWithUTF8CString(InterpreterImpl::spaceNormalize(event.content).c_str());
+ JSStringRef contentStr = JSStringCreateWithUTF8CString(spaceNormalize(event.content).c_str());
JSObjectSetProperty(_ctx, eventObj, propName, JSValueMakeString(_ctx, contentStr), 0, &exception);
JSStringRelease(propName);
JSStringRelease(contentStr);
@@ -701,7 +703,7 @@ void JSCDataModel::assign(const Element<std::string>& assignElem,
throw Event();
assign(key, Data(d, Data::INTERPRETED));
} catch (Event e) {
- assign(key, Data("\"" + InterpreterImpl::spaceNormalize(content) + "\"", Data::INTERPRETED));
+ assign(key, Data("\"" + spaceNormalize(content) + "\"", Data::INTERPRETED));
}
} else {
JSValueRef exception = NULL;
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h
index 2a2b1cc..ccadc79 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h
@@ -20,7 +20,8 @@
#ifndef JSCDATAMODEL_H_KN8TWG0V
#define JSCDATAMODEL_H_KN8TWG0V
-#include "uscxml/Interpreter.h"
+#include "uscxml/InterpreterInfo.h"
+#include "uscxml/plugins/DataModel.h"
#include <list>
#include <JavaScriptCore/JavaScriptCore.h>
#include "JSCDOM.h"
diff --git a/src/uscxml/plugins/datamodel/ecmascript/Storage.cpp b/src/uscxml/plugins/datamodel/ecmascript/Storage.cpp
index edab33c..980fc5d 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/Storage.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/Storage.cpp
@@ -19,6 +19,8 @@
#include "Storage.h"
#include <iostream>
+#include <fstream>
+#include <istream>
namespace uscxml {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/Storage.h b/src/uscxml/plugins/datamodel/ecmascript/Storage.h
index 6ec62dd..35bde86 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/Storage.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/Storage.h
@@ -22,8 +22,6 @@
#include <string>
#include <map>
-#include <fstream>
-#include <istream>
namespace uscxml {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/TypedArray.h b/src/uscxml/plugins/datamodel/ecmascript/TypedArray.h
index 7509390..a49410c 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/TypedArray.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/TypedArray.h
@@ -21,7 +21,7 @@
#define TYPEDARRAY_H_99815BLY
#include "uscxml/Common.h"
-#include "uscxml/Message.h"
+#include "uscxml/messages/Blob.h"
#include <string>
#include <vector>
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
index 3004b91..85ae0cd 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
@@ -46,7 +46,7 @@
#include "dom/V8DataView.h"
#include "uscxml/Message.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
#include <glog/logging.h>
#ifdef BUILD_AS_PLUGINS
@@ -102,7 +102,7 @@ void V8DataModel::addExtension(DataModelExtension* ext) {
v8::Context::Scope contextScope(_contexts.front());
v8::Handle<v8::Object> currScope = _contexts.front()->Global();
- std::list<std::string> locPath = InterpreterImpl::tokenize(ext->provides(), '.');
+ std::list<std::string> locPath = tokenize(ext->provides(), '.');
std::list<std::string>::iterator locIter = locPath.begin();
while(true) {
std::string pathComp = *locIter;
@@ -317,7 +317,7 @@ void V8DataModel::setEvent(const Event& event) {
if (!json.empty()) {
eventObj->Set(v8::String::New("data"), getDataAsValue(json));
} else {
- eventObj->Set(v8::String::New("data"), v8::String::New(InterpreterImpl::spaceNormalize(event.content).c_str()));
+ eventObj->Set(v8::String::New("data"), v8::String::New(spaceNormalize(event.content).c_str()));
}
} else {
// _event.data is KVP
@@ -716,7 +716,7 @@ void V8DataModel::assign(const Element<std::string>& assignElem,
try {
evalAsValue(key + " = " + content);
} catch (...) {
- evalAsValue(key + " = " + "\"" + InterpreterImpl::spaceNormalize(content) + "\"");
+ evalAsValue(key + " = " + "\"" + spaceNormalize(content) + "\"");
}
} else {
global->Set(v8::String::New(key.c_str()), v8::Undefined());
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h
index 35cc12d..8e665b7 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h
@@ -20,7 +20,7 @@
#ifndef V8DATAMODEL_H_KN8TWG0V
#define V8DATAMODEL_H_KN8TWG0V
-#include "uscxml/Interpreter.h"
+#include "uscxml/InterpreterInfo.h"
#include <list>
#include <v8.h>
#include "V8DOM.h"
diff --git a/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp b/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp
index c204946..c23b483 100644
--- a/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp
@@ -20,6 +20,7 @@
#include <boost/algorithm/string.hpp>
#include "uscxml/Common.h"
+#include "uscxml/util/String.h"
#include "LuaDataModel.h"
// disable forcing to bool performance warning
@@ -28,7 +29,7 @@
#include "LuaBridge.h"
#pragma warning(pop)
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
#include "uscxml/Message.h"
#include <glog/logging.h>
@@ -123,7 +124,7 @@ LuaDataModel::LuaDataModel() {
static int luaInFunction(lua_State * l) {
luabridge::LuaRef ref = luabridge::getGlobal(l, "__interpreter");
- InterpreterImpl* interpreter = ref.cast<InterpreterImpl*>();
+ InterpreterInfo* interpreter = ref.cast<InterpreterInfo*>();
int stackSize = lua_gettop(l);
for (int i = 0; i < stackSize; i++) {
@@ -278,7 +279,7 @@ void LuaDataModel::setEvent(const Event& event) {
std::string trimmed = boost::trim_copy(event.content);
if ((boost::starts_with(trimmed, "'") && boost::ends_with(trimmed, "'")) ||
(boost::starts_with(trimmed, "\"") && boost::ends_with(trimmed, "\""))) {
- luaEvent["data"] = InterpreterImpl::spaceNormalize(event.content);
+ luaEvent["data"] = spaceNormalize(event.content);
} else {
Data tmp(event.content, Data::INTERPRETED);
luaEvent["data"] = getDataAsLua(_luaState, tmp);
@@ -464,7 +465,7 @@ void LuaDataModel::assign(const Arabica::DOM::Element<std::string>& assignElem,
try {
eval(Arabica::DOM::Element<std::string>(), key + " = " + content + ";");
} catch (...) {
- eval(Arabica::DOM::Element<std::string>(), key + " = " + "\"" + InterpreterImpl::spaceNormalize(content) + "\";");
+ eval(Arabica::DOM::Element<std::string>(), key + " = " + "\"" + spaceNormalize(content) + "\";");
}
} else {
eval(Arabica::DOM::Element<std::string>(), key + " = " + "nil;");
diff --git a/src/uscxml/plugins/datamodel/lua/LuaDataModel.h b/src/uscxml/plugins/datamodel/lua/LuaDataModel.h
index bce1d62..eb23815 100644
--- a/src/uscxml/plugins/datamodel/lua/LuaDataModel.h
+++ b/src/uscxml/plugins/datamodel/lua/LuaDataModel.h
@@ -20,7 +20,8 @@
#ifndef LUADATAMODEL_H_113E014C
#define LUADATAMODEL_H_113E014C
-#include "uscxml/Interpreter.h"
+#include "uscxml/InterpreterInfo.h"
+#include "uscxml/plugins/DataModel.h"
#include <list>
#ifdef BUILD_AS_PLUGINS
diff --git a/src/uscxml/plugins/datamodel/null/NULLDataModel.cpp b/src/uscxml/plugins/datamodel/null/NULLDataModel.cpp
index c9f0d5a..7211dc5 100644
--- a/src/uscxml/plugins/datamodel/null/NULLDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/null/NULLDataModel.cpp
@@ -21,7 +21,7 @@
#include "uscxml/Common.h"
#include "NULLDataModel.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
#include "uscxml/Message.h"
#include <glog/logging.h>
diff --git a/src/uscxml/plugins/datamodel/null/NULLDataModel.h b/src/uscxml/plugins/datamodel/null/NULLDataModel.h
index db5fa28..f813ae1 100644
--- a/src/uscxml/plugins/datamodel/null/NULLDataModel.h
+++ b/src/uscxml/plugins/datamodel/null/NULLDataModel.h
@@ -20,7 +20,8 @@
#ifndef NULLDATAMODEL_H_KN8TWG0V
#define NULLDATAMODEL_H_KN8TWG0V
-#include "uscxml/Interpreter.h"
+#include "uscxml/InterpreterInfo.h"
+#include "uscxml/plugins/DataModel.h"
#include <list>
#ifdef BUILD_AS_PLUGINS
diff --git a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp
index fc41901..9a59a20 100644
--- a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp
@@ -21,8 +21,10 @@
#include "uscxml/Common.h"
#include "uscxml/config.h"
+#include "uscxml/util/String.h"
+#include "uscxml/URL.h"
#include "SWIDataModel.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
#include "uscxml/Message.h"
#include <glog/logging.h>
@@ -272,7 +274,7 @@ void SWIDataModel::setEvent(const Event& event) {
dataInitStr << "load_xml_file('" << domUrl.asLocalFile(".pl") << "', XML), copy_term(XML,DATA), assert(event(data(DATA)))";
PlCall(dataInitStr.str().c_str());
} else if (event.content.size() > 0) {
- PlCall("assert", PlCompound("event", PlCompound("data", PlString(InterpreterImpl::spaceNormalize(event.content).c_str()))));
+ PlCall("assert", PlCompound("event", PlCompound("data", PlString(spaceNormalize(event.content).c_str()))));
} else if (!event.data.empty()) {
assertFromData(event.data, "event(data(", 2);
}
diff --git a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h
index 398e24c..e968b61 100644
--- a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h
+++ b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h
@@ -20,7 +20,8 @@
#ifndef SWIDATAMODEL_H_KN8TWG0V
#define SWIDATAMODEL_H_KN8TWG0V
-#include "uscxml/Interpreter.h"
+#include "uscxml/InterpreterInfo.h"
+#include "uscxml/plugins/DataModel.h"
#include "uscxml/SWIConfig.h"
#include <list>
diff --git a/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp b/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp
index d9f50cf..02df56d 100644
--- a/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp
@@ -21,8 +21,9 @@
#include "uscxml/Common.h"
#include "uscxml/config.h"
+#include "uscxml/util/String.h"
#include "PromelaDataModel.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
#include "uscxml/Message.h"
#include <glog/logging.h>
#include <cctype>
@@ -138,7 +139,7 @@ void PromelaDataModel::setEvent(const Event& event) {
if (isNumeric(event.content.c_str(), 10)) {
variable.compound["value"].compound["data"] = Data(event.content, Data::INTERPRETED);
} else {
- variable.compound["value"].compound["data"] = Data(InterpreterImpl::spaceNormalize(event.content), Data::VERBATIM);
+ variable.compound["value"].compound["data"] = Data(spaceNormalize(event.content), Data::VERBATIM);
}
}
} else {
diff --git a/src/uscxml/plugins/datamodel/promela/PromelaDataModel.h b/src/uscxml/plugins/datamodel/promela/PromelaDataModel.h
index 060560d..0778ecf 100644
--- a/src/uscxml/plugins/datamodel/promela/PromelaDataModel.h
+++ b/src/uscxml/plugins/datamodel/promela/PromelaDataModel.h
@@ -20,7 +20,8 @@
#ifndef PROMELADATAMODEL_H_4VG0TDMU
#define PROMELADATAMODEL_H_4VG0TDMU
-#include "uscxml/Interpreter.h"
+#include "uscxml/InterpreterInfo.h"
+#include "uscxml/plugins/DataModel.h"
#include <list>
#ifdef BUILD_AS_PLUGINS
diff --git a/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp b/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp
index de8eecb..3bb22cc 100644
--- a/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp
@@ -22,10 +22,16 @@
#include "XPathDataModel.h"
#include "uscxml/Message.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/util/String.h"
+#include "uscxml/dom/DOMUtils.h"
#include <glog/logging.h>
#include <boost/algorithm/string.hpp>
+#include <DOM/SAX2DOM/SAX2DOM.hpp>
+//#include <SAX/helpers/CatchErrorHandler.hpp>
+//#include <DOM/Events/EventTarget.hpp>
+//#include <DOM/Events/EventListener.hpp>
+
#ifdef BUILD_AS_PLUGINS
#include <Pluma/Connector.hpp>
#endif
@@ -195,7 +201,7 @@ void XPathDataModel::setEvent(const Event& event) {
}
if (event.content.size() > 0) {
- Text<std::string> textNode = _doc.createTextNode(InterpreterImpl::spaceNormalize(event.content).c_str());
+ Text<std::string> textNode = _doc.createTextNode(spaceNormalize(event.content).c_str());
eventDataElem.appendChild(textNode);
}
if (event.dom) {
@@ -503,7 +509,7 @@ void XPathDataModel::assign(const Element<std::string>& assignElem,
}
assign(key, nodeSet, assignElem);
} else if (content.length() > 0) {
- Text<std::string> textNode = _doc.createTextNode(InterpreterImpl::spaceNormalize(content));
+ Text<std::string> textNode = _doc.createTextNode(spaceNormalize(content));
nodeSet.push_back(textNode);
assign(key, nodeSet, assignElem);
} else if (HAS_ATTR(assignElem, "expr")) {
diff --git a/src/uscxml/plugins/datamodel/xpath/XPathDataModel.h b/src/uscxml/plugins/datamodel/xpath/XPathDataModel.h
index 9a71b79..7a085d2 100644
--- a/src/uscxml/plugins/datamodel/xpath/XPathDataModel.h
+++ b/src/uscxml/plugins/datamodel/xpath/XPathDataModel.h
@@ -20,7 +20,9 @@
#ifndef XPATHDATAMODEL_H_KN8TWG0V
#define XPATHDATAMODEL_H_KN8TWG0V
-#include "uscxml/Interpreter.h"
+#include "uscxml/InterpreterInfo.h"
+#include "uscxml/plugins/DataModel.h"
+
#include <list>
#ifdef BUILD_AS_PLUGINS
diff --git a/src/uscxml/plugins/element/fetch/FetchElement.cpp b/src/uscxml/plugins/element/fetch/FetchElement.cpp
index 595c913..bf3129b 100644
--- a/src/uscxml/plugins/element/fetch/FetchElement.cpp
+++ b/src/uscxml/plugins/element/fetch/FetchElement.cpp
@@ -20,7 +20,7 @@
#include <boost/algorithm/string.hpp>
#include "FetchElement.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
#include <glog/logging.h>
#include <event2/http.h>
diff --git a/src/uscxml/plugins/element/file/FileElement.cpp b/src/uscxml/plugins/element/file/FileElement.cpp
index decd5ca..c2e4f55 100644
--- a/src/uscxml/plugins/element/file/FileElement.cpp
+++ b/src/uscxml/plugins/element/file/FileElement.cpp
@@ -24,7 +24,8 @@
#include <boost/algorithm/string.hpp>
#include "uscxml/messages/Blob.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
+#include "uscxml/dom/NameSpacingParser.h"
#ifdef BUILD_AS_PLUGINS
#include <Pluma/Connector.hpp>
diff --git a/src/uscxml/plugins/element/mmi/MMIEvents.h b/src/uscxml/plugins/element/mmi/MMIEvents.h
index 82d0b22..74c66c0 100644
--- a/src/uscxml/plugins/element/mmi/MMIEvents.h
+++ b/src/uscxml/plugins/element/mmi/MMIEvents.h
@@ -42,8 +42,8 @@ public:\
std::string getLocalName() { return "elementName"; }\
std::string getNamespace() { return "http://www.w3.org/2008/04/mmi-arch"; }\
bool processChildren() { return false; }\
- void enterElement(const Arabica::DOM::Node<std::string>& node);\
- void exitElement(const Arabica::DOM::Node<std::string>& node) {}\
+ void enterElement(const Arabica::DOM::Element<std::string>& node) {}\
+ void exitElement(const Arabica::DOM::Element<std::string>& node) {}\
};
namespace uscxml {
diff --git a/src/uscxml/plugins/element/postpone/PostponeElement.cpp b/src/uscxml/plugins/element/postpone/PostponeElement.cpp
index a041a9e..460cc88 100644
--- a/src/uscxml/plugins/element/postpone/PostponeElement.cpp
+++ b/src/uscxml/plugins/element/postpone/PostponeElement.cpp
@@ -21,7 +21,7 @@
#include "PostponeElement.h"
#include "uscxml/plugins/invoker/http/HTTPServletInvoker.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
#include <glog/logging.h>
#ifdef BUILD_AS_PLUGINS
diff --git a/src/uscxml/plugins/element/respond/RespondElement.cpp b/src/uscxml/plugins/element/respond/RespondElement.cpp
index a62f934..65babd7 100644
--- a/src/uscxml/plugins/element/respond/RespondElement.cpp
+++ b/src/uscxml/plugins/element/respond/RespondElement.cpp
@@ -20,7 +20,7 @@
#include "RespondElement.h"
#include "uscxml/plugins/invoker/http/HTTPServletInvoker.h"
#include "uscxml/server/InterpreterServlet.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
#include <glog/logging.h>
#ifdef BUILD_AS_PLUGINS
@@ -79,7 +79,7 @@ void RespondElement::enterElement(const Arabica::DOM::Element<std::string>& node
httpReply.status = strTo<int>(statusStr);;
// extract the content
- Arabica::XPath::NodeSet<std::string> contents = InterpreterImpl::filterChildElements(_interpreter->getNameSpaceInfo().getXMLPrefixForNS(getNamespace()) + "content", node);
+ Arabica::XPath::NodeSet<std::string> contents = DOMUtils::filterChildElements(_interpreter->getNameSpaceInfo().getXMLPrefixForNS(getNamespace()) + "content", node);
if (contents.size() > 0) {
Arabica::DOM::Element<std::string> contentElem = Arabica::DOM::Element<std::string>(contents[0]);
if (HAS_ATTR(contentElem, "expr")) { // -- content is evaluated string from datamodel ------
@@ -143,7 +143,7 @@ void RespondElement::enterElement(const Arabica::DOM::Element<std::string>& node
}
// process headers
- Arabica::XPath::NodeSet<std::string> headers = InterpreterImpl::filterChildElements(_interpreter->getNameSpaceInfo().getXMLPrefixForNS(getNamespace()) + "header", node);
+ Arabica::XPath::NodeSet<std::string> headers = DOMUtils::filterChildElements(_interpreter->getNameSpaceInfo().getXMLPrefixForNS(getNamespace()) + "header", node);
for (int i = 0; i < headers.size(); i++) {
Arabica::DOM::Element<std::string> headerElem = Arabica::DOM::Element<std::string>(headers[i]);
diff --git a/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp b/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp
index f8b4904..0b54228 100644
--- a/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp
+++ b/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp
@@ -20,7 +20,7 @@
#include <boost/algorithm/string.hpp>
#include "HeartbeatInvoker.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
#include <glog/logging.h>
#ifdef BUILD_AS_PLUGINS
diff --git a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp
index 7bd40d9..62f7a1e 100644
--- a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp
+++ b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp
@@ -19,7 +19,8 @@
#include "USCXMLInvoker.h"
#include <glog/logging.h>
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
+#include <DOM/SAX2DOM/SAX2DOM.hpp>
#ifdef BUILD_AS_PLUGINS
#include <Pluma/Connector.hpp>
@@ -91,7 +92,7 @@ void USCXMLInvoker::invoke(const InvokeRequest& req) {
}
if (_invokedInterpreter) {
if (req.elem && HAS_ATTR(req.elem, "initial")) {
- _invokedInterpreter.setInitalConfiguration(InterpreterImpl::tokenize(ATTR(req.elem, "initial")));
+ _invokedInterpreter.setInitalConfiguration(tokenize(ATTR(req.elem, "initial")));
}
DataModel dataModel(_invokedInterpreter.getImpl()->getDataModel());
diff --git a/src/uscxml/plugins/invoker/xhtml/XHTMLInvoker.cpp b/src/uscxml/plugins/invoker/xhtml/XHTMLInvoker.cpp
index 196d6d2..9c85f37 100644
--- a/src/uscxml/plugins/invoker/xhtml/XHTMLInvoker.cpp
+++ b/src/uscxml/plugins/invoker/xhtml/XHTMLInvoker.cpp
@@ -22,7 +22,7 @@
#include <uscxml/config.h>
#include "XHTMLInvoker.h"
#include <glog/logging.h>
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
#include <uscxml/plugins/ioprocessor/comet/CometIOProcessor.h>
#include <DOM/io/Stream.hpp>
diff --git a/src/uscxml/plugins/ioprocessor/basichttp/BasicHTTPIOProcessor.cpp b/src/uscxml/plugins/ioprocessor/basichttp/BasicHTTPIOProcessor.cpp
index 49aa8dc..1bced48 100644
--- a/src/uscxml/plugins/ioprocessor/basichttp/BasicHTTPIOProcessor.cpp
+++ b/src/uscxml/plugins/ioprocessor/basichttp/BasicHTTPIOProcessor.cpp
@@ -21,7 +21,9 @@
#include "uscxml/plugins/ioprocessor/basichttp/BasicHTTPIOProcessor.h"
#include "uscxml/Message.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
+#include "uscxml/dom/NameSpacingParser.h"
+
#include <iostream>
#include <event2/dns.h>
#include <event2/buffer.h>
diff --git a/src/uscxml/server/HTTPServer.cpp b/src/uscxml/server/HTTPServer.cpp
index 90ce242..6f2347c 100644
--- a/src/uscxml/server/HTTPServer.cpp
+++ b/src/uscxml/server/HTTPServer.cpp
@@ -26,7 +26,8 @@
#endif
#include "uscxml/server/HTTPServer.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
+#include "uscxml/dom/NameSpacingParser.h"
#include <string>
#include <iostream>
diff --git a/src/uscxml/transform/ChartAnnotator.cpp b/src/uscxml/transform/ChartAnnotator.cpp
new file mode 100644
index 0000000..5bab391
--- /dev/null
+++ b/src/uscxml/transform/ChartAnnotator.cpp
@@ -0,0 +1,24 @@
+/**
+ * @file
+ * @author 2012-2015 Stefan Radomski (stefan.radomski@cs.tu-darmstadt.de)
+ * @copyright Simplified BSD
+ *
+ * @cond
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the FreeBSD license as published by the FreeBSD
+ * project.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the FreeBSD license along with this
+ * program. If not, see <http://www.opensource.org/licenses/bsd-license>.
+ * @endcond
+ */
+
+#include "ChartAnnotator.h"
+
+namespace uscxml {
+
+} \ No newline at end of file
diff --git a/src/uscxml/Message.cpp b/src/uscxml/transform/ChartAnnotator.h
index 465b4ba..3ce8f4a 100644
--- a/src/uscxml/Message.cpp
+++ b/src/uscxml/transform/ChartAnnotator.h
@@ -1,6 +1,6 @@
/**
* @file
- * @author 2012-2013 Stefan Radomski (stefan.radomski@cs.tu-darmstadt.de)
+ * @author 2012-2016 Stefan Radomski (stefan.radomski@cs.tu-darmstadt.de)
* @copyright Simplified BSD
*
* @cond
@@ -17,41 +17,11 @@
* @endcond
*/
-#include "uscxml/config.h"
-
-#include "uscxml/Common.h"
-#include "uscxml/Message.h"
-#include "uscxml/DOMUtils.h"
-#include <DOM/SAX2DOM/SAX2DOM.hpp>
-#include <SAX/helpers/CatchErrorHandler.hpp>
-#include <glog/logging.h>
-
-#include <boost/algorithm/string.hpp>
-
+#ifndef CHARTANNOTATOR_H_2AC11ECB
+#define CHARTANNOTATOR_H_2AC11ECB
namespace uscxml {
+}
-
-
-
-
-
-
-
-
-#ifndef SWIGJAVA
-#endif
-
-
-#ifndef SWIGJAVA
-#endif
-
-#ifndef SWIGJAVA
-#endif
-
-#ifndef SWIGJAVA
-#endif
-
-
-} \ No newline at end of file
+#endif /* end of include guard: CHARTANNOTATOR_H_2AC11ECB */
diff --git a/src/uscxml/transform/ChartToC.cpp b/src/uscxml/transform/ChartToC.cpp
index 7cc50fc..ee0b431 100644
--- a/src/uscxml/transform/ChartToC.cpp
+++ b/src/uscxml/transform/ChartToC.cpp
@@ -21,10 +21,11 @@
#include "uscxml/transform/ChartToC.h"
#include "uscxml/debug/Complexity.h"
#include <DOM/io/Stream.hpp>
+#include <DOM/SAX2DOM/SAX2DOM.hpp>
#include <iostream>
#include "uscxml/UUID.h"
#include "uscxml/util/MD5.hpp"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
#include <math.h>
#include <boost/algorithm/string.hpp>
#include <glog/logging.h>
@@ -205,10 +206,10 @@ void ChartToC::setStateCompletion() {
completion = getChildStates(state);
} else if (state.hasAttribute("initial")) {
- completion = getStates(tokenizeIdRefs(state.getAttribute("initial")));
+ completion = getStates(tokenize(state.getAttribute("initial")));
} else {
- NodeSet<std::string> initElems = filterChildElements(_nsInfo.xmlNSPrefix + "initial", state);
+ NodeSet<std::string> initElems = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "initial", state);
if(initElems.size() > 0 && !iequals(ATTR_CAST(initElems[0], "generated"), "true")) {
// initial element is first child
completion.push_back(initElems[0]);
@@ -450,7 +451,7 @@ void ChartToC::writeForwardDeclarations(std::ostream& stream) {
}
void ChartToC::findNestedMachines() {
- NodeSet<std::string> invokes = InterpreterImpl::filterChildElements(_nsInfo.xmlNSPrefix + "invoke", _scxml, true);
+ NodeSet<std::string> invokes = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "invoke", _scxml, true);
for (size_t i = 0; i < invokes.size(); i++) {
if(isInEmbeddedDocument(invokes[i]))
@@ -472,10 +473,10 @@ void ChartToC::findNestedMachines() {
c2c = new ChartToC(Interpreter::fromURL(srcURL.asString()));
} else {
// is there a nested scxml machine inside?
- NodeSet<std::string> contents = filterChildElements(_nsInfo.xmlNSPrefix + "content", invoke);
+ NodeSet<std::string> contents = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "content", invoke);
if (contents.size() == 0)
continue;
- NodeSet<std::string> scxmls = filterChildElements(_nsInfo.xmlNSPrefix + "scxml", contents[0]);
+ NodeSet<std::string> scxmls = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "scxml", contents[0]);
if (scxmls.size() == 0)
continue;
@@ -555,7 +556,7 @@ void ChartToC::writeMacros(std::ostream& stream) {
stream << std::endl;
stream << "#ifndef USCXML_MAX_NR_STATES_BYTES " << std::endl;
- stream << "# define USCXML_MAX_NR_STATES_BYTES " << _stateCharArraySize << std::endl;
+ stream << "# define USCXML_MAX_NR_STATES_BYTES " << (std::max)((size_t)1, _stateCharArraySize) << std::endl;
stream << "#endif " << std::endl;
stream << std::endl;
@@ -566,7 +567,7 @@ void ChartToC::writeMacros(std::ostream& stream) {
stream << std::endl;
stream << "#ifndef USCXML_MAX_NR_TRANS_BYTES " << std::endl;
- stream << "# define USCXML_MAX_NR_TRANS_BYTES " << _transCharArraySize << std::endl;
+ stream << "# define USCXML_MAX_NR_TRANS_BYTES " << (std::max)((size_t)1, _transCharArraySize) << std::endl;
stream << "#endif " << std::endl;
stream << std::endl;
@@ -1037,7 +1038,7 @@ void ChartToC::writeExecContentFinalize(std::ostream& stream) {
for (size_t i = 0; i < finalizes.size(); i++) {
Element<std::string> finalize(finalizes[i]);
- NodeSet<std::string> execContent = filterChildType(Node_base::ELEMENT_NODE, finalize);
+ NodeSet<std::string> execContent = DOMUtils::filterChildType(Node_base::ELEMENT_NODE, finalize);
if (execContent.size() > 0) {
stream << "static int " << _prefix << "_" << DOMUtils::idForNode(finalize) << "(const uscxml_ctx* ctx, const uscxml_elem_invoke* invocation, const void* event) {" << std::endl;
@@ -1066,7 +1067,7 @@ void ChartToC::writeExecContent(std::ostream& stream) {
if (i == 0) {
// root state - we need to perform some initialization here
- NodeSet<std::string> globalScripts = filterChildElements(_nsInfo.xmlNSPrefix + "script", state);
+ NodeSet<std::string> globalScripts = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "script", state);
if (globalScripts.size() > 0) {
for (size_t j = 0; j < globalScripts.size(); j++) {
stream << "static int " << _prefix << "_global_script_" << toStr(j) << "(const uscxml_ctx* ctx, const uscxml_state* state, const void* event) {" << std::endl;
@@ -1086,7 +1087,7 @@ void ChartToC::writeExecContent(std::ostream& stream) {
}
}
- NodeSet<std::string> onexit = filterChildElements(_nsInfo.xmlNSPrefix + "onexit", state);
+ NodeSet<std::string> onexit = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "onexit", state);
for (size_t j = 0; j < onexit.size(); j++) {
stream << "static int " << _prefix << "_" << DOMUtils::idForNode(state) << "_on_exit_" << toStr(j) << "(const uscxml_ctx* ctx, const uscxml_state* state, const void* event) {" << std::endl;
stream << " int err = USCXML_ERR_OK;" << std::endl;
@@ -1107,7 +1108,7 @@ void ChartToC::writeExecContent(std::ostream& stream) {
}
- NodeSet<std::string> onentry = filterChildElements(_nsInfo.xmlNSPrefix + "onentry", state);
+ NodeSet<std::string> onentry = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "onentry", state);
for (size_t j = 0; j < onentry.size(); j++) {
stream << "static int " << _prefix << "_" << DOMUtils::idForNode(state) << "_on_entry_" << toStr(j) << "(const uscxml_ctx* ctx, const uscxml_state* state, const void* event) {" << std::endl;
stream << " int err = USCXML_ERR_OK;" << std::endl;
@@ -1129,7 +1130,7 @@ void ChartToC::writeExecContent(std::ostream& stream) {
}
- NodeSet<std::string> invokes = filterChildElements(_nsInfo.xmlNSPrefix + "invoke", state);
+ NodeSet<std::string> invokes = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "invoke", state);
if (invokes.size() > 0) {
stream << "static int " << _prefix << "_" << DOMUtils::idForNode(state) << "_invoke(const uscxml_ctx* ctx, const uscxml_state* s, const uscxml_elem_invoke* invocation, unsigned char uninvoke) {" << std::endl;
for (size_t j = 0; j < invokes.size(); j++) {
@@ -1144,7 +1145,7 @@ void ChartToC::writeExecContent(std::ostream& stream) {
for (size_t i = 0; i < _transitions.size(); i++) {
Element<std::string> transition(_transitions[i]);
- NodeSet<std::string> execContent = filterChildType(Node_base::ELEMENT_NODE, transition);
+ NodeSet<std::string> execContent = DOMUtils::filterChildType(Node_base::ELEMENT_NODE, transition);
if (execContent.size() > 0) {
stream << "static int " << _prefix << "_" << DOMUtils::idForNode(transition) << "_on_trans(const uscxml_ctx* ctx, const uscxml_state* state, const void* event) {" << std::endl;
@@ -1205,7 +1206,7 @@ void ChartToC::writeExecContent(std::ostream& stream, const Arabica::DOM::Node<s
stream << " if unlikely((err = ctx->exec_content_script(ctx, ";
stream << (HAS_ATTR(elem, "src") ? "\"" + escape(ATTR(elem, "src")) + "\"" : "NULL") << ", ";
- NodeSet<std::string> scriptTexts = filterChildType(Node_base::TEXT_NODE, elem);
+ NodeSet<std::string> scriptTexts = DOMUtils::filterChildType(Node_base::TEXT_NODE, elem);
if (scriptTexts.size() > 0) {
stream << "\"";
writeExecContent(stream, scriptTexts[0], 0);
@@ -1329,7 +1330,7 @@ void ChartToC::writeElementInfoInvocation(std::ostream& stream) {
stream << "#ifndef USCXML_NO_ELEM_INFO" << std::endl;
stream << std::endl;
- NodeSet<std::string> invokes = filterChildElements(_nsInfo.xmlNSPrefix + "invoke", _scxml, true);
+ NodeSet<std::string> invokes = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "invoke", _scxml, true);
if (invokes.size() > 0) {
_hasElement.insert("invoke");
stream << "static const uscxml_elem_invoke " << _prefix << "_elem_invokes[" << invokes.size() << "] = {" << std::endl;
@@ -1426,7 +1427,7 @@ void ChartToC::writeElementInfoInvocation(std::ostream& stream) {
stream << ", " << std::endl;
stream << " /* finalize */ ";
- NodeSet<std::string> finalizes = filterChildElements(_nsInfo.xmlNSPrefix + "finalize", invoke);
+ NodeSet<std::string> finalizes = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "finalize", invoke);
if (finalizes.size() > 0) {
stream << _prefix << "_" << DOMUtils::idForNode(finalizes[0]);
} else {
@@ -1434,7 +1435,7 @@ void ChartToC::writeElementInfoInvocation(std::ostream& stream) {
}
stream << ", " << std::endl;
- NodeSet<std::string> contents = filterChildElements(_nsInfo.xmlNSPrefix + "content", invoke);
+ NodeSet<std::string> contents = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "content", invoke);
if (contents.size() > 0 && !HAS_ATTR(invoke, "md5sum")) {
std::stringstream ss;
NodeList<std::string> cChilds = contents[0].getChildNodes();
@@ -1498,7 +1499,7 @@ void ChartToC::writeElementInfo(std::ostream& stream) {
stream << (HAS_ATTR(assign, "location") ? "\"" + escape(ATTR(assign, "location")) + "\"" : "NULL") << ", ";
stream << (HAS_ATTR(assign, "expr") ? "\"" + escape(ATTR(assign, "expr")) + "\"" : "NULL") << ", ";
- NodeSet<std::string> assignTexts = filterChildType(Node_base::TEXT_NODE, assign);
+ NodeSet<std::string> assignTexts = DOMUtils::filterChildType(Node_base::TEXT_NODE, assign);
if (assignTexts.size() > 0) {
if (boost::trim_copy(assignTexts[0].getNodeValue()).length() > 0) {
std::string escaped = escape(assignTexts[0].getNodeValue());
@@ -1557,7 +1558,7 @@ void ChartToC::writeElementInfo(std::ostream& stream) {
stream << (HAS_ATTR(data, "src") ? "\"" + escape(ATTR(data, "src")) + "\"" : "NULL") << ", ";
stream << (HAS_ATTR(data, "expr") ? "\"" + escape(ATTR(data, "expr")) + "\"" : "NULL") << ", ";
- NodeSet<std::string> dataTexts = filterChildType(Node_base::TEXT_NODE, data);
+ NodeSet<std::string> dataTexts = DOMUtils::filterChildType(Node_base::TEXT_NODE, data);
if (dataTexts.size() > 0) {
if (boost::trim_copy(dataTexts[0].getNodeValue()).length() > 0) {
std::string escaped = escape(dataTexts[0].getNodeValue());
@@ -1640,7 +1641,7 @@ void ChartToC::writeElementInfo(std::ostream& stream) {
stream << std::endl << " /* namelist */ ";
stream << (HAS_ATTR(send, "namelist") ? "\"" + escape(ATTR(send, "namelist")) + "\"" : "NULL") << ", ";
- NodeSet<std::string> contents = filterChildElements(_nsInfo.xmlNSPrefix + "content", send);
+ NodeSet<std::string> contents = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "content", send);
if (contents.size() > 0) {
std::stringstream ss;
NodeList<std::string> cChilds = contents[0].getChildNodes();
@@ -1684,7 +1685,7 @@ void ChartToC::writeElementInfo(std::ostream& stream) {
// parent
stream << ATTR_CAST(donedata.getParentNode(), "documentOrder") << ", ";
- NodeSet<std::string> contents = filterChildElements(_nsInfo.xmlNSPrefix + "content", donedata);
+ NodeSet<std::string> contents = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "content", donedata);
if (contents.size() > 0) {
std::stringstream ss;
NodeList<std::string> cChilds = contents[0].getChildNodes();
@@ -1751,7 +1752,11 @@ void ChartToC::writeMachineInfo(std::ostream& stream) {
stream << " /* datamodel */ \"" << (HAS_ATTR(_scxml, "datamodel") ? ATTR(_scxml, "datamodel") : "null") << "\"," << std::endl;
stream << " /* uuid */ \"" << _md5 << "\"," << std::endl;
stream << " /* states */ " << "&" << _prefix << "_states[0], " << std::endl;
- stream << " /* transitions */ " << "&" << _prefix << "_transitions[0], " << std::endl;
+ if (_transitions.size() > 0) {
+ stream << " /* transitions */ " << "&" << _prefix << "_transitions[0], " << std::endl;
+ } else {
+ stream << " /* transitions */ " << "NULL, " << std::endl;
+ }
stream << " /* parent */ ";
if (_parentMachine != NULL) {
size_t parentIndex = 0;
@@ -1769,7 +1774,7 @@ void ChartToC::writeMachineInfo(std::ostream& stream) {
stream << " /* donedata */ " << "&" << _prefix << "_elem_donedatas[0], " << std::endl;
stream << " /* script */ ";
- if (filterChildElements(_nsInfo.xmlNSPrefix + "script", _scxml).size() > 0) {
+ if (DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "script", _scxml).size() > 0) {
stream << _prefix << "_global_script" << std::endl;
} else {
stream << "NULL";
@@ -1810,7 +1815,7 @@ void ChartToC::writeMachineInfo(std::ostream& stream) {
stream << " /* donedata */ " << "&" << m->_prefix << "_elem_donedatas[0], " << std::endl;
stream << " /* script */ ";
- if (filterChildElements(_nsInfo.xmlNSPrefix + "script", _scxml).size() > 0) {
+ if (DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "script", _scxml).size() > 0) {
stream << m->_prefix << "_global_script" << std::endl;
} else {
stream << "NULL";
@@ -1852,17 +1857,17 @@ void ChartToC::writeStates(std::ostream& stream) {
// onentry
stream << " /* onentry */ ";
- stream << (filterChildElements(_nsInfo.xmlNSPrefix + "onentry", state).size() > 0 ? _prefix + "_" + DOMUtils::idForNode(state) + "_on_entry" : "NULL");
+ stream << (DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "onentry", state).size() > 0 ? _prefix + "_" + DOMUtils::idForNode(state) + "_on_entry" : "NULL");
stream << "," << std::endl;
// onexit
stream << " /* onexit */ ";
- stream << (filterChildElements(_nsInfo.xmlNSPrefix + "onexit", state).size() > 0 ? _prefix + "_" + DOMUtils::idForNode(state) + "_on_exit" : "NULL");
+ stream << (DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "onexit", state).size() > 0 ? _prefix + "_" + DOMUtils::idForNode(state) + "_on_exit" : "NULL");
stream << "," << std::endl;
// invokers
stream << " /* invoke */ ";
- stream << (filterChildElements(_nsInfo.xmlNSPrefix + "invoke", state).size() > 0 ? _prefix + "_" + DOMUtils::idForNode(state) + "_invoke" : "NULL");
+ stream << (DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "invoke", state).size() > 0 ? _prefix + "_" + DOMUtils::idForNode(state) + "_invoke" : "NULL");
stream << "," << std::endl;
// children
@@ -1932,95 +1937,97 @@ void ChartToC::writeTransitions(std::ostream& stream) {
elements.insert(_nsInfo.xmlNSPrefix + "transition");
NodeSet<std::string> transDocOrder = DOMUtils::inDocumentOrder(elements, _scxml);
- stream << "static const uscxml_transition " << _prefix << "_transitions[" << toStr(_transitions.size()) << "] = {" << std::endl;
- for (size_t i = 0; i < _transitions.size(); i++) {
- Element<std::string> transition(_transitions[i]);
-
- stream << " { /* transition number " << ATTR(transition, "documentOrder") << " with priority " << toStr(i) << std::endl;
- stream << " target: " << ATTR(transition, "target") << std::endl;
- stream << " */" << std::endl;
+ if (_transitions.size() > 0) {
+ stream << "static const uscxml_transition " << _prefix << "_transitions[" << toStr(_transitions.size()) << "] = {" << std::endl;
+ for (size_t i = 0; i < _transitions.size(); i++) {
+ Element<std::string> transition(_transitions[i]);
- // source
- stream << " /* source */ ";
- stream << ATTR_CAST(transition.getParentNode(), "documentOrder");
- stream << "," << std::endl;
+ stream << " { /* transition number " << ATTR(transition, "documentOrder") << " with priority " << toStr(i) << std::endl;
+ stream << " target: " << ATTR(transition, "target") << std::endl;
+ stream << " */" << std::endl;
- // targets
- stream << " /* target */ ";
- if (HAS_ATTR(transition, "targetBools")) {
- stream << "{ ";
- writeCharArrayInitList(stream, ATTR(transition, "targetBools"));
- stream << " /* " << ATTR(transition, "targetBools") << " */ }";
+ // source
+ stream << " /* source */ ";
+ stream << ATTR_CAST(transition.getParentNode(), "documentOrder");
+ stream << "," << std::endl;
- } else {
- stream << "{ NULL }";
- }
- stream << "," << std::endl;
+ // targets
+ stream << " /* target */ ";
+ if (HAS_ATTR(transition, "targetBools")) {
+ stream << "{ ";
+ writeCharArrayInitList(stream, ATTR(transition, "targetBools"));
+ stream << " /* " << ATTR(transition, "targetBools") << " */ }";
- stream << " /* event */ ";
- stream << (HAS_ATTR(transition, "event") ? "\"" + escape(ATTR(transition, "event")) + "\"" : "NULL");
- stream << "," << std::endl;
+ } else {
+ stream << "{ NULL }";
+ }
+ stream << "," << std::endl;
- stream << " /* condition */ ";
- stream << (HAS_ATTR(transition, "cond") ? "\"" + escape(ATTR(transition, "cond")) + "\"" : "NULL");
- stream << "," << std::endl;
+ stream << " /* event */ ";
+ stream << (HAS_ATTR(transition, "event") ? "\"" + escape(ATTR(transition, "event")) + "\"" : "NULL");
+ stream << "," << std::endl;
- // on transition handlers
- stream << " /* ontrans */ ";
- if (filterChildType(Arabica::DOM::Node_base::ELEMENT_NODE, transition).size() > 0) {
- stream << _prefix << "_" << DOMUtils::idForNode(transition) + "_on_trans";
- } else {
- stream << "NULL";
- }
- stream << "," << std::endl;
+ stream << " /* condition */ ";
+ stream << (HAS_ATTR(transition, "cond") ? "\"" + escape(ATTR(transition, "cond")) + "\"" : "NULL");
+ stream << "," << std::endl;
- // type
- stream << " /* type */ ";
- std::string seperator = "";
- if (!HAS_ATTR(transition, "target")) {
- stream << seperator << "USCXML_TRANS_TARGETLESS";
- seperator = " | ";
- }
+ // on transition handlers
+ stream << " /* ontrans */ ";
+ if (DOMUtils::filterChildType(Arabica::DOM::Node_base::ELEMENT_NODE, transition).size() > 0) {
+ stream << _prefix << "_" << DOMUtils::idForNode(transition) + "_on_trans";
+ } else {
+ stream << "NULL";
+ }
+ stream << "," << std::endl;
+
+ // type
+ stream << " /* type */ ";
+ std::string seperator = "";
+ if (!HAS_ATTR(transition, "target")) {
+ stream << seperator << "USCXML_TRANS_TARGETLESS";
+ seperator = " | ";
+ }
- if (HAS_ATTR(transition, "type") && iequals(ATTR(transition, "type"), "internal")) {
- stream << seperator << "USCXML_TRANS_INTERNAL";
- seperator = " | ";
- }
+ if (HAS_ATTR(transition, "type") && iequals(ATTR(transition, "type"), "internal")) {
+ stream << seperator << "USCXML_TRANS_INTERNAL";
+ seperator = " | ";
+ }
- if (!HAS_ATTR(transition, "event")) {
- stream << seperator << "USCXML_TRANS_SPONTANEOUS";
- seperator = " | ";
- }
+ if (!HAS_ATTR(transition, "event")) {
+ stream << seperator << "USCXML_TRANS_SPONTANEOUS";
+ seperator = " | ";
+ }
- if (iequals(TAGNAME_CAST(transition.getParentNode()), "history")) {
- stream << seperator << "USCXML_TRANS_HISTORY";
- seperator = " | ";
- }
+ if (iequals(TAGNAME_CAST(transition.getParentNode()), "history")) {
+ stream << seperator << "USCXML_TRANS_HISTORY";
+ seperator = " | ";
+ }
- if (iequals(TAGNAME_CAST(transition.getParentNode()), "initial")) {
- stream << seperator << "USCXML_TRANS_INITIAL";
- seperator = " | ";
- }
+ if (iequals(TAGNAME_CAST(transition.getParentNode()), "initial")) {
+ stream << seperator << "USCXML_TRANS_INITIAL";
+ seperator = " | ";
+ }
- if (seperator.size() == 0) {
- stream << "0";
- }
- stream << "," << std::endl;
+ if (seperator.size() == 0) {
+ stream << "0";
+ }
+ stream << "," << std::endl;
- // conflicts
- stream << " /* conflicts */ { ";
- writeCharArrayInitList(stream, ATTR(transition, "conflictBools"));
- stream << " /* " << ATTR(transition, "conflictBools") << " */ }, " << std::endl;
+ // conflicts
+ stream << " /* conflicts */ { ";
+ writeCharArrayInitList(stream, ATTR(transition, "conflictBools"));
+ stream << " /* " << ATTR(transition, "conflictBools") << " */ }, " << std::endl;
- // exit set
- stream << " /* exit set */ { ";
- writeCharArrayInitList(stream, ATTR(transition, "exitSetBools"));
- stream << " /* " << ATTR(transition, "exitSetBools") << " */ }" << std::endl;
+ // exit set
+ stream << " /* exit set */ { ";
+ writeCharArrayInitList(stream, ATTR(transition, "exitSetBools"));
+ stream << " /* " << ATTR(transition, "exitSetBools") << " */ }" << std::endl;
- stream << " }" << (i + 1 < _transitions.size() ? ",": "") << std::endl;
+ stream << " }" << (i + 1 < _transitions.size() ? ",": "") << std::endl;
+ }
+ stream << "};" << std::endl;
+ stream << std::endl;
}
- stream << "};" << std::endl;
- stream << std::endl;
stream << "#endif" << std::endl;
stream << std::endl;
diff --git a/src/uscxml/transform/ChartToC.h b/src/uscxml/transform/ChartToC.h
index bb17102..0c9c2e5 100644
--- a/src/uscxml/transform/ChartToC.h
+++ b/src/uscxml/transform/ChartToC.h
@@ -21,7 +21,7 @@
#define FSMTOCPP_H_201672B0
#include "uscxml/interpreter/InterpreterRC.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
#include "uscxml/util/Trie.h"
#include "Transformer.h"
diff --git a/src/uscxml/transform/ChartToFSM.cpp b/src/uscxml/transform/ChartToFSM.cpp
index b78a2dd..da53c1f 100644
--- a/src/uscxml/transform/ChartToFSM.cpp
+++ b/src/uscxml/transform/ChartToFSM.cpp
@@ -23,6 +23,7 @@
#include "uscxml/Factory.h"
#include "uscxml/debug/Complexity.h"
+#include <DOM/SAX2DOM/SAX2DOM.hpp>
#include <DOM/io/Stream.hpp>
#include <glog/logging.h>
@@ -146,7 +147,7 @@ ChartToFSM::~ChartToFSM() {
}
// tear down caches
- Arabica::XPath::NodeSet<std::string> allTransitions = filterChildElements(_nsInfo.xmlNSPrefix + "transition", _scxml, true);
+ Arabica::XPath::NodeSet<std::string> allTransitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", _scxml, true);
for (int i = 0; i < allTransitions.size(); i++) {
_transParents.erase(allTransitions[i]);
}
@@ -212,7 +213,7 @@ InterpreterState ChartToFSM::interpret() {
// setup caches
{
- Arabica::XPath::NodeSet<std::string> allTransitions = filterChildElements(_nsInfo.xmlNSPrefix + "transition", _scxml, true);
+ Arabica::XPath::NodeSet<std::string> allTransitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", _scxml, true);
indexedTransitions.reserve(allTransitions.size());
for (int i = 0; i < allTransitions.size(); i++) {
_transParents[allTransitions[i]] = InterpreterImpl::getParentState(allTransitions[i]);
@@ -220,7 +221,7 @@ InterpreterState ChartToFSM::interpret() {
}
// identify all history elements
- NodeSet<std::string> histories = filterChildElements(_nsInfo.xmlNSPrefix + "history", _scxml, true);
+ NodeSet<std::string> histories = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "history", _scxml, true);
for (int i = 0; i < histories.size(); i++) {
_historyTargets[ATTR_CAST(histories[i], "id")] = Element<std::string>(histories[i]);
}
@@ -234,7 +235,7 @@ InterpreterState ChartToFSM::interpret() {
}
// set invokeid for all invokers to parent state if none given
- NodeSet<std::string> invokers = filterChildElements(_nsInfo.xmlNSPrefix + "invoke", _scxml, true);
+ NodeSet<std::string> invokers = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "invoke", _scxml, true);
for (int i = 0; i < invokers.size(); i++) {
Element<std::string> invokerElem = Element<std::string>(invokers[i]);
invokerElem.setAttribute("parent", ATTR_CAST(invokerElem.getParentNode(), "id"));
@@ -435,12 +436,12 @@ void ChartToFSM::internalDoneSend(const Arabica::DOM::Element<std::string>& stat
onentry.appendChild(raise);
if (doneData) {
- Arabica::XPath::NodeSet<std::string> contents = filterChildElements(_nsInfo.xmlNSPrefix + "content", doneData);
+ Arabica::XPath::NodeSet<std::string> contents = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "content", doneData);
if (contents.size() > 0) {
Node<std::string> imported = _flatDoc.importNode(contents[0], true);
raise.appendChild(imported);
}
- Arabica::XPath::NodeSet<std::string> params = filterChildElements(_nsInfo.xmlNSPrefix + "param", doneData);
+ Arabica::XPath::NodeSet<std::string> params = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "param", doneData);
if (params.size() > 0) {
Node<std::string> imported = _flatDoc.importNode(params[0], true);
raise.appendChild(imported);
@@ -532,7 +533,7 @@ static bool filterChildEnabled(const NodeSet<std::string>& transitions) {
if (p1 == p2) {
std::string eventDesc1 = ATTR_CAST(t1, "event");
std::string eventDesc2 = ATTR_CAST(t2, "event");
- if (InterpreterImpl::nameMatch(eventDesc1, eventDesc2)) {
+ if (nameMatch(eventDesc1, eventDesc2)) {
return false;
}
}
@@ -562,14 +563,14 @@ bool ChartToFSM::hasForeachInBetween(const Arabica::DOM::Node<std::string>& ance
void ChartToFSM::annotateRaiseAndSend(const Arabica::DOM::Element<std::string>& root) {
NodeSet<std::string> execContent;
- execContent.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "transition", _scxml, true));
- execContent.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "onentry", _scxml, true));
- execContent.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "onexit", _scxml, true));
+ execContent.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", _scxml, true));
+ execContent.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "onentry", _scxml, true));
+ execContent.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "onexit", _scxml, true));
for (int i = 0; i < execContent.size(); i++) {
Element<std::string> execContentElem(execContent[i]);
int nrRaise = 0;
- NodeSet<std::string> raise = filterChildElements(_nsInfo.xmlNSPrefix + "raise", execContent[i], true);
+ NodeSet<std::string> raise = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "raise", execContent[i], true);
for (int j = 0; j < raise.size(); j++) {
if (hasForeachInBetween(execContent[i], raise[j])) {
execContentElem.setAttribute("raise", "-1");
@@ -583,7 +584,7 @@ void ChartToFSM::annotateRaiseAndSend(const Arabica::DOM::Element<std::string>&
DONE_COUNT_RAISE:
int nrSend = 0;
- NodeSet<std::string> sends = filterChildElements(_nsInfo.xmlNSPrefix + "send", execContent[i], true);
+ NodeSet<std::string> sends = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "send", execContent[i], true);
for (int j = 0; j < sends.size(); j++) {
if (hasForeachInBetween(execContent[i], sends[j])) {
execContentElem.setAttribute("send", "-1");
@@ -600,7 +601,7 @@ DONE_COUNT_SEND:
}
void ChartToFSM::annotateDomain() {
- Arabica::XPath::NodeSet<std::string> allTransitions = filterChildElements(_nsInfo.xmlNSPrefix + "transition", _scxml, true);
+ Arabica::XPath::NodeSet<std::string> allTransitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", _scxml, true);
for (int i = 0; i < allTransitions.size(); i++) {
Element<std::string> transition(allTransitions[i]);
Arabica::DOM::Node<std::string> domain = getTransitionDomain(transition);
@@ -613,7 +614,7 @@ void ChartToFSM::annotateDomain() {
}
void ChartToFSM::annotateExitSet() {
- Arabica::XPath::NodeSet<std::string> allTransitions = filterChildElements(_nsInfo.xmlNSPrefix + "transition", _scxml, true);
+ Arabica::XPath::NodeSet<std::string> allTransitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", _scxml, true);
for (int i = 0; i < allTransitions.size(); i++) {
Element<std::string> transition(allTransitions[i]);
Arabica::DOM::Node<std::string> domain = getTransitionDomain(transition);
@@ -633,7 +634,7 @@ void ChartToFSM::annotateExitSet() {
}
void ChartToFSM::annotateEntrySet() {
- Arabica::XPath::NodeSet<std::string> allTransitions = filterChildElements(_nsInfo.xmlNSPrefix + "transition", _scxml, true);
+ Arabica::XPath::NodeSet<std::string> allTransitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", _scxml, true);
for (int i = 0; i < allTransitions.size(); i++) {
Element<std::string> transition(allTransitions[i]);
@@ -664,7 +665,7 @@ void ChartToFSM::annotateEntrySet() {
}
void ChartToFSM::annotateConflicts() {
- Arabica::XPath::NodeSet<std::string> allTransitions = filterChildElements(_nsInfo.xmlNSPrefix + "transition", _scxml, true);
+ Arabica::XPath::NodeSet<std::string> allTransitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", _scxml, true);
Arabica::XPath::NodeSet<std::string> allStates = getAllStates();
for (int i = 0; i < allTransitions.size(); i++) {
@@ -744,7 +745,7 @@ void ChartToFSM::indexTransitions() {
#if 0
void ChartToFSM::indexTransitions(const Arabica::DOM::Element<std::string>& root) {
// breadth first traversal of transitions
- Arabica::XPath::NodeSet<std::string> levelTransitions = filterChildElements(_nsInfo.xmlNSPrefix + "transition", root);
+ Arabica::XPath::NodeSet<std::string> levelTransitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", root);
for (int i = levelTransitions.size() - 1; i >= 0; i--) {
// push into index starting with least prior
indexedTransitions.push_back(Element<std::string>(levelTransitions[i]));
@@ -768,7 +769,7 @@ void ChartToFSM::indexTransitions(const Arabica::DOM::Element<std::string>& root
indexTransitions(childElem);
}
- Arabica::XPath::NodeSet<std::string> levelTransitions = filterChildElements(_nsInfo.xmlNSPrefix + "transition", root);
+ Arabica::XPath::NodeSet<std::string> levelTransitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", root);
for (int i = 0; i < levelTransitions.size(); i++) {
// push into index starting with least prior
indexedTransitions.push_back(Element<std::string>(levelTransitions[i]));
@@ -1247,10 +1248,10 @@ TransitionTreeNode* ChartToFSM::buildTransTree(const Arabica::DOM::Element<std::
// get all transitions and states from root without recursing
NodeSet<std::string> nested;
- nested.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "transition", root));
- nested.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "state", root));
- nested.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "final", root));
- nested.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "parallel", root));
+ nested.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", root));
+ nested.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "state", root));
+ nested.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "final", root));
+ nested.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "parallel", root));
nested.to_document_order();
TransitionTreeNode* lastNode = NULL;
@@ -1295,7 +1296,7 @@ TransitionTreeNode* ChartToFSM::buildTransTree(const Arabica::DOM::Element<std::
void ChartToFSM::getPotentialTransitionsForConfFromPowerSet(const Arabica::XPath::NodeSet<std::string>& conf, std::map<std::string, GlobalTransition*>& outMap) {
// get all transition elements from states in the current configuration
- NodeSet<std::string> allTransitions = filterChildElements(_nsInfo.xmlNSPrefix + "transition", conf);
+ NodeSet<std::string> allTransitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", conf);
{
std::string seperator = "";
@@ -1445,7 +1446,7 @@ void ChartToFSM::explode() {
// add all invokers for initial transition
for (unsigned int i = 0; i < _statesToInvoke.size(); i++) {
- NodeSet<std::string> invokes = filterChildElements(_nsInfo.xmlNSPrefix + "invoke", _statesToInvoke[i]);
+ NodeSet<std::string> invokes = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "invoke", _statesToInvoke[i]);
for (unsigned int j = 0; j < invokes.size(); j++) {
invoke(Element<std::string>(invokes[j]));
}
@@ -1592,7 +1593,7 @@ void ChartToFSM::explode() {
// add all invokers
for (unsigned int i = 0; i < _statesToInvoke.size(); i++) {
- NodeSet<std::string> invokes = filterChildElements(_nsInfo.xmlNSPrefix + "invoke", _statesToInvoke[i]);
+ NodeSet<std::string> invokes = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "invoke", _statesToInvoke[i]);
for (unsigned int j = 0; j < invokes.size(); j++) {
invoke(Element<std::string>(invokes[j]));
}
@@ -1915,7 +1916,7 @@ GlobalTransition::GlobalTransition(const Arabica::XPath::NodeSet<std::string>& t
conditions.push_back(boost::trim_copy(ATTR(transElem, "cond")));
}
- std::list<std::string> targets = InterpreterImpl::tokenizeIdRefs(ATTR(transElem, "target"));
+ std::list<std::string> targets = tokenize(ATTR(transElem, "target"));
std::list<std::string>::iterator targetIter = targets.begin();
while(targetIter != targets.end()) {
// std::cout << "// " << *targetIter << std::endl;
@@ -1983,7 +1984,7 @@ std::list<std::string> GlobalTransition::getCommonEvents(const NodeSet<std::stri
for (int i = 0; i < transitions.size(); i++) {
// for every transition
- std::list<std::string> eventNames = InterpreterImpl::tokenizeIdRefs(ATTR_CAST(transitions[i], "event"));
+ std::list<std::string> eventNames = tokenize(ATTR_CAST(transitions[i], "event"));
for (std::list<std::string>::iterator eventNameIter = eventNames.begin();
eventNameIter != eventNames.end();
@@ -2002,7 +2003,7 @@ std::list<std::string> GlobalTransition::getCommonEvents(const NodeSet<std::stri
// check if token would activate all other transitions
if (i == j)
continue;
- if (!InterpreterImpl::nameMatch(ATTR_CAST(transitions[j], "event"), eventName)) {
+ if (!nameMatch(ATTR_CAST(transitions[j], "event"), eventName)) {
isMatching = false;
break;
}
@@ -2020,7 +2021,7 @@ std::list<std::string> GlobalTransition::getCommonEvents(const NodeSet<std::stri
for (std::list<std::string>::iterator innerEventNameIter = prefixes.begin();
innerEventNameIter != prefixes.end();
innerEventNameIter++) {
- if (!iequals(*outerEventNameIter, *innerEventNameIter) && InterpreterImpl::nameMatch(*outerEventNameIter, *innerEventNameIter)) {
+ if (!iequals(*outerEventNameIter, *innerEventNameIter) && nameMatch(*outerEventNameIter, *innerEventNameIter)) {
goto IS_PREFIX;
}
}
diff --git a/src/uscxml/transform/ChartToFSM.h b/src/uscxml/transform/ChartToFSM.h
index ab4aed4..fa76f3a 100644
--- a/src/uscxml/transform/ChartToFSM.h
+++ b/src/uscxml/transform/ChartToFSM.h
@@ -20,8 +20,8 @@
#ifndef CHARTTOFSM_H_IOKPYEBY
#define CHARTTOFSM_H_IOKPYEBY
-#include "uscxml/DOMUtils.h"
#include "uscxml/interpreter/InterpreterRC.h"
+#include "uscxml/dom/DOMUtils.h"
#include <DOM/Document.hpp>
#include <DOM/Node.hpp>
#include <XPath/XPath.hpp>
diff --git a/src/uscxml/transform/ChartToFlatSCXML.cpp b/src/uscxml/transform/ChartToFlatSCXML.cpp
index 2905444..984c287 100644
--- a/src/uscxml/transform/ChartToFlatSCXML.cpp
+++ b/src/uscxml/transform/ChartToFlatSCXML.cpp
@@ -63,7 +63,7 @@ void ChartToFlatSCXML::writeTo(std::ostream& stream) {
}
// remove all debug attributes
- NodeSet<std::string> elementNodes = filterChildType(Node_base::ELEMENT_NODE, _scxml, true);
+ NodeSet<std::string> elementNodes = DOMUtils::filterChildType(Node_base::ELEMENT_NODE, _scxml, true);
for (int i = 0; i < elementNodes.size(); i++) {
Element<std::string> element(elementNodes[i]);
if (!envVarIsTrue("USCXML_ANNOTATE_GLOBAL_TRANS_SENDS") && HAS_ATTR(element, "send"))
@@ -92,7 +92,7 @@ void ChartToFlatSCXML::createDocument() {
return;
{
- NodeSet<std::string> allElements = filterChildType(Node_base::ELEMENT_NODE, _scxml, true);
+ NodeSet<std::string> allElements = DOMUtils::filterChildType(Node_base::ELEMENT_NODE, _scxml, true);
size_t nrElements = 0;
for (int i = 0; i < allElements.size(); i++) {
if (!isInEmbeddedDocument(allElements[i]))
@@ -133,7 +133,7 @@ void ChartToFlatSCXML::createDocument() {
NodeSet<std::string> datas;
if (_binding == InterpreterImpl::LATE) {
// with late binding, just copy direct datamodel childs
- datas = filterChildElements(_nsInfo.xmlNSPrefix + "datamodel", _origSCXML);
+ datas = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "datamodel", _origSCXML);
} else {
// with early binding, copy all datamodel elements into scxml element
datas = _xpath.evaluate("//" + _nsInfo.xpathPrefix + "datamodel", _origSCXML).asNodeSet();
@@ -146,13 +146,13 @@ void ChartToFlatSCXML::createDocument() {
}
- NodeSet<std::string> scripts = filterChildElements(_nsInfo.xmlNSPrefix + "script", _origSCXML);
+ NodeSet<std::string> scripts = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "script", _origSCXML);
for (int i = 0; i < scripts.size(); i++) {
Node<std::string> imported = _flatDoc.importNode(scripts[i], true);
_scxml.appendChild(imported);
}
- NodeSet<std::string> comments = filterChildType(Node_base::COMMENT_NODE, _origSCXML);
+ NodeSet<std::string> comments = DOMUtils::filterChildType(Node_base::COMMENT_NODE, _origSCXML);
for (int i = 0; i < comments.size(); i++) {
Node<std::string> imported = _flatDoc.importNode(comments[i], true);
_scxml.appendChild(imported);
@@ -177,13 +177,13 @@ void ChartToFlatSCXML::createDocument() {
_document = _flatDoc;
- NodeSet<std::string> scxmls = filterChildElements(_nsInfo.xmlNSPrefix + "scxml", _document);
+ NodeSet<std::string> scxmls = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "scxml", _document);
if (scxmls.size() > 0) {
_scxml = Element<std::string>(scxmls[0]);
}
{
- NodeSet<std::string> allElements = filterChildType(Node_base::ELEMENT_NODE, _scxml, true);
+ NodeSet<std::string> allElements = DOMUtils::filterChildType(Node_base::ELEMENT_NODE, _scxml, true);
size_t nrElements = 0;
for (int i = 0; i < allElements.size(); i++) {
if (!isInEmbeddedDocument(allElements[i]))
@@ -372,7 +372,7 @@ Node<std::string> ChartToFlatSCXML::globalTransitionToNode(GlobalTransition* glo
// we entered a new child - check if it has a datamodel and we entered for the first time
if (_binding == InterpreterImpl::LATE) {
- NodeSet<std::string> datamodel = filterChildElements(_nsInfo.xmlNSPrefix + "datamodel", actionIter->entered);
+ NodeSet<std::string> datamodel = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "datamodel", actionIter->entered);
if (datamodel.size() > 0 && !isMember(actionIter->entered, _globalConf[globalTransition->source]->getAlreadyEnteredStates())) {
childs.push_back(datamodel);
}
diff --git a/src/uscxml/transform/ChartToMinimalSCXML.cpp b/src/uscxml/transform/ChartToMinimalSCXML.cpp
index 69ac9cb..f052b09 100644
--- a/src/uscxml/transform/ChartToMinimalSCXML.cpp
+++ b/src/uscxml/transform/ChartToMinimalSCXML.cpp
@@ -49,7 +49,7 @@ void ChartToMinimalSCXML::writeTo(std::ostream& stream) {
addMonitor(this);
{
- NodeSet<std::string> allElements = filterChildType(Node_base::ELEMENT_NODE, _scxml, true);
+ NodeSet<std::string> allElements = DOMUtils::filterChildType(Node_base::ELEMENT_NODE, _scxml, true);
size_t nrElements = 0;
for (int i = 0; i < allElements.size(); i++) {
if (!isInEmbeddedDocument(allElements[i]))
@@ -61,11 +61,11 @@ void ChartToMinimalSCXML::writeTo(std::ostream& stream) {
// test 278 - move embedded datas to topmost datamodel
if (_binding == EARLY) {
// move all data elements into topmost datamodel element
- NodeSet<std::string> datas = filterChildElements(_nsInfo.xmlNSPrefix + "data", _scxml, true);
+ NodeSet<std::string> datas = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "data", _scxml, true);
if (datas.size() > 0) {
Node<std::string> topMostDatamodel;
- NodeSet<std::string> datamodels = filterChildElements(_nsInfo.xmlNSPrefix + "datamodel", _scxml, false);
+ NodeSet<std::string> datamodels = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "datamodel", _scxml, false);
if (datamodels.size() > 0) {
topMostDatamodel = datamodels[0];
} else {
@@ -118,7 +118,7 @@ void ChartToMinimalSCXML::writeTo(std::ostream& stream) {
removeUnvisited(_scxml);
{
- NodeSet<std::string> allElements = filterChildType(Node_base::ELEMENT_NODE, _scxml, true);
+ NodeSet<std::string> allElements = DOMUtils::filterChildType(Node_base::ELEMENT_NODE, _scxml, true);
size_t nrElements = 0;
for (int i = 0; i < allElements.size(); i++) {
if (!isInEmbeddedDocument(allElements[i]))
@@ -150,7 +150,7 @@ void ChartToMinimalSCXML::removeUnvisited(Arabica::DOM::Node<std::string>& node)
// special handling for conditional blocks with if
if (TAGNAME(elem) == _nsInfo.xmlNSPrefix + "if") {
- NodeSet<std::string> ifChilds = filterChildType(Node_base::ELEMENT_NODE, elem, false);
+ NodeSet<std::string> ifChilds = DOMUtils::filterChildType(Node_base::ELEMENT_NODE, elem, false);
Element<std::string> lastConditional = elem;
bool hadVisitedChild = false;
for (int j = 0; j < ifChilds.size(); j++) {
diff --git a/src/uscxml/transform/ChartToMinimalSCXML.h b/src/uscxml/transform/ChartToMinimalSCXML.h
index 0260ee1..4eb0b92 100644
--- a/src/uscxml/transform/ChartToMinimalSCXML.h
+++ b/src/uscxml/transform/ChartToMinimalSCXML.h
@@ -20,8 +20,8 @@
#ifndef CHARTTOMINIMALSCXML_H_7B97677A
#define CHARTTOMINIMALSCXML_H_7B97677A
-#include "uscxml/DOMUtils.h"
#include "uscxml/interpreter/InterpreterRC.h"
+#include "uscxml/dom/DOMUtils.h"
#include <DOM/Document.hpp>
#include <DOM/Node.hpp>
#include <XPath/XPath.hpp>
diff --git a/src/uscxml/transform/ChartToPromela.cpp b/src/uscxml/transform/ChartToPromela.cpp
index 4e3a990..747fb34 100644
--- a/src/uscxml/transform/ChartToPromela.cpp
+++ b/src/uscxml/transform/ChartToPromela.cpp
@@ -26,6 +26,7 @@
#include "uscxml/plugins/datamodel/promela/parser/promela.tab.hpp"
#include <DOM/io/Stream.hpp>
+#include <DOM/SAX2DOM/SAX2DOM.hpp>
#include <iostream>
#include "uscxml/UUID.h"
#include <math.h>
@@ -843,10 +844,10 @@ std::string ChartToPromela::conditionalizeForHist(const std::set<GlobalTransitio
// for (;;) {
// if (!HAS_ATTR(currState, "transient") || !DOMUtils::attributeIsTrue(ATTR(currState, "transient")))
// break;
-// content.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "invoke", currState));
-// content.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "onentry", currState));
-// content.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "onexit", currState));
-// NodeSet<std::string> transitions = filterChildElements(_nsInfo.xmlNSPrefix + "transition", currState);
+// content.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "invoke", currState));
+// content.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "onentry", currState));
+// content.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "onexit", currState));
+// NodeSet<std::string> transitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", currState);
// currState = _globalConf[ATTR_CAST(transitions[0], "target")];
// }
//
@@ -1511,7 +1512,7 @@ void ChartToPromela::writeExecutableContent(std::ostream& stream, const Arabica:
child = child.getNextSibling();
}
} else if(TAGNAME(nodeElem) == "script") {
- NodeSet<std::string> scriptText = filterChildType(Node_base::TEXT_NODE, node, true);
+ NodeSet<std::string> scriptText = DOMUtils::filterChildType(Node_base::TEXT_NODE, node, true);
for (int i = 0; i < scriptText.size(); i++) {
stream << ADAPT_SRC(beautifyIndentation(scriptText[i].getNodeValue(), indent)) << std::endl;
}
@@ -1564,13 +1565,13 @@ void ChartToPromela::writeExecutableContent(std::ostream& stream, const Arabica:
} else if(TAGNAME(nodeElem) == "if") {
NodeSet<std::string> condChain;
condChain.push_back(node);
- condChain.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "elseif", node));
- condChain.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "else", node));
+ condChain.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "elseif", node));
+ condChain.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "else", node));
writeIfBlock(stream, condChain, indent);
} else if(TAGNAME(nodeElem) == "assign") {
- NodeSet<std::string> assignTexts = filterChildType(Node_base::TEXT_NODE, nodeElem, true);
+ NodeSet<std::string> assignTexts = DOMUtils::filterChildType(Node_base::TEXT_NODE, nodeElem, true);
assert(assignTexts.size() > 0);
stream << beautifyIndentation(ADAPT_SRC(boost::trim_copy(assignTexts[0].getNodeValue())), indent) << std::endl;
@@ -1652,8 +1653,8 @@ void ChartToPromela::writeExecutableContent(std::ostream& stream, const Arabica:
typeAssignSS << padding << " tmpE.type = " << eventType << ";" << std::endl;
}
- NodeSet<std::string> sendParams = filterChildElements(_nsInfo.xmlNSPrefix + "param", nodeElem);
- NodeSet<std::string> sendContents = filterChildElements(_nsInfo.xmlNSPrefix + "content", nodeElem);
+ NodeSet<std::string> sendParams = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "param", nodeElem);
+ NodeSet<std::string> sendContents = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "content", nodeElem);
std::string sendNameList = ATTR(nodeElem, "namelist");
if (sendParams.size() > 0) {
for (int i = 0; i < sendParams.size(); i++) {
@@ -1662,7 +1663,7 @@ void ChartToPromela::writeExecutableContent(std::ostream& stream, const Arabica:
}
}
if (sendNameList.size() > 0) {
- std::list<std::string> nameListIds = tokenizeIdRefs(sendNameList);
+ std::list<std::string> nameListIds = tokenize(sendNameList);
std::list<std::string>::iterator nameIter = nameListIds.begin();
while(nameIter != nameListIds.end()) {
typeAssignSS << padding << " tmpE.data." << *nameIter << " = " << ADAPT_SRC(*nameIter) << ";" << std::endl;
@@ -1844,7 +1845,7 @@ PromelaInlines::PromelaInlines(const Arabica::DOM::Node<std::string>& node) {
for (int i = 0; i < levelNodes.size(); i++) {
// get all comments
- NodeSet<std::string> comments = InterpreterImpl::filterChildType(Node_base::COMMENT_NODE, levelNodes[i]);
+ NodeSet<std::string> comments = DOMUtils::filterChildType(Node_base::COMMENT_NODE, levelNodes[i]);
for (int j = 0; j < comments.size(); j++) {
PromelaInline* tmp = new PromelaInline(comments[j]);
if (tmp->type == PromelaInline::PROMELA_NIL) {
@@ -1864,7 +1865,7 @@ PromelaInlines::PromelaInlines(const Arabica::DOM::Node<std::string>& node) {
}
}
- levelNodes = InterpreterImpl::filterChildType(Node_base::ELEMENT_NODE, levelNodes);
+ levelNodes = DOMUtils::filterChildType(Node_base::ELEMENT_NODE, levelNodes);
level++;
}
}
@@ -2191,7 +2192,7 @@ void ChartToPromela::writeStartInvoker(std::ostream& stream, const Arabica::DOM:
}
// set from params
- NodeSet<std::string> invokeParams = filterChildElements(_nsInfo.xmlNSPrefix + "param", node);
+ NodeSet<std::string> invokeParams = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "param", node);
for (int i = 0; i < invokeParams.size(); i++) {
std::string identifier = ATTR_CAST(invokeParams[i], "name");
std::string expression = ATTR_CAST(invokeParams[i], "expr");
@@ -2218,10 +2219,10 @@ void ChartToPromela::writeFSM(std::ostream& stream) {
stream << " " << _prefix << "procid = _pid;" << std::endl;
stream << " }" << std::endl;
// write initial transition
-// transitions = filterChildElements(_nsInfo.xmlNSPrefix + "transition", _startState);
+// transitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", _startState);
// assert(transitions.size() == 1);
- NodeSet<std::string> scripts = filterChildElements(_nsInfo.xmlNSPrefix + "script", _scxml, false);
+ NodeSet<std::string> scripts = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "script", _scxml, false);
if (scripts.size() > 0) {
stream << std::endl << "/* global scripts */" << std::endl;
for (int i = 0; i < scripts.size(); i++) {
@@ -2336,14 +2337,14 @@ void ChartToPromela::writeFSM(std::ostream& stream) {
excludeEventDescs += " " + evIter->atom;
}
- NodeSet<std::string> transitions = filterChildElements("transition", es.container, true);
+ NodeSet<std::string> transitions = DOMUtils::filterChildElements("transition", es.container, true);
std::set<std::string> eventNames;
for (int i = 0; i < transitions.size(); i++) {
if (!HAS_ATTR_CAST(transitions[i], "event"))
continue;
if (HAS_ATTR_CAST(transitions[i], "cond") && ATTR_CAST(transitions[i], "cond").find("_event.") != std::string::npos)
continue;
- std::list<std::string> events = InterpreterImpl::tokenizeIdRefs(ATTR_CAST(transitions[i], "event"));
+ std::list<std::string> events = tokenize(ATTR_CAST(transitions[i], "event"));
for (std::list<std::string>::iterator evIter = events.begin(); evIter != events.end(); evIter++) {
std::string eventName = *evIter;
if (boost::ends_with(eventName, "*"))
@@ -2352,7 +2353,7 @@ void ChartToPromela::writeFSM(std::ostream& stream) {
eventName = eventName.substr(0, eventName.size() - 1);
// is this event excluded?
- if (!InterpreterImpl::nameMatch(excludeEventDescs, eventName)) {
+ if (!nameMatch(excludeEventDescs, eventName)) {
eventNames.insert(eventName);
}
}
@@ -2404,7 +2405,7 @@ void ChartToPromela::writeFSM(std::ostream& stream) {
{
bool finalizeFound = false;
for (std::map<Arabica::DOM::Node<std::string>, ChartToPromela*>::iterator invIter = _machines.begin(); invIter != _machines.end(); invIter++) {
- NodeSet<std::string> finalizes = filterChildElements(_nsInfo.xmlNSPrefix + "finalize", invIter->first, false);
+ NodeSet<std::string> finalizes = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "finalize", invIter->first, false);
if (finalizes.size() > 0) {
finalizeFound = true;
break;
@@ -2414,7 +2415,7 @@ void ChartToPromela::writeFSM(std::ostream& stream) {
stream << "/* <finalize> event */" << std::endl;
stream << " if" << std::endl;
for (std::map<Arabica::DOM::Node<std::string>, ChartToPromela*>::iterator invIter = _machines.begin(); invIter != _machines.end(); invIter++) {
- NodeSet<std::string> finalizes = filterChildElements(_nsInfo.xmlNSPrefix + "finalize", invIter->first, false);
+ NodeSet<std::string> finalizes = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "finalize", invIter->first, false);
if (finalizes.size() > 0) {
stream << " :: " << _prefix << "_event.invokeid == " << _analyzer->macroForLiteral(invIter->second->_invokerid) << " -> {" << std::endl;
writeExecutableContent(stream, finalizes[0], 3);
@@ -2841,7 +2842,7 @@ void ChartToPromela::writeDispatchingBlock(std::ostream& stream, std::list<Globa
} else {
std::string eventDescs = currTrans->eventDesc;
- std::list<std::string> eventNames = tokenizeIdRefs(eventDescs);
+ std::list<std::string> eventNames = tokenize(eventDescs);
std::set<std::string> eventPrefixes;
std::list<std::string>::iterator eventNameIter = eventNames.begin();
while(eventNameIter != eventNames.end()) {
@@ -2987,8 +2988,8 @@ void ChartToPromela::initNodes() {
{
// shorten UUID ids at invokers for readability
- NodeSet<std::string> invokes = filterChildElements(_nsInfo.xmlNSPrefix + "invoke", _scxml, true);
- invokes.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "uninvoke", _scxml, true));
+ NodeSet<std::string> invokes = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "invoke", _scxml, true);
+ invokes.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "uninvoke", _scxml, true));
// make sure all invokers have an id!
for (int i = 0; i < invokes.size(); i++) {
@@ -3006,7 +3007,7 @@ void ChartToPromela::initNodes() {
// are there nestes SCXML invokers?
{
- NodeSet<std::string> invokes = filterChildElements(_nsInfo.xmlNSPrefix + "invoke", _scxml, true);
+ NodeSet<std::string> invokes = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "invoke", _scxml, true);
for (int i = 0; i < invokes.size(); i++) {
if (!HAS_ATTR_CAST(invokes[i], "type") ||
ATTR_CAST(invokes[i], "type") == "scxml" ||
@@ -3023,9 +3024,9 @@ void ChartToPromela::initNodes() {
nested = Interpreter::fromURL(absUrl);
} else {
- NodeSet<std::string> nestedContent = InterpreterImpl::filterChildElements(_nsInfo.xmlNSPrefix + "content", invokes[i]);
+ NodeSet<std::string> nestedContent = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "content", invokes[i]);
assert(nestedContent.size() == 1);
- NodeSet<std::string> nestedRoot = InterpreterImpl::filterChildElements(_nsInfo.xmlNSPrefix + "scxml", nestedContent[0]);
+ NodeSet<std::string> nestedRoot = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "scxml", nestedContent[0]);
assert(nestedRoot.size() == 1);
DOMImplementation<std::string> domFactory = Arabica::SimpleDOM::DOMImplementation<std::string>::getDOMImplementation();
@@ -3070,9 +3071,9 @@ void ChartToPromela::initNodes() {
while(histIter != _historyTargets.end()) {
NodeSet<std::string> histStatesMembers;
bool isDeep = (HAS_ATTR_CAST(histIter->second, "type") && ATTR_CAST(histIter->second, "type") == "deep");
- histStatesMembers.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "state", histIter->second.getParentNode(), isDeep));
- histStatesMembers.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "parallel", histIter->second.getParentNode(), isDeep));
- histStatesMembers.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "final", histIter->second.getParentNode(), isDeep));
+ histStatesMembers.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "state", histIter->second.getParentNode(), isDeep));
+ histStatesMembers.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "parallel", histIter->second.getParentNode(), isDeep));
+ histStatesMembers.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "final", histIter->second.getParentNode(), isDeep));
for (int i = 0; i < histStatesMembers.size(); i++) {
_historyMembers[histIter->first].insert(std::make_pair(ATTR_CAST(histStatesMembers[i], "id"), i));
@@ -3089,7 +3090,7 @@ void ChartToPromela::initNodes() {
for (int i = 0; i < internalEventNames.size(); i++) {
if (HAS_ATTR_CAST(internalEventNames[i], "event")) {
std::string eventNames = ATTR_CAST(internalEventNames[i], "event");
- std::list<std::string> events = tokenizeIdRefs(eventNames);
+ std::list<std::string> events = tokenize(eventNames);
for (std::list<std::string>::iterator eventIter = events.begin();
eventIter != events.end(); eventIter++) {
std::string eventName = *eventIter;
@@ -3109,8 +3110,8 @@ void ChartToPromela::initNodes() {
// transform data / assign json into PROMELA statements
{
NodeSet<std::string> asgn;
- asgn.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "data", _scxml, true));
- asgn.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "assign", _scxml, true));
+ asgn.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "data", _scxml, true));
+ asgn.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "assign", _scxml, true));
for (int i = 0; i < asgn.size(); i++) {
if (isInEmbeddedDocument(asgn[i]))
@@ -3136,7 +3137,7 @@ void ChartToPromela::initNodes() {
absUrl.toAbsolute(_baseURL[_scxml]);
value = absUrl.getInContent();
} else {
- NodeSet<std::string> textChilds = filterChildType(Node_base::TEXT_NODE, asgnElem);
+ NodeSet<std::string> textChilds = DOMUtils::filterChildType(Node_base::TEXT_NODE, asgnElem);
if (textChilds.size() > 0) {
for (int j = 0; j < textChilds.size(); j++) {
value += textChilds[j].getNodeValue();
@@ -3171,9 +3172,9 @@ void ChartToPromela::initNodes() {
// do we need sendid / invokeid?
{
- NodeSet<std::string> invokes = filterChildElements(_nsInfo.xmlNSPrefix + "invoke", _scxml, true);
- NodeSet<std::string> sends = filterChildElements(_nsInfo.xmlNSPrefix + "send", _scxml, true);
- NodeSet<std::string> cancels = filterChildElements(_nsInfo.xmlNSPrefix + "cancel", _scxml, true);
+ NodeSet<std::string> invokes = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "invoke", _scxml, true);
+ NodeSet<std::string> sends = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "send", _scxml, true);
+ NodeSet<std::string> cancels = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "cancel", _scxml, true);
if (cancels.size() > 0) {
_analyzer->addCode("_event.invokeid", this);
@@ -3204,11 +3205,11 @@ void ChartToPromela::initNodes() {
{
// string literals for raise / send content
NodeSet<std::string> withContent;
- withContent.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "send", _scxml, true));
- withContent.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "raise", _scxml, true));
+ withContent.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "send", _scxml, true));
+ withContent.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "raise", _scxml, true));
for (int i = 0; i < withContent.size(); i++) {
- NodeSet<std::string> content = filterChildElements(_nsInfo.xmlNSPrefix + "content", withContent[i], true);
+ NodeSet<std::string> content = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "content", withContent[i], true);
for (int j = 0; j < content.size(); j++) {
Element<std::string> contentElem(content[j]);
std::string content = spaceNormalize(contentElem.getFirstChild().getNodeValue());
@@ -3264,7 +3265,7 @@ void ChartToPromela::initNodes() {
_analyzer->addLiteral(ATTR(_scxml, "name"), _analyzer->indexForLiteral(_prefix + "_sessionid"));
}
- NodeSet<std::string> contents = filterChildElements(_nsInfo.xmlNSPrefix + "content", _scxml, true);
+ NodeSet<std::string> contents = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "content", _scxml, true);
for (int i = 0; i < contents.size(); i++) {
Element<std::string> contentElem = Element<std::string>(contents[i]);
if (contentElem.hasChildNodes() && contentElem.getFirstChild().getNodeType() == Node_base::TEXT_NODE && contentElem.getChildNodes().getLength() == 1) {
@@ -3279,9 +3280,9 @@ void ChartToPromela::initNodes() {
std::set<std::string> allStrings;
{
NodeSet<std::string> withCond;
- withCond.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "transition", _scxml, true));
- withCond.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "if", _scxml, true));
- withCond.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "elseif", _scxml, true));
+ withCond.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", _scxml, true));
+ withCond.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "if", _scxml, true));
+ withCond.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "elseif", _scxml, true));
for (int i = 0; i < withCond.size(); i++) {
Element<std::string> elem = Element<std::string>(withCond[i]);
if (HAS_ATTR(elem, "cond")) {
@@ -3294,11 +3295,11 @@ void ChartToPromela::initNodes() {
}
{
NodeSet<std::string> withExpr;
- withExpr.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "log", _scxml, true));
- withExpr.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "data", _scxml, true));
- withExpr.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "assign", _scxml, true));
- withExpr.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "content", _scxml, true));
- withExpr.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "param", _scxml, true));
+ withExpr.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "log", _scxml, true));
+ withExpr.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "data", _scxml, true));
+ withExpr.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "assign", _scxml, true));
+ withExpr.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "content", _scxml, true));
+ withExpr.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "param", _scxml, true));
for (int i = 0; i < withExpr.size(); i++) {
Element<std::string> elem = Element<std::string>(withExpr[i]);
if (HAS_ATTR(elem, "expr")) {
@@ -3311,7 +3312,7 @@ void ChartToPromela::initNodes() {
}
{
NodeSet<std::string> withLocation;
- withLocation.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "assign", _scxml, true));
+ withLocation.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "assign", _scxml, true));
for (int i = 0; i < withLocation.size(); i++) {
Element<std::string> elem = Element<std::string>(withLocation[i]);
if (HAS_ATTR(elem, "location")) {
@@ -3324,10 +3325,10 @@ void ChartToPromela::initNodes() {
}
{
NodeSet<std::string> withText;
- withText.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "script", _scxml, true));
-// withText.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "data", _scxml, true));
+ withText.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "script", _scxml, true));
+// withText.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "data", _scxml, true));
for (int i = 0; i < withText.size(); i++) {
- NodeSet<std::string> texts = filterChildType(Node_base::TEXT_NODE, withText[i], true);
+ NodeSet<std::string> texts = DOMUtils::filterChildType(Node_base::TEXT_NODE, withText[i], true);
for (int j = 0; j < texts.size(); j++) {
if (texts[j].getNodeValue().size() > 0) {
Text<std::string> elem = Text<std::string>(texts[j]);
@@ -3340,7 +3341,7 @@ void ChartToPromela::initNodes() {
}
}
{
- NodeSet<std::string> foreachs = filterChildElements(_nsInfo.xmlNSPrefix + "foreach", _scxml, true);
+ NodeSet<std::string> foreachs = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "foreach", _scxml, true);
for (int i = 0; i < foreachs.size(); i++) {
if (HAS_ATTR_CAST(foreachs[i], "index")) {
allCode.insert(ATTR_CAST(foreachs[i], "index"));
@@ -3359,12 +3360,12 @@ void ChartToPromela::initNodes() {
// add all namelist entries to the _event structure
{
NodeSet<std::string> withNamelist;
- withNamelist.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "send", _scxml, true));
- withNamelist.push_back(filterChildElements(_nsInfo.xmlNSPrefix + "invoke", _scxml, true));
+ withNamelist.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "send", _scxml, true));
+ withNamelist.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "invoke", _scxml, true));
for (int i = 0; i < withNamelist.size(); i++) {
if (HAS_ATTR_CAST(withNamelist[i], "namelist")) {
std::string namelist = ATTR_CAST(withNamelist[i], "namelist");
- std::list<std::string> names = tokenizeIdRefs(namelist);
+ std::list<std::string> names = tokenize(namelist);
for (std::list<std::string>::iterator nameIter = names.begin(); nameIter != names.end(); nameIter++) {
_analyzer->addCode("_event.data." + *nameIter + " = 0;", this); // introduce for _event_t typedef
}
@@ -3531,14 +3532,14 @@ void ChartToPromela::writeProgram(std::ostream& stream) {
}
{
- NodeSet<std::string> cancels = filterChildElements(_nsInfo.xmlNSPrefix + "cancel", _scxml, true);
+ NodeSet<std::string> cancels = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "cancel", _scxml, true);
if (cancels.size() > 0) {
writeCancelEvents(stream);
stream << std::endl;
}
}
{
- NodeSet<std::string> invokes = filterChildElements(_nsInfo.xmlNSPrefix + "invoke", _scxml, true);
+ NodeSet<std::string> invokes = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "invoke", _scxml, true);
if (invokes.size() > 0 && _analyzer->usesEventField("delay")) {
writeRemovePendingEventsFromInvoker(stream);
stream << std::endl;
diff --git a/src/uscxml/transform/ChartToPromela.h b/src/uscxml/transform/ChartToPromela.h
index d289436..82c4e5d 100644
--- a/src/uscxml/transform/ChartToPromela.h
+++ b/src/uscxml/transform/ChartToPromela.h
@@ -23,7 +23,7 @@
#include "Transformer.h"
#include "ChartToFSM.h"
#include "uscxml/interpreter/InterpreterDraft6.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
#include "uscxml/util/Trie.h"
#include <DOM/Document.hpp>
diff --git a/src/uscxml/transform/ChartToTex.h b/src/uscxml/transform/ChartToTex.h
index 037b55c..de3743e 100644
--- a/src/uscxml/transform/ChartToTex.h
+++ b/src/uscxml/transform/ChartToTex.h
@@ -24,7 +24,7 @@
#include "Transformer.h"
#include "ChartToFSM.h"
#include "uscxml/Interpreter.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
#include "uscxml/util/Trie.h"
#include <DOM/Document.hpp>
diff --git a/src/uscxml/transform/ChartToVHDL.cpp b/src/uscxml/transform/ChartToVHDL.cpp
index f37ad7e..52f1a5c 100644
--- a/src/uscxml/transform/ChartToVHDL.cpp
+++ b/src/uscxml/transform/ChartToVHDL.cpp
@@ -22,7 +22,7 @@
#include <DOM/io/Stream.hpp>
#include <iostream>
#include "uscxml/UUID.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
#include <math.h>
#include <boost/algorithm/string.hpp>
#include <glog/logging.h>
@@ -103,9 +103,9 @@ void ChartToVHDL::checkDocument() {
void ChartToVHDL::findEvents() {
// elements with an event attribute
NodeSet<std::string> withEvent;
- withEvent.push_back(InterpreterImpl::filterChildElements(_nsInfo.xmlNSPrefix + "raise", _scxml, true));
- withEvent.push_back(InterpreterImpl::filterChildElements(_nsInfo.xmlNSPrefix + "send", _scxml, true));
- withEvent.push_back(InterpreterImpl::filterChildElements(_nsInfo.xmlNSPrefix + "transition", _scxml, true));
+ withEvent.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "raise", _scxml, true));
+ withEvent.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "send", _scxml, true));
+ withEvent.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", _scxml, true));
for (size_t i = 0; i < withEvent.size(); i++) {
if (HAS_ATTR_CAST(withEvent[i], "event")) {
@@ -479,7 +479,7 @@ void ChartToVHDL::writeOptimalTransitionSetSelection(std::ostream & stream) {
stream << " and ( '0' " << std::endl;;
// find all matching event literals
- std::list<std::string> eventDescs = tokenizeIdRefs(ATTR(transition, "event"));
+ std::list<std::string> eventDescs = tokenize(ATTR(transition, "event"));
for (std::list<std::string>::iterator descIter = eventDescs.begin(); descIter != eventDescs.end(); descIter++) {
std::list<TrieNode*> eventNames = _eventTrie.getWordsWithPrefix((*descIter) == "*" ? "" : *descIter);
for (std::list<TrieNode*>::iterator eventIter = eventNames.begin(); eventIter != eventNames.end(); eventIter++) {
diff --git a/src/uscxml/transform/ChartToVHDL.h b/src/uscxml/transform/ChartToVHDL.h
index abcb477..c2dec15 100644
--- a/src/uscxml/transform/ChartToVHDL.h
+++ b/src/uscxml/transform/ChartToVHDL.h
@@ -21,7 +21,7 @@
#define CHARTOVHDL_H
#include "uscxml/interpreter/InterpreterDraft6.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
#include "uscxml/util/Trie.h"
#include "Transformer.h"
#include "ChartToC.h"
diff --git a/src/uscxml/transform/FlatStateIdentifier.h b/src/uscxml/transform/FlatStateIdentifier.h
index 4afd956..99ae084 100644
--- a/src/uscxml/transform/FlatStateIdentifier.h
+++ b/src/uscxml/transform/FlatStateIdentifier.h
@@ -22,7 +22,7 @@
#include "uscxml/Common.h"
#include "uscxml/Convenience.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
#include <XPath/XPath.hpp>
diff --git a/src/uscxml/util/String.cpp b/src/uscxml/util/String.cpp
new file mode 100644
index 0000000..dc5a765
--- /dev/null
+++ b/src/uscxml/util/String.cpp
@@ -0,0 +1,176 @@
+/**
+ * @file
+ * @author 2016 Stefan Radomski (stefan.radomski@cs.tu-darmstadt.de)
+ * @copyright Simplified BSD
+ *
+ * @cond
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the FreeBSD license as published by the FreeBSD
+ * project.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the FreeBSD license along with this
+ * program. If not, see <http://www.opensource.org/licenses/bsd-license>.
+ * @endcond
+ */
+
+#include "String.h"
+#include <sstream>
+#include <boost/algorithm/string.hpp>
+
+namespace uscxml {
+
+#define ISWHITESPACE(char) (isspace(char))
+
+std::list<std::string> tokenize(const std::string& line, const char sep, bool trimWhiteSpace) {
+ std::list<std::string> tokens;
+
+ // appr. 3x faster than stringstream
+ size_t start = 0;
+ for (int i = 0; i < line.size(); i++) {
+ if (line[i] == sep || (trimWhiteSpace && ISWHITESPACE(line[i]))) {
+ if (i > 0 && start < i) {
+ tokens.push_back(line.substr(start, i - start));
+ }
+ while(line[i] == sep || (trimWhiteSpace && ISWHITESPACE(line[i]))) {
+ i++; // skip multiple occurences of seperator and whitespaces
+ }
+ start = i;
+ } else if (i + 1 == line.size()) {
+ tokens.push_back(line.substr(start, i + 1 - start));
+ }
+ }
+
+ return tokens;
+}
+
+std::string spaceNormalize(const std::string& text) {
+ std::stringstream content;
+
+#if 1
+ // 195ms with test-performance-events.scml
+ std::string seperator;
+
+ size_t start = 0;
+ for (int i = 0; i < text.size(); i++) {
+ if (isspace(text[i])) {
+ if (i > 0 && start < i) {
+ content << seperator << text.substr(start, i - start);
+ seperator = " ";
+ }
+ while(isspace(text[++i])); // skip whitespaces
+ start = i;
+ } else if (i + 1 == text.size()) {
+ content << seperator << text.substr(start, i + 1 - start);
+ }
+ }
+// std::cerr << ">>" << content.str() << "<<" << std::endl;
+
+#else
+
+// 291ms with test-performance-events.scml
+ std::istringstream iss(text);
+ std::string seperator;
+ do {
+ std::string token;
+ iss >> token;
+ if (token.length() > 0) {
+ content << seperator << token;
+ seperator = " ";
+ }
+ } while (iss);
+
+#endif
+ return content.str();
+}
+
+// see: http://www.w3.org/TR/scxml/#EventDescriptors
+bool nameMatch(const std::string& eventDescs, const std::string& eventName) {
+#if 1
+ if(eventDescs.length() == 0 || eventName.length() == 0)
+ return false;
+
+ // naive case of single descriptor and exact match
+ if (boost::iequals(eventDescs, eventName))
+ return true;
+
+ size_t start = 0;
+ std::string eventDesc;
+ for (int i = 0; i < eventDescs.size(); i++) {
+ if (isspace(eventDescs[i])) {
+ if (i > 0 && start < i - 1) {
+ eventDesc = eventDescs.substr(start, i - start);
+ }
+ while(isspace(eventDescs[++i])); // skip whitespaces
+ start = i;
+ } else if (i + 1 == eventDescs.size()) {
+ eventDesc = eventDescs.substr(start, i + 1 - start);
+ }
+
+ if (eventDesc.size() > 0) {
+ // remove optional trailing .* for CCXML compatibility
+ if (eventDesc.find("*", eventDesc.size() - 1) != std::string::npos)
+ eventDesc = eventDesc.substr(0, eventDesc.size() - 1);
+ if (eventDesc.find(".", eventDesc.size() - 1) != std::string::npos)
+ eventDesc = eventDesc.substr(0, eventDesc.size() - 1);
+
+ // was eventDesc the * wildcard
+ if (eventDesc.size() == 0)
+ return true;
+
+ // eventDesc has to be a real prefix of event now and therefore shorter
+ if (eventDesc.size() > eventName.size())
+ goto NEXT_DESC;
+
+ // are they already equal?
+ if (boost::iequals(eventDesc, eventName))
+ return true;
+
+ if (eventName.find(eventDesc) == 0) {
+ if (eventName.find(".", eventDesc.size()) == eventDesc.size())
+ return true;
+ }
+NEXT_DESC:
+ eventDesc = "";
+ }
+ }
+ return false;
+#else
+ const char* dPtr = eventDescs.c_str();
+ const char* ePtr = eventName.c_str();
+ while(*dPtr != 0) {
+
+ if (*dPtr == '*' && *ePtr != 0) // something following
+ return true;
+
+ // descriptor differs from event name
+ if (*dPtr != *ePtr) {
+ // move to next descriptor
+ while(*dPtr != ' ' && *dPtr != 0) {
+ dPtr++;
+ }
+ if (*dPtr == 0)
+ return false;
+ dPtr++;
+ ePtr = eventName.c_str();
+ } else {
+ // move both pointers one character
+ dPtr++;
+ ePtr++;
+
+ }
+
+ // descriptor is done, return match
+ if (((*dPtr == 0 || *dPtr == ' ') && (*ePtr == 0 || *ePtr == ' ')) || // exact match, end of string
+ (*dPtr == ' ' && *ePtr == '.') || (*dPtr == 0 && *ePtr == '.')) // prefix match
+ return true;
+ }
+ return false;
+#endif
+}
+
+
+} \ No newline at end of file
diff --git a/src/uscxml/util/String.h b/src/uscxml/util/String.h
new file mode 100644
index 0000000..5344245
--- /dev/null
+++ b/src/uscxml/util/String.h
@@ -0,0 +1,34 @@
+/**
+ * @file
+ * @author 2016 Stefan Radomski (stefan.radomski@cs.tu-darmstadt.de)
+ * @copyright Simplified BSD
+ *
+ * @cond
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the FreeBSD license as published by the FreeBSD
+ * project.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the FreeBSD license along with this
+ * program. If not, see <http://www.opensource.org/licenses/bsd-license>.
+ * @endcond
+ */
+
+#ifndef STRING_H_FD462039
+#define STRING_H_FD462039
+
+#include <string>
+#include <list>
+
+namespace uscxml {
+
+std::list<std::string> tokenize(const std::string& line, const char seperator = ' ', bool trimWhiteSpace = true);
+std::string spaceNormalize(const std::string& text);
+bool nameMatch(const std::string& eventDescs, const std::string& event);
+
+}
+
+#endif /* end of include guard: STRING_H_FD462039 */
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 1c1223e..b5b0906 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,6 +1,10 @@
set(TEST_TIMEOUT 15)
set(TEST_BENCHMARK_ITERATIONS 1000)
+find_program(SPIN spin)
+find_program(CC gcc)
+find_program(CXX g++)
+
function(USCXML_TEST_COMPILE)
set(options BUILD_ONLY)
set(oneValueArgs LABEL NAME)
@@ -82,6 +86,36 @@ add_test(test-execution ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/uscxml-browser ${CMAKE
add_test(test-communication ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/uscxml-browser -t5493 ${CMAKE_SOURCE_DIR}/test/uscxml/test-communication.scxml)
add_test(test-done-data ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/uscxml-browser ${CMAKE_SOURCE_DIR}/test/uscxml/test-donedata.scxml)
+# make sure all headers are self-reliant
+file(GLOB_RECURSE USCXML_HEADERS
+ ../src/*.h
+ ../src/*.hpp
+)
+
+foreach(USCXML_HEADER ${USCXML_HEADERS} )
+ STRING(REGEX REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/../src/" "" USCXML_REL_HEADER ${USCXML_HEADER})
+
+ set(HEADER_TEST)
+ set(HEADER_TEST "${HEADER_TEST}#include \"${USCXML_HEADER}\"\n")
+ set(HEADER_TEST "${HEADER_TEST}int main(int argc, char** argv) {}")
+ FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/headers/${USCXML_REL_HEADER}.cpp ${HEADER_TEST})
+
+ add_test(NAME "header/${USCXML_REL_HEADER}"
+ COMMAND ${CMAKE_COMMAND}
+ -DTESTFILE:FILEPATH=${CMAKE_CURRENT_BINARY_DIR}/headers/${USCXML_REL_HEADER}.cpp
+ -DCC_BIN:FILEPATH=${CC}
+ -DCXX_BIN:FILEPATH=${CXX}
+ -DPROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}
+ -DUSCXML_PLATFORM_ID=${USCXML_PLATFORM_ID}
+ -DCMAKE_BINARY_DIR=${CMAKE_BINARY_DIR}
+ -DPROJECT_BINARY_DIR=${PROJECT_BINARY_DIR}
+ -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
+ -P ${CMAKE_CURRENT_SOURCE_DIR}/ctest/scripts/run_header_compiles.cmake)
+ set_property(TEST "header/${USCXML_REL_HEADER}" PROPERTY LABELS "header/${USCXML_REL_HEADER}")
+
+endforeach()
+
+
# tests for inline SCXML with generated C
add_executable(test-c-inline src/test-c-inline.c)
@@ -107,10 +141,6 @@ set_property(TEST "gen/c/inline" PROPERTY LABELS "gen/c/inline")
# declare W3C tests
-find_program(SPIN spin)
-find_program(CC gcc)
-find_program(CXX g++)
-
if (NOT BUILD_MINIMAL)
# compile and add all reported issues tests
diff --git a/test/ctest/CTestCustom.ctest.in b/test/ctest/CTestCustom.ctest.in
index a9a96ad..9dfd5b2 100644
--- a/test/ctest/CTestCustom.ctest.in
+++ b/test/ctest/CTestCustom.ctest.in
@@ -251,6 +251,15 @@ set(CTEST_CUSTOM_TESTS_IGNORE
"perf/ecma/test553.scxml"
"perf/ecma/test579.scxml"
+ ### Ignore some Header self-sufficient tests
+ "header/bindings/swig/msvc/inttypes.h"
+ "header/bindings/swig/wrapped/WrappedDataModel.h"
+ "header/bindings/swig/wrapped/WrappedExecutableContent.h"
+ "header/bindings/swig/wrapped/WrappedInterpreterMonitor.h"
+ "header/bindings/swig/wrapped/WrappedInvoker.h"
+ "header/bindings/swig/wrapped/WrappedIOProcessor.h"
+
+
)
# unset(CTEST_CUSTOM_TESTS_IGNORE)
diff --git a/test/src/test-arabica-namespaces.cpp b/test/src/test-arabica-namespaces.cpp
index 3214d9f..ced9578 100644
--- a/test/src/test-arabica-namespaces.cpp
+++ b/test/src/test-arabica-namespaces.cpp
@@ -7,7 +7,8 @@
#include <DOM/SAX2DOM/SAX2DOM.hpp>
#include <DOM/io/Stream.hpp>
#include "uscxml/Interpreter.h"
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
+#include "uscxml/dom/NameSpacingParser.h"
using namespace Arabica::DOM;
using namespace Arabica::XPath;
@@ -25,8 +26,8 @@ parsed = cloneDocument(parsed);\
insertBaz(parsed);\
std::cout << parsed.first << std::endl;\
validateRootFooBarBaz(parsed);\
-assert(InterpreterImpl::filterChildElements(origNS.xmlNSPrefix + "bar", origDoc.getDocumentElement()).size() == 3);\
-assert(InterpreterImpl::filterChildElements(origNS.xmlNSPrefix + "baz", origDoc.getDocumentElement()).size() == 0);
+assert(DOMUtils::filterChildElements(origNS.xmlNSPrefix + "bar", origDoc.getDocumentElement()).size() == 3);\
+assert(DOMUtils::filterChildElements(origNS.xmlNSPrefix + "baz", origDoc.getDocumentElement()).size() == 0);
/**
@@ -96,7 +97,7 @@ static void validateRootFoo(std::pair<Document<std::string>, NameSpaceInfo>& par
assert(TAGNAME_CAST(root) == nsInfo.xmlNSPrefix + "root");
assert(LOCALNAME_CAST(root) == "root");
- NodeSet<std::string> foosFiltered = InterpreterImpl::filterChildElements(nsInfo.xmlNSPrefix + "foo", root);
+ NodeSet<std::string> foosFiltered = DOMUtils::filterChildElements(nsInfo.xmlNSPrefix + "foo", root);
assert(foosFiltered.size() == 3);
NodeSet<std::string> foosXPath = _xpath.evaluate("//" + nsInfo.xpathPrefix + "foo", root).asNodeSet();
assert(foosXPath.size() == 3);
@@ -118,7 +119,7 @@ static void validateRootFooBar(std::pair<Document<std::string>, NameSpaceInfo>&
Node<std::string> root = document.getDocumentElement();
_xpath.setNamespaceContext(*nsInfo.getNSContext());
- NodeSet<std::string> barsFiltered = InterpreterImpl::filterChildElements(nsInfo.xmlNSPrefix + "bar", root);
+ NodeSet<std::string> barsFiltered = DOMUtils::filterChildElements(nsInfo.xmlNSPrefix + "bar", root);
assert(barsFiltered.size() == 3);
NodeSet<std::string> barsXPath = _xpath.evaluate("//" + nsInfo.xpathPrefix + "bar", root).asNodeSet();
assert(barsXPath.size() == 3);
@@ -143,7 +144,7 @@ static void validateRootFooBarBaz(std::pair<Document<std::string>, NameSpaceInfo
assert(TAGNAME_CAST(root) == nsInfo.xmlNSPrefix + "root");
assert(LOCALNAME_CAST(root) == "root");
- NodeSet<std::string> bazsFiltered = InterpreterImpl::filterChildElements(nsInfo.xmlNSPrefix + "baz", root);
+ NodeSet<std::string> bazsFiltered = DOMUtils::filterChildElements(nsInfo.xmlNSPrefix + "baz", root);
assert(bazsFiltered.size() == 3);
NodeSet<std::string> bazsXPath = _xpath.evaluate("//" + nsInfo.xpathPrefix + "baz", root).asNodeSet();
assert(bazsXPath.size() == 3);
diff --git a/test/src/test-arabica-xpath.cpp b/test/src/test-arabica-xpath.cpp
index 998f4aa..9e21624 100644
--- a/test/src/test-arabica-xpath.cpp
+++ b/test/src/test-arabica-xpath.cpp
@@ -5,7 +5,7 @@
#include <DOM/io/Stream.hpp>
#include <iostream>
#include <string>
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
#define string_type std::string
#define string_adaptor Arabica::default_string_adaptor<std::string>
diff --git a/test/src/test-c-inline.c b/test/src/test-c-inline.c
index c12ac73..a4b237c 100644
--- a/test/src/test-c-inline.c
+++ b/test/src/test-c-inline.c
@@ -28,10 +28,11 @@ void enteredFoo() {
int main(int argc, char** argv) {
uscxml_ctx ctx;
+ int err = USCXML_ERR_OK;
+
memset(&ctx, 0, sizeof(uscxml_ctx));
ctx.machine = &USCXML_MACHINE_TEST_INLINE;
- int err = USCXML_ERR_OK;
while(err != USCXML_ERR_DONE) {
err = uscxml_step(&ctx);
}
diff --git a/test/src/test-c-inline.c.scxml.c b/test/src/test-c-inline.c.scxml.c
index d586bb3..740d030 100644
--- a/test/src/test-c-inline.c.scxml.c
+++ b/test/src/test-c-inline.c.scxml.c
@@ -60,7 +60,7 @@
*/
#ifndef USCXML_MAX_NR_TRANS_BYTES
-# define USCXML_MAX_NR_TRANS_BYTES 0
+# define USCXML_MAX_NR_TRANS_BYTES 1
#endif
/**
@@ -165,12 +165,14 @@ typedef struct uscxml_elem_invoke uscxml_elem_invoke;
typedef struct uscxml_elem_send uscxml_elem_send;
typedef struct uscxml_elem_param uscxml_elem_param;
typedef struct uscxml_elem_data uscxml_elem_data;
+typedef struct uscxml_elem_assign uscxml_elem_assign;
typedef struct uscxml_elem_donedata uscxml_elem_donedata;
typedef struct uscxml_elem_foreach uscxml_elem_foreach;
typedef void* (*dequeue_internal_t)(const uscxml_ctx* ctx);
typedef void* (*dequeue_external_t)(const uscxml_ctx* ctx);
-typedef int (*is_enabled_t)(const uscxml_ctx* ctx, const uscxml_transition* transition, const void* event);
+typedef int (*is_enabled_t)(const uscxml_ctx* ctx, const uscxml_transition* transition);
+typedef int (*is_matched_t)(const uscxml_ctx* ctx, const uscxml_transition* transition, const void* event);
typedef int (*is_true_t)(const uscxml_ctx* ctx, const char* expr);
typedef int (*exec_content_t)(const uscxml_ctx* ctx, const uscxml_state* state, const void* event);
typedef int (*raise_done_event_t)(const uscxml_ctx* ctx, const uscxml_state* state, const uscxml_elem_donedata* donedata);
@@ -182,7 +184,7 @@ typedef int (*exec_content_send_t)(const uscxml_ctx* ctx, const uscxml_elem_send
typedef int (*exec_content_foreach_init_t)(const uscxml_ctx* ctx, const uscxml_elem_foreach* foreach);
typedef int (*exec_content_foreach_next_t)(const uscxml_ctx* ctx, const uscxml_elem_foreach* foreach);
typedef int (*exec_content_foreach_done_t)(const uscxml_ctx* ctx, const uscxml_elem_foreach* foreach);
-typedef int (*exec_content_assign_t)(const uscxml_ctx* ctx, const char* location, const char* expr);
+typedef int (*exec_content_assign_t)(const uscxml_ctx* ctx, const uscxml_elem_assign* assign);
typedef int (*exec_content_init_t)(const uscxml_ctx* ctx, const uscxml_elem_data* data);
typedef int (*exec_content_cancel_t)(const uscxml_ctx* ctx, const char* sendid, const char* sendidexpr);
typedef int (*exec_content_finalize_t)(const uscxml_ctx* ctx, const uscxml_elem_invoke* invoker, const void* event);
@@ -218,6 +220,15 @@ struct uscxml_elem_data {
};
/**
+ * All information pertaining to an <assign> element.
+ */
+struct uscxml_elem_assign {
+ const char* location;
+ const char* expr;
+ const char* content;
+};
+
+/**
* All information pertaining to any state element.
*/
struct uscxml_state {
@@ -335,6 +346,7 @@ struct uscxml_ctx {
dequeue_internal_t dequeue_internal;
dequeue_external_t dequeue_external;
is_enabled_t is_enabled;
+ is_matched_t is_matched;
is_true_t is_true;
raise_done_event_t raise_done_event;
@@ -420,9 +432,6 @@ static const uscxml_state _uscxml_9FAC9BE9_states[2] = {
#ifndef USCXML_NO_ELEM_INFO
-static const uscxml_transition _uscxml_9FAC9BE9_transitions[0] = {
-};
-
#endif
#ifndef USCXML_NO_ELEM_INFO
@@ -441,7 +450,7 @@ const uscxml_machine _uscxml_9FAC9BE9_machine = {
/* datamodel */ "native",
/* uuid */ "9FAC9BE9A82F66AFD36A205557064B27",
/* states */ &_uscxml_9FAC9BE9_states[0],
- /* transitions */ &_uscxml_9FAC9BE9_transitions[0],
+ /* transitions */ NULL,
/* parent */ NULL,
/* donedata */ &_uscxml_9FAC9BE9_elem_donedatas[0],
/* script */ NULL
@@ -656,7 +665,8 @@ SELECT_TRANSITIONS:
if ((USCXML_GET_TRANS(i).event == NULL && ctx->event == NULL) ||
(USCXML_GET_TRANS(i).event != NULL && ctx->event != NULL)) {
/* is it enabled? */
- if (ctx->is_enabled(ctx, &USCXML_GET_TRANS(i), ctx->event) > 0) {
+ if ((ctx->event == NULL || ctx->is_matched(ctx, &USCXML_GET_TRANS(i), ctx->event) > 0) &&
+ (USCXML_GET_TRANS(i).condition == NULL || ctx->is_enabled(ctx, &USCXML_GET_TRANS(i)) > 0)) {
/* remember that we found a transition */
ctx->flags |= USCXML_CTX_TRANSITION_FOUND;
diff --git a/test/src/test-c-machine.cpp b/test/src/test-c-machine.cpp
index b4864e2..815993e 100644
--- a/test/src/test-c-machine.cpp
+++ b/test/src/test-c-machine.cpp
@@ -23,7 +23,7 @@
#include "uscxml/Convenience.h"
#include "uscxml/URL.h"
#include "uscxml/concurrency/Timer.h"
-//#include "uscxml/DOMUtils.h"
+//#include "uscxml/dom/DOMUtils.h"
#include "uscxml/Factory.h"
//#include "uscxml/Interpreter.h"
#include "uscxml/UUID.h"
diff --git a/test/src/test-predicates.cpp b/test/src/test-predicates.cpp
index 7ba9225..0aff104 100644
--- a/test/src/test-predicates.cpp
+++ b/test/src/test-predicates.cpp
@@ -1,5 +1,6 @@
#define protected public
#include "uscxml/Interpreter.h"
+#include "uscxml/util/String.h"
#undef protected
#include <iostream>
@@ -54,35 +55,35 @@ int main(int argc, char** argv) {
{
std::string idrefs("id1");
- std::list<std::string> tokenizedIdrefs = InterpreterImpl::tokenizeIdRefs(idrefs);
+ std::list<std::string> tokenizedIdrefs = tokenize(idrefs);
assert(tokenizedIdrefs.size() == 1);
assert(tokenizedIdrefs.front().compare("id1") == 0);
}
{
std::string idrefs(" id1");
- std::list<std::string> tokenizedIdrefs = InterpreterImpl::tokenizeIdRefs(idrefs);
+ std::list<std::string> tokenizedIdrefs = tokenize(idrefs);
assert(tokenizedIdrefs.size() == 1);
assert(tokenizedIdrefs.front().compare("id1") == 0);
}
{
std::string idrefs(" id1 ");
- std::list<std::string> tokenizedIdrefs = InterpreterImpl::tokenizeIdRefs(idrefs);
+ std::list<std::string> tokenizedIdrefs = tokenize(idrefs);
assert(tokenizedIdrefs.size() == 1);
assert(tokenizedIdrefs.front().compare("id1") == 0);
}
{
std::string idrefs(" \tid1\n ");
- std::list<std::string> tokenizedIdrefs = InterpreterImpl::tokenizeIdRefs(idrefs);
+ std::list<std::string> tokenizedIdrefs = tokenize(idrefs);
assert(tokenizedIdrefs.size() == 1);
assert(tokenizedIdrefs.front().compare("id1") == 0);
}
{
std::string idrefs("id1 id2 id3");
- std::list<std::string> tokenizedIdrefs = InterpreterImpl::tokenizeIdRefs(idrefs);
+ std::list<std::string> tokenizedIdrefs = tokenize(idrefs);
assert(tokenizedIdrefs.size() == 3);
assert(tokenizedIdrefs.front().compare("id1") == 0);
tokenizedIdrefs.pop_front();
@@ -93,7 +94,7 @@ int main(int argc, char** argv) {
{
std::string idrefs("\t id1 \nid2\n\n id3\t");
- std::list<std::string> tokenizedIdrefs = InterpreterImpl::tokenizeIdRefs(idrefs);
+ std::list<std::string> tokenizedIdrefs = tokenize(idrefs);
assert(tokenizedIdrefs.size() == 3);
assert(tokenizedIdrefs.front().compare("id1") == 0);
tokenizedIdrefs.pop_front();
@@ -104,7 +105,7 @@ int main(int argc, char** argv) {
{
std::string idrefs("id1 \nid2 \tid3");
- std::list<std::string> tokenizedIdrefs = InterpreterImpl::tokenizeIdRefs(idrefs);
+ std::list<std::string> tokenizedIdrefs = tokenize(idrefs);
assert(tokenizedIdrefs.size() == 3);
assert(tokenizedIdrefs.front().compare("id1") == 0);
tokenizedIdrefs.pop_front();
@@ -115,20 +116,20 @@ int main(int argc, char** argv) {
std::string transEvents;
transEvents = "error";
- assert(InterpreterImpl::nameMatch(transEvents, "error"));
- assert(!InterpreterImpl::nameMatch(transEvents, "foo"));
+ assert(nameMatch(transEvents, "error"));
+ assert(!nameMatch(transEvents, "foo"));
transEvents = " error foo";
- assert(InterpreterImpl::nameMatch(transEvents, "error"));
- assert(InterpreterImpl::nameMatch(transEvents, "error.send"));
- assert(InterpreterImpl::nameMatch(transEvents, "error.send.failed"));
- assert(InterpreterImpl::nameMatch(transEvents, "foo"));
- assert(InterpreterImpl::nameMatch(transEvents, "foo.bar"));
- assert(!InterpreterImpl::nameMatch(transEvents, "errors.my.custom"));
- assert(!InterpreterImpl::nameMatch(transEvents, "errorhandler.mistake"));
+ assert(nameMatch(transEvents, "error"));
+ assert(nameMatch(transEvents, "error.send"));
+ assert(nameMatch(transEvents, "error.send.failed"));
+ assert(nameMatch(transEvents, "foo"));
+ assert(nameMatch(transEvents, "foo.bar"));
+ assert(!nameMatch(transEvents, "errors.my.custom"));
+ assert(!nameMatch(transEvents, "errorhandler.mistake"));
// is the event name case sensitive?
- // assert(!InterpreterImpl::nameMatch(transEvents, "errOr.send"));
- assert(!InterpreterImpl::nameMatch(transEvents, "foobar"));
+ // assert(!nameMatch(transEvents, "errOr.send"));
+ assert(!nameMatch(transEvents, "foobar"));
} catch(std::exception e) {
std::cout << e.what();
return false;
diff --git a/test/src/test-promela-parser.cpp b/test/src/test-promela-parser.cpp
index cab19ab..f3ac4cc 100644
--- a/test/src/test-promela-parser.cpp
+++ b/test/src/test-promela-parser.cpp
@@ -9,6 +9,7 @@
#include <assert.h>
#include <boost/algorithm/string.hpp>
#include <iostream>
+#include <DOM/SAX2DOM/SAX2DOM.hpp>
#include <DOM/Document.hpp>
using namespace uscxml;
diff --git a/test/src/test-w3c.cpp b/test/src/test-w3c.cpp
index 0ac33a7..669db30 100644
--- a/test/src/test-w3c.cpp
+++ b/test/src/test-w3c.cpp
@@ -21,7 +21,7 @@
# endif
-#include "uscxml/DOMUtils.h"
+#include "uscxml/dom/DOMUtils.h"
#include "uscxml/concurrency/Timer.h"
#include "uscxml/Factory.h"
@@ -178,7 +178,7 @@ int main(int argc, char** argv) {
if (delayFactor != 1) {
Arabica::DOM::Document<std::string> document = interpreter.getDocument();
Arabica::DOM::Element<std::string> root = document.getDocumentElement();
- Arabica::XPath::NodeSet<std::string> sends = InterpreterImpl::filterChildElements(interpreter.getNameSpaceInfo().xmlNSPrefix + "send", root, true);
+ Arabica::XPath::NodeSet<std::string> sends = DOMUtils::filterChildElements(interpreter.getNameSpaceInfo().xmlNSPrefix + "send", root, true);
for (int i = 0; i < sends.size(); i++) {
Arabica::DOM::Element<std::string> send = Arabica::DOM::Element<std::string>(sends[i]);