summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2014-07-03 01:10:03 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2014-07-03 01:10:03 (GMT)
commitb542369263782dc8b85893e218119ed070efa7b3 (patch)
tree0a18012a0af991755ceab98a457b46b79c14129f /src
parent193a01614dc3290eec51745a91be65c166c3763b (diff)
downloaduscxml-b542369263782dc8b85893e218119ed070efa7b3.zip
uscxml-b542369263782dc8b85893e218119ed070efa7b3.tar.gz
uscxml-b542369263782dc8b85893e218119ed070efa7b3.tar.bz2
Got ready for cmake3 and some minor fixes
Diffstat (limited to 'src')
-rw-r--r--src/bindings/CMakeLists.txt5
-rw-r--r--src/bindings/swig/csharp/CMakeLists.txt3
-rw-r--r--src/bindings/swig/csharp/uscxml.i57
-rw-r--r--src/bindings/swig/java/uscxml.i57
-rw-r--r--src/bindings/swig/uscxml_beautify.i52
-rw-r--r--src/bindings/swig/wrapped/WrappedIOProcessor.h2
-rw-r--r--src/uscxml/Factory.cpp2
-rw-r--r--src/uscxml/Interpreter.cpp25
-rw-r--r--src/uscxml/Interpreter.h2
-rw-r--r--src/uscxml/interpreter/InterpreterDraft6.cpp6
-rw-r--r--src/uscxml/messages/SendRequest.h2
-rw-r--r--src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp2
12 files changed, 144 insertions, 71 deletions
diff --git a/src/bindings/CMakeLists.txt b/src/bindings/CMakeLists.txt
index ca5b774..25c11a1 100644
--- a/src/bindings/CMakeLists.txt
+++ b/src/bindings/CMakeLists.txt
@@ -12,6 +12,8 @@ if (WIN32)
endif()
LIST(APPEND CMAKE_PROGRAM_PATH "C:/Program Files/swig") # swig.exe
+ LIST(APPEND CMAKE_PROGRAM_PATH "C:/Program Files (x86)/swig") # swig.exe
+
endif()
LIST(APPEND CMAKE_PROGRAM_PATH $ENV{SWIG_DIR})
@@ -23,6 +25,9 @@ if (SWIG_FOUND)
INCLUDE(${SWIG_USE_FILE})
add_subdirectory(swig/java)
add_subdirectory(swig/csharp)
+ if(SWIG_VERSION VERSION_LESS 3.0.0)
+ message(STATUS "SWIG version > 3.0 is recommended, found ${SWIG_VERSION}")
+ endif()
else()
message(STATUS "SWIG version 2.0.5 is required, found ${SWIG_VERSION} - skipping java wrapper generation")
endif()
diff --git a/src/bindings/swig/csharp/CMakeLists.txt b/src/bindings/swig/csharp/CMakeLists.txt
index 80d093e..ee37bf7 100644
--- a/src/bindings/swig/csharp/CMakeLists.txt
+++ b/src/bindings/swig/csharp/CMakeLists.txt
@@ -2,9 +2,8 @@
# Make from within Eclipse fails miserably with the whole thing
if (WIN32)
- LIST(APPEND CMAKE_PROGRAM_PATH "C:/Program Files (x86)/swig") # swig.exe
- #LIST(APPEND CMAKE_PROGRAM_PATH "C:/Windows/Microsoft.NET/Framework/v4.0.30319") # CSharp compiler
LIST(APPEND CMAKE_PROGRAM_PATH "C:/Windows/Microsoft.NET/Framework/v3.5") # CSharp compiler
+ LIST(APPEND CMAKE_PROGRAM_PATH "C:/Windows/Microsoft.NET/Framework/v4.0.30319") # CSharp compiler
endif()
FIND_PROGRAM(DMCS_EXECUTABLE dmcs PATHS $ENV{DMCS_HOME} ENV PATH ) # Mono compiler
diff --git a/src/bindings/swig/csharp/uscxml.i b/src/bindings/swig/csharp/uscxml.i
index 8e9a297..2a1ac07 100644
--- a/src/bindings/swig/csharp/uscxml.i
+++ b/src/bindings/swig/csharp/uscxml.i
@@ -36,6 +36,8 @@ typedef uscxml::ExecutableContentImpl ExecutableContentImpl;
#pragma SWIG nowarn=401
// do not warn when we override symbols via extend
#pragma SWIG nowarn=302
+// do not warn when ignoring overrided method
+#pragma SWIG nowarn=516
%csconst(1);
@@ -133,14 +135,69 @@ WRAP_THROW_EXCEPTION(uscxml::Interpreter::step);
WRAP_THROW_EXCEPTION(uscxml::Interpreter::interpret);
+%define WRAP_TO_STRING( CLASSNAME )
+%csmethodmodifiers CLASSNAME::ToString() "public override";
+%extend CLASSNAME {
+ virtual std::string ToString() {
+ std::stringstream ss;
+ ss << *self;
+ return ss.str();
+ }
+};
+%enddef
+
+WRAP_TO_STRING(uscxml::Event);
+WRAP_TO_STRING(uscxml::Data);
+WRAP_TO_STRING(uscxml::SendRequest);
+WRAP_TO_STRING(uscxml::InvokeRequest);
+
%include "../uscxml_ignores.i"
//***********************************************
// Beautify important classes
//***********************************************
+%csmethodmodifiers uscxml::Event::getParamMap() "private";
+%csmethodmodifiers uscxml::Event::getParamMapKeys() "private";
+%csmethodmodifiers uscxml::Event::setParamMap(const std::map<std::string, std::list<uscxml::Data> >&) "private";
+%csmethodmodifiers uscxml::Event::getNameListKeys() "private";
+%csmethodmodifiers uscxml::Interpreter::getIOProcessorKeys() "private";
+%csmethodmodifiers uscxml::Interpreter::getInvokerKeys() "private";
+%csmethodmodifiers uscxml::Interpreter::getInvokers() "private";
+%csmethodmodifiers uscxml::Interpreter::getIOProcessors() "private";
+%csmethodmodifiers uscxml::Data::getCompoundKeys() "private";
+
%include "../uscxml_beautify.i"
+%typemap(csimports) uscxml::Interpreter %{
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+%}
+
+%typemap(cscode) uscxml::Interpreter %{
+ public Dictionary<string, NativeIOProcessor> getIOProcessors() {
+ Dictionary<string, NativeIOProcessor> ioProcs = new Dictionary<string, NativeIOProcessor>();
+ StringVector keys = getIOProcessorKeys();
+ IOProcMap ioProcMap = getIOProcessorsNative();
+ for (int i = 0; i < keys.Count; i++) {
+ ioProcs[keys[i]] = ioProcMap[keys[i]];
+ }
+ return ioProcs;
+ }
+
+ public Dictionary<string, NativeInvoker> getInvokers() {
+ Dictionary<string, NativeInvoker> invokers = new Dictionary<string, NativeInvoker>();
+ StringVector keys = getInvokerKeys();
+ InvokerMap invokerMap = getInvokersNative();
+ for (int i = 0; i < keys.Count; i++) {
+ invokers[keys[i]] = invokerMap[keys[i]];
+ }
+ return invokers;
+ }
+
+%}
+
%rename(getCompoundNative) uscxml::Data::getCompound();
%rename(getArrayNative) uscxml::Data::getArray();
diff --git a/src/bindings/swig/java/uscxml.i b/src/bindings/swig/java/uscxml.i
index cb760e4..ee95eb0 100644
--- a/src/bindings/swig/java/uscxml.i
+++ b/src/bindings/swig/java/uscxml.i
@@ -36,6 +36,8 @@ typedef uscxml::ExecutableContentImpl ExecutableContentImpl;
#pragma SWIG nowarn=401
// do not warn when we override symbols via extend
#pragma SWIG nowarn=302
+// do not warn when ignoring overrided method
+#pragma SWIG nowarn=516
%javaconst(1);
@@ -93,6 +95,21 @@ WRAP_THROW_EXCEPTION(uscxml::Interpreter::step);
WRAP_THROW_EXCEPTION(uscxml::Interpreter::interpret);
+%define WRAP_TO_STRING( CLASSNAME )
+%extend CLASSNAME {
+ virtual std::string toString() {
+ std::stringstream ss;
+ ss << *self;
+ return ss.str();
+ }
+};
+%enddef
+
+WRAP_TO_STRING(uscxml::Event);
+WRAP_TO_STRING(uscxml::Data);
+WRAP_TO_STRING(uscxml::SendRequest);
+WRAP_TO_STRING(uscxml::InvokeRequest);
+
%include "../uscxml_ignores.i"
// see http://swig.org/Doc2.0/Java.html#Java_date_marshalling
@@ -153,9 +170,49 @@ BEAUTIFY_NATIVE(uscxml::InvokeRequest, InvokeRequest, InvokeRequestNative);
// Beautify important classes
//***********************************************
+%javamethodmodifiers uscxml::Event::getParamMap() "private";
+%javamethodmodifiers uscxml::Event::getParamMapKeys() "private";
+%javamethodmodifiers uscxml::Event::setParamMap(const std::map<std::string, std::list<uscxml::Data> >&) "private";
+%javamethodmodifiers uscxml::Event::getNameListKeys() "private";
+%javamethodmodifiers uscxml::Interpreter::getIOProcessorKeys() "private";
+%javamethodmodifiers uscxml::Interpreter::getInvokerKeys() "private";
+%javamethodmodifiers uscxml::Interpreter::getInvokers() "private";
+%javamethodmodifiers uscxml::Interpreter::getIOProcessors() "private";
+%javamethodmodifiers uscxml::Data::getCompoundKeys() "private";
+
%include "../uscxml_beautify.i"
+%typemap(javaimports) uscxml::Interpreter %{
+import java.util.Map;
+import java.util.HashMap;
+import java.util.List;
+import java.util.LinkedList;
+%}
+
+%typemap(javacode) uscxml::Interpreter %{
+ public Map<String, NativeIOProcessor> getIOProcessors() {
+ Map<String, NativeIOProcessor> ioProcs = new HashMap<String, NativeIOProcessor>();
+ StringVector keys = getIOProcessorKeys();
+ IOProcMap ioProcMap = getIOProcessorsNative();
+ for (int i = 0; i < keys.size(); i++) {
+ ioProcs.put(keys.get(i), ioProcMap.get(keys.get(i)));
+ }
+ return ioProcs;
+ }
+
+ public Map<String, NativeInvoker> getInvokers() {
+ Map<String, NativeInvoker> invokers = new HashMap<String, NativeInvoker>();
+ StringVector keys = getInvokerKeys();
+ InvokerMap invokerMap = getInvokersNative();
+ for (int i = 0; i < keys.size(); i++) {
+ invokers.put(keys.get(i), invokerMap.get(keys.get(i)));
+ }
+ return invokers;
+ }
+
+%}
+
%rename(getCompoundNative) uscxml::Data::getCompound();
%rename(getArrayNative) uscxml::Data::getArray();
%rename(setCompoundNative) uscxml::Data::setCompound(const std::map<std::string, Data>&);
diff --git a/src/bindings/swig/uscxml_beautify.i b/src/bindings/swig/uscxml_beautify.i
index ac3ed44..6daba77 100644
--- a/src/bindings/swig/uscxml_beautify.i
+++ b/src/bindings/swig/uscxml_beautify.i
@@ -9,34 +9,10 @@
%rename(NativeInterpreterMonitor) InterpreterMonitor;
%rename(InterpreterMonitor) WrappedInterpreterMonitor;
-%extend uscxml::Event {
-/* std::vector<std::pair<std::string, uscxml::Data> > getParamPairs() {
- std::vector<std::pair<std::string, Data> > pairs;
- std::multimap<std::string, Data>::iterator paramPairIter = self->getParams().begin();
- while(paramPairIter != self->getParams().end()) {
- pairs.push_back(*paramPairIter);
- paramPairIter++;
- }
- return pairs;
- }
+%rename(getInvokersNative) uscxml::Interpreter::getInvokers();
+%rename(getIOProcessorsNative) uscxml::Interpreter::getIOProcessors();
- void setParamPairs(const std::vector<std::pair<std::string, uscxml::Data> >& pairs) {
- std::multimap<std::string, Data> params;
- std::vector<std::pair<std::string, Data> >::const_iterator pairIter = pairs.begin();
- while(pairIter != pairs.end()) {
- params.insert(std::make_pair(pairIter->first, pairIter->second));
- pairIter++;
- }
- self->setParams(params);
- }
-*/
-
- std::string toString() {
- std::stringstream ss;
- ss << *self;
- return ss.str();
- }
-
+%extend uscxml::Event {
std::map<std::string, std::list<uscxml::Data> > getParamMap() {
std::map<std::string, std::list<uscxml::Data> > paramMap;
std::multimap<std::string, Data>::const_iterator paramPairIter = self->getParams().begin();
@@ -127,12 +103,6 @@
};
%extend uscxml::Data {
- std::string toString() {
- std::stringstream ss;
- ss << *self;
- return ss.str();
- }
-
std::vector<std::string> getCompoundKeys() {
std::vector<std::string> keys;
std::map<std::string, Data>::const_iterator iter = self->compound.begin();
@@ -143,19 +113,3 @@
return keys;
}
};
-
-%extend uscxml::SendRequest {
- std::string toString() {
- std::stringstream ss;
- ss << *self;
- return ss.str();
- }
-};
-
-%extend uscxml::InvokeRequest {
- std::string toString() {
- std::stringstream ss;
- ss << *self;
- return ss.str();
- }
-}; \ No newline at end of file
diff --git a/src/bindings/swig/wrapped/WrappedIOProcessor.h b/src/bindings/swig/wrapped/WrappedIOProcessor.h
index b4e4938..0b5cfe8 100644
--- a/src/bindings/swig/wrapped/WrappedIOProcessor.h
+++ b/src/bindings/swig/wrapped/WrappedIOProcessor.h
@@ -47,7 +47,7 @@ public:
_interpreter = interpreter->shared_from_this();
return boost::shared_ptr<IOProcessorImpl>(create(_interpreter));
}
-
+
virtual std::list<std::string> getNames() {
return std::list<std::string>();
};
diff --git a/src/uscxml/Factory.cpp b/src/uscxml/Factory.cpp
index 22482e6..0f3e8c9 100644
--- a/src/uscxml/Factory.cpp
+++ b/src/uscxml/Factory.cpp
@@ -672,7 +672,7 @@ void EventHandlerImpl::returnEvent(Event& event, bool external) {
event.origin = "#_" + _invokeId;
if (event.origintype.length() == 0)
event.origintype = _type;
-
+
if (external) {
_interpreter->receive(event);
} else {
diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp
index 47a6182..5b0db2d 100644
--- a/src/uscxml/Interpreter.cpp
+++ b/src/uscxml/Interpreter.cpp
@@ -97,15 +97,15 @@
#define VALID_FROM_FINISHED(newState) ( \
newState == USCXML_DESTROYED || \
newState == USCXML_INSTANTIATED \
-)
+)
/// macro to catch exceptions in executeContent
#define CATCH_AND_DISTRIBUTE(msg) \
catch (Event e) {\
- LOG(ERROR) << msg << std::endl << e << std::endl;\
if (rethrow) {\
throw(e);\
} else {\
+ LOG(ERROR) << msg << std::endl << e << std::endl;\
e.name = "error.execution";\
e.data.compound["cause"] = uscxml::Data(msg, uscxml::Data::VERBATIM); \
e.eventType = Event::PLATFORM;\
@@ -116,10 +116,10 @@ catch (Event e) {\
#define CATCH_AND_DISTRIBUTE2(msg, node) \
catch (Event e) {\
std::string xpathPos = DOMUtils::xPathForNode(node); \
- LOG(ERROR) << msg << " " << xpathPos << ":" << std::endl << e << std::endl;\
if (rethrow) {\
throw(e);\
} else {\
+ LOG(ERROR) << msg << " " << xpathPos << ":" << std::endl << e << std::endl;\
e.name = "error.execution";\
e.data.compound["cause"] = uscxml::Data(msg, uscxml::Data::VERBATIM); \
e.data.compound["xpath"] = uscxml::Data(xpathPos, uscxml::Data::VERBATIM); \
@@ -684,7 +684,7 @@ void InterpreterImpl::reset() {
_topLevelFinalReached = false;
_isInitialized = false;
_stable = false;
-
+
setInterpreterState(USCXML_INSTANTIATED);
}
@@ -1162,15 +1162,16 @@ void InterpreterImpl::send(const Arabica::DOM::Node<std::string>& element) {
try {
// namelist
if (HAS_ATTR(element, "namelist")) {
- if (_dataModel) {
- std::list<std::string> names = tokenizeIdRefs(ATTR(element, "namelist"));
- for (std::list<std::string>::const_iterator nameIter = names.begin(); nameIter != names.end(); nameIter++) {
- Data namelistValue = _dataModel.getStringAsData(*nameIter);
- sendReq.namelist[*nameIter] = namelistValue;
- sendReq.data.compound[*nameIter] = namelistValue;
+ std::list<std::string> names = tokenizeIdRefs(ATTR(element, "namelist"));
+ for (std::list<std::string>::const_iterator nameIter = names.begin(); nameIter != names.end(); nameIter++) {
+ if (!_dataModel.isDeclared(*nameIter)) {
+ LOG(ERROR) << "Error in send element " << DOMUtils::xPathForNode(element) << " namelist:" << std::endl << "'" << *nameIter << "' is not declared" << std::endl;
+ ERROR_EXECUTION2(err, "Location expression '" + *nameIter + "' in namelist is invalid", element);
+ return;
}
- } else {
- LOG(ERROR) << "Namelist attribute at send requires datamodel to be defined";
+ Data namelistValue = _dataModel.getStringAsData(*nameIter);
+ sendReq.namelist[*nameIter] = namelistValue;
+ sendReq.data.compound[*nameIter] = namelistValue;
}
}
} catch (Event e) {
diff --git a/src/uscxml/Interpreter.h b/src/uscxml/Interpreter.h
index cf281b5..2ad1039 100644
--- a/src/uscxml/Interpreter.h
+++ b/src/uscxml/Interpreter.h
@@ -51,7 +51,7 @@
e.name = "error.platform"; \
e.data.compound["cause"] = Data(msg, Data::VERBATIM); \
throw e; \
-
+
#define USCXML_MONITOR_CATCH(callback) \
catch (Event e) { \
diff --git a/src/uscxml/interpreter/InterpreterDraft6.cpp b/src/uscxml/interpreter/InterpreterDraft6.cpp
index 048adf9..fdbd21b 100644
--- a/src/uscxml/interpreter/InterpreterDraft6.cpp
+++ b/src/uscxml/interpreter/InterpreterDraft6.cpp
@@ -151,7 +151,7 @@ InterpreterState InterpreterDraft6::step(int waitForMS = 0) {
}
_stable = true;
}
-
+
// test415
if (_topLevelFinalReached)
goto EXIT_INTERPRETER;
@@ -185,7 +185,7 @@ InterpreterState InterpreterDraft6::step(int waitForMS = 0) {
if (_state != USCXML_MACROSTEPPED && _state != USCXML_IDLE)
USCXML_MONITOR_CALLBACK(onStableConfiguration)
- setInterpreterState(USCXML_MACROSTEPPED);
+ setInterpreterState(USCXML_MACROSTEPPED);
if (_topLevelFinalReached)
goto EXIT_INTERPRETER;
@@ -232,7 +232,7 @@ InterpreterState InterpreterDraft6::step(int waitForMS = 0) {
_currEvent = _externalQueue.pop();
_currEvent.eventType = Event::EXTERNAL; // make sure it is set to external
_stable = false;
-
+
if (_topLevelFinalReached)
goto EXIT_INTERPRETER;
diff --git a/src/uscxml/messages/SendRequest.h b/src/uscxml/messages/SendRequest.h
index 6bc3d91..f43b856 100644
--- a/src/uscxml/messages/SendRequest.h
+++ b/src/uscxml/messages/SendRequest.h
@@ -26,7 +26,7 @@ namespace uscxml {
class USCXML_API SendRequest : public Event {
public:
- SendRequest() {}
+ SendRequest() : delayMs(0) {}
SendRequest(Event event) : Event(event) {}
std::string getTarget() {
diff --git a/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp b/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp
index 5800f98..3b28547 100644
--- a/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp
@@ -663,7 +663,7 @@ void XPathDataModel::assign(const NodeSet<std::string>& key,
// addattribute: Add an attribute with the name specified by 'attr'
// and value specified by 'expr' to the node specified by 'location'.
if (!HAS_ATTR(assignElem, "attr"))
- ERROR_EXECUTION_THROW("Assign element is missing 'attr'")
+ ERROR_EXECUTION_THROW("Assign element is missing 'attr'");
element.setAttribute(ATTR(assignElem, "attr"), value);
} else {
/// test 547