diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-10-27 20:26:07 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-10-27 20:26:07 (GMT) |
commit | 0a9c4c2e8f10de0323503fd5f2b11f31314b380c (patch) | |
tree | 2d5f6c0659df463b103fe376af72ce5ab173b5cf /src/uscxml/plugins | |
parent | 1e42b29439d247598d58aac10f62c77cf2f31f12 (diff) | |
download | uscxml-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/uscxml/plugins')
11 files changed, 25 insertions, 7 deletions
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: |