diff options
author | Jamie Bullock <jamie@postlude.co.uk> | 2007-09-04 19:07:55 +0000 |
---|---|---|
committer | Jamie Bullock <jamie@postlude.co.uk> | 2007-09-04 19:07:55 +0000 |
commit | 280bf6f6ba2c6ad6d4f470573ca23d72541813c1 (patch) | |
tree | 7c969fa59f5cee115b7a405ad45221d52f9ed1b2 | |
parent | e80ffb5d91cd3e017b5549e912a4e93f7bf03572 (diff) | |
download | LibXtract-280bf6f6ba2c6ad6d4f470573ca23d72541813c1.tar.gz LibXtract-280bf6f6ba2c6ad6d4f470573ca23d72541813c1.tar.bz2 LibXtract-280bf6f6ba2c6ad6d4f470573ca23d72541813c1.zip |
Added basic SWIG wrapper generator (use ./configure --enable-swig etc)
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | Makefile.am | 11 | ||||
-rwxr-xr-x | autogen.sh | 4 | ||||
-rw-r--r-- | bootstrap | 4 | ||||
-rw-r--r-- | configure.in | 34 | ||||
-rw-r--r-- | src/scalar.c | 4 | ||||
-rw-r--r-- | swig/Makefile.am | 18 | ||||
-rw-r--r-- | swig/test.py | 18 | ||||
-rw-r--r-- | swig/xtract.i | 12 |
9 files changed, 99 insertions, 10 deletions
@@ -1,3 +1,7 @@ +2007-09-04 Jamie Bullock <jamie@postlude.co.uk> + * version 0.4.8 + * Added cursory SWIG Python wrapper generator + 2007-04-20 Jamie Bullock <jamie@postlude.co.uk> * version 0.4.7 * Added MSP example diff --git a/Makefile.am b/Makefile.am index 6642025..6f72456 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,14 @@ -MAINTAINERCLEANFILES = Makefile.in configure depcomp compile config.guess ltmain.sh config.sub missing install-sh aclocal.m4 config.h.in config.h.in~ +MAINTAINERCLEANFILES = Makefile.in configure depcomp compile config.guess ltmain.sh config.sub missing install-sh aclocal.m4 config.h.in config.h.in~ py-compile -SUBDIRS = src xtract examples @DOXYGEN@ +if BUILD_SWIG +SWIG_DIR = swig +endif + +SUBDIRS = src xtract examples $(SWIG_DIR) @DOXYGEN@ pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libxtract.pc +ACLOCAL_AMFLAGS = -I m4 + +EXTRA_DIST = bootstrap autogen.sh README TODO @@ -8,11 +8,11 @@ export WANT_AUTOMAKE case `uname -s` in Linux) LIBTOOLIZE=libtoolize - ACLOCALARGS='' + ACLOCALARGS='-I m4' ;; Darwin) LIBTOOLIZE=glibtoolize - ACLOCALARGS='-I /usr/share/aclocal' + ACLOCALARGS='-I /usr/share/aclocal -I m4' ;; *) echo error: unrecognized OS exit 1 diff --git a/bootstrap b/bootstrap new file mode 100644 index 0000000..eff731b --- /dev/null +++ b/bootstrap @@ -0,0 +1,4 @@ +#!/bin/sh + +autoreconf --force --install -I config -I m4 + diff --git a/configure.in b/configure.in index 9c4abbe..285ab37 100644 --- a/configure.in +++ b/configure.in @@ -4,13 +4,13 @@ m4_define(libxtract_major_version, 0) # Increment for feature additions and enhancements m4_define(libxtract_minor_version, 4) # Increment for fixes -m4_define(libxtract_fix_version, 7) +m4_define(libxtract_fix_version, 8) m4_define(libxtract_version, libxtract_major_version.libxtract_minor_version.libxtract_fix_version) PACKAGE=libxtract -AC_INIT(libxtract, libxtract_version, bugs@postlude.co.uk) +AC_INIT(libxtract, libxtract_version, libxtract-devel@lists.sourceforge.net) AC_DEFINE(LIBXTRACT_VERSION, libxtract_version, [LibXtract Version]) AM_INIT_AUTOMAKE($PACKAGE, $LIBXTRACT_VERSION) AM_CONFIG_HEADER(config.h) @@ -64,7 +64,7 @@ AC_ARG_ENABLE(simpletest, # age to 0. XTRACT_SO_VERSION=0:0:0 -CFLAGS="$CFLAGS -pedantic -ansi -Wall -Werror -std=c99 -I/usr/local/include" +CFLAGS="$CFLAGS -pedantic -ansi -fno-strict-aliasing -Wall -std=c99 -I/usr/local/include" LDFLAGS="$LDFLAGS -lm" AC_ARG_WITH(pd_dir, @@ -124,6 +124,7 @@ fi AM_CONDITIONAL(BUILD_PD_EXAMPLE, test "x${pd_example}" = 'xtrue') + dnl Enable debugging (no) AC_ARG_ENABLE(debug, [ --enable-debug[[=value]] compile with debug [[default=no]]], @@ -135,6 +136,25 @@ then CFLAGS="$CFLAGS -O0 -ggdb -g" fi +AC_ARG_ENABLE(swig, + [ --enable-swig Generate swig bindings], + [case "${enableval}" in + yes) swig=true ;; + no) swig=false ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-swig) ;; + esac],[swig=false]) + + +dnl SWIG stuff +if [[ "$swig" = "true" ]] ; then + AC_PROG_SWIG(1.3.21) + AM_PATH_PYTHON + SWIG_PYTHON + AC_DEFINE([BUILD_SWIG], [1], [Build the swig bindings]) +fi + +AM_CONDITIONAL(BUILD_SWIG, test "x${swig}" = 'xtrue') + dnl ------------------------------------------ dnl ---- do some magic to gues the host opsys dnl ---- taken from libvorbis configure.in @@ -212,7 +232,7 @@ AC_SUBST(PD_SOURCES) AC_CONFIG_FILES([doc/documentation.doxygen libxtract.pc]) -AC_OUTPUT(Makefile src/Makefile xtract/Makefile doc/Makefile examples/Makefile examples/puredata/Makefile examples/simpletest/Makefile) +AC_OUTPUT(Makefile src/Makefile xtract/Makefile doc/Makefile examples/Makefile examples/puredata/Makefile examples/simpletest/Makefile swig/Makefile) echo echo "**************************************************************" @@ -240,7 +260,11 @@ if test "$pd_example" = "true"; then else echo "PD external: no" fi - +if test "$swig" == "true"; then + echo "SWIG Python bindings: yes" +else + echo "SWIG Python bindings: no" +fi echo echo "**************************************************************" echo diff --git a/src/scalar.c b/src/scalar.c index 6270869..fef1e6e 100644 --- a/src/scalar.c +++ b/src/scalar.c @@ -39,10 +39,12 @@ int xtract_mean(const float *data, const int N, const void *argv, float *result){ int n = N; + + *result = 0.f; while(n--) *result += data[n]; - + *result /= N; return XTRACT_SUCCESS; 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" |