summaryrefslogtreecommitdiffstats
path: root/src/bindings
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-08-09 15:05:52 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-08-09 15:05:52 (GMT)
commit6dce9df7f483f3229bb2f34f0386ce37a1551e07 (patch)
tree1d3acaec4612d74ee3234c808df7ae5fa3b4ef9f /src/bindings
parent01f8198f8b548e3f28cad1a441ceb8af6ea850a4 (diff)
downloaduscxml-6dce9df7f483f3229bb2f34f0386ce37a1551e07.zip
uscxml-6dce9df7f483f3229bb2f34f0386ce37a1551e07.tar.gz
uscxml-6dce9df7f483f3229bb2f34f0386ce37a1551e07.tar.bz2
Extended Java bindings and OpenAL invoker
Diffstat (limited to 'src/bindings')
-rw-r--r--src/bindings/swig/java/JavaInvoker.cpp8
-rw-r--r--src/bindings/swig/java/JavaInvoker.h39
-rw-r--r--src/bindings/swig/java/stl_list.i49
-rw-r--r--src/bindings/swig/java/stl_set.i73
-rw-r--r--src/bindings/swig/java/uscxml.i29
-rw-r--r--src/bindings/swig/php/uscxmlNativePHP.php14
6 files changed, 209 insertions, 3 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"
diff --git a/src/bindings/swig/php/uscxmlNativePHP.php b/src/bindings/swig/php/uscxmlNativePHP.php
index ef37b94..08fc515 100644
--- a/src/bindings/swig/php/uscxmlNativePHP.php
+++ b/src/bindings/swig/php/uscxmlNativePHP.php
@@ -306,8 +306,8 @@ class Data {
return Data_toXMLString($this->_cPtr);
}
- function getCompund() {
- return Data_getCompund($this->_cPtr);
+ function getCompound() {
+ return Data_getCompound($this->_cPtr);
}
function setCompound($compound) {
@@ -357,8 +357,8 @@ class Event {
}
function __get($var) {
- if ($var === 'data') return new Data(Event_data_get($this->_cPtr));
if ($var === 'namelist') return new StringMap(Event_namelist_get($this->_cPtr));
+ if ($var === 'data') return new Data(Event_data_get($this->_cPtr));
$func = 'Event_'.$var.'_get';
if (function_exists($func)) return call_user_func($func,$this->_cPtr);
if ($var === 'thisown') return swig_uscxmlNativePHP_get_newobject($this->_cPtr);
@@ -447,6 +447,14 @@ class Event {
Event_setContent($this->_cPtr,$content);
}
+ function getXML() {
+ return Event_getXML($this->_cPtr);
+ }
+
+ function setXML($xml) {
+ Event_setXML($this->_cPtr,$xml);
+ }
+
function getSendId() {
return Event_getSendId($this->_cPtr);
}