summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-04-12 15:10:36 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-04-12 15:10:36 (GMT)
commit72fb2cd0bd89eb40d4a96f86d464d9801ad91f59 (patch)
treeea6ec14f4da720b2ec80d9b1c10904f13ee43d32
parentba050afaaad699e60ca657b311d5c34d038bb89c (diff)
downloaduscxml-72fb2cd0bd89eb40d4a96f86d464d9801ad91f59.zip
uscxml-72fb2cd0bd89eb40d4a96f86d464d9801ad91f59.tar.gz
uscxml-72fb2cd0bd89eb40d4a96f86d464d9801ad91f59.tar.bz2
Got prolog datamodel to compile again
-rw-r--r--CMakeLists.txt11
-rw-r--r--contrib/cmake/FindSWI.cmake8
-rw-r--r--contrib/ctest/common.ctest.inc16
-rw-r--r--src/bindings/swig/php/uscxmlNativePHP.php4
-rw-r--r--src/uscxml/Interpreter.cpp72
-rw-r--r--src/uscxml/Message.cpp5
-rw-r--r--src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp37
-rw-r--r--src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h29
-rw-r--r--src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp25
-rw-r--r--test/samples/w3c/ecma/test568.scxml4
10 files changed, 81 insertions, 130 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fd72602..9989b38 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -178,7 +178,12 @@ if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
# order of arguments of gcc matters again
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
add_definitions(-fPIC)
-
+ add_definitions(-Wunreachable-code)
+
+ # coverage information
+ add_definitions(-fprofile-arcs)
+ add_definitions(-ftest-coverage)
+
# all warnings
add_definitions(-Wall)
# add_definitions(-Wno-parentheses-equality)
@@ -194,8 +199,8 @@ if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
# swig will throw a warning with optimization otherwise
add_definitions(-fno-strict-aliasing)
- add_definitions("-Wno-unused-value -Wno-unused-function -Wno-sign-compare")
-
+ add_definitions("-Wno-unused-value -Wno-sign-compare")
+# add_definitions(-Wno-unused-function)
if (NOT CMAKE_BUILD_TYPE MATCHES ".*Deb.*") # when not building for debug
# add_definitions("-s")
#set(CMAKE_CXX_FLAGS "-s") ## Strip binary for everything but debug builds
diff --git a/contrib/cmake/FindSWI.cmake b/contrib/cmake/FindSWI.cmake
index 1106633..3a10269 100644
--- a/contrib/cmake/FindSWI.cmake
+++ b/contrib/cmake/FindSWI.cmake
@@ -47,6 +47,8 @@ foreach(SWI_SEARCH_PATH ${SWI_SEARCH_PATHS})
endif()
endforeach()
+#message("SWI_VERSION: ${SWI_VERSION}")
+
# -- find prolog headers
FIND_PATH(SWI_INCLUDE_DIR SWI-Prolog.h
PATH_SUFFIXES
@@ -55,6 +57,8 @@ FIND_PATH(SWI_INCLUDE_DIR SWI-Prolog.h
PATHS ${SWI_SEARCH_PATHS}
)
+#message("SWI_INCLUDE_DIR: ${SWI_INCLUDE_DIR}")
+
FIND_PATH(SWI_CPP_INCLUDE_DIR SWI-cpp.h
PATH_SUFFIXES
packages/cpp
@@ -62,6 +66,8 @@ FIND_PATH(SWI_CPP_INCLUDE_DIR SWI-cpp.h
PATHS ${SWI_SEARCH_PATHS}
)
+#message("SWI_CPP_INCLUDE_DIR: ${SWI_CPP_INCLUDE_DIR}")
+
FIND_PROGRAM(SWI_BINARY swipl
PATH_SUFFIXES
src
@@ -69,6 +75,8 @@ FIND_PROGRAM(SWI_BINARY swipl
PATHS ${SWI_SEARCH_PATHS}
)
+#message("SWI_BINARY: ${SWI_BINARY}")
+
FIND_LIBRARY(SWI_LIBRARY_RELEASE
NAMES libswipl swipl
PATH_SUFFIXES
diff --git a/contrib/ctest/common.ctest.inc b/contrib/ctest/common.ctest.inc
index 4fa5829..6a6f286 100644
--- a/contrib/ctest/common.ctest.inc
+++ b/contrib/ctest/common.ctest.inc
@@ -36,8 +36,8 @@ set(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 1048576)
### Coverage and Memory checks? (untested) ################################
-#set(WITH_COVERAGE TRUE)
-#find_program(CTEST_COVERAGE_COMMAND NAMES gcov)
+set(WITH_COVERAGE TRUE)
+find_program(CTEST_COVERAGE_COMMAND NAMES gcov)
#set(WITH_MEMCHECK TRUE)
#find_program(CTEST_MEMORYCHECK_COMMAND NAMES valgrind)
@@ -71,9 +71,9 @@ set(CTEST_CONFIGURE_COMMAND "${CTEST_CONFIGURE_COMMAND} \"${CTEST_SOURCE_DIRECTO
### Test! ################################################################
# clean build directory for everything but continuous tests
-if (NOT ${CTEST_SUBMIT_TYPE} MATCHES ".*Continuous.*")
+#if (NOT ${CTEST_SUBMIT_TYPE} MATCHES ".*Continuous.*")
ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY})
-endif()
+#endif()
ctest_start(${CTEST_SUBMIT_TYPE}) # start testing
#
@@ -106,11 +106,11 @@ endif()
ctest_build() # build custom target that depends on all the actual tests
ctest_test() # run tests
-if (WITH_MEMCHECK AND CTEST_COVERAGE_COMMAND)
+if(CTEST_COVERAGE_COMMAND)
ctest_coverage()
-endif (WITH_MEMCHECK AND CTEST_COVERAGE_COMMAND)
-if (WITH_MEMCHECK AND CTEST_MEMORYCHECK_COMMAND)
+endif()
+if (WITH_MEMCHECK)
ctest_memcheck()
-endif (WITH_MEMCHECK AND CTEST_MEMORYCHECK_COMMAND)
+endif()
ctest_submit() # submit
diff --git a/src/bindings/swig/php/uscxmlNativePHP.php b/src/bindings/swig/php/uscxmlNativePHP.php
index c15f979..eb66b3d 100644
--- a/src/bindings/swig/php/uscxmlNativePHP.php
+++ b/src/bindings/swig/php/uscxmlNativePHP.php
@@ -769,6 +769,10 @@ class Interpreter {
return $r;
}
+ static function spaceNormalize($text) {
+ return Interpreter_spaceNormalize($text);
+ }
+
function isInitial($state) {
return Interpreter_isInitial($this->_cPtr,$state);
}
diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp
index 7fe5cc1..b314d1a 100644
--- a/src/uscxml/Interpreter.cpp
+++ b/src/uscxml/Interpreter.cpp
@@ -471,78 +471,6 @@ void InterpreterImpl::processContentElement(const Arabica::DOM::Node<std::string
} else {
LOG(ERROR) << "content element does not specify any content.";
}
-
-#if 0
- try {
- std::string contentToProcess;
- if (HAS_ATTR(content, "expr")) {
- if (_dataModel) {
- /// this is out of spec
- contentToProcess = ATTR(content, "expr");
- // sendReq.data.atom = contentValue;
- // sendReq.data.type = Data::VERBATIM;
- } else {
- LOG(ERROR) << "content element has expr attribute but no datamodel is specified.";
- }
- } else if (content.hasChildNodes()) {
- bool presentAsDom = false;
- Node<std::string> contentChild = content.getFirstChild();
- while(contentChild) {
- if (contentChild.getNodeType() == Node_base::TEXT_NODE) {
- std::string trimmed = contentChild.getNodeValue();
- boost::trim(trimmed);
- if (trimmed.length() > 0)
- break;
- }
- if (contentChild.getNodeType() == Node_base::ELEMENT_NODE) {
- presentAsDom = true;
- break;
- }
- contentChild = contentChild.getNextSibling();
- }
-
- if (contentChild && presentAsDom) {
- // use the whole dom
- DOMImplementation<std::string> domFactory = Arabica::SimpleDOM::DOMImplementation<std::string>::getDOMImplementation();
- dom = domFactory.createDocument(contentChild.getNamespaceURI(), "", 0);
- Node<std::string> newNode = dom.importNode(contentChild, true);
- dom.appendChild(newNode);
- } else if (contentChild) {
- contentToProcess = contentChild.getNodeValue();
- } else {
- LOG(ERROR) << "content element has neither text nor element children.";
- }
- } else {
- LOG(ERROR) << "content element does not specify any content.";
- }
- if (contentToProcess.size() > 0) {
- /// try to interpret as JSON
- std::string trimmedContent = contentToProcess;
- boost::trim(trimmedContent);
- if (trimmedContent.find_first_of("{[") == 0) {
- data = Data::fromJSON(contentToProcess);
- if (data)
- return;
- }
- /// create space normalized string
- std::istringstream iss(contentToProcess);
- std::stringstream content;
- std::string seperator;
- do {
- std::string token;
- iss >> token;
- if (token.length() > 0) {
- content << seperator << token;
- seperator = " ";
- }
- } while (iss);
- text = content.str();
- }
- } catch (Event e) {
- e.name = "error.execution";
- receiveInternal(e);
- }
-#endif
}
void InterpreterImpl::processDOMorText(const Arabica::DOM::Node<std::string>& node,
diff --git a/src/uscxml/Message.cpp b/src/uscxml/Message.cpp
index 0898cc7..c3f4281 100644
--- a/src/uscxml/Message.cpp
+++ b/src/uscxml/Message.cpp
@@ -188,13 +188,16 @@ Data Data::fromJSON(const std::string& jsonString) {
if (trimmed.length() == 0)
return data;
+ if (trimmed.find_first_of("{[") != 0)
+ return data;
+
jsmn_parser p;
jsmntok_t* t = NULL;
// we do not know the number of tokens beforehand, start with something sensible and increase
int rv;
- int frac = 16; // this will get decreased to 16 to first iteration for 1/16 length/token ratio
+ int frac = 16; // length/token ratio
do {
jsmn_init(&p);
diff --git a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp
index f3af4b6..fcd606d 100644
--- a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp
@@ -134,38 +134,25 @@ std::string SWIDataModel::evalAsString(const std::string& expr) {
return std::string(compound);
}
-void SWIDataModel::assign(const std::string& location,
+void SWIDataModel::assign(const Arabica::DOM::Element<std::string>& assignElem,
const Arabica::DOM::Document<std::string>& doc,
- const Arabica::DOM::Element<std::string>& assignElem) {
-
+ const std::string& content) {
+ std::string expr = content;
+ if (HAS_ATTR(assignElem, "expr")) {
+ expr = ATTR(assignElem, "expr");
+ }
+ if (expr.length() > 0)
+ eval(expr);
}
-void SWIDataModel::assign(const std::string& location,
- const std::string& expr,
- const Arabica::DOM::Element<std::string>& assignElem) {
- eval(expr);
-}
-void SWIDataModel::assign(const std::string& location,
- const Data& data,
- const Arabica::DOM::Element<std::string>& assignElem) {
+void SWIDataModel::assign(const std::string& location, const Data& data) {
eval(data.atom);
}
-void SWIDataModel::init(const std::string& location,
+void SWIDataModel::init(const Arabica::DOM::Element<std::string>& dataElem,
const Arabica::DOM::Document<std::string>& doc,
- const Arabica::DOM::Element<std::string>& dataElem) {
-
-}
-void SWIDataModel::init(const std::string& location,
- const std::string& expr,
- const Arabica::DOM::Element<std::string>& dataElem) {
-
-}
-void SWIDataModel::init(const std::string& location,
- const Data& data,
- const Arabica::DOM::Element<std::string>& dataElem) {
-
-}
+ const std::string& content) {}
+void SWIDataModel::init(const std::string& location, const Data& data) {}
bool SWIDataModel::isDeclared(const std::string& expr) {
return true;
diff --git a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h
index 5d95476..a278db8 100644
--- a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h
+++ b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h
@@ -36,6 +36,16 @@ public:
virtual void pushContext();
virtual void popContext();
+ virtual void assign(const Arabica::DOM::Element<std::string>& assignElem,
+ const Arabica::DOM::Document<std::string>& doc,
+ const std::string& content);
+ virtual void assign(const std::string& location, const Data& data);
+
+ virtual void init(const Arabica::DOM::Element<std::string>& dataElem,
+ const Arabica::DOM::Document<std::string>& doc,
+ const std::string& content);
+ virtual void init(const std::string& location, const Data& data);
+
virtual void eval(const std::string& expr);
virtual bool isDeclared(const std::string& expr);
@@ -44,25 +54,6 @@ public:
virtual std::string evalAsString(const std::string& expr);
virtual bool evalAsBool(const std::string& expr);
- virtual void assign(const std::string& location,
- const Arabica::DOM::Document<std::string>& doc,
- const Arabica::DOM::Element<std::string>& assignElem);
- virtual void assign(const std::string& location,
- const std::string& expr,
- const Arabica::DOM::Element<std::string>& assignElem);
- virtual void assign(const std::string& location,
- const Data& data,
- const Arabica::DOM::Element<std::string>& assignElem);
-
- virtual void init(const std::string& location,
- const Arabica::DOM::Document<std::string>& doc,
- const Arabica::DOM::Element<std::string>& dataElem);
- virtual void init(const std::string& location,
- const std::string& expr,
- const Arabica::DOM::Element<std::string>& dataElem);
- virtual void init(const std::string& location,
- const Data& data,
- const Arabica::DOM::Element<std::string>& dataElem);
protected:
Event _event;
diff --git a/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp b/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp
index eef8e51..0c649f5 100644
--- a/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp
@@ -187,7 +187,30 @@ bool XPathDataModel::evalAsBool(const std::string& expr) {
std::string XPathDataModel::evalAsString(const std::string& expr) {
XPathValue<std::string> result = _xpath.evaluate_expr(expr, _doc);
- return result.asString();
+ switch (result.type()) {
+ case STRING:
+ return result.asString();
+ break;
+ case BOOL:
+ return (result.asBool() ? "true" : "false");
+ break;
+ case NUMBER:
+ return toStr(result.asNumber());
+ break;
+ case NODE_SET: {
+ NodeSet<std::string> nodeSet = result.asNodeSet();
+ std::stringstream ss;
+ for (int i = 0; i < nodeSet.size(); i++) {
+ ss << nodeSet[i] << std::endl;
+ }
+ return ss.str();
+ break;
+ }
+ case ANY:
+ throw Event("error.execution", Event::PLATFORM);
+ break;
+ }
+ return "undefined";
}
double XPathDataModel::evalAsNumber(const std::string& expr) {
diff --git a/test/samples/w3c/ecma/test568.scxml b/test/samples/w3c/ecma/test568.scxml
index 79d7c92..ebfce36 100644
--- a/test/samples/w3c/ecma/test568.scxml
+++ b/test/samples/w3c/ecma/test568.scxml
@@ -5,7 +5,9 @@ send events. --><scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http:
<state id="s0">
<transition cond="$_ioprocessors/scxml/location/text()" target="pass"/>
- <transition target="fail"/>
+ <transition target="fail">
+ <log expr="$_ioprocessors/processor[@name='scxml']/location/text()" />
+ </transition>
</state>