aboutsummaryrefslogtreecommitdiff
path: root/swig/python
diff options
context:
space:
mode:
Diffstat (limited to 'swig/python')
-rw-r--r--swig/python/Makefile.am18
-rw-r--r--swig/python/test.py15
-rw-r--r--swig/python/xtract.i12
3 files changed, 45 insertions, 0 deletions
diff --git a/swig/python/Makefile.am b/swig/python/Makefile.am
new file mode 100644
index 0000000..e9b6747
--- /dev/null
+++ b/swig/python/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 = $(top_srcdir)/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/python/test.py b/swig/python/test.py
new file mode 100644
index 0000000..f491a39
--- /dev/null
+++ b/swig/python/test.py
@@ -0,0 +1,15 @@
+#!/usr/bin/python
+
+import xtract
+
+len = 5
+
+a = xtract.floatArray(len)
+
+for i in range(0, len):
+ a[i] = 2 * i
+
+retval,result = xtract.xtract_mean(a,len,None)
+
+print result
+
diff --git a/swig/python/xtract.i b/swig/python/xtract.i
new file mode 100644
index 0000000..b363f2e
--- /dev/null
+++ b/swig/python/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"