diff options
Diffstat (limited to 'src/uscxml')
-rw-r--r-- | src/uscxml/Interpreter.cpp | 13 | ||||
-rw-r--r-- | src/uscxml/Interpreter.h | 39 | ||||
-rw-r--r-- | src/uscxml/interpreter/InterpreterDraft6.cpp | 9 | ||||
-rw-r--r-- | src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.cpp | 3 | ||||
-rw-r--r-- | src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp | 2 | ||||
-rw-r--r-- | src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp | 2 | ||||
-rw-r--r-- | src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp | 3 |
7 files changed, 49 insertions, 22 deletions
diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp index b7de262..75d44c1 100644 --- a/src/uscxml/Interpreter.cpp +++ b/src/uscxml/Interpreter.cpp @@ -240,6 +240,8 @@ DONE_PARSING_CMD: void NameSpaceInfo::init(const std::map<std::string, std::string>& namespaceInfo) { nsInfo = namespaceInfo; nsURL = ""; + if (nsContext) + delete nsContext; nsContext = new Arabica::XPath::StandardNamespaceContext<std::string>(); std::map<std::string, std::string>::const_iterator nsIter = namespaceInfo.begin(); @@ -462,7 +464,12 @@ void InterpreterImpl::setName(const std::string& name) { } InterpreterImpl::~InterpreterImpl() { - _running = false; + { + // make sure we are done with setting up with early abort + tthread::lock_guard<tthread::recursive_mutex> lock(_mutex); + _running = false; + } +// std::cout << "stopped " << this << std::endl; // tthread::lock_guard<tthread::recursive_mutex> lock(_mutex); if (_thread) { if (_thread->get_id() != tthread::this_thread::get_id()) { @@ -554,8 +561,8 @@ void InterpreterImpl::init() { _scxml = (Arabica::DOM::Element<std::string>)scxmls.item(0); // setup xpath and check that it works - if (_nsInfo.nsContext != NULL) - _xpath.setNamespaceContext(*_nsInfo.nsContext); + if (_nsInfo.getNSContext() != NULL) + _xpath.setNamespaceContext(*_nsInfo.getNSContext()); if (_name.length() == 0) _name = (HAS_ATTR(_scxml, "name") ? ATTR(_scxml, "name") : UUID::getUUID()); diff --git a/src/uscxml/Interpreter.h b/src/uscxml/Interpreter.h index a18bc28..6a11c46 100644 --- a/src/uscxml/Interpreter.h +++ b/src/uscxml/Interpreter.h @@ -98,6 +98,18 @@ enum Capabilities { class USCXML_API InterpreterOptions { public: + InterpreterOptions() : + withDebugger(false), + verbose(false), + withHTTP(true), + withHTTPS(true), + withWS(true), + logLevel(0), + httpPort(0), + httpsPort(0), + wsPort(0) + {} + bool withDebugger; bool verbose; bool withHTTP; @@ -124,31 +136,19 @@ public: static InterpreterOptions fromCmdLine(int argc, char** argv); unsigned int getCapabilities(); -protected: - InterpreterOptions() : - withDebugger(false), - verbose(false), - withHTTP(true), - withHTTPS(true), - withWS(true), - logLevel(0), - httpPort(0), - httpsPort(0), - wsPort(0) - {} }; class NameSpaceInfo { public: - NameSpaceInfo() { + NameSpaceInfo() : nsContext(NULL) { init(std::map<std::string, std::string>()); } - NameSpaceInfo(const std::map<std::string, std::string>& nsInfo) { + NameSpaceInfo(const std::map<std::string, std::string>& nsInfo) : nsContext(NULL) { init(nsInfo); } - NameSpaceInfo(const NameSpaceInfo& other) { + NameSpaceInfo(const NameSpaceInfo& other) : nsContext(NULL) { init(other.nsInfo); } @@ -172,14 +172,19 @@ public: attribute.setPrefix(nsToPrefix[nsURL]); } + const Arabica::XPath::StandardNamespaceContext<std::string>* getNSContext() { + return nsContext; + } + std::string nsURL; // ough to be "http://www.w3.org/2005/07/scxml" but maybe empty std::string xpathPrefix; // prefix mapped for xpath, "scxml" is _xmlNSPrefix is empty but _nsURL set std::string xmlNSPrefix; // the actual prefix for elements in the xml file - Arabica::XPath::StandardNamespaceContext<std::string>* nsContext; std::map<std::string, std::string> nsToPrefix; // prefixes for a given namespace std::map<std::string, std::string> nsInfo; // all xmlns mappings private: + Arabica::XPath::StandardNamespaceContext<std::string>* nsContext; + void init(const std::map<std::string, std::string>& nsInfo); }; @@ -267,7 +272,7 @@ public: void setNameSpaceInfo(const NameSpaceInfo& nsInfo) { _nsInfo = nsInfo; - _xpath.setNamespaceContext(*_nsInfo.nsContext); + _xpath.setNamespaceContext(*_nsInfo.getNSContext()); } NameSpaceInfo getNameSpaceInfo() const { return _nsInfo; diff --git a/src/uscxml/interpreter/InterpreterDraft6.cpp b/src/uscxml/interpreter/InterpreterDraft6.cpp index 721aea0..31c433c 100644 --- a/src/uscxml/interpreter/InterpreterDraft6.cpp +++ b/src/uscxml/interpreter/InterpreterDraft6.cpp @@ -69,6 +69,10 @@ void InterpreterDraft6::interpret() { } _running = true; +#if VERBOSE + std::cout << "running " << this << std::endl; +#endif + _binding = (HAS_ATTR(_scxml, "binding") && iequals(ATTR(_scxml, "binding"), "late") ? LATE : EARLY); // @TODO: Reread http://www.w3.org/TR/scxml/#DataBinding @@ -270,6 +274,11 @@ void InterpreterDraft6::mainEventLoop() { _currEvent = _externalQueue.pop(); #if VERBOSE std::cout << "Received externalEvent event " << _currEvent.name << std::endl; + if (_running && _currEvent.name == "unblock.and.die") { + std::cout << "Still running " << this << std::endl; + } else { + std::cout << "Aborting " << this << std::endl; + } #endif _currEvent.eventType = Event::EXTERNAL; // make sure it is set to external if (!_running) diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.cpp index 40bd464..402152d 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.cpp @@ -29,10 +29,13 @@ JSCDOM::JSCDOM() { } JSCDOM::~JSCDOM() { + if (nsInfo) + delete(nsInfo); if (xpath) delete(xpath); if (storage) delete(storage); + } } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp index 2e8e6d2..3130d42 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp @@ -125,7 +125,7 @@ boost::shared_ptr<DataModelImpl> JSCDataModel::create(InterpreterImpl* interpret dm->_dom = new JSCDOM(); dm->_dom->xpath = new XPath<std::string>(); - dm->_dom->xpath->setNamespaceContext(*interpreter->getNameSpaceInfo().nsContext); + dm->_dom->xpath->setNamespaceContext(*interpreter->getNameSpaceInfo().getNSContext()); dm->_dom->storage = new Storage(URL::getResourceDir() + PATH_SEPERATOR + interpreter->getName() + ".storage"); dm->_dom->nsInfo = new NameSpaceInfo(interpreter->getNameSpaceInfo()); diff --git a/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp b/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp index c3e82df..bf32bf9 100644 --- a/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp +++ b/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp @@ -54,7 +54,7 @@ boost::shared_ptr<DataModelImpl> XPathDataModel::create(InterpreterImpl* interpr // dm->_xpath->setNamespaceContext(interpreter->getNSContext()); dm->_funcResolver.setInterpreter(interpreter); - dm->_xpath.setNamespaceContext(*interpreter->getNameSpaceInfo().nsContext); + dm->_xpath.setNamespaceContext(*interpreter->getNameSpaceInfo().getNSContext()); dm->_xpath.setFunctionResolver(dm->_funcResolver); dm->_xpath.setVariableResolver(dm->_varResolver); diff --git a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp index 37ec669..d89d8ac 100644 --- a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp +++ b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp @@ -41,6 +41,9 @@ USCXMLInvoker::USCXMLInvoker() : _cancelled(false) { USCXMLInvoker::~USCXMLInvoker() { _cancelled = true; + Event event; + event.name = "unblock.and.die"; + _invokedInterpreter.receive(event); }; boost::shared_ptr<InvokerImpl> USCXMLInvoker::create(InterpreterImpl* interpreter) { |