diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2012-09-16 23:09:21 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2012-09-16 23:09:21 (GMT) |
commit | 959224050cbceb024588bf0b49c57c503c299beb (patch) | |
tree | 50dfbf7f2c05e0974349b19c3f78e7681561a495 /src | |
parent | 2196f12c9f31b9858fedc477bbe9d5dbd2f87147 (diff) | |
download | uscxml-959224050cbceb024588bf0b49c57c503c299beb.zip uscxml-959224050cbceb024588bf0b49c57c503c299beb.tar.gz uscxml-959224050cbceb024588bf0b49c57c503c299beb.tar.bz2 |
fixed json in ecmascript data
Diffstat (limited to 'src')
-rw-r--r-- | src/uscxml/Interpreter.cpp | 11 | ||||
-rw-r--r-- | src/uscxml/Interpreter.h | 5 | ||||
-rw-r--r-- | src/uscxml/Message.cpp | 4 | ||||
-rw-r--r-- | src/uscxml/Message.h | 2 | ||||
-rw-r--r-- | src/uscxml/datamodel/ecmascript/v8/V8DataModel.cpp | 9 |
5 files changed, 18 insertions, 13 deletions
diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp index b1c504c..f965e1e 100644 --- a/src/uscxml/Interpreter.cpp +++ b/src/uscxml/Interpreter.cpp @@ -250,9 +250,15 @@ void Interpreter::initializeData(const Arabica::DOM::Node<std::string>& data) { _dataModel->assign(ATTR(data, "id"), value); } else if (data.hasChildNodes()) { // search for the text node with the actual script - Data value = Data(data); + NodeList<std::string> dataChilds = data.getChildNodes(); + for (int i = 0; i < dataChilds.getLength(); i++) { + if (dataChilds.item(i).getNodeType() == Node_base::TEXT_NODE) { + Data value = Data(dataChilds.item(i), Data::INTERPRETED); + _dataModel->assign(ATTR(data, "id"), value); + break; + } + } // std::cout << value << std::endl; - _dataModel->assign(ATTR(data, "id"), value); } } catch (Event e) { @@ -1406,6 +1412,7 @@ Arabica::DOM::Node<std::string> Interpreter::findLCCA(const Arabica::XPath::Node Arabica::DOM::Node<std::string> Interpreter::getState(const std::string& stateId) { // first try atomic and compund states + std::cout << _nsPrefix << stateId << std::endl; NodeSet<std::string> target = _xpath.evaluate("//" + _nsPrefix + "state[@id='" + stateId + "']", _doc).asNodeSet(); if (target.size() > 0) goto FOUND; diff --git a/src/uscxml/Interpreter.h b/src/uscxml/Interpreter.h index 9447498..cad8ee8 100644 --- a/src/uscxml/Interpreter.h +++ b/src/uscxml/Interpreter.h @@ -30,11 +30,6 @@ namespace uscxml { LATE = 1 }; - struct SendData { - Interpreter* interpreter; - uscxml::SendRequest req; - }; - virtual ~Interpreter(); static Interpreter* fromDOM(const Arabica::DOM::Node<std::string>& node); diff --git a/src/uscxml/Message.cpp b/src/uscxml/Message.cpp index 9b713ca..a2990b9 100644 --- a/src/uscxml/Message.cpp +++ b/src/uscxml/Message.cpp @@ -7,7 +7,7 @@ namespace uscxml { static int _dataIndentation = 1; -Data::Data(const Arabica::DOM::Node<std::string>& dom) { +Data::Data(const Arabica::DOM::Node<std::string>& dom, Type type) { // we may need to convert some keys to arrays if we have the same name as an element std::map<std::string, std::list<Data> > arrays; // Interpreter::dump(dom); @@ -54,7 +54,7 @@ Data::Data(const Arabica::DOM::Node<std::string>& dom) { } } else { atom = dom.getNodeValue(); - type = VERBATIM; + this->type = type; } std::map<std::string, std::list<Data> >::iterator arrayIter = arrays.begin(); diff --git a/src/uscxml/Message.h b/src/uscxml/Message.h index 34b85e1..be7747d 100644 --- a/src/uscxml/Message.h +++ b/src/uscxml/Message.h @@ -24,7 +24,7 @@ public: Data() {} Data(const std::string& atom_, Type type_ = INTERPRETED) : atom(atom_), type(type_) {} - Data(const Arabica::DOM::Node<std::string>& dom); + Data(const Arabica::DOM::Node<std::string>& dom, Type type = VERBATIM); virtual ~Data() {} static Data fromXML(const std::string& xmlString); diff --git a/src/uscxml/datamodel/ecmascript/v8/V8DataModel.cpp b/src/uscxml/datamodel/ecmascript/v8/V8DataModel.cpp index 2dfc72f..52c7ad7 100644 --- a/src/uscxml/datamodel/ecmascript/v8/V8DataModel.cpp +++ b/src/uscxml/datamodel/ecmascript/v8/V8DataModel.cpp @@ -14,10 +14,13 @@ DataModel* V8DataModel::create(Interpreter* interpreter) { v8::HandleScope scope; // see http://stackoverflow.com/questions/3171418/v8-functiontemplate-class-instance - dm->_globalTemplate = v8::Persistent<v8::ObjectTemplate>(v8::ObjectTemplate::New()); - dm->_globalTemplate->Set(v8::String::New("In"), v8::FunctionTemplate::New(jsIn, v8::External::New(reinterpret_cast<void*>(this)))); +// dm->_globalTemplate = v8::Persistent<v8::ObjectTemplate>(v8::ObjectTemplate::New()); +// dm->_globalTemplate->Set(v8::String::New("In"), v8::FunctionTemplate::New(jsIn, v8::External::New(reinterpret_cast<void*>(this)))); + + v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(); + global->Set(v8::String::New("In"), v8::FunctionTemplate::New(jsIn, v8::External::New(reinterpret_cast<void*>(dm)))); - dm->_contexts.push_back(v8::Context::New(0, _globalTemplate)); + dm->_contexts.push_back(v8::Context::New(NULL, global)); dm->setName(interpreter->getName()); dm->setSessionId(interpreter->getSessionId()); dm->eval("_ioprocessors = {};"); |