summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2014-07-23 20:34:15 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2014-07-23 20:34:15 (GMT)
commitafbd0c4463c6f28ec1cd6ea45a68fdbcfcfeae6c (patch)
tree5cfa0f6db2af351c730c230a6d665b51d33cb0c7 /src
parentdc5f5ddfa10bf91524e6f7555c263eaea069dcb0 (diff)
downloaduscxml-afbd0c4463c6f28ec1cd6ea45a68fdbcfcfeae6c.zip
uscxml-afbd0c4463c6f28ec1cd6ea45a68fdbcfcfeae6c.tar.gz
uscxml-afbd0c4463c6f28ec1cd6ea45a68fdbcfcfeae6c.tar.bz2
More work on lua datamodel
Diffstat (limited to 'src')
-rw-r--r--src/uscxml/Interpreter.cpp2
-rw-r--r--src/uscxml/UUID.cpp36
-rw-r--r--src/uscxml/debug/SCXMLDotWriter.cpp108
-rw-r--r--src/uscxml/debug/SCXMLDotWriter.h22
-rw-r--r--src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp81
-rw-r--r--src/uscxml/plugins/datamodel/lua/LuaDataModel.h12
6 files changed, 130 insertions, 131 deletions
diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp
index 5a1df44..8767242 100644
--- a/src/uscxml/Interpreter.cpp
+++ b/src/uscxml/Interpreter.cpp
@@ -2347,7 +2347,7 @@ bool InterpreterImpl::isInitial(const Arabica::DOM::Element<std::string>& state)
if (isParallel(parent))
return true;
-
+
return false;
}
diff --git a/src/uscxml/UUID.cpp b/src/uscxml/UUID.cpp
index b56b727..ae103ed 100644
--- a/src/uscxml/UUID.cpp
+++ b/src/uscxml/UUID.cpp
@@ -34,31 +34,31 @@ std::string UUID::getUUID() {
bool UUID::isUUID(const std::string& uuid) {
if (uuid.size() != 36)
return false;
-
+
if (uuid[8] != '-' || uuid[13] != '-' || uuid[18] != '-' || uuid[23] != '-')
return false;
-
+
for (int i = 0; i < 36; i++) {
if (i == 8 || i == 13 || i == 18 || i ==23)
continue;
-
+
char c = uuid[i];
if (c == 'a' ||
- c == 'b' ||
- c == 'c' ||
- c == 'd' ||
- c == 'e' ||
- c == 'f' ||
- c == '0' ||
- c == '1' ||
- c == '2' ||
- c == '3' ||
- c == '4' ||
- c == '5' ||
- c == '6' ||
- c == '7' ||
- c == '8' ||
- c == '9') {
+ c == 'b' ||
+ c == 'c' ||
+ c == 'd' ||
+ c == 'e' ||
+ c == 'f' ||
+ c == '0' ||
+ c == '1' ||
+ c == '2' ||
+ c == '3' ||
+ c == '4' ||
+ c == '5' ||
+ c == '6' ||
+ c == '7' ||
+ c == '8' ||
+ c == '9') {
continue;
} else {
return false;
diff --git a/src/uscxml/debug/SCXMLDotWriter.cpp b/src/uscxml/debug/SCXMLDotWriter.cpp
index 88db575..16269a9 100644
--- a/src/uscxml/debug/SCXMLDotWriter.cpp
+++ b/src/uscxml/debug/SCXMLDotWriter.cpp
@@ -28,7 +28,7 @@ namespace uscxml {
using namespace Arabica::DOM;
using namespace Arabica::XPath;
-
+
SCXMLDotWriter::SCXMLDotWriter() {
_iteration = 0;
_indentation = 0;
@@ -56,7 +56,7 @@ SCXMLDotWriter::SCXMLDotWriter(Interpreter interpreter,
anchIter->element = _scxml;
if (anchIter->childDepth >= 0 && anchIter->transDepth == -1)
anchIter->transDepth = anchIter->childDepth;
-
+
_portType = anchIter->type;
assembleGraph(anchIter->element, anchIter->childDepth, anchIter->transDepth + 1);
}
@@ -121,7 +121,7 @@ void SCXMLDotWriter::writeTo(std::ostream& os) {
if (_histories.find(edgeIter->to)->second.from == _histories.find(edgeIter->to)->second.to)
continue;
}
-
+
os << getPrefix() << "\"" << edgeIter->from << "\"";
if (edgeIter->fromPort.size() > 0) {
os << std::string(":\"") + edgeIter->fromPort + "\":e";
@@ -129,7 +129,7 @@ void SCXMLDotWriter::writeTo(std::ostream& os) {
os << ":__name";
}
os << " -> ";
-
+
if (_histories.find(edgeIter->to) != _histories.end()) {
os << getPrefix() << "\"" << _histories.find(edgeIter->to)->second.to << "\"";
if (_histories.find(edgeIter->to)->second.toPort.size() > 0) {
@@ -153,11 +153,11 @@ void SCXMLDotWriter::writeTo(std::ostream& os) {
os << " [color=\"black\"]";
}
os << std::endl;
-
+
}
-
+
_indentation--;
-
+
os << "}" << std::endl;
}
@@ -191,7 +191,7 @@ void SCXMLDotWriter::assembleGraph(const Element<std::string>& state, int32_t ch
_graph[nodeId].node = state;
_graph[nodeId].portType = _portType;
-
+
if (childDepth == 0 && transDepth == 0) {
_graph[nodeId].isBorder = true;
}
@@ -250,7 +250,7 @@ void SCXMLDotWriter::assembleGraph(const Element<std::string>& state, int32_t ch
}
}
-
+
/**
* Walk the complete graph and draw reachable subset
*/
@@ -263,11 +263,11 @@ void SCXMLDotWriter::writeStateElement(std::ostream& os, const Element<std::stri
std::list<Node<std::string> > invisParents;
bool isVisible = (_graph.find(stateId) != _graph.end());
-
+
bool subgraph = InterpreterImpl::isCompound(stateElem) || InterpreterImpl::isParallel(stateElem);
bool fatherIsParallel = (stateElem.getParentNode() &&
- stateElem.getParentNode().getNodeType() == Node_base::ELEMENT_NODE &&
- InterpreterImpl::isParallel(Element<std::string>(stateElem.getParentNode())));
+ stateElem.getParentNode().getNodeType() == Node_base::ELEMENT_NODE &&
+ InterpreterImpl::isParallel(Element<std::string>(stateElem.getParentNode())));
if (subgraph) {
_indentation++;
@@ -282,13 +282,13 @@ void SCXMLDotWriter::writeStateElement(std::ostream& os, const Element<std::stri
os << getPrefix() << (fatherIsParallel ? "style=dashed" : "style=solid") << std::endl;
// os << getPrefix() << "ranksep=\"equally\"" << std::endl;
-
+
}
if (isVisible) {
// this state is visible!
const DotState& dotState = _graph.find(stateId)->second;
-
+
// is this a subgraph?
os << std::endl;
@@ -321,32 +321,32 @@ void SCXMLDotWriter::writeStateElement(std::ostream& os, const Element<std::stri
// is the state initial?
bool isInitial = _interpreter.getImpl()->isInitial(stateElem);
- // if (isInitial)
- // os << getPrefix() << "style=filled, fillcolor=lightgrey, " << std::endl;
+ // if (isInitial)
+ // os << getPrefix() << "style=filled, fillcolor=lightgrey, " << std::endl;
DotState::mmap_s_e_t::const_iterator destIterF, destIterB;
std::list<std::string> outPorts; // count unique keys
switch (dotState.portType) {
- case PORT_TARGET: // outports are per target
- for(DotState::mmap_s_e_t::const_iterator it = dotState.targets.begin(), end = dotState.targets.end();
- it != end;
- it = dotState.targets.upper_bound(it->first)) {
- outPorts.push_back(it->first);
- }
- break;
- case PORT_EVENT: // outports are per event
- for(DotState::mmap_s_e_t::const_iterator it = dotState.events.begin(), end = dotState.events.end();
- it != end;
- it = dotState.events.upper_bound(it->first)) {
- outPorts.push_back(it->first);
- }
- break;
- case PORT_TRANSITION:
- for (int i = 0; i < dotState.transitions.size(); i++) {
- outPorts.push_back(idForNode(dotState.transitions[i]));
- }
- break;
+ case PORT_TARGET: // outports are per target
+ for(DotState::mmap_s_e_t::const_iterator it = dotState.targets.begin(), end = dotState.targets.end();
+ it != end;
+ it = dotState.targets.upper_bound(it->first)) {
+ outPorts.push_back(it->first);
+ }
+ break;
+ case PORT_EVENT: // outports are per event
+ for(DotState::mmap_s_e_t::const_iterator it = dotState.events.begin(), end = dotState.events.end();
+ it != end;
+ it = dotState.events.upper_bound(it->first)) {
+ outPorts.push_back(it->first);
+ }
+ break;
+ case PORT_TRANSITION:
+ for (int i = 0; i < dotState.transitions.size(); i++) {
+ outPorts.push_back(idForNode(dotState.transitions[i]));
+ }
+ break;
}
os << getPrefix() << "label = < " << std::endl;
@@ -366,17 +366,17 @@ void SCXMLDotWriter::writeStateElement(std::ostream& os, const Element<std::stri
os << " <tr><td port=\"__name\" rowspan=\"" << outPorts.size() + 1 << "\"><b>" << nameForNode(stateElem) << "</b></td></tr>" << std::endl;
switch (dotState.portType) {
- case PORT_TARGET: // outports are per target
- writePerTargetPorts(os, outPorts, dotState);
- break;
- case PORT_EVENT: // outports are per event
- writePerEventPorts(os, outPorts, dotState);
- break;
- case PORT_TRANSITION:
- writePerTransitionPorts(os, outPorts, dotState);
- break;
+ case PORT_TARGET: // outports are per target
+ writePerTargetPorts(os, outPorts, dotState);
+ break;
+ case PORT_EVENT: // outports are per event
+ writePerEventPorts(os, outPorts, dotState);
+ break;
+ case PORT_TRANSITION:
+ writePerTransitionPorts(os, outPorts, dotState);
+ break;
}
-
+
// write details of the state
if (details.size() > 0) {
@@ -445,12 +445,12 @@ void SCXMLDotWriter::writePerTargetPorts(std::ostream& os, const std::list<std::
DotState::mmap_s_e_t::const_iterator destIterF, destIterB;
for(std::list<std::string>::const_iterator nameIter = outPorts.begin(); nameIter != outPorts.end(); nameIter++) {
-
+
// gather all events that activate the transition
std::string portName = *nameIter;
DotEdge edge(stateId, portName);
edge.fromPort = portName;
-
+
std::multimap<std::string, std::string> eventConds; // event to condition
std::pair <DotState::mmap_s_e_t::const_iterator, DotState::mmap_s_e_t::const_iterator> targetKeyRange = dotState.targets.equal_range(portName);
for (destIterB = targetKeyRange.first; destIterB != targetKeyRange.second; ++destIterB) {
@@ -467,11 +467,11 @@ void SCXMLDotWriter::writePerTargetPorts(std::ostream& os, const std::list<std::
}
if (_graph.find(portName) != _graph.end())
_edges.insert(edge);
-
+
typedef std::multimap<std::string, std::string>::iterator condIter_t;
std::stringstream outPortSS;
outPortSS << "<b>" << portName << "</b><br align=\"right\" />";
-
+
std::string opener = "{";
std::string closer;
std::string seperator;
@@ -479,19 +479,19 @@ void SCXMLDotWriter::writePerTargetPorts(std::ostream& os, const std::list<std::
for(iterA = eventConds.begin(); iterA != eventConds.end(); iterA = iterB) {
std::string eventName = iterA->first;
bool hasCondition = false;
-
+
std::pair <condIter_t, condIter_t> condRange = eventConds.equal_range(eventName);
for (iterB = condRange.first; iterB != condRange.second; ++iterB) {
hasCondition = true;
}
-
+
outPortSS << opener << seperator << eventName << (hasCondition ? "" : "");
seperator = ", ";
opener = "";
closer = "}";
}
outPortSS << closer;
-
+
os << " <tr><td port=\"" << portEscape(portName) << "\" align=\"right\">" << outPortSS.str() << "</td></tr>" << std::endl;
}
@@ -582,7 +582,7 @@ std::string SCXMLDotWriter::getDetailedLabel(const Element<std::string>& elem, i
if (HAS_ATTR(childElems.item(i), "event "))
details.name += "<br />event = " + ATTR(childElems.item(i), "event");
}
-
+
// send ---------
if (iequals(TAGNAME(childElems.item(i)), "send")) {
if (HAS_ATTR(childElems.item(i), "id"))
@@ -718,7 +718,7 @@ std::string SCXMLDotWriter::nameForNode(const Node<std::string>& node) {
std::string elemName;
if (node.getNodeType() == Node_base::ELEMENT_NODE) {
Element<std::string> elem = (Element<std::string>)node;
-
+
if (false) {
} else if (elem.getTagName() == "scxml") {
if (elem.hasAttribute("name") && !UUID::isUUID(elem.getAttribute("name"))) {
diff --git a/src/uscxml/debug/SCXMLDotWriter.h b/src/uscxml/debug/SCXMLDotWriter.h
index 79ea6c1..3ac697f 100644
--- a/src/uscxml/debug/SCXMLDotWriter.h
+++ b/src/uscxml/debug/SCXMLDotWriter.h
@@ -68,9 +68,9 @@ public:
Arabica::DOM::Element<std::string> element;
int32_t childDepth;
int32_t transDepth;
-
+
PortType type;
-
+
operator bool() const {
return childDepth != -1 || transDepth != -1 || element;
}
@@ -94,7 +94,7 @@ public:
std::set<std::string> childs;
std::set<std::string> initialchilds;
-
+
typedef std::multimap<std::string, Arabica::DOM::Element<std::string> > mmap_s_e_t;
};
@@ -108,7 +108,7 @@ public:
DotEdge() : type(EDGE_TRANSIION) {}
DotEdge(const std::string& from, const std::string& to) : type(EDGE_TRANSIION), from(from), to(to) {
}
-
+
bool operator< (const DotEdge& other) const {
return from + fromPort + to + toPort > other.from + other.fromPort + other.to + other.toPort;
}
@@ -121,7 +121,7 @@ public:
std::string toPort;
std::string toCompass;
};
-
+
SCXMLDotWriter();
~SCXMLDotWriter();
@@ -162,14 +162,14 @@ protected:
const Arabica::DOM::Element<std::string>& transition);
void assembleGraph(const Arabica::DOM::Element<std::string>& start,
- int32_t childDepth = std::numeric_limits<int32_t>::max(),
- int32_t transDepth = std::numeric_limits<int32_t>::max());
+ int32_t childDepth = std::numeric_limits<int32_t>::max(),
+ int32_t transDepth = std::numeric_limits<int32_t>::max());
void writeStateElement(std::ostream& os, const Arabica::DOM::Element<std::string>& state);
-
+
void writePerTransitionPorts(std::ostream& os, const std::list<std::string>& outPorts, const DotState& dotState);
void writePerEventPorts(std::ostream& os, const std::list<std::string>& outPorts, const DotState& dotState);
void writePerTargetPorts(std::ostream& os, const std::list<std::string>& outPorts, const DotState& dotState);
-
+
void writeUnknownNode(std::ostream& os, const std::string& targetId);
int _iteration;
@@ -179,7 +179,7 @@ protected:
std::map<std::string, DotState> _graph;
std::set<DotEdge> _edges;
-
+
// these are only set in ephemeral instances per monitor call
Arabica::DOM::Element<std::string> _transition;
Arabica::DOM::Element<std::string> _scxml;
@@ -187,7 +187,7 @@ protected:
std::string _xmlNSPrefix;
std::list<StateAnchor> _anchors;
std::map<std::string, DotEdge> _histories;
-
+
PortType _portType;
};
diff --git a/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp b/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp
index 84833fb..018a8c4 100644
--- a/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp
@@ -48,6 +48,10 @@ LuaDataModel::LuaDataModel() {
_luaState = NULL;
}
+static int luaInspect(lua_State * l) {
+ return 0;
+}
+
static int luaInFunction(lua_State * l) {
luabridge::LuaRef ref = luabridge::getGlobal(l, "__interpreter");
InterpreterImpl* interpreter = ref.cast<InterpreterImpl*>();
@@ -151,6 +155,7 @@ static luabridge::LuaRef getDataAsLua(lua_State* _luaState, const Data& data) {
luaData[compoundIter->first] = getDataAsLua(_luaState, compoundIter->second);
compoundIter++;
}
+ luaData["inspect"] = luaInspect;
return luaData;
}
if (data.array.size() > 0) {
@@ -161,6 +166,7 @@ static luabridge::LuaRef getDataAsLua(lua_State* _luaState, const Data& data) {
luaData[index++] = getDataAsLua(_luaState, *arrayIter);
arrayIter++;
}
+ luaData["inspect"] = luaInspect;
return luaData;
}
if (data.atom.size() > 0) {
@@ -170,7 +176,15 @@ static luabridge::LuaRef getDataAsLua(lua_State* _luaState, const Data& data) {
break;
}
case Data::INTERPRETED: {
- luaData = data.atom; // not sure
+ if (isNumeric(data.atom.c_str(), 10)) {
+ if (data.atom.find(".") != std::string::npos) {
+ luaData = strTo<double>(data.atom);
+ } else {
+ luaData = strTo<long>(data.atom);
+ }
+ } else {
+ luaData = data.atom;
+ }
}
}
return luaData;
@@ -190,6 +204,7 @@ void LuaDataModel::setEvent(const Event& event) {
luaEvent["content"] = event.content;
luaEvent["invokeId"] = event.invokeid;
luaEvent["sendId"] = event.sendid;
+ luaEvent["inspect"] = luaInspect;
switch (event.eventType) {
case Event::INTERNAL:
@@ -214,7 +229,15 @@ void LuaDataModel::setEvent(const Event& event) {
if (!json.empty()) {
luaEvent["data"] = getDataAsLua(_luaState, json);
} else {
- luaEvent["data"] = InterpreterImpl::spaceNormalize(event.content);
+ // test179
+ std::string trimmed = boost::trim_copy(event.content);
+ if ((boost::starts_with(trimmed, "'") && boost::ends_with(trimmed, "'")) ||
+ (boost::starts_with(trimmed, "\"") && boost::ends_with(trimmed, "\""))) {
+ luaEvent["data"] = InterpreterImpl::spaceNormalize(event.content);
+ } else {
+ Data tmp(event.content, Data::INTERPRETED);
+ luaEvent["data"] = getDataAsLua(_luaState, tmp);
+ }
}
} else {
// _event.data is KVP
@@ -254,15 +277,11 @@ Data LuaDataModel::getStringAsData(const std::string& content) {
trimmedExpr = "return(" + trimmedExpr + ");";
}
- int preStack = lua_gettop(_luaState);
- eval(Arabica::DOM::Element<std::string>(), trimmedExpr);
- int postStack = lua_gettop(_luaState);
- int retVals = postStack - preStack;
+ int retVals = luaEval(Arabica::DOM::Element<std::string>(), trimmedExpr);
if (retVals == 1) {
data = getLuaAsData(luabridge::LuaRef::fromStack(_luaState, -1));
}
- postStack = lua_gettop(_luaState);
- lua_pop(_luaState, postStack - preStack);
+ lua_pop(_luaState, retVals);
}
return data;
@@ -280,17 +299,11 @@ uint32_t LuaDataModel::getLength(const std::string& expr) {
// we need the result of the expression on the lua stack -> has to "return"!
std::string trimmedExpr = boost::trim_copy(expr);
-// luabridge::LuaRef val = luabridge::getGlobal(_luaState, expr.c_str());
-// std::cout << val.tostring() << std::endl;
-
if (!boost::starts_with(trimmedExpr, "return")) {
trimmedExpr = "return(#" + trimmedExpr + ")";
}
- int preStack = lua_gettop(_luaState);
- eval(Arabica::DOM::Element<std::string>(), trimmedExpr);
- int postStack = lua_gettop(_luaState);
- int retVals = postStack - preStack;
+ int retVals = luaEval(Arabica::DOM::Element<std::string>(), trimmedExpr);
if (retVals == 1 && lua_isnumber(_luaState, -1)) {
int result = lua_tointeger(_luaState, -1);
@@ -311,19 +324,14 @@ void LuaDataModel::setForeach(const std::string& item,
const luabridge::LuaRef& arrRef = luabridge::getGlobal(_luaState, array.c_str());
if (arrRef.isTable()) {
- int preStack = lua_gettop(_luaState);
// trigger syntax error for invalid items
- eval(Arabica::DOM::Element<std::string>(), "return(" + item + ");");
- int postStack = lua_gettop(_luaState);
- lua_pop(_luaState, postStack - preStack);
+ int retVals = luaEval(Arabica::DOM::Element<std::string>(), "return(" + item + ");");
+ lua_pop(_luaState, retVals);
const luabridge::LuaRef& val = arrRef[iteration];
luabridge::setGlobal(_luaState, val, item.c_str());
-// luabridge::LuaRef retVal = luabridge::getGlobal(_luaState, item.c_str());
-// std::cout << retVal.tostring() << std::endl;
-
if (index.length() > 0) {
// assign iteration element to index
luabridge::setGlobal(_luaState, iteration, index.c_str());
@@ -333,12 +341,20 @@ void LuaDataModel::setForeach(const std::string& item,
void LuaDataModel::eval(const Arabica::DOM::Element<std::string>& scriptElem,
const std::string& expr) {
+ luaEval(scriptElem, expr);
+}
+
+int LuaDataModel::luaEval(const Arabica::DOM::Element<std::string>& scriptElem,
+ const std::string& expr) {
+ int preStack = lua_gettop(_luaState);
int error = luaL_loadstring(_luaState, expr.c_str()) || lua_pcall(_luaState, 0, LUA_MULTRET, 0);
if (error) {
std::string errMsg = lua_tostring(_luaState, -1);
lua_pop(_luaState, 1); /* pop error message from the stack */
ERROR_EXECUTION_THROW(errMsg);
}
+ int postStack = lua_gettop(_luaState);
+ return postStack - preStack;
}
bool LuaDataModel::isDeclared(const std::string& expr) {
@@ -378,10 +394,10 @@ void LuaDataModel::assign(const Arabica::DOM::Element<std::string>& assignElem,
// luabridge::LuaRef val = luabridge::getGlobal(_luaState, key.c_str());
// std::cout << val.tostring() << std::endl;
- int preStack = lua_gettop(_luaState);
+ int retVals = 0;
if (HAS_ATTR(assignElem, "expr")) {
- eval(Arabica::DOM::Element<std::string>(), key + " = " + ATTR(assignElem, "expr") + ";");
+ retVals = luaEval(Arabica::DOM::Element<std::string>(), key + " = " + ATTR(assignElem, "expr") + ";");
} else if (node) {
ERROR_EXECUTION_THROW("Cannot assign xml nodes in lua datamodel");
} else if (content.size() > 0) {
@@ -397,13 +413,10 @@ void LuaDataModel::assign(const Arabica::DOM::Element<std::string>& assignElem,
// val = luabridge::getGlobal(_luaState, key.c_str());
// std::cout << val.tostring() << std::endl;
- int postStack = lua_gettop(_luaState);
- int retVals = postStack - preStack;
-
}
void LuaDataModel::assign(const std::string& location, const Data& data) {
- std::cout << "assign" << std::endl;
+ luabridge::setGlobal(_luaState, getDataAsLua(_luaState, data), location.c_str());
}
void LuaDataModel::init(const Arabica::DOM::Element<std::string>& dataElem,
@@ -413,7 +426,7 @@ void LuaDataModel::init(const Arabica::DOM::Element<std::string>& dataElem,
}
void LuaDataModel::init(const std::string& location, const Data& data) {
- std::cout << "init" << std::endl;
+ assign(location, data);
}
/**
@@ -429,10 +442,7 @@ bool LuaDataModel::evalAsBool(const Arabica::DOM::Node<std::string>& node, const
trimmedExpr = "return(" + trimmedExpr + ");";
}
- int preStack = lua_gettop(_luaState);
- eval(Arabica::DOM::Element<std::string>(), trimmedExpr);
- int postStack = lua_gettop(_luaState);
- int retVals = postStack - preStack;
+ int retVals = luaEval(Arabica::DOM::Element<std::string>(), trimmedExpr);
if (retVals == 1 && lua_isboolean(_luaState, -1)) {
bool result = lua_toboolean(_luaState, -1);
@@ -450,10 +460,7 @@ std::string LuaDataModel::evalAsString(const std::string& expr) {
trimmedExpr = "return(" + trimmedExpr + ")";
}
- int preStack = lua_gettop(_luaState);
- eval(Arabica::DOM::Element<std::string>(), trimmedExpr);
- int postStack = lua_gettop(_luaState);
- int retVals = postStack - preStack;
+ int retVals = luaEval(Arabica::DOM::Element<std::string>(), trimmedExpr);
if (retVals == 1 && lua_isstring(_luaState, -1)) {
std::string result = lua_tostring(_luaState, -1);
diff --git a/src/uscxml/plugins/datamodel/lua/LuaDataModel.h b/src/uscxml/plugins/datamodel/lua/LuaDataModel.h
index c5d9e4b..828db0e 100644
--- a/src/uscxml/plugins/datamodel/lua/LuaDataModel.h
+++ b/src/uscxml/plugins/datamodel/lua/LuaDataModel.h
@@ -87,16 +87,8 @@ public:
protected:
- static int luaEventData(lua_State * l);
- static int luaEventOrigin(lua_State * l);
- static int luaEventOriginType(lua_State * l);
- static int luaEventRaw(lua_State * l);
- static int luaEventXML(lua_State * l);
- static int luaEventName(lua_State * l);
- static int luaEventContent(lua_State * l);
- static int luaEventSendId(lua_State * l);
- static int luaEventInvokeId(lua_State * l);
- static int luaEventDestructor(lua_State * l);
+ virtual int luaEval(const Arabica::DOM::Element<std::string>& scriptElem,
+ const std::string& expr);
lua_State* _luaState;
};