diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-06-25 21:05:44 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-06-25 21:05:44 (GMT) |
commit | e3767be4f9c5874d9c996200f2e9705ce31a5976 (patch) | |
tree | be3d06f550286e23eeb3252277c1a2b7d12554ef | |
parent | 758bda908ded461c9d34d274a18454ffba4b7450 (diff) | |
download | uscxml-e3767be4f9c5874d9c996200f2e9705ce31a5976.zip uscxml-e3767be4f9c5874d9c996200f2e9705ce31a5976.tar.gz uscxml-e3767be4f9c5874d9c996200f2e9705ce31a5976.tar.bz2 |
Work on bindings
- Introduced exceptions into C# and Java
- Moved binding examples to /embedding
- Interpreter will now throw exceptions, beware!
61 files changed, 1008 insertions, 433 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b03821..90e5316 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,8 +13,8 @@ endif() # specify USCXML version SET(USCXML_VERSION_MAJOR "0") -SET(USCXML_VERSION_MINOR "1") -SET(USCXML_VERSION_PATCH "2") +SET(USCXML_VERSION_MINOR "2") +SET(USCXML_VERSION_PATCH "0") SET(USCXML_VERSION ${USCXML_VERSION_MAJOR}.${USCXML_VERSION_MINOR}.${USCXML_VERSION_PATCH}) # build type has to be set before the project definition4 diff --git a/contrib/java/.project b/contrib/java/.project deleted file mode 100644 index bed7874..0000000 --- a/contrib/java/.project +++ /dev/null @@ -1,39 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>uscxml</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> - <linkedResources> - <link> - <name>applications</name> - <type>2</type> - <location>/Users/sradomski/Documents/TK/Code/uscxml/test/samples/uscxml/applications</location> - </link> - <link> - <name>bindings</name> - <type>2</type> - <location>/Users/sradomski/Documents/TK/Code/uscxml/src/bindings/swig/java</location> - </link> - <link> - <name>java</name> - <type>2</type> - <location>/Users/sradomski/Documents/TK/Code/uscxml/src/bindings/swig/java</location> - </link> - <link> - <name>uscxml</name> - <type>2</type> - <location>/Users/sradomski/Documents/TK/Code/uscxml/build/cli/src/bindings/swig/java</location> - </link> - </linkedResources> -</projectDescription> diff --git a/contrib/java/build-java.xml b/contrib/java/build-java.xml new file mode 100644 index 0000000..ca5cc88 --- /dev/null +++ b/contrib/java/build-java.xml @@ -0,0 +1,91 @@ +<!-- This ant build script is called from CMake at configure time --> +<project name="uscxml" default="jar"> + +<!-- taskdef resource="net/sf/antcontrib/antcontrib.properties"> + <classpath> + <pathelement location="lib/ant-contrib-1.0b3.jar"/> + </classpath> +</taskdef --> + +<target name="compile" description="Compile the uscxml java code."> + <echo message="dest: ${build.dir}/src/bindings/swig/java-class/"/> + <echo message="src: ${build.dir}/src/bindings/swig/java/"/> + <echo message="src: ${src.dir}/src/bindings/swig/java/"/> + + <mkdir dir="${build.dir}/src/bindings/swig/java-class/" /> + + <javac destdir="${build.dir}/src/bindings/swig/java-class/" debug="true" includeantruntime="false" target="1.5" source="1.5"> + <src path="${build.dir}/src/bindings/swig/java/" /> + <src path="${src.dir}/src/bindings/swig/java/" /> + <!--classpath> + <pathelement location="${src.dir}/contrib/java/lib/protobuf-java-2.5.0.jar"/> + </classpath --> + </javac> +</target> + +<target name="jar" depends="compile" description="Create a bundle of the source code"> + <echo message="library dir: ${lib.dir}"/> + <echo message="source dir: ${src.dir}"/> + <echo message="build dir: ${build.dir}"/> + <echo message="build type: ${build.type}"/> + <echo message="exclude debug: ${exclude.debug}"/> + <echo message="exclude jni: ${exclude.jni}"/> + + <condition property="exclude.debug.jar"> + <equals arg1="${exclude.debug}" arg2="ON"/> + </condition> + + <condition property="exclude.jni.jar"> + <equals arg1="${exclude.jni}" arg2="ON"/> + </condition> + + <!-- flatten all JNI libraries for inclusion into the fat JAR --> + <fileset id="all.jni" dir="${lib.dir}"> + <include name="**/*NativeJava*.jnilib"/> + <include name="**/*NativeJava*.so"/> + <include name="**/*NativeJava*.dll"/> + <exclude name="cross-compiled/**"/> + <exclude name="linux-armv*/**"/> + <!-- do not include debug builds in release --> + <!--exclude name="**/*undocoreSwigSwig_d*" if="${exclude.debug.jar}"/ --> + <!--exclude name="**/*undocoreSwig64_d*" if="${exclude.debug.jar}"/ --> + </fileset> + + <!-- Copy all JNI libraries as found above into the lib/ directory --> + <mkdir dir="${lib.dir}/jni" /> + <copy todir="${lib.dir}/jni" flatten="true"> + <fileset refid="all.jni" /> + </copy> + + <pathconvert pathsep="${line.separator}| |-- " + property="echo.all.jni" + refid="all.jni"> + </pathconvert> + <echo>${echo.all.jni}</echo> + + <!-- delete an eventual old jar --> + <delete dir="${lib.dir}/uscxml.jar" /> + + <!-- build new jar --> + <jar destfile="${lib.dir}/uscxml.jar"> + <!-- All the class files we compiled --> + <fileset dir="${build.dir}/src/bindings/swig/java-class/" > + <include name="**/*.class" /> + </fileset> + <!-- Include all source files --> + <fileset dir="${build.dir}/src/bindings/swig/java/" > + <include name="**/*.java" /> + </fileset> + <fileset dir="${src.dir}/src/bindings/swig/java/" > + <include name="**/*.java" /> + </fileset> + <!-- The JNI libraries --> + <fileset dir="${lib.dir}/jni" > + <include name="**/*" /> + <exclude name="**/*" if="${exclude.jni.jar}" /> + </fileset> + </jar> + <delete dir="${lib.dir}/jni" /> +</target> + +</project> diff --git a/contrib/local/compress_and_upload_deps.sh b/contrib/local/compress_and_upload_deps.sh index 4abb4a9..76413de 100755 --- a/contrib/local/compress_and_upload_deps.sh +++ b/contrib/local/compress_and_upload_deps.sh @@ -33,7 +33,7 @@ ssh ${USCXML_PREBUILT_HOST} mkdir -p ${USCXML_PREBUILT_PATH}/${VERSION} PLATFORMS=`find . -maxdepth 1 -type d -regex ./[^\.].*` #PLATFORMS="linux-x86_64" #PLATFORMS="darwin-i386" -PLATFORMS="windows-x86" +#PLATFORMS="windows-x86" for FILE in ${PLATFORMS}; do PLATFORM=`basename $FILE` echo $FILE diff --git a/contrib/csharp/embedding/embedding.sln b/embedding/csharp/embedding/embedding.sln index 0f9a49e..0f9a49e 100644 --- a/contrib/csharp/embedding/embedding.sln +++ b/embedding/csharp/embedding/embedding.sln diff --git a/contrib/csharp/embedding/embedding.suo b/embedding/csharp/embedding/embedding.suo Binary files differindex f011087..f011087 100644 --- a/contrib/csharp/embedding/embedding.suo +++ b/embedding/csharp/embedding/embedding.suo diff --git a/contrib/csharp/embedding/embedding.userprefs b/embedding/csharp/embedding/embedding.userprefs index 05e379d..681be08 100644 --- a/contrib/csharp/embedding/embedding.userprefs +++ b/embedding/csharp/embedding/embedding.userprefs @@ -2,7 +2,7 @@ <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|x86" /> <MonoDevelop.Ide.Workbench ActiveDocument="embedding/Program.cs"> <Files> - <File FileName="embedding/Program.cs" Line="31" Column="1" /> + <File FileName="embedding/Program.cs" Line="16" Column="40" /> </Files> </MonoDevelop.Ide.Workbench> <MonoDevelop.Ide.DebuggingService.Breakpoints> diff --git a/contrib/csharp/embedding/embedding/Program.cs b/embedding/csharp/embedding/embedding/Program.cs index 3899178..3899178 100644 --- a/contrib/csharp/embedding/embedding/Program.cs +++ b/embedding/csharp/embedding/embedding/Program.cs diff --git a/contrib/csharp/embedding/embedding/Properties/AssemblyInfo.cs b/embedding/csharp/embedding/embedding/Properties/AssemblyInfo.cs index bd9015e..bd9015e 100644 --- a/contrib/csharp/embedding/embedding/Properties/AssemblyInfo.cs +++ b/embedding/csharp/embedding/embedding/Properties/AssemblyInfo.cs diff --git a/contrib/csharp/embedding/embedding/embedding.csproj b/embedding/csharp/embedding/embedding/embedding.csproj index 53e1eed..53e1eed 100644 --- a/contrib/csharp/embedding/embedding/embedding.csproj +++ b/embedding/csharp/embedding/embedding/embedding.csproj diff --git a/contrib/java/.classpath b/embedding/java/.classpath index 0830f8a..fa94b3c 100644 --- a/contrib/java/.classpath +++ b/embedding/java/.classpath @@ -1,10 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/> - <classpathentry kind="src" path="java"/> - <classpathentry kind="src" path="uscxml"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/umundo"/> - <classpathentry kind="lib" path="/Users/sradomski/Documents/TK/Code/rhino1_7R4/build/rhino1_7R4/js.jar" sourcepath="/Users/sradomski/Documents/TK/Code/rhino1_7R4/src"/> + <classpathentry kind="lib" path="lib/js.jar"/> + <classpathentry kind="lib" path="/Users/sradomski/Documents/TK/Code/uscxml/build/cli/lib/uscxml.jar"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/embedding/java/.gitignore b/embedding/java/.gitignore new file mode 100644 index 0000000..5e56e04 --- /dev/null +++ b/embedding/java/.gitignore @@ -0,0 +1 @@ +/bin diff --git a/embedding/java/.project b/embedding/java/.project new file mode 100644 index 0000000..9aecdf8 --- /dev/null +++ b/embedding/java/.project @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>uscxml</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/contrib/java/src/js.jar b/embedding/java/lib/js.jar Binary files differindex 6f0dafb..6f0dafb 100644 --- a/contrib/java/src/js.jar +++ b/embedding/java/lib/js.jar diff --git a/contrib/java/src/org/uscxml/datamodel/ecmascript/ECMAData.java b/embedding/java/src/org/uscxml/datamodel/ecmascript/ECMAData.java index 56d7090..56d7090 100644 --- a/contrib/java/src/org/uscxml/datamodel/ecmascript/ECMAData.java +++ b/embedding/java/src/org/uscxml/datamodel/ecmascript/ECMAData.java diff --git a/contrib/java/src/org/uscxml/datamodel/ecmascript/ECMAEvent.java b/embedding/java/src/org/uscxml/datamodel/ecmascript/ECMAEvent.java index 58fff72..58fff72 100644 --- a/contrib/java/src/org/uscxml/datamodel/ecmascript/ECMAEvent.java +++ b/embedding/java/src/org/uscxml/datamodel/ecmascript/ECMAEvent.java diff --git a/contrib/java/src/org/uscxml/datamodel/ecmascript/ECMAScriptDataModel.java b/embedding/java/src/org/uscxml/datamodel/ecmascript/ECMAScriptDataModel.java index 3d77dc5..dcafcb9 100644 --- a/contrib/java/src/org/uscxml/datamodel/ecmascript/ECMAScriptDataModel.java +++ b/embedding/java/src/org/uscxml/datamodel/ecmascript/ECMAScriptDataModel.java @@ -14,11 +14,11 @@ import org.uscxml.Data; import org.uscxml.DataNative; import org.uscxml.Event; import org.uscxml.Interpreter; -import org.uscxml.JavaDataModel; -import org.uscxml.StringSet; +import org.uscxml.StringList; import org.uscxml.StringVector; +import org.uscxml.WrappedDataModel; -public class ECMAScriptDataModel extends JavaDataModel { +public class ECMAScriptDataModel extends WrappedDataModel { public static boolean debug = true; @@ -77,7 +77,7 @@ public class ECMAScriptDataModel extends JavaDataModel { } @Override - public JavaDataModel create(Interpreter interpreter) { + public WrappedDataModel create(Interpreter interpreter) { /** * Called when an SCXML interpreter wants an instance of this datamodel * Be careful to instantiate attributes of instance returned and not @@ -142,13 +142,13 @@ public class ECMAScriptDataModel extends JavaDataModel { } @Override - public StringSet getNames() { + public StringList getNames() { /** * Register with the following names for the datamodel attribute at the * scxml element. <scxml datamodel="one of these"> */ - StringSet ss = new StringSet(); - ss.insert("ecmascript"); + StringList ss = new StringList(); + ss.add("ecmascript"); return ss; } diff --git a/contrib/java/src/org/uscxml/tests/TestData.java b/embedding/java/src/org/uscxml/tests/TestData.java index 44f1ce0..44f1ce0 100644 --- a/contrib/java/src/org/uscxml/tests/TestData.java +++ b/embedding/java/src/org/uscxml/tests/TestData.java diff --git a/contrib/java/src/org/uscxml/tests/TestJavaScriptDataModel.java b/embedding/java/src/org/uscxml/tests/datamodel/TestJavaScriptDataModel.java index 7399c94..7cfa793 100644 --- a/contrib/java/src/org/uscxml/tests/TestJavaScriptDataModel.java +++ b/embedding/java/src/org/uscxml/tests/datamodel/TestJavaScriptDataModel.java @@ -1,12 +1,13 @@ -package org.uscxml.tests; +package org.uscxml.tests.datamodel; import org.uscxml.Factory; import org.uscxml.Interpreter; +import org.uscxml.InterpreterException; import org.uscxml.datamodel.ecmascript.ECMAScriptDataModel; public class TestJavaScriptDataModel { - public static void main(String[] args) { + public static void main(String[] args) throws InterpreterException { // load JNI library from build directory System.load("/Users/sradomski/Documents/TK/Code/uscxml/build/cli/lib/libuscxmlNativeJava64.jnilib"); diff --git a/contrib/java/src/org/uscxml/tests/TestW3CECMA.java b/embedding/java/src/org/uscxml/tests/datamodel/TestW3CECMA.java index 0949701..c525fd1 100644 --- a/contrib/java/src/org/uscxml/tests/TestW3CECMA.java +++ b/embedding/java/src/org/uscxml/tests/datamodel/TestW3CECMA.java @@ -1,10 +1,11 @@ -package org.uscxml.tests; +package org.uscxml.tests.datamodel; import java.io.File; import org.uscxml.Capabilities; import org.uscxml.Factory; import org.uscxml.Interpreter; +import org.uscxml.InterpreterException; import org.uscxml.InterpreterOptions; import org.uscxml.datamodel.ecmascript.ECMAScriptDataModel; @@ -12,7 +13,7 @@ public class TestW3CECMA { public static String testDir = "/Users/sradomski/Documents/TK/Code/uscxml/test/w3c/ecma"; - public static void main(String[] args) { + public static void main(String[] args) throws InterpreterException { System.load("/Users/sradomski/Documents/TK/Code/uscxml/build/cli/lib/libuscxmlNativeJava64.jnilib"); ECMAScriptDataModel datamodel = new ECMAScriptDataModel(); diff --git a/embedding/java/src/org/uscxml/tests/execContent/TestCustomExecContent.java b/embedding/java/src/org/uscxml/tests/execContent/TestCustomExecContent.java new file mode 100644 index 0000000..dd5e39a --- /dev/null +++ b/embedding/java/src/org/uscxml/tests/execContent/TestCustomExecContent.java @@ -0,0 +1,81 @@ +package org.uscxml.tests.execContent; + +import org.uscxml.Data; +import org.uscxml.Event; +import org.uscxml.Factory; +import org.uscxml.Interpreter; +import org.uscxml.InterpreterException; +import org.uscxml.WrappedExecutableContent; + +public class TestCustomExecContent extends WrappedExecutableContent { + + static int instanceId = 0; + public int id = 0; + + public TestCustomExecContent() { + id = instanceId++; + } + + @Override + public String getLocalName() { + return "custom"; + } + + @Override + public String getNamespace() { + return "http://www.w3.org/2005/07/scxml"; + } + + + @Override + public void enterElement(String node) { + System.out.println(id + " entering:" + node); + } + + @Override + public void exitElement(String node) { + System.out.println(id + " exiting:" + node); + } + + @Override + public boolean processChildren() { + return false; + } + + @Override + public WrappedExecutableContent create(Interpreter interpreter) { + return new TestCustomExecContent(); + } + + /** + * @param args + * @throws InterruptedException + * @throws InterpreterException + */ + public static void main(String[] args) throws InterruptedException, InterpreterException { + System.load("/Users/sradomski/Documents/TK/Code/uscxml/build/cli/lib/libuscxmlNativeJava64.jnilib"); + + TestCustomExecContent execContent = new TestCustomExecContent(); + Factory.getInstance().registerExecutableContent(execContent); + + Interpreter interpreter = Interpreter.fromXML( + "<scxml>\n" + + " <state id=\"s0\">\n" + + " <onentry>\n" + + " <custom foo=\"bar\">\n" + + " <something></something>\n" + + " </custom>\n" + + " <custom foo=\"bar\">\n" + + " <something></something>\n" + + " </custom>\n" + + " </onentry>\n" + + " <transition target=\"exit\" />" + + " </state>\n" + + " <final id=\"exit\" />" + + "</scxml>\n" + ); + interpreter.interpret(); + Thread.sleep(1000); + } + +} diff --git a/contrib/java/src/org/uscxml/tests/TestInvoker.java b/embedding/java/src/org/uscxml/tests/invoker/TestCustomInvoker.java index 7807cda..9343c65 100644 --- a/contrib/java/src/org/uscxml/tests/TestInvoker.java +++ b/embedding/java/src/org/uscxml/tests/invoker/TestCustomInvoker.java @@ -1,21 +1,23 @@ -package org.uscxml.tests; +package org.uscxml.tests.invoker; import org.uscxml.Data; import org.uscxml.DataNative; import org.uscxml.Event; import org.uscxml.Factory; import org.uscxml.Interpreter; +import org.uscxml.InterpreterException; import org.uscxml.InvokeRequest; -import org.uscxml.JavaInvoker; +import org.uscxml.StringList; +import org.uscxml.WrappedInvoker; import org.uscxml.SendRequest; import org.uscxml.StringSet; -public class TestInvoker extends JavaInvoker { +public class TestCustomInvoker extends WrappedInvoker { @Override - public StringSet getNames() { - StringSet ss = new StringSet(); - ss.insert("java"); + public StringList getNames() { + StringList ss = new StringList(); + ss.add("java"); return ss; } @@ -44,17 +46,18 @@ public class TestInvoker extends JavaInvoker { } @Override - public JavaInvoker create(Interpreter interpreter) { - return new TestInvoker(); + public WrappedInvoker create(Interpreter interpreter) { + return new TestCustomInvoker(); } /** * @param args + * @throws InterpreterException */ - public static void main(String[] args) { + public static void main(String[] args) throws InterpreterException { System.load("/Users/sradomski/Documents/TK/Code/uscxml/build/cli/lib/libuscxmlNativeJava64_d.jnilib"); - TestInvoker invoker = new TestInvoker(); + TestCustomInvoker invoker = new TestCustomInvoker(); Factory.getInstance().registerInvoker(invoker); Interpreter interpreter = Interpreter diff --git a/embedding/java/src/org/uscxml/tests/ioprocessor/TestCustomIOProc.java b/embedding/java/src/org/uscxml/tests/ioprocessor/TestCustomIOProc.java new file mode 100644 index 0000000..37b31a3 --- /dev/null +++ b/embedding/java/src/org/uscxml/tests/ioprocessor/TestCustomIOProc.java @@ -0,0 +1,54 @@ +package org.uscxml.tests.ioprocessor; + +import org.uscxml.Data; +import org.uscxml.DataNative; +import org.uscxml.Factory; +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 { + + @Override + public StringList getNames() { + StringList ss = new StringList(); + ss.add("java"); + return ss; + } + + @Override + public DataNative getDataModelVariables() { + Data data = new Data(); + data.array.add(new Data("foo", Data.Type.VERBATIM)); + return Data.toNative(data); + } + + @Override + public void send(SendRequest req) { + System.out.println("send"); + } + + @Override + public WrappedIOProcessor create(Interpreter interpreter) { + return new TestCustomIOProc(); + } + + /** + * @param args + * @throws InterpreterException + */ + public static void main(String[] args) throws InterpreterException { + System.load("/Users/sradomski/Documents/TK/Code/uscxml/build/cli/lib/libuscxmlNativeJava64_d.jnilib"); + + TestCustomIOProc ioproc = new TestCustomIOProc(); + Factory.getInstance().registerIOProcessor(ioproc); + + 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/CMakeLists.txt b/src/bindings/swig/csharp/CMakeLists.txt index 6310778..80d093e 100644 --- a/src/bindings/swig/csharp/CMakeLists.txt +++ b/src/bindings/swig/csharp/CMakeLists.txt @@ -59,6 +59,8 @@ if (DMCS_EXECUTABLE OR CSC_EXECUTABLE) # build managed code part if (CSC_EXECUTABLE) ADD_CUSTOM_TARGET(csharp + COMMAND ${CMAKE_COMMAND} -E + copy ${CMAKE_CURRENT_SOURCE_DIR}/org/uscxml/InterpreterException.cs ${PROJECT_BINARY_DIR}/src/bindings/swig/csharp/org/uscxml COMMAND ${CSC_EXECUTABLE} /target:library /out:${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/uscxmlCSharp.dll @@ -67,6 +69,8 @@ if (DMCS_EXECUTABLE OR CSC_EXECUTABLE) COMMENT "Creating umundoCSharp.dll for C# ...") else() ADD_CUSTOM_TARGET(csharp + COMMAND ${CMAKE_COMMAND} -E + copy ${CMAKE_CURRENT_SOURCE_DIR}/org/uscxml/InterpreterException.cs ${PROJECT_BINARY_DIR}/src/bindings/swig/csharp/org/uscxml COMMAND ${DMCS_EXECUTABLE} -target:library /out:${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/uscxmlCSharp.dll diff --git a/src/bindings/swig/csharp/org/uscxml/InterpreterException.cs b/src/bindings/swig/csharp/org/uscxml/InterpreterException.cs new file mode 100644 index 0000000..f86dc0e --- /dev/null +++ b/src/bindings/swig/csharp/org/uscxml/InterpreterException.cs @@ -0,0 +1,7 @@ +namespace org.uscxml { + class InterpreterException : System.ApplicationException { + public InterpreterException(string message) + : base(message) { + } + } +}
\ No newline at end of file diff --git a/src/bindings/swig/csharp/stl_list.i b/src/bindings/swig/csharp/stl_list.i deleted file mode 100644 index aabd448..0000000 --- a/src/bindings/swig/csharp/stl_list.i +++ /dev/null @@ -1,49 +0,0 @@ -/* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * - * std_list.i - * ----------------------------------------------------------------------------- */ - -%include <std_common.i> - -%{ -#include <list> -#include <stdexcept> -%} - -namespace std { - - template<class T> class list { - public: - typedef size_t size_type; - typedef T value_type; - typedef const value_type& const_reference; - list(); - size_type size() const; - %rename(isEmpty) empty; - bool empty() const; - void clear(); - %rename(add) push_back; - void push_back(const value_type& x); - %extend { - const_reference get(int i) throw (std::out_of_range) { - int size = int(self->size()); - int j; - if (i>=0 && i<size) { - std::list<T>::const_iterator p; - p=self->begin(); - for (j=0; j<i; j++) {p++;} - return (*p); - } - else - throw std::out_of_range("list index out of range"); - } - } - }; -} - -%define specialize_std_list(T) -#warning "specialize_std_list - specialization for type T no longer needed" -%enddef - diff --git a/src/bindings/swig/csharp/stl_set.i b/src/bindings/swig/csharp/stl_set.i deleted file mode 100644 index d009a7b..0000000 --- a/src/bindings/swig/csharp/stl_set.i +++ /dev/null @@ -1,73 +0,0 @@ -/*========================================================================= - - Program: GDCM (Grassroots DICOM). A DICOM library - - Copyright (c) 2006-2011 Mathieu Malaterre - All rights reserved. - See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ -/* ----------------------------------------------------------------------------- - * std_set.i - * - * SWIG typemaps for std::set - * ----------------------------------------------------------------------------- */ - -%include <std_common.i> - -// ------------------------------------------------------------------------ -// std::set -// ------------------------------------------------------------------------ - -%{ -#include <set> -#include <algorithm> -#include <stdexcept> -%} - -// exported class - -namespace std { - - template<class V> class set { - // add typemaps here - public: - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef V value_type; - set(); - set(const set<V> &); - - unsigned int size() const; - bool empty() const; - void clear(); - %extend { - const V& get(const V& key) throw (std::out_of_range) { - std::set<V>::iterator i = self->find(key); - if (i != self->end()) - return *i; - else - throw std::out_of_range("key not found"); - } - void insert(const V& key) { // Do NOT call this function 'set' ! - self->insert(key); - } - void del(const V& key) throw (std::out_of_range) { - std::set<V>::iterator i = self->find(key); - if (i != self->end()) - self->erase(i); - else - throw std::out_of_range("key not found"); - } - bool has_key(const V& key) { - std::set<V>::iterator i = self->find(key); - return i != self->end(); - } - } - }; - -}
\ No newline at end of file diff --git a/src/bindings/swig/csharp/uscxml.i b/src/bindings/swig/csharp/uscxml.i index 07604c4..e7b7d62 100644 --- a/src/bindings/swig/csharp/uscxml.i +++ b/src/bindings/swig/csharp/uscxml.i @@ -20,9 +20,15 @@ typedef uscxml::Event Event; typedef uscxml::InvokeRequest InvokeRequest; typedef uscxml::SendRequest SendRequest; +%feature("director") uscxml::WrappedInvoker; +%feature("director") uscxml::WrappedDataModel; +%feature("director") uscxml::WrappedIOProcessor; +%feature("director") uscxml::WrappedExecutableContent; + // disable warning related to unknown base class #pragma SWIG nowarn=401 -//%ignore boost::enable_shared_from_this; +// do not warn when we override symbols via extend +#pragma SWIG nowarn=302 %csconst(1); @@ -31,14 +37,6 @@ typedef uscxml::SendRequest SendRequest; %rename(equals) operator==; %rename(isValid) operator bool; -%ignore operator!=; -%ignore operator<; -%ignore operator=; -%ignore operator[]; -%ignore operator std::list<Data>; -%ignore operator std::string; -%ignore operator std::map<std::string,Data>; -%ignore operator<<; //************************************************** @@ -49,6 +47,7 @@ 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> @@ -59,104 +58,89 @@ typedef uscxml::SendRequest SendRequest; #include "../wrapped/WrappedInvoker.h" #include "../wrapped/WrappedDataModel.h" +#include "../wrapped/WrappedExecutableContent.h" +#include "../wrapped/WrappedIOProcessor.h" using namespace uscxml; using namespace Arabica::DOM; #include "../wrapped/WrappedInvoker.cpp" #include "../wrapped/WrappedDataModel.cpp" +#include "../wrapped/WrappedExecutableContent.cpp" +#include "../wrapped/WrappedIOProcessor.cpp" %} -%ignore uscxml::NumAttr; -%ignore uscxml::SCXMLParser; -%ignore uscxml::InterpreterImpl; +// see http://binf.gmu.edu/software/SWIG/CSharp.html#csharp_exceptions +%insert(runtime) %{ + // Code to handle throwing of C# CustomApplicationException from C/C++ code. + // The equivalent delegate to the callback, CSharpExceptionCallback_t, is CustomExceptionDelegate + // and the equivalent customExceptionCallback instance is customDelegate + typedef void (SWIGSTDCALL* CSharpExceptionCallback_t)(const char *); + CSharpExceptionCallback_t customExceptionCallback = NULL; + + extern "C" SWIGEXPORT + void SWIGSTDCALL CustomExceptionRegisterCallback(CSharpExceptionCallback_t customCallback) { + customExceptionCallback = customCallback; + } + + // Note that SWIG detects any method calls named starting with + // SWIG_CSharpSetPendingException for warning 845 + static void SWIG_CSharpSetPendingExceptionCustom(const char *msg) { + customExceptionCallback(msg); + } +%} -%ignore create(); +%pragma(csharp) imclasscode=%{ + class CustomExceptionHelper { + // C# delegate for the C/C++ customExceptionCallback + public delegate void CustomExceptionDelegate(string message); + static CustomExceptionDelegate customDelegate = + new CustomExceptionDelegate(SetPendingCustomException); + + [System.Runtime.InteropServices.DllImport("$dllimport", EntryPoint="CustomExceptionRegisterCallback")] + public static extern + void CustomExceptionRegisterCallback(CustomExceptionDelegate customCallback); + + static void SetPendingCustomException(string message) { + SWIGPendingException.Set(new org.uscxml.InterpreterException(message)); + } + + static CustomExceptionHelper() { + CustomExceptionRegisterCallback(customDelegate); + } + } + static CustomExceptionHelper exceptionHelper = new CustomExceptionHelper(); +%} -%ignore uscxml::Interpreter::getDelayQueue(); -%ignore uscxml::WrappedInvoker::create(InterpreterImpl*); +%define WRAP_THROW_EXCEPTION( MATCH ) +%exception MATCH %{ +try { + $action +} catch (uscxml::Event& e) { + std::stringstream ss; + ss << std::endl << e; + SWIG_CSharpSetPendingExceptionCustom(ss.str().c_str()); +} +%} +%enddef -%ignore uscxml::WrappedDataModel::create(InterpreterImpl*); -%ignore uscxml::WrappedDataModel::init(const Arabica::DOM::Element<std::string>&, const Arabica::DOM::Document<std::string>&, const std::string&); -%ignore uscxml::WrappedDataModel::init(const std::string&, const Data&); -%ignore uscxml::WrappedDataModel::assign(const Arabica::DOM::Element<std::string>&, const Arabica::DOM::Document<std::string>&, const std::string&); -%ignore uscxml::WrappedDataModel::assign(const std::string&, const Data&); -%ignore uscxml::WrappedDataModel::eval(const Arabica::DOM::Element<std::string>&, const std::string&); +WRAP_THROW_EXCEPTION(uscxml::Interpreter::fromXML); +WRAP_THROW_EXCEPTION(uscxml::Interpreter::fromURI); +WRAP_THROW_EXCEPTION(uscxml::Interpreter::step); +WRAP_THROW_EXCEPTION(uscxml::Interpreter::interpret); -%ignore uscxml::Event::Event(const Arabica::DOM::Node<std::string>&); -%ignore uscxml::Event::getStrippedDOM; -%ignore uscxml::Event::getFirstDOMElement; -%ignore uscxml::Event::getDOM(); -%ignore uscxml::Event::setDOM(const Arabica::DOM::Document<std::string>&); -%ignore uscxml::Event::toDocument(); -%template(DataList) std::list<uscxml::Data>; -%template(DataMap) std::map<std::string, uscxml::Data>; -%template(StringSet) std::set<std::string>; -%template(StringVector) std::vector<std::string>; -%template(ParamPair) std::pair<std::string, uscxml::Data>; -%template(ParamPairVector) std::vector<std::pair<std::string, uscxml::Data> >; -%template(IOProcMap) std::map<std::string, uscxml::IOProcessor>; -%template(InvokerMap) std::map<std::string, uscxml::Invoker>; +%include "../uscxml_ignores.i" %rename Data DataNative; -%feature("director") uscxml::WrappedInvoker; -%feature("director") uscxml::WrappedDataModel; - // translate param multimap to Map<String, List<Data> > %rename(getParamsNative) uscxml::Event::getParams(); %csmethodmodifiers uscxml::Event::getParams() "private"; -%extend uscxml::Event { - std::vector<std::pair<std::string, 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; - } -}; - -%extend uscxml::Interpreter { - std::vector<std::string> getIOProcessorKeys() { - std::vector<std::string> keys; - std::map<std::string, IOProcessor>::const_iterator iter = self->getIOProcessors().begin(); - while(iter != self->getIOProcessors().end()) { - keys.push_back(iter->first); - iter++; - } - return keys; - } - - std::vector<std::string> getInvokerKeys() { - std::vector<std::string> keys; - std::map<std::string, Invoker>::const_iterator iter = self->getInvokers().begin(); - while(iter != self->getInvokers().end()) { - keys.push_back(iter->first); - iter++; - } - return keys; - } - -}; - -%extend uscxml::Data { - std::vector<std::string> getCompundKeys() { - std::vector<std::string> keys; - std::map<std::string, Data>::const_iterator iter = self->compound.begin(); - while(iter != self->compound.end()) { - keys.push_back(iter->first); - iter++; - } - return keys; - } -}; - +%include "../uscxml_beautify.i" //*********************************************** @@ -167,19 +151,21 @@ using namespace Arabica::DOM; %include "../../../uscxml/Factory.h" %include "../../../uscxml/Message.h" %include "../../../uscxml/Interpreter.h" -#include "../../../uscxml/DOMUtils.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" + -# %template(XMLDocument) Arabica::DOM::Document<std::string>; -# %template(XMLNode) Arabica::DOM::Node<std::string>; -# %template(XMLElement) Arabica::DOM::Element<std::string>; -# %template(XMLAttr) Arabica::DOM::Attr<std::string>; -# %template(XMLText) Arabica::DOM::Text<std::string>; +%template(DataList) std::list<uscxml::Data>; +%template(DataMap) std::map<std::string, uscxml::Data>; +%template(StringSet) std::set<std::string>; +%template(StringVector) std::vector<std::string>; +%template(StringList) std::list<std::string>; +%template(ParamPair) std::pair<std::string, uscxml::Data>; +%template(ParamPairVector) std::vector<std::pair<std::string, uscxml::Data> >; +%template(IOProcMap) std::map<std::string, uscxml::IOProcessor>; +%template(InvokerMap) std::map<std::string, uscxml::Invoker>; +%template(ParentQueue) uscxml::concurrency::BlockingQueue<uscxml::SendRequest>; diff --git a/src/bindings/swig/java/CMakeLists.txt b/src/bindings/swig/java/CMakeLists.txt index 51d67bb..3a7e9e0 100644 --- a/src/bindings/swig/java/CMakeLists.txt +++ b/src/bindings/swig/java/CMakeLists.txt @@ -33,3 +33,42 @@ set_target_properties(uscxmlNativeJava PROPERTIES COMPILE_FLAGS "-DSWIG") swig_link_libraries(uscxmlNativeJava uscxml) set(USCXML_LANGUAGE_BINDINGS ${USCXML_LANGUAGE_BINDINGS} PARENT_SCOPE) + +FIND_PROGRAM(ANT_EXECUTABLE ant PATHS $ENV{ANT_HOME}/bin ENV PATH ) +if (ANT_EXECUTABLE) + set(JAR_EXCLUDE_DEBUG OFF) + set(JAR_EXCLUDE_JNI OFF) + + # include all the JNI libraries prepared from DIST_PREPARE builds on the various desktop platforms + if (DIST_PREPARE) + if (CMAKE_CROSSCOMPILING) + if (ANDROID) + find_program(PROTOBUF_PROTOC_EXECUTABLE NAMES protoc protoc.exe) + set(JAR_EXCLUDE_JNI ON) # JNI inside jar not allowed with Android + SET(JAR_JNI_ROOT_PATH ${PROJECT_SOURCE_DIR}/package/cross-compiled/android) + else() + SET(JAR_JNI_ROOT_PATH ${PROJECT_SOURCE_DIR}/package/cross-compiled/${CMAKE_CROSSCOMPILING_TARGET_LC}) + endif() + else() + SET(JAR_JNI_ROOT_PATH ${PROJECT_SOURCE_DIR}/package) + endif() + else() + # when not preparing a distribution, just put the jar into the libs + SET(JAR_JNI_ROOT_PATH ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) + endif() + + ADD_CUSTOM_TARGET(java + COMMAND ${ANT_EXECUTABLE} + -Dlib.dir=${JAR_JNI_ROOT_PATH} + -Dsrc.dir=${PROJECT_SOURCE_DIR} + -Dbuild.dir=${PROJECT_BINARY_DIR} + -Dbuild.type=${CMAKE_BUILD_TYPE} + -Dexclude.debug=${JAR_EXCLUDE_DEBUG} + -Dexclude.jni=${JAR_EXCLUDE_JNI} + -f build-java.xml + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/contrib/java + COMMENT "Creating the jar ...") + +else() + message(STATUS "Could not find ant binary - will not build jars") +endif()
\ No newline at end of file diff --git a/src/bindings/swig/java/org/uscxml/InterpreterException.java b/src/bindings/swig/java/org/uscxml/InterpreterException.java new file mode 100644 index 0000000..b089566 --- /dev/null +++ b/src/bindings/swig/java/org/uscxml/InterpreterException.java @@ -0,0 +1,9 @@ +package org.uscxml; + +public class InterpreterException extends Exception { + private static final long serialVersionUID = -3534919496547591015L; + + public InterpreterException(String msg) { + super(msg); + } +} diff --git a/src/bindings/swig/java/uscxml.i b/src/bindings/swig/java/uscxml.i index f72084e..b780f74 100644 --- a/src/bindings/swig/java/uscxml.i +++ b/src/bindings/swig/java/uscxml.i @@ -3,10 +3,6 @@ // provide a macro for the header files #define SWIGIMPORTED 1 -// import swig typemaps -//%include <arrays_java.i> -//%include <inttypes.i> - %include <stl.i> %include <std_map.i> %include <std_string.i> @@ -22,25 +18,20 @@ typedef uscxml::Event Event; typedef uscxml::InvokeRequest InvokeRequest; typedef uscxml::SendRequest SendRequest; +%feature("director") uscxml::WrappedInvoker; +%feature("director") uscxml::WrappedDataModel; +%feature("director") uscxml::WrappedIOProcessor; +%feature("director") uscxml::WrappedExecutableContent; + // disable warning related to unknown base class #pragma SWIG nowarn=401 -//%ignore boost::enable_shared_from_this; +// do not warn when we override symbols via extend +#pragma SWIG nowarn=302 %javaconst(1); -# %shared_ptr(uscxml::dom::Element); -# %shared_ptr(uscxml::dom::Executable); - %rename(equals) operator==; %rename(isValid) operator bool; -%ignore operator!=; -%ignore operator<; -%ignore operator=; -%ignore operator[]; -%ignore operator std::list<Data>; -%ignore operator std::string; -%ignore operator std::map<std::string,Data>; -%ignore operator<<; //************************************************** @@ -52,113 +43,54 @@ typedef uscxml::SendRequest SendRequest; #include "../../../uscxml/Message.h" #include "../../../uscxml/Factory.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" using namespace uscxml; using namespace Arabica::DOM; #include "../wrapped/WrappedInvoker.cpp" #include "../wrapped/WrappedDataModel.cpp" +#include "../wrapped/WrappedExecutableContent.cpp" +#include "../wrapped/WrappedIOProcessor.cpp" %} -%ignore uscxml::NumAttr; -%ignore uscxml::SCXMLParser; -%ignore uscxml::InterpreterImpl; - -%ignore create(); - -%ignore uscxml::Interpreter::getDelayQueue(); - -%ignore uscxml::WrappedInvoker::create(InterpreterImpl*); - -%ignore uscxml::WrappedDataModel::create(InterpreterImpl*); -%ignore uscxml::WrappedDataModel::init(const Arabica::DOM::Element<std::string>&, const Arabica::DOM::Document<std::string>&, const std::string&); -%ignore uscxml::WrappedDataModel::init(const std::string&, const Data&); -%ignore uscxml::WrappedDataModel::assign(const Arabica::DOM::Element<std::string>&, const Arabica::DOM::Document<std::string>&, const std::string&); -%ignore uscxml::WrappedDataModel::assign(const std::string&, const Data&); -%ignore uscxml::WrappedDataModel::eval(const Arabica::DOM::Element<std::string>&, const std::string&); - -%ignore uscxml::Event::Event(const Arabica::DOM::Node<std::string>&); -%ignore uscxml::Event::getStrippedDOM; -%ignore uscxml::Event::getFirstDOMElement; -%ignore uscxml::Event::getDOM(); -%ignore uscxml::Event::setDOM(const Arabica::DOM::Document<std::string>&); -%ignore uscxml::Event::toDocument(); - -%template(DataList) std::list<uscxml::Data>; -%template(DataMap) std::map<std::string, uscxml::Data>; -%template(StringSet) std::set<std::string>; -%template(StringVector) std::vector<std::string>; -%template(ParamPair) std::pair<std::string, uscxml::Data>; -%template(ParamPairVector) std::vector<std::pair<std::string, uscxml::Data> >; -%template(IOProcMap) std::map<std::string, uscxml::IOProcessor>; -%template(InvokerMap) std::map<std::string, uscxml::Invoker>; +%define WRAP_THROW_EXCEPTION( MATCH ) +%javaexception("org.uscxml.InterpreterException") MATCH { + try { + $action + } + catch ( uscxml::Event& e ) { + jclass eclass = jenv->FindClass("org/uscxml/InterpreterException"); + if ( eclass ) { + std::stringstream ss; + ss << std::endl << e; + jenv->ThrowNew( eclass, ss.str().c_str() ); + } + } +} +%enddef + +WRAP_THROW_EXCEPTION(uscxml::Interpreter::fromXML); +WRAP_THROW_EXCEPTION(uscxml::Interpreter::fromURI); +WRAP_THROW_EXCEPTION(uscxml::Interpreter::step); +WRAP_THROW_EXCEPTION(uscxml::Interpreter::interpret); + + +%include "../uscxml_ignores.i" %rename Data DataNative; -%feature("director") uscxml::WrappedInvoker; -%feature("director") uscxml::WrappedDataModel; - // translate param multimap to Map<String, List<Data> > %rename(getParamsNative) uscxml::Event::getParams(); %javamethodmodifiers uscxml::Event::getParams() "private"; -%extend uscxml::Event { - std::vector<std::pair<std::string, 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; - } -}; - -%extend uscxml::Interpreter { - std::vector<std::string> getIOProcessorKeys() { - std::vector<std::string> keys; - std::map<std::string, IOProcessor>::const_iterator iter = self->getIOProcessors().begin(); - while(iter != self->getIOProcessors().end()) { - keys.push_back(iter->first); - iter++; - } - return keys; - } - - std::vector<std::string> getInvokerKeys() { - std::vector<std::string> keys; - std::map<std::string, Invoker>::const_iterator iter = self->getInvokers().begin(); - while(iter != self->getInvokers().end()) { - keys.push_back(iter->first); - iter++; - } - return keys; - } - -}; - -%extend uscxml::Data { - std::vector<std::string> getCompundKeys() { - std::vector<std::string> keys; - std::map<std::string, Data>::const_iterator iter = self->compound.begin(); - while(iter != self->compound.end()) { - keys.push_back(iter->first); - iter++; - } - return keys; - } -}; - +%include "../uscxml_beautify.i" //*********************************************** @@ -169,19 +101,21 @@ using namespace Arabica::DOM; %include "../../../uscxml/Factory.h" %include "../../../uscxml/Message.h" %include "../../../uscxml/Interpreter.h" -#include "../../../uscxml/DOMUtils.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" + -# %template(XMLDocument) Arabica::DOM::Document<std::string>; -# %template(XMLNode) Arabica::DOM::Node<std::string>; -# %template(XMLElement) Arabica::DOM::Element<std::string>; -# %template(XMLAttr) Arabica::DOM::Attr<std::string>; -# %template(XMLText) Arabica::DOM::Text<std::string>; +%template(DataList) std::list<uscxml::Data>; +%template(DataMap) std::map<std::string, uscxml::Data>; +%template(StringSet) std::set<std::string>; +%template(StringVector) std::vector<std::string>; +%template(StringList) std::list<std::string>; +%template(ParamPair) std::pair<std::string, uscxml::Data>; +%template(ParamPairVector) std::vector<std::pair<std::string, uscxml::Data> >; +%template(IOProcMap) std::map<std::string, uscxml::IOProcessor>; +%template(InvokerMap) std::map<std::string, uscxml::Invoker>; +%template(ParentQueue) uscxml::concurrency::BlockingQueue<uscxml::SendRequest>; diff --git a/src/bindings/swig/uscxml_beautify.i b/src/bindings/swig/uscxml_beautify.i new file mode 100644 index 0000000..8b57e78 --- /dev/null +++ b/src/bindings/swig/uscxml_beautify.i @@ -0,0 +1,67 @@ +%extend uscxml::Event { + std::vector<std::pair<std::string, 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; + } +}; + +%extend uscxml::Interpreter { + + std::vector<std::string> getBasicConfiguration() { + Arabica::XPath::NodeSet<std::string> nativeConfig = self->getBasicConfiguration(); + std::vector<std::string> config; + for (int i = 0; i < nativeConfig.size(); i++) { + Arabica::DOM::Element<std::string> elem(nativeConfig[i]); + config.push_back(elem.getAttribute("id")); + } + return config; + } + + std::vector<std::string> getConfiguration() { + Arabica::XPath::NodeSet<std::string> nativeConfig = self->getConfiguration(); + std::vector<std::string> config; + for (int i = 0; i < nativeConfig.size(); i++) { + Arabica::DOM::Element<std::string> elem(nativeConfig[i]); + config.push_back(elem.getAttribute("id")); + } + return config; + } + + std::vector<std::string> getIOProcessorKeys() { + std::vector<std::string> keys; + std::map<std::string, IOProcessor>::const_iterator iter = self->getIOProcessors().begin(); + while(iter != self->getIOProcessors().end()) { + keys.push_back(iter->first); + iter++; + } + return keys; + } + + std::vector<std::string> getInvokerKeys() { + std::vector<std::string> keys; + std::map<std::string, Invoker>::const_iterator iter = self->getInvokers().begin(); + while(iter != self->getInvokers().end()) { + keys.push_back(iter->first); + iter++; + } + return keys; + } + +}; + +%extend uscxml::Data { + std::vector<std::string> getCompundKeys() { + std::vector<std::string> keys; + std::map<std::string, Data>::const_iterator iter = self->compound.begin(); + while(iter != self->compound.end()) { + keys.push_back(iter->first); + iter++; + } + return keys; + } +}; diff --git a/src/bindings/swig/uscxml_ignores.i b/src/bindings/swig/uscxml_ignores.i new file mode 100644 index 0000000..4f8b2a3 --- /dev/null +++ b/src/bindings/swig/uscxml_ignores.i @@ -0,0 +1,54 @@ +%ignore uscxml::NumAttr; +%ignore uscxml::SCXMLParser; +%ignore uscxml::InterpreterImpl; + +%ignore create(); + +%ignore uscxml::Interpreter::getDelayQueue(); +%ignore uscxml::Interpreter::fromDOM; +%ignore uscxml::Interpreter::fromClone; +%ignore uscxml::Interpreter::start(); +%ignore uscxml::Interpreter::stop(); +%ignore uscxml::Interpreter::setCmdLineOptions(std::map<std::string, std::string>); +%ignore uscxml::Interpreter::getDocument; +%ignore uscxml::Interpreter::getImpl; +%ignore uscxml::Interpreter::runOnMainThread; +%ignore uscxml::Interpreter::getHTTPServlet(); +%ignore uscxml::Interpreter::getNodeSetForXPath(const std::string&); +%ignore uscxml::Interpreter::isLegalConfiguration(const Arabica::XPath::NodeSet<std::string>&); +%ignore uscxml::Interpreter::getInstances(); + +%ignore uscxml::WrappedInvoker::create(InterpreterImpl*); + +%ignore uscxml::WrappedDataModel::create(InterpreterImpl*); +%ignore uscxml::WrappedDataModel::init(const Arabica::DOM::Element<std::string>&, const Arabica::DOM::Document<std::string>&, const std::string&); +%ignore uscxml::WrappedDataModel::init(const Arabica::DOM::Element<std::string>&, const Arabica::DOM::Node<std::string>&, const std::string&); +%ignore uscxml::WrappedDataModel::init(const std::string&, const Data&); +%ignore uscxml::WrappedDataModel::assign(const Arabica::DOM::Element<std::string>&, const Arabica::DOM::Document<std::string>&, const std::string&); +%ignore uscxml::WrappedDataModel::assign(const Arabica::DOM::Element<std::string>&, const Arabica::DOM::Node<std::string>&, const std::string&); +%ignore uscxml::WrappedDataModel::assign(const std::string&, const Data&); +%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&); + +%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>&); + +%ignore uscxml::WrappedIOProcessor::create(InterpreterImpl*); + +%ignore uscxml::Event::Event(const Arabica::DOM::Node<std::string>&); +%ignore uscxml::Event::getStrippedDOM; +%ignore uscxml::Event::getFirstDOMElement; +%ignore uscxml::Event::getDOM(); +%ignore uscxml::Event::setDOM(const Arabica::DOM::Document<std::string>&); +%ignore uscxml::Event::toDocument(); + +%ignore operator!=; +%ignore operator<; +%ignore operator=; +%ignore operator[]; +%ignore operator std::list<Data>; +%ignore operator std::string; +%ignore operator std::map<std::string,Data>; +%ignore operator<<; + diff --git a/src/bindings/swig/wrapped/WrappedDataModel.cpp b/src/bindings/swig/wrapped/WrappedDataModel.cpp index 901d246..8ba57be 100644 --- a/src/bindings/swig/wrapped/WrappedDataModel.cpp +++ b/src/bindings/swig/wrapped/WrappedDataModel.cpp @@ -1,3 +1,22 @@ +/** + * @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 "WrappedDataModel.h" namespace uscxml { diff --git a/src/bindings/swig/wrapped/WrappedDataModel.h b/src/bindings/swig/wrapped/WrappedDataModel.h index 2b1ad48..026bed2 100644 --- a/src/bindings/swig/wrapped/WrappedDataModel.h +++ b/src/bindings/swig/wrapped/WrappedDataModel.h @@ -1,3 +1,22 @@ +/** + * @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 WRAPPEDDATAMODEL_H_DBAAD6AF #define WRAPPEDDATAMODEL_H_DBAAD6AF diff --git a/src/bindings/swig/wrapped/WrappedExecutableContent.cpp b/src/bindings/swig/wrapped/WrappedExecutableContent.cpp new file mode 100644 index 0000000..a876754 --- /dev/null +++ b/src/bindings/swig/wrapped/WrappedExecutableContent.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 "WrappedExecutableContent.h" + +namespace uscxml { + +WrappedExecutableContent::WrappedExecutableContent() {} +WrappedExecutableContent::~WrappedExecutableContent() {} + +}
\ No newline at end of file diff --git a/src/bindings/swig/wrapped/WrappedExecutableContent.h b/src/bindings/swig/wrapped/WrappedExecutableContent.h new file mode 100644 index 0000000..24c6978 --- /dev/null +++ b/src/bindings/swig/wrapped/WrappedExecutableContent.h @@ -0,0 +1,86 @@ +/** + * @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 WRAPPEDEXECUTABLECONTENT_H_F690F480 +#define WRAPPEDEXECUTABLECONTENT_H_F690F480 + +#include "../../../uscxml/Message.h" +#include "../../../uscxml/Factory.h" +#include "../../../uscxml/Interpreter.h" + +namespace uscxml { + +class WrappedExecutableContent : public ExecutableContentImpl { +public: + WrappedExecutableContent(); + virtual ~WrappedExecutableContent(); + + virtual WrappedExecutableContent* create(const Interpreter& interpreter) { + return new WrappedExecutableContent(); + } + + virtual boost::shared_ptr<ExecutableContentImpl> create(InterpreterImpl* interpreter) { + _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"; + } + + virtual void enterElement(const Arabica::DOM::Node<std::string>& node) { + std::ostringstream ssElement; + ssElement << node; + enterElement(ssElement.str()); + } + + virtual void exitElement(const Arabica::DOM::Node<std::string>& node) { + std::ostringstream ssElement; + ssElement << node; + exitElement(ssElement.str()); + } + + virtual bool processChildren() { + return false; + } + + virtual void enterElement(const std::string& node) { + + } + + virtual void exitElement(const std::string& node) { + + } + + void croak() throw(Event) { + + } + +private: + Interpreter _interpreter; +}; + +} + + +#endif /* end of include guard: WRAPPEDEXECUTABLECONTENT_H_F690F480 */ diff --git a/src/bindings/swig/wrapped/WrappedIOProcessor.cpp b/src/bindings/swig/wrapped/WrappedIOProcessor.cpp new file mode 100644 index 0000000..2f39d80 --- /dev/null +++ b/src/bindings/swig/wrapped/WrappedIOProcessor.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 "WrappedIOProcessor.h" + +namespace uscxml { + +WrappedIOProcessor::WrappedIOProcessor() {} +WrappedIOProcessor::~WrappedIOProcessor() {} + +}
\ No newline at end of file diff --git a/src/bindings/swig/wrapped/WrappedIOProcessor.h b/src/bindings/swig/wrapped/WrappedIOProcessor.h new file mode 100644 index 0000000..70c400e --- /dev/null +++ b/src/bindings/swig/wrapped/WrappedIOProcessor.h @@ -0,0 +1,62 @@ +/** + * @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 WRAPPEDIOPROCESSOR_H_AE98064A +#define WRAPPEDIOPROCESSOR_H_AE98064A + +#include "../../../uscxml/Message.h" +#include "../../../uscxml/Factory.h" +#include "../../../uscxml/Interpreter.h" + +namespace uscxml { + +class WrappedIOProcessor : public IOProcessorImpl { +public: + WrappedIOProcessor(); + virtual ~WrappedIOProcessor(); + + virtual WrappedIOProcessor* create(const Interpreter& interpreter) { + return new WrappedIOProcessor(); + } + + virtual boost::shared_ptr<IOProcessorImpl> create(InterpreterImpl* interpreter) { + _interpreter = interpreter->shared_from_this(); + return boost::shared_ptr<IOProcessorImpl>(create(_interpreter)); + } + virtual std::list<std::string> getNames() { + return std::list<std::string>(); + }; + + virtual Data getDataModelVariables() { + Data data; + return data; + } + + virtual void send(const SendRequest& req) { + + } + +private: + Interpreter _interpreter; +}; + +} + + +#endif /* end of include guard: WRAPPEDIOPROCESSOR_H_AE98064A */ diff --git a/src/bindings/swig/wrapped/WrappedInvoker.cpp b/src/bindings/swig/wrapped/WrappedInvoker.cpp index b775878..8187a9f 100644 --- a/src/bindings/swig/wrapped/WrappedInvoker.cpp +++ b/src/bindings/swig/wrapped/WrappedInvoker.cpp @@ -1,3 +1,22 @@ +/** + * @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 "WrappedInvoker.h" namespace uscxml { diff --git a/src/bindings/swig/wrapped/WrappedInvoker.h b/src/bindings/swig/wrapped/WrappedInvoker.h index 61eedac..ff56b15 100644 --- a/src/bindings/swig/wrapped/WrappedInvoker.h +++ b/src/bindings/swig/wrapped/WrappedInvoker.h @@ -1,3 +1,22 @@ +/** + * @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 WRAPPEDINVOKER_H_F9725D47 #define WRAPPEDINVOKER_H_F9725D47 diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp index 4ffa92c..9770387 100644 --- a/src/uscxml/Interpreter.cpp +++ b/src/uscxml/Interpreter.cpp @@ -82,7 +82,8 @@ #define VALID_FROM_IDLE(newState) ( \ newState == InterpreterState::USCXML_DESTROYED || \ - newState == InterpreterState::USCXML_MICROSTEPPED \ + newState == InterpreterState::USCXML_MICROSTEPPED || \ + newState == InterpreterState::USCXML_MACROSTEPPED \ ) #define VALID_FROM_FINISHED(newState) ( \ @@ -90,6 +91,12 @@ newState == InterpreterState::USCXML_INSTANTIATED \ ) +#define THROW_ERROR_PLATFORM(msg) \ + Event e; \ + 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) \ @@ -378,8 +385,7 @@ Interpreter Interpreter::fromURI(const std::string& uri) { URL absUrl(uri); if (!absUrl.isAbsolute()) { if (!absUrl.toAbsoluteCwd()) { - LOG(ERROR) << "Given URL is not absolute or does not have file schema"; - return Interpreter(); + THROW_ERROR_PLATFORM("Given URL is not absolute or does not have file schema"); } } @@ -401,8 +407,7 @@ Interpreter Interpreter::fromURI(const std::string& uri) { std::stringstream ss; ss << absUrl; if (absUrl.downloadFailed()) { - LOG(ERROR) << "Downloading SCXML document from " << absUrl << " failed"; - return interpreter; + THROW_ERROR_PLATFORM("Downloading SCXML document from " + absUrl.asString() + " failed"); } interpreter = fromXML(ss.str()); } @@ -412,7 +417,7 @@ Interpreter Interpreter::fromURI(const std::string& uri) { interpreter._impl->_baseURI = URL::asBaseURL(absUrl); interpreter._impl->_sourceURI = absUrl; } else { - LOG(ERROR) << "Cannot create interpreter from URI '" << absUrl.asString() << "'"; + THROW_ERROR_PLATFORM("Cannot create interpreter from URI " + absUrl.asString() + "'"); } return interpreter; } @@ -439,8 +444,12 @@ Interpreter Interpreter::fromInputSource(Arabica::SAX::InputSource<std::string>& interpreterImpl->setNameSpaceInfo(parser.nameSpace); interpreterImpl->_document = parser.getDocument(); } else { -// assert(parser.errorsReported()); - interpreterImpl->setInterpreterState(InterpreterState::USCXML_FAULTED, parser.errors()); + if (parser.errorsReported()) { + THROW_ERROR_PLATFORM(parser.errors()) + } else { + THROW_ERROR_PLATFORM("Failed to create interpreter"); +// interpreterImpl->setInterpreterState(InterpreterState::USCXML_FAULTED, parser.errors()); + } } return interpreter; } diff --git a/src/uscxml/Interpreter.h b/src/uscxml/Interpreter.h index d9aeac3..9a3e553 100644 --- a/src/uscxml/Interpreter.h +++ b/src/uscxml/Interpreter.h @@ -315,11 +315,11 @@ public: URL::toBaseURL(baseURI); _baseURI = baseURI; } - URL getBaseURI() { - return _baseURI; + std::string getBaseURI() { + return _baseURI.asString(); } - URL getSourceURI() { - return _sourceURI; + std::string getSourceURI() { + return _sourceURI.asString(); } void setCmdLineOptions(std::map<std::string, std::string> params); @@ -652,10 +652,10 @@ public: void setSourceURI(std::string sourceURI) { return _impl->setSourceURI(sourceURI); } - URL getSourceURI() { + std::string getSourceURI() { return _impl->getSourceURI(); } - URL getBaseURI() { + std::string getBaseURI() { return _impl->getBaseURI(); } diff --git a/src/uscxml/URL.h b/src/uscxml/URL.h index 5f55454..fd89503 100644 --- a/src/uscxml/URL.h +++ b/src/uscxml/URL.h @@ -261,7 +261,9 @@ public: return _impl->pathComponents(); } const std::string asString() const { - return _impl->asString(); + if (_impl) + return _impl->asString(); + return ""; } static std::string tmpDir(); diff --git a/src/uscxml/concurrency/tinythread.cpp b/src/uscxml/concurrency/tinythread.cpp index 6167545..d46cda3 100644 --- a/src/uscxml/concurrency/tinythread.cpp +++ b/src/uscxml/concurrency/tinythread.cpp @@ -85,10 +85,27 @@ condition_variable::~condition_variable() { #endif #if defined(_TTHREAD_WIN32_) -void condition_variable::_wait() { +void condition_variable::_wait(unsigned int ms) { + if (ms <= 0) + ms = INFINITE; // Wait for either event to become signaled due to notify_one() or // notify_all() being called - int result = WaitForMultipleObjects(2, mEvents, FALSE, INFINITE); + int result = WaitForMultipleObjects(2, mEvents, FALSE, ms); + if (result == WAIT_FAILED) { + LPVOID lpMsgBuf; + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + (LPTSTR) &lpMsgBuf, + 0, + NULL); +// UM_LOG_ERR("%s", lpMsgBuf); + LocalFree(lpMsgBuf); + + } // Check if we are the last waiter EnterCriticalSection(&mWaitersCountLock); diff --git a/src/uscxml/concurrency/tinythread.h b/src/uscxml/concurrency/tinythread.h index 9d211f4..867f036 100644 --- a/src/uscxml/concurrency/tinythread.h +++ b/src/uscxml/concurrency/tinythread.h @@ -421,7 +421,7 @@ public: // Release the mutex while waiting for the condition (will decrease // the number of waiters when done)... aMutex.unlock(); - _wait(); + _wait(0); aMutex.lock(); #else pthread_cond_wait(&mHandle, &aMutex.mHandle); @@ -483,7 +483,7 @@ public: private: #if defined(_TTHREAD_WIN32_) - void _wait(); + void _wait(unsigned int ms); HANDLE mEvents[2]; ///< Signal and broadcast event HANDLEs. unsigned int mWaitersCount; ///< Count of the number of waiters. CRITICAL_SECTION mWaitersCountLock; ///< Serialize access to mWaitersCount. diff --git a/src/uscxml/debug/DebuggerServlet.cpp b/src/uscxml/debug/DebuggerServlet.cpp index 17c11d6..d7528f0 100644 --- a/src/uscxml/debug/DebuggerServlet.cpp +++ b/src/uscxml/debug/DebuggerServlet.cpp @@ -228,7 +228,7 @@ void DebuggerServlet::processListSessions(const HTTPServer::Request& request) { Data sessionData; sessionData.compound["name"] = Data(instance->getName(), Data::VERBATIM); sessionData.compound["id"] = Data(instance->getSessionId(), Data::VERBATIM); - sessionData.compound["source"] = Data(instance->getSourceURI().asString(), Data::VERBATIM); + sessionData.compound["source"] = Data(instance->getSourceURI(), Data::VERBATIM); sessionData.compound["xml"].node = instance->getDocument(); replyData.compound["sessions"].array.push_back(sessionData); diff --git a/test/w3c/confEcma.xsl b/test/w3c/confEcma.xsl index 96c1708..b77e22c 100644 --- a/test/w3c/confEcma.xsl +++ b/test/w3c/confEcma.xsl @@ -674,7 +674,7 @@ the basic http tests. In the case of python, we have to import the regexp modul <!-- returns true if _event/raw contains the param with the specified value --> <xsl:template match="//@conf:eventNamedParamHasValue"> <xsl:attribute name="cond"><xsl:analyze-string select="." regex="(\S+)(\s+)(\S+)"> - <xsl:matching-substring>_event.raw.search(/Var<xsl:value-of select="regex-group(1)"/>=<xsl:value-of select="regex-group(3)"/>/) !== -1</xsl:matching-substring></xsl:analyze-string></xsl:attribute> + <xsl:matching-substring>_event.raw.search(<xsl:value-of select="regex-group(1)"/>=<xsl:value-of select="regex-group(3)"/>) !== -1</xsl:matching-substring></xsl:analyze-string></xsl:attribute> </xsl:template> <xsl:template match="//@conf:messageBodyEquals"> diff --git a/test/w3c/ecma/test329.scxml b/test/w3c/ecma/test329.scxml index 586f15a..9a95643 100644 --- a/test/w3c/ecma/test329.scxml +++ b/test/w3c/ecma/test329.scxml @@ -1,5 +1,4 @@ <?xml version="1.0" encoding="UTF-8"?><!-- test that none of the system variables can be modified --><scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" initial="s0" version="1.0" datamodel="ecmascript" name="machineName"> - <script src="http://uscxml.tk.informatik.tu-darmstadt.de/scripts/dump.js" /> <datamodel> <data id="Var1"/> <data id="Var2"/> diff --git a/test/w3c/ecma/test350.scxml b/test/w3c/ecma/test350.scxml new file mode 100644 index 0000000..176903e --- /dev/null +++ b/test/w3c/ecma/test350.scxml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?><!-- test that target value is used to decide what session to deliver the event to. A session should be +able to send an event to itself using its own session ID as the target --><scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" initial="s0" datamodel="ecmascript" version="1.0"> +<datamodel> + <data id="Var1" expr="'#_scxml_'"/> + <data id="Var2" expr="_sessionid"/> +</datamodel> + +<state id="s0"> + + <onentry> + <assign location="Var1" expr="Var1 + Var2"/> + <send delay="5s" event="timeout"/> + <send type="http://www.w3.org/TR/scxml/#SCXMLEventProcessor" targetexpr="Var1" event="s0Event"/> + </onentry> + <transition event="s0Event" target="pass"/> + <transition event="*" target="fail"/> + +</state> + + + <final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final> + <final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final> + +</scxml>
\ No newline at end of file diff --git a/test/w3c/ecma/test446.scxml b/test/w3c/ecma/test446.scxml index 0fa8698..64ab3c9 100644 --- a/test/w3c/ecma/test446.scxml +++ b/test/w3c/ecma/test446.scxml @@ -2,7 +2,7 @@ assigns it as the value of the var --><scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" initial="s0" version="1.0" datamodel="ecmascript"> <datamodel> <data id="var1">[1, 2, 3]</data> - <data id="var2" src="file:test458.txt"/> + <data id="var2" src="file:test446.txt"/> </datamodel> <state id="s0"> diff --git a/test/w3c/ecma/test446.txt b/test/w3c/ecma/test446.txt new file mode 100644 index 0000000..4db4843 --- /dev/null +++ b/test/w3c/ecma/test446.txt @@ -0,0 +1,12 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> +<html><head> +<title>300 Multiple Choices</title> +</head><body> +<h1>Multiple Choices</h1> +The document name you requested (<code>/Voice/2013/scxml-irp/446/test446.txt</code>) could not be found on this server. +However, we found documents with names similar to the one you requested.<p>Available documents: +<ul> +<li><a href="/Voice/2013/scxml-irp/446/test446.txml">/Voice/2013/scxml-irp/446/test446.txml</a> (common basename) +</ul> +Please consider informing the owner of the <a href="http://www.w3.org/Voice/2013/scxml-irp/">referring page</a> about the broken link. +</body></html> diff --git a/test/w3c/ecma/test458.txt b/test/w3c/ecma/test458.txt deleted file mode 100644 index 6001c44..0000000 --- a/test/w3c/ecma/test458.txt +++ /dev/null @@ -1 +0,0 @@ -[1, 2, 3]
\ No newline at end of file diff --git a/test/w3c/ecma/test519.scxml b/test/w3c/ecma/test519.scxml index 6f559da..8945354 100644 --- a/test/w3c/ecma/test519.scxml +++ b/test/w3c/ecma/test519.scxml @@ -10,7 +10,7 @@ </onentry> <!-- if other end sends us back this event, we succeed --> - <transition event="test" cond="_event.raw.search(/Varparam1=1/) !== -1" target="pass"/> + <transition event="test" cond="_event.raw.search(param1=1) !== -1" target="pass"/> <transition event="*" target="fail"/> </state> diff --git a/test/w3c/ecma/test534.scxml b/test/w3c/ecma/test534.scxml index 9495d9e..57a54bf 100644 --- a/test/w3c/ecma/test534.scxml +++ b/test/w3c/ecma/test534.scxml @@ -9,7 +9,7 @@ </onentry> <!-- if other end sends us back this event, we succeed --> - <transition event="test" cond="_event.raw.search(/Var_scxmleventname=test/) !== -1" target="pass"/> + <transition event="test" cond="_event.raw.search('_scxmleventname=test') !== -1" target="pass"/> <transition event="*" target="fail"/> </state> diff --git a/test/w3c/txml/test350.txml b/test/w3c/txml/test350.txml index 1086db7..784b96e 100644 --- a/test/w3c/txml/test350.txml +++ b/test/w3c/txml/test350.txml @@ -6,15 +6,15 @@ able to send an event to itself using its own session ID as the target --> <scxml initial="s0" conf:datamodel="" version="1.0" xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance"> <datamodel> <data conf:id="1" conf:quoteExpr="#_scxml_"/> - <data conf:id="2" conf:systemVarExpr="_sessionid”/> + <data conf:id="2" conf:systemVarExpr="_sessionid"/> </datamodel> <state id="s0"> <onentry> - <conf:concatVars id1="1" id2="2"/> + <conf:concatVars id1="1" id2="2"/> <send delay="5s" event="timeout"/> - <send type="http://www.w3.org/TR/scxml/#SCXMLEventProcessor" conf:targetVar="1" event="s0Event"/> + <send type="http://www.w3.org/TR/scxml/#SCXMLEventProcessor" conf:targetVar="1" event="s0Event"/> </onentry> <transition event="s0Event" conf:targetpass=""/> <transition event="*" conf:targetfail=""/> diff --git a/test/w3c/txml/test446.txml b/test/w3c/txml/test446.txml index afdf6a0..3d03fcf 100644 --- a/test/w3c/txml/test446.txml +++ b/test/w3c/txml/test446.txml @@ -6,7 +6,7 @@ xmlns:conf="http://www.w3.org/2005/scxml-conformance" initial="s0" version="1.0" datamodel="ecmascript"> <datamodel> <data id="var1">[1, 2, 3]</data> - <data id="var2" src="file:test458.txt"/> + <data id="var2" src="file:test446.txt"/> </datamodel> <state id="s0"> diff --git a/test/w3c/txml/test446.txt b/test/w3c/txml/test446.txt new file mode 100644 index 0000000..4db4843 --- /dev/null +++ b/test/w3c/txml/test446.txt @@ -0,0 +1,12 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> +<html><head> +<title>300 Multiple Choices</title> +</head><body> +<h1>Multiple Choices</h1> +The document name you requested (<code>/Voice/2013/scxml-irp/446/test446.txt</code>) could not be found on this server. +However, we found documents with names similar to the one you requested.<p>Available documents: +<ul> +<li><a href="/Voice/2013/scxml-irp/446/test446.txml">/Voice/2013/scxml-irp/446/test446.txml</a> (common basename) +</ul> +Please consider informing the owner of the <a href="http://www.w3.org/Voice/2013/scxml-irp/">referring page</a> about the broken link. +</body></html> diff --git a/test/w3c/xpath/test350.scxml b/test/w3c/xpath/test350.scxml new file mode 100644 index 0000000..848ed71 --- /dev/null +++ b/test/w3c/xpath/test350.scxml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?><!-- test that target value is used to decide what session to deliver the event to. A session should be +able to send an event to itself using its own session ID as the target --><scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" initial="s0" datamodel="xpath" version="1.0"> +<datamodel> + <data id="Var1" expr="'#_scxml_'"/> + <data id="Var2" expr="$_sessionid"/> +</datamodel> + +<state id="s0"> + + <onentry> + <assign location="$Var1" expr="concat($Var1, $Var2)"/> + <send delay="5s" event="timeout"/> + <send type="http://www.w3.org/TR/scxml/#SCXMLEventProcessor" targetexpr="$Var1" event="s0Event"/> + </onentry> + <transition event="s0Event" target="pass"/> + <transition event="*" target="fail"/> + +</state> + + + <final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final> + <final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final> + +</scxml>
\ No newline at end of file diff --git a/test/w3c/xpath/test446.scxml b/test/w3c/xpath/test446.scxml index 0fa8698..64ab3c9 100644 --- a/test/w3c/xpath/test446.scxml +++ b/test/w3c/xpath/test446.scxml @@ -2,7 +2,7 @@ assigns it as the value of the var --><scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" initial="s0" version="1.0" datamodel="ecmascript"> <datamodel> <data id="var1">[1, 2, 3]</data> - <data id="var2" src="file:test458.txt"/> + <data id="var2" src="file:test446.txt"/> </datamodel> <state id="s0"> diff --git a/test/w3c/xpath/test446.txt b/test/w3c/xpath/test446.txt new file mode 100644 index 0000000..4db4843 --- /dev/null +++ b/test/w3c/xpath/test446.txt @@ -0,0 +1,12 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> +<html><head> +<title>300 Multiple Choices</title> +</head><body> +<h1>Multiple Choices</h1> +The document name you requested (<code>/Voice/2013/scxml-irp/446/test446.txt</code>) could not be found on this server. +However, we found documents with names similar to the one you requested.<p>Available documents: +<ul> +<li><a href="/Voice/2013/scxml-irp/446/test446.txml">/Voice/2013/scxml-irp/446/test446.txml</a> (common basename) +</ul> +Please consider informing the owner of the <a href="http://www.w3.org/Voice/2013/scxml-irp/">referring page</a> about the broken link. +</body></html> |