diff options
Diffstat (limited to 'src/uscxml/transform')
-rw-r--r-- | src/uscxml/transform/ChartToC.cpp | 83 | ||||
-rw-r--r-- | src/uscxml/transform/ChartToC.h | 18 | ||||
-rw-r--r-- | src/uscxml/transform/ChartToVHDL.cpp | 6 | ||||
-rw-r--r-- | src/uscxml/transform/Transformer.h | 16 |
4 files changed, 50 insertions, 73 deletions
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; |