diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-06-26 21:37:03 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-06-26 21:37:03 (GMT) |
commit | a4b506fd774ec50ad79b7531bd3698c5a6339407 (patch) | |
tree | 5e524b2c91e97f1037818e0262616f74e5e628a4 /embedding | |
parent | fe84b93d3e80d4b03e7a401582654c84d7fa7d9a (diff) | |
download | uscxml-a4b506fd774ec50ad79b7531bd3698c5a6339407.zip uscxml-a4b506fd774ec50ad79b7531bd3698c5a6339407.tar.gz uscxml-a4b506fd774ec50ad79b7531bd3698c5a6339407.tar.bz2 |
More work on language bindings and C# examples
Diffstat (limited to 'embedding')
12 files changed, 243 insertions, 20 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(); } |