summaryrefslogtreecommitdiffstats
path: root/src/uscxml
diff options
context:
space:
mode:
authorStefan Radomski <github@mintwerk.de>2017-01-27 21:54:43 (GMT)
committerStefan Radomski <github@mintwerk.de>2017-01-27 21:54:43 (GMT)
commit7f83038a1ef642b883417cc984d1f8ca9f0bc64b (patch)
treefd9236e866a06b250992e84bbf41324adf93a9fd /src/uscxml
parentb450411ee8f0a57f3ec3909d65ecc289189e2b35 (diff)
downloaduscxml-7f83038a1ef642b883417cc984d1f8ca9f0bc64b.zip
uscxml-7f83038a1ef642b883417cc984d1f8ca9f0bc64b.tar.gz
uscxml-7f83038a1ef642b883417cc984d1f8ca9f0bc64b.tar.bz2
Reactivated BUILD_AS_PLUGINS
Diffstat (limited to 'src/uscxml')
-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
43 files changed, 691 insertions, 214 deletions
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
};