summaryrefslogtreecommitdiffstats
path: root/src/uscxml/plugins
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2014-12-14 13:20:04 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2014-12-14 13:20:04 (GMT)
commit330576fcb4d97504e0d6951067b753499d91b541 (patch)
tree9c583dd3e13ff574295f559a7b92dfe9a1dafd2d /src/uscxml/plugins
parent9608216597fd17021d38e80689644beb3c85abb9 (diff)
downloaduscxml-330576fcb4d97504e0d6951067b753499d91b541.zip
uscxml-330576fcb4d97504e0d6951067b753499d91b541.tar.gz
uscxml-330576fcb4d97504e0d6951067b753499d91b541.tar.bz2
Renamed URI to URL
Some fixes for Xincludes
Diffstat (limited to 'src/uscxml/plugins')
-rw-r--r--src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp64
-rw-r--r--src/uscxml/plugins/datamodel/promela/PromelaParser.h5
-rw-r--r--src/uscxml/plugins/element/fetch/FetchElement.cpp2
-rw-r--r--src/uscxml/plugins/invoker/audio/OpenALInvoker.cpp2
-rw-r--r--src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.cpp2
-rw-r--r--src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp2
-rw-r--r--src/uscxml/plugins/invoker/miles/MilesSessionInvoker.cpp2
-rw-r--r--src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp6
-rw-r--r--src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp6
9 files changed, 43 insertions, 48 deletions
diff --git a/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp b/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp
index 5b3c79c..9edd505 100644
--- a/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp
@@ -276,7 +276,6 @@ std::string PromelaDataModel::evalAsString(const std::string& expr) {
void PromelaDataModel::assign(const Element<std::string>& assignElem,
const Node<std::string>& node,
const std::string& content) {
- std::string expr;
std::string key;
std::string value;
@@ -299,32 +298,18 @@ void PromelaDataModel::assign(const Element<std::string>& assignElem,
value = content;
}
- if (key.length() > 0) {
- PromelaParser parser(key);
-
- // declaration is an array?
- if (parser.ast->operands.size() > 0 &&
- parser.ast->operands.back()->operands.size() > 0 &&
- parser.ast->operands.back()->operands.back()->type == PML_VAR_ARRAY) {
- evaluateDecl(parser.ast);
- expr = content;
- } else if (value.length() > 0) {
- expr = key + " = " + value + ";";
- } else {
- // declaration
- expr = key + ";";
- }
+ if (value.length() == 0)
+ return;
+
+ Data json = Data::fromJSON(value);
+ if (!json.empty()) {
+ // simply assign from json to key
+ assign(key, json);
} else {
- expr = content;
- }
-
- PromelaParser parser(expr, 2, PromelaParser::PROMELA_DECL, PromelaParser::PROMELA_STMNT);
- if (parser.type == PromelaParser::PROMELA_DECL)
- evaluateDecl(parser.ast);
- if (parser.type == PromelaParser::PROMELA_STMNT)
+ std::string expr = key + " = " + value;
+ PromelaParser parser(expr, 1, PromelaParser::PROMELA_STMNT);
evaluateStmnt(parser.ast);
-// parser.dump();
-// std::cout << Data::toJSON(_variables) << std::endl;
+ }
}
void PromelaDataModel::evaluateDecl(const std::string& expr) {
@@ -510,9 +495,9 @@ Data PromelaDataModel::evaluateExpr(void* ast) {
PromelaParserNode* lhs = *opIter++;
PromelaParserNode* rhs = *opIter++;
- std::cout << "-----" << std::endl;
- lhs->dump();
- rhs->dump();
+// std::cout << "-----" << std::endl;
+// lhs->dump();
+// rhs->dump();
Data left = evaluateExpr(lhs);
Data right = evaluateExpr(rhs);
@@ -548,7 +533,18 @@ void PromelaDataModel::evaluateStmnt(void* ast) {
}
break;
}
+ case PML_INCR: {
+ PromelaParserNode* name = *opIter++;
+ setVariable(name, strTo<long>(getVariable(name)) + 1);
+ break;
+ }
+ case PML_DECR: {
+ PromelaParserNode* name = *opIter++;
+ setVariable(name, strTo<long>(getVariable(name)) - 1);
+ break;
+ }
default:
+ node->dump();
ERROR_EXECUTION_THROW("No support for " + PromelaParserNode::typeToDesc(node->type) + " statement implemented");
}
}
@@ -714,7 +710,6 @@ void PromelaDataModel::init(const Element<std::string>& dataElem,
const std::string& content) {
// from <datamodel>
if (HAS_ATTR(dataElem, "id")) {
- Element<std::string> dataElemCopy = dataElem;
std::string identifier = ATTR(dataElem, "id");
std::string type = (HAS_ATTR(dataElem, "type") ? ATTR(dataElem, "type") : "int");
std::string arrSize;
@@ -725,14 +720,11 @@ void PromelaDataModel::init(const Element<std::string>& dataElem,
type = type.substr(0, bracketPos);
}
- dataElemCopy.setAttribute("id", type + " " + identifier + arrSize);
-
- assign(dataElemCopy, node, content);
- dataElemCopy.setAttribute("id", identifier);
-
- return;
+ std::string expr = type + " " + identifier + arrSize;
+ PromelaParser parser(expr, 1, PromelaParser::PROMELA_DECL);
+ evaluateDecl(parser.ast);
+
}
-
assign(dataElem, node, content);
}
void PromelaDataModel::init(const std::string& location, const Data& data) {
diff --git a/src/uscxml/plugins/datamodel/promela/PromelaParser.h b/src/uscxml/plugins/datamodel/promela/PromelaParser.h
index 303b9be..d1683b9 100644
--- a/src/uscxml/plugins/datamodel/promela/PromelaParser.h
+++ b/src/uscxml/plugins/datamodel/promela/PromelaParser.h
@@ -82,7 +82,10 @@ public:
Type type;
Event pendingException;
-
+ operator bool() const {
+ return ast != NULL;
+ }
+
protected:
void init(const std::string& expr);
diff --git a/src/uscxml/plugins/element/fetch/FetchElement.cpp b/src/uscxml/plugins/element/fetch/FetchElement.cpp
index 9f97ca9..c042802 100644
--- a/src/uscxml/plugins/element/fetch/FetchElement.cpp
+++ b/src/uscxml/plugins/element/fetch/FetchElement.cpp
@@ -112,7 +112,7 @@ void FetchElement::enterElement(const Arabica::DOM::Element<std::string>& node)
_targetUrl = URL(_target);
if (!_targetUrl.isAbsolute()) {
- if (!_targetUrl.toAbsolute(_interpreter->getBaseURI())) {
+ if (!_targetUrl.toAbsolute(_interpreter->getBaseURL(node))) {
LOG(ERROR) << "Cannot transform " << _target << " into absolute URL";
return;
}
diff --git a/src/uscxml/plugins/invoker/audio/OpenALInvoker.cpp b/src/uscxml/plugins/invoker/audio/OpenALInvoker.cpp
index 004eb84..e813f2f 100644
--- a/src/uscxml/plugins/invoker/audio/OpenALInvoker.cpp
+++ b/src/uscxml/plugins/invoker/audio/OpenALInvoker.cpp
@@ -94,7 +94,7 @@ void OpenALInvoker::send(const SendRequest& req) {
}
URL srcURL = req.params.find("src")->second.atom;
- if (!srcURL.toAbsolute(_interpreter->getBaseURI())) {
+ if (!srcURL.toAbsolute(_interpreter->getBaseURL(req.elem))) {
LOG(ERROR) << "src URL " << req.params.find("src")->second << " is relative with no base URI set for interpreter";
return;
}
diff --git a/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.cpp b/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.cpp
index c808192..63d1628 100644
--- a/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.cpp
+++ b/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.cpp
@@ -138,7 +138,7 @@ void DirMonInvoker::invoke(const InvokeRequest& req) {
while(dirIter != req.params.upper_bound("dir")) {
// this is simplified - Data might be more elaborate than a simple string atom
URL url(dirIter->second.atom);
- if (!url.toAbsolute(_interpreter->getBaseURI()) || !iequals(url.scheme(), "file")) {
+ if (!url.toAbsolute(_interpreter->getBaseURL(req.elem)) || !iequals(url.scheme(), "file")) {
LOG(ERROR) << "Given directory '" << dirIter->second << "' cannot be transformed to absolute path";
} else {
_dir = url.path();
diff --git a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp
index dac4f99..9315185 100644
--- a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp
+++ b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp
@@ -394,7 +394,7 @@ void OSGInvoker::processNode(const Arabica::DOM::Element<std::string>& element)
}
URL srcURI(filename);
- if (!srcURI.toAbsolute(_interpreter->getBaseURI())) {
+ if (!srcURI.toAbsolute(_interpreter->getBaseURL(element))) {
LOG(ERROR) << "invoke element has relative src URI with no baseURI set.";
return;
}
diff --git a/src/uscxml/plugins/invoker/miles/MilesSessionInvoker.cpp b/src/uscxml/plugins/invoker/miles/MilesSessionInvoker.cpp
index 7b45f2c..7b12ddd 100644
--- a/src/uscxml/plugins/invoker/miles/MilesSessionInvoker.cpp
+++ b/src/uscxml/plugins/invoker/miles/MilesSessionInvoker.cpp
@@ -456,7 +456,7 @@ void MilesSessionInvoker::processEventThumbnail(const std::string& origin, const
testImageName << "test" << _imageSeq << ".jpeg";
URL imageURL(testImageName.str());
- imageURL.toAbsolute(_interpreter->getBaseURI());
+ imageURL.toAbsolute(_interpreter->getBaseURL());
std::stringstream ssImage;
ssImage << imageURL;
std::string imageContent = ssImage.str();
diff --git a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp
index 84e5520..79b1829 100644
--- a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp
+++ b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp
@@ -74,7 +74,7 @@ void USCXMLInvoker::cancel(const std::string sendId) {
void USCXMLInvoker::invoke(const InvokeRequest& req) {
_cancelled = false;
if (req.src.length() > 0) {
- _invokedInterpreter = Interpreter::fromURI(req.src);
+ _invokedInterpreter = Interpreter::fromURL(req.src);
} else if (req.dom) {
Arabica::DOM::DOMImplementation<std::string> domFactory = Arabica::SimpleDOM::DOMImplementation<std::string>::getDOMImplementation();
Arabica::DOM::Document<std::string> dom = domFactory.createDocument(req.dom.getNamespaceURI(), "", 0);
@@ -82,9 +82,9 @@ void USCXMLInvoker::invoke(const InvokeRequest& req) {
Arabica::DOM::Node<std::string> newNode = dom.importNode(req.dom, true);
dom.appendChild(newNode);
// TODO: where do we get the namespace from?
- _invokedInterpreter = Interpreter::fromDOM(dom, _interpreter->getNameSpaceInfo(), _interpreter->getSourceURI());
+ _invokedInterpreter = Interpreter::fromDOM(dom, _interpreter->getNameSpaceInfo(), _interpreter->getSourceURL());
} else if (req.content.size() > 0) {
- _invokedInterpreter = Interpreter::fromXML(req.content, _interpreter->getSourceURI());
+ _invokedInterpreter = Interpreter::fromXML(req.content, _interpreter->getSourceURL());
} else {
LOG(ERROR) << "Cannot invoke nested SCXML interpreter, neither src attribute nor content nor DOM is given";
}
diff --git a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp
index 61008ff..5fd325d 100644
--- a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp
+++ b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp
@@ -187,11 +187,11 @@ void UmundoInvoker::invoke(const InvokeRequest& req) {
std::list<std::string>::const_iterator typeIter = type.begin();
while(typeIter != type.end()) {
URL typeURI(*typeIter);
- if (typeURI.toAbsolute(_interpreter->getBaseURI())) {
+ if (typeURI.toAbsolute(_interpreter->getBaseURL(req.elem))) {
std::string filename = typeURI.asLocalFile(".proto");
umundo::PBSerializer::addProto(filename);
} else {
- LOG(ERROR) << "umundo invoker has relative type src but nor baseURI set with interpreter.";
+ LOG(ERROR) << "umundo invoker has relative type src but no baseURI set with interpreter.";
}
typeIter++;
}
@@ -202,7 +202,7 @@ void UmundoInvoker::invoke(const InvokeRequest& req) {
std::list<std::string>::const_iterator typesIter = types.begin();
while(typesIter != types.end()) {
URL typeURI(*typesIter);
- if (typeURI.toAbsolute(_interpreter->getBaseURI())) {
+ if (typeURI.toAbsolute(_interpreter->getBaseURL(req.elem))) {
umundo::PBSerializer::addProto(typeURI.path());
} else {
LOG(ERROR) << "invoke element has relative src URI with no baseURI set.";