summaryrefslogtreecommitdiffstats
path: root/src/bindings/swig
diff options
context:
space:
mode:
Diffstat (limited to 'src/bindings/swig')
-rw-r--r--src/bindings/swig/java/JavaDataModel.h61
-rw-r--r--src/bindings/swig/java/uscxml.i11
2 files changed, 65 insertions, 7 deletions
diff --git a/src/bindings/swig/java/JavaDataModel.h b/src/bindings/swig/java/JavaDataModel.h
index 9188cf6..5d76480 100644
--- a/src/bindings/swig/java/JavaDataModel.h
+++ b/src/bindings/swig/java/JavaDataModel.h
@@ -44,7 +44,11 @@ public:
virtual void popContext() {}
virtual void eval(const Arabica::DOM::Element<std::string>& scriptElem,
- const std::string& expr) {}
+ const std::string& expr) {
+ std::ostringstream ssEval;
+ ssEval << scriptElem;
+ eval(ssEval.str(), expr);
+ }
virtual std::string evalAsString(const std::string& expr) {
return "";
@@ -59,14 +63,61 @@ public:
virtual void assign(const Arabica::DOM::Element<std::string>& assignElem,
const Arabica::DOM::Document<std::string>& doc,
- const std::string& content) {}
- virtual void assign(const std::string& location, const Data& data) {}
+ const std::string& content) {
+ // convert XML back into strings
+ std::string location;
+ if (assignElem.hasAttribute("location")) {
+ location = assignElem.getAttribute("location");
+ }
+ std::ostringstream ssAssign;
+ ssAssign << assignElem;
+ std::string tmp;
+ if (doc) {
+ std::ostringstream ssContent;
+ ssContent << doc;
+ tmp = ssContent.str();
+ } else {
+ tmp = content;
+ }
+ assign(location, ssAssign.str(), tmp);
+ }
+
+ virtual void assign(const std::string& location, const Data& data) {
+ init("", location, Data::toJSON(data));
+ }
+
+ // this is assign the function exposed to java
virtual void init(const Arabica::DOM::Element<std::string>& dataElem,
const Arabica::DOM::Document<std::string>& doc,
- const std::string& content) {}
- virtual void init(const std::string& location, const Data& data) {}
+ const std::string& content) {
+ // convert XML back into strings
+ std::string location;
+ if (dataElem.hasAttribute("id")) {
+ location = dataElem.getAttribute("id");
+ }
+ std::ostringstream ssData;
+ if (dataElem)
+ ssData << dataElem;
+ std::string tmp;
+ if (doc) {
+ std::ostringstream ssContent;
+ ssContent << doc;
+ tmp = ssContent.str();
+ } else {
+ tmp = content;
+ }
+ init(location, ssData.str(), tmp);
+ }
+
+ virtual void init(const std::string& location, const Data& data) {
+ init("", location, Data::toJSON(data));
+ }
+ // these functions are exposed to java
+ virtual void init(const std::string& dataElem, const std::string& location, const std::string& content) {}
+ virtual void assign(const std::string& assignElem, const std::string& location, const std::string& content) {}
+ virtual void eval(const std::string& scriptElem, const std::string& expr) {}
};
diff --git a/src/bindings/swig/java/uscxml.i b/src/bindings/swig/java/uscxml.i
index 81ac83e..02ef531 100644
--- a/src/bindings/swig/java/uscxml.i
+++ b/src/bindings/swig/java/uscxml.i
@@ -1,5 +1,8 @@
%module(directors="1", allprotected="1") uscxmlNativeJava
+// provide a macro for the header files
+#define SWIGIMPORTED 1
+
// import swig typemaps
//%include <arrays_java.i>
//%include <inttypes.i>
@@ -12,7 +15,6 @@
%include <boost_shared_ptr.i>
-
typedef uscxml::Data Data;
typedef uscxml::Event Event;
typedef uscxml::InvokeRequest InvokeRequest;
@@ -68,6 +70,12 @@ using namespace uscxml;
%ignore uscxml::JavaInvoker::create(InterpreterImpl*);
%ignore uscxml::JavaDataModel::create(InterpreterImpl*);
+%ignore uscxml::JavaDataModel::init(const Arabica::DOM::Element<std::string>&, const Arabica::DOM::Document<std::string>&, const std::string&);
+%ignore uscxml::JavaDataModel::init(const std::string&, const Data&);
+%ignore uscxml::JavaDataModel::assign(const Arabica::DOM::Element<std::string>&, const Arabica::DOM::Document<std::string>&, const std::string&);
+%ignore uscxml::JavaDataModel::assign(const std::string&, const Data&);
+%ignore uscxml::JavaDataModel::eval(const Arabica::DOM::Element<std::string>&, const std::string&);
+
%template(DataMap) std::map<std::string, uscxml::Data>;
%template(DataList) std::list<uscxml::Data>;
%template(StringSet) std::set<std::string>;
@@ -80,7 +88,6 @@ using namespace uscxml;
// Parse the header file to generate wrappers
//***********************************************
-#define SWIGIMPORTED 1
%include "../../../uscxml/Factory.h"
%include "../../../uscxml/Message.h"
%include "../../../uscxml/Interpreter.h"