summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2014-06-25 21:05:44 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2014-06-25 21:05:44 (GMT)
commite3767be4f9c5874d9c996200f2e9705ce31a5976 (patch)
treebe3d06f550286e23eeb3252277c1a2b7d12554ef /contrib
parent758bda908ded461c9d34d274a18454ffba4b7450 (diff)
downloaduscxml-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!
Diffstat (limited to 'contrib')
-rw-r--r--contrib/csharp/embedding/embedding.sln20
-rw-r--r--contrib/csharp/embedding/embedding.suobin15872 -> 0 bytes
-rw-r--r--contrib/csharp/embedding/embedding.userprefs12
-rw-r--r--contrib/csharp/embedding/embedding/Program.cs35
-rw-r--r--contrib/csharp/embedding/embedding/Properties/AssemblyInfo.cs36
-rw-r--r--contrib/csharp/embedding/embedding/embedding.csproj66
-rw-r--r--contrib/java/.classpath10
-rw-r--r--contrib/java/.project39
-rw-r--r--contrib/java/build-java.xml91
-rw-r--r--contrib/java/src/js.jarbin1134765 -> 0 bytes
-rw-r--r--contrib/java/src/org/uscxml/datamodel/ecmascript/ECMAData.java110
-rw-r--r--contrib/java/src/org/uscxml/datamodel/ecmascript/ECMAEvent.java126
-rw-r--r--contrib/java/src/org/uscxml/datamodel/ecmascript/ECMAScriptDataModel.java396
-rw-r--r--contrib/java/src/org/uscxml/tests/TestData.java23
-rw-r--r--contrib/java/src/org/uscxml/tests/TestInvoker.java66
-rw-r--r--contrib/java/src/org/uscxml/tests/TestJavaScriptDataModel.java26
-rw-r--r--contrib/java/src/org/uscxml/tests/TestW3CECMA.java40
-rwxr-xr-xcontrib/local/compress_and_upload_deps.sh2
18 files changed, 92 insertions, 1006 deletions
diff --git a/contrib/csharp/embedding/embedding.sln b/contrib/csharp/embedding/embedding.sln
deleted file mode 100644
index 0f9a49e..0000000
--- a/contrib/csharp/embedding/embedding.sln
+++ /dev/null
@@ -1,20 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "embedding", "embedding\embedding.csproj", "{75E5EE93-513B-45DA-AD50-64C570AAD0C0}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|x86 = Debug|x86
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {75E5EE93-513B-45DA-AD50-64C570AAD0C0}.Debug|x86.ActiveCfg = Debug|x86
- {75E5EE93-513B-45DA-AD50-64C570AAD0C0}.Debug|x86.Build.0 = Debug|x86
- {75E5EE93-513B-45DA-AD50-64C570AAD0C0}.Release|x86.ActiveCfg = Release|x86
- {75E5EE93-513B-45DA-AD50-64C570AAD0C0}.Release|x86.Build.0 = Release|x86
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/contrib/csharp/embedding/embedding.suo b/contrib/csharp/embedding/embedding.suo
deleted file mode 100644
index f011087..0000000
--- a/contrib/csharp/embedding/embedding.suo
+++ /dev/null
Binary files differ
diff --git a/contrib/csharp/embedding/embedding.userprefs b/contrib/csharp/embedding/embedding.userprefs
deleted file mode 100644
index 05e379d..0000000
--- a/contrib/csharp/embedding/embedding.userprefs
+++ /dev/null
@@ -1,12 +0,0 @@
-<Properties>
- <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|x86" />
- <MonoDevelop.Ide.Workbench ActiveDocument="embedding/Program.cs">
- <Files>
- <File FileName="embedding/Program.cs" Line="31" Column="1" />
- </Files>
- </MonoDevelop.Ide.Workbench>
- <MonoDevelop.Ide.DebuggingService.Breakpoints>
- <BreakpointStore />
- </MonoDevelop.Ide.DebuggingService.Breakpoints>
- <MonoDevelop.Ide.DebuggingService.PinnedWatches />
-</Properties> \ No newline at end of file
diff --git a/contrib/csharp/embedding/embedding/Program.cs b/contrib/csharp/embedding/embedding/Program.cs
deleted file mode 100644
index 3899178..0000000
--- a/contrib/csharp/embedding/embedding/Program.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Runtime.InteropServices;
-
-namespace embedding
-{
- using org.uscxml;
-
- class Program
- {
- [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
- private static extern void SetDllDirectory(string lpPathName);
-
- static void Main(string[] args)
- {
-
- /*
- * Make sure this path contains the umundoNativeCSharp.dll!
- */
- if (System.Environment.Is64BitProcess)
- {
- SetDllDirectory("C:\\Users\\sradomski\\Desktop\\build\\lib\\csharp64");
- }
- else
- {
- SetDllDirectory("C:\\Users\\sradomski\\Desktop\\build\\lib\\csharp");
- }
-
- Interpreter interpreter = Interpreter.fromXML("<scxml><state id=\"foo\"/></scxml>");
- interpreter.interpret();
- }
- }
-}
diff --git a/contrib/csharp/embedding/embedding/Properties/AssemblyInfo.cs b/contrib/csharp/embedding/embedding/Properties/AssemblyInfo.cs
deleted file mode 100644
index bd9015e..0000000
--- a/contrib/csharp/embedding/embedding/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("embedding")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("embedding")]
-[assembly: AssemblyCopyright("Copyright © 2014")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("0d270ead-e8cf-4cc1-a2c8-fa123e71812c")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/contrib/csharp/embedding/embedding/embedding.csproj b/contrib/csharp/embedding/embedding/embedding.csproj
deleted file mode 100644
index 53e1eed..0000000
--- a/contrib/csharp/embedding/embedding/embedding.csproj
+++ /dev/null
@@ -1,66 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
- <ProductVersion>8.0.30703</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{75E5EE93-513B-45DA-AD50-64C570AAD0C0}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>embedding</RootNamespace>
- <AssemblyName>embedding</AssemblyName>
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
- <TargetFrameworkProfile>Client</TargetFrameworkProfile>
- <FileAlignment>512</FileAlignment>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
- <PlatformTarget>x86</PlatformTarget>
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Debug\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <EnvironmentVariables>
- <EnvironmentVariables>
- <Variable name="DYLD_FALLBACK_LIBRARY_PATH" value="/Users/sradomski/Documents/TK/Code/uscxml/build/cli/lib/csharp" />
- <Variable name="MONO_LOG_LEVEL" value="debug" />
- </EnvironmentVariables>
- </EnvironmentVariables>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
- <PlatformTarget>x86</PlatformTarget>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>bin\Release\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- <Reference Include="System.Core" />
- <Reference Include="System.Xml.Linq" />
- <Reference Include="System.Data.DataSetExtensions" />
- <Reference Include="Microsoft.CSharp" />
- <Reference Include="System.Data" />
- <Reference Include="System.Xml" />
- <Reference Include="uscxmlCSharp">
- <HintPath>..\..\..\..\build\cli\lib\uscxmlCSharp.dll</HintPath>
- </Reference>
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Program.cs" />
- <Compile Include="Properties\AssemblyInfo.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.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project> \ No newline at end of file
diff --git a/contrib/java/.classpath b/contrib/java/.classpath
deleted file mode 100644
index 0830f8a..0000000
--- a/contrib/java/.classpath
+++ /dev/null
@@ -1,10 +0,0 @@
-<?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="output" path="bin"/>
-</classpath>
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/java/src/js.jar b/contrib/java/src/js.jar
deleted file mode 100644
index 6f0dafb..0000000
--- a/contrib/java/src/js.jar
+++ /dev/null
Binary files differ
diff --git a/contrib/java/src/org/uscxml/datamodel/ecmascript/ECMAData.java b/contrib/java/src/org/uscxml/datamodel/ecmascript/ECMAData.java
deleted file mode 100644
index 56d7090..0000000
--- a/contrib/java/src/org/uscxml/datamodel/ecmascript/ECMAData.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package org.uscxml.datamodel.ecmascript;
-
-import org.mozilla.javascript.Scriptable;
-import org.uscxml.Data;
-
-public class ECMAData implements Scriptable {
-
- protected Data data;
- protected Scriptable parent;
- protected Scriptable prototype;
-
- public ECMAData(Data data) {
- this.data = data;
- }
-
- @Override
- public String getClassName() {
- return "Data";
- }
-
- public Object unwrap(Data data) {
- if (data.atom.length() > 0) {
- return data.atom;
- }
- return new ECMAData(data);
-
- }
-
- @Override
- public Object get(String name, Scriptable start) {
- if (data.compound.containsKey(name))
- return unwrap(data.compound.get(name));
- return NOT_FOUND;
- }
-
- @Override
- public Object get(int index, Scriptable start) {
- if (data.array.size() > index)
- return unwrap(data.array.get(index));
- return NOT_FOUND;
- }
-
- @Override
- public boolean has(String name, Scriptable start) {
- return data.compound.containsKey(name);
- }
-
- @Override
- public boolean has(int index, Scriptable start) {
- return data.array.size() > index;
- }
-
- @Override
- public void put(String name, Scriptable start, Object value) {
- }
-
- @Override
- public void put(int index, Scriptable start, Object value) {
- }
-
- @Override
- public void delete(String name) {
- }
-
- @Override
- public void delete(int index) {
- }
-
- @Override
- public Scriptable getPrototype() {
- return prototype;
- }
-
- @Override
- public void setPrototype(Scriptable prototype) {
- this.prototype = prototype;
- }
-
- @Override
- public Scriptable getParentScope() {
- return parent;
- }
-
- @Override
- public void setParentScope(Scriptable parent) {
- this.parent = parent;
- }
-
- @Override
- public Object[] getIds() {
- return data.compound.keySet().toArray();
- }
-
- @Override
- public Object getDefaultValue(Class<?> hint) {
- return "[object Data]";
- }
-
- @Override
- public boolean hasInstance(Scriptable instance) {
- Scriptable proto = instance.getPrototype();
- while (proto != null) {
- if (proto.equals(this))
- return true;
- proto = proto.getPrototype();
- }
- return false;
- }
-
-}
diff --git a/contrib/java/src/org/uscxml/datamodel/ecmascript/ECMAEvent.java b/contrib/java/src/org/uscxml/datamodel/ecmascript/ECMAEvent.java
deleted file mode 100644
index 58fff72..0000000
--- a/contrib/java/src/org/uscxml/datamodel/ecmascript/ECMAEvent.java
+++ /dev/null
@@ -1,126 +0,0 @@
-package org.uscxml.datamodel.ecmascript;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.mozilla.javascript.Scriptable;
-import org.uscxml.Data;
-import org.uscxml.Event;
-import org.uscxml.ParamPair;
-import org.uscxml.ParamPairVector;
-
-public class ECMAEvent implements Scriptable {
-
- protected Event event;
- protected Scriptable parent;
- protected Scriptable prototype;
-
- protected Map<String, Object> members = new HashMap<String, Object>();
-
- public ECMAEvent(Event event) {
- this.event = event;
-
- Data data = new Data(event.getData());
-
- // insert params into event.data
- ParamPairVector ppv = event.getParamPairs();
- for (int i = 0; i < ppv.size(); i++) {
- ParamPair pp = ppv.get(i);
- data.compound.put(pp.getFirst(), new Data(pp.getSecond()));
- }
-
- members.put("type", event.getEventType().toString());
- members.put("data", new ECMAData(data));
- members.put("sendid", event.getSendId());
- members.put("origin", event.getOrigin());
- members.put("originType", event.getOriginType());
- // add others as necessary
-
- }
-
- @Override
- public String getClassName() {
- return "Event";
- }
-
- @Override
- public Object get(String name, Scriptable start) {
- if (members.containsKey(name))
- return members.get(name);
- return NOT_FOUND;
- }
-
- @Override
- public Object get(int index, Scriptable start) {
- return NOT_FOUND;
- }
-
- @Override
- public boolean has(String name, Scriptable start) {
- return (members.containsKey(name));
- }
-
- @Override
- public boolean has(int index, Scriptable start) {
- return false;
- }
-
- @Override
- public void put(String name, Scriptable start, Object value) {
- }
-
- @Override
- public void put(int index, Scriptable start, Object value) {
- }
-
- @Override
- public void delete(String name) {
- }
-
- @Override
- public void delete(int index) {
- }
-
- @Override
- public Scriptable getPrototype() {
- return prototype;
- }
-
- @Override
- public void setPrototype(Scriptable prototype) {
- this.prototype = prototype;
- }
-
- @Override
- public Scriptable getParentScope() {
- return parent;
- }
-
- @Override
- public void setParentScope(Scriptable parent) {
- this.parent = parent;
- }
-
- @Override
- public Object[] getIds() {
- return members.keySet().toArray();
- }
-
- @Override
- public Object getDefaultValue(Class<?> hint) {
- return "[object Event]";
- }
-
- @Override
- public boolean hasInstance(Scriptable instance) {
- Scriptable proto = instance.getPrototype();
- while (proto != null) {
- if (proto.equals(this))
- return true;
- proto = proto.getPrototype();
- }
-
- return false;
- }
-
-}
diff --git a/contrib/java/src/org/uscxml/datamodel/ecmascript/ECMAScriptDataModel.java b/contrib/java/src/org/uscxml/datamodel/ecmascript/ECMAScriptDataModel.java
deleted file mode 100644
index 3d77dc5..0000000
--- a/contrib/java/src/org/uscxml/datamodel/ecmascript/ECMAScriptDataModel.java
+++ /dev/null
@@ -1,396 +0,0 @@
-package org.uscxml.datamodel.ecmascript;
-
-import java.lang.reflect.Method;
-
-import org.mozilla.javascript.Callable;
-import org.mozilla.javascript.Context;
-import org.mozilla.javascript.EvaluatorException;
-import org.mozilla.javascript.FunctionObject;
-import org.mozilla.javascript.NativeJSON;
-import org.mozilla.javascript.Scriptable;
-import org.mozilla.javascript.ScriptableObject;
-import org.mozilla.javascript.Undefined;
-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.StringVector;
-
-public class ECMAScriptDataModel extends JavaDataModel {
-
- public static boolean debug = true;
-
- private class NullCallable implements Callable {
- @Override
- public Object call(Context context, Scriptable scope,
- Scriptable holdable, Object[] objects) {
- return objects[1];
- }
- }
-
- public Context ctx;
- public Scriptable scope;
- public Interpreter interpreter;
-
- public Data getScriptableAsData(Object object) {
- Data data = new Data();
-
- Scriptable s;
- try {
- s = (Scriptable) object;
- String className = s.getClassName(); // ECMA class name
- if (className.toLowerCase().equals("object")) {
- ScriptableObject obj = (ScriptableObject) Context.toObject(s,
- scope);
- for (Object key : obj.getIds()) {
- data.compound.put(Context.toString(key),
- getScriptableAsData(obj.get(key)));
- }
- }
- } catch (ClassCastException e) {
- if (object instanceof Boolean) {
- data.atom = (Context.toBoolean(object) ? "true" : "false");
- data.type = Data.Type.INTERPRETED;
- } else if (object instanceof String) {
- data.atom = (String) object;
- data.type = Data.Type.VERBATIM;
- } else if (object instanceof Integer) {
- data.atom = ((Integer) object).toString();
- data.type = Data.Type.INTERPRETED;
- } else {
- throw new RuntimeException("Unhandled ECMA type "
- + object.getClass().getName());
- }
- }
-
- return data;
- }
-
- public ScriptableObject getDataAsScriptable(Data data) {
- throw new UnsupportedOperationException("Not implemented");
- }
-
- public static boolean jsIn(String stateName) {
- return true;
- }
-
- @Override
- public JavaDataModel create(Interpreter interpreter) {
- /**
- * Called when an SCXML interpreter wants an instance of this datamodel
- * Be careful to instantiate attributes of instance returned and not
- * *this*
- */
-
- ECMAScriptDataModel newDM = new ECMAScriptDataModel();
- newDM.interpreter = interpreter;
- newDM.ctx = Context.enter();
-
- try {
- newDM.scope = newDM.ctx.initStandardObjects();
- } catch (Exception e) {
- System.err.println(e);
- }
-
- newDM.scope.put("_name", newDM.scope, interpreter.getName());
- newDM.scope.put("_sessionid", newDM.scope, interpreter.getSessionId());
-
- // ioProcessors
- {
- Data ioProcs = new Data();
- StringVector keys = interpreter.getIOProcessorKeys();
- for (int i = 0; i < keys.size(); i++) {
- ioProcs.compound.put(keys.get(i), new Data(interpreter
- .getIOProcessors().get(keys.get(i))
- .getDataModelVariables()));
- }
- newDM.scope
- .put("_ioprocessors", newDM.scope, new ECMAData(ioProcs));
- }
-
- // invokers
- {
- Data invokers = new Data();
- StringVector keys = interpreter.getInvokerKeys();
- for (int i = 0; i < keys.size(); i++) {
- invokers.compound.put(keys.get(i), new Data(interpreter
- .getInvokers().get(keys.get(i))
- .getDataModelVariables()));
- }
- newDM.scope
- .put("_ioprocessors", newDM.scope, new ECMAData(invokers));
- }
-
- // In predicate (not working as static is required) see:
- // http://stackoverflow.com/questions/3441947/how-do-i-call-a-method-of-a-java-instance-from-javascript/16479685#16479685
- try {
- Class[] parameters = new Class[] { String.class };
- Method inMethod = ECMAScriptDataModel.class.getMethod("jsIn",
- parameters);
- FunctionObject inFunc = new FunctionObject("In", inMethod,
- newDM.scope);
- newDM.scope.put("In", newDM.scope, inFunc);
- } catch (SecurityException e) {
- System.err.println(e);
- } catch (NoSuchMethodException e) {
- System.err.println(e);
- }
-
- return newDM;
- }
-
- @Override
- public StringSet 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");
- return ss;
- }
-
- @Override
- public boolean validate(String location, String schema) {
- /**
- * Validate the datamodel. This make more sense for XML datamodels and
- * is pretty much unused but required as per draft.
- */
- return true;
- }
-
- @Override
- public void setEvent(Event event) {
- if (debug) {
- System.out.println(interpreter.getName() + " setEvent");
- }
-
- /**
- * Make the current event available as the variable _event in the
- * datamodel.
- */
- ECMAEvent ecmaEvent = new ECMAEvent(event);
- scope.put("_event", scope, ecmaEvent);
- }
-
- @Override
- public DataNative getStringAsData(String content) {
- if (debug) {
- System.out.println(interpreter.getName() + " getStringAsData");
- }
-
- /**
- * Evaluate the string as a value expression and transform it into a
- * JSON-like Data structure
- */
- if (content.length() == 0) {
- return Data.toNative(new Data());
- }
-
- // is it a json expression?
- try {
- Object json = NativeJSON.parse(ctx, scope, content,
- new NullCallable());
- if (json != NativeJSON.NOT_FOUND) {
- return Data.toNative(getScriptableAsData(json));
- }
- } catch (org.mozilla.javascript.EcmaError e) {
- System.err.println(e);
- }
-
- // is it a function call or variable?
- Object x = ctx.evaluateString(scope, content, "uscxml", 0, null);
- if (x == Undefined.instance) {
- // maybe a literal string?
- x = ctx.evaluateString(scope, '"' + content + '"', "uscxml", 0,
- null);
- }
- return Data.toNative(getScriptableAsData(x));
- }
-
- @Override
- public long getLength(String expr) {
- if (debug) {
- System.out.println(interpreter.getName() + " getLength");
- }
-
- /**
- * Return the length of the expression if it were an array, used by
- * foreach element.
- */
-
- Object x = scope.get(expr, scope);
- if (x == Undefined.instance) {
- return 0;
- }
-
- Scriptable result = Context.toObject(x, scope);
- if (result.has("length", result)) {
- return (long) Context.toNumber(result.get("length", result));
- }
- return 0;
- }
-
- @Override
- public void setForeach(String item, String array, String index,
- long iteration) {
- if (debug) {
- System.out.println(interpreter.getName() + " setForeach");
- }
-
- /**
- * Prepare an iteration of the foreach element, by setting the variable
- * in index to the current iteration and setting the variable in item to
- * the current item from array.
- */
-
- try {
- // get the array object
- Scriptable arr = (Scriptable) scope.get(array, scope);
-
- if (arr.has((int) iteration, arr)) {
- ctx.evaluateString(scope, item + '=' + array + '[' + iteration
- + ']', "uscxml", 1, null);
- if (index.length() > 0) {
- ctx.evaluateString(scope, index + '=' + iteration,
- "uscxml", 1, null);
- }
- } else {
- handleException("");
- }
-
- } catch (ClassCastException e) {
- System.err.println(e);
- }
- }
-
- @Override
- public void eval(String scriptElem, String expr) {
- if (debug) {
- System.out.println(interpreter.getName() + " eval");
- }
-
- /**
- * Evaluate the given expression in the datamodel. This is used foremost
- * with script elements.
- */
- ctx.evaluateString(scope, expr, "uscxml", 1, null);
-
- }
-
- @Override
- public String evalAsString(String expr) {
- if (debug) {
- System.out.println(interpreter.getName() + " evalAsString: " + expr);
- }
-
- /**
- * Evaluate the expression as a string e.g. for the log element.
- */
- if (!ctx.stringIsCompilableUnit(expr)) {
- handleException("");
- return "";
- }
- try {
- Object result = ctx.evaluateString(scope, expr, "uscxml", 1, null);
- return Context.toString(result);
- } catch (IllegalStateException e) {
- System.err.println(e);
- handleException("");
- } catch (EvaluatorException e) {
- System.err.println(e);
- handleException("");
- }
- return "";
- }
-
- @Override
- public boolean evalAsBool(String elem, String expr) {
- if (debug) {
- System.out.println(interpreter.getName() + " evalAsBool");
- }
-
- /**
- * Evaluate the expression as a boolean for cond attributes in if and
- * transition elements.
- */
- Object result = ctx.evaluateString(scope, expr, "uscxml", 1, null);
- return Context.toBoolean(result);
- }
-
- @Override
- public boolean isDeclared(String expr) {
- if (debug) {
- System.out.println(interpreter.getName() + " isDeclared");
- }
-
- /**
- * The interpreter is supposed to raise an error if we assign to an
- * undeclared variable. This method is used to check whether a location
- * from assign is declared.
- */
- Object x = scope.get(expr, scope);
- return x != Scriptable.NOT_FOUND;
- }
-
- @Override
- public void init(String dataElem, String location, String content) {
- if (debug) {
- System.out.println(interpreter.getName() + " init");
- }
-
- /**
- * Called when we pass data elements.
- */
- if (("null").equals(location))
- return;
-
- if (("null").equals(content) || content.length() == 0) {
- scope.put(location, scope, Context.getUndefinedValue());
- return;
- }
-
- try {
- Object json = NativeJSON.parse(ctx, scope, content,
- new NullCallable());
- if (json != NativeJSON.NOT_FOUND) {
- scope.put(location, scope, json);
- } else {
- scope.put(location, scope, content);
- }
- } catch (org.mozilla.javascript.EcmaError e) {
- scope.put(location, scope, content);
- }
- }
-
- @Override
- public void assign(String assignElem, String location, String content) {
- if (debug) {
- System.out.println(interpreter.getName() + " assign");
- }
-
- /**
- * Called when we evaluate assign elements
- */
- if (("null").equals(location))
- return;
-
- if (("null").equals(content) || content.length() == 0) {
- scope.put(location, scope, Context.getUndefinedValue());
- return;
- }
-
- String expr = location + "=" + content;
- ctx.evaluateString(scope, expr, "uscxml", 1, null);
- }
-
- public void handleException(String cause) {
- Event exceptionEvent = new Event();
- exceptionEvent.setName("error.execution");
- exceptionEvent.setEventType(Event.Type.PLATFORM);
-
- interpreter.receiveInternal(exceptionEvent);
- }
-}
diff --git a/contrib/java/src/org/uscxml/tests/TestData.java b/contrib/java/src/org/uscxml/tests/TestData.java
deleted file mode 100644
index 44f1ce0..0000000
--- a/contrib/java/src/org/uscxml/tests/TestData.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.uscxml.tests;
-
-import org.uscxml.Data;
-import org.uscxml.DataNative;
-
-public class TestData {
-
- public static void main(String[] args) {
- System.load("/Users/sradomski/Documents/TK/Code/uscxml/build/cli/lib/libuscxmlNativeJava64.jnilib");
- {
- Data data = Data.fromJSON("[1,2,3,4,5]");
- DataNative nData2 = Data.toNative(data);
- Data data2 = new Data(nData2);
- System.out.println(data2);
- }
- {
- Data data = Data.fromJSON("{ \"foo\": \"bar\", \"faz\": 12 }");
- DataNative nData2 = Data.toNative(data);
- Data data2 = new Data(nData2);
- System.out.println(data2);
- }
- }
-}
diff --git a/contrib/java/src/org/uscxml/tests/TestInvoker.java b/contrib/java/src/org/uscxml/tests/TestInvoker.java
deleted file mode 100644
index 7807cda..0000000
--- a/contrib/java/src/org/uscxml/tests/TestInvoker.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package org.uscxml.tests;
-
-import org.uscxml.Data;
-import org.uscxml.DataNative;
-import org.uscxml.Event;
-import org.uscxml.Factory;
-import org.uscxml.Interpreter;
-import org.uscxml.InvokeRequest;
-import org.uscxml.JavaInvoker;
-import org.uscxml.SendRequest;
-import org.uscxml.StringSet;
-
-public class TestInvoker extends JavaInvoker {
-
- @Override
- public StringSet getNames() {
- StringSet ss = new StringSet();
- ss.insert("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 void invoke(InvokeRequest req) {
- System.out.println("invoke");
-
- System.out.println(req.getData());
- System.out.println(req.getXML());
-
- Event ev = new Event();
- ev.setName("foo");
- returnEvent(ev);
- }
-
- @Override
- public JavaInvoker create(Interpreter interpreter) {
- return new TestInvoker();
- }
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- System.load("/Users/sradomski/Documents/TK/Code/uscxml/build/cli/lib/libuscxmlNativeJava64_d.jnilib");
-
- TestInvoker invoker = new TestInvoker();
- Factory.getInstance().registerInvoker(invoker);
-
- Interpreter interpreter = Interpreter
- .fromURI("/Users/sradomski/Documents/TK/Code/uscxml/test/samples/uscxml/test-java-invoker.scxml");
- while (true)
- interpreter.interpret();
- }
-
-}
diff --git a/contrib/java/src/org/uscxml/tests/TestJavaScriptDataModel.java b/contrib/java/src/org/uscxml/tests/TestJavaScriptDataModel.java
deleted file mode 100644
index 7399c94..0000000
--- a/contrib/java/src/org/uscxml/tests/TestJavaScriptDataModel.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.uscxml.tests;
-
-import org.uscxml.Factory;
-import org.uscxml.Interpreter;
-import org.uscxml.datamodel.ecmascript.ECMAScriptDataModel;
-
-public class TestJavaScriptDataModel {
-
- public static void main(String[] args) {
- // load JNI library from build directory
- System.load("/Users/sradomski/Documents/TK/Code/uscxml/build/cli/lib/libuscxmlNativeJava64.jnilib");
-
- // register java datamodel at factory
- ECMAScriptDataModel datamodel = new ECMAScriptDataModel();
- Factory.getInstance().registerDataModel(datamodel);
-
- // instantiate interpreter with document from file
- Interpreter interpreter = Interpreter
- .fromURI("/Users/sradomski/Documents/TK/Code/uscxml/test/uscxml/java/test-ecmascript-datamodel.scxml");
-
- // wait until interpreter has finished
- while (true)
- interpreter.interpret();
- }
-
-}
diff --git a/contrib/java/src/org/uscxml/tests/TestW3CECMA.java b/contrib/java/src/org/uscxml/tests/TestW3CECMA.java
deleted file mode 100644
index 0949701..0000000
--- a/contrib/java/src/org/uscxml/tests/TestW3CECMA.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.uscxml.tests;
-
-import java.io.File;
-
-import org.uscxml.Capabilities;
-import org.uscxml.Factory;
-import org.uscxml.Interpreter;
-import org.uscxml.InterpreterOptions;
-import org.uscxml.datamodel.ecmascript.ECMAScriptDataModel;
-
-public class TestW3CECMA {
-
- public static String testDir = "/Users/sradomski/Documents/TK/Code/uscxml/test/w3c/ecma";
-
- public static void main(String[] args) {
- System.load("/Users/sradomski/Documents/TK/Code/uscxml/build/cli/lib/libuscxmlNativeJava64.jnilib");
-
- ECMAScriptDataModel datamodel = new ECMAScriptDataModel();
- Factory.getInstance().registerDataModel(datamodel);
-
-// while(true) {
-// System.out.println("### test235 #####");
-// Interpreter interpreter = Interpreter.fromURI("/Users/sradomski/Documents/TK/Code/uscxml/test/w3c/ecma/test144.scxml");
-// interpreter.interpret();
-// }
-
- File dir = new File(testDir);
- File[] filesList = dir.listFiles();
- for (File file : filesList) {
- if (file.isFile() && file.getName().endsWith(".scxml")) {
- System.out.println("### " + file.getName() + " #####");
- Interpreter interpreter = Interpreter.fromURI(file.getAbsolutePath());
- interpreter.setCapabilities(1);
- interpreter.interpret();
- }
- }
-
- }
-
-}
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