summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorrlm <rlm@techsat.com>2019-07-04 08:10:19 (GMT)
committerrlm <rlm@techsat.com>2019-07-04 08:10:19 (GMT)
commitf4cbdb0292c5505bed8c8b69c8a559596267eda5 (patch)
tree99df5d899e4b231afe051809a42c9e95be67e0c4 /src
parentee0a17cc63316edd83388a2f8f93b48cdcc6913c (diff)
downloaduscxml-f4cbdb0292c5505bed8c8b69c8a559596267eda5.zip
uscxml-f4cbdb0292c5505bed8c8b69c8a559596267eda5.tar.gz
uscxml-f4cbdb0292c5505bed8c8b69c8a559596267eda5.tar.bz2
implementation of tascxml:result action in c transformerrefs/changes/09/8109/1
Change-Id: Ic858e887d644d564a4e0a2c2b275732678649e49
Diffstat (limited to 'src')
-rwxr-xr-x[-rw-r--r--]src/uscxml/transform/ChartToC.cpp86
1 files changed, 75 insertions, 11 deletions
diff --git a/src/uscxml/transform/ChartToC.cpp b/src/uscxml/transform/ChartToC.cpp
index a52cf5e..08ea1a0 100644..100755
--- a/src/uscxml/transform/ChartToC.cpp
+++ b/src/uscxml/transform/ChartToC.cpp
@@ -710,6 +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 << std::endl;
stream << "typedef void* (*dequeue_internal_t)(const uscxml_ctx* ctx);" << std::endl;
@@ -733,6 +734,7 @@ void ChartToC::writeTypes(std::ostream& stream) {
stream << "typedef int (*exec_content_cancel_t)(const uscxml_ctx* ctx, const char* sendid, const char* sendidexpr);" << std::endl;
stream << "typedef int (*exec_content_finalize_t)(const uscxml_ctx* ctx, const uscxml_elem_invoke* invoker, const void* event);" << std::endl;
stream << "typedef int (*exec_content_script_t)(const uscxml_ctx* ctx, const char* src, const char* content);" << std::endl;
+ stream << "typedef int (*exec_content_tascxml_result_t)(const uscxml_ctx* ctx, const uscxml_elem_tascxml_result* result);" << std::endl;
stream << std::endl;
stream << "/**" << std::endl;
@@ -885,6 +887,20 @@ 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 << " * Represents an instance of a state-chart at runtime/" << std::endl;
stream << " */" << std::endl;
stream << "struct uscxml_ctx {" << std::endl;
@@ -905,16 +921,17 @@ void ChartToC::writeTypes(std::ostream& stream) {
stream << " is_true_t is_true;" << std::endl;
stream << " raise_done_event_t raise_done_event;" << std::endl;
stream << std::endl;
- stream << " exec_content_log_t exec_content_log;" << std::endl;
- stream << " exec_content_raise_t exec_content_raise;" << std::endl;
- stream << " exec_content_send_t exec_content_send;" << std::endl;
- stream << " exec_content_foreach_init_t exec_content_foreach_init;" << std::endl;
- stream << " exec_content_foreach_next_t exec_content_foreach_next;" << std::endl;
- stream << " exec_content_foreach_done_t exec_content_foreach_done;" << std::endl;
- stream << " exec_content_assign_t exec_content_assign;" << std::endl;
- stream << " exec_content_init_t exec_content_init;" << std::endl;
- stream << " exec_content_cancel_t exec_content_cancel;" << std::endl;
- stream << " exec_content_script_t exec_content_script;" << std::endl;
+ stream << " exec_content_log_t exec_content_log;" << std::endl;
+ stream << " exec_content_raise_t exec_content_raise;" << std::endl;
+ stream << " exec_content_send_t exec_content_send;" << std::endl;
+ stream << " exec_content_foreach_init_t exec_content_foreach_init;" << std::endl;
+ stream << " exec_content_foreach_next_t exec_content_foreach_next;" << std::endl;
+ stream << " exec_content_foreach_done_t exec_content_foreach_done;" << std::endl;
+ stream << " exec_content_assign_t exec_content_assign;" << std::endl;
+ stream << " exec_content_init_t exec_content_init;" << std::endl;
+ stream << " exec_content_cancel_t exec_content_cancel;" << std::endl;
+ stream << " exec_content_script_t exec_content_script;" << std::endl;
+ stream << " exec_content_tascxml_result_t exec_content_tascxml_result;" << std::endl;
stream << std::endl;
stream << " invoke_t invoke;" << std::endl;
stream << "};" << std::endl;
@@ -1391,6 +1408,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:result") {
+ stream << padding;
+ stream << "if likely(ctx->exec_content_tascxml_result != NULL) {" << std::endl;
+ stream << padding;
+ stream << " if ((ctx->exec_content_tascxml_result(ctx, &" << _prefix << "_elem_tascxml_results[" << 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);
@@ -1690,7 +1717,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");
@@ -1769,6 +1796,43 @@ void ChartToC::writeElementInfo(std::ostream& stream) {
stream << std::endl;
}
+ static const X kXMLCharVerdict = X("verdict");
+ static const X kXMLCharTimestamp = X("timestamp");
+ static const X kXMLCharTestStep = X("teststep");
+ static const X kXMLCharDescription = X("description");
+ static const X kXMLCharResultId = X("resultid");
+ static const X kXMLChaRequirementId = X("requirementid");
+ static const X kXMLCharCurrentVaue = X("currentvalue");
+ std::list<DOMElement*> tascxmlresults = DOMUtils::inDocumentOrder({ "tascxml:result" }, _scxml);
+ if (tascxmlresults.size() > 0) {
+ _hasElement.insert("result");
+ stream << "static const uscxml_elem_tascxml_result " << _prefix << "_elem_tascxml_results[" << tascxmlresults.size() << "] = {" << std::endl;
+ size_t i = 0;
+ for (auto iter = tascxmlresults.begin(); iter != tascxmlresults.end(); iter++, i++) {
+ DOMElement* tascxmlresult = *iter;
+ stream << " { ";
+ stream << std::endl << " /* verdict */ ";
+ stream << (HAS_ATTR(tascxmlresult, kXMLCharVerdict) ? "\"" + escape(ATTR(tascxmlresult, kXMLCharVerdict)) + "\"" : "NULL") << ", ";
+ stream << std::endl << " /* timestamp */ ";
+ stream << (HAS_ATTR(tascxmlresult, kXMLCharTimestamp) ? "\"" + escape(ATTR(tascxmlresult, kXMLCharTimestamp)) + "\"" : "NULL") << ", ";
+ stream << std::endl << " /* teststep */ ";
+ stream << (HAS_ATTR(tascxmlresult, kXMLCharTestStep) ? "\"" + escape(ATTR(tascxmlresult, kXMLCharTestStep)) + "\"" : "NULL") << ", ";
+ stream << std::endl << " /* description */ ";
+ stream << (HAS_ATTR(tascxmlresult, kXMLCharDescription) ? "\"" + escape(ATTR(tascxmlresult, kXMLCharDescription)) + "\"" : "NULL") << ", ";
+ stream << std::endl << " /* resultid */ ";
+ stream << (HAS_ATTR(tascxmlresult, kXMLCharResultId) ? "\"" + escape(ATTR(tascxmlresult, kXMLCharResultId)) + "\"" : "NULL") << ", ";
+ stream << std::endl << " /* requirementid */ ";
+ stream << (HAS_ATTR(tascxmlresult, kXMLChaRequirementId) ? "\"" + escape(ATTR(tascxmlresult, kXMLChaRequirementId)) + "\"" : "NULL") << ", ";
+ stream << std::endl << " /* currentvalue */ ";
+ stream << (HAS_ATTR(tascxmlresult, kXMLCharCurrentVaue) ? "\"" + escape(ATTR(tascxmlresult, kXMLCharCurrentVaue)) + "\"" : "NULL");
+
+ stream << std::endl << " }" << (i + 1 < tascxmlresults.size() ? ",": "") << std::endl;
+ tascxmlresult->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;