summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-10-08 17:44:23 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-10-08 17:44:23 (GMT)
commit9479a0d91c1bb9241324dea4f92b50405d17e97b (patch)
tree5d7e85b1ecfff44d352466246ee1c41e281a156a
parent8daf2ea0a7192e556cc059c2220469ea22155380 (diff)
downloaduscxml-9479a0d91c1bb9241324dea4f92b50405d17e97b.zip
uscxml-9479a0d91c1bb9241324dea4f92b50405d17e97b.tar.gz
uscxml-9479a0d91c1bb9241324dea4f92b50405d17e97b.tar.bz2
Pass more ECMAScript W3C tests
-rw-r--r--README.md7
-rw-r--r--src/uscxml/Interpreter.cpp14
-rw-r--r--src/uscxml/concurrency/eventqueue/DelayedEventQueue.cpp10
-rw-r--r--src/uscxml/interpreter/InterpreterDraft6.cpp2
-rw-r--r--src/uscxml/plugins/ioprocessor/basichttp/BasicHTTPIOProcessor.cpp75
-rw-r--r--src/uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.cpp3
6 files changed, 27 insertions, 84 deletions
diff --git a/README.md b/README.md
index 71ef366..e52be77 100644
--- a/README.md
+++ b/README.md
@@ -40,12 +40,6 @@ uSCXML still fails the following ecmascript tests:
<table>
<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/samples/w3c/ecma/test159.scxml">159</a></tt></td>
- <td><tt>Failed</tt></td>
- <td>"If the processing of an element of executable content causes an error to be raised, the processor MUST NOT process the remaining elements of the block."</td>
- <td>uSCXML continues processing the rest of the block as if there was no error.</td>
- </tr>
- <tr>
<td><tt><a href="https://github.com/tklab-tud/uscxml/blob/master/test/samples/w3c/ecma/test301.scxml">301</a></tt></td>
<td><tt>Failed</tt></td>
<td>"the processor should reject this document because it can't download the script"</td>
@@ -67,6 +61,7 @@ uSCXML still fails the following ecmascript tests:
<tr>
<td>
<tt>
+ <a href="https://github.com/tklab-tud/uscxml/blob/master/test/samples/w3c/ecma/test518.scxml">518</a>
<a href="https://github.com/tklab-tud/uscxml/blob/master/test/samples/w3c/ecma/test519.scxml">519</a>
<a href="https://github.com/tklab-tud/uscxml/blob/master/test/samples/w3c/ecma/test520.scxml">520</a>
<a href="https://github.com/tklab-tud/uscxml/blob/master/test/samples/w3c/ecma/test531.scxml">531</a>
diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp
index 065b61e..b23ccd7 100644
--- a/src/uscxml/Interpreter.cpp
+++ b/src/uscxml/Interpreter.cpp
@@ -914,6 +914,8 @@ void InterpreterImpl::delayedSend(void* userdata, std::string eventName) {
if (ioProc) {
try {
ioProc.send(sendReq);
+ } catch(Event e) {
+ throw e;
} catch(...) {
LOG(ERROR) << "Exception caught while sending event to ioprocessor " << sendReq.type;
}
@@ -1157,7 +1159,10 @@ void InterpreterImpl::executeContent(const NodeList<std::string>& content, bool
for (unsigned int i = 0; i < content.getLength(); i++) {
if (content.item(i).getNodeType() != Node_base::ELEMENT_NODE)
continue;
- executeContent(content.item(i), rethrow);
+ try {
+ executeContent(content.item(i), true);
+ }
+ CATCH_AND_DISTRIBUTE("Error when executing content");
}
}
@@ -1165,7 +1170,10 @@ void InterpreterImpl::executeContent(const NodeSet<std::string>& content, bool r
for (unsigned int i = 0; i < content.size(); i++) {
if (content[i].getNodeType() != Node_base::ELEMENT_NODE)
continue;
- executeContent(content[i], rethrow);
+ try {
+ executeContent(content[i], true);
+ }
+ CATCH_AND_DISTRIBUTE("Error when executing content");
}
}
@@ -1246,7 +1254,7 @@ void InterpreterImpl::executeContent(const Arabica::DOM::Node<std::string>& cont
_dataModel.setForeach(item, array, index, iteration);
if (content.hasChildNodes())
// execute content and have exception rethrown to break foreach
- executeContent(content.getChildNodes(), true);
+ executeContent(content.getChildNodes(), rethrow);
}
_dataModel.popContext(); // leave stacked context
}
diff --git a/src/uscxml/concurrency/eventqueue/DelayedEventQueue.cpp b/src/uscxml/concurrency/eventqueue/DelayedEventQueue.cpp
index fe16361..28bd343 100644
--- a/src/uscxml/concurrency/eventqueue/DelayedEventQueue.cpp
+++ b/src/uscxml/concurrency/eventqueue/DelayedEventQueue.cpp
@@ -1,4 +1,6 @@
+#include "uscxml/Message.h"
#include "DelayedEventQueue.h"
+#include <glog/logging.h>
#include <assert.h>
#include <event2/event.h>
#include <sstream>
@@ -115,7 +117,13 @@ void DelayedEventQueue::timerCallback(evutil_socket_t fd, short what, void *arg)
tthread::lock_guard<tthread::recursive_mutex> lock(data->eventQueue->_mutex);
std::string eventId = data->eventId; // copy eventId
- data->callback(data->userData, eventId);
+ try {
+ data->callback(data->userData, eventId);
+ } catch (Event e) {
+ LOG(ERROR) << "Exception thrown when executing delayed event:" << std::endl << e << std::endl;
+ } catch (...) {
+ LOG(ERROR) << "Exception thrown when executing delayed event" << std::endl;
+ }
if (!data->persist) {
event_free(data->event);
data->eventQueue->_callbackData.erase(data->eventId);
diff --git a/src/uscxml/interpreter/InterpreterDraft6.cpp b/src/uscxml/interpreter/InterpreterDraft6.cpp
index 176bddf..3480c43 100644
--- a/src/uscxml/interpreter/InterpreterDraft6.cpp
+++ b/src/uscxml/interpreter/InterpreterDraft6.cpp
@@ -934,7 +934,7 @@ void InterpreterDraft6::enterStates(const Arabica::XPath::NodeSet<std::string>&
}
// execute onentry executable content
NodeSet<std::string> onEntryElems = filterChildElements(_xmlNSPrefix + "onEntry", stateElem);
- executeContent(onEntryElems);
+ executeContent(onEntryElems, false);
if (isMember(stateElem, statesForDefaultEntry)) {
// execute initial transition content for compound states
diff --git a/src/uscxml/plugins/ioprocessor/basichttp/BasicHTTPIOProcessor.cpp b/src/uscxml/plugins/ioprocessor/basichttp/BasicHTTPIOProcessor.cpp
index 74e51d6..b5aa985 100644
--- a/src/uscxml/plugins/ioprocessor/basichttp/BasicHTTPIOProcessor.cpp
+++ b/src/uscxml/plugins/ioprocessor/basichttp/BasicHTTPIOProcessor.cpp
@@ -71,85 +71,16 @@ Data BasicHTTPIOProcessor::getDataModelVariables() {
bool BasicHTTPIOProcessor::httpRecvRequest(const HTTPServer::Request& req) {
Event reqEvent = req;
reqEvent.eventType = Event::EXTERNAL;
- bool scxmlStructFound = false;
-
- if (reqEvent.data.compound["header"].compound.find("Content-Type") != reqEvent.data.compound["header"].compound.end() &&
- boost::iequals(reqEvent.data.compound["header"].compound["Content-Type"].atom, "application/x-www-form-urlencoded")) {
- std::stringstream ss(reqEvent.data.compound["content"].atom);
- std::string term;
- while(std::getline(ss, term, '&')) {
- size_t split = term.find_first_of("=");
- if (split != std::string::npos) {
-
- char* keyCStr = evhttp_decode_uri(term.substr(0, split).c_str());
- char* valueCStr = evhttp_decode_uri(term.substr(split + 1).c_str());
- std::string key = keyCStr;
- std::string value = valueCStr;
- free(keyCStr);
- free(valueCStr);
-
- if (boost::iequals(key, "_scxmleventname")) {
- reqEvent.name = value;
- } else if (boost::iequals(key, "content")) {
- reqEvent.initContent(value);
- } else {
- reqEvent.data.compound[key] = value;
- reqEvent.params.insert(std::make_pair(key, value));
- }
- } else {
- // this is most likely wrong
- char* contentCStr = evhttp_decode_uri(term.c_str());
- reqEvent.content = contentCStr;
- free(contentCStr);
- }
- }
- } else {
- if (reqEvent.data.compound["header"].compound.find("_scxmleventstruct") != reqEvent.data.compound["header"].compound.end()) {
- // TODO: this looses all other information
- char* scxmlStructCStr = evhttp_decode_uri(reqEvent.data.compound["header"].compound["_scxmleventstruct"].atom.c_str());
- reqEvent = Event::fromXML(scxmlStructCStr);
- free(scxmlStructCStr);
- scxmlStructFound = true;
- }
- if (reqEvent.data.compound["header"].compound.find("_scxmleventname") != reqEvent.data.compound["header"].compound.end()) {
- char* evNameCStr = evhttp_decode_uri(reqEvent.data.compound["header"].compound["_scxmleventname"].atom.c_str());
- reqEvent.name = evNameCStr;
- free(evNameCStr);
- }
- }
- std::map<std::string, Data>::iterator headerIter = reqEvent.data.compound["header"].compound.begin();
- while(headerIter != reqEvent.data.compound["header"].compound.end()) {
- char* headerCStr = evhttp_decode_uri(headerIter->second.atom.c_str());
- reqEvent.data.compound[headerIter->first] = Data(headerCStr, Data::VERBATIM);
- free(headerCStr);
- headerIter++;
- }
-#if 0
- std::map<std::string, std::string>::const_iterator headerIter = req.headers.begin();
- while(headerIter != req.headers.end()) {
- if (boost::iequals("_scxmleventstruct", headerIter->first)) {
- reqEvent = Event::fromXML(evhttp_decode_uri(headerIter->second.c_str()));
- scxmlStructFound = true;
- break;
- } else if (boost::iequals("_scxmleventname", headerIter->first)) {
- reqEvent.name = evhttp_decode_uri(headerIter->second.c_str());
- } else {
- reqEvent.data.compound[headerIter->first] = Data(evhttp_decode_uri(headerIter->second.c_str()), Data::VERBATIM);
- }
- headerIter++;
+ // this will call the const subscript operator
+ if (req.data["content"]["_scxmleventname"]) {
+ reqEvent.name = req.data["content"]["_scxmleventname"].atom;
}
-#endif
/// test532
if (reqEvent.name.length() == 0)
reqEvent.name = "http." + req.data.compound.at("type").atom;
- if (!scxmlStructFound) {
- // get content into event
- reqEvent.data.compound["content"] = Data(req.content, Data::VERBATIM);
- }
-
returnEvent(reqEvent);
evhttp_send_reply(req.curlReq, 200, "OK", NULL);
return true;
diff --git a/src/uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.cpp b/src/uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.cpp
index ac570c4..dcf1d4e 100644
--- a/src/uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.cpp
+++ b/src/uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.cpp
@@ -159,7 +159,8 @@ void SCXMLIOProcessor::send(const SendRequest& req) {
Event error("error.execution", Event::PLATFORM);
error.sendid = reqCopy.sendid;
// test 159 still fails
- _interpreter->receiveInternal(error);
+// _interpreter->receiveInternal(error);
+ throw error;
}
}
}