summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Radomski <github@mintwerk.de>2017-05-14 11:42:18 (GMT)
committerStefan Radomski <github@mintwerk.de>2017-05-14 11:42:18 (GMT)
commit56074d3bd2ab4c8220b67b3da56ff55bbb286bae (patch)
treead507c0f39088bb367fe7bb295f9dba0396064d2
parent1453feb7ca59167c219afb21dfba4ed3ea68d176 (diff)
downloaduscxml-56074d3bd2ab4c8220b67b3da56ff55bbb286bae.zip
uscxml-56074d3bd2ab4c8220b67b3da56ff55bbb286bae.tar.gz
uscxml-56074d3bd2ab4c8220b67b3da56ff55bbb286bae.tar.bz2
Beautified code and some light refactoring
-rw-r--r--src/uscxml/interpreter/BasicContentExecutor.cpp3
-rw-r--r--src/uscxml/interpreter/ContentExecutorImpl.h2
-rw-r--r--src/uscxml/plugins/DataModelImpl.h11
-rw-r--r--src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp2
-rw-r--r--test/w3c/lua/test520.scxml.orig21
5 files changed, 10 insertions, 29 deletions
diff --git a/src/uscxml/interpreter/BasicContentExecutor.cpp b/src/uscxml/interpreter/BasicContentExecutor.cpp
index 5defce3..4443237 100644
--- a/src/uscxml/interpreter/BasicContentExecutor.cpp
+++ b/src/uscxml/interpreter/BasicContentExecutor.cpp
@@ -700,8 +700,7 @@ Data BasicContentExecutor::elementAsData(XERCESC_NS::DOMElement* element, bool a
Data d = _callbacks->getAsData(contentSS.str());
if (!d.empty())
return d;
- }
- catch (ErrorEvent &) {
+ } catch (ErrorEvent &) {
return Data(spaceNormalize(contentSS.str()), Data::VERBATIM);
}
}
diff --git a/src/uscxml/interpreter/ContentExecutorImpl.h b/src/uscxml/interpreter/ContentExecutorImpl.h
index 82acc1c..5b39108 100644
--- a/src/uscxml/interpreter/ContentExecutorImpl.h
+++ b/src/uscxml/interpreter/ContentExecutorImpl.h
@@ -59,7 +59,7 @@ public:
uint32_t iteration) = 0;
virtual Data evalAsData(const std::string& expr) = 0;
- virtual void eval(const std::string& expr) { evalAsData(expr); }
+ virtual void eval(const std::string& expr) = 0;
virtual Data getAsData(const std::string& expr) = 0;
virtual void assign(const std::string& location, const Data& data, const std::map<std::string, std::string>& attrs) = 0;
diff --git a/src/uscxml/plugins/DataModelImpl.h b/src/uscxml/plugins/DataModelImpl.h
index 62453a8..e3db75a 100644
--- a/src/uscxml/plugins/DataModelImpl.h
+++ b/src/uscxml/plugins/DataModelImpl.h
@@ -173,10 +173,13 @@ public:
virtual Data evalAsData(const std::string& content) = 0;
/**
- * evaluating script content without return
- * @param mostly used in script content.
- */
- virtual void eval(const std::string& content) { evalAsData(content); }
+ * Evaluating an expression
+ * We need an explicit 'eval' function for the LuaDataModel, see issue 118
+ * @param expr An expression in the data-model's language.
+ */
+ virtual void eval(const std::string& content) {
+ evalAsData(content);
+ }
/**
* Evaluate a given expression as a boolean.
diff --git a/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp b/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp
index 8f50729..9dcbc17 100644
--- a/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp
@@ -82,7 +82,7 @@ static Data getLuaAsData(lua_State* _luaState, const luabridge::LuaRef& lua) {
// we are creating __tmpFunc
// then it will be assigned to data variable
luabridge::setGlobal(_luaState, lua, "__tmpFunc");
-
+
data.atom = "__tmpFunc";
data.type = Data::INTERPRETED;
} else if(lua.isLightUserdata() || lua.isUserdata()) {
diff --git a/test/w3c/lua/test520.scxml.orig b/test/w3c/lua/test520.scxml.orig
deleted file mode 100644
index 9c91eda..0000000
--- a/test/w3c/lua/test520.scxml.orig
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?><!-- test that that <content> gets sent as the body of the message. --><scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" initial="s0" datamodel="lua" version="1.0">
-
-
-<state id="s0">
- <onentry>
- <send event="timeout" delay="30s"/>
- <send targetexpr="_ioprocessors.basichttp.location" type="http://www.w3.org/TR/scxml/#BasicHTTPEventProcessor">
- <content>this is some content</content>
- </send>
- </onentry>
-
- <!-- if other end sends us back this event, we succeed. Test for two common
- ways of encoding -->
- <transition event="HTTP.POST" cond="string.find(_event.raw, 'this+is+some+content')" target="pass"/>
- <transition event="HTTP.POST" cond="string.find(_event.raw, 'this%20is%20some%20content')" target="pass"/>
- <transition event="*" target="fail"/>
- </state>
-
- <final xmlns:scxml="http://www.w3.org/2005/07/scxml" id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
- <final xmlns:scxml="http://www.w3.org/2005/07/scxml" id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>
-</scxml> \ No newline at end of file