summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/uscxml/interpreter/BasicContentExecutor.cpp2
-rw-r--r--src/uscxml/interpreter/ContentExecutorImpl.h1
-rw-r--r--src/uscxml/interpreter/InterpreterImpl.h4
-rw-r--r--src/uscxml/plugins/DataModel.cpp4
-rw-r--r--src/uscxml/plugins/DataModel.h2
-rw-r--r--src/uscxml/plugins/DataModelImpl.h6
-rw-r--r--src/uscxml/plugins/datamodel/c89/C89DataModel.h1
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h1
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h1
-rw-r--r--src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp46
-rw-r--r--src/uscxml/plugins/datamodel/lua/LuaDataModel.h1
-rw-r--r--src/uscxml/plugins/datamodel/null/NullDataModel.h3
-rw-r--r--src/uscxml/plugins/datamodel/promela/PromelaDataModel.h1
13 files changed, 37 insertions, 36 deletions
diff --git a/src/uscxml/interpreter/BasicContentExecutor.cpp b/src/uscxml/interpreter/BasicContentExecutor.cpp
index 7ffda91..96777b1 100644
--- a/src/uscxml/interpreter/BasicContentExecutor.cpp
+++ b/src/uscxml/interpreter/BasicContentExecutor.cpp
@@ -291,7 +291,7 @@ void BasicContentExecutor::processLog(XERCESC_NS::DOMElement* content) {
void BasicContentExecutor::processScript(XERCESC_NS::DOMElement* content) {
// download as necessary
std::string scriptContent(X(content->getTextContent()));
- _callbacks->evalAsData(scriptContent);
+ _callbacks->evalAsScript(scriptContent);
}
diff --git a/src/uscxml/interpreter/ContentExecutorImpl.h b/src/uscxml/interpreter/ContentExecutorImpl.h
index 5f0acfe..6afeca8 100644
--- a/src/uscxml/interpreter/ContentExecutorImpl.h
+++ b/src/uscxml/interpreter/ContentExecutorImpl.h
@@ -59,6 +59,7 @@ public:
uint32_t iteration) = 0;
virtual Data evalAsData(const std::string& expr) = 0;
+ virtual void evalAsScript(const std::string& content) = 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/interpreter/InterpreterImpl.h b/src/uscxml/interpreter/InterpreterImpl.h
index a68298b..aa439c0 100644
--- a/src/uscxml/interpreter/InterpreterImpl.h
+++ b/src/uscxml/interpreter/InterpreterImpl.h
@@ -187,6 +187,10 @@ public:
return _dataModel.evalAsData(expr);
}
+ virtual void evalAsScript(const std::string& content) {
+ _dataModel.evalAsScript(content);
+ }
+
virtual Data getAsData(const std::string& expr) {
return _dataModel.getAsData(expr);
}
diff --git a/src/uscxml/plugins/DataModel.cpp b/src/uscxml/plugins/DataModel.cpp
index 07fd4b4..bb1324d 100644
--- a/src/uscxml/plugins/DataModel.cpp
+++ b/src/uscxml/plugins/DataModel.cpp
@@ -42,6 +42,10 @@ Data DataModel::evalAsData(const std::string& content) {
return _impl->evalAsData(content);
}
+void DataModel::evalAsScript(const std::string& content) {
+ _impl->evalAsScript(content);
+}
+
bool DataModel::evalAsBool(const std::string& expr) {
return _impl->evalAsBool(expr);
}
diff --git a/src/uscxml/plugins/DataModel.h b/src/uscxml/plugins/DataModel.h
index 9185cc8..d141f32 100644
--- a/src/uscxml/plugins/DataModel.h
+++ b/src/uscxml/plugins/DataModel.h
@@ -54,6 +54,8 @@ public:
virtual Data getAsData(const std::string& content);
/// @copydoc DataModelImpl::evalAsData()
virtual Data evalAsData(const std::string& content);
+ /// @copydoc DataModelImpl::evalAsScript()
+ virtual void evalAsScript(const std::string& content);
/// @copydoc DataModelImpl::evalAsBool()
virtual bool evalAsBool(const std::string& expr);
diff --git a/src/uscxml/plugins/DataModelImpl.h b/src/uscxml/plugins/DataModelImpl.h
index 8326871..da56bd1 100644
--- a/src/uscxml/plugins/DataModelImpl.h
+++ b/src/uscxml/plugins/DataModelImpl.h
@@ -153,6 +153,12 @@ public:
virtual Data evalAsData(const std::string& content) = 0;
/**
+ * evaluating script content without return
+ * @param mostly script content.
+ */
+ virtual void evalAsScript(const std::string& content) = 0;
+
+ /**
* Evaluate a given expression as a boolean.
* This function is a subset of evalAsData() but saves on creating and copying a Data object.
* @param expr An expression in the data-model's language.
diff --git a/src/uscxml/plugins/datamodel/c89/C89DataModel.h b/src/uscxml/plugins/datamodel/c89/C89DataModel.h
index 4e9eef0..34aaf04 100644
--- a/src/uscxml/plugins/datamodel/c89/C89DataModel.h
+++ b/src/uscxml/plugins/datamodel/c89/C89DataModel.h
@@ -76,6 +76,7 @@ public:
virtual bool evalAsBool(const std::string& expr);
virtual Data evalAsData(const std::string& expr);
+ virtual void evalAsScript(const std::string& content) { evalAsData(content); }
virtual Data getAsData(const std::string& content);
virtual bool isDeclared(const std::string& expr);
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h
index 5a0e830..562593a 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h
@@ -77,6 +77,7 @@ public:
virtual Data getAsData(const std::string& content);
virtual Data evalAsData(const std::string& expr);
+ virtual void evalAsScript(const std::string& content) { evalAsData(content); }
virtual bool evalAsBool(const std::string& expr);
virtual bool isDeclared(const std::string& expr);
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h
index 00a871b..3d3d25f 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h
@@ -70,6 +70,7 @@ public:
virtual bool evalAsBool(const std::string& expr);
virtual Data evalAsData(const std::string& expr);
+ virtual void evalAsScript(const std::string& content) { evalAsData(content); }
virtual Data getAsData(const std::string& content);
virtual bool isDeclared(const std::string& expr);
diff --git a/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp b/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp
index 2071d39..97d3637 100644
--- a/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp
@@ -350,49 +350,25 @@ void LuaDataModel::setEvent(const Event& event) {
Data LuaDataModel::evalAsData(const std::string& content) {
Data data;
- ErrorEvent originalError;
std::string trimmedExpr = boost::trim_copy(content);
- try {
- int retVals = luaEval(_luaState, "return(" + trimmedExpr + ")");
- if (retVals == 1) {
- data = getLuaAsData(_luaState, luabridge::LuaRef::fromStack(_luaState, -1));
- }
- lua_pop(_luaState, retVals);
- return data;
- } catch (ErrorEvent e) {
- originalError = e;
- }
-
- int retVals = 0;
- try {
- // evaluate again without the return()
- retVals = luaEval(_luaState, trimmedExpr);
- } catch (ErrorEvent e) {
- throw originalError; // we will assume syntax error and throw
- }
-
-#if 1
- // Note: Empty result is not an error test302, but how to do test488?
- if (retVals == 0 && !isValidSyntax(trimmedExpr)) {
- throw originalError; // we will assume syntax error and throw
+ int retVals = luaEval(_luaState, "return(" + trimmedExpr + ")");
+ if (retVals == 1) {
+ data = getLuaAsData(_luaState, luabridge::LuaRef::fromStack(_luaState, -1));
}
-#endif
+ lua_pop(_luaState, retVals);
+ return data;
+}
- try {
- if (retVals == 1) {
- data = getLuaAsData(_luaState, luabridge::LuaRef::fromStack(_luaState, -1));
- }
- lua_pop(_luaState, retVals);
- return data;
+void LuaDataModel::evalAsScript(const std::string& content) {
+ Data data;
- } catch (ErrorEvent e) {
- throw e; // we will assume syntax error and throw
- }
+ std::string trimmedExpr = boost::trim_copy(content);
+ int retVals = luaEval(_luaState, trimmedExpr);
- return data;
+ lua_pop(_luaState, retVals);
}
bool LuaDataModel::isValidSyntax(const std::string& expr) {
diff --git a/src/uscxml/plugins/datamodel/lua/LuaDataModel.h b/src/uscxml/plugins/datamodel/lua/LuaDataModel.h
index c64656a..a71a734 100644
--- a/src/uscxml/plugins/datamodel/lua/LuaDataModel.h
+++ b/src/uscxml/plugins/datamodel/lua/LuaDataModel.h
@@ -74,6 +74,7 @@ public:
virtual bool evalAsBool(const std::string& expr);
virtual Data evalAsData(const std::string& expr);
+ virtual void evalAsScript(const std::string& content);
virtual Data getAsData(const std::string& content);
virtual bool isDeclared(const std::string& expr);
diff --git a/src/uscxml/plugins/datamodel/null/NullDataModel.h b/src/uscxml/plugins/datamodel/null/NullDataModel.h
index 8c9f5b9..9a7ea0e 100644
--- a/src/uscxml/plugins/datamodel/null/NullDataModel.h
+++ b/src/uscxml/plugins/datamodel/null/NullDataModel.h
@@ -77,6 +77,9 @@ public:
virtual Data evalAsData(const std::string& content) {
return getAsData(content);
}
+ virtual void evalAsScript(const std::string& content) {
+ getAsData(content);
+ }
virtual std::string evalAsString(const std::string& expr) {
return expr;
}
diff --git a/src/uscxml/plugins/datamodel/promela/PromelaDataModel.h b/src/uscxml/plugins/datamodel/promela/PromelaDataModel.h
index f19bd5d..37a2cf7 100644
--- a/src/uscxml/plugins/datamodel/promela/PromelaDataModel.h
+++ b/src/uscxml/plugins/datamodel/promela/PromelaDataModel.h
@@ -57,6 +57,7 @@ public:
virtual bool evalAsBool(const std::string& expr);
virtual Data evalAsData(const std::string& expr);
+ virtual void evalAsScript(const std::string& expr) { evalAsData(expr); }
virtual Data getAsData(const std::string& content);
virtual bool isDeclared(const std::string& expr);