diff options
Diffstat (limited to 'src/bindings/swig/java')
-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/stl_list.i | 49 | ||||
-rw-r--r-- | src/bindings/swig/java/stl_set.i | 73 | ||||
-rw-r--r-- | src/bindings/swig/java/uscxml.i | 29 |
5 files changed, 198 insertions, 0 deletions
diff --git a/src/bindings/swig/java/JavaInvoker.cpp b/src/bindings/swig/java/JavaInvoker.cpp new file mode 100644 index 0000000..c10ae6d --- /dev/null +++ b/src/bindings/swig/java/JavaInvoker.cpp @@ -0,0 +1,8 @@ +#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 new file mode 100644 index 0000000..0a13176 --- /dev/null +++ b/src/bindings/swig/java/JavaInvoker.h @@ -0,0 +1,39 @@ +#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::set<std::string> getNames() { + return std::set<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/stl_list.i b/src/bindings/swig/java/stl_list.i new file mode 100644 index 0000000..aabd448 --- /dev/null +++ b/src/bindings/swig/java/stl_list.i @@ -0,0 +1,49 @@ +/* ----------------------------------------------------------------------------- + * 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 new file mode 100644 index 0000000..d009a7b --- /dev/null +++ b/src/bindings/swig/java/stl_set.i @@ -0,0 +1,73 @@ +/*========================================================================= + + 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 ee7133c..af979d0 100644 --- a/src/bindings/swig/java/uscxml.i +++ b/src/bindings/swig/java/uscxml.i @@ -3,8 +3,21 @@ // import swig typemaps //%include <arrays_java.i> //%include <inttypes.i> + +%include <stl.i> +%include <std_map.i> +%include <inttypes.i> +%include "stl_set.i" +%include "stl_list.i" + %include <boost_shared_ptr.i> + +typedef uscxml::Data Data; +typedef uscxml::Event Event; +typedef uscxml::InvokeRequest InvokeRequest; +typedef uscxml::SendRequest SendRequest; + // disable warning related to unknown base class #pragma SWIG nowarn=401 //%ignore boost::enable_shared_from_this; @@ -32,10 +45,14 @@ %{ #include "../../../uscxml/Message.h" +#include "../../../uscxml/Factory.h" #include "../../../uscxml/Interpreter.h" +#include "JavaInvoker.h" using namespace uscxml; +#include "JavaInvoker.cpp" + %} %rename(toString) operator<<; @@ -46,10 +63,22 @@ using namespace uscxml; %ignore uscxml::Interpreter::getDelayQueue(); +%ignore uscxml::JavaInvoker::create(InterpreterImpl*); + +%template(DataMap) std::map<std::string, uscxml::Data>; +%template(DataList) std::list<uscxml::Data>; +%template(StringSet) std::set<std::string>; + + +%feature("director") uscxml::JavaInvoker; + //*********************************************** // Parse the header file to generate wrappers //*********************************************** +#define SWIGIMPORTED 1 +%include "../../../uscxml/Factory.h" %include "../../../uscxml/Message.h" %include "../../../uscxml/Interpreter.h" +%include "JavaInvoker.h" |