diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-07-23 20:34:15 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-07-23 20:34:15 (GMT) |
commit | afbd0c4463c6f28ec1cd6ea45a68fdbcfcfeae6c (patch) | |
tree | 5cfa0f6db2af351c730c230a6d665b51d33cb0c7 | |
parent | dc5f5ddfa10bf91524e6f7555c263eaea069dcb0 (diff) | |
download | uscxml-afbd0c4463c6f28ec1cd6ea45a68fdbcfcfeae6c.zip uscxml-afbd0c4463c6f28ec1cd6ea45a68fdbcfcfeae6c.tar.gz uscxml-afbd0c4463c6f28ec1cd6ea45a68fdbcfcfeae6c.tar.bz2 |
More work on lua datamodel
47 files changed, 213 insertions, 880 deletions
@@ -33,8 +33,9 @@ even in C# and Java. It runs on <b>Linux</b>, <b>Windows</b> and <b>Mac OSX</b>, * Support for binary data via [TypedArrays](https://www.khronos.org/registry/typedarray/specs/latest/) (will not throw exceptions yet) * Full [NULL datamodel](https://github.com/tklab-tud/uscxml/tree/master/src/uscxml/plugins/datamodel/null) with required <tt>In</tt> predicate * [Prolog datamodel](https://github.com/tklab-tud/uscxml/tree/master/src/uscxml/plugins/datamodel/prolog/swi) using SWI prolog - * Early [Promela datamodel](https://github.com/tklab-tud/uscxml/tree/master/src/uscxml/plugins/datamodel/promela) for use + * Experimental [Promela datamodel](https://github.com/tklab-tud/uscxml/tree/master/src/uscxml/plugins/datamodel/promela) for use with the [SPIN](http://spinroot.com/spin/whatispin.html) model-checker + * Early support for a [Lua datamodel](https://github.com/tklab-tud/uscxml/tree/master/src/uscxml/plugins/datamodel/lua) * Rudimentary support for [XPath datamodel](https://github.com/tklab-tud/uscxml/tree/master/src/uscxml/plugins/datamodel/xpath) * <b>Invokers</b> * <tt>scxml</tt>: Invoke a nested scxml interpreter @@ -68,10 +69,12 @@ uSCXML still fails the following ecmascript tests: <tr><th>Test#</th><th>Status</th><th>Description</th><th>Comment</th></tr> <tr> <td> - <tt><a href="https://github.com/tklab-tud/uscxml/blob/master/test/w3c/ecma/test326.scxml">326</a></tt> / - <tt><a href="https://github.com/tklab-tud/uscxml/blob/master/test/w3c/ecma/test326.scxml">329</a></tt> + <tt> + <a href="https://github.com/tklab-tud/uscxml/blob/master/test/w3c/ecma/test326.scxml">326</a> / + <a href="https://github.com/tklab-tud/uscxml/blob/master/test/w3c/ecma/test326.scxml">329</a> + </tt> </td> - <td><tt>Failed for v8</tt></td> + <td><tt>Fail for v8</tt></td> <td>"test that _ioprocessors stays bound till the session ends" / "test that none of the system variables can be modified"</td> <td>The v8 implementation will return a new <tt>_ioprocessor</tt> object for each access.</td> </tr> diff --git a/apps/uscxml-dot.cpp b/apps/uscxml-dot.cpp index 56f5c57..2b230b4 100644 --- a/apps/uscxml-dot.cpp +++ b/apps/uscxml-dot.cpp @@ -3,6 +3,7 @@ #include "uscxml/DOMUtils.h" #include "uscxml/debug/SCXMLDotWriter.h" #include <glog/logging.h> +#include "getopt.h" #include "uscxml/Factory.h" #include <boost/algorithm/string.hpp> @@ -67,7 +68,7 @@ int main(int argc, char** argv) { google::LogToStderr(); google::InitGoogleLogging(argv[0]); - + if (argc < 2) printUsageAndExit(argv[0]); @@ -77,25 +78,30 @@ int main(int argc, char** argv) { int option; while ((option = getopt(argc, argv, "d:t:")) != -1) { switch(option) { - case 'd': currAnchor.childDepth = strTo<int32_t>(optarg); break; - case 't': currAnchor.transDepth = strTo<int32_t>(optarg); break; - case 'e': { - std::string edgeType(optarg); - if (edgeType == "target") { - currAnchor.type = SCXMLDotWriter::PORT_TARGET; - } else if (edgeType == "event") { - currAnchor.type = SCXMLDotWriter::PORT_EVENT; - } else if (edgeType == "transition") { - currAnchor.type = SCXMLDotWriter::PORT_TRANSITION; - } else { - printUsageAndExit(argv[0]); - } - break; + case 'd': + currAnchor.childDepth = strTo<int32_t>(optarg); + break; + case 't': + currAnchor.transDepth = strTo<int32_t>(optarg); + break; + case 'e': { + std::string edgeType(optarg); + if (edgeType == "target") { + currAnchor.type = SCXMLDotWriter::PORT_TARGET; + } else if (edgeType == "event") { + currAnchor.type = SCXMLDotWriter::PORT_EVENT; + } else if (edgeType == "transition") { + currAnchor.type = SCXMLDotWriter::PORT_TRANSITION; + } else { + printUsageAndExit(argv[0]); } - default: break; + break; + } + default: + break; } } - + if (currAnchor) stateAnchors.push_back(currAnchor); @@ -104,14 +110,19 @@ int main(int argc, char** argv) { URL inputFile(argv[optind]); Interpreter interpreter = Interpreter::fromURI(inputFile); optind++; - + while(optind < argc) { // are while ((option = getopt(argc, argv, "d:t:")) != -1) { switch(option) { - case 'd': currAnchor.childDepth = strTo<int32_t>(optarg); break; - case 't': currAnchor.transDepth = strTo<int32_t>(optarg); break; - default: break; + case 'd': + currAnchor.childDepth = strTo<int32_t>(optarg); + break; + case 't': + currAnchor.transDepth = strTo<int32_t>(optarg); + break; + default: + break; } } if (argc > optind) { @@ -120,14 +131,14 @@ int main(int argc, char** argv) { } else { printUsageAndExit(argv[0]); } - + if (currAnchor) { stateAnchors.push_back(currAnchor); } - + currAnchor = SCXMLDotWriter::StateAnchor(); } - + std::string outName = inputFile.file() + ".dot"; SCXMLDotWriter::toDot(outName, interpreter, stateAnchors); diff --git a/docs/BUILDING.md b/docs/BUILDING.md index 95582ed..4a16aad 100644 --- a/docs/BUILDING.md +++ b/docs/BUILDING.md @@ -15,6 +15,7 @@ - [Java](#java) - [CSharp](#csharp) - [Important Note for Windows](#important-note-for-windows) +- [Optional Functionality](#optional-functionality) - [About 32/64Bit Support](#about-3264bit-support) <!-- END doctoc generated TOC please keep comment here to allow auto update --> @@ -394,6 +395,26 @@ Command Prompt (2010)</tt> and type: > nmake && nmake csharp && nmake java ... +## Optional Functionality + +At configure time, CMake will search for various libraries and conditionally compile only the part of uSCXML for +which libraries have been found. On unices, it is straight forward to add libraries and - if you installed them to +their default location - CMake will usually pick them up. On Windows, however, the process is more complicated. +While we try to search in the locations where the various installers saved the header files and libraries, there are +some of distributed only as an archive. + +If you want to give CMake the best chance of picking up these libraries, put them into the <emph>platform prebuilt path</emph>. +This path is located in <tt><USCXML_SRC>/contrib/prebuilt/<PLATFORM>/<COMPILER></tt>. For Windows 32bit, +with MSVC this path is <tt><USCXML_SRC>/contrib/prebuilt/windows-x86/msvc</tt>. + +For instance, in order to enable the <tt>lua</tt> datamodel on windows, download the static lua libraries and save +the dll in <tt><PREBUILT>/lib/lua52.lib</tt> and the header files directly in <tt><PREBUILT>/include/</tt>. +When you run CMake for the first time, it will automatically create these paths for you. + +<b>Note:</b> Actually, we would have to differentiate the various MSVC versions as well: v16 (VS2010) and v18 (VS2012/13) +employ a different application binary interface (ABI). This is approach is taken e.g. in uMundo with <tt>msvc16</tt> +vs <tt>msvc18</tt>, but not yet realized for uSCXML. + ## About 32/64Bit Support We do support both, 32 and 64Bit for Linux and Windows. On Macintosh, most prebuilt dependencies are compiled as diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp index 5a1df44..8767242 100644 --- a/src/uscxml/Interpreter.cpp +++ b/src/uscxml/Interpreter.cpp @@ -2347,7 +2347,7 @@ bool InterpreterImpl::isInitial(const Arabica::DOM::Element<std::string>& state) if (isParallel(parent)) return true; - + return false; } diff --git a/src/uscxml/UUID.cpp b/src/uscxml/UUID.cpp index b56b727..ae103ed 100644 --- a/src/uscxml/UUID.cpp +++ b/src/uscxml/UUID.cpp @@ -34,31 +34,31 @@ std::string UUID::getUUID() { bool UUID::isUUID(const std::string& uuid) { if (uuid.size() != 36) return false; - + if (uuid[8] != '-' || uuid[13] != '-' || uuid[18] != '-' || uuid[23] != '-') return false; - + for (int i = 0; i < 36; i++) { if (i == 8 || i == 13 || i == 18 || i ==23) continue; - + char c = uuid[i]; if (c == 'a' || - c == 'b' || - c == 'c' || - c == 'd' || - c == 'e' || - c == 'f' || - c == '0' || - c == '1' || - c == '2' || - c == '3' || - c == '4' || - c == '5' || - c == '6' || - c == '7' || - c == '8' || - c == '9') { + c == 'b' || + c == 'c' || + c == 'd' || + c == 'e' || + c == 'f' || + c == '0' || + c == '1' || + c == '2' || + c == '3' || + c == '4' || + c == '5' || + c == '6' || + c == '7' || + c == '8' || + c == '9') { continue; } else { return false; diff --git a/src/uscxml/debug/SCXMLDotWriter.cpp b/src/uscxml/debug/SCXMLDotWriter.cpp index 88db575..16269a9 100644 --- a/src/uscxml/debug/SCXMLDotWriter.cpp +++ b/src/uscxml/debug/SCXMLDotWriter.cpp @@ -28,7 +28,7 @@ namespace uscxml { using namespace Arabica::DOM; using namespace Arabica::XPath; - + SCXMLDotWriter::SCXMLDotWriter() { _iteration = 0; _indentation = 0; @@ -56,7 +56,7 @@ SCXMLDotWriter::SCXMLDotWriter(Interpreter interpreter, anchIter->element = _scxml; if (anchIter->childDepth >= 0 && anchIter->transDepth == -1) anchIter->transDepth = anchIter->childDepth; - + _portType = anchIter->type; assembleGraph(anchIter->element, anchIter->childDepth, anchIter->transDepth + 1); } @@ -121,7 +121,7 @@ void SCXMLDotWriter::writeTo(std::ostream& os) { if (_histories.find(edgeIter->to)->second.from == _histories.find(edgeIter->to)->second.to) continue; } - + os << getPrefix() << "\"" << edgeIter->from << "\""; if (edgeIter->fromPort.size() > 0) { os << std::string(":\"") + edgeIter->fromPort + "\":e"; @@ -129,7 +129,7 @@ void SCXMLDotWriter::writeTo(std::ostream& os) { os << ":__name"; } os << " -> "; - + if (_histories.find(edgeIter->to) != _histories.end()) { os << getPrefix() << "\"" << _histories.find(edgeIter->to)->second.to << "\""; if (_histories.find(edgeIter->to)->second.toPort.size() > 0) { @@ -153,11 +153,11 @@ void SCXMLDotWriter::writeTo(std::ostream& os) { os << " [color=\"black\"]"; } os << std::endl; - + } - + _indentation--; - + os << "}" << std::endl; } @@ -191,7 +191,7 @@ void SCXMLDotWriter::assembleGraph(const Element<std::string>& state, int32_t ch _graph[nodeId].node = state; _graph[nodeId].portType = _portType; - + if (childDepth == 0 && transDepth == 0) { _graph[nodeId].isBorder = true; } @@ -250,7 +250,7 @@ void SCXMLDotWriter::assembleGraph(const Element<std::string>& state, int32_t ch } } - + /** * Walk the complete graph and draw reachable subset */ @@ -263,11 +263,11 @@ void SCXMLDotWriter::writeStateElement(std::ostream& os, const Element<std::stri std::list<Node<std::string> > invisParents; bool isVisible = (_graph.find(stateId) != _graph.end()); - + bool subgraph = InterpreterImpl::isCompound(stateElem) || InterpreterImpl::isParallel(stateElem); bool fatherIsParallel = (stateElem.getParentNode() && - stateElem.getParentNode().getNodeType() == Node_base::ELEMENT_NODE && - InterpreterImpl::isParallel(Element<std::string>(stateElem.getParentNode()))); + stateElem.getParentNode().getNodeType() == Node_base::ELEMENT_NODE && + InterpreterImpl::isParallel(Element<std::string>(stateElem.getParentNode()))); if (subgraph) { _indentation++; @@ -282,13 +282,13 @@ void SCXMLDotWriter::writeStateElement(std::ostream& os, const Element<std::stri os << getPrefix() << (fatherIsParallel ? "style=dashed" : "style=solid") << std::endl; // os << getPrefix() << "ranksep=\"equally\"" << std::endl; - + } if (isVisible) { // this state is visible! const DotState& dotState = _graph.find(stateId)->second; - + // is this a subgraph? os << std::endl; @@ -321,32 +321,32 @@ void SCXMLDotWriter::writeStateElement(std::ostream& os, const Element<std::stri // is the state initial? bool isInitial = _interpreter.getImpl()->isInitial(stateElem); - // if (isInitial) - // os << getPrefix() << "style=filled, fillcolor=lightgrey, " << std::endl; + // if (isInitial) + // os << getPrefix() << "style=filled, fillcolor=lightgrey, " << std::endl; DotState::mmap_s_e_t::const_iterator destIterF, destIterB; std::list<std::string> outPorts; // count unique keys switch (dotState.portType) { - case PORT_TARGET: // outports are per target - for(DotState::mmap_s_e_t::const_iterator it = dotState.targets.begin(), end = dotState.targets.end(); - it != end; - it = dotState.targets.upper_bound(it->first)) { - outPorts.push_back(it->first); - } - break; - case PORT_EVENT: // outports are per event - for(DotState::mmap_s_e_t::const_iterator it = dotState.events.begin(), end = dotState.events.end(); - it != end; - it = dotState.events.upper_bound(it->first)) { - outPorts.push_back(it->first); - } - break; - case PORT_TRANSITION: - for (int i = 0; i < dotState.transitions.size(); i++) { - outPorts.push_back(idForNode(dotState.transitions[i])); - } - break; + case PORT_TARGET: // outports are per target + for(DotState::mmap_s_e_t::const_iterator it = dotState.targets.begin(), end = dotState.targets.end(); + it != end; + it = dotState.targets.upper_bound(it->first)) { + outPorts.push_back(it->first); + } + break; + case PORT_EVENT: // outports are per event + for(DotState::mmap_s_e_t::const_iterator it = dotState.events.begin(), end = dotState.events.end(); + it != end; + it = dotState.events.upper_bound(it->first)) { + outPorts.push_back(it->first); + } + break; + case PORT_TRANSITION: + for (int i = 0; i < dotState.transitions.size(); i++) { + outPorts.push_back(idForNode(dotState.transitions[i])); + } + break; } os << getPrefix() << "label = < " << std::endl; @@ -366,17 +366,17 @@ void SCXMLDotWriter::writeStateElement(std::ostream& os, const Element<std::stri os << " <tr><td port=\"__name\" rowspan=\"" << outPorts.size() + 1 << "\"><b>" << nameForNode(stateElem) << "</b></td></tr>" << std::endl; switch (dotState.portType) { - case PORT_TARGET: // outports are per target - writePerTargetPorts(os, outPorts, dotState); - break; - case PORT_EVENT: // outports are per event - writePerEventPorts(os, outPorts, dotState); - break; - case PORT_TRANSITION: - writePerTransitionPorts(os, outPorts, dotState); - break; + case PORT_TARGET: // outports are per target + writePerTargetPorts(os, outPorts, dotState); + break; + case PORT_EVENT: // outports are per event + writePerEventPorts(os, outPorts, dotState); + break; + case PORT_TRANSITION: + writePerTransitionPorts(os, outPorts, dotState); + break; } - + // write details of the state if (details.size() > 0) { @@ -445,12 +445,12 @@ void SCXMLDotWriter::writePerTargetPorts(std::ostream& os, const std::list<std:: DotState::mmap_s_e_t::const_iterator destIterF, destIterB; for(std::list<std::string>::const_iterator nameIter = outPorts.begin(); nameIter != outPorts.end(); nameIter++) { - + // gather all events that activate the transition std::string portName = *nameIter; DotEdge edge(stateId, portName); edge.fromPort = portName; - + std::multimap<std::string, std::string> eventConds; // event to condition std::pair <DotState::mmap_s_e_t::const_iterator, DotState::mmap_s_e_t::const_iterator> targetKeyRange = dotState.targets.equal_range(portName); for (destIterB = targetKeyRange.first; destIterB != targetKeyRange.second; ++destIterB) { @@ -467,11 +467,11 @@ void SCXMLDotWriter::writePerTargetPorts(std::ostream& os, const std::list<std:: } if (_graph.find(portName) != _graph.end()) _edges.insert(edge); - + typedef std::multimap<std::string, std::string>::iterator condIter_t; std::stringstream outPortSS; outPortSS << "<b>" << portName << "</b><br align=\"right\" />"; - + std::string opener = "{"; std::string closer; std::string seperator; @@ -479,19 +479,19 @@ void SCXMLDotWriter::writePerTargetPorts(std::ostream& os, const std::list<std:: for(iterA = eventConds.begin(); iterA != eventConds.end(); iterA = iterB) { std::string eventName = iterA->first; bool hasCondition = false; - + std::pair <condIter_t, condIter_t> condRange = eventConds.equal_range(eventName); for (iterB = condRange.first; iterB != condRange.second; ++iterB) { hasCondition = true; } - + outPortSS << opener << seperator << eventName << (hasCondition ? "" : ""); seperator = ", "; opener = ""; closer = "}"; } outPortSS << closer; - + os << " <tr><td port=\"" << portEscape(portName) << "\" align=\"right\">" << outPortSS.str() << "</td></tr>" << std::endl; } @@ -582,7 +582,7 @@ std::string SCXMLDotWriter::getDetailedLabel(const Element<std::string>& elem, i if (HAS_ATTR(childElems.item(i), "event ")) details.name += "<br />event = " + ATTR(childElems.item(i), "event"); } - + // send --------- if (iequals(TAGNAME(childElems.item(i)), "send")) { if (HAS_ATTR(childElems.item(i), "id")) @@ -718,7 +718,7 @@ std::string SCXMLDotWriter::nameForNode(const Node<std::string>& node) { std::string elemName; if (node.getNodeType() == Node_base::ELEMENT_NODE) { Element<std::string> elem = (Element<std::string>)node; - + if (false) { } else if (elem.getTagName() == "scxml") { if (elem.hasAttribute("name") && !UUID::isUUID(elem.getAttribute("name"))) { diff --git a/src/uscxml/debug/SCXMLDotWriter.h b/src/uscxml/debug/SCXMLDotWriter.h index 79ea6c1..3ac697f 100644 --- a/src/uscxml/debug/SCXMLDotWriter.h +++ b/src/uscxml/debug/SCXMLDotWriter.h @@ -68,9 +68,9 @@ public: Arabica::DOM::Element<std::string> element; int32_t childDepth; int32_t transDepth; - + PortType type; - + operator bool() const { return childDepth != -1 || transDepth != -1 || element; } @@ -94,7 +94,7 @@ public: std::set<std::string> childs; std::set<std::string> initialchilds; - + typedef std::multimap<std::string, Arabica::DOM::Element<std::string> > mmap_s_e_t; }; @@ -108,7 +108,7 @@ public: DotEdge() : type(EDGE_TRANSIION) {} DotEdge(const std::string& from, const std::string& to) : type(EDGE_TRANSIION), from(from), to(to) { } - + bool operator< (const DotEdge& other) const { return from + fromPort + to + toPort > other.from + other.fromPort + other.to + other.toPort; } @@ -121,7 +121,7 @@ public: std::string toPort; std::string toCompass; }; - + SCXMLDotWriter(); ~SCXMLDotWriter(); @@ -162,14 +162,14 @@ protected: const Arabica::DOM::Element<std::string>& transition); void assembleGraph(const Arabica::DOM::Element<std::string>& start, - int32_t childDepth = std::numeric_limits<int32_t>::max(), - int32_t transDepth = std::numeric_limits<int32_t>::max()); + int32_t childDepth = std::numeric_limits<int32_t>::max(), + int32_t transDepth = std::numeric_limits<int32_t>::max()); void writeStateElement(std::ostream& os, const Arabica::DOM::Element<std::string>& state); - + void writePerTransitionPorts(std::ostream& os, const std::list<std::string>& outPorts, const DotState& dotState); void writePerEventPorts(std::ostream& os, const std::list<std::string>& outPorts, const DotState& dotState); void writePerTargetPorts(std::ostream& os, const std::list<std::string>& outPorts, const DotState& dotState); - + void writeUnknownNode(std::ostream& os, const std::string& targetId); int _iteration; @@ -179,7 +179,7 @@ protected: std::map<std::string, DotState> _graph; std::set<DotEdge> _edges; - + // these are only set in ephemeral instances per monitor call Arabica::DOM::Element<std::string> _transition; Arabica::DOM::Element<std::string> _scxml; @@ -187,7 +187,7 @@ protected: std::string _xmlNSPrefix; std::list<StateAnchor> _anchors; std::map<std::string, DotEdge> _histories; - + PortType _portType; }; diff --git a/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp b/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp index 84833fb..018a8c4 100644 --- a/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp +++ b/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp @@ -48,6 +48,10 @@ LuaDataModel::LuaDataModel() { _luaState = NULL; } +static int luaInspect(lua_State * l) { + return 0; +} + static int luaInFunction(lua_State * l) { luabridge::LuaRef ref = luabridge::getGlobal(l, "__interpreter"); InterpreterImpl* interpreter = ref.cast<InterpreterImpl*>(); @@ -151,6 +155,7 @@ static luabridge::LuaRef getDataAsLua(lua_State* _luaState, const Data& data) { luaData[compoundIter->first] = getDataAsLua(_luaState, compoundIter->second); compoundIter++; } + luaData["inspect"] = luaInspect; return luaData; } if (data.array.size() > 0) { @@ -161,6 +166,7 @@ static luabridge::LuaRef getDataAsLua(lua_State* _luaState, const Data& data) { luaData[index++] = getDataAsLua(_luaState, *arrayIter); arrayIter++; } + luaData["inspect"] = luaInspect; return luaData; } if (data.atom.size() > 0) { @@ -170,7 +176,15 @@ static luabridge::LuaRef getDataAsLua(lua_State* _luaState, const Data& data) { break; } case Data::INTERPRETED: { - luaData = data.atom; // not sure + if (isNumeric(data.atom.c_str(), 10)) { + if (data.atom.find(".") != std::string::npos) { + luaData = strTo<double>(data.atom); + } else { + luaData = strTo<long>(data.atom); + } + } else { + luaData = data.atom; + } } } return luaData; @@ -190,6 +204,7 @@ void LuaDataModel::setEvent(const Event& event) { luaEvent["content"] = event.content; luaEvent["invokeId"] = event.invokeid; luaEvent["sendId"] = event.sendid; + luaEvent["inspect"] = luaInspect; switch (event.eventType) { case Event::INTERNAL: @@ -214,7 +229,15 @@ void LuaDataModel::setEvent(const Event& event) { if (!json.empty()) { luaEvent["data"] = getDataAsLua(_luaState, json); } else { - luaEvent["data"] = InterpreterImpl::spaceNormalize(event.content); + // test179 + std::string trimmed = boost::trim_copy(event.content); + if ((boost::starts_with(trimmed, "'") && boost::ends_with(trimmed, "'")) || + (boost::starts_with(trimmed, "\"") && boost::ends_with(trimmed, "\""))) { + luaEvent["data"] = InterpreterImpl::spaceNormalize(event.content); + } else { + Data tmp(event.content, Data::INTERPRETED); + luaEvent["data"] = getDataAsLua(_luaState, tmp); + } } } else { // _event.data is KVP @@ -254,15 +277,11 @@ Data LuaDataModel::getStringAsData(const std::string& content) { trimmedExpr = "return(" + trimmedExpr + ");"; } - int preStack = lua_gettop(_luaState); - eval(Arabica::DOM::Element<std::string>(), trimmedExpr); - int postStack = lua_gettop(_luaState); - int retVals = postStack - preStack; + int retVals = luaEval(Arabica::DOM::Element<std::string>(), trimmedExpr); if (retVals == 1) { data = getLuaAsData(luabridge::LuaRef::fromStack(_luaState, -1)); } - postStack = lua_gettop(_luaState); - lua_pop(_luaState, postStack - preStack); + lua_pop(_luaState, retVals); } return data; @@ -280,17 +299,11 @@ uint32_t LuaDataModel::getLength(const std::string& expr) { // we need the result of the expression on the lua stack -> has to "return"! std::string trimmedExpr = boost::trim_copy(expr); -// luabridge::LuaRef val = luabridge::getGlobal(_luaState, expr.c_str()); -// std::cout << val.tostring() << std::endl; - if (!boost::starts_with(trimmedExpr, "return")) { trimmedExpr = "return(#" + trimmedExpr + ")"; } - int preStack = lua_gettop(_luaState); - eval(Arabica::DOM::Element<std::string>(), trimmedExpr); - int postStack = lua_gettop(_luaState); - int retVals = postStack - preStack; + int retVals = luaEval(Arabica::DOM::Element<std::string>(), trimmedExpr); if (retVals == 1 && lua_isnumber(_luaState, -1)) { int result = lua_tointeger(_luaState, -1); @@ -311,19 +324,14 @@ void LuaDataModel::setForeach(const std::string& item, const luabridge::LuaRef& arrRef = luabridge::getGlobal(_luaState, array.c_str()); if (arrRef.isTable()) { - int preStack = lua_gettop(_luaState); // trigger syntax error for invalid items - eval(Arabica::DOM::Element<std::string>(), "return(" + item + ");"); - int postStack = lua_gettop(_luaState); - lua_pop(_luaState, postStack - preStack); + int retVals = luaEval(Arabica::DOM::Element<std::string>(), "return(" + item + ");"); + lua_pop(_luaState, retVals); const luabridge::LuaRef& val = arrRef[iteration]; luabridge::setGlobal(_luaState, val, item.c_str()); -// luabridge::LuaRef retVal = luabridge::getGlobal(_luaState, item.c_str()); -// std::cout << retVal.tostring() << std::endl; - if (index.length() > 0) { // assign iteration element to index luabridge::setGlobal(_luaState, iteration, index.c_str()); @@ -333,12 +341,20 @@ void LuaDataModel::setForeach(const std::string& item, void LuaDataModel::eval(const Arabica::DOM::Element<std::string>& scriptElem, const std::string& expr) { + luaEval(scriptElem, expr); +} + +int LuaDataModel::luaEval(const Arabica::DOM::Element<std::string>& scriptElem, + const std::string& expr) { + int preStack = lua_gettop(_luaState); int error = luaL_loadstring(_luaState, expr.c_str()) || lua_pcall(_luaState, 0, LUA_MULTRET, 0); if (error) { std::string errMsg = lua_tostring(_luaState, -1); lua_pop(_luaState, 1); /* pop error message from the stack */ ERROR_EXECUTION_THROW(errMsg); } + int postStack = lua_gettop(_luaState); + return postStack - preStack; } bool LuaDataModel::isDeclared(const std::string& expr) { @@ -378,10 +394,10 @@ void LuaDataModel::assign(const Arabica::DOM::Element<std::string>& assignElem, // luabridge::LuaRef val = luabridge::getGlobal(_luaState, key.c_str()); // std::cout << val.tostring() << std::endl; - int preStack = lua_gettop(_luaState); + int retVals = 0; if (HAS_ATTR(assignElem, "expr")) { - eval(Arabica::DOM::Element<std::string>(), key + " = " + ATTR(assignElem, "expr") + ";"); + retVals = luaEval(Arabica::DOM::Element<std::string>(), key + " = " + ATTR(assignElem, "expr") + ";"); } else if (node) { ERROR_EXECUTION_THROW("Cannot assign xml nodes in lua datamodel"); } else if (content.size() > 0) { @@ -397,13 +413,10 @@ void LuaDataModel::assign(const Arabica::DOM::Element<std::string>& assignElem, // val = luabridge::getGlobal(_luaState, key.c_str()); // std::cout << val.tostring() << std::endl; - int postStack = lua_gettop(_luaState); - int retVals = postStack - preStack; - } void LuaDataModel::assign(const std::string& location, const Data& data) { - std::cout << "assign" << std::endl; + luabridge::setGlobal(_luaState, getDataAsLua(_luaState, data), location.c_str()); } void LuaDataModel::init(const Arabica::DOM::Element<std::string>& dataElem, @@ -413,7 +426,7 @@ void LuaDataModel::init(const Arabica::DOM::Element<std::string>& dataElem, } void LuaDataModel::init(const std::string& location, const Data& data) { - std::cout << "init" << std::endl; + assign(location, data); } /** @@ -429,10 +442,7 @@ bool LuaDataModel::evalAsBool(const Arabica::DOM::Node<std::string>& node, const trimmedExpr = "return(" + trimmedExpr + ");"; } - int preStack = lua_gettop(_luaState); - eval(Arabica::DOM::Element<std::string>(), trimmedExpr); - int postStack = lua_gettop(_luaState); - int retVals = postStack - preStack; + int retVals = luaEval(Arabica::DOM::Element<std::string>(), trimmedExpr); if (retVals == 1 && lua_isboolean(_luaState, -1)) { bool result = lua_toboolean(_luaState, -1); @@ -450,10 +460,7 @@ std::string LuaDataModel::evalAsString(const std::string& expr) { trimmedExpr = "return(" + trimmedExpr + ")"; } - int preStack = lua_gettop(_luaState); - eval(Arabica::DOM::Element<std::string>(), trimmedExpr); - int postStack = lua_gettop(_luaState); - int retVals = postStack - preStack; + int retVals = luaEval(Arabica::DOM::Element<std::string>(), trimmedExpr); if (retVals == 1 && lua_isstring(_luaState, -1)) { std::string result = lua_tostring(_luaState, -1); diff --git a/src/uscxml/plugins/datamodel/lua/LuaDataModel.h b/src/uscxml/plugins/datamodel/lua/LuaDataModel.h index c5d9e4b..828db0e 100644 --- a/src/uscxml/plugins/datamodel/lua/LuaDataModel.h +++ b/src/uscxml/plugins/datamodel/lua/LuaDataModel.h @@ -87,16 +87,8 @@ public: protected: - static int luaEventData(lua_State * l); - static int luaEventOrigin(lua_State * l); - static int luaEventOriginType(lua_State * l); - static int luaEventRaw(lua_State * l); - static int luaEventXML(lua_State * l); - static int luaEventName(lua_State * l); - static int luaEventContent(lua_State * l); - static int luaEventSendId(lua_State * l); - static int luaEventInvokeId(lua_State * l); - static int luaEventDestructor(lua_State * l); + virtual int luaEval(const Arabica::DOM::Element<std::string>& scriptElem, + const std::string& expr); lua_State* _luaState; }; diff --git a/test/src/test-vxml-mmi-socket.cpp b/test/src/test-vxml-mmi-socket.cpp index b57b7f6..a79cec7 100644 --- a/test/src/test-vxml-mmi-socket.cpp +++ b/test/src/test-vxml-mmi-socket.cpp @@ -52,21 +52,21 @@ int main(int argc, char** argv) { // TestClient client(PF_INET, SOCK_STREAM, 0); // client.connect("epikur.local", 4343); - + StartRequest startReq; startReq.source = "undefined.source"; startReq.target = "epikur.local:4343"; startReq.requestId = "131234141234"; startReq.data = - "<vxml xmlns=\"http://www.w3.org/2001/vxml\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" version=\"2.1\" xml:lang=\"en\"" - "xsi:schematicLocation=\"http://www.w3.org/2001/vxml http://www.w3.org/TR/voicexml20/vxml.xsd\">" - " <prompt>Goodbye!</prompt>" - "</vxml>"; + "<vxml xmlns=\"http://www.w3.org/2001/vxml\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" version=\"2.1\" xml:lang=\"en\"" + "xsi:schematicLocation=\"http://www.w3.org/2001/vxml http://www.w3.org/TR/voicexml20/vxml.xsd\">" + " <prompt>Goodbye!</prompt>" + "</vxml>"; Arabica::DOM::Document<std::string> reqXML = startReq.toXML(); std::stringstream xmlSS; xmlSS << reqXML; std::cout << reqXML; - + // client.write(xmlSS.str().data(), xmlSS.str().size()); }
\ No newline at end of file diff --git a/test/w3c/lua/test176.scxml b/test/w3c/lua/test176.scxml index 97f8f51..7e5f460 100644 --- a/test/w3c/lua/test176.scxml +++ b/test/w3c/lua/test176.scxml @@ -19,6 +19,11 @@ aParam in event1 is 2 so that var2 gets set to 2, success, otherwise failure -- <transition event="*" target="fail"/> </state> <state id="s1"> + <onentry> + <log label="asdfasdf" expr="testvar2" /> + <log label="123123" expr="_event.data.aParam" /> + + </onentry> <transition cond="testvar2 == 2" target="pass"/> <transition target="fail"/> </state> diff --git a/test/w3c/lua/test178.scxml b/test/w3c/lua/test178.scxml index 11361e1..c4df704 100644 --- a/test/w3c/lua/test178.scxml +++ b/test/w3c/lua/test178.scxml @@ -13,11 +13,11 @@ inspection.) --> <param expr="3" name="testvar1"/> </send> </onentry> - <transition event="event1" target="final"> + <transition event="event1" target="pass"> <log label="_event " expr="_event:inspect(true)"/> </transition> <transition event="*" target="fail"/> </state> - <final id="final"/> + <final id="pass"/> <final id="fail"/> </scxml> diff --git a/test/w3c/lua/test183.scxml b/test/w3c/lua/test183.scxml index 2b36df9..13378c9 100644 --- a/test/w3c/lua/test183.scxml +++ b/test/w3c/lua/test183.scxml @@ -7,7 +7,7 @@ var1 has a value and we pass. Otherwise we fail --> </datamodel> <state id="s0"> <onentry> - <send event="event1" idlocation="'testvar1'"/> + <send event="event1" idlocation="testvar1"/> </onentry> <transition cond="testvar1 ~= nil" target="pass"/> <transition target="fail"/> diff --git a/test/w3c/lua/test187.scxml b/test/w3c/lua/test187.scxml index 48aac56..0b6daa1 100644 --- a/test/w3c/lua/test187.scxml +++ b/test/w3c/lua/test187.scxml @@ -6,7 +6,7 @@ parent session, should not receive childToParent. If it does, we fail. Otherwis <scxml xmlns="http://www.w3.org/2005/07/scxml" initial="s0" version="1.0" datamodel="lua"> <state id="s0"> <onentry> - <send event="timeout" delay="100ms"/> + <send event="timeout" delay="400ms"/> </onentry> <invoke type="scxml"> <content> @@ -14,7 +14,7 @@ parent session, should not receive childToParent. If it does, we fail. Otherwis <scxml initial="sub0" version="1.0" datamodel="lua"> <state id="sub0"> <onentry> - <send event="childToParent" target="#_parent" delay="0ms"/> + <send event="childToParent" target="#_parent" delay="40ms"/> </onentry> <transition target="subFinal"/> </state> diff --git a/test/w3c/lua/test223.scxml b/test/w3c/lua/test223.scxml index 92cf1a9..dcbf061 100644 --- a/test/w3c/lua/test223.scxml +++ b/test/w3c/lua/test223.scxml @@ -8,7 +8,7 @@ <onentry> <send event="timeout" delay="1s"/> </onentry> - <invoke type="http://www.w3.org/TR/scxml/" idlocation="'testvar1'"> + <invoke type="http://www.w3.org/TR/scxml/" idlocation="testvar1"> <content> <!-- when invoked, terminate returning done.invoke. This proves that the invocation succeeded. --> <scxml initial="subFinal" version="1.0" datamodel="lua"> diff --git a/test/w3c/lua/test224.scxml b/test/w3c/lua/test224.scxml index 7a095e0..acca9f6 100644 --- a/test/w3c/lua/test224.scxml +++ b/test/w3c/lua/test224.scxml @@ -9,7 +9,7 @@ <onentry> <send event="timeout" delay="1s"/> </onentry> - <invoke type="http://www.w3.org/TR/scxml/" idlocation="'testvar1'"> + <invoke type="http://www.w3.org/TR/scxml/" idlocation="testvar1"> <content> <!-- when invoked, terminate returning done.invoke. This proves that the invocation succeeded. --> <scxml version="1.0" initial="subFinal" datamodel="lua"> diff --git a/test/w3c/lua/test225.scxml b/test/w3c/lua/test225.scxml index d370f9b..17f80c3 100644 --- a/test/w3c/lua/test225.scxml +++ b/test/w3c/lua/test225.scxml @@ -9,14 +9,14 @@ <onentry> <send event="timeout" delay="1s"/> </onentry> - <invoke type="http://www.w3.org/TR/scxml/" idlocation="'testvar1'"> + <invoke type="http://www.w3.org/TR/scxml/" idlocation="testvar1"> <content> <scxml initial="subFinal1" version="1.0" datamodel="lua"> <final id="subFinal1"/> </scxml> </content> </invoke> - <invoke type="http://www.w3.org/TR/scxml/" idlocation="'testvar2'"> + <invoke type="http://www.w3.org/TR/scxml/" idlocation="testvar2"> <content> <scxml initial="subFinal2" version="1.0" datamodel="lua"> <final id="subFinal2"/> diff --git a/test/w3c/lua/test463.scxml b/test/w3c/lua/test463.scxml deleted file mode 100644 index 23ca9cf..0000000 --- a/test/w3c/lua/test463.scxml +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- test that the <data> tag creates an element in the XML datamodel with the correct name and id attr -and binds an XPath variable to it --> -<scxml xmlns="http://www.w3.org/2005/07/scxml" initial="s0" version="1.0" datamodel="xpath"> - <datamodel> - <data id="foo" expr="2"/> - </datamodel> - <state id="s0"> - <transition cond="local-name($foo)='data'and $foo/@id ='foo'" target="pass"/> - <transition target="fail"/> - </state> - <final id="pass"/> - <final id="fail"/> -</scxml> diff --git a/test/w3c/lua/test464.scxml b/test/w3c/lua/test464.scxml deleted file mode 100644 index ddbef86..0000000 --- a/test/w3c/lua/test464.scxml +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- test that an unassigned variable creates an empty <data> element --> -<scxml xmlns="http://www.w3.org/2005/07/scxml" initial="s0" version="1.0" datamodel="xpath"> - <datamodel> - <data id="foo"/> - </datamodel> - <state id="s0"> - <transition cond="count($foo) = 1 and count($foo/*) = 0" target="pass"/> - <transition target="fail"/> - </state> - <final id="pass"/> - <final id="fail"/> -</scxml> diff --git a/test/w3c/lua/test465.scxml b/test/w3c/lua/test465.scxml deleted file mode 100644 index 50e708a..0000000 --- a/test/w3c/lua/test465.scxml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- test that all xpath variables are in a single global scope--> -<scxml xmlns="http://www.w3.org/2005/07/scxml" initial="s0" version="1.0" datamodel="xpath"> - <datamodel> - <data id="foo" expr="2"/> - </datamodel> - <state id="s0"> - <transition cond="count($foo) = 1 and count($bar) = 1" target="s1"/> - <transition target="fail"/> - </state> - <state id="s1"> - <datamodel> - <data id="bar" expr="1"/> - </datamodel> - <transition target="pass"/> - </state> - <final id="pass"/> - <final id="fail"/> -</scxml> diff --git a/test/w3c/lua/test466.scxml b/test/w3c/lua/test466.scxml deleted file mode 100644 index 51896b4..0000000 --- a/test/w3c/lua/test466.scxml +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- test that xpath expressions are converted to boolean when used as conditional expressions--> -<scxml xmlns="http://www.w3.org/2005/07/scxml" initial="s0" version="1.0" datamodel="xpath"> - <datamodel> - <data id="foo" expr="2"/> - </datamodel> - <state id="s0"> - <transition cond="$foo" target="pass"/> - <transition target="fail"/> - </state> - <final id="pass"/> - <final id="fail"/> -</scxml> diff --git a/test/w3c/lua/test467.scxml b/test/w3c/lua/test467.scxml deleted file mode 100644 index 673a561..0000000 --- a/test/w3c/lua/test467.scxml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- test that in() is available --> -<scxml xmlns="http://www.w3.org/2005/07/scxml" initial="s0" version="1.0" datamodel="xpath"> - <state id="s0"> - <transition cond="In('s0')" target="pass"/> - <transition target="fail"/> - </state> - <final id="pass"/> - <final id="fail"/> -</scxml> diff --git a/test/w3c/lua/test468.scxml b/test/w3c/lua/test468.scxml deleted file mode 100644 index 8c0c74a..0000000 --- a/test/w3c/lua/test468.scxml +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- test that XPath expressions can be used as location expressions. - This example is taken from the spec --> -<scxml xmlns="http://www.w3.org/2005/07/scxml" initial="s0" version="1.0" datamodel="xpath"> - <datamodel> - <data id="cities"> - <list> - <city id="nyc" count="0">New York</city> - <city id="bos" count="0">Boston</city> - </list> - </data> - </datamodel> - <state id="s0"> - <onentry> - <assign location="$cities/list/city[@id='nyc']/@count" expr="1"/> - </onentry> - <transition cond="$cities/list/city[@id='nyc']/@count = 1" target="pass"/> - <transition target="fail"/> - </state> - <final id="pass"/> - <final id="fail"/> -</scxml> diff --git a/test/w3c/lua/test469.scxml b/test/w3c/lua/test469.scxml deleted file mode 100644 index 487029d..0000000 --- a/test/w3c/lua/test469.scxml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- test that XPath expressions can be used as value expressions. --> -<scxml xmlns="http://www.w3.org/2005/07/scxml" initial="s0" version="1.0" datamodel="xpath"> - <datamodel> - <data id="copyOfEventData"/> - </datamodel> - <state id="s0"> - <onentry> - <send event="event1"> - <param name="param1" expr="1"/> - </send> - </onentry> - <transition event="event1" target="s1"> - <assign location="$copyOfEventData" expr="$_event/data"/> - </transition> - </state> - <state id="s1"> - <transition cond="$copyOfEventData/data/data[@id='param1'] =1" target="pass"/> - <transition target="fail"/> - </state> - <final id="pass"/> - <final id="fail"/> -</scxml> diff --git a/test/w3c/lua/test470.scxml b/test/w3c/lua/test470.scxml deleted file mode 100644 index 68d55bc..0000000 --- a/test/w3c/lua/test470.scxml +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- test that the processor makes a deep copy of a node set when assigning. --> -<scxml xmlns="http://www.w3.org/2005/07/scxml" initial="s0" version="1.0" datamodel="xpath"> - <datamodel> - <data id="var1"> - <foo> - <bar>2</bar> - </foo> - </data> - <data id="var2"/> - </datamodel> - <state id="s0"> - <onentry> - <assign location="$var2" expr="$var1/foo"/> - <assign location="$var1/foo/bar" expr="3"/> - </onentry> - <transition cond="$var2/foo/bar=2" target="pass"/> - <transition target="fail"/> - </state> - <final id="pass"/> - <final id="fail"/> -</scxml> diff --git a/test/w3c/lua/test473.scxml b/test/w3c/lua/test473.scxml deleted file mode 100644 index 45dfb40..0000000 --- a/test/w3c/lua/test473.scxml +++ /dev/null @@ -1,36 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- test that 'replacechildren' in <assign> replaces all children with the new value. - This example is taken from the doc --> -<scxml xmlns="http://www.w3.org/2005/07/scxml" initial="s0" version="1.0" datamodel="xpath"> - <datamodel> - <data id="cart"> - <myCart> - <books> - <book> - <title>The Zen Mind</title> - </book> - <book> - <title>Freakonomics</title> - </book> - </books> - <cds> - <cd name="Something"/> - </cds> - </myCart> - </data> - </datamodel> - <state id="s0"> - <onentry> - <assign location="$cart/myCart/books/book[1]"> - <bookinfo> - <isdn>12334455</isdn> - <author>some author</author> - </bookinfo> - </assign> - </onentry> - <transition cond="$cart/myCart/books/book[1]/bookinfo/isdn/text() = '12334455' and not($cart/myCart/books/book[1]/title)" target="pass"/> - <transition target="fail"/> - </state> - <final id="pass"/> - <final id="fail"/> -</scxml> diff --git a/test/w3c/lua/test474.scxml b/test/w3c/lua/test474.scxml deleted file mode 100644 index fdbce30..0000000 --- a/test/w3c/lua/test474.scxml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- test that 'firstchild' in <assign> inserts the new value before the other children. --> -<scxml xmlns="http://www.w3.org/2005/07/scxml" initial="s0" version="1.0" datamodel="xpath"> - <datamodel> - <data id="cart"> - <myCart> - <books> - <book> - <title>The Zen Mind</title> - </book> - <book> - <title>Freakonomics</title> - </book> - </books> - <cds> - <cd name="Something"/> - </cds> - </myCart> - </data> - </datamodel> - <state id="s0"> - <onentry> - <assign location="$cart/myCart/books/book[1]" type="firstchild"> - <bookinfo> - <isdn>12334455</isdn> - <author>some author</author> - </bookinfo> - </assign> - </onentry> - <transition cond="$cart/myCart/books/book[1]/*[1]/isdn/text() = '12334455' and $cart/myCart/books/book[1]/*[2]/text() = 'The Zen Mind'" target="pass"/> - <transition target="fail"/> - </state> - <final id="pass"/> - <final id="fail"/> -</scxml> diff --git a/test/w3c/lua/test475.scxml b/test/w3c/lua/test475.scxml deleted file mode 100644 index dc01a91..0000000 --- a/test/w3c/lua/test475.scxml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- test that 'lastchild' in <assign> inserts the new value after the other children. --> -<scxml xmlns="http://www.w3.org/2005/07/scxml" initial="s0" version="1.0" datamodel="xpath"> - <datamodel> - <data id="cart"> - <myCart> - <books> - <book> - <title>The Zen Mind</title> - </book> - <book> - <title>Freakonomics</title> - </book> - </books> - <cds> - <cd name="Something"/> - </cds> - </myCart> - </data> - </datamodel> - <state id="s0"> - <onentry> - <assign location="$cart/myCart/books/book[1]" type="lastchild"> - <bookinfo> - <isdn>12334455</isdn> - <author>some author</author> - </bookinfo> - </assign> - </onentry> - <transition cond="$cart/myCart/books/book[1]/*[2]/isdn/text() = '12334455' and $cart/myCart/books/book[1]/*[1]/text() = 'The Zen Mind'" target="pass"/> - <transition target="fail"/> - </state> - <final id="pass"/> - <final id="fail"/> -</scxml> diff --git a/test/w3c/lua/test476.scxml b/test/w3c/lua/test476.scxml deleted file mode 100644 index fcb7bd9..0000000 --- a/test/w3c/lua/test476.scxml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- test that 'nextsibling' in <assign> inserts the new value after the location. --> -<scxml xmlns="http://www.w3.org/2005/07/scxml" initial="s0" version="1.0" datamodel="xpath"> - <datamodel> - <data id="cart"> - <myCart> - <books> - <book> - <title>The Zen Mind</title> - </book> - <book> - <title>Freakonomics</title> - </book> - </books> - <cds> - <cd name="Something"/> - </cds> - </myCart> - </data> - </datamodel> - <state id="s0"> - <onentry> - <assign location="$cart/myCart/books/book[1]/title" type="nextsibling"> - <bookinfo> - <isdn>12334455</isdn> - <author>some author</author> - </bookinfo> - </assign> - </onentry> - <transition cond="$cart/myCart/books/book[1]/*[2]/isdn/text() = '12334455' and $cart/myCart/books/book[1]/*[1]/text() = 'The Zen Mind'" target="pass"/> - <transition target="fail"/> - </state> - <final id="pass"/> - <final id="fail"/> -</scxml> diff --git a/test/w3c/lua/test477.scxml b/test/w3c/lua/test477.scxml deleted file mode 100644 index b9ebba9..0000000 --- a/test/w3c/lua/test477.scxml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- test that 'previoussibling' in <assign> inserts the new value before the location. --> -<scxml xmlns="http://www.w3.org/2005/07/scxml" initial="s0" version="1.0" datamodel="xpath"> - <datamodel> - <data id="cart"> - <myCart> - <books> - <book> - <title>The Zen Mind</title> - </book> - <book> - <title>Freakonomics</title> - </book> - </books> - <cds> - <cd name="Something"/> - </cds> - </myCart> - </data> - </datamodel> - <state id="s0"> - <onentry> - <assign location="$cart/myCart/books/book[1]/title" type="previoussibling"> - <bookinfo> - <isdn>12334455</isdn> - <author>some author</author> - </bookinfo> - </assign> - </onentry> - <transition cond="$cart/myCart/books/book[1]/*[1]/isdn/text() = '12334455' and $cart/myCart/books/book[1]/*[2]/text() = 'The Zen Mind'" target="pass"/> - <transition target="fail"/> - </state> - <final id="pass"/> - <final id="fail"/> -</scxml> diff --git a/test/w3c/lua/test478.scxml b/test/w3c/lua/test478.scxml deleted file mode 100644 index d687487..0000000 --- a/test/w3c/lua/test478.scxml +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- test that 'replace' in <assign> replaces the value at the location. --> -<scxml xmlns="http://www.w3.org/2005/07/scxml" initial="s0" version="1.0" datamodel="xpath"> - <datamodel> - <data id="cart"> - <myCart> - <books> - <book> - <title>The Zen Mind</title> - </book> - <book> - <title>Freakonomics</title> - </book> - </books> - <cds> - <cd name="Something"/> - </cds> - </myCart> - </data> - </datamodel> - <state id="s0"> - <onentry> - <assign location="$cart/myCart/books/book[2]" type="replace"> - <cd> - <title>This is not a book</title> - </cd> - </assign> - </onentry> - <transition cond="$cart/myCart/books/cd/title = 'This is not a book'" target="pass"/> - <transition target="fail"/> - </state> - <final id="pass"/> - <final id="fail"/> -</scxml> diff --git a/test/w3c/lua/test479.scxml b/test/w3c/lua/test479.scxml deleted file mode 100644 index a26ae7b..0000000 --- a/test/w3c/lua/test479.scxml +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- test that 'delete' in <assign> deletes the value at the location. --> -<scxml xmlns="http://www.w3.org/2005/07/scxml" initial="s0" version="1.0" datamodel="xpath"> - <datamodel> - <data id="cart"> - <myCart> - <books> - <book> - <title>The Zen Mind</title> - </book> - <book> - <title>Freakonomics</title> - </book> - </books> - <cds> - <cd name="Something"/> - </cds> - </myCart> - </data> - </datamodel> - <state id="s0"> - <onentry> - <assign location="$cart/myCart/cds" type="delete"> - <cd> - <title>This is not a book</title> - </cd> - </assign> - </onentry> - <transition cond="not($cart/myCart/cds)" target="pass"/> - <transition target="fail"/> - </state> - <final id="pass"/> - <final id="fail"/> -</scxml> diff --git a/test/w3c/lua/test480.scxml b/test/w3c/lua/test480.scxml deleted file mode 100644 index 866444f..0000000 --- a/test/w3c/lua/test480.scxml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- test that 'addattr' in <assign> adds an attribute to the specified node. --> -<scxml xmlns="http://www.w3.org/2005/07/scxml" initial="s0" version="1.0" datamodel="xpath"> - <datamodel> - <data id="cart"> - <myCart> - <books> - <book> - <title>The Zen Mind</title> - </book> - <book> - <title>Freakonomics</title> - </book> - </books> - <cds> - <cd name="Something"/> - </cds> - </myCart> - </data> - </datamodel> - <state id="s0"> - <onentry> - <assign location="$cart/myCart/books/book[1]" type="addattribute" attr="author" expr="'somebody'"/> - </onentry> - <transition cond="$cart/myCart/books/book[1]/@author = 'somebody'" target="pass"/> - <transition target="fail"/> - </state> - <final id="pass"/> - <final id="fail"/> -</scxml> diff --git a/test/w3c/lua/test481.scxml b/test/w3c/lua/test481.scxml deleted file mode 100644 index 930b60d..0000000 --- a/test/w3c/lua/test481.scxml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- test that illegal assignments fail and have no side effects. --> -<scxml xmlns="http://www.w3.org/2005/07/scxml" initial="s0" version="1.0" datamodel="xpath"> - <datamodel> - <data id="cart"> - <myCart> - <books> - <book> - <title>The Zen Mind</title> - </book> - <book> - <title>Freakonomics</title> - </book> - </books> - <cds> - <cd name="Something"/> - </cds> - </myCart> - </data> - </datamodel> - <state id="s0"> - <onentry> - <send event="timeout" delay="3s"/> - <assign location="$cart/myCart/cds/cd/@name"> - <foo> - <bar/> - </foo> - </assign> - </onentry> - <transition event="error.execution" cond="$cart/myCart/cds/cd/@name = 'Something'" target="pass"/> - <transition event="*" target="fail"/> - </state> - <final id="pass"/> - <final id="fail"/> -</scxml> diff --git a/test/w3c/lua/test482.scxml b/test/w3c/lua/test482.scxml deleted file mode 100644 index 33b35a6..0000000 --- a/test/w3c/lua/test482.scxml +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- test that system vars are created and bound to XPath variables --> -<scxml xmlns="http://www.w3.org/2005/07/scxml" name="scxmltest" initial="s0" version="1.0" datamodel="xpath"> - <state id="s0"> - <onentry> - <!-- event isn't bound until an event is raised --> - <raise event="someevent"/> - </onentry> - <transition event="*" cond="local-name($_event) = 'data' and local-name($_sessionid) = 'data' and local-name($_name) = 'data' and local-name($_ioprocessors) = 'data'" target="pass"/> - <transition event="*" target="fail"/> - </state> - <final id="pass"/> - <final id="fail"/> -</scxml> diff --git a/test/w3c/lua/test483.scxml b/test/w3c/lua/test483.scxml deleted file mode 100644 index 375ca05..0000000 --- a/test/w3c/lua/test483.scxml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- test that foreach works correctly, iterating over node set in document order. - This tests assertions 483-485 --> -<scxml xmlns="http://www.w3.org/2005/07/scxml" name="scxmltest" initial="s0" version="1.0" datamodel="xpath"> - <datamodel> - <data id="var1"> - <nodes> - <node/> - <node/> - <node/> - </nodes> - </data> - </datamodel> - <state id="s0"> - <onentry> - <foreach array="$var1/nodes/node" item="item" index="pos"> - <assign location="$item" type="addattribute" attr="position" expr="$pos"/> - </foreach> - </onentry> - <transition cond="$var1/nodes/node[1]/@position = 1 and $var1/nodes/node[2]/@position = 2 and $var1/nodes/node[3]/@position = 3" target="pass"/> - <transition target="fail"/> - </state> - <final id="pass"/> - <final id="fail"/> -</scxml> diff --git a/test/w3c/lua/test537.scxml b/test/w3c/lua/test537.scxml deleted file mode 100644 index a231a97..0000000 --- a/test/w3c/lua/test537.scxml +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- test that the root element of the datamodel is <datamodel> and that <data> elements are its -children--> -<scxml xmlns="http://www.w3.org/2005/07/scxml" initial="s0" version="1.0" datamodel="xpath"> - <datamodel> - <data id="foo" expr="2"/> - </datamodel> - <state id="s0"> - <transition cond="local-name($foo/..)='datamodel'" target="pass"/> - <transition target="fail"/> - </state> - <final id="pass"/> - <final id="fail"/> -</scxml> diff --git a/test/w3c/lua/test539.scxml b/test/w3c/lua/test539.scxml deleted file mode 100644 index fced2e6..0000000 --- a/test/w3c/lua/test539.scxml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- test that if the child of <data> is XML, or if XML is loaded via src=, the processor - assigns it as the value of the var --> -<scxml xmlns="http://www.w3.org/2005/07/scxml" initial="s0" version="1.0" datamodel="xpath"> - <datamodel> - <data id="var1"> - <books> - <book title="title1"/> - <book title="title2"/> - </books> - </data> - <data id="var2" src="file:test539.txt"/> - </datamodel> - <state id="s0"> - <transition cond="$var1/books/book[2]/@title = 'title2'" target="s1"/> - <transition target="fail"/> - </state> - <state id="s1"> - <transition cond="$var2/books/book[2]/@title = 'title2'" target="pass"/> - <transition target="fail"/> - </state> - <final id="pass"/> - <final id="fail"/> -</scxml> diff --git a/test/w3c/lua/test540.scxml b/test/w3c/lua/test540.scxml deleted file mode 100644 index b0298b7..0000000 --- a/test/w3c/lua/test540.scxml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- test that if the child of <data> is a string or if a string is loaded via src=, the processor - does white space normalization on it and assigns it as the value of the var --> -<scxml xmlns="http://www.w3.org/2005/07/scxml" initial="s0" version="1.0" datamodel="xpath"> - <datamodel> - <data id="var1">123 -4 5 -</data> - <data id="var2" src="file:test540.txt"/> - </datamodel> - <state id="s0"> - <onentry> - <log label="var1 " expr="$var1"/> - </onentry> - <transition cond="$var1 = '123 4 5' and $var2 = '123 4 5'" target="pass"/> - <transition target="fail"/> - </state> - <final id="pass"/> - <final id="fail"/> -</scxml> diff --git a/test/w3c/lua/test542.scxml b/test/w3c/lua/test542.scxml deleted file mode 100644 index 69b6ea3..0000000 --- a/test/w3c/lua/test542.scxml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- test that <content> inside <donedata> handles XML and strings, - including white space normalization. --> -<scxml xmlns="http://www.w3.org/2005/07/scxml" initial="s0" version="1.0" datamodel="xpath"> - <state id="s0" initial="s01"> - <transition event="done.state.s0" cond="$_event/data/books/book[1]/@title = 'title1'" target="s1"/> - <transition event="done" target="fail"/> - <final id="s01"> - <donedata> - <content> - <books> - <book title="title1"/> - <book title="title2"/> - </books> - </content> - </donedata> - </final> - </state> - <state id="s1" initial="s11"> - <transition event="done.state.s1" cond="$_event/data = '123 4 5'" target="pass"/> - <transition event="done" target="fail"/> - <final id="s11"> - <donedata> - <content>123 -4 5 - </content> - </donedata> - </final> - </state> - <final id="pass"/> - <final id="fail"/> -</scxml> diff --git a/test/w3c/lua/test543.scxml b/test/w3c/lua/test543.scxml deleted file mode 100644 index 55946ed..0000000 --- a/test/w3c/lua/test543.scxml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- test that event fields are present as children of _event --> -<scxml xmlns="http://www.w3.org/2005/07/scxml" name="scxmltest" initial="s0" version="1.0" datamodel="xpath"> - <state id="s0"> - <onentry> - <!-- event isn't bound until an event is raised --> - <raise event="someevent"/> - </onentry> - <!-- origintype sendid, invokeid and data will not be bound in this event. name, type, and origin - are guaranteed to be there. --> - <transition event="*" cond="$_event/name and $_event/origin and $_event/type" target="pass"/> - <transition event="*" target="fail"/> - </state> - <final id="pass"/> - <final id="fail"/> -</scxml> diff --git a/test/w3c/lua/test544.scxml b/test/w3c/lua/test544.scxml deleted file mode 100644 index 5d935ab..0000000 --- a/test/w3c/lua/test544.scxml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- test that kvps are represented as <data> elements under event/data --> -<scxml xmlns="http://www.w3.org/2005/07/scxml" name="scxmltest" initial="s0" version="1.0" datamodel="xpath"> - <state id="s0"> - <onentry> - <send event="someevent"> - <param name="key1" expr="2"/> - </send> - </onentry> - <transition event="*" cond="$_event/data/data[@id='key1'] = 2" target="pass"/> - <transition event="*" target="fail"/> - </state> - <final id="pass"/> - <final id="fail"/> -</scxml> diff --git a/test/w3c/lua/test545.scxml b/test/w3c/lua/test545.scxml deleted file mode 100644 index 7443ff2..0000000 --- a/test/w3c/lua/test545.scxml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- test that xml content in send is place as XML under event/data --> -<scxml xmlns="http://www.w3.org/2005/07/scxml" name="scxmltest" initial="s0" version="1.0" datamodel="xpath"> - <state id="s0"> - <onentry> - <send event="someevent"> - <content> - <foo> - <bar>3</bar> - </foo> - </content> - </send> - </onentry> - <transition event="*" cond="$_event/data/foo/bar = 3" target="pass"/> - <transition event="*" target="fail"/> - </state> - <final id="pass"/> - <final id="fail"/> -</scxml> diff --git a/test/w3c/lua/test546.scxml b/test/w3c/lua/test546.scxml deleted file mode 100644 index 68efb84..0000000 --- a/test/w3c/lua/test546.scxml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- test that string content in send is place as a string under event/data --> -<scxml xmlns="http://www.w3.org/2005/07/scxml" name="scxmltest" initial="s0" version="1.0" datamodel="xpath"> - <state id="s0"> - <onentry> - <send event="someevent"> - <content>some string</content> - </send> - </onentry> - <transition event="*" cond="$_event/data = 'some string'" target="pass"/> - <transition event="*" target="fail"/> - </state> - <final id="pass"/> - <final id="fail"/> -</scxml> diff --git a/test/w3c/lua/test547.scxml b/test/w3c/lua/test547.scxml deleted file mode 100644 index 26e5cc8..0000000 --- a/test/w3c/lua/test547.scxml +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- test that assiging to a node set performs the assignment to each node. - This example is taken from the spec. --> -<scxml xmlns="http://www.w3.org/2005/07/scxml" name="scxmltest" initial="s0" version="1.0" datamodel="xpath"> - <datamodel> - <data id="cart"> - <myCart> - <books> - <book> - <title>The Zen Mind</title> - </book> - <book> - <title>Freakonomics</title> - </book> - </books> - <cds> - <cd name="Something"/> - </cds> - </myCart> - </data> - </datamodel> - <state id="s0"> - <onentry> - <assign location="$cart/myCart/books/book" expr="'The Zen Mind'"/> - </onentry> - <transition cond="$cart/myCart/books/book[1] = 'The Zen Mind' and $cart/myCart/books/book[2] = 'The Zen Mind'" target="pass"/> - <transition target="fail"/> - </state> - <final id="pass"/> - <final id="fail"/> -</scxml> diff --git a/test/w3c/lua/test555.scxml b/test/w3c/lua/test555.scxml deleted file mode 100644 index 2609689..0000000 --- a/test/w3c/lua/test555.scxml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- in the XPATH data model, test that processor coerces types to produce a string - where it's needed --> -<scxml xmlns="http://www.w3.org/2005/07/scxml" initial="s0" version="1.0" datamodel="xpath"> - <datamodel> - <data id="var1"> - <books> - <book title="title1"/> - <book title="title2"/> - </books> - </data> - </datamodel> - <state id="s0"> - <onentry> - <send eventexpr="$var1"/> - </onentry> - <transition event="error" target="fail"/> - <!-- don't really know what the stringification of that xml structure should be, but if - we get something other than an error, we assume that it worked. --> - <transition event="*" target="pass"/> - </state> - <final id="pass"/> - <final id="fail"/> -</scxml> diff --git a/test/w3c/lua/test568.scxml b/test/w3c/lua/test568.scxml deleted file mode 100644 index aaa1023..0000000 --- a/test/w3c/lua/test568.scxml +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- test that location field is found inside entry for SCXML Event I/O processor in the XPath -data model. The tests for the relevant event i/o processors will test that it can be used to -send events. --> -<scxml xmlns="http://www.w3.org/2005/07/scxml" initial="s0" version="1.0" datamodel="xpath"> - <state id="s0"> - <transition cond="$_ioprocessors/[@name='http://www.w3.org/TR/scxml/#SCXMLEventProcessor']/location/text()" target="pass"/> - <transition target="fail"/> - </state> - <final id="pass"/> - <final id="fail"/> -</scxml> |