diff options
Diffstat (limited to 'src/uscxml')
-rwxr-xr-x | src/uscxml/transform/ChartToC.cpp | 73 |
1 files changed, 57 insertions, 16 deletions
diff --git a/src/uscxml/transform/ChartToC.cpp b/src/uscxml/transform/ChartToC.cpp index 08ea1a0..75aaf8b 100755 --- a/src/uscxml/transform/ChartToC.cpp +++ b/src/uscxml/transform/ChartToC.cpp @@ -710,7 +710,7 @@ void ChartToC::writeTypes(std::ostream& stream) { stream << "typedef struct uscxml_elem_assign uscxml_elem_assign;" << std::endl; stream << "typedef struct uscxml_elem_donedata uscxml_elem_donedata;" << std::endl; stream << "typedef struct uscxml_elem_foreach uscxml_elem_foreach;" << std::endl; - stream << "typedef struct uscxml_elem_tascxml_result uscxml_elem_tascxml_result;" << std::endl;
+ stream << "typedef struct uscxml_elem_tascxml_result uscxml_elem_tascxml_result;" << std::endl; stream << std::endl; stream << "typedef void* (*dequeue_internal_t)(const uscxml_ctx* ctx);" << std::endl; @@ -887,20 +887,29 @@ void ChartToC::writeTypes(std::ostream& stream) { stream << std::endl; stream << "/**" << std::endl; - stream << " * All information pertaining to a <tascxml:result> element" << std::endl;
- stream << " */" << std::endl;
- stream << "struct uscxml_elem_tascxml_result {" << std::endl;
- stream << " const char* verdict;" << std::endl;
- stream << " const char* timestamp;" << std::endl;
- stream << " const char* teststep;" << std::endl;
- stream << " const char* description;" << std::endl;
- stream << " const char* resultid;" << std::endl;
- stream << " const char* requirementid;" << std::endl;
- stream << " const char* currentvalue;" << std::endl;
- stream << "};" << std::endl;
- stream << std::endl;
-
- stream << "/**" << std::endl;
+ stream << " * All information pertaining to a <tascxml:result> element" << std::endl; + stream << " */" << std::endl; + stream << "struct uscxml_elem_tascxml_result {" << std::endl; + stream << " const char* verdict;" << std::endl; + stream << " const char* timestamp;" << std::endl; + stream << " const char* teststep;" << std::endl; + stream << " const char* description;" << std::endl; + stream << " const char* resultid;" << std::endl; + stream << " const char* requirementid;" << std::endl; + stream << " const char* currentvalue;" << std::endl; + stream << "};" << std::endl; + stream << std::endl; + + stream << "/**" << std::endl; + stream << " * All information pertaining to a <tascxml:set> element" << std::endl; + stream << " */" << std::endl; + stream << "struct uscxml_elem_tascxml_set {" << std::endl; + stream << " const char* dataid;" << std::endl; + stream << " const char* value;" << std::endl; + stream << "};" << std::endl; + stream << std::endl; + + stream << "/**" << std::endl; stream << " * Represents an instance of a state-chart at runtime/" << std::endl; stream << " */" << std::endl; stream << "struct uscxml_ctx {" << std::endl; @@ -1418,6 +1427,16 @@ void ChartToC::writeExecContent(std::ostream& stream, const DOMNode* node, size_ stream << padding << " return USCXML_ERR_MISSING_CALLBACK;" << std::endl; stream << padding << "}" << std::endl; + } else if(TAGNAME(elem) == "tascxml:set") { + stream << padding; + stream << "if likely(ctx->exec_content_tascxml_set != NULL) {" << std::endl; + stream << padding; + stream << " if ((ctx->exec_content_tascxml_set(ctx, &" << _prefix << "_elem_tascxml_sets[" << ATTR(elem, X("documentOrder")) << "]"; + stream << ")) != USCXML_ERR_OK) return err;" << std::endl; + stream << padding << "} else {" << std::endl; + stream << padding << " return USCXML_ERR_MISSING_CALLBACK;" << std::endl; + stream << padding << "}" << std::endl; + } else { LOGD(USCXML_VERBATIM) << "writeExecContent unsupported element: '" << TAGNAME(elem) << "'" << std::endl << *elem << std::endl; assert(false); @@ -1717,7 +1736,7 @@ void ChartToC::writeElementInfo(std::ostream& stream) { stream << "};" << std::endl; stream << std::endl; } -
+ std::list<DOMElement*> sends = DOMUtils::inDocumentOrder({ XML_PREFIX(_scxml).str() + "send" }, _scxml); if (sends.size() > 0) { _hasElement.insert("send"); @@ -1833,6 +1852,28 @@ void ChartToC::writeElementInfo(std::ostream& stream) { stream << std::endl; } + static const X kXMLCharDataId = X("dataid"); + static const X kXMLCharValue = X("value"); + std::list<DOMElement*> tascxmlsets = DOMUtils::inDocumentOrder({ "tascxml:set" }, _scxml); + if (tascxmlsets.size() > 0) { + _hasElement.insert("set"); + stream << "static const uscxml_elem_tascxml_set " << _prefix << "_elem_tascxml_sets[" << tascxmlsets.size() << "] = {" << std::endl; + size_t i = 0; + for (auto iter = tascxmlsets.begin(); iter != tascxmlsets.end(); iter++, i++) { + DOMElement* tascxmlset = *iter; + stream << " { "; + stream << std::endl << " /* dataid */ "; + stream << (HAS_ATTR(tascxmlset, kXMLCharDataId) ? "\"" + escape(ATTR(tascxmlset, kXMLCharDataId)) + "\"" : "NULL") << ", "; + stream << std::endl << " /* value */ "; + stream << (HAS_ATTR(tascxmlset, kXMLCharValue) ? "\"" + escape(ATTR(tascxmlset, kXMLCharValue)) + "\"" : "NULL"); + + stream << std::endl << " }" << (i + 1 < tascxmlsets.size() ? ",": "") << std::endl; + tascxmlset->setAttribute(X("documentOrder"), X(toStr(i))); + } + stream << "};" << std::endl; + stream << std::endl; + } + std::list<DOMElement*> donedatas = DOMUtils::inDocumentOrder({ XML_PREFIX(_scxml).str() + "donedata" }, _scxml); stream << "static const uscxml_elem_donedata " << _prefix << "_elem_donedatas[" << donedatas.size() + 1 << "] = {" << std::endl; stream << " /* source, content, contentexpr, params */" << std::endl; |