From 422dedee98e956a7f4cffa69a4ba0a34716dec7f Mon Sep 17 00:00:00 2001 From: Stefan Radomski Date: Tue, 13 Aug 2013 14:38:26 +0200 Subject: Polished java datamodel example --- .../java/src/org/uscxml/tests/TestDataModel.java | 11 +++++-- src/bindings/swig/java/uscxml.i | 3 +- src/bindings/swig/php/uscxml.i | 1 + src/bindings/swig/php/uscxmlNativePHP.php | 36 +++------------------- test/src/scxml-test-framework-client.cpp | 2 +- 5 files changed, 16 insertions(+), 37 deletions(-) diff --git a/contrib/java/src/org/uscxml/tests/TestDataModel.java b/contrib/java/src/org/uscxml/tests/TestDataModel.java index e3c8d7a..0721501 100644 --- a/contrib/java/src/org/uscxml/tests/TestDataModel.java +++ b/contrib/java/src/org/uscxml/tests/TestDataModel.java @@ -17,7 +17,7 @@ public class TestDataModel extends JavaDataModel { @Override public JavaDataModel create(Interpreter interpreter) { /** - * An SCXML interpreter wants an instance of this datamodel + * Called when an SCXML interpreter wants an instance of this datamodel */ System.out.println("create"); return new TestDataModel(); @@ -27,7 +27,7 @@ public class TestDataModel extends JavaDataModel { public StringSet getNames() { /** * Register with the following names for the datamodel attribute - * at the scxml element. + * at the scxml element. */ System.out.println("getNames"); StringSet ss = new StringSet(); @@ -48,7 +48,7 @@ public class TestDataModel extends JavaDataModel { @Override public void setEvent(Event event) { /** - * Make the event available as the variable _event + * Make the current event available as the variable _event * in the datamodel. */ System.out.println("setEvent " + event); @@ -144,12 +144,17 @@ public class TestDataModel extends JavaDataModel { * @param args */ public static void main(String[] args) { + // load JNI library from build directory System.load("/Users/sradomski/Documents/TK/Code/uscxml/build/cli/lib/libuscxmlNativeJava64_d.jnilib"); + // register java datamodel at factory TestDataModel datamodel = new TestDataModel(); Factory.getInstance().registerDataModel(datamodel); + // instantiate interpreter with document from file Interpreter interpreter = Interpreter.fromURI("/Users/sradomski/Documents/TK/Code/uscxml/test/samples/uscxml/test-java-datamodel.scxml"); + + // wait until interpreter has finished while(true) interpreter.interpret(); } diff --git a/src/bindings/swig/java/uscxml.i b/src/bindings/swig/java/uscxml.i index 02ef531..7f496cd 100644 --- a/src/bindings/swig/java/uscxml.i +++ b/src/bindings/swig/java/uscxml.i @@ -38,6 +38,7 @@ typedef uscxml::SendRequest SendRequest; %ignore operator std::list; %ignore operator std::string; %ignore operator std::map; +%ignore operator<<; //************************************************** @@ -59,8 +60,6 @@ using namespace uscxml; %} -%rename(toString) operator<<; - %ignore uscxml::NumAttr; %ignore uscxml::SCXMLParser; %ignore uscxml::InterpreterImpl; diff --git a/src/bindings/swig/php/uscxml.i b/src/bindings/swig/php/uscxml.i index 8500bfe..fb7d370 100644 --- a/src/bindings/swig/php/uscxml.i +++ b/src/bindings/swig/php/uscxml.i @@ -19,6 +19,7 @@ %ignore operator std::list; %ignore operator std::string; %ignore operator std::map; +%ignore operator<<; %template(StringMap) std::map; %template(StringVector) std::vector; diff --git a/src/bindings/swig/php/uscxmlNativePHP.php b/src/bindings/swig/php/uscxmlNativePHP.php index 08fc515..ce52045 100644 --- a/src/bindings/swig/php/uscxmlNativePHP.php +++ b/src/bindings/swig/php/uscxmlNativePHP.php @@ -391,12 +391,12 @@ class Event { Event_setName($this->_cPtr,$name); } - function getType() { - return Event_getType($this->_cPtr); + function getEventType() { + return Event_getEventType($this->_cPtr); } - function setType($type) { - Event_setType($this->_cPtr,$type); + function setEventType($type) { + Event_setEventType($this->_cPtr,$type); } function getOrigin() { @@ -517,34 +517,8 @@ class Event { return $r; } - function getNameListKeys() { - $r=Event_getNameListKeys($this->_cPtr); - if (is_resource($r)) { - $c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3)); - if (class_exists($c)) return new $c($r); - return new StringVector($r); - } - return $r; - } - function getParams() { - $r=Event_getParams($this->_cPtr); - if (is_resource($r)) { - $c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3)); - if (class_exists($c)) return new $c($r); - return new Params($r); - } - return $r; - } - - function getParamKeys() { - $r=Event_getParamKeys($this->_cPtr); - if (is_resource($r)) { - $c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3)); - if (class_exists($c)) return new $c($r); - return new StringVector($r); - } - return $r; + return Event_getParams($this->_cPtr); } } diff --git a/test/src/scxml-test-framework-client.cpp b/test/src/scxml-test-framework-client.cpp index 8fbdf75..6c50f07 100644 --- a/test/src/scxml-test-framework-client.cpp +++ b/test/src/scxml-test-framework-client.cpp @@ -152,7 +152,7 @@ public: std::string token = jsonReq.compound["event"].compound["sessionToken"].atom; assert(_interpreters.find(token) != _interpreters.end()); uscxml::Event event; - event.type = uscxml::Event::INTERNAL; + event.eventType = uscxml::Event::INTERNAL; event.name = jsonReq.compound["event"].compound["name"].atom; std::cout << "Sending event " << event << std::endl; // evhttp_request_free(_interpreters[token].second); -- cgit v0.12