diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-06-23 23:38:20 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-06-23 23:38:20 (GMT) |
commit | febde41c4c69d8f38967d5c195328d468834d037 (patch) | |
tree | 4580a433d410e91a6f8df9203c20693e7a21128d /src/bindings/swig/java | |
parent | eb6e9807cdb43b408de45ae789916cdf3bebe6f0 (diff) | |
download | uscxml-febde41c4c69d8f38967d5c195328d468834d037.zip uscxml-febde41c4c69d8f38967d5c195328d468834d037.tar.gz uscxml-febde41c4c69d8f38967d5c195328d468834d037.tar.bz2 |
Updated tests for IRP and work on bindings
Diffstat (limited to 'src/bindings/swig/java')
-rw-r--r-- | src/bindings/swig/java/JavaDataModel.cpp | 8 | ||||
-rw-r--r-- | src/bindings/swig/java/JavaDataModel.h | 141 | ||||
-rw-r--r-- | src/bindings/swig/java/JavaInvoker.cpp | 8 | ||||
-rw-r--r-- | src/bindings/swig/java/JavaInvoker.h | 39 | ||||
-rw-r--r-- | src/bindings/swig/java/org/uscxml/Data.java | 2 | ||||
-rw-r--r-- | src/bindings/swig/java/stl_list.i | 49 | ||||
-rw-r--r-- | src/bindings/swig/java/stl_set.i | 73 | ||||
-rw-r--r-- | src/bindings/swig/java/uscxml.i | 43 |
8 files changed, 19 insertions, 344 deletions
diff --git a/src/bindings/swig/java/JavaDataModel.cpp b/src/bindings/swig/java/JavaDataModel.cpp deleted file mode 100644 index 896794b..0000000 --- a/src/bindings/swig/java/JavaDataModel.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "JavaDataModel.h" - -namespace uscxml { - -JavaDataModel::JavaDataModel() {} -JavaDataModel::~JavaDataModel() {} - -}
\ No newline at end of file diff --git a/src/bindings/swig/java/JavaDataModel.h b/src/bindings/swig/java/JavaDataModel.h deleted file mode 100644 index 5da0cda..0000000 --- a/src/bindings/swig/java/JavaDataModel.h +++ /dev/null @@ -1,141 +0,0 @@ -#ifndef JAVADataModel_H_7U446XJQ -#define JAVADataModel_H_7U446XJQ - -#include "../../../uscxml/Message.h" -#include "../../../uscxml/Factory.h" -#include "../../../uscxml/Interpreter.h" - -namespace uscxml { - -class JavaDataModel : public DataModelImpl { -public: - JavaDataModel(); - virtual ~JavaDataModel(); - - virtual JavaDataModel* create(const Interpreter& interpreter) { - return new JavaDataModel(); - } - - virtual boost::shared_ptr<DataModelImpl> create(InterpreterImpl* interpreter) { - _interpreter = interpreter->shared_from_this(); - return boost::shared_ptr<DataModelImpl>(create(_interpreter)); - } - virtual std::list<std::string> getNames() { - return std::list<std::string>(); - }; - - virtual bool validate(const std::string& location, const std::string& schema) { - return true; - } - virtual void setEvent(const Event& event) {} - virtual Data getStringAsData(const std::string& content) { - Data data; - return data; - } - - // foreach - virtual uint32_t getLength(const std::string& expr) { - return 0; - } - virtual void setForeach(const std::string& item, - const std::string& array, - const std::string& index, - uint32_t iteration) {} - virtual void pushContext() {} - virtual void popContext() {} - - virtual void eval(const Arabica::DOM::Element<std::string>& scriptElem, - const std::string& expr) { - std::ostringstream ssEval; - ssEval << scriptElem; - eval(ssEval.str(), expr); - } - - virtual std::string evalAsString(const std::string& expr) { - return ""; - } - virtual bool evalAsBool(const std::string& expr) { - return evalAsBool("", expr); - } - - virtual bool evalAsBool(const Arabica::DOM::Node<std::string>& node, const std::string& expr) { - std::ostringstream ssNode; - ssNode << node; - return evalAsBool(ssNode.str(), expr); - } - - virtual bool isDeclared(const std::string& expr) { - return false; - } - - virtual void assign(const Arabica::DOM::Element<std::string>& assignElem, - const Arabica::DOM::Node<std::string>& node, - 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 (node) { - std::ostringstream ssContent; - ssContent << node; - tmp = ssContent.str(); - } else if (assignElem.hasAttribute("expr")) { - tmp = assignElem.getAttribute("expr"); - } else { - tmp = content; - } - assign(ssAssign.str(), location, 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::Node<std::string>& node, - 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 (node) { - std::ostringstream ssContent; - ssContent << node; - tmp = ssContent.str(); - } else if (dataElem.hasAttribute("expr")) { - tmp = dataElem.getAttribute("expr"); - } else { - tmp = content; - } - init(ssData.str(), location, tmp); - } - - virtual void init(const std::string& location, const Data& data) { - init("", location, Data::toJSON(data)); - } - - // these functions are exposed to java - virtual bool evalAsBool(const std::string& elem, const std::string& content) { return false; } - 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) {} - -private: - Interpreter _interpreter; -}; - -} - -#endif /* end of include guard: JAVADataModel_H_7U446XJQ */ diff --git a/src/bindings/swig/java/JavaInvoker.cpp b/src/bindings/swig/java/JavaInvoker.cpp deleted file mode 100644 index e1c6a31..0000000 --- a/src/bindings/swig/java/JavaInvoker.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "JavaInvoker.h" - -namespace uscxml { - -JavaInvoker::JavaInvoker() {} -JavaInvoker::~JavaInvoker() {} - -}
\ No newline at end of file diff --git a/src/bindings/swig/java/JavaInvoker.h b/src/bindings/swig/java/JavaInvoker.h deleted file mode 100644 index 8994ab5..0000000 --- a/src/bindings/swig/java/JavaInvoker.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef JAVAINVOKER_H_WDV9B5F6 -#define JAVAINVOKER_H_WDV9B5F6 - -#include "../../../uscxml/Message.h" -#include "../../../uscxml/Factory.h" -#include "../../../uscxml/Interpreter.h" - -namespace uscxml { - -class JavaInvoker : public InvokerImpl { -public: - JavaInvoker(); - virtual ~JavaInvoker(); - - virtual std::list<std::string> getNames() { - return std::list<std::string>(); - }; - - virtual Data getDataModelVariables() { - Data data; - return data; - } - - virtual void send(const SendRequest& req) {} - virtual void invoke(const InvokeRequest& req) {} - - virtual JavaInvoker* create(Interpreter interpreter) { - return new JavaInvoker(); - } - - virtual boost::shared_ptr<InvokerImpl> create(InterpreterImpl* interpreter) { - return boost::shared_ptr<InvokerImpl>(create(interpreter->shared_from_this())); - } - -}; - -} - -#endif /* end of include guard: JAVAINVOKER_H_WDV9B5F6 */ diff --git a/src/bindings/swig/java/org/uscxml/Data.java b/src/bindings/swig/java/org/uscxml/Data.java index fdd7448..7781f47 100644 --- a/src/bindings/swig/java/org/uscxml/Data.java +++ b/src/bindings/swig/java/org/uscxml/Data.java @@ -80,7 +80,7 @@ public class Data { if (data.type == Type.INTERPRETED) { nativeData.setType(DataNative.Type.INTERPRETED); } else { - nativeData.setType(DataNative.Type.VERBATIM); + nativeData.setType(DataNative.Type.VERBATIM); } } return nativeData; diff --git a/src/bindings/swig/java/stl_list.i b/src/bindings/swig/java/stl_list.i deleted file mode 100644 index aabd448..0000000 --- a/src/bindings/swig/java/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/java/stl_set.i b/src/bindings/swig/java/stl_set.i deleted file mode 100644 index d009a7b..0000000 --- a/src/bindings/swig/java/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/java/uscxml.i b/src/bindings/swig/java/uscxml.i index 5dac9d2..f72084e 100644 --- a/src/bindings/swig/java/uscxml.i +++ b/src/bindings/swig/java/uscxml.i @@ -9,10 +9,10 @@ %include <stl.i> %include <std_map.i> -%include "std_string.i" +%include <std_string.i> %include <inttypes.i> -%include "stl_set.i" -%include "stl_list.i" +%include "../stl_set.i" +%include "../stl_list.i" %include <boost_shared_ptr.i> @@ -59,14 +59,14 @@ typedef uscxml::SendRequest SendRequest; //#include <DOM/Attr.hpp> //#include <DOM/Text.hpp> -#include "JavaInvoker.h" -#include "JavaDataModel.h" +#include "../wrapped/WrappedInvoker.h" +#include "../wrapped/WrappedDataModel.h" using namespace uscxml; using namespace Arabica::DOM; -#include "JavaInvoker.cpp" -#include "JavaDataModel.cpp" +#include "../wrapped/WrappedInvoker.cpp" +#include "../wrapped/WrappedDataModel.cpp" %} @@ -78,14 +78,14 @@ using namespace Arabica::DOM; %ignore uscxml::Interpreter::getDelayQueue(); -%ignore uscxml::JavaInvoker::create(InterpreterImpl*); +%ignore uscxml::WrappedInvoker::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&); +%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; @@ -104,16 +104,9 @@ using namespace Arabica::DOM; %template(InvokerMap) std::map<std::string, uscxml::Invoker>; %rename Data DataNative; -# %typemap(jstype) uscxml::Data "Data" -# %typemap(javaout) uscxml::Data { -# return new Data(new DataNative($jnicall, $owner)); -# } -# %typemap(javadirectorin) uscxml::Data "new Data($jniinput)" -# %typemap(javadirectorout) uscxml::Data "new Data($jniinput)" - -%feature("director") uscxml::JavaInvoker; -%feature("director") uscxml::JavaDataModel; +%feature("director") uscxml::WrappedInvoker; +%feature("director") uscxml::WrappedDataModel; // translate param multimap to Map<String, List<Data> > %rename(getParamsNative) uscxml::Event::getParams(); @@ -184,8 +177,8 @@ using namespace Arabica::DOM; # %include <DOM/Attr.hpp> # %include <DOM/Text.hpp> -%include "JavaInvoker.h" -%include "JavaDataModel.h" +%include "../wrapped/WrappedInvoker.h" +%include "../wrapped/WrappedDataModel.h" # %template(XMLDocument) Arabica::DOM::Document<std::string>; # %template(XMLNode) Arabica::DOM::Node<std::string>; |