summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt30
-rw-r--r--apps/uscxml-browser.cpp2
-rw-r--r--config.h.in1
-rwxr-xr-xcontrib/src/Pluma/PluginManager.cpp5
-rw-r--r--src/uscxml/CMakeLists.txt10
-rw-r--r--src/uscxml/Interpreter.cpp3
-rw-r--r--src/uscxml/interpreter/BasicDelayedEventQueue.cpp3
-rw-r--r--src/uscxml/interpreter/BasicEventQueue.cpp2
-rw-r--r--src/uscxml/interpreter/FastMicroStep.cpp12
-rw-r--r--src/uscxml/messages/Data.cpp7
-rw-r--r--src/uscxml/messages/Data.h8
-rw-r--r--src/uscxml/messages/Event.cpp5
-rw-r--r--src/uscxml/plugins/Factory.cpp92
-rw-r--r--src/uscxml/plugins/Factory.h4
-rw-r--r--src/uscxml/plugins/Plugins.cpp31
-rw-r--r--src/uscxml/plugins/Plugins.h41
-rw-r--r--src/uscxml/plugins/datamodel/CMakeLists.txt94
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp11
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp12
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h1
-rw-r--r--src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp31
-rw-r--r--src/uscxml/plugins/datamodel/lua/LuaDataModel.h3
-rw-r--r--src/uscxml/plugins/datamodel/null/NULLDataModel.cpp18
-rw-r--r--src/uscxml/plugins/datamodel/null/NULLDataModel.h9
-rw-r--r--src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp6
-rw-r--r--src/uscxml/plugins/datamodel/promela/PromelaDataModel.h3
-rw-r--r--src/uscxml/plugins/datamodel/promela/PromelaParser.cpp4
-rw-r--r--src/uscxml/plugins/datamodel/promela/PromelaParser.h2
-rw-r--r--src/uscxml/plugins/invoker/CMakeLists.txt22
-rw-r--r--src/uscxml/plugins/invoker/dirmon/DirMonInvoker.cpp4
-rw-r--r--src/uscxml/plugins/invoker/dirmon/DirMonInvoker.h3
-rw-r--r--src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp6
-rw-r--r--src/uscxml/plugins/invoker/scxml/USCXMLInvoker.h3
-rw-r--r--src/uscxml/plugins/ioprocessor/CMakeLists.txt27
-rw-r--r--src/uscxml/plugins/ioprocessor/basichttp/BasicHTTPIOProcessor.h9
-rw-r--r--src/uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.cpp12
-rw-r--r--src/uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.h9
-rw-r--r--src/uscxml/transform/ChartToC.cpp13
-rw-r--r--src/uscxml/transform/ChartToPromela.cpp36
-rw-r--r--src/uscxml/transform/ChartToPromela.h14
-rw-r--r--src/uscxml/transform/ChartToVHDL.cpp8
-rw-r--r--src/uscxml/transform/Trie.cpp4
-rw-r--r--src/uscxml/transform/Trie.h2
-rw-r--r--src/uscxml/transform/promela/PromelaCodeAnalyzer.h4
-rw-r--r--src/uscxml/util/DOM.cpp288
-rw-r--r--src/uscxml/util/DOM.h27
-rw-r--r--test/CMakeLists.txt40
-rw-r--r--test/ctest/scripts/test_generated_c.cmake31
-rw-r--r--test/src/test-gen-c.cpp4
-rw-r--r--test/src/test-utils.cpp74
-rw-r--r--test/src/test-validating.cpp1323
52 files changed, 1528 insertions, 887 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a7c4cdc..764fd8c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -86,6 +86,11 @@ set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
+# additional system library directories
+# if (EXISTS "/usr/lib/x86_64-linux-gnu")
+# LIST(APPEND CMAKE_FIND_ROOT_PATH "/usr/lib/x86_64-linux-gnu")
+# endif()
+
# setup header include paths
include_directories(src)
include_directories(contrib/src)
@@ -249,10 +254,11 @@ else()
# make a quick attempt to find xerces
INCLUDE(FindPackageHandleStandardArgs)
find_path(XercesC_INCLUDE_DIR NAMES "xercesc/util/PlatformUtils.hpp")
- find_library(XercesC_LIBRARY NAMES "xerces-c" "xerces-c_3")
+ find_library(XercesC_LIBRARIES NAMES "xerces-c" "xerces-c_3")
mark_as_advanced(XercesC_LIBRARIES)
mark_as_advanced(XercesC_INCLUDE_DIR)
if (XercesC_INCLUDE_DIR AND XercesC_LIBRARIES)
+ message(STATUS "Found XercesC: ${XercesC_LIBRARIES}")
set(XercesC_FOUND ON)
else()
message(STATUS "Could NOT find XercesC (your CMake distribution does not include the FindXercesC module)")
@@ -409,14 +415,30 @@ endif()
add_subdirectory(src/uscxml)
add_subdirectory(src/bindings)
-add_library(uscxml ${USCXML_FILES})
+if (BUILD_AS_PLUGINS)
+ file(GLOB USCXML_PLUGINS
+ ${CMAKE_SOURCE_DIR}/contrib/src/Pluma/*.cpp
+ )
+ include_directories(${CMAKE_SOURCE_DIR}/contrib/src)
+ source_group("Plugins" FILES ${USCXML_PLUGINS})
+ list (APPEND USCXML_FILES ${USCXML_PLUGINS})
+
+ add_library(uscxml ${USCXML_FILES})
+ target_link_libraries(uscxml ${USCXML_CORE_LIBS})
+ set_target_properties(uscxml PROPERTIES COMPILE_FLAGS "-DUSCXML_EXPORT")
+# set_target_properties(uscxml PROPERTIES COMPILE_FLAGS "-DPLUMA_EXPORTS")
+ add_definitions(-DPLUMA_EXPORTS)
+else()
+ add_library(uscxml ${USCXML_FILES})
+ target_link_libraries(uscxml ${USCXML_OPT_LIBS} ${USCXML_CORE_LIBS})
+endif()
+
set_property(TARGET uscxml PROPERTY CXX_STANDARD 11)
set_property(TARGET uscxml PROPERTY CXX_STANDARD_REQUIRED ON)
set_property(TARGET uscxml PROPERTY SOVERSION ${USCXML_VERSION})
+add_dependencies(uscxml ${USCXML_PREREQS})
install_library(TARGETS uscxml)
-add_dependencies(uscxml ${USCXML_PREREQS})
-target_link_libraries(uscxml ${USCXML_OPT_LIBS} ${USCXML_CORE_LIBS})
add_library(uscxml_transform ${USCXML_TRANSFORM_FILES})
set_property(TARGET uscxml_transform PROPERTY CXX_STANDARD 11)
diff --git a/apps/uscxml-browser.cpp b/apps/uscxml-browser.cpp
index b421f3f..626ad60 100644
--- a/apps/uscxml-browser.cpp
+++ b/apps/uscxml-browser.cpp
@@ -52,7 +52,7 @@ int main(int argc, char** argv) {
// instantiate and configure interpreters
std::list<Interpreter> interpreters;
- for(int i = 0; i < options.interpreters.size(); i++) {
+ for(size_t i = 0; i < options.interpreters.size(); i++) {
// InterpreterOptions* currOptions = options.interpreters[0].second;
std::string documentURL = options.interpreters[0].first;
diff --git a/config.h.in b/config.h.in
index cdead01..ae184c0 100644
--- a/config.h.in
+++ b/config.h.in
@@ -73,6 +73,7 @@
#cmakedefine WITH_DM_C89
#cmakedefine WITH_DM_PROMELA
+#cmakedefine BUILD_AS_PLUGINS
/** Optional libraries we found */
#cmakedefine UMUNDO_FOUND
diff --git a/contrib/src/Pluma/PluginManager.cpp b/contrib/src/Pluma/PluginManager.cpp
index 1124505..3463377 100755
--- a/contrib/src/Pluma/PluginManager.cpp
+++ b/contrib/src/Pluma/PluginManager.cpp
@@ -53,10 +53,10 @@ bool PluginManager::load(const std::string& path){
if (!lib) return false;
fnRegisterPlugin* registerFunction;
- registerFunction = reinterpret_cast<fnRegisterPlugin*>(lib->getSymbol("connect"));
+ registerFunction = reinterpret_cast<fnRegisterPlugin*>(lib->getSymbol("pluginConnect"));
if(!registerFunction){
- fprintf(stderr, "Failed to initialize plugin \"%s\": connect function not found\n", plugName.c_str());
+ fprintf(stderr, "Failed to initialize plugin \"%s\": pluginConnect function not found\n", plugName.c_str());
delete lib;
return false;
}
@@ -68,6 +68,7 @@ bool PluginManager::load(const std::string& path){
delete lib;
return false;
}
+
// Store the library if addictions are confirmed
if (host.confirmAddictions())
libraries[plugName] = lib;
diff --git a/src/uscxml/CMakeLists.txt b/src/uscxml/CMakeLists.txt
index 459fe23..e1881e4 100644
--- a/src/uscxml/CMakeLists.txt
+++ b/src/uscxml/CMakeLists.txt
@@ -62,7 +62,6 @@ file(GLOB USCXML_CORE
source_group("Interpreter" FILES ${USCXML_CORE})
list (APPEND USCXML_FILES ${USCXML_CORE})
-
file(GLOB USCXML_PLUGINS
plugins/*.cpp
plugins/*.h
@@ -78,6 +77,15 @@ file(GLOB_RECURSE USCXML_TRANSFORM
source_group("Interpreter" FILES ${USCXML_TRANSFORM})
list (APPEND USCXML_TRANSFORM_FILES ${USCXML_TRANSFORM})
+if (BUILD_AS_PLUGINS)
+ file(GLOB_RECURSE PROMELA_PARSER
+ plugins/datamodel/promela/parser/*.cpp
+ plugins/datamodel/promela/PromelaParser.cpp
+ )
+ list (APPEND USCXML_TRANSFORM_FILES ${PROMELA_PARSER})
+
+endif()
+
add_subdirectory(plugins/datamodel)
# add_subdirectory(plugins/element)
add_subdirectory(plugins/invoker)
diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp
index d5f764d..4630cf2 100644
--- a/src/uscxml/Interpreter.cpp
+++ b/src/uscxml/Interpreter.cpp
@@ -61,6 +61,7 @@ static URL normalizeURL(const std::string url) {
}
Interpreter Interpreter::fromXML(const std::string& xml, const std::string& baseURL) {
+
URL absUrl = normalizeURL(baseURL);
std::shared_ptr<InterpreterImpl> interpreterImpl(new InterpreterImpl());
@@ -197,7 +198,7 @@ std::string Interpreter::serialize() {
InterpreterState Interpreter::step(size_t blockMs) {
return _impl->step(blockMs);
-};
+}
void loadState(const std::string& encodedState);
diff --git a/src/uscxml/interpreter/BasicDelayedEventQueue.cpp b/src/uscxml/interpreter/BasicDelayedEventQueue.cpp
index 74ab757..ef194ca 100644
--- a/src/uscxml/interpreter/BasicDelayedEventQueue.cpp
+++ b/src/uscxml/interpreter/BasicDelayedEventQueue.cpp
@@ -196,7 +196,8 @@ Data BasicDelayedEventQueue::serialize() {
for (auto event : _queue) {
struct callbackData cb = _callbackData[event.uuid];
- struct timeval delay, now;
+ struct timeval delay = {0, 0};
+ struct timeval now = {0, 0};
uint64_t delayMs = 0;
evutil_gettimeofday(&now, NULL);
diff --git a/src/uscxml/interpreter/BasicEventQueue.cpp b/src/uscxml/interpreter/BasicEventQueue.cpp
index bb7c78b..5b3e9f8 100644
--- a/src/uscxml/interpreter/BasicEventQueue.cpp
+++ b/src/uscxml/interpreter/BasicEventQueue.cpp
@@ -42,7 +42,7 @@ Event BasicEventQueue::dequeue(size_t blockMs) {
system_clock::time_point endTime = now + milliseconds(blockMs);
// now + milliseconds(blockMs) may not have fitted into a duration type - limit to maximum duration
- if (blockMs > system_clock::duration::max().count() - duration_cast<milliseconds>(now.time_since_epoch()).count()) {
+ if (blockMs > (size_t)(system_clock::duration::max().count() - duration_cast<milliseconds>(now.time_since_epoch()).count())) {
endTime = system_clock::time_point::max();
}
diff --git a/src/uscxml/interpreter/FastMicroStep.cpp b/src/uscxml/interpreter/FastMicroStep.cpp
index 3edd3e4..33ffebd 100644
--- a/src/uscxml/interpreter/FastMicroStep.cpp
+++ b/src/uscxml/interpreter/FastMicroStep.cpp
@@ -420,7 +420,17 @@ COMPLETION_STABLISHED:
/** -- All things transitions -- */
- tmp = DOMUtils::inPostFixOrder({_xmlPrefix.str() + "transition"}, _scxml);
+// tmp = DOMUtils::inPostFixOrder({_xmlPrefix.str() + "transition"}, _scxml);
+ tmp = DOMUtils::inPostFixOrder({
+ XML_PREFIX(_scxml).str() + "scxml",
+ XML_PREFIX(_scxml).str() + "state",
+ XML_PREFIX(_scxml).str() + "final",
+ XML_PREFIX(_scxml).str() + "history",
+ XML_PREFIX(_scxml).str() + "initial",
+ XML_PREFIX(_scxml).str() + "parallel"
+ }, _scxml);
+ tmp = DOMUtils::filterChildElements(XML_PREFIX(_scxml).str() + "transition", tmp);
+
_transitions.resize(tmp.size());
for (i = 0; i < _transitions.size(); i++) {
diff --git a/src/uscxml/messages/Data.cpp b/src/uscxml/messages/Data.cpp
index 6c48c46..8853b19 100644
--- a/src/uscxml/messages/Data.cpp
+++ b/src/uscxml/messages/Data.cpp
@@ -73,6 +73,7 @@ void Data::merge(const Data& other) {
}
Data Data::fromJSON(const std::string& jsonString) {
+
Data data;
std::string trimmed = boost::trim_copy(jsonString);
@@ -129,7 +130,7 @@ Data Data::fromJSON(const std::string& jsonString) {
return data;
}
- if (t[0].end != trimmed.length())
+ if ((size_t)t[0].end != trimmed.length())
return data;
// jsmntok_t* token = t;
@@ -218,7 +219,7 @@ std::string Data::toJSON(const Data& data) {
}
if (false) {
} else if (data.compound.size() > 0) {
- int longestKey = 0;
+ size_t longestKey = 0;
std::map<std::string, Data>::const_iterator compoundIter = data.compound.begin();
while(compoundIter != data.compound.end()) {
if (compoundIter->first.size() > longestKey)
@@ -226,7 +227,7 @@ std::string Data::toJSON(const Data& data) {
compoundIter++;
}
std::string keyPadding;
- for (unsigned int i = 0; i < longestKey; i++)
+ for (size_t i = 0; i < longestKey; i++)
keyPadding += " ";
std::string seperator;
diff --git a/src/uscxml/messages/Data.h b/src/uscxml/messages/Data.h
index 48323ed..5e4df87 100644
--- a/src/uscxml/messages/Data.h
+++ b/src/uscxml/messages/Data.h
@@ -39,7 +39,7 @@ class DOMNode;
namespace uscxml {
-static int _dataIndentation = 1;
+static unsigned int _dataIndentation = 1;
class USCXML_API Data {
public:
@@ -48,7 +48,10 @@ public:
INTERPRETED,
};
- Data() : node(NULL), type(INTERPRETED) {}
+ Data() : node(NULL), type(INTERPRETED) {
+ // silence stupid not used error for statics in gcc
+ (void)_dataIndentation;
+ }
explicit Data(const char* data, size_t size, const std::string& mimeType, bool adopt = false);
@@ -87,7 +90,6 @@ public:
compound.clear();
array.clear();
atom.clear();
-// adoptedDoc.reset();
binary = Blob();
node = NULL;
}
diff --git a/src/uscxml/messages/Event.cpp b/src/uscxml/messages/Event.cpp
index f372798..f667e92 100644
--- a/src/uscxml/messages/Event.cpp
+++ b/src/uscxml/messages/Event.cpp
@@ -84,7 +84,10 @@ std::ostream& operator<< (std::ostream& os, const Event& event) {
indent += " ";
}
-// os << indent << (event.eventType == Event::EXTERNAL ? "External" : "Internal") << " Event " << (event.dom ? "with DOM attached" : "") << std::endl;
+ os << indent
+ << (event.eventType == Event::INTERNAL ? "Internal" : "")
+ << (event.eventType == Event::EXTERNAL ? "External" : "")
+ << (event.eventType == Event::PLATFORM ? "Platform" : "") << " Event " << std::endl;
if (event.name.size() > 0)
os << indent << " name: " << event.name << std::endl;
diff --git a/src/uscxml/plugins/Factory.cpp b/src/uscxml/plugins/Factory.cpp
index b609955..0b9104e 100644
--- a/src/uscxml/plugins/Factory.cpp
+++ b/src/uscxml/plugins/Factory.cpp
@@ -33,10 +33,21 @@
#include "uscxml/plugins/InvokerImpl.h"
#include "uscxml/plugins/DataModelImpl.h"
+#include <xercesc/dom/DOM.hpp>
+#include <xercesc/util/PlatformUtils.hpp>
+#include "uscxml/util/DOM.h"
+
+#include <iostream>
// see http://nadeausoftware.com/articles/2012/01/c_c_tip_how_use_compiler_predefined_macros_detect_operating_system
+/*** BEGIN PLUGINS ***/
+
+#ifdef BUILD_AS_PLUGINS
+# include "uscxml/plugins/Plugins.h"
+#else
+
#ifdef WITH_IOPROC_SCXML
# include "uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.h"
#endif
@@ -45,10 +56,9 @@
# include "uscxml/plugins/ioprocessor/basichttp/BasicHTTPIOProcessor.h"
#endif
+#include "uscxml/plugins/datamodel/null/NullDataModel.h"
-#include "uscxml/plugins/datamodel/null/NULLDataModel.h"
-
-#ifdef WITH_DM_ECMA_V8
+#if defined WITH_DM_ECMA_V8
# include "uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h"
#endif
@@ -77,6 +87,9 @@
# include "uscxml/plugins/invoker/dirmon/DirMonInvoker.h"
#endif
+#endif
+/*** END PLUGINS ***/
+
namespace uscxml {
@@ -98,8 +111,62 @@ std::string Factory::getDefaultPluginPath() {
return _defaultPluginPath;
}
+Factory::~Factory() {
+#ifdef BUILD_AS_PLUGINS
+ pluma.unloadAll();
+#endif
+}
+
void Factory::registerPlugins() {
+ /*** PLUGINS ***/
+#ifdef BUILD_AS_PLUGINS
+
+ if (_pluginPath.length() == 0) {
+ // try to read USCXML_PLUGIN_PATH environment variable
+ _pluginPath = (getenv("USCXML_PLUGIN_PATH") != NULL ? getenv("USCXML_PLUGIN_PATH") : "");
+ }
+ if (_pluginPath.length() > 0) {
+ pluma.acceptProviderType<InvokerImplProvider>();
+ pluma.acceptProviderType<IOProcessorImplProvider>();
+ pluma.acceptProviderType<DataModelImplProvider>();
+ pluma.acceptProviderType<ExecutableContentImplProvider>();
+ pluma.loadFromFolder(_pluginPath, true);
+
+ std::vector<InvokerImplProvider*> invokerProviders;
+ pluma.getProviders(invokerProviders);
+ for (auto provider : invokerProviders) {
+ InvokerImpl* invoker = provider->create();
+ registerInvoker(invoker);
+ }
+
+ std::vector<IOProcessorImplProvider*> ioProcessorProviders;
+ pluma.getProviders(ioProcessorProviders);
+ for (auto provider : ioProcessorProviders) {
+ IOProcessorImpl* ioProcessor = provider->create();
+ registerIOProcessor(ioProcessor);
+ }
+
+ std::vector<DataModelImplProvider*> dataModelProviders;
+ pluma.getProviders(dataModelProviders);
+ for (auto provider : dataModelProviders) {
+ DataModelImpl* dataModel = provider->create();
+ registerDataModel(dataModel);
+ }
+
+ std::vector<ExecutableContentImplProvider*> execContentProviders;
+ pluma.getProviders(execContentProviders);
+ for (auto provider : execContentProviders) {
+ ExecutableContentImpl* execContent = provider->create();
+ registerExecutableContent(execContent);
+ }
+
+ } else {
+ ERROR_EXECUTION_THROW("No path to plugins known, export USCXML_PLUGIN_PATH or pass path as parameter");
+ }
+
+#else
+
#ifdef WITH_IOPROC_SCXML
{
SCXMLIOProcessor* ioProcessor = new SCXMLIOProcessor();
@@ -150,11 +217,10 @@ void Factory::registerPlugins() {
#endif
{
- NULLDataModel* dataModel = new NULLDataModel();
+ NullDataModel* dataModel = new NullDataModel();
registerDataModel(dataModel);
}
-
#ifdef WITH_INV_SCXML
{
USCXMLInvoker* invoker = new USCXMLInvoker();
@@ -169,12 +235,9 @@ void Factory::registerPlugins() {
}
#endif
-}
-
-Factory::~Factory() {
-#ifdef BUILD_AS_PLUGINS
- pluma.unloadAll();
#endif
+ /*** PLUGINS ***/
+
}
#define LIST_COMPONENTS(type, name) \
@@ -476,6 +539,13 @@ size_t DataModelImpl::replaceExpressions(std::string& content) {
Factory* Factory::getInstance() {
+ // this needs to be here as some plugins use xercesc
+ try {
+ ::xercesc_3_1::XMLPlatformUtils::Initialize();
+ } catch (const XERCESC_NS::XMLException& toCatch) {
+ ERROR_PLATFORM_THROW("Cannot initialize XercesC: " + X(toCatch.getMessage()).str());
+ }
+
if (_instance == NULL) {
_instance = new Factory(Factory::_defaultPluginPath);
}
@@ -530,6 +600,6 @@ void InvokerImpl::eventToSCXML(Event& event,
}
}
-Factory* Factory::_instance = NULL;
std::string Factory::_defaultPluginPath;
+Factory* Factory::_instance = NULL;
}
diff --git a/src/uscxml/plugins/Factory.h b/src/uscxml/plugins/Factory.h
index 48bfae8..0026df1 100644
--- a/src/uscxml/plugins/Factory.h
+++ b/src/uscxml/plugins/Factory.h
@@ -92,10 +92,10 @@ protected:
Factory(const std::string&);
~Factory();
- Factory* _parentFactory;
+ Factory* _parentFactory = NULL;
std::string _pluginPath;
- static Factory* _instance;
static std::string _defaultPluginPath;
+ static Factory* _instance;
};
diff --git a/src/uscxml/plugins/Plugins.cpp b/src/uscxml/plugins/Plugins.cpp
new file mode 100644
index 0000000..0c9a23c
--- /dev/null
+++ b/src/uscxml/plugins/Plugins.cpp
@@ -0,0 +1,31 @@
+/**
+ * @file
+ * @author 2012-2013 Stefan Radomski (stefan.radomski@cs.tu-darmstadt.de)
+ * @copyright Simplified BSD
+ *
+ * @cond
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the FreeBSD license as published by the FreeBSD
+ * project.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the FreeBSD license along with this
+ * program. If not, see <http://www.opensource.org/licenses/bsd-license>.
+ * @endcond
+ */
+
+#include "Plugins.h"
+
+namespace uscxml {
+
+#ifdef BUILD_AS_PLUGINS
+PLUMA_PROVIDER_SOURCE(DataModelImpl, 1, 1)
+PLUMA_PROVIDER_SOURCE(IOProcessorImpl, 1, 1)
+PLUMA_PROVIDER_SOURCE(InvokerImpl, 1, 1)
+PLUMA_PROVIDER_SOURCE(ExecutableContentImpl, 1, 1)
+#endif
+
+}
diff --git a/src/uscxml/plugins/Plugins.h b/src/uscxml/plugins/Plugins.h
new file mode 100644
index 0000000..eb1c9cb
--- /dev/null
+++ b/src/uscxml/plugins/Plugins.h
@@ -0,0 +1,41 @@
+/**
+ * @file
+ * @author 2012-2013 Stefan Radomski (stefan.radomski@cs.tu-darmstadt.de)
+ * @copyright Simplified BSD
+ *
+ * @cond
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the FreeBSD license as published by the FreeBSD
+ * project.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the FreeBSD license along with this
+ * program. If not, see <http://www.opensource.org/licenses/bsd-license>.
+ * @endcond
+ */
+
+#ifndef PLUGINS_H_M6G1NF1E
+#define PLUGINS_H_M6G1NF1E
+
+#include "uscxml/config.h"
+#include <Pluma/Pluma.hpp>
+#include "uscxml/plugins/DataModelImpl.h"
+#include "uscxml/plugins/IOProcessorImpl.h"
+#include "uscxml/plugins/InvokerImpl.h"
+#include "uscxml/plugins/ExecutableContentImpl.h"
+
+namespace uscxml {
+
+#ifdef BUILD_AS_PLUGINS
+PLUMA_PROVIDER_HEADER(IOProcessorImpl)
+PLUMA_PROVIDER_HEADER(InvokerImpl)
+PLUMA_PROVIDER_HEADER(ExecutableContentImpl)
+PLUMA_PROVIDER_HEADER(DataModelImpl)
+#endif
+
+}
+
+#endif /* end of include guard: PLUGINS_H_M6G1NF1E */
diff --git a/src/uscxml/plugins/datamodel/CMakeLists.txt b/src/uscxml/plugins/datamodel/CMakeLists.txt
index a208856..24a1ea0 100644
--- a/src/uscxml/plugins/datamodel/CMakeLists.txt
+++ b/src/uscxml/plugins/datamodel/CMakeLists.txt
@@ -5,8 +5,19 @@ file(GLOB NULL_DATAMODEL
null/*.cpp
null/*.h
)
-list (APPEND USCXML_FILES ${NULL_DATAMODEL})
-
+if (BUILD_AS_PLUGINS)
+ source_group("Null" FILES ${NULL_DATAMODEL})
+ add_library(
+ datamodel_null SHARED
+ ${NULL_DATAMODEL}
+ "../Plugins.cpp")
+ target_link_libraries(datamodel_null uscxml)
+ set_target_properties(datamodel_null PROPERTIES FOLDER "Plugins//DataModel")
+ set_target_properties(datamodel_null PROPERTIES COMPILE_FLAGS "-DPLUMA_EXPORTS")
+ set_target_properties(datamodel_null PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/plugins")
+else()
+ list (APPEND USCXML_FILES ${NULL_DATAMODEL})
+endif()
if (JSC_FOUND)
set(USCXML_DATAMODELS "ecmascript(JSC) ${USCXML_DATAMODELS}")
@@ -17,8 +28,20 @@ if (JSC_FOUND)
ecmascript/*.cpp
ecmascript/*.h
)
- list (APPEND USCXML_FILES ${JSC_DATAMODEL})
- list (APPEND USCXML_OPT_LIBS ${JSC_LIBRARY})
+ if (BUILD_AS_PLUGINS)
+ source_group("JavaScriptCore" FILES ${JSC_DATAMODEL})
+ add_library(
+ datamodel_jsc SHARED
+ ${JSC_DATAMODEL}
+ "../Plugins.cpp")
+ target_link_libraries(datamodel_jsc uscxml ${JSC_LIBRARY})
+ set_target_properties(datamodel_jsc PROPERTIES FOLDER "Plugins//DataModel")
+ set_target_properties(datamodel_jsc PROPERTIES COMPILE_FLAGS "-DPLUMA_EXPORTS")
+ set_target_properties(datamodel_jsc PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/plugins")
+ else()
+ list (APPEND USCXML_FILES ${JSC_DATAMODEL})
+ list (APPEND USCXML_OPT_LIBS ${JSC_LIBRARY})
+ endif()
endif()
@@ -31,8 +54,21 @@ if (V8_FOUND)
ecmascript/*.cpp
ecmascript/*.h
)
- list (APPEND USCXML_FILES ${V8_DATAMODEL})
- list (APPEND USCXML_OPT_LIBS ${V8_LIBRARY})
+ if (BUILD_AS_PLUGINS)
+ source_group("V8" FILES ${V8_DATAMODEL})
+
+ add_library(
+ datamodel_v8 SHARED
+ ${V8_DATAMODEL}
+ "../Plugins.cpp")
+ target_link_libraries(datamodel_v8 uscxml ${V8_LIBRARY})
+ set_target_properties(datamodel_v8 PROPERTIES FOLDER "Plugins//DataModel")
+ set_target_properties(datamodel_v8 PROPERTIES COMPILE_FLAGS "-DPLUMA_EXPORTS")
+ set_target_properties(datamodel_v8 PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/plugins")
+ else()
+ list (APPEND USCXML_FILES ${V8_DATAMODEL})
+ list (APPEND USCXML_OPT_LIBS ${V8_LIBRARY})
+ endif()
endif()
@@ -43,8 +79,20 @@ if (LUA51_FOUND AND WITH_DM_LUA)
lua/*.cpp
lua/*.h
)
- list (APPEND USCXML_FILES ${LUA_DATAMODEL})
- list (APPEND USCXML_OPT_LIBS ${LUA_LIBRARY})
+ if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${LUA_DATAMODEL})
+ add_library(datamodel_lua SHARED ${LUA_DATAMODEL} "../Plugins.cpp")
+ target_link_libraries(datamodel_lua
+ uscxml
+ ${LUA_LIBRARIES}
+ )
+ set_target_properties(datamodel_lua PROPERTIES FOLDER "Plugins//DataModel")
+ set_target_properties(datamodel_lua PROPERTIES COMPILE_FLAGS "-DPLUMA_EXPORTS")
+ set_target_properties(datamodel_lua PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/plugins")
+ else()
+ list (APPEND USCXML_FILES ${LUA_DATAMODEL})
+ list (APPEND USCXML_OPT_LIBS ${LUA_LIBRARY})
+ endif()
endif()
if (WITH_DM_C89)
@@ -55,7 +103,18 @@ if (WITH_DM_C89)
c89/*.c
c89/*.h
)
- list (APPEND USCXML_FILES ${C89_DATAMODEL})
+ if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${C89_DATAMODEL})
+ add_library(datamodel_c89 SHARED ${C89_DATAMODEL} "../Plugins.cpp")
+ target_link_libraries(datamodel_c89
+ uscxml
+ )
+ set_target_properties(datamodel_c89 PROPERTIES FOLDER "Plugins//DataModel")
+ set_target_properties(datamodel_c89 PROPERTIES COMPILE_FLAGS "-DPLUMA_EXPORTS")
+ set_target_properties(datamodel_c89 PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/plugins")
+ else()
+ list (APPEND USCXML_FILES ${C89_DATAMODEL})
+ endif()
endif()
if (WITH_DM_PROMELA)
@@ -66,7 +125,22 @@ if (WITH_DM_PROMELA)
promela/*.c
promela/*.h
)
- list (APPEND USCXML_FILES ${PROMELA_DATAMODEL})
+ if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${PROMELA_DATAMODEL})
+ add_library(datamodel_promela SHARED ${PROMELA_DATAMODEL} "../Plugins.cpp")
+ target_link_libraries(datamodel_promela
+ uscxml
+ )
+ # SET_SOURCE_FILES_PROPERTIES is directory scope
+ if (${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
+ SET_SOURCE_FILES_PROPERTIES(promela/parser/promela.lex.yy.cpp PROPERTIES COMPILE_FLAGS -Wno-deprecated-register )
+ endif()
+ set_target_properties(datamodel_promela PROPERTIES FOLDER "Plugins//DataModel")
+ set_target_properties(datamodel_promela PROPERTIES COMPILE_FLAGS "-DPLUMA_EXPORTS")
+ set_target_properties(datamodel_promela PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/plugins")
+ else()
+ list (APPEND USCXML_FILES ${PROMELA_DATAMODEL})
+ endif()
endif()
if (NOT SWIG_FOUND)
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp
index 5ce6128..66bf45a 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp
@@ -22,7 +22,6 @@
#include "uscxml/util/String.h"
#include "JSCDataModel.h"
-//#include "JSCSCXMLEvent.h"
#include "uscxml/messages/Event.h"
#include "uscxml/util/DOM.h"
@@ -32,6 +31,10 @@
#include <string>
#include <boost/algorithm/string.hpp>
+#ifdef BUILD_AS_PLUGINS
+#include <Pluma/Connector.hpp>
+#endif
+
#define EVENT_STRING_OR_UNDEF(field, cond) \
JSStringRef field##Name = JSStringCreateWithUTF8CString( #field ); \
JSStringRef field##Val = JSStringCreateWithUTF8CString(event.field.c_str()); \
@@ -193,7 +196,7 @@ bool JSCNodeListHasPropertyCallback(JSContextRef ctx, JSObjectRef object, JSStri
return false;
}
- int index = strTo<int>(propName);
+ size_t index = strTo<size_t>(propName);
SwigPrivData* t = (SwigPrivData*) JSObjectGetPrivate(object);
DOMNodeList* nodeList = (DOMNodeList*)t->swigCObject;
@@ -216,7 +219,7 @@ JSValueRef JSCNodeListGetPropertyCallback(JSContextRef context, JSObjectRef obje
return JSValueMakeUndefined(context);
}
- int index = strTo<int>(propName);
+ size_t index = strTo<size_t>(propName);
SwigPrivData* t = (SwigPrivData*) JSObjectGetPrivate(object);
DOMNodeList* nodeList = (DOMNodeList*)t->swigCObject;
@@ -316,7 +319,7 @@ void JSCDataModel::setEvent(const Event& event) {
case Event::INTERNAL:
eventTypeVal = JSStringCreateWithUTF8CString("internal");
break;
- case Event::PLATFORM:
+ default:
eventTypeVal = JSStringCreateWithUTF8CString("platform");
break;
}
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h
index 3a53da2..cd992ea 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h
@@ -126,7 +126,7 @@ protected:
};
#ifdef BUILD_AS_PLUGINS
-PLUMA_INHERIT_PROVIDER(JSCDataModel, DataModelImpl);
+PLUMA_INHERIT_PROVIDER(JSCDataModel, DataModelImpl)
#endif
}
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
index 61eb815..84cfa81 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
@@ -35,6 +35,10 @@
#include <boost/algorithm/string.hpp>
+#ifdef BUILD_AS_PLUGINS
+#include <Pluma/Connector.hpp>
+#endif
+
using namespace XERCESC_NS;
static v8::Local<v8::Value> XMLString2JS(const XMLCh* input) {
@@ -56,6 +60,14 @@ static XMLCh* JS2XMLString(const v8::Local<v8::Value>& value) {
namespace uscxml {
+#ifdef BUILD_AS_PLUGINS
+PLUMA_CONNECTOR
+bool pluginConnect(pluma::Host& host) {
+ host.add( new V8DataModelProvider() );
+ return true;
+}
+#endif
+
V8DataModel::V8DataModel() {
// _contexts.push_back(v8::Context::New());
}
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h
index a9dbca1..00a871b 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h
@@ -20,6 +20,7 @@
#ifndef V8DATAMODEL_H_KN8TWG0V
#define V8DATAMODEL_H_KN8TWG0V
+#include "uscxml/config.h"
#include "uscxml/plugins/DataModelImpl.h"
#include <list>
diff --git a/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp b/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp
index fccc5f0..607f994 100644
--- a/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp
@@ -42,8 +42,20 @@
//#include "LuaDOM.cpp.inc"
+#ifdef BUILD_AS_PLUGINS
+#include <Pluma/Connector.hpp>
+#endif
+
namespace uscxml {
+#ifdef BUILD_AS_PLUGINS
+PLUMA_CONNECTOR
+bool pluginConnect(pluma::Host& host) {
+ host.add( new LuaDataModelProvider() );
+ return true;
+}
+#endif
+
//static int luaInspect(lua_State * l) {
// return 0;
//}
@@ -194,20 +206,23 @@ int LuaDataModel::luaInFunction(lua_State * l) {
std::shared_ptr<DataModelImpl> LuaDataModel::create(DataModelCallbacks* callbacks) {
std::shared_ptr<LuaDataModel> dm(new LuaDataModel());
+
dm->_callbacks = callbacks;
dm->_luaState = luaL_newstate();
luaL_openlibs(dm->_luaState);
try {
const luabridge::LuaRef& requireFunc = luabridge::getGlobal(dm->_luaState, "require");
- const luabridge::LuaRef& resultLxp = requireFunc("lxp");
- const luabridge::LuaRef& resultLxpLOM = requireFunc("lxp.lom");
-
- // MSVC compiler bug with implicit cast operators, see comments in LuaRef class
- if ((bool)resultLxp && (bool)resultLxpLOM) {
- _luaHasXMLParser = true;
- luabridge::setGlobal(dm->_luaState, resultLxp, "lxp");
- luabridge::setGlobal(dm->_luaState, resultLxpLOM, "lxp.lom");
+ if (requireFunc.isFunction()) {
+ const luabridge::LuaRef& resultLxp = requireFunc("lxp");
+ const luabridge::LuaRef& resultLxpLOM = requireFunc("lxp.lom");
+
+ // MSVC compiler bug with implicit cast operators, see comments in LuaRef class
+ if ((bool)resultLxp && (bool)resultLxpLOM) {
+ _luaHasXMLParser = true;
+ luabridge::setGlobal(dm->_luaState, resultLxp, "lxp");
+ luabridge::setGlobal(dm->_luaState, resultLxpLOM, "lxp.lom");
+ }
}
} catch (luabridge::LuaException e) {
LOG(_callbacks->getLogger(), USCXML_INFO) << e.what();
diff --git a/src/uscxml/plugins/datamodel/lua/LuaDataModel.h b/src/uscxml/plugins/datamodel/lua/LuaDataModel.h
index 85d7b53..ad86872 100644
--- a/src/uscxml/plugins/datamodel/lua/LuaDataModel.h
+++ b/src/uscxml/plugins/datamodel/lua/LuaDataModel.h
@@ -20,6 +20,7 @@
#ifndef LUADATAMODEL_H_113E014C
#define LUADATAMODEL_H_113E014C
+#include "uscxml/config.h"
#include "uscxml/plugins/DataModelImpl.h"
#include <list>
@@ -92,7 +93,7 @@ protected:
};
#ifdef BUILD_AS_PLUGINS
-PLUMA_INHERIT_PROVIDER(LuaDataModel, DataModelImpl);
+PLUMA_INHERIT_PROVIDER(LuaDataModel, DataModelImpl)
#endif
}
diff --git a/src/uscxml/plugins/datamodel/null/NULLDataModel.cpp b/src/uscxml/plugins/datamodel/null/NULLDataModel.cpp
index 53c414f..efa77fa 100644
--- a/src/uscxml/plugins/datamodel/null/NULLDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/null/NULLDataModel.cpp
@@ -20,7 +20,7 @@
#include <boost/algorithm/string.hpp>
#include "uscxml/Common.h"
-#include "NULLDataModel.h"
+#include "NullDataModel.h"
#include "uscxml/util/DOM.h"
#ifdef BUILD_AS_PLUGINS
@@ -32,24 +32,24 @@ namespace uscxml {
#ifdef BUILD_AS_PLUGINS
PLUMA_CONNECTOR
bool pluginConnect(pluma::Host& host) {
- host.add( new NULLDataModelProvider() );
+ host.add( new NullDataModelProvider() );
return true;
}
#endif
-NULLDataModel::NULLDataModel() {
+NullDataModel::NullDataModel() {
}
-std::shared_ptr<DataModelImpl> NULLDataModel::create(DataModelCallbacks* callbacks) {
- std::shared_ptr<NULLDataModel> dm(new NULLDataModel());
+std::shared_ptr<DataModelImpl> NullDataModel::create(DataModelCallbacks* callbacks) {
+ std::shared_ptr<NullDataModel> dm(new NullDataModel());
dm->_callbacks = callbacks;
return dm;
}
-NULLDataModel::~NULLDataModel() {
+NullDataModel::~NullDataModel() {
}
-Data NULLDataModel::getAsData(const std::string& content) {
+Data NullDataModel::getAsData(const std::string& content) {
Data data = Data::fromJSON(content);
if (data.empty()) {
data = Data(content, Data::VERBATIM);
@@ -63,7 +63,7 @@ Data NULLDataModel::getAsData(const std::string& content) {
* The predicate must return 'true' if and only if that state is in the current
* state configuration.
*/
-bool NULLDataModel::evalAsBool(const XERCESC_NS::DOMElement* scriptNode, const std::string& expr) {
+bool NullDataModel::evalAsBool(const XERCESC_NS::DOMElement* scriptNode, const std::string& expr) {
std::string trimmedExpr = expr;
boost::trim(trimmedExpr);
if (!boost::istarts_with(trimmedExpr, "in"))
@@ -105,4 +105,4 @@ bool NULLDataModel::evalAsBool(const XERCESC_NS::DOMElement* scriptNode, const s
return true;
}
-} \ No newline at end of file
+}
diff --git a/src/uscxml/plugins/datamodel/null/NULLDataModel.h b/src/uscxml/plugins/datamodel/null/NULLDataModel.h
index fba8577..8c9f5b9 100644
--- a/src/uscxml/plugins/datamodel/null/NULLDataModel.h
+++ b/src/uscxml/plugins/datamodel/null/NULLDataModel.h
@@ -20,6 +20,7 @@
#ifndef NULLDATAMODEL_H_KN8TWG0V
#define NULLDATAMODEL_H_KN8TWG0V
+#include "uscxml/config.h"
#include "uscxml/plugins/DataModelImpl.h"
#include <list>
@@ -38,10 +39,10 @@ namespace uscxml {
* @ingroup datamodel
* NULL data-model.
*/
-class NULLDataModel : public DataModelImpl {
+class NullDataModel : public DataModelImpl {
public:
- NULLDataModel();
- virtual ~NULLDataModel();
+ NullDataModel();
+ virtual ~NullDataModel();
virtual std::shared_ptr<DataModelImpl> create(DataModelCallbacks* callbacks);
virtual std::list<std::string> getNames() {
@@ -104,7 +105,7 @@ protected:
};
#ifdef BUILD_AS_PLUGINS
-PLUMA_INHERIT_PROVIDER(NULLDataModel, DataModelImpl);
+PLUMA_INHERIT_PROVIDER(NullDataModel, DataModelImpl)
#endif
}
diff --git a/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp b/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp
index 14d24c3..5adf337 100644
--- a/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp
@@ -17,15 +17,13 @@
* @endcond
*/
-#include <boost/algorithm/string.hpp>
-
#include "uscxml/Common.h"
-#include "uscxml/config.h"
#include "uscxml/util/String.h"
#include "PromelaDataModel.h"
#include "uscxml/util/DOM.h"
#include <cctype>
+#include <boost/algorithm/string.hpp>
#include "PromelaParser.h"
#include "parser/promela.tab.hpp"
@@ -337,7 +335,7 @@ void PromelaDataModel::setEvent(const Event& event) {
int size = dataToInt(evaluateExpr(*opIterAsgn++));
variable.compound["size"] = Data(size);
- for (size_t i = 0; i < size; i++) {
+ for (int i = 0; i < size; i++) {
variable.compound["value"].array.push_back(Data(0, Data::INTERPRETED));
}
diff --git a/src/uscxml/plugins/datamodel/promela/PromelaDataModel.h b/src/uscxml/plugins/datamodel/promela/PromelaDataModel.h
index 4a763ac..f19bd5d 100644
--- a/src/uscxml/plugins/datamodel/promela/PromelaDataModel.h
+++ b/src/uscxml/plugins/datamodel/promela/PromelaDataModel.h
@@ -20,6 +20,7 @@
#ifndef PROMELADATAMODEL_H_4VG0TDMU
#define PROMELADATAMODEL_H_4VG0TDMU
+#include "uscxml/config.h"
#include "uscxml/plugins/DataModelImpl.h"
#include <list>
@@ -96,7 +97,7 @@ protected:
};
#ifdef BUILD_AS_PLUGINS
-PLUMA_INHERIT_PROVIDER(PromelaDataModel, DataModelImpl);
+PLUMA_INHERIT_PROVIDER(PromelaDataModel, DataModelImpl)
#endif
}
diff --git a/src/uscxml/plugins/datamodel/promela/PromelaParser.cpp b/src/uscxml/plugins/datamodel/promela/PromelaParser.cpp
index 57f694a..44f8bdd 100644
--- a/src/uscxml/plugins/datamodel/promela/PromelaParser.cpp
+++ b/src/uscxml/plugins/datamodel/promela/PromelaParser.cpp
@@ -43,7 +43,7 @@ void promela_error (void* yylloc_param, uscxml::PromelaParser* ctx, void* yyscan
excEvent.data.compound["col"] = uscxml::Data(yylloc->first_column, uscxml::Data::VERBATIM);
std::stringstream ssUnderline;
- for (size_t i = 0; i < yylloc->first_column; i++)
+ for (int i = 0; i < yylloc->first_column; i++)
ssUnderline << " ";
ssUnderline << "^";
excEvent.data.compound["sourcemark"] = uscxml::Data(ssUnderline.str(), uscxml::Data::VERBATIM);
@@ -196,7 +196,7 @@ void PromelaParserNode::push(PromelaParserNode* node) {
operands.push_back(node);
}
-void PromelaParserNode::dump(int indent) {
+void PromelaParserNode::dump(size_t indent) {
std::string padding;
for (size_t i = 0; i < indent; i++) {
padding += " ";
diff --git a/src/uscxml/plugins/datamodel/promela/PromelaParser.h b/src/uscxml/plugins/datamodel/promela/PromelaParser.h
index 236233d..45ea341 100644
--- a/src/uscxml/plugins/datamodel/promela/PromelaParser.h
+++ b/src/uscxml/plugins/datamodel/promela/PromelaParser.h
@@ -48,7 +48,7 @@ public:
void merge(PromelaParserNode* node);
void push(PromelaParserNode* node);
- void dump(int indent = 0);
+ void dump(size_t indent = 0);
static std::string typeToDesc(int type);
diff --git a/src/uscxml/plugins/invoker/CMakeLists.txt b/src/uscxml/plugins/invoker/CMakeLists.txt
index 5500e3f..9f50684 100644
--- a/src/uscxml/plugins/invoker/CMakeLists.txt
+++ b/src/uscxml/plugins/invoker/CMakeLists.txt
@@ -6,7 +6,18 @@ if (WITH_INV_SCXML)
file(GLOB_RECURSE USCXML_INVOKER
scxml/*.cpp
scxml/*.h)
+ if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${USCXML_INVOKER})
+ add_library(invoker_uscxml SHARED ${USCXML_INVOKER} "../Plugins.cpp")
+ target_link_libraries(invoker_uscxml
+ uscxml
+ )
+ set_target_properties(invoker_uscxml PROPERTIES FOLDER "Plugins//Invoker")
+ set_target_properties(invoker_uscxml PROPERTIES COMPILE_FLAGS "-DPLUMA_EXPORTS")
+ set_target_properties(invoker_uscxml PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/plugins")
+ else()
list (APPEND USCXML_FILES ${USCXML_INVOKER})
+ endif()
endif()
# Directoy Monitor
@@ -17,7 +28,18 @@ if (WITH_INV_DIRMON)
file(GLOB_RECURSE DIRMON_INVOKER
dirmon/*.cpp
dirmon/*.h)
+ if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${DIRMON_INVOKER})
+ add_library(invoker_dirmon SHARED ${DIRMON_INVOKER} "../Plugins.cpp")
+ target_link_libraries(invoker_dirmon
+ uscxml
+ )
+ set_target_properties(invoker_dirmon PROPERTIES FOLDER "Plugins//Invoker")
+ set_target_properties(invoker_dirmon PROPERTIES COMPILE_FLAGS "-DPLUMA_EXPORTS")
+ set_target_properties(invoker_dirmon PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/plugins")
+ else()
list (APPEND USCXML_FILES ${DIRMON_INVOKER})
+ endif()
endif()
set(USCXML_INCLUDE_DIRS ${USCXML_INCLUDE_DIRS} PARENT_SCOPE)
diff --git a/src/uscxml/plugins/invoker/dirmon/DirMonInvoker.cpp b/src/uscxml/plugins/invoker/dirmon/DirMonInvoker.cpp
index be13bf4..e9cf702 100644
--- a/src/uscxml/plugins/invoker/dirmon/DirMonInvoker.cpp
+++ b/src/uscxml/plugins/invoker/dirmon/DirMonInvoker.cpp
@@ -19,8 +19,6 @@
#include "DirMonInvoker.h"
-#include "uscxml/config.h"
-
#ifdef BUILD_AS_PLUGINS
#include <Pluma/Connector.hpp>
#endif
@@ -62,7 +60,7 @@ DirMonInvoker::~DirMonInvoker() {
}
if (_watcher)
delete(_watcher);
-};
+}
std::shared_ptr<InvokerImpl> DirMonInvoker::create(InvokerCallbacks* callbacks) {
std::shared_ptr<DirMonInvoker> invoker(new DirMonInvoker());
diff --git a/src/uscxml/plugins/invoker/dirmon/DirMonInvoker.h b/src/uscxml/plugins/invoker/dirmon/DirMonInvoker.h
index dffbe14..6d9911f 100644
--- a/src/uscxml/plugins/invoker/dirmon/DirMonInvoker.h
+++ b/src/uscxml/plugins/invoker/dirmon/DirMonInvoker.h
@@ -20,6 +20,7 @@
#ifndef DIRMONINVOKER_H_W09J90F0
#define DIRMONINVOKER_H_W09J90F0
+#include "uscxml/config.h"
#include "uscxml/plugins/InvokerImpl.h"
#include "uscxml/interpreter/Logging.h"
@@ -139,7 +140,7 @@ protected:
};
#ifdef BUILD_AS_PLUGINS
-PLUMA_INHERIT_PROVIDER(DirMonInvoker, InvokerImpl);
+PLUMA_INHERIT_PROVIDER(DirMonInvoker, InvokerImpl)
#endif
}
diff --git a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp
index b035993..d3bc5bf 100644
--- a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp
+++ b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp
@@ -19,8 +19,6 @@
#include "USCXMLInvoker.h"
-#include "uscxml/config.h"
-
#ifdef BUILD_AS_PLUGINS
#include <Pluma/Connector.hpp>
#endif
@@ -52,7 +50,7 @@ USCXMLInvoker::USCXMLInvoker() {
USCXMLInvoker::~USCXMLInvoker() {
stop();
-};
+}
void USCXMLInvoker::start() {
_isStarted = true;
@@ -184,7 +182,7 @@ void USCXMLInvoker::invoke(const std::string& source, const Event& invokeEvent)
InterpreterImpl* invoked = _invokedInterpreter.getImpl().get();
ActionLanguage al = _callbacks->getActionLanguage();
- // create new instances
+ // create new instances
al.execContent = al.execContent.getImpl()->create(invoked);
al.delayQueue = al.delayQueue.getImplDelayed()->create(invoked);
al.internalQueue = al.internalQueue.getImplBase()->create();
diff --git a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.h b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.h
index d37d2af..61931c6 100644
--- a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.h
+++ b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.h
@@ -20,6 +20,7 @@
#ifndef USCXMLINVOKER_H_OQFA21IO
#define USCXMLINVOKER_H_OQFA21IO
+#include "uscxml/config.h"
#include "uscxml/interpreter/InterpreterImpl.h"
#include "uscxml/interpreter/BasicEventQueue.h"
@@ -88,7 +89,7 @@ protected:
};
#ifdef BUILD_AS_PLUGINS
-PLUMA_INHERIT_PROVIDER(USCXMLInvoker, InvokerImpl);
+PLUMA_INHERIT_PROVIDER(USCXMLInvoker, InvokerImpl)
#endif
}
diff --git a/src/uscxml/plugins/ioprocessor/CMakeLists.txt b/src/uscxml/plugins/ioprocessor/CMakeLists.txt
index 3505920..fb4315b 100644
--- a/src/uscxml/plugins/ioprocessor/CMakeLists.txt
+++ b/src/uscxml/plugins/ioprocessor/CMakeLists.txt
@@ -7,7 +7,18 @@ if (WITH_IOPROC_SCXML)
scxml/*.cpp
scxml/*.h
)
- list (APPEND USCXML_FILES ${SCXML_IOPROCESSOR})
+ if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${SCXML_IOPROCESSOR})
+ add_library(ioproc_scxml SHARED ${SCXML_IOPROCESSOR} "../Plugins.cpp")
+ target_link_libraries(ioproc_scxml
+ uscxml
+ )
+ set_target_properties(ioproc_scxml PROPERTIES FOLDER "Plugins//IO Processors")
+ set_target_properties(ioproc_scxml PROPERTIES COMPILE_FLAGS "-DPLUMA_EXPORTS")
+ set_target_properties(ioproc_scxml PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/plugins")
+ else()
+ list (APPEND USCXML_FILES ${SCXML_IOPROCESSOR})
+ endif()
endif()
OPTION(WITH_IOPROC_BASICHTTP "Build the basichttp i/o processor" ON)
@@ -17,8 +28,18 @@ if (WITH_IOPROC_BASICHTTP)
basichttp/*.cpp
basichttp/*.h
)
- list (APPEND BASICHTTP_IOPROCESSOR "")
- list (APPEND USCXML_FILES ${BASICHTTP_IOPROCESSOR})
+ if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${BASICHTTP_IOPROCESSOR})
+ add_library(ioproc_basichttp SHARED ${BASICHTTP_IOPROCESSOR} "../Plugins.cpp")
+ target_link_libraries(ioproc_basichttp
+ uscxml
+ )
+ set_target_properties(ioproc_basichttp PROPERTIES FOLDER "Plugins//IO Processors")
+ set_target_properties(ioproc_basichttp PROPERTIES COMPILE_FLAGS "-DPLUMA_EXPORTS")
+ set_target_properties(ioproc_basichttp PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/plugins")
+ else()
+ list (APPEND USCXML_FILES ${BASICHTTP_IOPROCESSOR})
+ endif()
endif()
set(USCXML_INCLUDE_DIRS ${USCXML_INCLUDE_DIRS} PARENT_SCOPE)
diff --git a/src/uscxml/plugins/ioprocessor/basichttp/BasicHTTPIOProcessor.h b/src/uscxml/plugins/ioprocessor/basichttp/BasicHTTPIOProcessor.h
index dec22fe..5ec66ec 100644
--- a/src/uscxml/plugins/ioprocessor/basichttp/BasicHTTPIOProcessor.h
+++ b/src/uscxml/plugins/ioprocessor/basichttp/BasicHTTPIOProcessor.h
@@ -20,6 +20,8 @@
#ifndef BASICHTTPIOPROCESSOR_H_2CUY93KU
#define BASICHTTPIOPROCESSOR_H_2CUY93KU
+#include "uscxml/config.h"
+
extern "C" {
#include <event2/http.h>
#include <event2/http_struct.h>
@@ -93,11 +95,8 @@ protected:
std::map<std::string, std::pair<URL, Event> > _sendRequests;
};
-// do not implement pluma plugins if we build an inherited plugin
-#ifdef ioprocessor_basichttp_EXPORTS
-# ifdef BUILD_AS_PLUGINS
-PLUMA_INHERIT_PROVIDER(BasicHTTPIOProcessor, IOProcessorImpl);
-# endif
+#ifdef BUILD_AS_PLUGINS
+PLUMA_INHERIT_PROVIDER(BasicHTTPIOProcessor, IOProcessorImpl)
#endif
}
diff --git a/src/uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.cpp b/src/uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.cpp
index 5a82860..33a725e 100644
--- a/src/uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.cpp
+++ b/src/uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.cpp
@@ -30,8 +30,20 @@
#include <arpa/inet.h>
#endif
+#ifdef BUILD_AS_PLUGINS
+#include <Pluma/Connector.hpp>
+#endif
+
namespace uscxml {
+#ifdef BUILD_AS_PLUGINS
+PLUMA_CONNECTOR
+bool pluginConnect(pluma::Host& host) {
+ host.add( new SCXMLIOProcessorProvider() );
+ return true;
+}
+#endif
+
// see http://www.w3.org/TR/scxml/#SCXMLEventProcessor
SCXMLIOProcessor::SCXMLIOProcessor() {
diff --git a/src/uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.h b/src/uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.h
index 6494873..328e18e 100644
--- a/src/uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.h
+++ b/src/uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.h
@@ -20,8 +20,13 @@
#ifndef SCXMLIOProcessor_H_2CUY93KU
#define SCXMLIOProcessor_H_2CUY93KU
+#include "uscxml/config.h"
#include "uscxml/plugins/IOProcessorImpl.h"
+#ifdef BUILD_AS_PLUGINS
+#include "uscxml/plugins/Plugins.h"
+#endif
+
namespace uscxml {
/**
@@ -45,12 +50,10 @@ public:
virtual bool isValidTarget(const std::string& target);
Data getDataModelVariables();
-protected:
- IOProcessorCallbacks* _callbacks;
};
#ifdef BUILD_AS_PLUGINS
-PLUMA_INHERIT_PROVIDER(SCXMLIOProcessor, IOProcessorImpl);
+PLUMA_INHERIT_PROVIDER(SCXMLIOProcessor, IOProcessorImpl)
#endif
}
diff --git a/src/uscxml/transform/ChartToC.cpp b/src/uscxml/transform/ChartToC.cpp
index 932ac73..7deef17 100644
--- a/src/uscxml/transform/ChartToC.cpp
+++ b/src/uscxml/transform/ChartToC.cpp
@@ -309,7 +309,18 @@ void ChartToC::prepare() {
}
// set transitions' postfix order attribute
- tmp = DOMUtils::inPostFixOrder({ XML_PREFIX(_scxml).str() + "transition" }, _scxml);
+// tmp = DOMUtils::inPostFixOrder({ XML_PREFIX(_scxml).str() + "transition" }, _scxml);
+
+ tmp = DOMUtils::inPostFixOrder({
+ XML_PREFIX(_scxml).str() + "scxml",
+ XML_PREFIX(_scxml).str() + "state",
+ XML_PREFIX(_scxml).str() + "final",
+ XML_PREFIX(_scxml).str() + "history",
+ XML_PREFIX(_scxml).str() + "initial",
+ XML_PREFIX(_scxml).str() + "parallel"
+ }, _scxml);
+ tmp = DOMUtils::filterChildElements(XML_PREFIX(_scxml).str() + "transition", tmp);
+
_transitions.insert(_transitions.end(), tmp.begin(), tmp.end());
for (size_t i = 0; i < _transitions.size(); i++) {
diff --git a/src/uscxml/transform/ChartToPromela.cpp b/src/uscxml/transform/ChartToPromela.cpp
index ec11a76..7b1c327 100644
--- a/src/uscxml/transform/ChartToPromela.cpp
+++ b/src/uscxml/transform/ChartToPromela.cpp
@@ -816,7 +816,7 @@ void ChartToPromela::writeTransitions(std::ostream& stream) {
if (HAS_ATTR(transition, "conflictBools")) {
std::string conflicts = ATTR(transition, "conflictBools");
- for (auto j = 0; j < conflicts.size(); j++) {
+ for (size_t j = 0; j < conflicts.size(); j++) {
if (conflicts[j] == '1')
stream << " " << _prefix << "transitions[" << toStr(i) << "].conflicts[" << toStr(j) << "] = 1;" << std::endl;
}
@@ -824,7 +824,7 @@ void ChartToPromela::writeTransitions(std::ostream& stream) {
if (HAS_ATTR(transition, "exitSetBools")) {
std::string exitSet = ATTR(transition, "exitSetBools");
- for (auto j = 0; j < exitSet.size(); j++) {
+ for (size_t j = 0; j < exitSet.size(); j++) {
if (exitSet[j] == '1')
stream << " " << _prefix << "transitions[" << toStr(i) << "].exit_set[" << toStr(j) << "] = 1;" << std::endl;
}
@@ -848,7 +848,7 @@ void ChartToPromela::writeStates(std::ostream& stream) {
if (HAS_ATTR(state, "childBools")) {
std::string childs = ATTR(state, "childBools");
- for (auto j = 0; j < childs.size(); j++) {
+ for (size_t j = 0; j < childs.size(); j++) {
if (childs[j] == '1')
stream << " " << _prefix << "states[" << toStr(i) << "].children[" << toStr(j) << "] = 1;" << std::endl;
}
@@ -856,7 +856,7 @@ void ChartToPromela::writeStates(std::ostream& stream) {
if (HAS_ATTR(state, "completionBools")) {
std::string completions = ATTR(state, "completionBools");
- for (auto j = 0; j < completions.size(); j++) {
+ for (size_t j = 0; j < completions.size(); j++) {
if (completions[j] == '1')
stream << " " << _prefix << "states[" << toStr(i) << "].completion[" << toStr(j) << "] = 1;" << std::endl;
}
@@ -864,7 +864,7 @@ void ChartToPromela::writeStates(std::ostream& stream) {
if (HAS_ATTR(state, "ancBools")) {
std::string ancestors = ATTR(state, "ancBools");
- for (auto j = 0; j < ancestors.size(); j++) {
+ for (size_t j = 0; j < ancestors.size(); j++) {
if (ancestors[j] == '1')
stream << " " << _prefix << "states[" << toStr(i) << "].ancestors[" << toStr(j) << "] = 1;" << std::endl;
}
@@ -1849,7 +1849,7 @@ void ChartToPromela::writeFSMSelectTransitions(std::ostream& stream) {
stream << " (false " << std::endl;
- for (auto i = 0; i < _transitions.size(); i++) {
+ for (size_t i = 0; i < _transitions.size(); i++) {
stream << " || (i == " << toStr(i);
if (HAS_ATTR(_transitions[i], "event") && ATTR(_transitions[i], "event") != "*") {
stream << " && (false";
@@ -2333,7 +2333,7 @@ void ChartToPromela::writeFSMExitStates(std::ostream& stream) {
TRACE_EXECUTION_V("Exiting state %d", "i");
stream << " if" << std::endl;
- for (auto i = 0; i < _states.size(); i++) {
+ for (size_t i = 0; i < _states.size(); i++) {
std::list<DOMElement*> onexits = DOMUtils::filterChildElements(XML_PREFIX(_states[i]).str() + "onexit" , _states[i]);
if (onexits.size() > 0) {
stream << " :: i == " << toStr(i) << " -> {" << std::endl;
@@ -2374,7 +2374,7 @@ void ChartToPromela::writeFSMTakeTransitions(std::ostream& stream) {
TRACE_EXECUTION_V("Taking transition %d", "i");
stream << " if" << std::endl;
- for (auto i = 0; i < _transitions.size(); i++) {
+ for (size_t i = 0; i < _transitions.size(); i++) {
stream << " :: i == " << toStr(i) << " -> {" << std::endl;
TRACE_EXECUTION_V("Processing executable content for transition %d", "i");
writeExecContent(stream, _transitions[i], 4);
@@ -2428,7 +2428,7 @@ void ChartToPromela::writeFSMEnterStates(std::ostream& stream) {
stream << " /* Process executable content for entering a state */" << std::endl;
stream << " if" << std::endl;
- for (auto i = 0; i < _states.size(); i++) {
+ for (size_t i = 0; i < _states.size(); i++) {
std::list<DOMElement*> onentries = DOMUtils::filterChildElements(XML_PREFIX(_states[i]).str() + "onentry" , _states[i]);
if (onentries.size() > 0) {
stream << " :: i == " << toStr(i) << " -> {" << std::endl;
@@ -2454,7 +2454,7 @@ void ChartToPromela::writeFSMEnterStates(std::ostream& stream) {
stream << " " << _prefix << "states[" << _prefix << "transitions[j].source].parent == i) -> {" << std::endl;
stream << " /* Call executable content in history or initial transition */" << std::endl;
stream << " if" << std::endl;
- for (auto i = 0; i < _transitions.size(); i++) {
+ for (size_t i = 0; i < _transitions.size(); i++) {
stream << " :: j == " << toStr(i) << " -> {" << std::endl;
TRACE_EXECUTION_V("Processing executable content for transition %d", "j");
@@ -2642,7 +2642,7 @@ void ChartToPromela::writeFSMTerminateMachine(std::ostream& stream) {
stream << " :: " << _prefix << "config[i] && " << _prefix << "flags[USCXML_CTX_TOP_LEVEL_FINAL] -> {" << std::endl;
stream << " /* call all on exit handlers */" << std::endl;
stream << " if" << std::endl;
- for (auto i = 0; i < _states.size(); i++) {
+ for (size_t i = 0; i < _states.size(); i++) {
std::list<DOMElement*> onentries = DOMUtils::filterChildElements(XML_PREFIX(_states[i]).str() + "onexit" , _states[i]);
if (onentries.size() > 0) {
stream << " :: i == " << toStr(i) << " -> {" << std::endl;
@@ -2884,7 +2884,7 @@ std::string ChartToPromela::declForRange(const std::string& identifier, long min
}
}
-void ChartToPromela::writeDetermineShortestDelay(std::ostream& stream, int indent) {
+void ChartToPromela::writeDetermineShortestDelay(std::ostream& stream, size_t indent) {
std::string padding;
for (size_t i = 0; i < indent; i++) {
padding += " ";
@@ -2905,7 +2905,7 @@ void ChartToPromela::writeDetermineShortestDelay(std::ostream& stream, int inden
stream << padding << "}" << std::endl;
}
-void ChartToPromela::writeScheduleMachines(std::ostream& stream, int indent) {
+void ChartToPromela::writeScheduleMachines(std::ostream& stream, size_t indent) {
std::string padding;
for (size_t i = 0; i < indent; i++) {
padding += " ";
@@ -2963,7 +2963,7 @@ void ChartToPromela::writeScheduleMachines(std::ostream& stream, int indent) {
stream << padding << "}" << std::endl;
}
-void ChartToPromela::writeAdvanceTime(std::ostream& stream, int indent) {
+void ChartToPromela::writeAdvanceTime(std::ostream& stream, size_t indent) {
std::string padding;
for (size_t i = 0; i < indent; i++) {
padding += " ";
@@ -2986,7 +2986,7 @@ void ChartToPromela::writeAdvanceTime(std::ostream& stream, int indent) {
stream << padding << "}" << std::endl;
}
-void ChartToPromela::writeInsertWithDelay(std::ostream& stream, int indent) {
+void ChartToPromela::writeInsertWithDelay(std::ostream& stream, size_t indent) {
std::string padding;
for (size_t i = 0; i < indent; i++) {
padding += " ";
@@ -3089,7 +3089,7 @@ void ChartToPromela::writeInsertWithDelay(std::ostream& stream, int indent) {
stream << padding << "}" << std::endl;
}
-void ChartToPromela::writeRescheduleProcess(std::ostream& stream, int indent) {
+void ChartToPromela::writeRescheduleProcess(std::ostream& stream, size_t indent) {
std::string padding;
for (size_t i = 0; i < indent; i++) {
padding += " ";
@@ -3133,7 +3133,7 @@ void ChartToPromela::writeRescheduleProcess(std::ostream& stream, int indent) {
stream << padding << "}" << std::endl;
}
-void ChartToPromela::writeCancelEvents(std::ostream& stream, int indent) {
+void ChartToPromela::writeCancelEvents(std::ostream& stream, size_t indent) {
std::list<std::string> queues;
queues.push_back("eQ");
if (_allowEventInterleaving)
@@ -3166,7 +3166,7 @@ void ChartToPromela::writeCancelEvents(std::ostream& stream, int indent) {
stream << "}" << std::endl;
}
-void ChartToPromela::writeRemovePendingEventsFromInvoker(std::ostream& stream, int indent) {
+void ChartToPromela::writeRemovePendingEventsFromInvoker(std::ostream& stream, size_t indent) {
std::list<std::string> queues;
queues.push_back("eQ");
if (_allowEventInterleaving)
diff --git a/src/uscxml/transform/ChartToPromela.h b/src/uscxml/transform/ChartToPromela.h
index d846e03..ead0ef0 100644
--- a/src/uscxml/transform/ChartToPromela.h
+++ b/src/uscxml/transform/ChartToPromela.h
@@ -72,13 +72,13 @@ protected:
void writeStrings(std::ostream& stream);
- void writeCancelEvents(std::ostream& stream, int indent = 0);
- void writeScheduleMachines(std::ostream& stream, int indent = 0);
- void writeDetermineShortestDelay(std::ostream& stream, int indent = 0);
- void writeRescheduleProcess(std::ostream& stream, int indent = 0);
- void writeInsertWithDelay(std::ostream& stream, int indent = 0);
- void writeAdvanceTime(std::ostream& stream, int indent = 0);
- void writeRemovePendingEventsFromInvoker(std::ostream& stream, int indent = 0);
+ void writeCancelEvents(std::ostream& stream, size_t indent = 0);
+ void writeScheduleMachines(std::ostream& stream, size_t indent = 0);
+ void writeDetermineShortestDelay(std::ostream& stream, size_t indent = 0);
+ void writeRescheduleProcess(std::ostream& stream, size_t indent = 0);
+ void writeInsertWithDelay(std::ostream& stream, size_t indent = 0);
+ void writeAdvanceTime(std::ostream& stream, size_t indent = 0);
+ void writeRemovePendingEventsFromInvoker(std::ostream& stream, size_t indent = 0);
void prepare();
diff --git a/src/uscxml/transform/ChartToVHDL.cpp b/src/uscxml/transform/ChartToVHDL.cpp
index 0a344c8..578b310 100644
--- a/src/uscxml/transform/ChartToVHDL.cpp
+++ b/src/uscxml/transform/ChartToVHDL.cpp
@@ -766,13 +766,13 @@ void ChartToVHDL::writeEventController(std::ostream &stream) {
stream << "signal event_bus : std_logic_vector( " << _eventBitSize << " downto 0);" << std::endl;
stream << "signal event_we : std_logic;" << std::endl;
- for (int i = 0; i < _execContent.size(); i++) {
+ for (size_t i = 0; i < _execContent.size(); i++) {
stream << "signal done_" << toStr(i) << "_sig : std_logic;" << std::endl;
stream << "signal start_" << toStr(i) << "_sig : std_logic;" << std::endl;
}
stream << "-- sequence input line" << std::endl;
- for (int i = 0; i < _execContent.size(); i++) {
+ for (size_t i = 0; i < _execContent.size(); i++) {
stream << "signal seq_" << toStr(i) << "_sig : std_logic;" << std::endl;
}
stream << std::endl;
@@ -838,7 +838,7 @@ void ChartToVHDL::writeEventController(std::ostream &stream) {
stream << "ex_content_block : process (clk, rst) " << std::endl;
stream << "begin" << std::endl;
stream << " if rst = '1' then" << std::endl;
- for (int i = 0; i < _execContent.size(); i++) {
+ for (size_t i = 0; i < _execContent.size(); i++) {
stream << " done_" << toStr(i) << "_sig <= '0';" << std::endl;
}
stream << " event_bus <= (others => '0');" << std::endl;
@@ -981,7 +981,7 @@ void ChartToVHDL::writeConditionSolver(std::ostream &stream) {
stream << "signal rst : std_logic;" << std::endl;
stream << "signal micro_stepper_en : std_logic;" << std::endl;
- for (int i = 0; i < _execContent.size(); i++) {
+ for (size_t i = 0; i < _execContent.size(); i++) {
stream << "signal done_" << toStr(i) << "_sig : std_logic;" << std::endl;
stream << "signal start_" << toStr(i) << "_sig : std_logic;" << std::endl;
}
diff --git a/src/uscxml/transform/Trie.cpp b/src/uscxml/transform/Trie.cpp
index 8e3aff3..9966931 100644
--- a/src/uscxml/transform/Trie.cpp
+++ b/src/uscxml/transform/Trie.cpp
@@ -146,7 +146,7 @@ std::list<TrieNode*> Trie::getChildsWithWords(TrieNode* node) {
return nodes;
}
-void TrieNode::dump(int indent) {
+void TrieNode::dump(size_t indent) {
std::string padding;
for (size_t i = 0; i < indent; i++) {
padding += " ";
@@ -170,4 +170,4 @@ void Trie::dump() {
root->dump();
}
-} \ No newline at end of file
+}
diff --git a/src/uscxml/transform/Trie.h b/src/uscxml/transform/Trie.h
index 73d75e7..2c7da8b 100644
--- a/src/uscxml/transform/Trie.h
+++ b/src/uscxml/transform/Trie.h
@@ -36,7 +36,7 @@ struct USCXML_API TrieNode {
std::string identifier;
std::string value;
std::map<std::string, TrieNode*> childs;
- void dump(int indent = 0);
+ void dump(size_t indent = 0);
};
struct USCXML_API Trie {
diff --git a/src/uscxml/transform/promela/PromelaCodeAnalyzer.h b/src/uscxml/transform/promela/PromelaCodeAnalyzer.h
index 7f69ac9..2188ab1 100644
--- a/src/uscxml/transform/promela/PromelaCodeAnalyzer.h
+++ b/src/uscxml/transform/promela/PromelaCodeAnalyzer.h
@@ -38,8 +38,8 @@ public:
std::string name;
std::string type;
size_t arraySize = 0;
- size_t minValue = 0;
- size_t maxValue = 0;
+ int minValue = 0;
+ int maxValue = 0;
std::map<std::string, PromelaTypedef> types;
std::set<ChartToPromela*> occurrences;
diff --git a/src/uscxml/util/DOM.cpp b/src/uscxml/util/DOM.cpp
index f661ebb..c21dee1 100644
--- a/src/uscxml/util/DOM.cpp
+++ b/src/uscxml/util/DOM.cpp
@@ -21,9 +21,7 @@
#include "uscxml/Common.h"
#include "uscxml/util/Convenience.h"
-//#include "uscxml/util/UUID.h"
#include "uscxml/util/DOM.h"
-//#include "uscxml/util/Convenience.h"
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/dom/DOM.hpp>
@@ -31,9 +29,6 @@
#include "uscxml/interpreter/Logging.h"
-//#include <glog/logging.h>
-//#include <boost/algorithm/string.hpp>
-
namespace uscxml {
using namespace XERCESC_NS;
@@ -42,12 +37,16 @@ std::ostream& operator<< (std::ostream& os, const DOMNode& node) {
DOMImplementation *implementation = DOMImplementationRegistry::getDOMImplementation(X("LS"));
DOMLSSerializer *serializer = ((DOMImplementationLS*)implementation)->createLSSerializer();
+
if (serializer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true))
serializer->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true);
- serializer->setNewLine(XMLString::transcode("\r\n"));
- X output = serializer->writeToString(&node);
- os << output;
+ serializer->setNewLine(X("\r\n"));
+ XMLCh* outString = serializer->writeToString(&node);
+ os << X(outString);
+ XMLString::release(&outString);
+
+ delete (serializer);
return os;
}
@@ -220,108 +219,142 @@ bool DOMUtils::isDescendant(const DOMNode* s1,
return false;
}
-std::list<DOMElement*> DOMUtils::inPostFixOrder(const std::set<std::string>& elements,
- const DOMElement* root,
- const bool includeEmbeddedDoc) {
- std::list<DOMElement*> nodes;
- inPostFixOrder(elements, root, includeEmbeddedDoc, nodes);
- return nodes;
-}
+void DOMUtils::filterElementGeneric(const std::set<std::string>& elements,
+ std::list<DOMElement*>& result,
+ const DOMElement* root,
+ const Order order,
+ const bool includeEmbeddedDoc,
+ const bool includeRoot) {
-void DOMUtils::inPostFixOrder(const std::set<std::string>& elements,
- const DOMElement* root,
- const bool includeEmbeddedDoc,
- std::list<DOMElement*>& nodes) {
-
- if (root == NULL)
+ if (!root)
return;
- for (auto childElem = root->getFirstElementChild(); childElem; childElem = childElem->getNextElementSibling()) {
- if (!includeEmbeddedDoc && LOCALNAME(childElem) == "scxml")
- continue;
- inPostFixOrder(elements, childElem, includeEmbeddedDoc, nodes);
+ if ((order == NO_RECURSE || order == DOCUMENT) &&
+ includeRoot &&
+ elements.find(TAGNAME(root)) != elements.end()) {
+ result.push_back((DOMElement*)root);
}
- for (auto childElem = root->getFirstElementChild(); childElem; childElem = childElem->getNextElementSibling()) {
- if (!includeEmbeddedDoc && TAGNAME(childElem) == XML_PREFIX(root).str() + "scxml")
- continue;
- if (elements.find(TAGNAME(childElem)) != elements.end()) {
- nodes.push_back((DOMElement*)childElem);
+ if (root->getNodeType() == DOMNode::ELEMENT_NODE && root->hasChildNodes()) {
+ DOMElement* currElement = root->getFirstElementChild();
+ while (currElement) {
+ if (order == NO_RECURSE) {
+ if (elements.find(TAGNAME(currElement)) != elements.end()) {
+ result.push_back(currElement);
+ }
+ } else {
+ if (includeEmbeddedDoc || TAGNAME(currElement) != XML_PREFIX(root).str() + "scxml") {
+ filterElementGeneric(elements, result, currElement, order, includeEmbeddedDoc, true);
+ }
+ }
+ currElement = currElement->getNextElementSibling();
}
}
-}
-//TODO: Unify recursive search in DOM
+ if (order == POSTFIX &&
+ includeRoot &&
+ elements.find(TAGNAME(root)) != elements.end()) {
+ result.push_back((DOMElement*)root);
+ }
-std::list<DOMElement*> DOMUtils::inDocumentOrder(const std::set<std::string>& elements,
- const DOMElement* root,
- const bool includeEmbeddedDoc) {
- std::list<DOMElement*> nodes;
- inDocumentOrder(elements, root, includeEmbeddedDoc, nodes);
- return nodes;
}
-void DOMUtils::inDocumentOrder(const std::set<std::string>& elements,
- const DOMElement* root,
- const bool includeEmbeddedDoc,
- std::list<DOMElement*>& nodes) {
- if (root == NULL)
+
+void DOMUtils::filterTypeGeneric(const std::set<DOMNode::NodeType>& types,
+ std::list<DOMNode*>& result,
+ const DOMElement* root,
+ const Order order,
+ const bool includeEmbeddedDoc,
+ const bool includeRoot) {
+
+ if (!root)
return;
- if (elements.find(TAGNAME(root)) != elements.end()) {
- nodes.push_back((DOMElement*)root);
+ if ((order == NO_RECURSE || order == DOCUMENT) &&
+ includeRoot &&
+ types.find(root->getNodeType()) != types.end()) {
+ result.push_back((DOMNode*)root);
}
- /// @todo: item from getChildNodes is O(N)!
- DOMElement* child = root->getFirstElementChild();
- while(child) {
- if (includeEmbeddedDoc || TAGNAME(child) != XML_PREFIX(root).str() + "scxml") {
- inDocumentOrder(elements, child, includeEmbeddedDoc, nodes);
+ if (root->getNodeType() == DOMNode::ELEMENT_NODE && root->hasChildNodes()) {
+ DOMNode* currNode = root->getFirstChild();
+ while (currNode) {
+ if (currNode->getNodeType() != DOMNode::ELEMENT_NODE) {
+ if (types.find(currNode->getNodeType()) != types.end()) {
+ result.push_back(currNode);
+ }
+ } else {
+ if (currNode->getNodeType() == DOMNode::ELEMENT_NODE) {
+ DOMElement* currElement = (DOMElement*)currNode;
+ if (includeEmbeddedDoc || TAGNAME(currElement) != XML_PREFIX(root).str() + "scxml") {
+ filterTypeGeneric(types, result, currElement, order, includeEmbeddedDoc, true);
+ }
+ }
+ }
+ currNode = currNode->getNextSibling();
}
+ }
- child = child->getNextElementSibling();
+ if (order == POSTFIX &&
+ includeRoot &&
+ types.find(root->getNodeType()) != types.end()) {
+ result.push_back((DOMNode*)root);
}
-}
-std::list<DOMNode*> DOMUtils::getElementsByType(const DOMNode* root,
- DOMNode::NodeType type) {
- std::list<DOMNode*> result;
- std::list<DOMNode*> stack;
- std::list<DOMNode*>::iterator stackIter;
+}
- if (!root)
- return result;
-
- stack.push_back((DOMNode*)root);
- while(stack.size() > 0) {
-// for(stackIter = stack.begin(); stackIter != stack.end(); stackIter++) {
-// std::cout << stackIter->getNodeType() << " " << stackIter->getLocalName() << " " << stackIter->getNodeValue() << std::endl;
-// }
-// std::cout << std::endl;
-
- DOMNode* currNode = stack.back();
- if (currNode->hasChildNodes()) {
- stack.push_back(currNode->getFirstChild());
- continue;
- }
+#if 1
+std::list<DOMElement*> DOMUtils::inPostFixOrder(const std::set<std::string>& elements,
+ const DOMElement* root,
+ const bool includeEmbeddedDoc) {
+ std::list<DOMElement*> result;
+ filterElementGeneric(elements, result, root, POSTFIX, includeEmbeddedDoc, true);
+ return result;
+}
+#else
+std::list<DOMElement*> DOMUtils::inPostFixOrder(const std::set<std::string>& elements,
+ const DOMElement* root,
+ const bool includeEmbeddedDoc) {
+ std::list<DOMElement*> nodes;
+ inPostFixOrder(elements, root, includeEmbeddedDoc, nodes);
+ return nodes;
+}
+#endif
- // roll back stack and pop everyone without next sibling
- do {
- currNode = stack.back();
- if (currNode->getNodeType() == type)
- result.push_back(currNode);
- stack.pop_back();
- if (currNode->getNextSibling()) {
- stack.push_back(currNode->getNextSibling());
- break;
- }
- } while(stack.size() > 0);
- }
+#if 1
+std::list<DOMElement*> DOMUtils::inDocumentOrder(const std::set<std::string>& elements,
+ const DOMElement* root,
+ const bool includeEmbeddedDoc) {
+ std::list<DOMElement*> result;
+ filterElementGeneric(elements, result, root, DOCUMENT, includeEmbeddedDoc, true);
return result;
}
+#else
+std::list<DOMElement*> DOMUtils::inDocumentOrder(const std::set<std::string>& elements,
+ const DOMElement* root,
+ const bool includeEmbeddedDoc) {
+ std::list<DOMElement*> nodes;
+ inDocumentOrder(elements, root, includeEmbeddedDoc, nodes);
+ return nodes;
+}
+#endif
+#if 1
+std::list<DOMElement*> DOMUtils::filterChildElements(const std::string& tagName,
+ const std::list<DOMElement*>& nodeSet,
+ bool recurse) {
+ std::list<DOMElement*> filteredChildElems;
+ std::list<DOMElement*>::const_iterator nodeIter = nodeSet.begin();
+ while(nodeIter != nodeSet.end()) {
+ if ((*nodeIter)->getNodeType() == DOMNode::ELEMENT_NODE)
+ filterElementGeneric({ tagName }, filteredChildElems, (DOMElement*)(*nodeIter), (recurse ? DOCUMENT : NO_RECURSE), true, false);
+ nodeIter++;
+ }
+ return filteredChildElems;
+}
+#else
std::list<DOMElement*> DOMUtils::filterChildElements(const std::string& tagName,
const std::list<DOMElement*>& nodeSet,
bool recurse) {
@@ -335,7 +368,18 @@ std::list<DOMElement*> DOMUtils::filterChildElements(const std::string& tagName,
}
return filteredChildElems;
}
+#endif
+#if 1
+std::list<DOMElement*> DOMUtils::filterChildElements(const std::string& tagName,
+ const DOMElement* node,
+ bool recurse) {
+
+ std::list<DOMElement*> result;
+ filterElementGeneric({ tagName }, result, node, (recurse ? DOCUMENT : NO_RECURSE), true, false);
+ return result;
+}
+#else
std::list<DOMElement*> DOMUtils::filterChildElements(const std::string& tagName,
const DOMElement* node,
bool recurse) {
@@ -358,7 +402,22 @@ std::list<DOMElement*> DOMUtils::filterChildElements(const std::string& tagName,
return filteredChildElems;
}
+#endif
+#if 1
+std::list<DOMNode*> DOMUtils::filterChildType(const DOMNode::NodeType type,
+ const std::list<DOMNode*>& nodeSet,
+ bool recurse) {
+ std::list<DOMNode*> filteredChildType;
+ std::list<DOMNode*>::const_iterator nodeIter = nodeSet.begin();
+ while(nodeIter != nodeSet.end()) {
+ if ((*nodeIter)->getNodeType() == DOMNode::ELEMENT_NODE)
+ filterTypeGeneric({ type }, filteredChildType, (DOMElement*)(*nodeIter), (recurse ? DOCUMENT : NO_RECURSE), true, false);
+ nodeIter++;
+ }
+ return filteredChildType;
+}
+#else
std::list<DOMNode*> DOMUtils::filterChildType(const DOMNode::NodeType type,
const std::list<DOMNode*>& nodeSet,
bool recurse) {
@@ -371,7 +430,21 @@ std::list<DOMNode*> DOMUtils::filterChildType(const DOMNode::NodeType type,
}
return filteredChildType;
}
+#endif
+#if 1
+std::list<DOMNode*> DOMUtils::filterChildType(const DOMNode::NodeType type,
+ const DOMNode* node,
+ bool recurse) {
+
+ std::list<DOMNode*> result;
+ if (node) {
+ assert(node->getNodeType() == DOMNode::ELEMENT_NODE);
+ }
+ filterTypeGeneric({ type }, result, (DOMElement*)node, (recurse ? DOCUMENT : NO_RECURSE), true, false);
+ return result;
+}
+#else
std::list<DOMNode*> DOMUtils::filterChildType(const DOMNode::NodeType type,
const DOMNode* node,
bool recurse) {
@@ -392,6 +465,53 @@ std::list<DOMNode*> DOMUtils::filterChildType(const DOMNode::NodeType type,
}
return filteredChildTypes;
}
+#endif
+
+#if 0
+void DOMUtils::inPostFixOrder(const std::set<std::string>& elements,
+ const DOMElement* root,
+ const bool includeEmbeddedDoc,
+ std::list<DOMElement*>& nodes) {
+
+ if (root == NULL)
+ return;
+
+ for (auto childElem = root->getFirstElementChild(); childElem; childElem = childElem->getNextElementSibling()) {
+ if (!includeEmbeddedDoc && LOCALNAME(childElem) == "scxml")
+ continue;
+ inPostFixOrder(elements, childElem, includeEmbeddedDoc, nodes);
+
+ }
+ for (auto childElem = root->getFirstElementChild(); childElem; childElem = childElem->getNextElementSibling()) {
+ if (!includeEmbeddedDoc && TAGNAME(childElem) == XML_PREFIX(root).str() + "scxml")
+ continue;
+
+ if (elements.find(TAGNAME(childElem)) != elements.end()) {
+ nodes.push_back((DOMElement*)childElem);
+ }
+ }
+}
+void DOMUtils::inDocumentOrder(const std::set<std::string>& elements,
+ const DOMElement* root,
+ const bool includeEmbeddedDoc,
+ std::list<DOMElement*>& nodes) {
+ if (root == NULL)
+ return;
+
+ if (elements.find(TAGNAME(root)) != elements.end()) {
+ nodes.push_back((DOMElement*)root);
+ }
+ /// @todo: item from getChildNodes is O(N)!
+ DOMElement* child = root->getFirstElementChild();
+ while(child) {
+ if (includeEmbeddedDoc || TAGNAME(child) != XML_PREFIX(root).str() + "scxml") {
+ inDocumentOrder(elements, child, includeEmbeddedDoc, nodes);
+ }
+
+ child = child->getNextElementSibling();
+ }
+}
+#endif
}
diff --git a/src/uscxml/util/DOM.h b/src/uscxml/util/DOM.h
index 2b133d8..48ad321 100644
--- a/src/uscxml/util/DOM.h
+++ b/src/uscxml/util/DOM.h
@@ -57,9 +57,6 @@ public:
const std::string& ns = "");
static std::string idForNode(const XERCESC_NS::DOMNode* node);
- static std::list<XERCESC_NS::DOMNode*> getElementsByType(const XERCESC_NS::DOMNode* root,
- XERCESC_NS::DOMNode::NodeType type);
-
static std::list<XERCESC_NS::DOMElement*> inPostFixOrder(const std::set<std::string>& elements,
const XERCESC_NS::DOMElement* root,
const bool includeEmbeddedDoc = false);
@@ -83,8 +80,28 @@ public:
static std::list<XERCESC_NS::DOMNode*> filterChildType(const XERCESC_NS::DOMNode::NodeType type,
const std::list<XERCESC_NS::DOMNode*>& nodeSet,
bool recurse = false);
-
protected:
+ enum Order {
+ POSTFIX,
+ DOCUMENT,
+ NO_RECURSE
+ };
+
+ static void filterElementGeneric(const std::set<std::string>& elements,
+ std::list<XERCESC_NS::DOMElement*>& result,
+ const XERCESC_NS::DOMElement* root,
+ const Order order,
+ const bool includeEmbeddedDoc,
+ const bool includeRoot);
+
+ static void filterTypeGeneric(const std::set<XERCESC_NS::DOMNode::NodeType>& types,
+ std::list<XERCESC_NS::DOMNode*>& result,
+ const XERCESC_NS::DOMElement* root,
+ const Order order,
+ const bool includeEmbeddedDoc,
+ const bool includeRoot);
+
+#if 0
static void inPostFixOrder(const std::set<std::string>& elements,
const XERCESC_NS::DOMElement* root,
const bool includeEmbeddedDoc,
@@ -94,7 +111,7 @@ protected:
const XERCESC_NS::DOMElement* root,
const bool includeEmbeddedDoc,
std::list<XERCESC_NS::DOMElement*>& nodes);
-
+#endif
};
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index bc1c85a..2b90b97 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -39,25 +39,32 @@ function(USCXML_TEST_COMPILE)
add_test(${USCXML_TEST_NAME} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${USCXML_TEST_NAME} ${USCXML_TEST_ARGS})
set_property(TEST ${USCXML_TEST_NAME} PROPERTY LABELS ${USCXML_TEST_LABEL})
set_property(TEST ${USCXML_TEST_NAME} PROPERTY TIMEOUT ${TEST_TIMEOUT})
+ set_property(TEST ${USCXML_TEST_NAME} PROPERTY ENVIRONMENT "USCXML_PLUGIN_PATH=${CMAKE_BINARY_DIR}/lib/plugins")
endif ()
set_target_properties(${USCXML_TEST_NAME} PROPERTIES FOLDER "Tests")
endfunction()
# simple one file tests
+USCXML_TEST_COMPILE(NAME test-utils LABEL general/test-utils FILES src/test-utils.cpp)
USCXML_TEST_COMPILE(NAME test-extensions LABEL general/test-extensions FILES src/test-extensions.cpp ../contrib/src/uscxml/PausableDelayedEventQueue.cpp)
USCXML_TEST_COMPILE(NAME test-url LABEL general/test-url FILES src/test-url.cpp)
USCXML_TEST_COMPILE(NAME test-lifecycle LABEL general/test-lifecycle FILES src/test-lifecycle.cpp)
USCXML_TEST_COMPILE(NAME test-validating LABEL general/test-validating FILES src/test-validating.cpp)
USCXML_TEST_COMPILE(NAME test-snippets LABEL general/test-snippets FILES src/test-snippets.cpp)
-USCXML_TEST_COMPILE(
- NAME test-serialization
- LABEL general/test-serialization
- FILES src/test-serialization.cpp ../contrib/src/uscxml/PausableDelayedEventQueue.cpp
- ARGS ${CMAKE_CURRENT_SOURCE_DIR}/w3c/ecma)
+
+if (NOT BUILD_AS_PLUGINS)
+ USCXML_TEST_COMPILE(
+ NAME test-serialization
+ LABEL general/test-serialization
+ FILES src/test-serialization.cpp ../contrib/src/uscxml/PausableDelayedEventQueue.cpp
+ ARGS ${CMAKE_CURRENT_SOURCE_DIR}/w3c/ecma)
+endif()
# USCXML_TEST_COMPILE(NAME test-c89-parser LABEL general/test-c89-parser FILES src/test-c89-parser.cpp)
# test-stress is not an automated test
-USCXML_TEST_COMPILE(BUILD_ONLY NAME test-stress LABEL general/test-stress FILES src/test-stress.cpp)
+if (NOT BUILD_AS_PLUGINS)
+ USCXML_TEST_COMPILE(BUILD_ONLY NAME test-stress LABEL general/test-stress FILES src/test-stress.cpp)
+endif()
file(GLOB_RECURSE USCXML_WRAPPERS
${PROJECT_SOURCE_DIR}/src/bindings/swig/wrapped/*.cpp
@@ -91,6 +98,7 @@ foreach (USCXML_ISSUE ${USCXML_ISSUES})
if (ISSUE_TYPE STREQUAL ".scxml")
add_test(issue/${ISSUE_NAME} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-state-pass ${USCXML_ISSUE})
set_property(TEST issue/${ISSUE_NAME} PROPERTY LABELS issue/${ISSUE_NAME})
+ set_property(TEST issue/${ISSUE_NAME} PROPERTY ENVIRONMENT "USCXML_PLUGIN_PATH=${CMAKE_BINARY_DIR}/lib/plugins")
else ()
USCXML_TEST_COMPILE(NAME ${ISSUE_NAME} LABEL issues/${ISSUE_NAME} FILES ${USCXML_ISSUE})
endif ()
@@ -130,6 +138,7 @@ foreach (USCXML_HEADER ${USCXML_PUBLIC_HEADERS})
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
-P ${CMAKE_CURRENT_SOURCE_DIR}/ctest/scripts/run_header_compiles.cmake)
set_property(TEST "header/${USCXML_REL_HEADER}" PROPERTY LABELS "header/${USCXML_REL_HEADER}")
+ set_property(TEST "header/${USCXML_REL_HEADER}" PROPERTY ENVIRONMENT "USCXML_PLUGIN_PATH=${CMAKE_BINARY_DIR}/lib/plugins")
endforeach ()
@@ -142,7 +151,8 @@ if (PERL_BIN)
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/test/src
)
set_property(TEST "general/test-debug-api" PROPERTY LABELS "general/test-debug-api")
- set_tests_properties("general/test-debug-api" PROPERTIES DEPENDS uscxml-browser)
+ set_property(TEST "general/test-debug-api" PROPERTY DEPENDS uscxml-browser)
+ set_property(TEST "general/test-debug-api" PROPERTY ENVIRONMENT "USCXML_PLUGIN_PATH=${CMAKE_BINARY_DIR}/lib/plugins")
endif ()
@@ -299,7 +309,7 @@ if (NOT BUILD_MINIMAL)
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
-DSCAFFOLDING_FOR_GENERATED_C:FILEPATH=${CMAKE_CURRENT_SOURCE_DIR}/src/test-gen-c.cpp
-P ${CMAKE_CURRENT_SOURCE_DIR}/ctest/scripts/test_generated_${TEST_TARGET}.cmake)
- set_tests_properties("${TEST_NAME}" PROPERTIES DEPENDS uscxml-transform)
+ set_property(TEST ${TEST_NAME} PROPERTY DEPENDS uscxml-transform)
set(TEST_ADDED ON)
endif()
@@ -313,7 +323,7 @@ if (NOT BUILD_MINIMAL)
-Dtest.file=${W3C_TEST}
-Duscxml.jar=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/uscxml.jar
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/contrib/java/bindings)
- set_tests_properties("${TEST_NAME}" PROPERTIES DEPENDS jar)
+ set_property(TEST ${TEST_NAME} PROPERTY DEPENDS jar)
set(TEST_ADDED ON)
endif ()
@@ -325,7 +335,8 @@ if (NOT BUILD_MINIMAL)
${W3C_TEST}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/contrib/python/bindings)
- set_tests_properties("${TEST_NAME}" PROPERTIES ENVIRONMENT "USCXML_PYTHON_PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
+ set_property(TEST ${TEST_NAME} PROPERTY ENVIRONMENT "USCXML_PYTHON_PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
+ set_property(TEST ${TEST_NAME} APPEND PROPERTY ENVIRONMENT "USCXML_PLUGIN_PATH=${CMAKE_BINARY_DIR}/lib/plugins")
set(TEST_ADDED ON)
endif ()
@@ -343,8 +354,8 @@ if (NOT BUILD_MINIMAL)
-DSPIN_BIN:FILEPATH=${SPIN_BIN}
-DCC_BIN:FILEPATH=${CC_BIN}
-P ${CMAKE_CURRENT_SOURCE_DIR}/ctest/scripts/run_promela_test.cmake)
- set_tests_properties("${TEST_NAME}" PROPERTIES PASS_REGULAR_EXPRESSION "depth reached [0-9]+, errors: 0")
- set_tests_properties("${TEST_NAME}" PROPERTIES FAIL_REGULAR_EXPRESSION "depth reached [0-9]+, errors: [1-9]+")
+ set_property(TEST ${TEST_NAME} PROPERTY PASS_REGULAR_EXPRESSION "depth reached [0-9]+, errors: 0")
+ set_property(TEST ${TEST_NAME} PROPERTY FAIL_REGULAR_EXPRESSION "depth reached [0-9]+, errors: [1-9]+")
set(TEST_ADDED ON)
elseif (TEST_TYPE MATCHES "^fsm.*")
@@ -356,9 +367,10 @@ if (NOT BUILD_MINIMAL)
if (TEST_ADDED)
set_property(TEST ${TEST_NAME} PROPERTY LABELS ${TEST_NAME})
- set_tests_properties(${TEST_NAME} PROPERTIES TIMEOUT ${TEST_TIMEOUT})
+ set_property(TEST ${TEST_NAME} PROPERTY TIMEOUT ${TEST_TIMEOUT})
+ set_property(TEST ${TEST_NAME} APPEND PROPERTY ENVIRONMENT "USCXML_PLUGIN_PATH=${CMAKE_BINARY_DIR}/lib/plugins")
if (IS_PERFORMANCE_TEST)
- set_tests_properties("${TEST_NAME}" PROPERTIES ENVIRONMENT USCXML_BENCHMARK_ITERATIONS=${TEST_BENCHMARK_ITERATIONS})
+ set_property(TEST ${TEST_NAME} APPEND PROPERTY ENVIRONMENT USCXML_BENCHMARK_ITERATIONS=${TEST_BENCHMARK_ITERATIONS})
endif ()
endif ()
diff --git a/test/ctest/scripts/test_generated_c.cmake b/test/ctest/scripts/test_generated_c.cmake
index c170639..b130d29 100644
--- a/test/ctest/scripts/test_generated_c.cmake
+++ b/test/ctest/scripts/test_generated_c.cmake
@@ -15,36 +15,6 @@ if (CMD_RESULT)
endif ()
message(STATUS "time for transforming to c machine")
-# set(COMPILE_CMD_OBJ
-# "-c" "${OUTDIR}/${TEST_FILE_NAME}.machine.c"
-# "-o" "${OUTDIR}/${TEST_FILE_NAME}.machine.c.o"
-# "-Ofast" "-ansi" "-m16")
-#
-# message(STATUS "${CC_BIN} ${COMPILE_CMD_OBJ}")
-# execute_process(
-# COMMAND time -p ${CC_BIN} ${COMPILE_CMD_OBJ}
-# WORKING_DIRECTORY ${OUTDIR} RESULT_VARIABLE CMD_RESULT)
-# if(CMD_RESULT)
-# message(FATAL_ERROR "Error running gcc ${CC_BIN}: ${CMD_RESULT}")
-# endif()
-# file (SIZE "${OUTDIR}/${TEST_FILE_NAME}.machine.c.o" BINARY_SIZE)
-# message("Size of compiled unit optimized for speed: ${BINARY_SIZE}")
-#
-# set(COMPILE_CMD_OBJ
-# "-c" "${OUTDIR}/${TEST_FILE_NAME}.machine.c"
-# "-o" "${OUTDIR}/${TEST_FILE_NAME}.machine.c.o"
-# "-Os" "-ansi" "-m16")
-#
-# message(STATUS "${CC_BIN} ${COMPILE_CMD_OBJ}")
-# execute_process(
-# COMMAND time -p ${CC_BIN} ${COMPILE_CMD_OBJ}
-# WORKING_DIRECTORY ${OUTDIR} RESULT_VARIABLE CMD_RESULT)
-# if(CMD_RESULT)
-# message(FATAL_ERROR "Error running gcc ${CC_BIN}: ${CMD_RESULT}")
-# endif()
-# file (SIZE "${OUTDIR}/${TEST_FILE_NAME}.machine.c.o" BINARY_SIZE)
-# message("Size of compiled unit optimized for size: ${BINARY_SIZE}")
-
set(COMPILE_CMD_BIN
"-O0"
"-std=c++11"
@@ -53,6 +23,7 @@ set(COMPILE_CMD_BIN
"-o" "${OUTDIR}/${TEST_FILE_NAME}"
"-L${CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
"-L${PROJECT_BINARY_DIR}/deps/xerces-c/lib"
+ "-L/opt/local/lib"
"-luscxml"
"-lxerces-c"
"-include" "${OUTDIR}/${TEST_FILE_NAME}.machine.c"
diff --git a/test/src/test-gen-c.cpp b/test/src/test-gen-c.cpp
index 090b289..7af121c 100644
--- a/test/src/test-gen-c.cpp
+++ b/test/src/test-gen-c.cpp
@@ -18,9 +18,7 @@
#ifndef AUTOINCLUDE_TEST
#include "test-c-machine.scxml.c"
-//#include "/Users/sradomski/Documents/TK/Code/uscxml/build/cli/test/gen/c/ecma/test562.scxml.machine.c"
-//#include "/Users/sradomski/Documents/TK/Code/uscxml/build/cli/test/gen/c/ecma/test558.scxml.machine.c"
-// #include "/Users/sradomski/Documents/TK/Code/uscxml/build/cli/test/gen/c/lua/test530.scxml.machine.c"
+//#include "/Users/sradomski/Documents/TK/Code/uscxml/build/cli/test/gen/c/ecma/test446.scxml.machine.c"
#endif
#include "uscxml/util/URL.h"
diff --git a/test/src/test-utils.cpp b/test/src/test-utils.cpp
new file mode 100644
index 0000000..474cf89
--- /dev/null
+++ b/test/src/test-utils.cpp
@@ -0,0 +1,74 @@
+/**
+ * This file contains all the snippets in the doxygen documentation.
+ *
+ * It is not actually a test as such, but makes sure that the snippets will
+ * actually compile and do what we claim they do.
+ */
+#define protected public
+
+#include "uscxml/config.h"
+#include "uscxml/Common.h"
+#include "uscxml/Interpreter.h"
+#include "uscxml/interpreter/InterpreterImpl.h"
+#include "uscxml/util/DOM.h"
+
+using namespace uscxml;
+using namespace XERCESC_NS;
+
+void testDOMUtils() {
+
+ const char* xml =
+ "<scxml>"
+ " <state doc=\"1\" post=\"1\">"
+ " <transition doc=\"1\" post=\"1\" />"
+ " </state>"
+ " <state doc=\"2\" post=\"3\">"
+ " <transition doc=\"2\" post=\"3\" />"
+ " <state doc=\"3\" post=\"2\">"
+ " <transition doc=\"2\" post=\"2\" />"
+ " </state>"
+ " </state>"
+ " <final id=\"done\" />"
+ "</scxml>";
+
+ size_t index = 1;
+
+ Interpreter interpreter = Interpreter::fromXML(xml, "");
+ interpreter.step();
+ XERCESC_NS::DOMElement* scxml = interpreter.getImpl()->_scxml;
+
+ {
+ // postfix
+ std::list<DOMElement*> result;
+ DOMUtils::filterElementGeneric({ "state" }, result, scxml, DOMUtils::POSTFIX, true, true);
+ index = 1;
+ for (auto trans : result) {
+ assert(HAS_ATTR(trans, "post"));
+ std::cout << "post: " << ATTR(trans, "post") << std::endl;
+ assert(ATTR(trans, "post") == toStr(index));
+ index++;
+ }
+ }
+
+ {
+ // document
+ std::list<DOMElement*> result;
+ DOMUtils::filterElementGeneric({ "state" }, result, scxml, DOMUtils::DOCUMENT, true, true);
+ index = 1;
+ for (auto trans : result) {
+ assert(HAS_ATTR(trans, "doc"));
+ std::cout << "doc: " << ATTR(trans, "doc") << std::endl;
+ assert(ATTR(trans, "doc") == toStr(index));
+ index++;
+ }
+ }
+
+}
+
+int main(int argc, char** argv) {
+ try {
+ testDOMUtils();
+ } catch (ErrorEvent e) {
+ std::cout << e;
+ }
+}
diff --git a/test/src/test-validating.cpp b/test/src/test-validating.cpp
index fa660b9..7e0cc31 100644
--- a/test/src/test-validating.cpp
+++ b/test/src/test-validating.cpp
@@ -5,6 +5,8 @@
#include "uscxml/interpreter/Logging.h"
#include <xercesc/util/PlatformUtils.hpp>
+uscxml::Factory* factory = NULL;
+
using namespace uscxml;
std::set<std::string> issueLocationsForXML(const std::string xml) {
@@ -36,782 +38,865 @@ public:
}
};
-int main(int argc, char** argv) {
-
- using namespace XERCESC_NS;
-
- int iterations = 1;
+bool endlessLoop() {
- while(iterations--) {
-
- if (Factory::getInstance()->hasDataModel("ecmascript")) {
- // Potential endless loop
-
- const char* xml =
- "<scxml datamodel=\"ecmascript\">"
- " <datamodel><data id=\"counter\" expr=\"5\" /></datamodel>"
- " <state id=\"foo\">"
- " <onentry><script>counter--;</script></onentry>"
- " <transition target=\"foo\" cond=\"counter > 0\" />"
- " <transition target=\"bar\" cond=\"counter == 0\" />"
- " </state>"
- " <state id=\"bar\" final=\"true\" />"
- "</scxml>";
+ if (Factory::getInstance()->hasDataModel("ecmascript")) {
+ // Potential endless loop
- IssueMonitor monitor;
- Interpreter interpreter = Interpreter::fromXML(xml, "");
- interpreter.addMonitor(&monitor);
+ const char* xml =
+ "<scxml datamodel=\"ecmascript\">"
+ " <datamodel><data id=\"counter\" expr=\"5\" /></datamodel>"
+ " <state id=\"foo\">"
+ " <onentry><script>counter--;</script></onentry>"
+ " <transition target=\"foo\" cond=\"counter > 0\" />"
+ " <transition target=\"bar\" cond=\"counter == 0\" />"
+ " </state>"
+ " <state id=\"bar\" final=\"true\" />"
+ "</scxml>";
- while(interpreter.step() > 0) {}
+ IssueMonitor monitor;
+ Interpreter interpreter = Interpreter::fromXML(xml, "");
+ interpreter.addMonitor(&monitor);
- // four identical configurations between macrosteps
- assert(runtimeIssues == 4);
- }
+ while(interpreter.step() > 0) {}
- if (1) {
- // Unreachable states 1
+ // four identical configurations between macrosteps
+ assert(runtimeIssues == 4);
+ }
+ return true;
+}
- const char* xml =
- "<scxml>"
- " <state id=\"foo\">"
- " <parallel id=\"foz\">"
- " <state id=\"s0\" />"
- " <state id=\"s1\" />"
- " <state id=\"s2\" />"
- " </parallel>"
- " </state>"
- " <state id=\"bar\" />"
- "</scxml>";
+bool unreachableState() {
+ if (1) {
+ // Unreachable states 1
+
+ const char* xml =
+ "<scxml>"
+ " <state id=\"foo\">"
+ " <parallel id=\"foz\">"
+ " <state id=\"s0\" />"
+ " <state id=\"s1\" />"
+ " <state id=\"s2\" />"
+ " </parallel>"
+ " </state>"
+ " <state id=\"bar\" />"
+ "</scxml>";
+
+ std::set<std::string> issueLocations = issueLocationsForXML(xml);
+ assert(issueLocations.find("//state[@id=\"bar\"]") != issueLocations.end());
+ assert(issueLocations.size() == 1);
+ }
+ return true;
+}
- std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//state[@id=\"bar\"]") != issueLocations.end());
- assert(issueLocations.size() == 1);
- }
+bool invalidParents() {
+ if (1) {
+ // Invalid parents
+ const char* xml =
+ "<scxml>"
+ " <onentry>"
+ " <cancel sendid=\"foo\" />"
+ " </onentry>"
+ "</scxml>";
+
+ std::set<std::string> issueLocations = issueLocationsForXML(xml);
+ assert(issueLocations.find("/scxml[1]/onentry[1]") != issueLocations.end());
+ assert(issueLocations.size() == 1);
+ }
+ return true;
+}
- if (1) {
- // Invalid parents
- const char* xml =
- "<scxml>"
- " <onentry>"
- " <cancel sendid=\"foo\" />"
- " </onentry>"
- "</scxml>";
+bool noIdAttr() {
+ if (1) {
+ // State has no 'id' attribute
+ // *** This is not actually an error! ***
+ const char* xml =
+ "<scxml>"
+ " <state>"
+ " <transition/>"
+ " </state>"
+ "</scxml>";
+
+ std::set<std::string> issueLocations = issueLocationsForXML(xml);
+ assert(issueLocations.find("/scxml[1]/state[1]") != issueLocations.end());
+ assert(issueLocations.size() == 1);
+ }
- std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("/scxml[1]/onentry[1]") != issueLocations.end());
- assert(issueLocations.size() == 1);
- }
+ return true;
+}
- if (1) {
- // State has no 'id' attribute
- // *** This is not actually an error! ***
- const char* xml =
- "<scxml>"
- " <state>"
- " <transition/>"
- " </state>"
- "</scxml>";
+bool duplicateIdAttr() {
+ if (1) {
+ // Duplicate state with id
+ const char* xml =
+ "<scxml>"
+ " <state id=\"start\" />"
+ " <state id=\"start\" />"
+ "</scxml>";
+
+ std::set<std::string> issueLocations = issueLocationsForXML(xml);
+ assert(issueLocations.find("//state[@id=\"start\"]") != issueLocations.end());
+ assert(issueLocations.size() == 1);
+ }
- std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("/scxml[1]/state[1]") != issueLocations.end());
- assert(issueLocations.size() == 1);
- }
+ return true;
+}
- if (1) {
- // Duplicate state with id
- const char* xml =
- "<scxml>"
- " <state id=\"start\" />"
- " <state id=\"start\" />"
- "</scxml>";
+bool invalidTarget() {
+ if (1) {
+ // Transition has non-existant target state
- std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//state[@id=\"start\"]") != issueLocations.end());
- assert(issueLocations.size() == 1);
- }
+ const char* xml =
+ "<scxml>"
+ " <state id=\"start\">"
+ " <transition target=\"done\" />"
+ " </state>"
+ "</scxml>";
- if (1) {
- // Transition has non-existant target state
+ std::set<std::string> issueLocations = issueLocationsForXML(xml);
+ assert(issueLocations.find("//state[@id=\"start\"]/transition[1]") != issueLocations.end());
+ assert(issueLocations.size() == 1);
+ }
- const char* xml =
- "<scxml>"
- " <state id=\"start\">"
- " <transition target=\"done\" />"
- " </state>"
- "</scxml>";
+ return true;
+}
- std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//state[@id=\"start\"]/transition[1]") != issueLocations.end());
- assert(issueLocations.size() == 1);
- }
+bool uselessHistory1() {
+ if (1) {
+ // Useless history 1
+
+ const char* xml =
+ "<scxml>"
+ " <state id=\"start\" initial=\"bar\">"
+ " <history id=\"bar\" />"
+ " <state id=\"baz\" />"
+ " <transition event=\"e.foo\" target=\"done\" />"
+ " <transition event=\"e.bar\" target=\"baz\" />"
+ " </state>"
+ " <final id=\"done\" />"
+ "</scxml>";
+
+ std::set<std::string> issueLocations = issueLocationsForXML(xml);
+ assert(issueLocations.find("//history[@id=\"bar\"]") != issueLocations.end());
+ assert(issueLocations.size() == 1);
+ }
- if (1) {
- // Useless history 1
+ return true;
+}
- const char* xml =
- "<scxml>"
- " <state id=\"start\" initial=\"bar\">"
- " <history id=\"bar\" />"
- " <state id=\"baz\" />"
- " <transition event=\"e.foo\" target=\"done\" />"
- " <transition event=\"e.bar\" target=\"baz\" />"
- " </state>"
- " <final id=\"done\" />"
- "</scxml>";
+bool uselessHistory2() {
+ if (1) {
+ // Useless history 2
+
+ const char* xml =
+ "<scxml>"
+ " <state id=\"start\" initial=\"bar\">"
+ " <history id=\"bar\">"
+ " <transition target=\"foo\" />"
+ " </history>"
+ " <transition target=\"done\" />"
+ " <state id=\"foo\" />"
+ " </state>"
+ " <final id=\"done\" />"
+ "</scxml>";
+
+ std::set<std::string> issueLocations = issueLocationsForXML(xml);
+ assert(issueLocations.find("//history[@id=\"bar\"]") != issueLocations.end());
+ assert(issueLocations.size() == 1);
+ }
+ return true;
+}
- std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//history[@id=\"bar\"]") != issueLocations.end());
- assert(issueLocations.size() == 1);
- }
+bool illegalCompletion() {
+ if (1) {
+ // No legal completion
+
+ const char* xml =
+ "<scxml>"
+ " <state id=\"start\" initial=\"foo bar\">"
+ " <state id=\"foo\" />"
+ " <state id=\"bar\" />"
+ " <transition target=\"foo bar\" />"
+ " </state>"
+ "</scxml>";
+
+ std::set<std::string> issueLocations = issueLocationsForXML(xml);
+ assert(issueLocations.find("//state[@id=\"start\"]") != issueLocations.end());
+ assert(issueLocations.find("//state[@id=\"start\"]/transition[1]") != issueLocations.end());
+ assert(issueLocations.size() == 2);
+ }
+ return true;
+}
- if (1) {
- // Useless history 2
+bool attributeConstraints() {
+ if (1) {
+ // attribute constraints
+ {
+ // initial attribute and <initial> child
const char* xml =
"<scxml>"
- " <state id=\"start\" initial=\"bar\">"
- " <history id=\"bar\">"
+ " <state id=\"start\" initial=\"foo\">"
+ " <initial>"
" <transition target=\"foo\" />"
- " </history>"
- " <transition target=\"done\" />"
- " <state id=\"foo\" />"
- " </state>"
- " <final id=\"done\" />"
- "</scxml>";
-
- std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//history[@id=\"bar\"]") != issueLocations.end());
- assert(issueLocations.size() == 1);
- }
-
- if (1) {
- // No legal completion
-
- const char* xml =
- "<scxml>"
- " <state id=\"start\" initial=\"foo bar\">"
+ " </initial>"
" <state id=\"foo\" />"
- " <state id=\"bar\" />"
- " <transition target=\"foo bar\" />"
" </state>"
"</scxml>";
std::set<std::string> issueLocations = issueLocationsForXML(xml);
assert(issueLocations.find("//state[@id=\"start\"]") != issueLocations.end());
- assert(issueLocations.find("//state[@id=\"start\"]/transition[1]") != issueLocations.end());
- assert(issueLocations.size() == 2);
- }
-
- if (1) {
- // attribute constraints
-
- {
- // initial attribute and <initial> child
- const char* xml =
- "<scxml>"
- " <state id=\"start\" initial=\"foo\">"
- " <initial>"
- " <transition target=\"foo\" />"
- " </initial>"
- " <state id=\"foo\" />"
- " </state>"
- "</scxml>";
-
- std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//state[@id=\"start\"]") != issueLocations.end());
- assert(issueLocations.size() == 1);
- }
-
- {
- // initial attribute with atomic state
- const char* xml =
- "<scxml>"
- " <state id=\"start\" initial=\"\" />"
- "</scxml>";
-
- std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//state[@id=\"start\"]") != issueLocations.end());
- assert(issueLocations.size() == 1);
- }
-
- {
- // initial child with atomic state
- const char* xml =
- "<scxml>"
- " <state id=\"start\">"
- " <initial>"
- " <transition target=\"start\" />"
- " </initial>"
- " </state>"
- "</scxml>";
-
- std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//state[@id=\"start\"]") != issueLocations.end());
- assert(issueLocations.size() == 2); // also invalid non-child target state in initial
- }
-
- // combinations of namelist, content and param
- {
- // send with content and namelist, not allowed
- const char* xml =
- "<scxml>"
- " <state id=\"start\">"
- " <onentry>"
- " <send target=\"#_external\" namelist=\"var1\">"
- " <content>Foo!</content>"
- " </send>"
- " </onentry>"
- " </state>"
- "</scxml>";
-
- std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/send[1]") != issueLocations.end());
- assert(issueLocations.size() == 1);
- }
-
- {
- // send with content and params, not allowed
- const char* xml =
- "<scxml>"
- " <state id=\"start\">"
- " <onentry>"
- " <send target=\"#_external\">"
- " <param name=\"foo\" expr=\"3\" />"
- " <content>Foo!</content>"
- " </send>"
- " </onentry>"
- " </state>"
- "</scxml>";
-
- std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/send[1]") != issueLocations.end());
- assert(issueLocations.size() == 1);
- }
-
- {
- // send with params and namelist, perfectly acceptable
- const char* xml =
- "<scxml>"
- " <state id=\"start\">"
- " <onentry>"
- " <send target=\"#_external\" namelist=\"foo\">"
- " <param name=\"foo\" expr=\"3\" />"
- " </send>"
- " </onentry>"
- " </state>"
- "</scxml>";
-
- std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.size() == 0);
- }
-
- {
- // invoke with content and src, not allowed
- const char* xml =
- "<scxml>"
- " <state id=\"start\">"
- " <invoke type=\"scxml\" src=\"var1\">"
- " <content>Foo!</content>"
- " </invoke>"
- " </state>"
- "</scxml>";
-
- std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//state[@id=\"start\"]/invoke[1]") != issueLocations.end());
- assert(issueLocations.size() == 1);
- }
-
- {
- // invoke with namelist and param, not allowed
- const char* xml =
- "<scxml>"
- " <state id=\"start\">"
- " <invoke type=\"scxml\" namelist=\"var1\">"
- " <param name=\"foo\" expr=\"3\" />"
- " </invoke>"
- " </state>"
- "</scxml>";
-
- std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//state[@id=\"start\"]/invoke[1]") != issueLocations.end());
- assert(issueLocations.size() == 1);
- }
-
- {
- // invoke with param and content, perfectly acceptable
- const char* xml =
- "<scxml>"
- " <state id=\"start\">"
- " <invoke type=\"scxml\">"
- " <param name=\"foo\" expr=\"3\" />"
- " <content>Foo!</content>"
- " </invoke>"
- " </state>"
- "</scxml>";
-
- std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.size() == 0);
- }
-
- {
- // invoke with namelist and content, perfectly acceptable
- const char* xml =
- "<scxml>"
- " <state id=\"start\">"
- " <invoke type=\"scxml\" namelist=\"var1\">"
- " <content>Foo!</content>"
- " </invoke>"
- " </state>"
- "</scxml>";
-
- std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.size() == 0);
- }
-
- {
- // donedata with content and param, not allowed
- const char* xml =
- "<scxml>"
- " <state id=\"start\">"
- " <donedata>"
- " <param name=\"foo\" expr=\"3\" />"
- " <content>Foo!</content>"
- " </donedata>"
- " </state>"
- "</scxml>";
-
- std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//state[@id=\"start\"]/donedata[1]") != issueLocations.end());
- assert(issueLocations.size() == 1);
- }
-
-
- }
-
- if (1) {
- // Transition can never be optimally enabled (conditionless, eventless)
-
- const char* xml =
- "<scxml>"
- " <state id=\"start\">"
- " <transition target=\"done\" />"
- " <transition target=\"done\" />"
- " </state>"
- " <final id=\"done\" />"
- "</scxml>";
-
- std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//state[@id=\"start\"]/transition[2]") != issueLocations.end());
- assert(issueLocations.size() == 1);
- }
- if (1) {
- // Transition can never be optimally enabled (conditionless, more events)
-
- const char* xml =
- "<scxml>"
- " <state id=\"start\">"
- " <transition event=\"error\" target=\"done\" />"
- " <transition event=\"error.bar error.foo\" />"
- " </state>"
- " <final id=\"done\" />"
- "</scxml>";
-
- std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//state[@id=\"start\"]/transition[2]") != issueLocations.end());
- assert(issueLocations.size() == 1);
- }
-
-
- if (1) {
- // Initial attribute has invalid target state
-
- const char* xml =
- "<scxml initial=\"foo\">"
- "</scxml>";
-
- std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("/scxml[1]") != issueLocations.end());
assert(issueLocations.size() == 1);
}
- if (1) {
- // Initial attribute with target outside of children
-
+ {
+ // initial attribute with atomic state
const char* xml =
"<scxml>"
- " <state id=\"start\" initial=\"foo done\">"
- " <state id=\"foo\" />"
- " </state>"
- " <final id=\"done\" />"
+ " <state id=\"start\" initial=\"\" />"
"</scxml>";
std::set<std::string> issueLocations = issueLocationsForXML(xml);
assert(issueLocations.find("//state[@id=\"start\"]") != issueLocations.end());
assert(issueLocations.size() == 1);
}
- if (1) {
- // Initial transition with target outside of children
+ {
+ // initial child with atomic state
const char* xml =
"<scxml>"
" <state id=\"start\">"
" <initial>"
- " <transition target=\"foo done\" />"
+ " <transition target=\"start\" />"
" </initial>"
- " <state id=\"foo\" />"
" </state>"
- " <final id=\"done\" />"
"</scxml>";
std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//state[@id=\"start\"]/initial[1]/transition[1]") != issueLocations.end());
- assert(issueLocations.size() == 1); // there are actually two issues with the transition
+ assert(issueLocations.find("//state[@id=\"start\"]") != issueLocations.end());
+ assert(issueLocations.size() == 2); // also invalid non-child target state in initial
}
- if (1) {
- // Initial history transition with target outside of children
+ // combinations of namelist, content and param
+ {
+ // send with content and namelist, not allowed
const char* xml =
"<scxml>"
- " <state id=\"start\" initial=\"bar\">"
- " <history id=\"bar\">"
- " <transition target=\"foo done\" />"
- " </history>"
- " <state id=\"foo\">"
- " <transition target=\"baz\" />"
- " </state>"
- " <state id=\"baz\" />"
+ " <state id=\"start\">"
+ " <onentry>"
+ " <send target=\"#_external\" namelist=\"var1\">"
+ " <content>Foo!</content>"
+ " </send>"
+ " </onentry>"
" </state>"
- " <final id=\"done\" />"
"</scxml>";
std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//history[@id=\"bar\"]/transition[1]") != issueLocations.end());
+ assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/send[1]") != issueLocations.end());
assert(issueLocations.size() == 1);
}
- if (1) {
- // Initial transition with target outside of children
+ {
+ // send with content and params, not allowed
const char* xml =
"<scxml>"
" <state id=\"start\">"
- " <initial>"
- " <transition target=\"foo done\" />"
- " </initial>"
- " <state id=\"foo\" />"
+ " <onentry>"
+ " <send target=\"#_external\">"
+ " <param name=\"foo\" expr=\"3\" />"
+ " <content>Foo!</content>"
+ " </send>"
+ " </onentry>"
" </state>"
- " <final id=\"done\" />"
"</scxml>";
std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//state[@id=\"start\"]/initial[1]/transition[1]") != issueLocations.end());
+ assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/send[1]") != issueLocations.end());
assert(issueLocations.size() == 1);
}
- if (1) {
- // Initial transition with event
+ {
+ // send with params and namelist, perfectly acceptable
const char* xml =
"<scxml>"
" <state id=\"start\">"
- " <initial>"
- " <transition event=\"e.foo\" target=\"foo\" />"
- " </initial>"
- " <state id=\"foo\" />"
- " <transition event=\"e.bar\" target=\"done\" />"
+ " <onentry>"
+ " <send target=\"#_external\" namelist=\"foo\">"
+ " <param name=\"foo\" expr=\"3\" />"
+ " </send>"
+ " </onentry>"
" </state>"
- " <final id=\"done\" />"
"</scxml>";
std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//state[@id=\"start\"]/initial[1]/transition[1]") != issueLocations.end());
- assert(issueLocations.size() == 1);
+ assert(issueLocations.size() == 0);
}
- if (1) {
- // Initial transition with condition
+ {
+ // invoke with content and src, not allowed
const char* xml =
"<scxml>"
" <state id=\"start\">"
- " <initial>"
- " <transition cond=\"true\" target=\"foo\" />"
- " </initial>"
- " <state id=\"foo\" />"
- " <transition event=\"e.bar\" target=\"done\" />"
+ " <invoke type=\"scxml\" src=\"var1\">"
+ " <content>Foo!</content>"
+ " </invoke>"
" </state>"
- " <final id=\"done\" />"
"</scxml>";
std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//state[@id=\"start\"]/initial[1]/transition[1]") != issueLocations.end());
+ assert(issueLocations.find("//state[@id=\"start\"]/invoke[1]") != issueLocations.end());
assert(issueLocations.size() == 1);
}
- if (1) {
- // Initial with multiple transitions
+ {
+ // invoke with namelist and param, not allowed
const char* xml =
"<scxml>"
" <state id=\"start\">"
- " <initial>"
- " <transition target=\"foo\" />"
- " <transition target=\"foo\" />"
- " </initial>"
- " <state id=\"foo\" />"
- " <transition event=\"e.bar\" target=\"done\" />"
+ " <invoke type=\"scxml\" namelist=\"var1\">"
+ " <param name=\"foo\" expr=\"3\" />"
+ " </invoke>"
" </state>"
- " <final id=\"done\" />"
"</scxml>";
std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//state[@id=\"start\"]/initial[1]") != issueLocations.end());
+ assert(issueLocations.find("//state[@id=\"start\"]/invoke[1]") != issueLocations.end());
assert(issueLocations.size() == 1);
}
- if (1) {
- // Initial with no transitions
+ {
+ // invoke with param and content, perfectly acceptable
const char* xml =
"<scxml>"
" <state id=\"start\">"
- " <initial />"
- " <state id=\"foo\" />"
- " <transition event=\"e.bar\" target=\"done\" />"
+ " <invoke type=\"scxml\">"
+ " <param name=\"foo\" expr=\"3\" />"
+ " <content>Foo!</content>"
+ " </invoke>"
" </state>"
- " <final id=\"done\" />"
"</scxml>";
std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//state[@id=\"foo\"]") != issueLocations.end()); // unreachable
- assert(issueLocations.find("//state[@id=\"start\"]/initial[1]") != issueLocations.end());
- assert(issueLocations.size() == 2);
+ assert(issueLocations.size() == 0);
}
- if (1) {
- // History transition with event
+ {
+ // invoke with namelist and content, perfectly acceptable
const char* xml =
"<scxml>"
- " <state id=\"start\" initial=\"bar\">"
- " <history id=\"bar\">"
- " <transition event=\"e.foo\" target=\"foo\" />"
- " </history>"
- " <state id=\"foo\">"
- " <state id=\"foo.s1\">"
- " <transition target=\"foo.s2\" />"
- " </state>"
- " <state id=\"foo.s2\" />"
- " </state>"
- " <transition event=\"e.bar\" target=\"done\" />"
+ " <state id=\"start\">"
+ " <invoke type=\"scxml\" namelist=\"var1\">"
+ " <content>Foo!</content>"
+ " </invoke>"
" </state>"
- " <final id=\"done\" />"
"</scxml>";
std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//history[@id=\"bar\"]/transition[1]") != issueLocations.end());
- assert(issueLocations.size() == 1);
+ assert(issueLocations.size() == 0);
}
- if (1) {
- // History transition with condition
+ {
+ // donedata with content and param, not allowed
const char* xml =
"<scxml>"
- " <state id=\"start\" initial=\"bar\">"
- " <history id=\"bar\">"
- " <transition cond=\"false\" target=\"foo\" />"
- " </history>"
- " <state id=\"foo\">"
- " <state id=\"foo.s1\">"
- " <transition target=\"foo.s2\" />"
- " </state>"
- " <state id=\"foo.s2\" />"
- " </state>"
- " <transition event=\"e.bar\" target=\"done\" />"
+ " <state id=\"start\">"
+ " <donedata>"
+ " <param name=\"foo\" expr=\"3\" />"
+ " <content>Foo!</content>"
+ " </donedata>"
" </state>"
- " <final id=\"done\" />"
"</scxml>";
std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//history[@id=\"bar\"]/transition[1]") != issueLocations.end());
+ assert(issueLocations.find("//state[@id=\"start\"]/donedata[1]") != issueLocations.end());
assert(issueLocations.size() == 1);
}
+ }
+ return true;
+}
- if (1) {
- // Send to unknown IO Processor
+bool optimallyEnabled() {
+ if (1) {
+ // Transition can never be optimally enabled (conditionless, eventless)
+
+ const char* xml =
+ "<scxml>"
+ " <state id=\"start\">"
+ " <transition target=\"done\" />"
+ " <transition target=\"done\" />"
+ " </state>"
+ " <final id=\"done\" />"
+ "</scxml>";
+
+ std::set<std::string> issueLocations = issueLocationsForXML(xml);
+ assert(issueLocations.find("//state[@id=\"start\"]/transition[2]") != issueLocations.end());
+ assert(issueLocations.size() == 1);
+ }
+ if (1) {
+ // Transition can never be optimally enabled (conditionless, more events)
+
+ const char* xml =
+ "<scxml>"
+ " <state id=\"start\">"
+ " <transition event=\"error\" target=\"done\" />"
+ " <transition event=\"error.bar error.foo\" />"
+ " </state>"
+ " <final id=\"done\" />"
+ "</scxml>";
+
+ std::set<std::string> issueLocations = issueLocationsForXML(xml);
+ assert(issueLocations.find("//state[@id=\"start\"]/transition[2]") != issueLocations.end());
+ assert(issueLocations.size() == 1);
+ }
+ return true;
+}
- const char* xml =
- "<scxml>"
- " <state id=\"start\">"
- " <onentry>"
- " <send type=\"non-existant\" />"
- " </onentry>"
- " </state>"
- "</scxml>";
+bool invalidInitial() {
+ if (1) {
+ // Initial attribute has invalid target state
- std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/send[1]") != issueLocations.end());
- assert(issueLocations.size() == 1);
- }
+ const char* xml =
+ "<scxml initial=\"foo\">"
+ "</scxml>";
- if (1) {
- // SCXML document requires unknown datamodel
+ std::set<std::string> issueLocations = issueLocationsForXML(xml);
+ assert(issueLocations.find("/scxml[1]") != issueLocations.end());
+ assert(issueLocations.size() == 1);
+ }
- const char* xml =
- "<scxml datamodel=\"non-existant\">"
- "</scxml>";
+ if (1) {
+ // Initial attribute with target outside of children
- std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("/scxml[1]") != issueLocations.end());
- assert(issueLocations.size() == 1);
- }
+ const char* xml =
+ "<scxml>"
+ " <state id=\"start\" initial=\"foo done\">"
+ " <state id=\"foo\" />"
+ " </state>"
+ " <final id=\"done\" />"
+ "</scxml>";
- if (1) {
- // Unknown executable content element
+ std::set<std::string> issueLocations = issueLocationsForXML(xml);
+ assert(issueLocations.find("//state[@id=\"start\"]") != issueLocations.end());
+ assert(issueLocations.size() == 1);
+ }
+ if (1) {
+ // Initial transition with target outside of children
+
+ const char* xml =
+ "<scxml>"
+ " <state id=\"start\">"
+ " <initial>"
+ " <transition target=\"foo done\" />"
+ " </initial>"
+ " <state id=\"foo\" />"
+ " </state>"
+ " <final id=\"done\" />"
+ "</scxml>";
+
+ std::set<std::string> issueLocations = issueLocationsForXML(xml);
+ assert(issueLocations.find("//state[@id=\"start\"]/initial[1]/transition[1]") != issueLocations.end());
+ assert(issueLocations.size() == 1); // there are actually two issues with the transition
+ }
+ if (1) {
+ // Initial history transition with target outside of children
+
+ const char* xml =
+ "<scxml>"
+ " <state id=\"start\" initial=\"bar\">"
+ " <history id=\"bar\">"
+ " <transition target=\"foo done\" />"
+ " </history>"
+ " <state id=\"foo\">"
+ " <transition target=\"baz\" />"
+ " </state>"
+ " <state id=\"baz\" />"
+ " </state>"
+ " <final id=\"done\" />"
+ "</scxml>";
+
+ std::set<std::string> issueLocations = issueLocationsForXML(xml);
+ assert(issueLocations.find("//history[@id=\"bar\"]/transition[1]") != issueLocations.end());
+ assert(issueLocations.size() == 1);
+ }
+ if (1) {
+ // Initial transition with target outside of children
+
+ const char* xml =
+ "<scxml>"
+ " <state id=\"start\">"
+ " <initial>"
+ " <transition target=\"foo done\" />"
+ " </initial>"
+ " <state id=\"foo\" />"
+ " </state>"
+ " <final id=\"done\" />"
+ "</scxml>";
+
+ std::set<std::string> issueLocations = issueLocationsForXML(xml);
+ assert(issueLocations.find("//state[@id=\"start\"]/initial[1]/transition[1]") != issueLocations.end());
+ assert(issueLocations.size() == 1);
+ }
- const char* xml =
- "<scxml>"
- " <state id=\"start\">"
- " <onentry>"
- " <nonexistant />"
- " </onentry>"
- " </state>"
- "</scxml>";
+ if (1) {
+ // Initial transition with event
+ const char* xml =
+ "<scxml>"
+ " <state id=\"start\">"
+ " <initial>"
+ " <transition event=\"e.foo\" target=\"foo\" />"
+ " </initial>"
+ " <state id=\"foo\" />"
+ " <transition event=\"e.bar\" target=\"done\" />"
+ " </state>"
+ " <final id=\"done\" />"
+ "</scxml>";
+
+ std::set<std::string> issueLocations = issueLocationsForXML(xml);
+ assert(issueLocations.find("//state[@id=\"start\"]/initial[1]/transition[1]") != issueLocations.end());
+ assert(issueLocations.size() == 1);
+ }
- std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/nonexistant[1]") != issueLocations.end());
- assert(issueLocations.size() == 1);
- }
+ if (1) {
+ // Initial transition with condition
+ const char* xml =
+ "<scxml>"
+ " <state id=\"start\">"
+ " <initial>"
+ " <transition cond=\"true\" target=\"foo\" />"
+ " </initial>"
+ " <state id=\"foo\" />"
+ " <transition event=\"e.bar\" target=\"done\" />"
+ " </state>"
+ " <final id=\"done\" />"
+ "</scxml>";
+
+ std::set<std::string> issueLocations = issueLocationsForXML(xml);
+ assert(issueLocations.find("//state[@id=\"start\"]/initial[1]/transition[1]") != issueLocations.end());
+ assert(issueLocations.size() == 1);
+ }
- if (Factory::getInstance()->hasDataModel("ecmascript")) {
- // Syntax error in script
+ if (1) {
+ // Initial with multiple transitions
+ const char* xml =
+ "<scxml>"
+ " <state id=\"start\">"
+ " <initial>"
+ " <transition target=\"foo\" />"
+ " <transition target=\"foo\" />"
+ " </initial>"
+ " <state id=\"foo\" />"
+ " <transition event=\"e.bar\" target=\"done\" />"
+ " </state>"
+ " <final id=\"done\" />"
+ "</scxml>";
+
+ std::set<std::string> issueLocations = issueLocationsForXML(xml);
+ assert(issueLocations.find("//state[@id=\"start\"]/initial[1]") != issueLocations.end());
+ assert(issueLocations.size() == 1);
+ }
- const char* xml =
- "<scxml datamodel=\"ecmascript\">"
- " <script>"
- " $wfwegr^ "
- " </script>"
- "</scxml>";
+ if (1) {
+ // Initial with no transitions
+ const char* xml =
+ "<scxml>"
+ " <state id=\"start\">"
+ " <initial />"
+ " <state id=\"foo\" />"
+ " <transition event=\"e.bar\" target=\"done\" />"
+ " </state>"
+ " <final id=\"done\" />"
+ "</scxml>";
+
+ std::set<std::string> issueLocations = issueLocationsForXML(xml);
+ assert(issueLocations.find("//state[@id=\"foo\"]") != issueLocations.end()); // unreachable
+ assert(issueLocations.find("//state[@id=\"start\"]/initial[1]") != issueLocations.end());
+ assert(issueLocations.size() == 2);
+ }
+ return true;
+}
- std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("/scxml[1]/script[1]") != issueLocations.end());
- assert(issueLocations.size() == 1);
- }
+bool invalidHistory() {
+ if (1) {
+ // History transition with event
+ const char* xml =
+ "<scxml>"
+ " <state id=\"start\" initial=\"bar\">"
+ " <history id=\"bar\">"
+ " <transition event=\"e.foo\" target=\"foo\" />"
+ " </history>"
+ " <state id=\"foo\">"
+ " <state id=\"foo.s1\">"
+ " <transition target=\"foo.s2\" />"
+ " </state>"
+ " <state id=\"foo.s2\" />"
+ " </state>"
+ " <transition event=\"e.bar\" target=\"done\" />"
+ " </state>"
+ " <final id=\"done\" />"
+ "</scxml>";
+
+ std::set<std::string> issueLocations = issueLocationsForXML(xml);
+ assert(issueLocations.find("//history[@id=\"bar\"]/transition[1]") != issueLocations.end());
+ assert(issueLocations.size() == 1);
+ }
- if (Factory::getInstance()->hasDataModel("ecmascript")) {
- // Syntax error in cond attribute
+ if (1) {
+ // History transition with condition
+ const char* xml =
+ "<scxml>"
+ " <state id=\"start\" initial=\"bar\">"
+ " <history id=\"bar\">"
+ " <transition cond=\"false\" target=\"foo\" />"
+ " </history>"
+ " <state id=\"foo\">"
+ " <state id=\"foo.s1\">"
+ " <transition target=\"foo.s2\" />"
+ " </state>"
+ " <state id=\"foo.s2\" />"
+ " </state>"
+ " <transition event=\"e.bar\" target=\"done\" />"
+ " </state>"
+ " <final id=\"done\" />"
+ "</scxml>";
+
+ std::set<std::string> issueLocations = issueLocationsForXML(xml);
+ assert(issueLocations.find("//history[@id=\"bar\"]/transition[1]") != issueLocations.end());
+ assert(issueLocations.size() == 1);
+ }
+ return true;
+}
- const char* xml =
- "<scxml datamodel=\"ecmascript\">"
- " <state id=\"start\">"
- " <onentry>"
- " <if cond=\"%2345\">"
- " <elseif cond=\"%2345\" />"
- " </if>"
- " </onentry>"
- " <transition cond=\"%2345\" />"
- " </state>"
- "</scxml>";
+bool unknownIOProc() {
+ if (1) {
+ // Send to unknown IO Processor
+
+ const char* xml =
+ "<scxml>"
+ " <state id=\"start\">"
+ " <onentry>"
+ " <send type=\"non-existant\" />"
+ " </onentry>"
+ " </state>"
+ "</scxml>";
+
+ std::set<std::string> issueLocations = issueLocationsForXML(xml);
+ assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/send[1]") != issueLocations.end());
+ assert(issueLocations.size() == 1);
+ }
- std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//state[@id=\"start\"]/transition[1]") != issueLocations.end());
- assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/if[1]") != issueLocations.end());
- assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/if[1]/elseif[1]") != issueLocations.end());
- assert(issueLocations.size() == 3);
- }
+ return true;
+}
- if (Factory::getInstance()->hasDataModel("ecmascript")) {
- // Syntax error in expr attribute
+bool unknownDataModel() {
+ if (1) {
+ // SCXML document requires unknown datamodel
- const char* xml =
- "<scxml datamodel=\"ecmascript\">"
- " <datamodel>"
- " <data id=\"foo\" expr=\"%2345\" />"
- " </datamodel>"
- " <state id=\"start\">"
- " <onentry>"
- " <log expr=\"%2345\" />"
- " <assign location=\"foo\" expr=\"%2345\" />"
- " <send>"
- " <param expr=\"%2345\" />"
- " </send>"
- " <send>"
- " <content expr=\"%2345\" />"
- " </send>"
- " </onentry>"
- " </state>"
- "</scxml>";
+ const char* xml =
+ "<scxml datamodel=\"non-existant\">"
+ "</scxml>";
- std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/log[1]") != issueLocations.end());
- assert(issueLocations.find("//data[@id=\"foo\"]") != issueLocations.end());
- assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/assign[1]") != issueLocations.end());
- assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/send[1]/param[1]") != issueLocations.end());
- assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/send[2]/content[1]") != issueLocations.end());
- assert(issueLocations.size() == 5);
- }
+ std::set<std::string> issueLocations = issueLocationsForXML(xml);
+ assert(issueLocations.find("/scxml[1]") != issueLocations.end());
+ assert(issueLocations.size() == 1);
+ }
- if (Factory::getInstance()->hasDataModel("ecmascript")) {
- // Syntax error with foreach
+ return true;
+}
- const char* xml =
- "<scxml datamodel=\"ecmascript\">"
- " <state id=\"start\">"
- " <onentry>"
- " <foreach item=\"%2345\" index=\"%2345\" array=\"%2345\">"
- " </foreach>"
- " </onentry>"
- " </state>"
- "</scxml>";
+bool unknownExecContent() {
+ if (1) {
+ // Unknown executable content element
+
+ const char* xml =
+ "<scxml>"
+ " <state id=\"start\">"
+ " <onentry>"
+ " <nonexistant />"
+ " </onentry>"
+ " </state>"
+ "</scxml>";
+
+ std::set<std::string> issueLocations = issueLocationsForXML(xml);
+ assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/nonexistant[1]") != issueLocations.end());
+ assert(issueLocations.size() == 1);
+ }
- std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/foreach[1]") != issueLocations.end());
- assert(issueLocations.size() == 1);
- }
+ return true;
+}
- if (Factory::getInstance()->hasDataModel("ecmascript")) {
- // Syntax error with send
+bool syntaxErrors() {
+ if (Factory::getInstance()->hasDataModel("ecmascript")) {
+ // Syntax error in script
- const char* xml =
- "<scxml datamodel=\"ecmascript\">"
- " <state id=\"start\">"
- " <onentry>"
- " <send eventexpr=\"%2345\" targetexpr=\"%2345\" typeexpr=\"%2345\" idlocation=\"%2345\" delayexpr=\"%2345\" />"
- " </onentry>"
- " </state>"
- "</scxml>";
+ const char* xml =
+ "<scxml datamodel=\"ecmascript\">"
+ " <script>"
+ " $wfwegr^ "
+ " </script>"
+ "</scxml>";
- std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/send[1]") != issueLocations.end());
- assert(issueLocations.size() == 1);
- }
+ std::set<std::string> issueLocations = issueLocationsForXML(xml);
+ assert(issueLocations.find("/scxml[1]/script[1]") != issueLocations.end());
+ assert(issueLocations.size() == 1);
+ }
- if (Factory::getInstance()->hasDataModel("ecmascript")) {
- // Syntax error with invoke
+ if (Factory::getInstance()->hasDataModel("ecmascript")) {
+ // Syntax error in cond attribute
+
+ const char* xml =
+ "<scxml datamodel=\"ecmascript\">"
+ " <state id=\"start\">"
+ " <onentry>"
+ " <if cond=\"%2345\">"
+ " <elseif cond=\"%2345\" />"
+ " </if>"
+ " </onentry>"
+ " <transition cond=\"%2345\" />"
+ " </state>"
+ "</scxml>";
+
+ std::set<std::string> issueLocations = issueLocationsForXML(xml);
+ assert(issueLocations.find("//state[@id=\"start\"]/transition[1]") != issueLocations.end());
+ assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/if[1]") != issueLocations.end());
+ assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/if[1]/elseif[1]") != issueLocations.end());
+ assert(issueLocations.size() == 3);
+ }
- const char* xml =
- "<scxml datamodel=\"ecmascript\">"
- " <state id=\"start\">"
- " <invoke typeexpr=\"%2345\" srcexpr=\"%2345\" idlocation=\"%2345\" />"
- " </state>"
- "</scxml>";
+ if (Factory::getInstance()->hasDataModel("ecmascript")) {
+ // Syntax error in expr attribute
+
+ const char* xml =
+ "<scxml datamodel=\"ecmascript\">"
+ " <datamodel>"
+ " <data id=\"foo\" expr=\"%2345\" />"
+ " </datamodel>"
+ " <state id=\"start\">"
+ " <onentry>"
+ " <log expr=\"%2345\" />"
+ " <assign location=\"foo\" expr=\"%2345\" />"
+ " <send>"
+ " <param expr=\"%2345\" />"
+ " </send>"
+ " <send>"
+ " <content expr=\"%2345\" />"
+ " </send>"
+ " </onentry>"
+ " </state>"
+ "</scxml>";
+
+ std::set<std::string> issueLocations = issueLocationsForXML(xml);
+ assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/log[1]") != issueLocations.end());
+ assert(issueLocations.find("//data[@id=\"foo\"]") != issueLocations.end());
+ assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/assign[1]") != issueLocations.end());
+ assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/send[1]/param[1]") != issueLocations.end());
+ assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/send[2]/content[1]") != issueLocations.end());
+ assert(issueLocations.size() == 5);
+ }
- std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//state[@id=\"start\"]/invoke[1]") != issueLocations.end());
- assert(issueLocations.size() == 1);
- }
+ if (Factory::getInstance()->hasDataModel("ecmascript")) {
+ // Syntax error with foreach
+
+ const char* xml =
+ "<scxml datamodel=\"ecmascript\">"
+ " <state id=\"start\">"
+ " <onentry>"
+ " <foreach item=\"%2345\" index=\"%2345\" array=\"%2345\">"
+ " </foreach>"
+ " </onentry>"
+ " </state>"
+ "</scxml>";
+
+ std::set<std::string> issueLocations = issueLocationsForXML(xml);
+ assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/foreach[1]") != issueLocations.end());
+ assert(issueLocations.size() == 1);
+ }
- if (Factory::getInstance()->hasDataModel("ecmascript")) {
- // Syntax error with cancel
+ if (Factory::getInstance()->hasDataModel("ecmascript")) {
+ // Syntax error with send
+
+ const char* xml =
+ "<scxml datamodel=\"ecmascript\">"
+ " <state id=\"start\">"
+ " <onentry>"
+ " <send eventexpr=\"%2345\" targetexpr=\"%2345\" typeexpr=\"%2345\" idlocation=\"%2345\" delayexpr=\"%2345\" />"
+ " </onentry>"
+ " </state>"
+ "</scxml>";
+
+ std::set<std::string> issueLocations = issueLocationsForXML(xml);
+ assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/send[1]") != issueLocations.end());
+ assert(issueLocations.size() == 1);
+ }
- const char* xml =
- "<scxml datamodel=\"ecmascript\">"
- " <state id=\"start\">"
- " <onentry>"
- " <cancel sendidexpr=\"%2345\" />"
- " </onentry>"
- " </state>"
- "</scxml>";
+ if (Factory::getInstance()->hasDataModel("ecmascript")) {
+ // Syntax error with invoke
- std::set<std::string> issueLocations = issueLocationsForXML(xml);
- assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/cancel[1]") != issueLocations.end());
- assert(issueLocations.size() == 1);
- }
+ const char* xml =
+ "<scxml datamodel=\"ecmascript\">"
+ " <state id=\"start\">"
+ " <invoke typeexpr=\"%2345\" srcexpr=\"%2345\" idlocation=\"%2345\" />"
+ " </state>"
+ "</scxml>";
+
+ std::set<std::string> issueLocations = issueLocationsForXML(xml);
+ assert(issueLocations.find("//state[@id=\"start\"]/invoke[1]") != issueLocations.end());
+ assert(issueLocations.size() == 1);
+ }
+
+ if (Factory::getInstance()->hasDataModel("ecmascript")) {
+ // Syntax error with cancel
+
+ const char* xml =
+ "<scxml datamodel=\"ecmascript\">"
+ " <state id=\"start\">"
+ " <onentry>"
+ " <cancel sendidexpr=\"%2345\" />"
+ " </onentry>"
+ " </state>"
+ "</scxml>";
+
+ std::set<std::string> issueLocations = issueLocationsForXML(xml);
+ assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/cancel[1]") != issueLocations.end());
+ assert(issueLocations.size() == 1);
+ }
+
+ return true;
+}
+
+int main(int argc, char** argv) {
+
+ factory = Factory::getInstance();
+ return EXIT_SUCCESS;
+ try {
+ using namespace XERCESC_NS;
+
+ int iterations = 1;
+
+ while(iterations--) {
+
+ endlessLoop();
+ unreachableState();
+ invalidParents();
+ noIdAttr();
+ duplicateIdAttr();
+ invalidTarget();
+ uselessHistory1();
+ uselessHistory2();
+ illegalCompletion();
+ attributeConstraints();
+ optimallyEnabled();
+ invalidInitial();
+ invalidHistory();
+ unknownIOProc();
+ unknownDataModel();
+ unknownExecContent();
+ syntaxErrors();
+
+ }
+ } catch (ErrorEvent e) {
+ std::cout << e;
+ return EXIT_FAILURE;
}
return EXIT_SUCCESS;