diff options
23 files changed, 663 insertions, 56 deletions
diff --git a/embedding/csharp/embedding/embedding.suo b/embedding/csharp/embedding/embedding.suo Binary files differindex f011087..3c8cd31 100644 --- a/embedding/csharp/embedding/embedding.suo +++ b/embedding/csharp/embedding/embedding.suo diff --git a/embedding/csharp/embedding/embedding/Program.cs b/embedding/csharp/embedding/embedding/Program.cs index 3899178..3b5a28c 100644 --- a/embedding/csharp/embedding/embedding/Program.cs +++ b/embedding/csharp/embedding/embedding/Program.cs @@ -17,18 +17,19 @@ namespace embedding {
/*
- * Make sure this path contains the umundoNativeCSharp.dll!
+ * Make sure this path contains the uscxmlNativeCSharp.dll!
*/
if (System.Environment.Is64BitProcess)
{
- SetDllDirectory("C:\\Users\\sradomski\\Desktop\\build\\lib\\csharp64");
+ SetDllDirectory("C:\\Users\\sradomski\\Desktop\\build\\uscxml64\\lib\\csharp");
}
else
{
- SetDllDirectory("C:\\Users\\sradomski\\Desktop\\build\\lib\\csharp");
+ SetDllDirectory("C:\\Users\\sradomski\\Desktop\\build\\uscxml\\lib\\csharp");
}
- Interpreter interpreter = Interpreter.fromXML("<scxml><state id=\"foo\"/></scxml>");
+ Interpreter interpreter = Interpreter.fromXML("<scxml><state id=\"foo\" final=\"true\" /></scxml>");
+ interpreter.addMonitor(new TestInterpreterMonitor());
interpreter.interpret();
}
}
diff --git a/embedding/csharp/embedding/embedding/TestDataModel.cs b/embedding/csharp/embedding/embedding/TestDataModel.cs new file mode 100644 index 0000000..bfcfd30 --- /dev/null +++ b/embedding/csharp/embedding/embedding/TestDataModel.cs @@ -0,0 +1,92 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using org.uscxml;
+
+namespace EmbeddedDataModel
+{
+ class TestDataModel : DataModel
+ {
+ public override DataModel create(Interpreter interpreter)
+ {
+ return new TestDataModel();
+ }
+
+ public override void eval(string scriptElem, string expr)
+ {
+ // evaluate expr on the datamodel
+ }
+
+ public override bool evalAsBool(string elem, string content)
+ {
+ return evalAsBool(content);
+ }
+
+ public override bool evalAsBool(string expr)
+ {
+ // evaluate expr as bool
+ return false;
+ }
+
+ public override void assign(string assignElem, string location, string content)
+ {
+ // set variable at location to content
+ }
+
+ public override string evalAsString(string expr)
+ {
+ // evaluate given expr as a string (e.g. for <log>)
+ return "";
+ }
+
+ public override uint getLength(string expr)
+ {
+ // return the length of an expression for foreach
+ return 0;
+ }
+
+ public override StringList getNames()
+ {
+ // name of this datamodel to be used in scxml element
+ StringList names = new StringList();
+ names.add("simple");
+ return names;
+ }
+
+ public override DataNative getStringAsData(string content)
+ {
+ // DataNative ought to be wrapped by a Data.cs class - used to carry JSONesque structures
+ DataNative data = new DataNative();
+ return data;
+ }
+
+ public override void init(string dataElem, string location, string content)
+ {
+ // initialize variable at location to evaluated content - used for scxml data elements
+ }
+
+ public override void setEvent(Event arg0)
+ {
+ // represent given event as _event in datamodel
+ }
+
+ public override bool isDeclared(string expr)
+ {
+ // using an undeclared variable is an error.execution with some scxml constructs -
+ // determine whether the given expression is defined
+ return true;
+ }
+
+ public override void setForeach(string item, string array, string index, uint iteration)
+ {
+ // called per foreach iteration, set datamodel variables accordingly
+ }
+
+ public override bool validate(string location, string schema)
+ {
+ // primarily intended for xpath datamodel
+ return true;
+ }
+ }
+}
diff --git a/embedding/csharp/embedding/embedding/TestExecutableContent.cs b/embedding/csharp/embedding/embedding/TestExecutableContent.cs new file mode 100644 index 0000000..199445b --- /dev/null +++ b/embedding/csharp/embedding/embedding/TestExecutableContent.cs @@ -0,0 +1,33 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using org.uscxml;
+
+namespace embedding
+{
+ class TestExecutableContent : ExecutableContent
+ {
+ public override string getLocalName()
+ {
+ return "custom";
+ }
+
+ public override void enterElement(string node)
+ {
+
+ }
+
+ public override void exitElement(string node)
+ {
+
+ }
+
+ public override ExecutableContent create(Interpreter interpreter)
+ {
+ return new TestExecutableContent();
+ }
+
+
+ }
+}
diff --git a/embedding/csharp/embedding/embedding/TestIOProc.cs b/embedding/csharp/embedding/embedding/TestIOProc.cs new file mode 100644 index 0000000..1c00034 --- /dev/null +++ b/embedding/csharp/embedding/embedding/TestIOProc.cs @@ -0,0 +1,28 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using org.uscxml;
+
+namespace embedding
+{
+ class TestIOProc : IOProcessor
+ {
+ public override DataNative getDataModelVariables()
+ {
+ DataNative data = new DataNative();
+ return data;
+ }
+
+ public override StringList getNames()
+ {
+ StringList names = new StringList();
+ names.add("simple");
+ return names;
+ }
+
+ public override void send(SendRequest req)
+ {
+ }
+ }
+}
diff --git a/embedding/csharp/embedding/embedding/TestInterpreterMonitor.cs b/embedding/csharp/embedding/embedding/TestInterpreterMonitor.cs new file mode 100644 index 0000000..03eb9d6 --- /dev/null +++ b/embedding/csharp/embedding/embedding/TestInterpreterMonitor.cs @@ -0,0 +1,31 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using org.uscxml;
+
+namespace embedding
+{
+ class TestInterpreterMonitor : InterpreterMonitor
+ {
+ public override void afterCompletion(Interpreter interpreter) { }
+ public override void afterMicroStep(Interpreter interpreter) { }
+ public override void beforeCompletion(Interpreter interpreter) { }
+ public override void beforeMicroStep(Interpreter interpreter) { }
+ public override void beforeProcessingEvent(Interpreter interpreter, Event arg1) { }
+ public override void onStableConfiguration(Interpreter interpreter) { }
+ public override void afterEnteringState(Interpreter interpreter, string stateId, string xpath, string state, bool moreComing) { }
+ public override void afterExecutingContent(Interpreter interpreter, string tagName, string xpath, string element) { }
+ public override void afterExitingState(Interpreter interpreter, string stateId, string xpath, string state, bool moreComing) { }
+ public override void afterInvoking(Interpreter interpreter, string xpath, string invokeid, string element) { }
+ public override void afterTakingTransition(Interpreter interpreter, string xpath, string source, StringList targets, string element, bool moreComing) { }
+ public override void afterUninvoking(Interpreter interpreter, string xpath, string invokeid, string element) { }
+ public override void beforeEnteringState(Interpreter interpreter, string stateId, string xpath, string state, bool moreComing) { }
+ public override void beforeExecutingContent(Interpreter interpreter, string tagName, string xpath, string element) { }
+ public override void beforeExitingState(Interpreter interpreter, string stateId, string xpath, string state, bool moreComing) { }
+ public override void beforeInvoking(Interpreter interpreter, string xpath, string invokeid, string element) { }
+ public override void beforeTakingTransition(Interpreter interpreter, string xpath, string source, StringList targets, string element, bool moreComing) { }
+ public override void beforeUninvoking(Interpreter interpreter, string xpath, string invokeid, string element) { }
+
+ }
+}
diff --git a/embedding/csharp/embedding/embedding/TestInvoker.cs b/embedding/csharp/embedding/embedding/TestInvoker.cs new file mode 100644 index 0000000..11493d3 --- /dev/null +++ b/embedding/csharp/embedding/embedding/TestInvoker.cs @@ -0,0 +1,32 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using org.uscxml;
+
+namespace EmbeddedInvoker
+{
+ class TestInvoker : Invoker
+ {
+ public override DataNative getDataModelVariables()
+ {
+ DataNative data = new DataNative();
+ return data;
+ }
+
+ public override StringList getNames()
+ {
+ StringList names = new StringList();
+ names.add("simple");
+ return names;
+ }
+
+ public override void invoke(InvokeRequest req)
+ {
+ }
+
+ public override void send(SendRequest req)
+ {
+ }
+ }
+}
diff --git a/embedding/csharp/embedding/embedding/embedding.csproj b/embedding/csharp/embedding/embedding/embedding.csproj index 53e1eed..ca54bd4 100644 --- a/embedding/csharp/embedding/embedding/embedding.csproj +++ b/embedding/csharp/embedding/embedding/embedding.csproj @@ -47,13 +47,19 @@ <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
- <Reference Include="uscxmlCSharp">
- <HintPath>..\..\..\..\build\cli\lib\uscxmlCSharp.dll</HintPath>
+ <Reference Include="uscxmlCSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>C:\Users\sradomski\Desktop\build\uscxml\lib\uscxmlCSharp.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
+ <Compile Include="TestExecutableContent.cs" />
+ <Compile Include="TestInterpreterMonitor.cs" />
+ <Compile Include="TestIOProc.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="TestDataModel.cs" />
+ <Compile Include="TestInvoker.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
diff --git a/embedding/java/src/org/uscxml/datamodel/ecmascript/ECMAScriptDataModel.java b/embedding/java/src/org/uscxml/datamodel/ecmascript/ECMAScriptDataModel.java index dcafcb9..152f5e3 100644 --- a/embedding/java/src/org/uscxml/datamodel/ecmascript/ECMAScriptDataModel.java +++ b/embedding/java/src/org/uscxml/datamodel/ecmascript/ECMAScriptDataModel.java @@ -11,14 +11,14 @@ import org.mozilla.javascript.Scriptable; import org.mozilla.javascript.ScriptableObject; import org.mozilla.javascript.Undefined; import org.uscxml.Data; +import org.uscxml.DataModel; import org.uscxml.DataNative; import org.uscxml.Event; import org.uscxml.Interpreter; import org.uscxml.StringList; import org.uscxml.StringVector; -import org.uscxml.WrappedDataModel; -public class ECMAScriptDataModel extends WrappedDataModel { +public class ECMAScriptDataModel extends DataModel { public static boolean debug = true; @@ -77,7 +77,7 @@ public class ECMAScriptDataModel extends WrappedDataModel { } @Override - public WrappedDataModel create(Interpreter interpreter) { + public DataModel create(Interpreter interpreter) { /** * Called when an SCXML interpreter wants an instance of this datamodel * Be careful to instantiate attributes of instance returned and not diff --git a/embedding/java/src/org/uscxml/tests/execContent/TestCustomExecContent.java b/embedding/java/src/org/uscxml/tests/execContent/TestCustomExecContent.java index dd5e39a..92d7ed3 100644 --- a/embedding/java/src/org/uscxml/tests/execContent/TestCustomExecContent.java +++ b/embedding/java/src/org/uscxml/tests/execContent/TestCustomExecContent.java @@ -5,9 +5,9 @@ import org.uscxml.Event; import org.uscxml.Factory; import org.uscxml.Interpreter; import org.uscxml.InterpreterException; -import org.uscxml.WrappedExecutableContent; +import org.uscxml.ExecutableContent; -public class TestCustomExecContent extends WrappedExecutableContent { +public class TestCustomExecContent extends ExecutableContent { static int instanceId = 0; public int id = 0; @@ -43,7 +43,7 @@ public class TestCustomExecContent extends WrappedExecutableContent { } @Override - public WrappedExecutableContent create(Interpreter interpreter) { + public ExecutableContent create(Interpreter interpreter) { return new TestCustomExecContent(); } diff --git a/embedding/java/src/org/uscxml/tests/invoker/TestCustomInvoker.java b/embedding/java/src/org/uscxml/tests/invoker/TestCustomInvoker.java index 9343c65..b17b52e 100644 --- a/embedding/java/src/org/uscxml/tests/invoker/TestCustomInvoker.java +++ b/embedding/java/src/org/uscxml/tests/invoker/TestCustomInvoker.java @@ -7,12 +7,11 @@ import org.uscxml.Factory; import org.uscxml.Interpreter; import org.uscxml.InterpreterException; import org.uscxml.InvokeRequest; -import org.uscxml.StringList; -import org.uscxml.WrappedInvoker; +import org.uscxml.Invoker; import org.uscxml.SendRequest; -import org.uscxml.StringSet; +import org.uscxml.StringList; -public class TestCustomInvoker extends WrappedInvoker { +public class TestCustomInvoker extends Invoker { @Override public StringList getNames() { @@ -46,7 +45,7 @@ public class TestCustomInvoker extends WrappedInvoker { } @Override - public WrappedInvoker create(Interpreter interpreter) { + public Invoker create(Interpreter interpreter) { return new TestCustomInvoker(); } diff --git a/embedding/java/src/org/uscxml/tests/ioprocessor/TestCustomIOProc.java b/embedding/java/src/org/uscxml/tests/ioprocessor/TestCustomIOProc.java index 37b31a3..cc4d332 100644 --- a/embedding/java/src/org/uscxml/tests/ioprocessor/TestCustomIOProc.java +++ b/embedding/java/src/org/uscxml/tests/ioprocessor/TestCustomIOProc.java @@ -3,13 +3,13 @@ package org.uscxml.tests.ioprocessor; import org.uscxml.Data; import org.uscxml.DataNative; import org.uscxml.Factory; +import org.uscxml.IOProcessor; import org.uscxml.Interpreter; import org.uscxml.InterpreterException; import org.uscxml.SendRequest; import org.uscxml.StringList; -import org.uscxml.WrappedIOProcessor; -public class TestCustomIOProc extends WrappedIOProcessor { +public class TestCustomIOProc extends IOProcessor { @Override public StringList getNames() { @@ -31,7 +31,7 @@ public class TestCustomIOProc extends WrappedIOProcessor { } @Override - public WrappedIOProcessor create(Interpreter interpreter) { + public IOProcessor create(Interpreter interpreter) { return new TestCustomIOProc(); } @@ -47,6 +47,7 @@ public class TestCustomIOProc extends WrappedIOProcessor { Interpreter interpreter = Interpreter .fromURI("/Users/sradomski/Documents/TK/Code/uscxml/test/samples/uscxml/test-java-invoker.scxml"); + while (true) interpreter.interpret(); } diff --git a/src/bindings/swig/csharp/uscxml.i b/src/bindings/swig/csharp/uscxml.i index e7b7d62..6f4f214 100644 --- a/src/bindings/swig/csharp/uscxml.i +++ b/src/bindings/swig/csharp/uscxml.i @@ -3,9 +3,6 @@ // provide a macro for the header files #define SWIGIMPORTED 1 -// import swig typemaps -//%include <inttypes.i> - %include <stl.i> %include <std_map.i> %include <std_string.i> @@ -24,6 +21,7 @@ typedef uscxml::SendRequest SendRequest; %feature("director") uscxml::WrappedDataModel; %feature("director") uscxml::WrappedIOProcessor; %feature("director") uscxml::WrappedExecutableContent; +%feature("director") uscxml::WrappedInterpreterMonitor; // disable warning related to unknown base class #pragma SWIG nowarn=401 @@ -32,9 +30,6 @@ typedef uscxml::SendRequest SendRequest; %csconst(1); -# %shared_ptr(uscxml::dom::Element); -# %shared_ptr(uscxml::dom::Executable); - %rename(equals) operator==; %rename(isValid) operator bool; @@ -47,19 +42,14 @@ typedef uscxml::SendRequest SendRequest; #include "../../../uscxml/Message.h" #include "../../../uscxml/Factory.h" -#include "../../../uscxml/concurrency/BlockingQueue.h" #include "../../../uscxml/Interpreter.h" - -//#include <DOM/Document.hpp> -//#include <DOM/Node.hpp> -//#include <DOM/Element.hpp> -//#include <DOM/Attr.hpp> -//#include <DOM/Text.hpp> +#include "../../../uscxml/concurrency/BlockingQueue.h" #include "../wrapped/WrappedInvoker.h" #include "../wrapped/WrappedDataModel.h" #include "../wrapped/WrappedExecutableContent.h" #include "../wrapped/WrappedIOProcessor.h" +#include "../wrapped/WrappedInterpreterMonitor.h" using namespace uscxml; using namespace Arabica::DOM; @@ -68,6 +58,7 @@ using namespace Arabica::DOM; #include "../wrapped/WrappedDataModel.cpp" #include "../wrapped/WrappedExecutableContent.cpp" #include "../wrapped/WrappedIOProcessor.cpp" +#include "../wrapped/WrappedInterpreterMonitor.cpp" %} @@ -136,10 +127,6 @@ WRAP_THROW_EXCEPTION(uscxml::Interpreter::interpret); %rename Data DataNative; -// translate param multimap to Map<String, List<Data> > -%rename(getParamsNative) uscxml::Event::getParams(); -%csmethodmodifiers uscxml::Event::getParams() "private"; - %include "../uscxml_beautify.i" @@ -157,6 +144,7 @@ WRAP_THROW_EXCEPTION(uscxml::Interpreter::interpret); %include "../wrapped/WrappedDataModel.h" %include "../wrapped/WrappedExecutableContent.h" %include "../wrapped/WrappedIOProcessor.h" +%include "../wrapped/WrappedInterpreterMonitor.h" %template(DataList) std::list<uscxml::Data>; diff --git a/src/bindings/swig/java/uscxml.i b/src/bindings/swig/java/uscxml.i index b780f74..64dfdd5 100644 --- a/src/bindings/swig/java/uscxml.i +++ b/src/bindings/swig/java/uscxml.i @@ -10,7 +10,6 @@ %include "../stl_set.i" %include "../stl_list.i" - %include <boost_shared_ptr.i> typedef uscxml::Data Data; @@ -22,6 +21,7 @@ typedef uscxml::SendRequest SendRequest; %feature("director") uscxml::WrappedDataModel; %feature("director") uscxml::WrappedIOProcessor; %feature("director") uscxml::WrappedExecutableContent; +%feature("director") uscxml::WrappedInterpreterMonitor; // disable warning related to unknown base class #pragma SWIG nowarn=401 @@ -49,6 +49,7 @@ typedef uscxml::SendRequest SendRequest; #include "../wrapped/WrappedDataModel.h" #include "../wrapped/WrappedExecutableContent.h" #include "../wrapped/WrappedIOProcessor.h" +#include "../wrapped/WrappedInterpreterMonitor.h" using namespace uscxml; using namespace Arabica::DOM; @@ -57,6 +58,7 @@ using namespace Arabica::DOM; #include "../wrapped/WrappedDataModel.cpp" #include "../wrapped/WrappedExecutableContent.cpp" #include "../wrapped/WrappedIOProcessor.cpp" +#include "../wrapped/WrappedInterpreterMonitor.cpp" %} @@ -86,10 +88,6 @@ WRAP_THROW_EXCEPTION(uscxml::Interpreter::interpret); %rename Data DataNative; -// translate param multimap to Map<String, List<Data> > -%rename(getParamsNative) uscxml::Event::getParams(); -%javamethodmodifiers uscxml::Event::getParams() "private"; - %include "../uscxml_beautify.i" @@ -107,6 +105,7 @@ WRAP_THROW_EXCEPTION(uscxml::Interpreter::interpret); %include "../wrapped/WrappedDataModel.h" %include "../wrapped/WrappedExecutableContent.h" %include "../wrapped/WrappedIOProcessor.h" +%include "../wrapped/WrappedInterpreterMonitor.h" %template(DataList) std::list<uscxml::Data>; diff --git a/src/bindings/swig/uscxml_beautify.i b/src/bindings/swig/uscxml_beautify.i index 8b57e78..8a53fbb 100644 --- a/src/bindings/swig/uscxml_beautify.i +++ b/src/bindings/swig/uscxml_beautify.i @@ -1,3 +1,14 @@ +%rename(NativeDataModel) DataModel; +%rename(DataModel) WrappedDataModel; +%rename(NativeExecutableContent) ExecutableContent; +%rename(ExecutableContent) WrappedExecutableContent; +%rename(NativeInvoker) Invoker; +%rename(Invoker) WrappedInvoker; +%rename(NativeIOProcessor) IOProcessor; +%rename(IOProcessor) WrappedIOProcessor; +%rename(NativeInterpreterMonitor) InterpreterMonitor; +%rename(InterpreterMonitor) WrappedInterpreterMonitor; + %extend uscxml::Event { std::vector<std::pair<std::string, Data> > getParamPairs() { std::vector<std::pair<std::string, Data> > pairs; diff --git a/src/bindings/swig/uscxml_ignores.i b/src/bindings/swig/uscxml_ignores.i index 4f8b2a3..38b3e9e 100644 --- a/src/bindings/swig/uscxml_ignores.i +++ b/src/bindings/swig/uscxml_ignores.i @@ -1,14 +1,48 @@ %ignore uscxml::NumAttr; %ignore uscxml::SCXMLParser; %ignore uscxml::InterpreterImpl; +#if 0 +%ignore uscxml::EventHandlerImpl; +#endif %ignore create(); +%ignore uscxml::EventHandlerImpl::setInterpreter(InterpreterImpl*); +%ignore uscxml::EventHandlerImpl::getInterpreter; +%ignore uscxml::EventHandlerImpl::setElement(const Arabica::DOM::Element<std::string>&); +%ignore uscxml::EventHandlerImpl::getElement; +%ignore uscxml::EventHandlerImpl::runOnMainThread; + +%ignore uscxml::EventHandler::EventHandler(const boost::shared_ptr<EventHandlerImpl>); +%ignore uscxml::EventHandler::EventHandler(EventHandler&); +%ignore uscxml::EventHandler::setInterpreter(InterpreterImpl*); +%ignore uscxml::EventHandler::getInterpreter; +%ignore uscxml::EventHandler::setElement(const Arabica::DOM::Element<std::string>&); +%ignore uscxml::EventHandler::getElement; +%ignore uscxml::EventHandler::runOnMainThread; + + +%ignore uscxml::NameSpaceInfo::NameSpaceInfo(const std::map<std::string, std::string>&); +%ignore uscxml::NameSpaceInfo::NameSpaceInfo(const NameSpaceInfo&); +%ignore uscxml::NameSpaceInfo::setPrefix(Arabica::DOM::Element<std::string>); +%ignore uscxml::NameSpaceInfo::setPrefix(Arabica::DOM::Attr<std::string>); +%ignore uscxml::NameSpaceInfo::getNSContext; +%ignore uscxml::NameSpaceInfo::nsURL; +%ignore uscxml::NameSpaceInfo::xpathPrefix; +%ignore uscxml::NameSpaceInfo::xmlNSPrefix; +%ignore uscxml::NameSpaceInfo::nsToPrefix; +%ignore uscxml::NameSpaceInfo::nsInfo; + +// interpreter + +%ignore uscxml::Interpreter::Interpreter(const boost::shared_ptr<InterpreterImpl>); +%ignore uscxml::Interpreter::Interpreter(const Interpreter&); %ignore uscxml::Interpreter::getDelayQueue(); %ignore uscxml::Interpreter::fromDOM; %ignore uscxml::Interpreter::fromClone; %ignore uscxml::Interpreter::start(); %ignore uscxml::Interpreter::stop(); +%ignore uscxml::Interpreter::isRunning(); %ignore uscxml::Interpreter::setCmdLineOptions(std::map<std::string, std::string>); %ignore uscxml::Interpreter::getDocument; %ignore uscxml::Interpreter::getImpl; @@ -18,7 +52,71 @@ %ignore uscxml::Interpreter::isLegalConfiguration(const Arabica::XPath::NodeSet<std::string>&); %ignore uscxml::Interpreter::getInstances(); +// InterpreterMonitor + +%ignore uscxml::InterpreterMonitor::beforeExitingState(Interpreter, const Arabica::DOM::Element<std::string>&, bool); +%ignore uscxml::InterpreterMonitor::afterExitingState(Interpreter, const Arabica::DOM::Element<std::string>&, bool); +%ignore uscxml::InterpreterMonitor::beforeEnteringState(Interpreter, const Arabica::DOM::Element<std::string>&, bool); +%ignore uscxml::InterpreterMonitor::afterEnteringState(Interpreter, const Arabica::DOM::Element<std::string>&, bool); + +%ignore uscxml::InterpreterMonitor::beforeUninvoking(Interpreter, const Arabica::DOM::Element<std::string>&, const std::string&); +%ignore uscxml::InterpreterMonitor::afterUninvoking(Interpreter, const Arabica::DOM::Element<std::string>&, const std::string&); +%ignore uscxml::InterpreterMonitor::beforeInvoking(Interpreter, const Arabica::DOM::Element<std::string>&, const std::string&); +%ignore uscxml::InterpreterMonitor::afterInvoking(Interpreter, const Arabica::DOM::Element<std::string>&, const std::string&); + +%ignore uscxml::InterpreterMonitor::beforeTakingTransition(Interpreter, const Arabica::DOM::Element<std::string>&, bool); +%ignore uscxml::InterpreterMonitor::afterTakingTransition(Interpreter, const Arabica::DOM::Element<std::string>&, bool); + +%ignore uscxml::InterpreterMonitor::beforeExecutingContent(Interpreter, const Arabica::DOM::Element<std::string>&); +%ignore uscxml::InterpreterMonitor::afterExecutingContent(Interpreter, const Arabica::DOM::Element<std::string>&); + + +%ignore uscxml::InterpreterOptions::fromCmdLine(int, char**); +%ignore uscxml::InterpreterOptions::additionalParameters; +%ignore uscxml::InterpreterOptions::interpreters; + +// Invoker + +%ignore uscxml::Invoker::Invoker(const boost::shared_ptr<InvokerImpl>); +%ignore uscxml::Invoker::setInterpreter(InterpreterImpl*); +%ignore uscxml::Invoker::getInterpreter; + +%ignore uscxml::InvokerImpl::create(InterpreterImpl*); %ignore uscxml::WrappedInvoker::create(InterpreterImpl*); +%ignore uscxml::InvokerImpl::setInterpreter(InterpreterImpl*); +%ignore uscxml::InvokerImpl::getInterpreter; + + +// DataModel + +%ignore uscxml::DataModel::DataModel(const boost::shared_ptr<DataModelImpl>); +%ignore uscxml::DataModel::DataModel(const DataModel&); +%ignore uscxml::DataModel::eval(const Arabica::DOM::Element<std::string>&, const std::string&); +%ignore uscxml::DataModel::evalAsBool(const Arabica::DOM::Node<std::string>&, const std::string&); +%ignore uscxml::DataModel::throwErrorExecution(const std::string&); +%ignore uscxml::DataModel::throwErrorPlatform(const std::string&); +%ignore uscxml::DataModel::init(const Arabica::DOM::Element<std::string>&, const Arabica::DOM::Document<std::string>&, const std::string&); +%ignore uscxml::DataModel::init(const Arabica::DOM::Element<std::string>&, const Arabica::DOM::Node<std::string>&, const std::string&); +%ignore uscxml::DataModel::assign(const Arabica::DOM::Element<std::string>&, const Arabica::DOM::Document<std::string>&, const std::string&); +%ignore uscxml::DataModel::assign(const Arabica::DOM::Element<std::string>&, const Arabica::DOM::Node<std::string>&, const std::string&); +%ignore uscxml::DataModel::replaceExpressions(std::string&); +%ignore uscxml::DataModel::setInterpreter(InterpreterImpl*); +%ignore uscxml::DataModel::getInterpreter; + +%ignore uscxml::DataModelImpl::create(InterpreterImpl*); +%ignore uscxml::DataModelImpl::throwErrorExecution(const std::string&); +%ignore uscxml::DataModelImpl::throwErrorPlatform(const std::string&); +%ignore uscxml::DataModelImpl::setInterpreter(InterpreterImpl*); +%ignore uscxml::DataModelImpl::getInterpreter; +%ignore uscxml::DataModelImpl::replaceExpressions(std::string&); +%ignore uscxml::DataModelImpl::init(const Arabica::DOM::Element<std::string>&, const Arabica::DOM::Document<std::string>&, const std::string&); +%ignore uscxml::DataModelImpl::init(const Arabica::DOM::Element<std::string>&, const Arabica::DOM::Node<std::string>&, const std::string&); +%ignore uscxml::DataModelImpl::init(const std::string&, const Data&); +%ignore uscxml::DataModelImpl::assign(const Arabica::DOM::Element<std::string>&, const Arabica::DOM::Document<std::string>&, const std::string&); +%ignore uscxml::DataModelImpl::assign(const Arabica::DOM::Element<std::string>&, const Arabica::DOM::Node<std::string>&, const std::string&); +%ignore uscxml::DataModelImpl::assign(const std::string&, const Data&); +%ignore uscxml::DataModelImpl::eval(const Arabica::DOM::Element<std::string>&, const std::string&); +%ignore uscxml::DataModelImpl::evalAsBool(const Arabica::DOM::Node<std::string>&, const std::string&); %ignore uscxml::WrappedDataModel::create(InterpreterImpl*); %ignore uscxml::WrappedDataModel::init(const Arabica::DOM::Element<std::string>&, const Arabica::DOM::Document<std::string>&, const std::string&); @@ -30,18 +128,60 @@ %ignore uscxml::WrappedDataModel::eval(const Arabica::DOM::Element<std::string>&, const std::string&); %ignore uscxml::WrappedDataModel::evalAsBool(const Arabica::DOM::Node<std::string>&, const std::string&); + +// Executable Content + +%ignore uscxml::ExecutableContent::ExecutableContent(const boost::shared_ptr<ExecutableContentImpl>); +%ignore uscxml::ExecutableContent::ExecutableContent(const ExecutableContent&); +%ignore uscxml::ExecutableContent::setInterpreter(InterpreterImpl*); +%ignore uscxml::ExecutableContent::getInterpreter; +%ignore uscxml::ExecutableContent::enterElement(const Arabica::DOM::Node<std::string>&); +%ignore uscxml::ExecutableContent::exitElement(const Arabica::DOM::Node<std::string>&); + +%ignore uscxml::ExecutableContentImpl::create(InterpreterImpl*); +%ignore uscxml::ExecutableContentImpl::enterElement(const Arabica::DOM::Node<std::string>&); +%ignore uscxml::ExecutableContentImpl::exitElement(const Arabica::DOM::Node<std::string>&); +%ignore uscxml::ExecutableContentImpl::setInterpreter(InterpreterImpl*); +%ignore uscxml::ExecutableContentImpl::getInterpreter; + %ignore uscxml::WrappedExecutableContent::create(InterpreterImpl*); %ignore uscxml::WrappedExecutableContent::enterElement(const Arabica::DOM::Node<std::string>&); %ignore uscxml::WrappedExecutableContent::exitElement(const Arabica::DOM::Node<std::string>&); + +// IOProcessor + +%ignore uscxml::IOProcessorImpl::create(InterpreterImpl*); + +%ignore uscxml::IOProcessor::IOProcessor(const boost::shared_ptr<IOProcessorImpl>); +%ignore uscxml::IOProcessor::IOProcessor(const IOProcessor&); + %ignore uscxml::WrappedIOProcessor::create(InterpreterImpl*); + +// Factory + +%ignore uscxml::Factory::createDataModel; +%ignore uscxml::Factory::createIOProcessor; +%ignore uscxml::Factory::createInvoker; +%ignore uscxml::Factory::createExecutableContent; +%ignore uscxml::Factory::getIOProcessors; + +// Event + %ignore uscxml::Event::Event(const Arabica::DOM::Node<std::string>&); %ignore uscxml::Event::getStrippedDOM; %ignore uscxml::Event::getFirstDOMElement; +%ignore uscxml::Event::dom; %ignore uscxml::Event::getDOM(); %ignore uscxml::Event::setDOM(const Arabica::DOM::Document<std::string>&); %ignore uscxml::Event::toDocument(); +%ignore uscxml::Event::getParams(); + +// Data + +%ignore uscxml::Data::toDocument; +%ignore uscxml::Data::Data(const Arabica::DOM::Node<std::string>&); %ignore operator!=; %ignore operator<; diff --git a/src/bindings/swig/wrapped/WrappedDataModel.h b/src/bindings/swig/wrapped/WrappedDataModel.h index 026bed2..0d0630c 100644 --- a/src/bindings/swig/wrapped/WrappedDataModel.h +++ b/src/bindings/swig/wrapped/WrappedDataModel.h @@ -43,6 +43,10 @@ public: return std::list<std::string>(); }; + virtual std::string andExpressions(std::list<std::string>) { + return ""; + } + virtual bool validate(const std::string& location, const std::string& schema) { return true; } diff --git a/src/bindings/swig/wrapped/WrappedExecutableContent.h b/src/bindings/swig/wrapped/WrappedExecutableContent.h index 24c6978..fb09e54 100644 --- a/src/bindings/swig/wrapped/WrappedExecutableContent.h +++ b/src/bindings/swig/wrapped/WrappedExecutableContent.h @@ -39,11 +39,11 @@ public: _interpreter = interpreter->shared_from_this(); return boost::shared_ptr<ExecutableContentImpl>(create(_interpreter)); } - + virtual std::string getLocalName() { return ""; } - + virtual std::string getNamespace() { return "http://www.w3.org/2005/07/scxml"; } @@ -57,7 +57,7 @@ public: virtual void exitElement(const Arabica::DOM::Node<std::string>& node) { std::ostringstream ssElement; ssElement << node; - exitElement(ssElement.str()); + exitElement(ssElement.str()); } virtual bool processChildren() { @@ -65,15 +65,11 @@ public: } virtual void enterElement(const std::string& node) { - + } virtual void exitElement(const std::string& node) { - - } - void croak() throw(Event) { - } private: diff --git a/src/bindings/swig/wrapped/WrappedIOProcessor.h b/src/bindings/swig/wrapped/WrappedIOProcessor.h index 70c400e..716d9f4 100644 --- a/src/bindings/swig/wrapped/WrappedIOProcessor.h +++ b/src/bindings/swig/wrapped/WrappedIOProcessor.h @@ -47,11 +47,11 @@ public: Data data; return data; } - + virtual void send(const SendRequest& req) { - + } - + private: Interpreter _interpreter; }; diff --git a/src/bindings/swig/wrapped/WrappedInterpreterMonitor.cpp b/src/bindings/swig/wrapped/WrappedInterpreterMonitor.cpp new file mode 100644 index 0000000..1c99101 --- /dev/null +++ b/src/bindings/swig/wrapped/WrappedInterpreterMonitor.cpp @@ -0,0 +1,27 @@ +/** + * @file + * @author 2012-2014 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 "WrappedInterpreterMonitor.h" + +namespace uscxml { + +WrappedInterpreterMonitor::WrappedInterpreterMonitor() {} +WrappedInterpreterMonitor::~WrappedInterpreterMonitor() {} + +}
\ No newline at end of file diff --git a/src/bindings/swig/wrapped/WrappedInterpreterMonitor.h b/src/bindings/swig/wrapped/WrappedInterpreterMonitor.h new file mode 100644 index 0000000..57372ea --- /dev/null +++ b/src/bindings/swig/wrapped/WrappedInterpreterMonitor.h @@ -0,0 +1,218 @@ +/** + * @file + * @author 2012-2014 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 WRAPPEDINTERPRETERMONITOR_H_F5C83A0D +#define WRAPPEDINTERPRETERMONITOR_H_F5C83A0D + + +#include "../../../uscxml/Message.h" +#include "../../../uscxml/Factory.h" +#include "../../../uscxml/Interpreter.h" +#include "../../../uscxml/DOMUtils.h" + +namespace uscxml { + +class WrappedInterpreterMonitor : public InterpreterMonitor { +public: + WrappedInterpreterMonitor(); + virtual ~WrappedInterpreterMonitor(); + + virtual void beforeExitingState(Interpreter interpreter, + const Arabica::DOM::Element<std::string>& state, + bool moreComing) { + std::stringstream ss; + ss << state; + beforeExitingState(interpreter, state.getAttribute("id"), DOMUtils::xPathForNode(state), ss.str(), moreComing); + } + virtual void beforeExitingState(Interpreter interpreter, + const std::string& stateId, + const std::string& xpath, + const std::string& state, + bool moreComing) {} + + + virtual void afterExitingState(Interpreter interpreter, + const Arabica::DOM::Element<std::string>& state, + bool moreComing) { + std::stringstream ss; + ss << state; + afterExitingState(interpreter, state.getAttribute("id"), DOMUtils::xPathForNode(state), ss.str(), moreComing); + } + virtual void afterExitingState(Interpreter interpreter, + const std::string& stateId, + const std::string& xpath, + const std::string& state, + bool moreComing) { } + + + virtual void beforeExecutingContent(Interpreter interpreter, + const Arabica::DOM::Element<std::string>& element) { + std::stringstream ss; + ss << element; + beforeExecutingContent(interpreter, element.getTagName(), DOMUtils::xPathForNode(element), ss.str()); + } + virtual void beforeExecutingContent(Interpreter interpreter, + const std::string& tagName, + const std::string& xpath, + const std::string& element) {} + + + virtual void afterExecutingContent(Interpreter interpreter, + const Arabica::DOM::Element<std::string>& element) { + std::stringstream ss; + ss << element; + afterExecutingContent(interpreter, element.getTagName(), DOMUtils::xPathForNode(element), ss.str()); + } + virtual void afterExecutingContent(Interpreter interpreter, + const std::string& tagName, + const std::string& xpath, + const std::string& element) {} + + + virtual void beforeUninvoking(Interpreter interpreter, + const Arabica::DOM::Element<std::string>& invokeElem, + const std::string& invokeid) { + std::stringstream ss; + ss << invokeElem; + beforeUninvoking(interpreter, DOMUtils::xPathForNode(invokeElem), invokeid, ss.str()); + } + virtual void beforeUninvoking(Interpreter interpreter, + const std::string& xpath, + const std::string& invokeid, + const std::string& element) {} + + + virtual void afterUninvoking(Interpreter interpreter, + const Arabica::DOM::Element<std::string>& invokeElem, + const std::string& invokeid) { + std::stringstream ss; + ss << invokeElem; + afterUninvoking(interpreter, DOMUtils::xPathForNode(invokeElem), invokeid, ss.str()); + } + virtual void afterUninvoking(Interpreter interpreter, + const std::string& xpath, + const std::string& invokeid, + const std::string& element) {} + + + virtual void beforeTakingTransition(Interpreter interpreter, + const Arabica::DOM::Element<std::string>& transition, + bool moreComing) { + Arabica::DOM::Node<std::string> sourceState = interpreter.getImpl()->getSourceState(transition); + Arabica::XPath::NodeSet<std::string> targetStates = interpreter.getImpl()->getTargetStates(transition); + + std::stringstream ss; + ss << transition; + + std::list<std::string> targets; + for (int i = 0; i < targetStates.size(); i++) { + targets.push_back(ATTR(targetStates[i], "id")); + } + + beforeTakingTransition(interpreter, DOMUtils::xPathForNode(transition), ATTR(sourceState, "id"), targets, ss.str(), moreComing); + } + virtual void beforeTakingTransition(Interpreter interpreter, + const std::string& xpath, + const std::string& source, + const std::list<std::string>& targets, + const std::string& element, + bool moreComing) {} + + virtual void afterTakingTransition(Interpreter interpreter, + const Arabica::DOM::Element<std::string>& transition, + bool moreComing) { + Arabica::DOM::Node<std::string> sourceState = interpreter.getImpl()->getSourceState(transition); + Arabica::XPath::NodeSet<std::string> targetStates = interpreter.getImpl()->getTargetStates(transition); + + std::stringstream ss; + ss << transition; + + std::list<std::string> targets; + for (int i = 0; i < targetStates.size(); i++) { + targets.push_back(ATTR(targetStates[i], "id")); + } + + afterTakingTransition(interpreter, DOMUtils::xPathForNode(transition), ATTR(sourceState, "id"), targets, ss.str(), moreComing); + } + virtual void afterTakingTransition(Interpreter interpreter, + const std::string& xpath, + const std::string& source, + const std::list<std::string>& targets, + const std::string& element, + bool moreComing) {} + + + virtual void beforeEnteringState(Interpreter interpreter, + const Arabica::DOM::Element<std::string>& state, + bool moreComing) { + std::stringstream ss; + ss << state; + beforeEnteringState(interpreter, state.getAttribute("id"), DOMUtils::xPathForNode(state), ss.str(), moreComing); + } + virtual void beforeEnteringState(Interpreter interpreter, + const std::string& stateId, + const std::string& xpath, + const std::string& state, + bool moreComing) {} + + + virtual void afterEnteringState(Interpreter interpreter, + const Arabica::DOM::Element<std::string>& state, + bool moreComing) { + std::stringstream ss; + ss << state; + afterEnteringState(interpreter, state.getAttribute("id"), DOMUtils::xPathForNode(state), ss.str(), moreComing); + } + virtual void afterEnteringState(Interpreter interpreter, + const std::string& stateId, + const std::string& xpath, + const std::string& state, + bool moreComing) {} + + + virtual void beforeInvoking(Interpreter interpreter, + const Arabica::DOM::Element<std::string>& invokeElem, + const std::string& invokeid) { + std::stringstream ss; + ss << invokeElem; + beforeInvoking(interpreter, DOMUtils::xPathForNode(invokeElem), invokeid, ss.str()); + } + virtual void beforeInvoking(Interpreter interpreter, + const std::string& xpath, + const std::string& invokeid, + const std::string& element) {} + + virtual void afterInvoking(Interpreter interpreter, + const Arabica::DOM::Element<std::string>& invokeElem, + const std::string& invokeid) { + std::stringstream ss; + ss << invokeElem; + afterInvoking(interpreter, DOMUtils::xPathForNode(invokeElem), invokeid, ss.str()); + } + virtual void afterInvoking(Interpreter interpreter, + const std::string& xpath, + const std::string& invokeid, + const std::string& element) {} + +}; + +} + + +#endif /* end of include guard: WRAPPEDINTERPRETERMONITOR_H_F5C83A0D */ diff --git a/src/uscxml/Factory.h b/src/uscxml/Factory.h index a0569bb..ff08754 100644 --- a/src/uscxml/Factory.h +++ b/src/uscxml/Factory.h @@ -325,6 +325,7 @@ public: static void throwErrorPlatform(const std::string& cause); // we need it public for various static functions +protected: InterpreterImpl* _interpreter; }; @@ -460,6 +461,7 @@ public: static void setDefaultPluginPath(const std::string& path); static std::string getDefaultPluginPath(); +protected: std::map<std::string, DataModelImpl*> _dataModels; std::map<std::string, std::string> _dataModelAliases; std::map<std::string, IOProcessorImpl*> _ioProcessors; @@ -468,7 +470,6 @@ public: std::map<std::string, std::string> _invokerAliases; std::map<std::pair<std::string, std::string>, ExecutableContentImpl*> _executableContent; -protected: #ifdef BUILD_AS_PLUGINS pluma::Pluma pluma; #endif diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp index 9770387..f5aaf77 100644 --- a/src/uscxml/Interpreter.cpp +++ b/src/uscxml/Interpreter.cpp @@ -96,7 +96,7 @@ e.name = "error.platform"; \ e.data.compound["cause"] = Data(msg, Data::VERBATIM); \ throw e; \ - + /// macro to catch exceptions in executeContent #define CATCH_AND_DISTRIBUTE(msg) \ @@ -556,7 +556,7 @@ void InterpreterImpl::join() { bool InterpreterImpl::isRunning() { // return _running || !_topLevelFinalReached; - return _state.thread & InterpreterState::USCXML_THREAD_RUNNING; + return (_state.thread & InterpreterState::USCXML_THREAD_RUNNING) > 0; } void InterpreterImpl::run(void* instance) { |