diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-04-20 19:28:50 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-04-20 19:28:50 (GMT) |
commit | c1ebae519210cd4d09eb63bde593d48e769ad7ca (patch) | |
tree | 488cfd8056c2e727a7b49882c2f3d46240d00998 /src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp | |
parent | 26609f8b8097b21e952835e7064bc938c8542d93 (diff) | |
download | uscxml-c1ebae519210cd4d09eb63bde593d48e769ad7ca.zip uscxml-c1ebae519210cd4d09eb63bde593d48e769ad7ca.tar.gz uscxml-c1ebae519210cd4d09eb63bde593d48e769ad7ca.tar.bz2 |
Support for event.raw and more XPath datamodel refactorings
Diffstat (limited to 'src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp')
-rw-r--r-- | src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp index 22777fa..34dd524 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp @@ -339,11 +339,30 @@ uint32_t V8DataModel::getLength(const std::string& expr) { Event exceptionEvent; exceptionEvent.name = "error.execution"; - exceptionEvent.data.compound["exception"] = Data("'" + expr + "' does not evaluate to an array.", Data::VERBATIM);; + exceptionEvent.data.compound["exception"] = Data("'" + expr + "' does not evaluate to an array.", Data::VERBATIM); throw(exceptionEvent); } +void V8DataModel::setForeach(const std::string& item, + const std::string& array, + const std::string& index, + uint32_t iteration) { + if (!isDeclared(item)) { + assign(item, Data()); + } + // assign array element to item + std::stringstream ss; + ss << array << "[" << iteration << "]"; + assign(item, ss.str()); + if (index.length() > 0) { + // assign iteration element to index + std::stringstream ss; + ss << iteration; + assign(index, ss.str()); + } +} + void V8DataModel::eval(const std::string& expr) { v8::Locker locker; v8::HandleScope handleScope; |