summaryrefslogtreecommitdiffstats
path: root/src/uscxml/debug
diff options
context:
space:
mode:
authorStefan Radomski <github@mintwerk.de>2017-08-02 06:04:38 (GMT)
committerGitHub <noreply@github.com>2017-08-02 06:04:38 (GMT)
commit97e72c5cb5e70eca231f74f01097c9b2392b4c98 (patch)
treef90d4ceb9d48fdc0dc240fce031dc81308e471dd /src/uscxml/debug
parent998e624aaddb237767f5d80e0ff12eb2cfdc814b (diff)
parent045bde78c0587316e0373c7698413412d0f315f9 (diff)
downloaduscxml-97e72c5cb5e70eca231f74f01097c9b2392b4c98.zip
uscxml-97e72c5cb5e70eca231f74f01097c9b2392b4c98.tar.gz
uscxml-97e72c5cb5e70eca231f74f01097c9b2392b4c98.tar.bz2
Merge pull request #165 from tklab-tud/sradomski
Reenabled V8, Debugger tests and smaller fixes
Diffstat (limited to 'src/uscxml/debug')
-rw-r--r--src/uscxml/debug/DebugSession.cpp34
-rw-r--r--src/uscxml/debug/DebugSession.h1
-rw-r--r--src/uscxml/debug/DebuggerServlet.cpp10
-rw-r--r--src/uscxml/debug/DebuggerServlet.h2
-rw-r--r--src/uscxml/debug/InterpreterIssue.cpp4
5 files changed, 44 insertions, 7 deletions
diff --git a/src/uscxml/debug/DebugSession.cpp b/src/uscxml/debug/DebugSession.cpp
index 42973fc..b5c1605 100644
--- a/src/uscxml/debug/DebugSession.cpp
+++ b/src/uscxml/debug/DebugSession.cpp
@@ -20,6 +20,7 @@
#include "uscxml/debug/DebugSession.h"
#include "uscxml/debug/Debugger.h"
#include "uscxml/util/Predicates.h"
+#include "uscxml/util/DOM.h"
#include "uscxml/interpreter/Logging.h"
@@ -440,7 +441,7 @@ Data DebugSession::debugEval(const Data& data) {
replyData.compound["reason"] = Data("No datamodel available", Data::VERBATIM);
} else {
try {
- replyData.compound["eval"] = _interpreter.getImpl()->getAsData(expr);
+ replyData.compound["eval"] = _interpreter.getImpl()->evalAsData(expr);
} catch (Event e) {
replyData.compound["eval"] = e.data;
replyData.compound["eval"].compound["error"] = Data(e.name, Data::VERBATIM);
@@ -450,6 +451,37 @@ Data DebugSession::debugEval(const Data& data) {
return replyData;
}
+Data DebugSession::debugEvent(const Data& data) {
+ Data replyData;
+
+ if (!_interpreter) {
+ replyData.compound["status"] = Data("failure", Data::VERBATIM);
+ replyData.compound["reason"] = Data("No interpreter running", Data::VERBATIM);
+ } else if (!data.hasKey("name")) {
+ replyData.compound["status"] = Data("failure", Data::VERBATIM);
+ replyData.compound["reason"] = Data("No event name given", Data::VERBATIM);
+ return replyData;
+ }
+ try {
+ Event event(data.at("name").atom);
+ if (data.hasKey("data")) {
+ event.data = data.at("data");
+ }
+ // TODO: this should not be necessary - initialize lazily
+ if (_interpreter.getState() == USCXML_INSTANTIATED) {
+ _interpreter.step();
+ }
+ _interpreter.receive(event);
+
+ } catch (Event e) {
+ replyData.compound["eval"] = e.data;
+ replyData.compound["eval"].compound["error"] = Data(e.name, Data::VERBATIM);
+ }
+ replyData.compound["status"] = Data("success", Data::VERBATIM);
+
+ return replyData;
+}
+
std::shared_ptr<LoggerImpl> DebugSession::create() {
return shared_from_this();
}
diff --git a/src/uscxml/debug/DebugSession.h b/src/uscxml/debug/DebugSession.h
index e258568..ab4d79d 100644
--- a/src/uscxml/debug/DebugSession.h
+++ b/src/uscxml/debug/DebugSession.h
@@ -68,6 +68,7 @@ public:
Data disableAllBreakPoints();
Data getIssues();
Data debugEval(const Data& data);
+ Data debugEvent(const Data& data);
void setDebugger(Debugger* debugger) {
_debugger = debugger;
diff --git a/src/uscxml/debug/DebuggerServlet.cpp b/src/uscxml/debug/DebuggerServlet.cpp
index 74853f4..8a7e087 100644
--- a/src/uscxml/debug/DebuggerServlet.cpp
+++ b/src/uscxml/debug/DebuggerServlet.cpp
@@ -106,8 +106,8 @@ bool DebuggerServlet::requestFromHTTP(const HTTPServer::Request& request) {
} else if (boost::istarts_with(request.data.at("path").atom, "/debug/connect")) {
processConnect(request);
return true;
- } else if (boost::starts_with(request.data.at("path").atom, "/debug/sessions")) {
- processListSessions(request);
+ } else if (boost::starts_with(request.data.at("path").atom, "/debug/instances")) {
+ processListInstances(request);
return true;
}
@@ -168,6 +168,8 @@ bool DebuggerServlet::requestFromHTTP(const HTTPServer::Request& request) {
replyData = session->debugResume(request.data["content"]);
} else if (boost::starts_with(request.data.at("path").atom, "/debug/eval")) {
replyData = session->debugEval(request.data["content"]);
+ } else if (boost::starts_with(request.data.at("path").atom, "/debug/event")) {
+ replyData = session->debugEvent(request.data["content"]);
}
if (!replyData.empty()) {
@@ -220,7 +222,7 @@ void DebuggerServlet::processDisconnect(const HTTPServer::Request& request) {
returnData(request, replyData);
}
-void DebuggerServlet::processListSessions(const HTTPServer::Request& request) {
+void DebuggerServlet::processListInstances(const HTTPServer::Request& request) {
Data replyData;
std::map<std::string, std::weak_ptr<InterpreterImpl> > instances = InterpreterImpl::getInstances();
@@ -234,7 +236,7 @@ void DebuggerServlet::processListSessions(const HTTPServer::Request& request) {
sessionData.compound["source"] = Data(instance->getBaseURL(), Data::VERBATIM);
sessionData.compound["xml"].node = instance->getDocument();
- replyData.compound["sessions"].array.push_back(sessionData);
+ replyData.compound["instances"].array.push_back(sessionData);
}
}
diff --git a/src/uscxml/debug/DebuggerServlet.h b/src/uscxml/debug/DebuggerServlet.h
index 4cd04bb..674d842 100644
--- a/src/uscxml/debug/DebuggerServlet.h
+++ b/src/uscxml/debug/DebuggerServlet.h
@@ -48,7 +48,7 @@ public:
void processDisconnect(const HTTPServer::Request& request);
void processConnect(const HTTPServer::Request& request);
- void processListSessions(const HTTPServer::Request& request);
+ void processListInstances(const HTTPServer::Request& request);
void processIssues(const HTTPServer::Request& request);
diff --git a/src/uscxml/debug/InterpreterIssue.cpp b/src/uscxml/debug/InterpreterIssue.cpp
index 346c0f6..f3620be 100644
--- a/src/uscxml/debug/InterpreterIssue.cpp
+++ b/src/uscxml/debug/InterpreterIssue.cpp
@@ -767,7 +767,9 @@ NEXT_SET:
for (auto iter = scripts.begin(); iter != scripts.end(); iter++) {
DOMElement* script = *iter;
- if (HAS_ATTR(script, kXMLCharSource) && script->getChildNodes()->getLength() > 0) {
+ if (HAS_ATTR(script, kXMLCharSource) &&
+ script->getChildNodes()->getLength() > 0 &&
+ script->getUserData(X("downladed")) == NULL) {
issues.push_back(InterpreterIssue("Script element cannot have src attribute and children", script, InterpreterIssue::USCXML_ISSUE_WARNING));
}
}