diff options
Diffstat (limited to 'src/uscxml/debug')
-rw-r--r-- | src/uscxml/debug/DebugSession.cpp | 34 | ||||
-rw-r--r-- | src/uscxml/debug/DebugSession.h | 1 | ||||
-rw-r--r-- | src/uscxml/debug/DebuggerServlet.cpp | 10 | ||||
-rw-r--r-- | src/uscxml/debug/DebuggerServlet.h | 2 | ||||
-rw-r--r-- | src/uscxml/debug/InterpreterIssue.cpp | 4 |
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)); } } |