diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-07-23 11:05:27 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-07-23 11:05:27 (GMT) |
commit | 4a1d9cd369c3a799f4485cf07c4f9d3c231bef7c (patch) | |
tree | 00ed65dfdc9303b884104ccde2a1e32a8f550315 | |
parent | a84db30b735877a0bdacebd590acea07e3f140a1 (diff) | |
download | uscxml-4a1d9cd369c3a799f4485cf07c4f9d3c231bef7c.zip uscxml-4a1d9cd369c3a799f4485cf07c4f9d3c231bef7c.tar.gz uscxml-4a1d9cd369c3a799f4485cf07c4f9d3c231bef7c.tar.bz2 |
Introduced type="query" attribute for prolog script element
13 files changed, 107 insertions, 72 deletions
diff --git a/src/uscxml/Factory.h b/src/uscxml/Factory.h index 2a0ec43..9507d07 100644 --- a/src/uscxml/Factory.h +++ b/src/uscxml/Factory.h @@ -265,7 +265,9 @@ public: virtual void pushContext() = 0; virtual void popContext() = 0; - virtual void eval(const std::string& expr) = 0; + virtual void eval(const Arabica::DOM::Element<std::string>& scriptElem, + const std::string& expr) = 0; + virtual std::string evalAsString(const std::string& expr) = 0; virtual bool evalAsBool(const std::string& expr) = 0; @@ -326,8 +328,9 @@ public: return _impl->popContext(); } - virtual void eval(const std::string& expr) { - return _impl->eval(expr); + virtual void eval(const Arabica::DOM::Element<std::string>& scriptElem, + const std::string& expr) { + return _impl->eval(scriptElem, expr); } virtual std::string evalAsString(const std::string& expr) { return _impl->evalAsString(expr); diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp index 9d9115f..16fb503 100644 --- a/src/uscxml/Interpreter.cpp +++ b/src/uscxml/Interpreter.cpp @@ -1122,7 +1122,7 @@ void InterpreterImpl::executeContent(const Arabica::DOM::Node<std::string>& cont try { - _dataModel.eval(srcContent.str()); + _dataModel.eval((Element<std::string>)content, srcContent.str()); } CATCH_AND_DISTRIBUTE("Syntax error while executing script element from '" << ATTR(content, "src") << "':") } else { @@ -1130,7 +1130,7 @@ void InterpreterImpl::executeContent(const Arabica::DOM::Node<std::string>& cont // search for the text node with the actual script if (content.getFirstChild().getNodeType() == Node_base::TEXT_NODE) { try { - _dataModel.eval(content.getFirstChild().getNodeValue()); + _dataModel.eval((Element<std::string>)content, content.getFirstChild().getNodeValue()); } CATCH_AND_DISTRIBUTE("Syntax error while executing script element") } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp index 47ec21d..2143f5f 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp @@ -13,6 +13,9 @@ namespace uscxml { +using namespace Arabica::XPath; +using namespace Arabica::DOM; + #ifdef BUILD_AS_PLUGINS PLUMA_CONNECTOR bool connect(pluma::Host& host) { @@ -61,8 +64,8 @@ boost::shared_ptr<DataModelImpl> JSCDataModel::create(InterpreterImpl* interpret dm->_ctx = JSGlobalContextCreate(NULL); dm->_interpreter = interpreter; - dm->_dom = new Arabica::DOM::JSCDOM(); - dm->_dom->xpath = new Arabica::XPath::XPath<std::string>(); + dm->_dom = new JSCDOM(); + dm->_dom->xpath = new XPath<std::string>(); dm->_dom->xpath->setNamespaceContext(interpreter->getNSContext()); // introduce global functions as objects for private data @@ -96,18 +99,18 @@ boost::shared_ptr<DataModelImpl> JSCDataModel::create(InterpreterImpl* interpret JSStringRelease(sessionIdName); JSStringRelease(sessionId); - Arabica::DOM::JSCDocument::JSCDocumentPrivate* privData = new Arabica::DOM::JSCDocument::JSCDocumentPrivate(); + JSCDocument::JSCDocumentPrivate* privData = new JSCDocument::JSCDocumentPrivate(); if (interpreter) { - privData->nativeObj = new Arabica::DOM::Document<std::string>(interpreter->getDocument()); + privData->nativeObj = new Document<std::string>(interpreter->getDocument()); privData->dom = dm->_dom; - JSObjectRef documentObject = JSObjectMake(dm->_ctx, Arabica::DOM::JSCDocument::getTmpl(), privData); + JSObjectRef documentObject = JSObjectMake(dm->_ctx, JSCDocument::getTmpl(), privData); JSObjectRef globalObject = JSContextGetGlobalObject(dm->_ctx); JSObjectSetProperty(dm->_ctx, globalObject, JSStringCreateWithUTF8CString("document"), documentObject, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, NULL); } - dm->eval("_invokers = {};"); - dm->eval("_x = {};"); + dm->eval(Element<std::string>(), "_invokers = {};"); + dm->eval(Element<std::string>(), "_x = {};"); return dm; } @@ -123,11 +126,11 @@ void JSCDataModel::popContext() { } void JSCDataModel::setEvent(const Event& event) { - Arabica::DOM::JSCSCXMLEvent::JSCSCXMLEventPrivate* privData = new Arabica::DOM::JSCSCXMLEvent::JSCSCXMLEventPrivate(); + JSCSCXMLEvent::JSCSCXMLEventPrivate* privData = new JSCSCXMLEvent::JSCSCXMLEventPrivate(); privData->nativeObj = new Event(event); privData->dom = _dom; - JSObjectRef eventObj = JSObjectMake(_ctx, Arabica::DOM::JSCSCXMLEvent::getTmpl(), privData); + JSObjectRef eventObj = JSObjectMake(_ctx, JSCSCXMLEvent::getTmpl(), privData); JSObjectRef globalObject = JSContextGetGlobalObject(_ctx); JSValueRef exception = NULL; @@ -355,7 +358,8 @@ bool JSCDataModel::isDeclared(const std::string& expr) { return true; } -void JSCDataModel::eval(const std::string& expr) { +void JSCDataModel::eval(const Element<std::string>& scriptElem, + const std::string& expr) { evalAsValue(expr); } @@ -394,8 +398,8 @@ JSValueRef JSCDataModel::evalAsValue(const std::string& expr, bool dontThrow) { return result; } -void JSCDataModel::assign(const Arabica::DOM::Element<std::string>& assignElem, - const Arabica::DOM::Document<std::string>& doc, +void JSCDataModel::assign(const Element<std::string>& assignElem, + const Document<std::string>& doc, const std::string& content) { std::string key; JSValueRef exception = NULL; @@ -426,13 +430,13 @@ void JSCDataModel::assign(const Arabica::DOM::Element<std::string>& assignElem, } } -JSValueRef JSCDataModel::getDocumentAsValue(const Arabica::DOM::Document<std::string>& doc) { +JSValueRef JSCDataModel::getDocumentAsValue(const Document<std::string>& doc) { - struct Arabica::DOM::JSCDocument::JSCDocumentPrivate* retPrivData = new Arabica::DOM::JSCDocument::JSCDocumentPrivate(); + struct JSCDocument::JSCDocumentPrivate* retPrivData = new JSCDocument::JSCDocumentPrivate(); retPrivData->dom = _dom; - retPrivData->nativeObj = new Arabica::DOM::Document<std::string>(doc); + retPrivData->nativeObj = new Document<std::string>(doc); - JSObjectRef retObj = JSObjectMake(_ctx, Arabica::DOM::JSCDocument::getTmpl(), retPrivData); + JSObjectRef retObj = JSObjectMake(_ctx, JSCDocument::getTmpl(), retPrivData); return retObj; } @@ -443,8 +447,8 @@ void JSCDataModel::assign(const std::string& location, const Data& data) { evalAsValue(location + " = " + ssJSON.str()); } -void JSCDataModel::init(const Arabica::DOM::Element<std::string>& dataElem, - const Arabica::DOM::Document<std::string>& doc, +void JSCDataModel::init(const Element<std::string>& dataElem, + const Document<std::string>& doc, const std::string& content) { try { assign(dataElem, doc, content); diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h index 36765c2..9f254e4 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h @@ -42,7 +42,8 @@ public: virtual void pushContext(); virtual void popContext(); - virtual void eval(const std::string& expr); + 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); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp index 420f1bb..2eb41db 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp @@ -14,6 +14,9 @@ namespace uscxml { +using namespace Arabica::XPath; +using namespace Arabica::DOM; + #ifdef BUILD_AS_PLUGINS PLUMA_CONNECTOR bool connect(pluma::Host& host) { @@ -32,9 +35,9 @@ boost::shared_ptr<DataModelImpl> V8DataModel::create(InterpreterImpl* interprete v8::Locker locker; v8::HandleScope scope; - dm->_dom = new Arabica::DOM::V8DOM(); + dm->_dom = new V8DOM(); // dom->interpreter = interpreter; - dm->_dom->xpath = new Arabica::XPath::XPath<std::string>(); + dm->_dom->xpath = new XPath<std::string>(); dm->_dom->xpath->setNamespaceContext(interpreter->getNSContext()); // see http://stackoverflow.com/questions/3171418/v8-functiontemplate-class-instance @@ -48,13 +51,13 @@ boost::shared_ptr<DataModelImpl> V8DataModel::create(InterpreterImpl* interprete v8::Context::Scope contextScope(context); // instantiate the document function - v8::Handle<v8::Function> docCtor = Arabica::DOM::V8Document::getTmpl()->GetFunction(); + v8::Handle<v8::Function> docCtor = V8Document::getTmpl()->GetFunction(); v8::Handle<v8::Object> docObj = docCtor->NewInstance(); - Arabica::DOM::V8Document::V8DocumentPrivate* privData = new Arabica::DOM::V8Document::V8DocumentPrivate(); - privData->nativeObj = new Arabica::DOM::Document<std::string>(interpreter->getDocument()); + V8Document::V8DocumentPrivate* privData = new V8Document::V8DocumentPrivate(); + privData->nativeObj = new Document<std::string>(interpreter->getDocument()); privData->dom = dm->_dom; - docObj->SetInternalField(0, Arabica::DOM::V8DOM::toExternal(privData)); + docObj->SetInternalField(0, V8DOM::toExternal(privData)); context->Global()->Set(v8::String::New("document"), docObj); @@ -74,8 +77,8 @@ boost::shared_ptr<DataModelImpl> V8DataModel::create(InterpreterImpl* interprete dm->_contexts.push_back(context); // instantiate objects - we have to have a context for that! - dm->eval("_invokers = {};"); - dm->eval("_x = {};"); + dm->eval(Element<std::string>(), "_invokers = {};"); + dm->eval(Element<std::string>(), "_x = {};"); return dm; } @@ -91,7 +94,7 @@ void V8DataModel::setWithException(v8::Local<v8::String> property, v8::Local<v8: } v8::Handle<v8::Value> V8DataModel::getIOProcessors(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - V8DataModel* dataModel = Arabica::DOM::V8DOM::toClassPtr<V8DataModel>(info.Data()); + V8DataModel* dataModel = V8DOM::toClassPtr<V8DataModel>(info.Data()); if (dataModel->_ioProcessors.IsEmpty()) { dataModel->_ioProcessors = v8::Persistent<v8::Object>::New(v8::Object::New()); @@ -135,14 +138,14 @@ void V8DataModel::setEvent(const Event& event) { v8::Context::Scope contextScope(_contexts.front()); v8::Handle<v8::Object> global = _contexts.front()->Global(); - v8::Handle<v8::Function> eventCtor = Arabica::DOM::V8SCXMLEvent::getTmpl()->GetFunction(); + v8::Handle<v8::Function> eventCtor = V8SCXMLEvent::getTmpl()->GetFunction(); v8::Persistent<v8::Object> eventObj = v8::Persistent<v8::Object>::New(eventCtor->NewInstance()); - Arabica::DOM::V8SCXMLEvent::V8SCXMLEventPrivate* privData = new Arabica::DOM::V8SCXMLEvent::V8SCXMLEventPrivate(); + V8SCXMLEvent::V8SCXMLEventPrivate* privData = new V8SCXMLEvent::V8SCXMLEventPrivate(); privData->nativeObj = new Event(event); privData->dom = _dom; - eventObj->SetInternalField(0, Arabica::DOM::V8DOM::toExternal(privData)); - eventObj.MakeWeak(0, Arabica::DOM::V8SCXMLEvent::jsDestructor); + eventObj->SetInternalField(0, V8DOM::toExternal(privData)); + eventObj.MakeWeak(0, V8SCXMLEvent::jsDestructor); if (event.dom) { eventObj->Set(v8::String::New("data"), getDocumentAsValue(event.dom)); @@ -261,16 +264,16 @@ Data V8DataModel::getValueAsData(const v8::Handle<v8::Value>& value, std::set<v8 return data; } -v8::Handle<v8::Value> V8DataModel::getDocumentAsValue(const Arabica::DOM::Document<std::string>& doc) { - v8::Handle<v8::Function> retCtor = Arabica::DOM::V8Document::getTmpl()->GetFunction(); +v8::Handle<v8::Value> V8DataModel::getDocumentAsValue(const Document<std::string>& doc) { + v8::Handle<v8::Function> retCtor = V8Document::getTmpl()->GetFunction(); v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); - struct Arabica::DOM::V8Document::V8DocumentPrivate* retPrivData = new Arabica::DOM::V8Document::V8DocumentPrivate(); + struct V8Document::V8DocumentPrivate* retPrivData = new V8Document::V8DocumentPrivate(); retPrivData->dom = _dom; - retPrivData->nativeObj = new Arabica::DOM::Document<std::string>(doc); + retPrivData->nativeObj = new Document<std::string>(doc); - retObj->SetInternalField(0, Arabica::DOM::V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, Arabica::DOM::V8Document::jsDestructor); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj.MakeWeak(0, V8Document::jsDestructor); return retObj; } @@ -363,7 +366,8 @@ void V8DataModel::setForeach(const std::string& item, } } -void V8DataModel::eval(const std::string& expr) { +void V8DataModel::eval(const Element<std::string>& scriptElem, + const std::string& expr) { v8::Locker locker; v8::HandleScope handleScope; v8::Context::Scope contextScope(_contexts.back()); @@ -411,19 +415,19 @@ std::string V8DataModel::evalAsString(const std::string& expr) { v8::Local<v8::Object> obj = result->ToObject(); v8::Local<v8::Object> proto; - proto = obj->FindInstanceInPrototypeChain(Arabica::DOM::V8Document::getTmpl()); + proto = obj->FindInstanceInPrototypeChain(V8Document::getTmpl()); if (!proto.IsEmpty()) { - struct Arabica::DOM::V8Document::V8DocumentPrivate* privData = - Arabica::DOM::V8DOM::toClassPtr<Arabica::DOM::V8Document::V8DocumentPrivate >(obj->GetInternalField(0)); + struct V8Document::V8DocumentPrivate* privData = + V8DOM::toClassPtr<V8Document::V8DocumentPrivate >(obj->GetInternalField(0)); std::stringstream ss; ss << privData->nativeObj->getDocumentElement(); return ss.str(); } - proto = obj->FindInstanceInPrototypeChain(Arabica::DOM::V8Node::getTmpl()); + proto = obj->FindInstanceInPrototypeChain(V8Node::getTmpl()); if (!proto.IsEmpty()) { - struct Arabica::DOM::V8Node::V8NodePrivate* privData = - Arabica::DOM::V8DOM::toClassPtr<Arabica::DOM::V8Node::V8NodePrivate >(obj->GetInternalField(0)); + struct V8Node::V8NodePrivate* privData = + V8DOM::toClassPtr<V8Node::V8NodePrivate >(obj->GetInternalField(0)); std::stringstream ss; ss << privData->nativeObj; return ss.str(); @@ -450,8 +454,8 @@ double V8DataModel::evalAsNumber(const std::string& expr) { return 0; } -void V8DataModel::assign(const Arabica::DOM::Element<std::string>& assignElem, - const Arabica::DOM::Document<std::string>& doc, +void V8DataModel::assign(const Element<std::string>& assignElem, + const Document<std::string>& doc, const std::string& content) { v8::Locker locker; v8::HandleScope handleScope; @@ -493,8 +497,8 @@ void V8DataModel::assign(const std::string& location, evalAsValue(location + " = " + ssJSON.str()); } -void V8DataModel::init(const Arabica::DOM::Element<std::string>& dataElem, - const Arabica::DOM::Document<std::string>& doc, +void V8DataModel::init(const Element<std::string>& dataElem, + const Document<std::string>& doc, const std::string& content) { try { assign(dataElem, doc, content); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h index 548cf20..da69c4f 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h @@ -47,7 +47,8 @@ public: return true; } - virtual void eval(const std::string& expr); + virtual void eval(const Arabica::DOM::Element<std::string>& scriptElem, + const std::string& expr); virtual void assign(const Arabica::DOM::Element<std::string>& assignElem, const Arabica::DOM::Document<std::string>& doc, const std::string& content); diff --git a/src/uscxml/plugins/datamodel/null/NULLDataModel.cpp b/src/uscxml/plugins/datamodel/null/NULLDataModel.cpp index dac3386..53eaffa 100644 --- a/src/uscxml/plugins/datamodel/null/NULLDataModel.cpp +++ b/src/uscxml/plugins/datamodel/null/NULLDataModel.cpp @@ -61,7 +61,8 @@ void NULLDataModel::setForeach(const std::string& item, uint32_t iteration) { } -void NULLDataModel::eval(const std::string& expr) { +void NULLDataModel::eval(const Arabica::DOM::Element<std::string>& scriptElem, + const std::string& expr) { } bool NULLDataModel::isDeclared(const std::string& expr) { diff --git a/src/uscxml/plugins/datamodel/null/NULLDataModel.h b/src/uscxml/plugins/datamodel/null/NULLDataModel.h index 3d86bf2..924bc8c 100644 --- a/src/uscxml/plugins/datamodel/null/NULLDataModel.h +++ b/src/uscxml/plugins/datamodel/null/NULLDataModel.h @@ -54,7 +54,8 @@ public: virtual Data getStringAsData(const std::string& content); virtual bool isDeclared(const std::string& expr); - virtual void eval(const std::string& expr); + 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 double evalAsNumber(const std::string& expr); diff --git a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp index 2e37b29..2f43c73 100644 --- a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp +++ b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp @@ -10,6 +10,9 @@ namespace uscxml { +using namespace Arabica::XPath; +using namespace Arabica::DOM; + #ifdef BUILD_AS_PLUGINS PLUMA_CONNECTOR bool connect(pluma::Host& host) { @@ -86,7 +89,7 @@ boost::shared_ptr<DataModelImpl> SWIDataModel::create(InterpreterImpl* interpret foreign_t SWIDataModel::inPredicate(term_t a0, int arity, void* context) { char *s; if ( PL_get_atom_chars(a0, &s) ) { - Arabica::XPath::NodeSet<std::string> config = _swiInterpreterPtr->getConfiguration(); + NodeSet<std::string> config = _swiInterpreterPtr->getConfiguration(); for (int i = 0; i < config.size(); i++) { if (HAS_ATTR(config[i], "id") && strcmp(ATTR(config[i], "id").c_str(), s) == 0) { return TRUE; @@ -258,9 +261,13 @@ void SWIDataModel::setForeach(const std::string& item, } } -void SWIDataModel::eval(const std::string& expr) { - URL localPLFile = URL::toLocalFile(expr, ".pl"); - PlCall("user", "load_files", PlTermv(localPLFile.asLocalFile(".pl").c_str())) || LOG(ERROR) << "Could not execute prolog from file"; +void SWIDataModel::eval(const Element<std::string>& scriptElem, const std::string& expr) { + if (scriptElem && HAS_ATTR(scriptElem, "type") && boost::iequals(ATTR(scriptElem, "type"), "query")) { + evalAsBool(expr); + } else { + URL localPLFile = URL::toLocalFile(expr, ".pl"); + PlCall("user", "load_files", PlTermv(localPLFile.asLocalFile(".pl").c_str())) || LOG(ERROR) << "Could not execute prolog from file"; + } } bool SWIDataModel::evalAsBool(const std::string& expr) { @@ -333,8 +340,8 @@ std::map<std::string, PlTerm> SWIDataModel::resolveAtoms(PlTerm& term, PlTerm& o return atoms; } -void SWIDataModel::assign(const Arabica::DOM::Element<std::string>& assignElem, - const Arabica::DOM::Document<std::string>& doc, +void SWIDataModel::assign(const Element<std::string>& assignElem, + const Document<std::string>& doc, const std::string& content) { std::string expr = content; std::string predicate; @@ -365,7 +372,7 @@ void SWIDataModel::assign(const Arabica::DOM::Element<std::string>& assignElem, if (doc) { std::stringstream dataInitStr; std::stringstream xmlDoc; - Arabica::DOM::Node<std::string> node = Event::getFirstDOMElement(doc); + Node<std::string> node = Event::getFirstDOMElement(doc); while(node) { xmlDoc << node; node = node.getNextSibling(); @@ -394,7 +401,7 @@ void SWIDataModel::assign(const Arabica::DOM::Element<std::string>& assignElem, } } else if (expr.length() > 0) { if (boost::equals(TAGNAME(assignElem), "data")) { - eval(expr); + eval(assignElem, expr); } else { std::stringstream exprStream(expr); std::string item; @@ -409,11 +416,11 @@ void SWIDataModel::assign(const Arabica::DOM::Element<std::string>& assignElem, } void SWIDataModel::assign(const std::string& location, const Data& data) { - eval(data.atom); + eval(Element<std::string>(), data.atom); } -void SWIDataModel::init(const Arabica::DOM::Element<std::string>& dataElem, - const Arabica::DOM::Document<std::string>& doc, +void SWIDataModel::init(const Element<std::string>& dataElem, + const Document<std::string>& doc, const std::string& content) { assign(dataElem, doc, content); } diff --git a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h index 504dd3a..f391139 100644 --- a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h +++ b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h @@ -51,7 +51,9 @@ public: const std::string& content); virtual void init(const std::string& location, const Data& data); - virtual void eval(const std::string& expr); + virtual void eval(const Arabica::DOM::Element<std::string>& scriptElem, + const std::string& expr); + virtual bool isDeclared(const std::string& expr); virtual Data getStringAsData(const std::string& content); diff --git a/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp b/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp index 1de9c1b..1f6a7cc 100644 --- a/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp +++ b/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp @@ -299,7 +299,8 @@ bool XPathDataModel::isValidIdentifier(const std::string& identifier) { } -void XPathDataModel::eval(const std::string& expr) { +void XPathDataModel::eval(const Arabica::DOM::Element<std::string>& scriptElem, + const std::string& expr) { XPathValue<std::string> result = _xpath.evaluate_expr(expr, _doc); } diff --git a/src/uscxml/plugins/datamodel/xpath/XPathDataModel.h b/src/uscxml/plugins/datamodel/xpath/XPathDataModel.h index 104d100..761661a 100644 --- a/src/uscxml/plugins/datamodel/xpath/XPathDataModel.h +++ b/src/uscxml/plugins/datamodel/xpath/XPathDataModel.h @@ -86,7 +86,8 @@ public: virtual void pushContext(); virtual void popContext(); - virtual void eval(const std::string& expr); + virtual void eval(const Arabica::DOM::Element<std::string>& scriptElem, + const std::string& expr); virtual void assign(const Arabica::DOM::Element<std::string>& assignElem, const Arabica::DOM::Document<std::string>& doc, const std::string& content); diff --git a/test/samples/uscxml/test-prolog.scxml b/test/samples/uscxml/test-prolog.scxml index def23db..ea2365e 100644 --- a/test/samples/uscxml/test-prolog.scxml +++ b/test/samples/uscxml/test-prolog.scxml @@ -1,6 +1,6 @@ <scxml datamodel="prolog"> <datamodel> - <data src="" /> + <data src="" /> <data id="father"> bob, jim. bob, john. @@ -22,6 +22,15 @@ </datamodel> <state id="s1"> <onentry> + <log label="Entering s1" expr="listing." /> + <script> + :- dynamic ampel/1. + ampel(false). + ampel(X) :- retract(ampel(_)), assertz(ampel(X)). + </script> + <script type="query"> + ampel(true). + </script> <assign location=""> retract(father(bob, jim)). assert(father(steve, jim)). |