summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Radomski <sradomski@mintwerk.de>2016-01-30 00:42:45 (GMT)
committerStefan Radomski <sradomski@mintwerk.de>2016-01-30 00:42:45 (GMT)
commit0b313e00915b31c8c03980b7225f82ac2e9513e6 (patch)
tree2b3bf60553db69bf7bb7cc9c37cdb96faf198f6e
parente67b8c3bce5ce1cf5b3b1b17faff3ec114b70f0a (diff)
downloaduscxml-0b313e00915b31c8c03980b7225f82ac2e9513e6.zip
uscxml-0b313e00915b31c8c03980b7225f82ac2e9513e6.tar.gz
uscxml-0b313e00915b31c8c03980b7225f82ac2e9513e6.tar.bz2
Prepared ANSI C transformation with invokers
-rw-r--r--apps/uscxml-transform.cpp104
-rw-r--r--src/uscxml/DOMUtils.cpp49
-rw-r--r--src/uscxml/DOMUtils.h15
-rw-r--r--src/uscxml/Interpreter.cpp7
-rw-r--r--src/uscxml/Interpreter.h1
-rw-r--r--src/uscxml/interpreter/InterpreterFast.cpp42
-rw-r--r--src/uscxml/interpreter/InterpreterFast.h47
-rw-r--r--src/uscxml/transform/ChartToC.cpp83
-rw-r--r--src/uscxml/transform/ChartToC.h18
-rw-r--r--src/uscxml/transform/ChartToVHDL.cpp6
-rw-r--r--src/uscxml/transform/Transformer.h16
11 files changed, 270 insertions, 118 deletions
diff --git a/apps/uscxml-transform.cpp b/apps/uscxml-transform.cpp
index 69e0c97..fcc9965 100644
--- a/apps/uscxml-transform.cpp
+++ b/apps/uscxml-transform.cpp
@@ -7,9 +7,13 @@
#include "uscxml/transform/ChartToMinimalSCXML.h"
#include "uscxml/transform/ChartToPromela.h"
#include "uscxml/DOMUtils.h"
+
#include <glog/logging.h>
+#include <boost/algorithm/string.hpp>
+
#include <fstream>
#include <iostream>
+#include <map>
#include "uscxml/Factory.h"
#include "uscxml/server/HTTPServer.h"
@@ -28,7 +32,7 @@
#endif
#define ANNOTATE(envKey, annotationParam) \
-envVarIsTrue(envKey) || std::find(annotations.begin(), annotations.end(), annotationParam) != annotations.end()
+envVarIsTrue(envKey) || std::find(options.begin(), options.end(), annotationParam) != options.end()
class VerboseMonitor : public uscxml::InterpreterMonitor {
void onStableConfiguration(uscxml::Interpreter interpreter) {
@@ -71,29 +75,31 @@ void printUsageAndExit(const char* progName) {
printf(" [-i URL] [-o FILE]");
printf("\n");
printf("Options\n");
- printf("\t-t c : convert to C program\n");
- printf("\t-t pml : convert to spin/promela program\n");
- printf("\t-t vhdl : convert to VHDL hardware description\n");
- printf("\t-t flat : flatten to SCXML state-machine\n");
- printf("\t-t min : minimize SCXML state-chart\n");
- printf("\t-t tex : write global state transition table as tex file\n");
- printf("\t-a {OPTIONS} : annotate SCXML elements with comma seperated options\n");
- printf("\t 'priority' - transitions with their priority for transition selection\n");
- printf("\t 'exitset' - annotate all transitions with their exit sets\n");
- printf("\t 'entryset' - annotate all transitions with their entry sets\n");
- printf("\t 'conflicts' - annotate all transitions with their conflicts\n");
- printf("\t 'domain' - annotate all transitions with their domain\n");
- printf("\t 'step' - global states with their step identifier (-tflat only)\n");
- printf("\t 'members' - global transitions with their member transitions per index (-tflat only)\n");
- printf("\t 'sends' - transititve number of sends to external queue for global transitions (-tflat only)\n");
- printf("\t 'raises' - transititve number of raises to internal queue for global transitions (-tflat only)\n");
- printf("\t 'verbose' - comments detailling state changes and transitions for content selection (-tflat only)\n");
- printf("\t 'progress' - insert comments documenting progress in dociment (-tmin only)\n");
- printf("\t 'nocomment' - surpress the generation of comments in output\n");
- printf("\t-v : be verbose\n");
- printf("\t-lN : Set loglevel to N\n");
- printf("\t-i URL : Input file (defaults to STDIN)\n");
- printf("\t-o FILE : Output file (defaults to STDOUT)\n");
+ printf("\t-t c : convert to C program\n");
+ printf("\t-t pml : convert to spin/promela program\n");
+ printf("\t-t vhdl : convert to VHDL hardware description\n");
+ printf("\t-t flat : flatten to SCXML state-machine\n");
+ printf("\t-t min : minimize SCXML state-chart\n");
+ printf("\t-t tex : write global state transition table as tex file\n");
+ printf("\t-a {OPTIONS} : annotate SCXML elements with comma seperated options\n");
+ printf("\t priority - transitions with their priority for transition selection\n");
+ printf("\t exitset - annotate all transitions with their exit sets\n");
+ printf("\t entryset - annotate all transitions with their entry sets\n");
+ printf("\t conflicts - annotate all transitions with their conflicts\n");
+ printf("\t domain - annotate all transitions with their domain\n");
+ printf("\t step - global states with their step identifier (-tflat only)\n");
+ printf("\t members - global transitions with their member transitions per index (-tflat only)\n");
+ printf("\t sends - transititve number of sends to external queue for global transitions (-tflat only)\n");
+ printf("\t raises - transititve number of raises to internal queue for global transitions (-tflat only)\n");
+ printf("\t verbose - comments detailling state changes and transitions for content selection (-tflat only)\n");
+ printf("\t progress - insert comments documenting progress in dociment (-tmin only)\n");
+ printf("\t nocomment - surpress the generation of comments in output\n");
+ printf("\t-X {PARAMETER} : pass additional parameters to the transformation\n");
+ printf("\t prefix=ID - prefix all symbols and identifiers with ID (-tc)\n");
+ printf("\t-v : be verbose\n");
+ printf("\t-lN : Set loglevel to N\n");
+ printf("\t-i URL : Input file (defaults to STDIN)\n");
+ printf("\t-o FILE : Output file (defaults to STDOUT)\n");
printf("\n");
exit(1);
}
@@ -106,8 +112,9 @@ int main(int argc, char** argv) {
std::string pluginPath;
std::string inputFile;
std::string outputFile;
- std::list<std::string> annotations;
-
+ std::list<std::string> options;
+ std::multimap<std::string, std::string> extensions;
+
#if defined(HAS_SIGNAL_H) && !defined(WIN32)
signal(SIGPIPE, SIG_IGN);
#endif
@@ -122,7 +129,8 @@ int main(int argc, char** argv) {
struct option longOptions[] = {
{"verbose", no_argument, 0, 'v'},
{"type", required_argument, 0, 't'},
- {"annotate", required_argument, 0, 'a'},
+ {"annotate", required_argument, 0, 'a'},
+ {"param", required_argument, 0, 'X'},
{"plugin-path", required_argument, 0, 'p'},
{"input-file", required_argument, 0, 'i'},
{"output-file", required_argument, 0, 'o'},
@@ -134,7 +142,7 @@ int main(int argc, char** argv) {
int optionInd = 0;
int option;
for (;;) {
- option = getopt_long_only(argc, argv, "+vp:t:i:o:l:a:", longOptions, &optionInd);
+ option = getopt_long_only(argc, argv, "+vp:X:t:i:o:l:a:", longOptions, &optionInd);
if (option == -1) {
break;
}
@@ -157,8 +165,17 @@ int main(int argc, char** argv) {
inputFile = optarg;
break;
case 'a':
- annotations = InterpreterImpl::tokenize(optarg, ',');
+ options = InterpreterImpl::tokenize(optarg, ',');
break;
+ case 'X': {
+ std::list<std::string> extension = InterpreterImpl::tokenize(optarg, '=');
+ if (extension.size() != 2)
+ printUsageAndExit(argv[0]);
+ std::string key = boost::trim_copy(*(extension.begin()));
+ std::string value = boost::trim_copy(*(++extension.begin()));
+ extensions.insert(std::pair<std::string, std::string>(key, value));
+ }
+ break;
case 'o':
outputFile = optarg;
break;
@@ -228,11 +245,11 @@ int main(int argc, char** argv) {
outType != "vhdl" &&
outType != "min" &&
outType != "tex" &&
- std::find(annotations.begin(), annotations.end(), "priority") == annotations.end() &&
- std::find(annotations.begin(), annotations.end(), "domain") == annotations.end() &&
- std::find(annotations.begin(), annotations.end(), "conflicts") == annotations.end() &&
- std::find(annotations.begin(), annotations.end(), "exitset") == annotations.end() &&
- std::find(annotations.begin(), annotations.end(), "entryset") == annotations.end())
+ std::find(options.begin(), options.end(), "priority") == options.end() &&
+ std::find(options.begin(), options.end(), "domain") == options.end() &&
+ std::find(options.begin(), options.end(), "conflicts") == options.end() &&
+ std::find(options.begin(), options.end(), "exitset") == options.end() &&
+ std::find(options.begin(), options.end(), "entryset") == options.end())
printUsageAndExit(argv[0]);
// register plugins
@@ -271,12 +288,15 @@ int main(int argc, char** argv) {
}
if (outType == "c") {
+ Transformer transformer = ChartToC::transform(interpreter);
+ transformer.setExtensions(extensions);
+ transformer.setOptions(options);
if (outputFile.size() == 0 || outputFile == "-") {
- ChartToC::transform(interpreter).writeTo(std::cout);
+ transformer.writeTo(std::cout);
} else {
std::ofstream outStream;
outStream.open(outputFile.c_str());
- ChartToC::transform(interpreter).writeTo(outStream);
+ transformer.writeTo(outStream);
outStream.close();
}
exit(EXIT_SUCCESS);
@@ -344,17 +364,17 @@ int main(int argc, char** argv) {
#if 1
- if (annotations.size() > 0) {
+ if (options.size() > 0) {
ChartToFSM annotater(interpreter);
- if (std::find(annotations.begin(), annotations.end(), "priority") != annotations.end())
+ if (std::find(options.begin(), options.end(), "priority") != options.end())
annotater.indexTransitions();
- if (std::find(annotations.begin(), annotations.end(), "conflicts") != annotations.end())
+ if (std::find(options.begin(), options.end(), "conflicts") != options.end())
annotater.annotateConflicts();
- if (std::find(annotations.begin(), annotations.end(), "exitset") != annotations.end())
+ if (std::find(options.begin(), options.end(), "exitset") != options.end())
annotater.annotateExitSet();
- if (std::find(annotations.begin(), annotations.end(), "entryset") != annotations.end())
+ if (std::find(options.begin(), options.end(), "entryset") != options.end())
annotater.annotateEntrySet();
- if (std::find(annotations.begin(), annotations.end(), "domain") != annotations.end())
+ if (std::find(options.begin(), options.end(), "domain") != options.end())
annotater.annotateDomain();
if (outputFile.size() == 0 || outputFile == "-") {
diff --git a/src/uscxml/DOMUtils.cpp b/src/uscxml/DOMUtils.cpp
index 9703432..97b84c8 100644
--- a/src/uscxml/DOMUtils.cpp
+++ b/src/uscxml/DOMUtils.cpp
@@ -26,6 +26,9 @@
namespace uscxml {
+using namespace Arabica::XPath;
+using namespace Arabica::DOM;
+
bool DOMUtils::attributeIsTrue(const::std::string& value) {
return stringIsTrue(value.c_str());
}
@@ -126,6 +129,52 @@ std::string DOMUtils::xPathForNode(const Arabica::DOM::Node<std::string>& node,
return xPath;
}
+NodeSet<std::string> DOMUtils::inPostFixOrder(const std::set<std::string>& elements, const Element<std::string>& root) {
+ NodeSet<std::string> nodes;
+ inPostFixOrder(elements, root, nodes);
+ return nodes;
+}
+
+void DOMUtils::inPostFixOrder(const std::set<std::string>& elements, const Element<std::string>& root, NodeSet<std::string>& nodes) {
+ NodeList<std::string> children = root.getChildNodes();
+ for (size_t i = 0; i < children.getLength(); i++) {
+ if (children.item(i).getNodeType() != Node_base::ELEMENT_NODE)
+ continue;
+ Arabica::DOM::Element<std::string> childElem(children.item(i));
+ inPostFixOrder(elements, childElem, nodes);
+
+ }
+ for (size_t i = 0; i < children.getLength(); i++) {
+ if (children.item(i).getNodeType() != Node_base::ELEMENT_NODE)
+ continue;
+ Arabica::DOM::Element<std::string> childElem(children.item(i));
+
+ if (elements.find(TAGNAME(childElem)) != elements.end()) {
+ nodes.push_back(childElem);
+ }
+ }
+}
+
+NodeSet<std::string> DOMUtils::inDocumentOrder(const std::set<std::string>& elements, const Element<std::string>& root) {
+ NodeSet<std::string> nodes;
+ inDocumentOrder(elements, root, nodes);
+ return nodes;
+}
+
+void DOMUtils::inDocumentOrder(const std::set<std::string>& elements, const Element<std::string>& root, NodeSet<std::string>& nodes) {
+ if (elements.find(TAGNAME(root)) != elements.end()) {
+ nodes.push_back(root);
+ }
+
+ NodeList<std::string> children = root.getChildNodes();
+ for (size_t i = 0; i < children.getLength(); i++) {
+ if (children.item(i).getNodeType() != Node_base::ELEMENT_NODE)
+ continue;
+ Arabica::DOM::Element<std::string> childElem(children.item(i));
+ inDocumentOrder(elements, childElem, nodes);
+ }
+}
+
std::list<Arabica::DOM::Node<std::string> > DOMUtils::getElementsByType(const Arabica::DOM::Node<std::string>& root, Arabica::DOM::Node_base::Type type) {
std::list<Arabica::DOM::Node<std::string> > result;
std::list<Arabica::DOM::Node<std::string> > stack;
diff --git a/src/uscxml/DOMUtils.h b/src/uscxml/DOMUtils.h
index 426d797..a94bd90 100644
--- a/src/uscxml/DOMUtils.h
+++ b/src/uscxml/DOMUtils.h
@@ -25,6 +25,7 @@
#include <SAX/helpers/DefaultHandler.hpp>
#include <SAX/helpers/CatchErrorHandler.hpp>
#include <DOM/io/Stream.hpp> // operator<< for nodes
+#include <XPath/XPath.hpp>
#define TAGNAME_CAST(elem) ((Arabica::DOM::Element<std::string>)elem).getTagName()
#define LOCALNAME_CAST(elem) ((Arabica::DOM::Element<std::string>)elem).getLocalName()
@@ -47,6 +48,20 @@ public:
static std::string idForNode(const Arabica::DOM::Node<std::string>& node);
// deprecated, use stringIsTrue from Convenience.h instead
DEPRECATED static bool attributeIsTrue(const::std::string& value);
+
+ static Arabica::XPath::NodeSet<std::string> inPostFixOrder(const std::set<std::string>& elements,
+ const Arabica::DOM::Element<std::string>& root);
+ static Arabica::XPath::NodeSet<std::string> inDocumentOrder(const std::set<std::string>& elements,
+ const Arabica::DOM::Element<std::string>& root);
+protected:
+ static void inPostFixOrder(const std::set<std::string>& elements,
+ const Arabica::DOM::Element<std::string>& root,
+ Arabica::XPath::NodeSet<std::string>& nodes);
+
+ static void inDocumentOrder(const std::set<std::string>& elements,
+ const Arabica::DOM::Element<std::string>& root,
+ Arabica::XPath::NodeSet<std::string>& nodes);
+
};
class ScriptEntityResolver : public Arabica::SAX::EntityResolver<std::string> {
diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp
index f1490d4..a05fe39 100644
--- a/src/uscxml/Interpreter.cpp
+++ b/src/uscxml/Interpreter.cpp
@@ -52,9 +52,12 @@
#if 0
# define INTERPRETER_IMPL InterpreterDraft6
# include "uscxml/interpreter/InterpreterDraft6.h"
-#else
+#elif 1
# define INTERPRETER_IMPL InterpreterRC
# include "uscxml/interpreter/InterpreterRC.h"
+#else
+# define INTERPRETER_IMPL InterpreterFast
+# include "uscxml/interpreter/InterpreterFast.h"
#endif
#define VERBOSE 0
@@ -776,7 +779,7 @@ NodeSet<std::string> InterpreterImpl::getDocumentInitialTransitions() {
}
return initialTransitions;
}
-
+
InterpreterState InterpreterImpl::step(int waitForMS) {
try {
tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
diff --git a/src/uscxml/Interpreter.h b/src/uscxml/Interpreter.h
index c996c78..ce9354a 100644
--- a/src/uscxml/Interpreter.h
+++ b/src/uscxml/Interpreter.h
@@ -417,7 +417,6 @@ public:
virtual void handleDOMEvent(Arabica::DOM::Events::Event<std::string>& event);
protected:
-
static void run(void*); // static method for thread to run
class DOMEventListener : public Arabica::DOM::Events::EventListener<std::string> {
diff --git a/src/uscxml/interpreter/InterpreterFast.cpp b/src/uscxml/interpreter/InterpreterFast.cpp
new file mode 100644
index 0000000..0958c61
--- /dev/null
+++ b/src/uscxml/interpreter/InterpreterFast.cpp
@@ -0,0 +1,42 @@
+/**
+ * @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 "InterpreterFast.h"
+
+#include "uscxml/Factory.h"
+#include "uscxml/concurrency/DelayedEventQueue.h"
+
+#include <glog/logging.h>
+#include "uscxml/UUID.h"
+#include "uscxml/DOMUtils.h"
+
+namespace uscxml {
+
+using namespace Arabica::XPath;
+using namespace Arabica::DOM;
+
+
+void InterpreterFast::handleDOMEvent(Arabica::DOM::Events::Event<std::string>& event) {
+ InterpreterImpl::handleDOMEvent(event);
+
+ if (event.getType().compare("DOMAttrModified") == 0) // we do not care about attributes
+ return;
+
+}
+} \ No newline at end of file
diff --git a/src/uscxml/interpreter/InterpreterFast.h b/src/uscxml/interpreter/InterpreterFast.h
new file mode 100644
index 0000000..589e899
--- /dev/null
+++ b/src/uscxml/interpreter/InterpreterFast.h
@@ -0,0 +1,47 @@
+/**
+ * @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 INTERPRETERFAST_H_224A5F07
+#define INTERPRETERFAST_H_224A5F07
+
+#include "uscxml/Interpreter.h"
+
+namespace uscxml {
+
+class InterpreterFast : public InterpreterImpl {
+protected:
+ virtual void setupSets();
+ virtual void handleDOMEvent(Arabica::DOM::Events::Event<std::string>& event);
+
+private:
+
+ /* TODO: use post-order and document-order per STL comparator (sorted std::set?) */
+
+ std::vector<Arabica::XPath::NodeSet<std::string> > _states;
+ std::vector<Arabica::XPath::NodeSet<std::string> > _transitions;
+
+ std::vector<std::vector<bool> > _conflictingTransitions;
+ std::vector<std::vector<bool> > _exitSets;
+ std::vector<std::vector<bool> > _targetSets;
+
+};
+
+}
+
+#endif /* end of include guard: INTERPRETERFAST_H_224A5F07 */
diff --git a/src/uscxml/transform/ChartToC.cpp b/src/uscxml/transform/ChartToC.cpp
index a105f93..710a2de 100644
--- a/src/uscxml/transform/ChartToC.cpp
+++ b/src/uscxml/transform/ChartToC.cpp
@@ -51,7 +51,7 @@ ChartToC::ChartToC(const Interpreter& other) : TransformerImpl() {
void ChartToC::setHistoryCompletion() {
std::set<std::string> elements;
elements.insert(_nsInfo.xmlNSPrefix + "history");
- Arabica::XPath::NodeSet<std::string> histories = inPostFixOrder(elements, _scxml);
+ Arabica::XPath::NodeSet<std::string> histories = DOMUtils::inPostFixOrder(elements, _scxml);
NodeSet<std::string> covered;
NodeSet<std::string> perParentcovered;
@@ -235,7 +235,7 @@ void ChartToC::prepare() {
elements.insert(_nsInfo.xmlNSPrefix + "history");
elements.insert(_nsInfo.xmlNSPrefix + "initial");
elements.insert(_nsInfo.xmlNSPrefix + "parallel");
- _states = inDocumentOrder(elements, _scxml);
+ _states = DOMUtils::inDocumentOrder(elements, _scxml);
// set states' document order and parent attribute
for (size_t i = 0; i < _states.size(); i++) {
@@ -280,7 +280,7 @@ void ChartToC::prepare() {
// set transitions' document order and source attribute
elements.clear();
elements.insert(_nsInfo.xmlNSPrefix + "transition");
- _transitions = inDocumentOrder(elements, _scxml);
+ _transitions = DOMUtils::inDocumentOrder(elements, _scxml);
for (size_t i = 0; i < _transitions.size(); i++) {
Element<std::string> transition(_transitions[i]);
transition.setAttribute("documentOrder", toStr(i));
@@ -291,7 +291,7 @@ void ChartToC::prepare() {
}
// set transitions' postfix order attribute
- _transitions = inPostFixOrder(elements, _scxml);
+ _transitions = DOMUtils::inPostFixOrder(elements, _scxml);
for (size_t i = 0; i < _transitions.size(); i++) {
Element<std::string> transition(_transitions[i]);
transition.setAttribute("postFixOrder", toStr(i));
@@ -482,11 +482,11 @@ void ChartToC::writeMacros(std::ostream& stream) {
void ChartToC::writeTypes(std::ostream& stream) {
stream << std::endl;
- stream << "typedef struct scxml_transition scxml_transition;" << std::endl;
+ stream << "typedef struct scxml_machine scxml_machine;" << std::endl;
+ stream << "typedef struct scxml_transition scxml_transition;" << std::endl;
stream << "typedef struct scxml_state scxml_state;" << std::endl;
stream << "typedef struct scxml_ctx scxml_ctx;" << std::endl;
stream << "typedef struct scxml_invoke scxml_invoke;" << std::endl;
-
stream << std::endl;
stream << "typedef struct scxml_elem_send scxml_elem_send;" << std::endl;
@@ -518,6 +518,26 @@ void ChartToC::writeTypes(std::ostream& stream) {
stream << "typedef int (*exec_content_script_t)(const scxml_ctx* ctx, const char* src, const char* content);" << std::endl;
stream << std::endl;
+#if 0
+ stream << "struct scxml_machine {" << std::endl;
+ stream << " uint8_t flags;" << std::endl;
+ stream << " uint32_t nr_states;" << std::endl;
+ stream << " uint32_t nr_transitions;" << std::endl;
+ stream << " const char* name;" << std::endl;
+ stream << " const char* datamodel;" << std::endl;
+ stream << " const char* uuid;" << std::endl;
+ stream << " const scxml_elem_data* datas;" << std::endl;
+ stream << " const scxml_state* states;" << std::endl;
+ stream << " const scxml_transition* transitions;" << std::endl;
+ stream << " const scxml_foreach* foreachs;" << std::endl;
+ stream << " const scxml_elem_param* params;" << std::endl;
+ stream << " const scxml_elem_donedata* donedatas;" << std::endl;
+ stream << " const scxml_elem_invoke* invokes;" << std::endl;
+ stream << " const scxml_elem_send* sends;" << std::endl;
+ stream << "};" << std::endl;
+ stream << std::endl;
+#endif
+
stream << "struct scxml_elem_data {" << std::endl;
stream << " const char* id;" << std::endl;
stream << " const char* src;" << std::endl;
@@ -575,7 +595,8 @@ void ChartToC::writeTypes(std::ostream& stream) {
stream << std::endl;
stream << "struct scxml_elem_invoke {" << std::endl;
- stream << " const char* type;" << std::endl;
+ stream << " const char* uuid;" << std::endl;
+ stream << " const char* type;" << std::endl;
stream << " const char* typeexpr;" << std::endl;
stream << " const char* src;" << std::endl;
stream << " const char* srcexpr;" << std::endl;
@@ -1305,7 +1326,7 @@ void ChartToC::writeTransitions(std::ostream& stream) {
// cross reference transition by document order - is this really needed?!
std::set<std::string> elements;
elements.insert(_nsInfo.xmlNSPrefix + "transition");
- NodeSet<std::string> transDocOrder = inDocumentOrder(elements, _scxml);
+ NodeSet<std::string> transDocOrder = DOMUtils::inDocumentOrder(elements, _scxml);
stream << "static const scxml_transition scxml_transitions[" << toStr(_transitions.size()) << "] = {" << std::endl;
for (size_t i = 0; i < _transitions.size(); i++) {
@@ -1839,52 +1860,6 @@ void ChartToC::writeFSM(std::ostream& stream) {
stream << std::endl;
}
-NodeSet<std::string> ChartToC::inPostFixOrder(const std::set<std::string>& elements, const Element<std::string>& root) {
- NodeSet<std::string> nodes;
- inPostFixOrder(elements, root, nodes);
- return nodes;
-}
-
-void ChartToC::inPostFixOrder(const std::set<std::string>& elements, const Element<std::string>& root, NodeSet<std::string>& nodes) {
- NodeList<std::string> children = root.getChildNodes();
- for (size_t i = 0; i < children.getLength(); i++) {
- if (children.item(i).getNodeType() != Node_base::ELEMENT_NODE)
- continue;
- Arabica::DOM::Element<std::string> childElem(children.item(i));
- inPostFixOrder(elements, childElem, nodes);
-
- }
- for (size_t i = 0; i < children.getLength(); i++) {
- if (children.item(i).getNodeType() != Node_base::ELEMENT_NODE)
- continue;
- Arabica::DOM::Element<std::string> childElem(children.item(i));
-
- if (elements.find(TAGNAME(childElem)) != elements.end()) {
- nodes.push_back(childElem);
- }
- }
-}
-
-NodeSet<std::string> ChartToC::inDocumentOrder(const std::set<std::string>& elements, const Element<std::string>& root) {
- NodeSet<std::string> nodes;
- inDocumentOrder(elements, root, nodes);
- return nodes;
-}
-
-void ChartToC::inDocumentOrder(const std::set<std::string>& elements, const Element<std::string>& root, NodeSet<std::string>& nodes) {
- if (elements.find(TAGNAME(root)) != elements.end()) {
- nodes.push_back(root);
- }
-
- NodeList<std::string> children = root.getChildNodes();
- for (size_t i = 0; i < children.getLength(); i++) {
- if (children.item(i).getNodeType() != Node_base::ELEMENT_NODE)
- continue;
- Arabica::DOM::Element<std::string> childElem(children.item(i));
- inDocumentOrder(elements, childElem, nodes);
- }
-}
-
ChartToC::~ChartToC() {
}
diff --git a/src/uscxml/transform/ChartToC.h b/src/uscxml/transform/ChartToC.h
index 039e8a4..1ac59f3 100644
--- a/src/uscxml/transform/ChartToC.h
+++ b/src/uscxml/transform/ChartToC.h
@@ -20,7 +20,7 @@
#ifndef FSMTOCPP_H_201672B0
#define FSMTOCPP_H_201672B0
-#include "uscxml/interpreter/InterpreterDraft6.h"
+#include "uscxml/interpreter/InterpreterRC.h"
#include "uscxml/DOMUtils.h"
#include "uscxml/util/Trie.h"
#include "Transformer.h"
@@ -40,20 +40,8 @@ public:
void writeTo(std::ostream& stream);
- static Arabica::XPath::NodeSet<std::string> inPostFixOrder(const std::set<std::string>& elements,
- const Arabica::DOM::Element<std::string>& root);
- static Arabica::XPath::NodeSet<std::string> inDocumentOrder(const std::set<std::string>& elements,
- const Arabica::DOM::Element<std::string>& root);
protected:
ChartToC(const Interpreter& other);
-
- static void inPostFixOrder(const std::set<std::string>& elements,
- const Arabica::DOM::Element<std::string>& root,
- Arabica::XPath::NodeSet<std::string>& nodes);
-
- static void inDocumentOrder(const std::set<std::string>& elements,
- const Arabica::DOM::Element<std::string>& root,
- Arabica::XPath::NodeSet<std::string>& nodes);
void writeIncludes(std::ostream& stream);
void writeMacros(std::ostream& stream);
@@ -81,8 +69,8 @@ protected:
Arabica::XPath::NodeSet<std::string> _states;
Arabica::XPath::NodeSet<std::string> _transitions;
- bool _hasGlobalScripts;
-
+// std::string md5sum;
+
size_t _transCharArraySize;
std::string _transCharArrayInit;
std::string _transDataType;
diff --git a/src/uscxml/transform/ChartToVHDL.cpp b/src/uscxml/transform/ChartToVHDL.cpp
index d5bbac3..7631619 100644
--- a/src/uscxml/transform/ChartToVHDL.cpp
+++ b/src/uscxml/transform/ChartToVHDL.cpp
@@ -74,7 +74,7 @@ void ChartToVHDL::checkDocument() {
elements.insert(_nsInfo.xmlNSPrefix + "cancel");
elements.insert(_nsInfo.xmlNSPrefix + "invoke");
elements.insert(_nsInfo.xmlNSPrefix + "finalize");
- unsupported = ChartToC::inDocumentOrder(elements, _scxml);
+ unsupported = DOMUtils::inDocumentOrder(elements, _scxml);
std::stringstream ss;
if (unsupported.size() > 0) {
@@ -86,7 +86,7 @@ void ChartToVHDL::checkDocument() {
elements.clear();
elements.insert(_nsInfo.xmlNSPrefix + "transition");
- unsupported = inDocumentOrder(elements, _scxml);
+ unsupported = DOMUtils::inDocumentOrder(elements, _scxml);
for (int i = 0; i < unsupported.size(); i++) {
Element<std::string> transition(unsupported[i]);
@@ -116,7 +116,7 @@ void ChartToVHDL::findEvents() {
void ChartToVHDL::writeTo(std::ostream& stream) {
// same preparations as the C transformation
- prepare();
+ prepare();
// checkDocument();
findEvents();
diff --git a/src/uscxml/transform/Transformer.h b/src/uscxml/transform/Transformer.h
index 16d0a94..c88015b 100644
--- a/src/uscxml/transform/Transformer.h
+++ b/src/uscxml/transform/Transformer.h
@@ -21,7 +21,8 @@
#define TRANSFORMER_H_32113356
#include <iostream>
-#include "uscxml/interpreter/InterpreterRC.h"
+#include <map>
+#include "uscxml/Interpreter.h"
namespace uscxml {
@@ -34,6 +35,11 @@ public:
throw std::runtime_error("Transformer cannot be interpreted as an Interpreter again");
}
+protected:
+ std::multimap<std::string, std::string> _extensions;
+ std::list<std::string> _options;
+
+ friend class Transformer;
};
class USCXML_API Transformer : public boost::enable_shared_from_this<Transformer> {
@@ -73,6 +79,14 @@ public:
return _impl;
}
+ void setExtensions(const std::multimap<std::string, std::string>& extensions) {
+ _impl->_extensions = extensions;
+ }
+
+ void setOptions(const std::list<std::string>& options) {
+ _impl->_options = options;
+ }
+
protected:
boost::shared_ptr<TransformerImpl> _impl;