diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-05-14 12:07:05 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-05-14 12:07:05 (GMT) |
commit | cc580e3c27c45f56193e3add35a8cc00dcd19b31 (patch) | |
tree | 19d4457365ff7c3a9bc0b161d528fee993fffef4 /contrib/java | |
parent | e437da537c85d82e26665837ee7e66a35080eb1e (diff) | |
download | uscxml-cc580e3c27c45f56193e3add35a8cc00dcd19b31.zip uscxml-cc580e3c27c45f56193e3add35a8cc00dcd19b31.tar.gz uscxml-cc580e3c27c45f56193e3add35a8cc00dcd19b31.tar.bz2 |
Fixed some bugs with java bindings
Diffstat (limited to 'contrib/java')
-rw-r--r-- | contrib/java/src/org/uscxml/datamodel/ecmascript/ECMAScriptDataModel.java | 31 | ||||
-rw-r--r-- | contrib/java/src/org/uscxml/tests/TestW3CECMA.java | 13 |
2 files changed, 19 insertions, 25 deletions
diff --git a/contrib/java/src/org/uscxml/datamodel/ecmascript/ECMAScriptDataModel.java b/contrib/java/src/org/uscxml/datamodel/ecmascript/ECMAScriptDataModel.java index e3f4f2c..ba4319f 100644 --- a/contrib/java/src/org/uscxml/datamodel/ecmascript/ECMAScriptDataModel.java +++ b/contrib/java/src/org/uscxml/datamodel/ecmascript/ECMAScriptDataModel.java @@ -3,7 +3,6 @@ package org.uscxml.datamodel.ecmascript; import org.mozilla.javascript.Callable; import org.mozilla.javascript.Context; import org.mozilla.javascript.NativeJSON; -import org.mozilla.javascript.NativeJavaObject; import org.mozilla.javascript.Scriptable; import org.mozilla.javascript.ScriptableObject; import org.mozilla.javascript.Undefined; @@ -13,6 +12,7 @@ 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 { @@ -34,7 +34,6 @@ public class ECMAScriptDataModel extends JavaDataModel { try { s = (Scriptable) object; String className = s.getClassName(); // ECMA class name -// System.out.println("Scriptable: " + className); if (className.toLowerCase().equals("object")) { ScriptableObject obj = (ScriptableObject) Context.toObject(s, scope); @@ -63,7 +62,6 @@ public class ECMAScriptDataModel extends JavaDataModel { } public ScriptableObject getDataAsScriptable(Data data) { - // TODO! throw new UnsupportedOperationException("Not implemented"); } @@ -75,12 +73,17 @@ public class ECMAScriptDataModel extends JavaDataModel { * *this* */ ECMAScriptDataModel newDM = new ECMAScriptDataModel(); - newDM.ctx = Context.enter(); + + 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())); + } + try { newDM.scope = newDM.ctx.initStandardObjects(); -// ScriptableObject.defineClass(newDM.scope, ECMAEvent.class); -// ScriptableObject.defineClass(newDM.scope, ECMAEventScriptable.class); + newDM.scope.put("_ioprocessors", newDM.scope, new ECMAData(ioProcs)); } catch (Exception e) { System.err.println(e); } @@ -114,21 +117,7 @@ public class ECMAScriptDataModel extends JavaDataModel { * Make the current event available as the variable _event in the * datamodel. */ - - Data data = new Data(event.getData()); - -// Object[] args = { event }; -// Scriptable ecmaEvent = ctx.newObject(scope, "Event", args); - -// ECMAEvent ecmaEvent = new ECMAEvent(event); -// NativeJavaObject njo = new NativeJavaObject(scope, ecmaEvent, ECMAEvent.class, true); - - ECMAEvent ecmaEvent = new ECMAEvent(event); - -// for (Object key : ecmaEvent.getIds()) { -// System.out.println(key); -// } - + ECMAEvent ecmaEvent = new ECMAEvent(event); scope.put("_event", scope, ecmaEvent); } diff --git a/contrib/java/src/org/uscxml/tests/TestW3CECMA.java b/contrib/java/src/org/uscxml/tests/TestW3CECMA.java index 4c77a11..9cedee0 100644 --- a/contrib/java/src/org/uscxml/tests/TestW3CECMA.java +++ b/contrib/java/src/org/uscxml/tests/TestW3CECMA.java @@ -2,8 +2,10 @@ 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 { @@ -16,16 +18,19 @@ public class TestW3CECMA { ECMAScriptDataModel datamodel = new ECMAScriptDataModel(); Factory.getInstance().registerDataModel(datamodel); -// Interpreter interpreter = Interpreter.fromURI("/Users/sradomski/Documents/TK/Code/uscxml/test/w3c/ecma/test176.scxml"); -// interpreter.interpret(); -// System.exit(0); - +// while(true) { +// System.out.println("### test235 #####"); +// Interpreter interpreter = Interpreter.fromURI("/Users/sradomski/Documents/TK/Code/uscxml/test/w3c/ecma/test235.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(); } } |