summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xsrc/uscxml/transform/ChartToC.cpp48
-rw-r--r--src/uscxml/util/TASCXMLUtils.h2
2 files changed, 46 insertions, 4 deletions
diff --git a/src/uscxml/transform/ChartToC.cpp b/src/uscxml/transform/ChartToC.cpp
index a254f09..2f4ac1d 100755
--- a/src/uscxml/transform/ChartToC.cpp
+++ b/src/uscxml/transform/ChartToC.cpp
@@ -718,6 +718,7 @@ void ChartToC::writeTypes(std::ostream& stream) {
stream << "typedef struct uscxml_elem_taset uscxml_elem_taset;" << std::endl;
stream << "typedef struct uscxml_elem_taget uscxml_elem_taget;" << std::endl;
stream << "typedef struct uscxml_elem_taramp uscxml_elem_taramp;" << std::endl;
+ stream << "typedef struct uscxml_elem_tainterrupt uscxml_elem_tainterrupt;" << std::endl;
stream << std::endl;
stream << "typedef void* (*dequeue_internal_t)(const uscxml_ctx* ctx);" << std::endl;
@@ -747,6 +748,7 @@ void ChartToC::writeTypes(std::ostream& stream) {
stream << "typedef int (*exec_content_taset_t)(const uscxml_ctx* ctx, const uscxml_elem_taset* taset);" << std::endl;
stream << "typedef int (*exec_content_taget_t)(const uscxml_ctx* ctx, const uscxml_elem_taget* taget);" << std::endl;
stream << "typedef int (*exec_content_taramp_t)(const uscxml_ctx* ctx, const uscxml_elem_taramp* taramp);" << std::endl;
+ stream << "typedef int (*exec_content_tainterrupt_t)(const uscxml_ctx* ctx, const uscxml_elem_tainterrupt* tainterrupt);" << std::endl;
stream << std::endl;
stream << "/**" << std::endl;
@@ -944,6 +946,15 @@ void ChartToC::writeTypes(std::ostream& stream) {
stream << std::endl;
stream << "/**" << std::endl;
+ stream << " * All information pertaining to a <tascxml:interrupt> element" << std::endl;
+ stream << " */" << std::endl;
+ stream << "struct uscxml_elem_tainterrupt {" << std::endl;
+ stream << " const char* id;" << std::endl;
+ stream << " const char* cmdid;" << 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;
@@ -975,10 +986,11 @@ void ChartToC::writeTypes(std::ostream& stream) {
stream << " exec_content_cancel_t exec_content_cancel;" << std::endl;
stream << " exec_content_script_t exec_content_script;" << std::endl;
stream << std::endl;
- stream << " exec_content_taresult_t exec_content_taresult;" << std::endl;
- stream << " exec_content_taset_t exec_content_taset;" << std::endl;
- stream << " exec_content_taget_t exec_content_taget;" << std::endl;
- stream << " exec_content_taramp_t exec_content_taramp;" << std::endl;
+ stream << " exec_content_taresult_t exec_content_taresult;" << std::endl;
+ stream << " exec_content_taset_t exec_content_taset;" << std::endl;
+ stream << " exec_content_taget_t exec_content_taget;" << std::endl;
+ stream << " exec_content_taramp_t exec_content_taramp;" << std::endl;
+ stream << " exec_content_tainterrupt_t exec_content_tainterrupt;" << std::endl;
stream << std::endl;
stream << " invoke_t invoke;" << std::endl;
stream << "};" << std::endl;
@@ -1495,6 +1507,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::NS_PREFIX.str() + "interrupt") {
+ stream << padding;
+ stream << "if likely(ctx->exec_content_tainterrupt != NULL) {" << std::endl;
+ stream << padding;
+ stream << " if ((ctx->exec_content_tainterrupt(ctx, &" << _prefix << "_elem_tainterrupts[" << 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);
@@ -1959,6 +1981,24 @@ void ChartToC::writeElementInfo(std::ostream& stream) {
stream << std::endl;
}
+ std::list<DOMElement*> tainterrupts = DOMUtils::inDocumentOrder({ tascxml::NS_PREFIX.str() + "interrupt" }, _scxml);
+ if (tainterrupts.size() > 0) {
+ _hasElement.insert("interrupt");
+ stream << "static const uscxml_elem_tainterrupt " << _prefix << "_elem_tainterrupts[" << tainterrupts.size() << "] = {" << std::endl;
+ stream << " /* id, cmdid */" << std::endl;
+ size_t i = 0;
+ for (auto iter = tainterrupts.begin(); iter != tainterrupts.end(); iter++, i++) {
+ DOMElement* tainterrupt = *iter;
+ stream << " { ";
+ stream << (HAS_ATTR(tainterrupt, tascxml::kXMLCharId) ? "\"" + escape(ATTR(tainterrupt, tascxml::kXMLCharId)) + "\"" : "NULL") << ", ";
+ stream << (HAS_ATTR(tainterrupt, tascxml::kXMLCharCmdId) ? "\"" + escape(ATTR(tainterrupt, tascxml::kXMLCharCmdId)) + "\"" : "NULL");
+ stream << " }" << (i + 1 < tainterrupts.size() ? "," : "") << std::endl;
+ tainterrupt->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;
diff --git a/src/uscxml/util/TASCXMLUtils.h b/src/uscxml/util/TASCXMLUtils.h
index 9e64876..613e837 100644
--- a/src/uscxml/util/TASCXMLUtils.h
+++ b/src/uscxml/util/TASCXMLUtils.h
@@ -28,6 +28,8 @@ namespace tascxml {
static const uscxml::X kXMLCharEndCond = uscxml::X("endcond");
static const uscxml::X kXMLCharDuration = uscxml::X("duration");
+ static const uscxml::X kXMLCharCmdId = uscxml::X("cmdid");
+
}
#endif