From af6ec49c899ce26a0e07761b0e42200248808e21 Mon Sep 17 00:00:00 2001 From: Stefan Radomski Date: Thu, 28 Apr 2016 09:18:24 +0200 Subject: Implemented empty finalize (Spec 6.5.2) --- src/uscxml/Interpreter.cpp | 25 ++++++++++++++++++++++++- test/src/issues/test-issue67.scxml | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 test/src/issues/test-issue67.scxml diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp index 12f1c32..596bf20 100644 --- a/src/uscxml/Interpreter.cpp +++ b/src/uscxml/Interpreter.cpp @@ -2695,7 +2695,30 @@ void InterpreterImpl::finalizeAndAutoForwardCurrentEvent() { Arabica::XPath::NodeSet finalizes = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "finalize", invokeIter->second.getElement()); for (size_t k = 0; k < finalizes.size(); k++) { Element finalizeElem = Element(finalizes[k]); - executeContent(finalizeElem); + + bool hasChildElems = false; + Node child = finalizeElem.getFirstChild(); + while(child) { + if (child.getNodeType() == Node_base::ELEMENT_NODE) { + hasChildElems = true; + break; + } + child = child.getNextSibling(); + } + + if (hasChildElems) { + executeContent(finalizeElem); + } else { + // Specification 6.5.2: http://www.w3.org/TR/scxml/#N110EF + if (HAS_ATTR(invokeIter->second.getElement(), "namelist")) { + std::list names = tokenize(ATTR(invokeIter->second.getElement(), "namelist")); + for (std::list::iterator nameIter = names.begin(); nameIter != names.end(); nameIter++) { + if (_currEvent.data.compound.find(*nameIter) != _currEvent.data.compound.end()) { + _dataModel.assign(*nameIter, _currEvent.data.compound[*nameIter]); + } + } + } + } } } if (HAS_ATTR(invokeIter->second.getElement(), "autoforward") && stringIsTrue(ATTR(invokeIter->second.getElement(), "autoforward"))) { diff --git a/test/src/issues/test-issue67.scxml b/test/src/issues/test-issue67.scxml new file mode 100644 index 0000000..e1fc5fa --- /dev/null +++ b/test/src/issues/test-issue67.scxml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v0.12