aboutsummaryrefslogtreecommitdiff
path: root/swig
diff options
context:
space:
mode:
authorJamie Bullock <jamie@postlude.co.uk>2007-09-04 19:07:55 +0000
committerJamie Bullock <jamie@postlude.co.uk>2007-09-04 19:07:55 +0000
commit280bf6f6ba2c6ad6d4f470573ca23d72541813c1 (patch)
tree7c969fa59f5cee115b7a405ad45221d52f9ed1b2 /swig
parente80ffb5d91cd3e017b5549e912a4e93f7bf03572 (diff)
downloadLibXtract-280bf6f6ba2c6ad6d4f470573ca23d72541813c1.tar.gz
LibXtract-280bf6f6ba2c6ad6d4f470573ca23d72541813c1.tar.bz2
LibXtract-280bf6f6ba2c6ad6d4f470573ca23d72541813c1.zip
Added basic SWIG wrapper generator (use ./configure --enable-swig etc)
Diffstat (limited to 'swig')
-rw-r--r--swig/Makefile.am18
-rw-r--r--swig/test.py18
-rw-r--r--swig/xtract.i12
3 files changed, 48 insertions, 0 deletions
diff --git a/swig/Makefile.am b/swig/Makefile.am
new file mode 100644
index 0000000..6214909
--- /dev/null
+++ b/swig/Makefile.am
@@ -0,0 +1,18 @@
+MAINTAINERCLEANFILES = xtract.py xtract_wrap.c Makefile.in _xtract.so
+
+BUILT_SOURCES = $(srcdir)/xtract_wrap.c
+SWIG_SOURCES = xtract.i
+
+pkgpython_PYTHON = xtract.py
+pkgpyexec_LTLIBRARIES = _xtract.la
+_xtract_la_SOURCES = $(srcdir)/xtract_wrap.c $(SWIG_SOURCES)
+_xtract_la_CFLAGS = $(SWIG_PYTHON_CPPFLAGS) -I$(top_srcdir)/src
+_xtract_la_LDFLAGS = -module -lxtract
+_xtract_la_LIBADD = ../src/libxtract.la
+
+xtract_wrap.c : $(SWIG_SOURCES)
+ $(SWIG) $(SWIG_PYTHON_OPT) -I$(top_srcdir) -o $@ $<
+
+clean-local:
+ -rm -f _xtract.so xtract.py xtract_wrap.c xtract.pyc
+
diff --git a/swig/test.py b/swig/test.py
new file mode 100644
index 0000000..e98755d
--- /dev/null
+++ b/swig/test.py
@@ -0,0 +1,18 @@
+#!/usr/bin/python
+
+import xtract
+
+len = 5
+
+a = xtract.new_floatArray(len)
+
+for i in range(0, len):
+ xtract.floatArray_setitem(a, i, 2*i)
+
+retval,result = xtract.xtract_mean(a,len,None)
+
+print result
+
+
+
+
diff --git a/swig/xtract.i b/swig/xtract.i
new file mode 100644
index 0000000..b363f2e
--- /dev/null
+++ b/swig/xtract.i
@@ -0,0 +1,12 @@
+%module xtract
+%include carrays.i
+%include typemaps.i
+
+%{
+#include "xtract/xtract_scalar.h"
+%}
+
+%array_functions(float, floatArray);
+%apply float *OUTPUT { float *result };
+
+%include "xtract/xtract_scalar.h"