summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-10-27 20:26:07 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-10-27 20:26:07 (GMT)
commit0a9c4c2e8f10de0323503fd5f2b11f31314b380c (patch)
tree2d5f6c0659df463b103fe376af72ce5ab173b5cf /src
parent1e42b29439d247598d58aac10f62c77cf2f31f12 (diff)
downloaduscxml-0a9c4c2e8f10de0323503fd5f2b11f31314b380c.zip
uscxml-0a9c4c2e8f10de0323503fd5f2b11f31314b380c.tar.gz
uscxml-0a9c4c2e8f10de0323503fd5f2b11f31314b380c.tar.bz2
Added XML node to DataModel::evalAsBool signature to enable script caching
Diffstat (limited to 'src')
-rw-r--r--src/bindings/swig/java/JavaDataModel.h4
-rw-r--r--src/uscxml/Factory.cpp6
-rw-r--r--src/uscxml/Factory.h12
-rw-r--r--src/uscxml/Interpreter.cpp10
-rw-r--r--src/uscxml/Message.h1
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h3
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h8
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp4
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h1
-rw-r--r--src/uscxml/plugins/datamodel/null/NULLDataModel.cpp2
-rw-r--r--src/uscxml/plugins/datamodel/null/NULLDataModel.h2
-rw-r--r--src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp4
-rw-r--r--src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h1
-rw-r--r--src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp4
-rw-r--r--src/uscxml/plugins/datamodel/xpath/XPathDataModel.h1
16 files changed, 53 insertions, 12 deletions
diff --git a/src/bindings/swig/java/JavaDataModel.h b/src/bindings/swig/java/JavaDataModel.h
index ca503d1..ef8daa6 100644
--- a/src/bindings/swig/java/JavaDataModel.h
+++ b/src/bindings/swig/java/JavaDataModel.h
@@ -57,6 +57,10 @@ public:
return false;
}
+ virtual bool evalAsBool(const Arabica::DOM::Node<std::string>& node, const std::string& expr) {
+ return false;
+ }
+
virtual bool isDeclared(const std::string& expr) {
return false;
}
diff --git a/src/uscxml/Factory.cpp b/src/uscxml/Factory.cpp
index ccbb283..c836582 100644
--- a/src/uscxml/Factory.cpp
+++ b/src/uscxml/Factory.cpp
@@ -45,7 +45,7 @@
//# include "uscxml/plugins/ioprocessor/modality/MMIHTTPIOProcessor.h"
#endif
-# ifdef UMUNDO_FOUND
+# ifdef UMUNDO_FOUND
# include "uscxml/plugins/invoker/umundo/UmundoInvoker.h"
//# include "uscxml/plugins/invoker/vxml/VoiceXMLInvoker.h"
#endif
@@ -250,8 +250,8 @@ Factory::Factory() {
#ifdef PROTOBUF_FOUND
{
- // MMIHTTPIOProcessor* ioProcessor = new MMIHTTPIOProcessor();
- // registerIOProcessor(ioProcessor);
+ // MMIHTTPIOProcessor* ioProcessor = new MMIHTTPIOProcessor();
+ // registerIOProcessor(ioProcessor);
}
#endif
#endif
diff --git a/src/uscxml/Factory.h b/src/uscxml/Factory.h
index a463d5b..0011547 100644
--- a/src/uscxml/Factory.h
+++ b/src/uscxml/Factory.h
@@ -276,7 +276,12 @@ public:
const std::string& expr) = 0;
virtual std::string evalAsString(const std::string& expr) = 0;
- virtual bool evalAsBool(const std::string& expr) = 0;
+
+ virtual bool evalAsBool(const Arabica::DOM::Node<std::string>& scriptNode,
+ const std::string& expr) = 0;
+ virtual bool evalAsBool(const std::string& expr) {
+ return evalAsBool(Arabica::DOM::Node<std::string>(), expr);
+ }
virtual bool isDeclared(const std::string& expr) = 0;
@@ -353,6 +358,11 @@ public:
virtual bool evalAsBool(const std::string& expr) {
return _impl->evalAsBool(expr);
}
+ virtual bool evalAsBool(const Arabica::DOM::Node<std::string>& scriptNode,
+ const std::string& expr) {
+ return _impl->evalAsBool(scriptNode, expr);
+ }
+
virtual uint32_t getLength(const std::string& expr) {
return _impl->getLength(expr);
}
diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp
index fe8f3c7..b7a9d33 100644
--- a/src/uscxml/Interpreter.cpp
+++ b/src/uscxml/Interpreter.cpp
@@ -1193,7 +1193,7 @@ bool InterpreterImpl::hasConditionMatch(const Arabica::DOM::Node<std::string>& c
return false;
}
try {
- return _dataModel.evalAsBool(ATTR(conditional, "cond"));
+ return _dataModel.evalAsBool(ATTR_NODE(conditional, "cond"), ATTR(conditional, "cond"));
} catch (Event e) {
LOG(ERROR) << "Syntax error in cond attribute of " << TAGNAME(conditional) << " element:" << std::endl << e << std::endl;
e.name = "error.execution";
@@ -1702,6 +1702,7 @@ NodeSet<std::string> InterpreterImpl::getTargetStates(const Arabica::DOM::Node<s
std::vector<std::string> InterpreterImpl::tokenizeIdRefs(const std::string& idRefs) {
std::vector<std::string> ids;
+#if 0
if (idRefs.length() > 0) {
std::istringstream iss(idRefs);
@@ -1709,6 +1710,13 @@ std::vector<std::string> InterpreterImpl::tokenizeIdRefs(const std::string& idRe
std::istream_iterator<std::string>(),
std::back_inserter<std::vector<std::string> >(ids));
}
+#endif
+
+ // this version is somewhat fatser than the one above
+ std::stringstream ss (idRefs);
+ std::string item;
+ while(ss >> item)
+ ids.push_back(item);
return ids;
}
diff --git a/src/uscxml/Message.h b/src/uscxml/Message.h
index 6b84923..719db63 100644
--- a/src/uscxml/Message.h
+++ b/src/uscxml/Message.h
@@ -43,6 +43,7 @@
#define TAGNAME(elem) ((Arabica::DOM::Element<std::string>)elem).getTagName()
#define LOCALNAME(elem) ((Arabica::DOM::Element<std::string>)elem).getLocalName()
#define ATTR(elem, attr) ((Arabica::DOM::Element<std::string>)elem).getAttribute(attr)
+#define ATTR_NODE(elem, attr) ((Arabica::DOM::Element<std::string>)elem).getAttributeNode(attr)
#define HAS_ATTR(elem, attr) ((Arabica::DOM::Element<std::string>)elem).hasAttribute(attr)
namespace uscxml {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp
index c737d16..dbe4be5 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp
@@ -487,7 +487,7 @@ void JSCDataModel::eval(const Element<std::string>& scriptElem,
evalAsValue(expr);
}
-bool JSCDataModel::evalAsBool(const std::string& expr) {
+bool JSCDataModel::evalAsBool(const Arabica::DOM::Node<std::string>& node, const std::string& expr) {
JSValueRef result = evalAsValue(expr);
return JSValueToBoolean(_ctx, result);
}
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h
index fc35b46..c79c29e 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h
@@ -64,7 +64,8 @@ public:
virtual void eval(const Arabica::DOM::Element<std::string>& scriptElem,
const std::string& expr);
virtual std::string evalAsString(const std::string& expr);
- virtual bool evalAsBool(const std::string& expr);
+
+ virtual bool evalAsBool(const Arabica::DOM::Node<std::string>& node, const std::string& expr);
virtual bool isDeclared(const std::string& expr);
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h
index 2fa5b81..7030469 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h
@@ -60,12 +60,14 @@ public:
else if(!data->IsExternal())
return NULL;
else
- return static_cast<T *>(v8::External::Unwrap(data));
+ return v8::External::Cast(*data)->Value();
+// return static_cast<T *>(v8::External::Unwrap(data));
return NULL;
}
static v8::Local<v8::External> toExternal(void* pointer) {
- v8::HandleScope scope;
- return scope.Close(v8::External::New(pointer));
+// v8::HandleScope scope;
+// return scope.Close(v8::External::New(pointer));
+ return v8::External::New(pointer);
}
Arabica::XPath::XPath<std::string>* xpath;
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
index a0de760..1037802 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
@@ -518,6 +518,10 @@ bool V8DataModel::isDeclared(const std::string& expr) {
}
bool V8DataModel::evalAsBool(const std::string& expr) {
+ return evalAsBool(Arabica::DOM::Node<std::string>(), expr);
+}
+
+bool V8DataModel::evalAsBool(const Arabica::DOM::Node<std::string>& node, const std::string& expr) {
v8::Locker locker;
v8::HandleScope handleScope;
v8::Context::Scope contextScope(_contexts.back());
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h
index 17ca7bc..0a64a2e 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h
@@ -88,6 +88,7 @@ public:
virtual bool isDeclared(const std::string& expr);
virtual std::string evalAsString(const std::string& expr);
+ virtual bool evalAsBool(const Arabica::DOM::Node<std::string>& node, const std::string& expr);
virtual bool evalAsBool(const std::string& expr);
virtual double evalAsNumber(const std::string& expr);
diff --git a/src/uscxml/plugins/datamodel/null/NULLDataModel.cpp b/src/uscxml/plugins/datamodel/null/NULLDataModel.cpp
index 3e690a9..05072df 100644
--- a/src/uscxml/plugins/datamodel/null/NULLDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/null/NULLDataModel.cpp
@@ -96,7 +96,7 @@ bool NULLDataModel::isDeclared(const std::string& expr) {
* The predicate must return 'true' if and only if that state is in the current
* state configuration.
*/
-bool NULLDataModel::evalAsBool(const std::string& expr) {
+bool NULLDataModel::evalAsBool(const Arabica::DOM::Node<std::string>& node, const std::string& expr) {
std::string trimmedExpr = expr;
boost::trim(trimmedExpr);
if (!boost::istarts_with(trimmedExpr, "in"))
diff --git a/src/uscxml/plugins/datamodel/null/NULLDataModel.h b/src/uscxml/plugins/datamodel/null/NULLDataModel.h
index 781bb99..7ce9fde 100644
--- a/src/uscxml/plugins/datamodel/null/NULLDataModel.h
+++ b/src/uscxml/plugins/datamodel/null/NULLDataModel.h
@@ -76,7 +76,7 @@ public:
virtual void eval(const Arabica::DOM::Element<std::string>& scriptElem,
const std::string& expr);
virtual std::string evalAsString(const std::string& expr);
- virtual bool evalAsBool(const std::string& expr);
+ virtual bool evalAsBool(const Arabica::DOM::Node<std::string>& node, const std::string& expr);
virtual double evalAsNumber(const std::string& expr);
protected:
diff --git a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp
index 1c50e1d..02352fc 100644
--- a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp
@@ -360,6 +360,10 @@ void SWIDataModel::eval(const Element<std::string>& scriptElem, const std::strin
}
bool SWIDataModel::evalAsBool(const std::string& expr) {
+ return evalAsBool(Arabica::DOM::Node<std::string>(), expr);
+}
+
+bool SWIDataModel::evalAsBool(const Arabica::DOM::Node<std::string>& node, const std::string& expr) {
SET_PL_CONTEXT
try {
PlCompound compound(expr.c_str());
diff --git a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h
index 8e0a1b3..62a4ab7 100644
--- a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h
+++ b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h
@@ -78,6 +78,7 @@ public:
virtual Data getStringAsData(const std::string& content);
virtual std::string evalAsString(const std::string& expr);
+ virtual bool evalAsBool(const Arabica::DOM::Node<std::string>& node, const std::string& expr);
virtual bool evalAsBool(const std::string& expr);
static foreign_t inPredicate(term_t a0, int arity, void* context);
diff --git a/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp b/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp
index 9f8ff90..e81883a 100644
--- a/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp
@@ -363,6 +363,10 @@ bool XPathDataModel::isDeclared(const std::string& expr) {
}
bool XPathDataModel::evalAsBool(const std::string& expr) {
+ return evalAsBool(Arabica::DOM::Node<std::string>(), expr);
+}
+
+bool XPathDataModel::evalAsBool(const Arabica::DOM::Node<std::string>& node, const std::string& expr) {
// std::cout << std::endl << evalAsString(expr);
XPathValue<std::string> result;
try {
diff --git a/src/uscxml/plugins/datamodel/xpath/XPathDataModel.h b/src/uscxml/plugins/datamodel/xpath/XPathDataModel.h
index 55aca38..ac041f9 100644
--- a/src/uscxml/plugins/datamodel/xpath/XPathDataModel.h
+++ b/src/uscxml/plugins/datamodel/xpath/XPathDataModel.h
@@ -122,6 +122,7 @@ public:
virtual std::string evalAsString(const std::string& expr);
virtual bool evalAsBool(const std::string& expr);
+ virtual bool evalAsBool(const Arabica::DOM::Node<std::string>& node, const std::string& expr);
virtual double evalAsNumber(const std::string& expr);
protected: