summaryrefslogtreecommitdiffstats
path: root/src/uscxml/transform
diff options
context:
space:
mode:
authorrlm <rlm@techsat.com>2019-10-14 20:35:03 (GMT)
committerrlm <rlm@techsat.com>2019-10-14 20:35:03 (GMT)
commitd152ddd1a0b3307520eb417f4193eb542db52c22 (patch)
tree8dc694062266e2005d5d4071fa84ac5beb1682d2 /src/uscxml/transform
parentaaff09b1bb94f5353337e0aa9ce8cbd50afb0aec (diff)
downloaduscxml-d152ddd1a0b3307520eb417f4193eb542db52c22.zip
uscxml-d152ddd1a0b3307520eb417f4193eb542db52c22.tar.gz
uscxml-d152ddd1a0b3307520eb417f4193eb542db52c22.tar.bz2
:Jira: ADSVHTNG-1056 - tascxml get action definition and implementation in transformerrefs/changes/53/8953/1
Change-Id: I0a31c35a98e6503ed9d6ce37a1a1961a3893be44
Diffstat (limited to 'src/uscxml/transform')
-rwxr-xr-xsrc/uscxml/transform/ChartToC.cpp154
1 files changed, 94 insertions, 60 deletions
diff --git a/src/uscxml/transform/ChartToC.cpp b/src/uscxml/transform/ChartToC.cpp
index 979103a..710260f 100755
--- a/src/uscxml/transform/ChartToC.cpp
+++ b/src/uscxml/transform/ChartToC.cpp
@@ -712,8 +712,11 @@ 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_set uscxml_elem_tascxml_set;" << std::endl;
+ stream << std::endl;
+
+ stream << "typedef struct uscxml_elem_taresult uscxml_elem_taresult;" << std::endl;
+ stream << "typedef struct uscxml_elem_taset uscxml_elem_taset;" << std::endl;
+ stream << "typedef struct uscxml_elem_taget uscxml_elem_taget;" << std::endl;
stream << std::endl;
stream << "typedef void* (*dequeue_internal_t)(const uscxml_ctx* ctx);" << std::endl;
@@ -737,8 +740,11 @@ 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 << "typedef int (*exec_content_tascxml_set_t)(const uscxml_ctx* ctx, const uscxml_elem_tascxml_set* set);" << std::endl;
+ stream << std::endl;
+
+ stream << "typedef int (*exec_content_taresult_t)(const uscxml_ctx* ctx, const uscxml_elem_taresult* taresult);" << std::endl;
+ 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 << std::endl;
stream << "/**" << std::endl;
@@ -893,7 +899,7 @@ void ChartToC::writeTypes(std::ostream& stream) {
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 << "struct uscxml_elem_taresult {" << std::endl;
stream << " const char* verdict;" << std::endl;
stream << " const char* timestamp;" << std::endl;
stream << " const char* teststep;" << std::endl;
@@ -907,13 +913,21 @@ void ChartToC::writeTypes(std::ostream& stream) {
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 << "struct uscxml_elem_taset {" << std::endl;
stream << " const char* dataid;" << std::endl;
stream << " const char* value;" << std::endl;
stream << "};" << std::endl;
stream << std::endl;
stream << "/**" << std::endl;
+ stream << " * All information pertaining to a <tascxml:get> element" << std::endl;
+ stream << " */" << std::endl;
+ stream << "struct uscxml_elem_taget {" << std::endl;
+ stream << " const char* dataid;" << 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;
@@ -934,18 +948,20 @@ 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_tascxml_result_t exec_content_tascxml_result;" << std::endl;
- stream << " exec_content_tascxml_set_t exec_content_tascxml_set;" << 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 << 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 << std::endl;
stream << " invoke_t invoke;" << std::endl;
stream << "};" << std::endl;
@@ -1422,21 +1438,31 @@ 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") {
+ } else if(TAGNAME(elem) == tascxml::NS_PREFIX.str() + "result") {
+ stream << padding;
+ stream << "if likely(ctx->exec_content_taresult != NULL) {" << std::endl;
+ stream << padding;
+ stream << " if ((ctx->exec_content_taresult(ctx, &" << _prefix << "_elem_taresults[" << 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 if(TAGNAME(elem) == tascxml::NS_PREFIX.str() + "set") {
stream << padding;
- stream << "if likely(ctx->exec_content_tascxml_result != NULL) {" << std::endl;
+ stream << "if likely(ctx->exec_content_taset != NULL) {" << std::endl;
stream << padding;
- stream << " if ((ctx->exec_content_tascxml_result(ctx, &" << _prefix << "_elem_tascxml_results[" << ATTR(elem, X("documentOrder")) << "]";
+ stream << " if ((ctx->exec_content_taset(ctx, &" << _prefix << "_elem_tasets[" << 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 if(TAGNAME(elem) == "tascxml:set") {
+ } else if(TAGNAME(elem) == tascxml::NS_PREFIX.str() + "get") {
stream << padding;
- stream << "if likely(ctx->exec_content_tascxml_set != NULL) {" << std::endl;
+ stream << "if likely(ctx->exec_content_taget != NULL) {" << std::endl;
stream << padding;
- stream << " if ((ctx->exec_content_tascxml_set(ctx, &" << _prefix << "_elem_tascxml_sets[" << ATTR(elem, X("documentOrder")) << "]";
+ stream << " if ((ctx->exec_content_taget(ctx, &" << _prefix << "_elem_tagets[" << 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;
@@ -1605,7 +1631,7 @@ void ChartToC::writeElementInfo(std::ostream& stream) {
stream << (HAS_ATTR(foreach, kXMLCharArray) ? "\"" + escape(ATTR(foreach, kXMLCharArray)) + "\"" : "NULL") << ", ";
stream << (HAS_ATTR(foreach, kXMLCharItem) ? "\"" + escape(ATTR(foreach, kXMLCharItem)) + "\"" : "NULL") << ", ";
stream << (HAS_ATTR(foreach, kXMLCharIndex) ? "\"" + escape(ATTR(foreach, kXMLCharIndex)) + "\"" : "NULL");
- stream << " }" << (i + 1 < foreachs.size() ? ",": "") << std::endl;
+ stream << " }" << (i + 1 < foreachs.size() ? "," : "") << std::endl;
foreach->setAttribute(X("documentOrder"), X(toStr(i)));
}
stream << "};" << std::endl;
@@ -1617,11 +1643,9 @@ void ChartToC::writeElementInfo(std::ostream& stream) {
_hasElement.insert("assign");
stream << "static const uscxml_elem_assign " << _prefix << "_elem_assigns[" << assigns.size() << "] = {" << std::endl;
stream << " /* location, expr, content */" << std::endl;
-
size_t i = 0;
for (auto iter = assigns.begin(); iter != assigns.end(); iter++, i++) {
DOMElement* assign = *iter;
-
stream << " { ";
stream << (HAS_ATTR(assign, kXMLCharLocation) ? "\"" + escape(ATTR(assign, kXMLCharLocation)) + "\"" : "NULL") << ", ";
stream << (HAS_ATTR(assign, kXMLCharExpr) ? "\"" + escape(ATTR(assign, kXMLCharExpr)) + "\"" : "NULL") << ", ";
@@ -1635,14 +1659,11 @@ void ChartToC::writeElementInfo(std::ostream& stream) {
} else {
stream << "NULL";
}
- stream << " }," << std::endl;
-
+ stream << " }" << (i + 1 < assigns.size() ? "," : "") << std::endl;
assign->setAttribute(X("documentOrder"), X(toStr(i)));
}
-
stream << "};" << std::endl;
stream << std::endl;
-
}
std::list<DOMElement*> datas = DOMUtils::inDocumentOrder({ XML_PREFIX(_scxml).str() + "data" }, _scxml);
@@ -1714,6 +1735,7 @@ void ChartToC::writeElementInfo(std::ostream& stream) {
distinctParents++;
}
}
+
parent = NULL;
stream << "static const uscxml_elem_param " << _prefix << "_elem_params[" << params.size() + distinctParents << "] = {" << std::endl;
@@ -1735,7 +1757,6 @@ void ChartToC::writeElementInfo(std::ostream& stream) {
stream << (HAS_ATTR(param, kXMLCharExpr) ? "\"" + escape(ATTR(param, kXMLCharExpr)) + "\"" : "NULL") << ", ";
stream << (HAS_ATTR(param, kXMLCharLocation) ? "\"" + escape(ATTR(param, kXMLCharLocation)) + "\"" : "NULL");
stream << " }," << std::endl;
-
}
stream << " { NULL, NULL, NULL }" << std::endl;
stream << "};" << std::endl;
@@ -1805,7 +1826,6 @@ void ChartToC::writeElementInfo(std::ostream& stream) {
stream << "NULL,";
}
-
stream << std::endl << " /* params */ ";
if (HAS_ATTR(send, X("paramIndex"))) {
stream << "&" << _prefix << "_elem_params[" << escape(ATTR(send, X("paramIndex"))) << "] ";
@@ -1813,58 +1833,72 @@ void ChartToC::writeElementInfo(std::ostream& stream) {
stream << "NULL ";
}
- stream << std::endl << " }" << (i + 1 < sends.size() ? ",": "") << std::endl;
+ stream << std::endl << " }" << (i + 1 < sends.size() ? "," : "") << std::endl;
send->setAttribute(X("documentOrder"), X(toStr(i)));
}
stream << "};" << std::endl;
stream << std::endl;
}
- std::list<DOMElement*> tascxmlresults = DOMUtils::inDocumentOrder({ "tascxml:result" }, _scxml);
- if (tascxmlresults.size() > 0) {
+ std::list<DOMElement*> taresults = DOMUtils::inDocumentOrder({ tascxml::NS_PREFIX.str() + "result" }, _scxml);
+ if (taresults.size() > 0) {
_hasElement.insert("result");
- stream << "static const uscxml_elem_tascxml_result " << _prefix << "_elem_tascxml_results[" << tascxmlresults.size() << "] = {" << std::endl;
+ stream << "static const uscxml_elem_taresult " << _prefix << "_elem_taresults[" << taresults.size() << "] = {" << std::endl;
size_t i = 0;
- for (auto iter = tascxmlresults.begin(); iter != tascxmlresults.end(); iter++, i++) {
- DOMElement* tascxmlresult = *iter;
+ for (auto iter = taresults.begin(); iter != taresults.end(); iter++, i++) {
+ DOMElement* taresult = *iter;
stream << " { ";
stream << std::endl << " /* verdict */ ";
- stream << (HAS_ATTR(tascxmlresult, tascxml::kXMLCharVerdict) ? "\"" + escape(ATTR(tascxmlresult, tascxml::kXMLCharVerdict)) + "\"" : "NULL") << ", ";
+ stream << (HAS_ATTR(taresult, tascxml::kXMLCharVerdict) ? "\"" + escape(ATTR(taresult, tascxml::kXMLCharVerdict)) + "\"" : "NULL") << ", ";
stream << std::endl << " /* timestamp */ ";
- stream << (HAS_ATTR(tascxmlresult, tascxml::kXMLCharTimestamp) ? "\"" + escape(ATTR(tascxmlresult, tascxml::kXMLCharTimestamp)) + "\"" : "NULL") << ", ";
+ stream << (HAS_ATTR(taresult, tascxml::kXMLCharTimestamp) ? "\"" + escape(ATTR(taresult, tascxml::kXMLCharTimestamp)) + "\"" : "NULL") << ", ";
stream << std::endl << " /* teststep */ ";
- stream << (HAS_ATTR(tascxmlresult, tascxml::kXMLCharTestStep) ? "\"" + escape(ATTR(tascxmlresult, tascxml::kXMLCharTestStep)) + "\"" : "NULL") << ", ";
+ stream << (HAS_ATTR(taresult, tascxml::kXMLCharTestStep) ? "\"" + escape(ATTR(taresult, tascxml::kXMLCharTestStep)) + "\"" : "NULL") << ", ";
stream << std::endl << " /* description */ ";
- stream << (HAS_ATTR(tascxmlresult, tascxml::kXMLCharDescription) ? "\"" + escape(ATTR(tascxmlresult, tascxml::kXMLCharDescription)) + "\"" : "NULL") << ", ";
+ stream << (HAS_ATTR(taresult, tascxml::kXMLCharDescription) ? "\"" + escape(ATTR(taresult, tascxml::kXMLCharDescription)) + "\"" : "NULL") << ", ";
stream << std::endl << " /* resultid */ ";
- stream << (HAS_ATTR(tascxmlresult, tascxml::kXMLCharResultId) ? "\"" + escape(ATTR(tascxmlresult, tascxml::kXMLCharResultId)) + "\"" : "NULL") << ", ";
+ stream << (HAS_ATTR(taresult, tascxml::kXMLCharResultId) ? "\"" + escape(ATTR(taresult, tascxml::kXMLCharResultId)) + "\"" : "NULL") << ", ";
stream << std::endl << " /* requirementid */ ";
- stream << (HAS_ATTR(tascxmlresult, tascxml::kXMLChaRequirementId) ? "\"" + escape(ATTR(tascxmlresult, tascxml::kXMLChaRequirementId)) + "\"" : "NULL") << ", ";
+ stream << (HAS_ATTR(taresult, tascxml::kXMLChaRequirementId) ? "\"" + escape(ATTR(taresult, tascxml::kXMLChaRequirementId)) + "\"" : "NULL") << ", ";
stream << std::endl << " /* currentvalue */ ";
- stream << (HAS_ATTR(tascxmlresult, tascxml::kXMLCharCurrentVaue) ? "\"" + escape(ATTR(tascxmlresult, tascxml::kXMLCharCurrentVaue)) + "\"" : "NULL");
-
- stream << std::endl << " }" << (i + 1 < tascxmlresults.size() ? ",": "") << std::endl;
- tascxmlresult->setAttribute(X("documentOrder"), X(toStr(i)));
+ stream << (HAS_ATTR(taresult, tascxml::kXMLCharCurrentVaue) ? "\"" + escape(ATTR(taresult, tascxml::kXMLCharCurrentVaue)) + "\"" : "NULL");
+ stream << std::endl << " }" << (i + 1 < taresults.size() ? "," : "") << std::endl;
+ taresult->setAttribute(X("documentOrder"), X(toStr(i)));
}
stream << "};" << std::endl;
stream << std::endl;
}
- std::list<DOMElement*> tascxmlsets = DOMUtils::inDocumentOrder({ "tascxml:set" }, _scxml);
- if (tascxmlsets.size() > 0) {
+ std::list<DOMElement*> tasets = DOMUtils::inDocumentOrder({ tascxml::NS_PREFIX.str() + "set" }, _scxml);
+ if (tasets.size() > 0) {
_hasElement.insert("set");
- stream << "static const uscxml_elem_tascxml_set " << _prefix << "_elem_tascxml_sets[" << tascxmlsets.size() << "] = {" << std::endl;
+ stream << "static const uscxml_elem_taset " << _prefix << "_elem_tasets[" << tasets.size() << "] = {" << std::endl;
+ stream << " /* dataid, value */" << std::endl;
size_t i = 0;
- for (auto iter = tascxmlsets.begin(); iter != tascxmlsets.end(); iter++, i++) {
- DOMElement* tascxmlset = *iter;
+ for (auto iter = tasets.begin(); iter != tasets.end(); iter++, i++) {
+ DOMElement* taset = *iter;
stream << " { ";
- stream << std::endl << " /* dataid */ ";
- stream << (HAS_ATTR(tascxmlset, tascxml::kXMLCharDataId) ? "\"" + escape(ATTR(tascxmlset, tascxml::kXMLCharDataId)) + "\"" : "NULL") << ", ";
- stream << std::endl << " /* value */ ";
- stream << (HAS_ATTR(tascxmlset, tascxml::kXMLCharValue) ? "\"" + escape(ATTR(tascxmlset, tascxml::kXMLCharValue)) + "\"" : "NULL");
+ stream << (HAS_ATTR(taset, tascxml::kXMLCharDataId) ? "\"" + escape(ATTR(taset, tascxml::kXMLCharDataId)) + "\"" : "NULL") << ", ";
+ stream << (HAS_ATTR(taset, tascxml::kXMLCharValue) ? "\"" + escape(ATTR(taset, tascxml::kXMLCharValue)) + "\"" : "NULL");
+ stream << " }" << (i + 1 < tasets.size() ? "," : "") << std::endl;
+ taset->setAttribute(X("documentOrder"), X(toStr(i)));
+ }
+ stream << "};" << std::endl;
+ stream << std::endl;
+ }
- stream << std::endl << " }" << (i + 1 < tascxmlsets.size() ? ",": "") << std::endl;
- tascxmlset->setAttribute(X("documentOrder"), X(toStr(i)));
+ std::list<DOMElement*> tagets = DOMUtils::inDocumentOrder({ tascxml::NS_PREFIX.str() + "get" }, _scxml);
+ if (tagets.size() > 0) {
+ _hasElement.insert("get");
+ stream << "static const uscxml_elem_taget " << _prefix << "_elem_tagets[" << tagets.size() << "] = {" << std::endl;
+ stream << " /* dataid */" << std::endl;
+ size_t i = 0;
+ for (auto iter = tagets.begin(); iter != tagets.end(); iter++, i++) {
+ DOMElement* taget = *iter;
+ stream << " { ";
+ stream << (HAS_ATTR(taget, tascxml::kXMLCharDataId) ? "\"" + escape(ATTR(taget, tascxml::kXMLCharDataId)) + "\"" : "NULL");
+ stream << " }" << (i + 1 < tagets.size() ? "," : "") << std::endl;
+ taget->setAttribute(X("documentOrder"), X(toStr(i)));
}
stream << "};" << std::endl;
stream << std::endl;