From 95e571251050e5c2523504a79ee201f7d72ac3fe Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 14 Dec 2007 12:40:39 +0000 Subject: [PATCH] stuff --- ChangeLog | 1 + include/vips/VImage.h | 6 +++++- python/vipsCC/Makefile.am | 13 ++++++------- python/vipsCC/VImage.i | 18 +++++++++++++++--- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index bf4f0f95..73281c1e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 12/12/07 started 7.13.3 - added "include " to VImage.cc to help gcc 4.3 +- started moving the python binding to dynamic wrapping 31/10/07 started 7.13.2 - build cimg on windows fixes diff --git a/include/vips/VImage.h b/include/vips/VImage.h index 3444f2fa..5ee2b3bf 100644 --- a/include/vips/VImage.h +++ b/include/vips/VImage.h @@ -238,9 +238,13 @@ public: void initdesc( int, int, int, TBandFmt, TCoding, TType, float = 1.0, float = 1.0, int = 0, int = 0 ) throw( VError ); +/* Bindings wrap databased operations at runtime using reflection. + */ +#ifndef SWIG /* Insert automatically generated headers. */ #include "vipsc++.h" +#endif /*SWIG*/ /* No point getting SWIG to wrap these ... we do this by hand later so we can * handle things like "a + 12" correctly. @@ -389,7 +393,7 @@ public: VIPS_NAMESPACE_END -// Other VIPS protos +// Other VIPS protos we need extern "C" { extern int im_init_world( const char *argv0 ); extern void im__print_all(); diff --git a/python/vipsCC/Makefile.am b/python/vipsCC/Makefile.am index 80e0b39b..b4c3d3d4 100644 --- a/python/vipsCC/Makefile.am +++ b/python/vipsCC/Makefile.am @@ -1,3 +1,5 @@ + + INCLUDES = -I${top_srcdir}/include @VIPS_CFLAGS@ @VIPS_INCLUDES@ @PYTHON_INCLUDES@ # we install to a directory inside the python area, since we are a module @@ -5,18 +7,15 @@ vipsccdir = $(pyexecdir)/vipsCC vipscc_PYTHON = VImage.py VDisplay.py VError.py VMask.py __init__.py -# need an expanded VImage.h ... SWIG's preprocessor b0rks on includes inside -# class definitions +# I tried making a suffix rule for this (and defining SUFFIXES) but I couldn;t +# get it to work, how annoying +# FIXME at some point vimagemodule.cxx: VImage.i - cpp -DSWIG -E $(top_srcdir)/include/vips/VImage.h > VImage.h swig -python -c++ -interface $(@:.cxx=) -I$(top_srcdir)/include -o $@ $< - vdisplaymodule.cxx: VDisplay.i swig -python -c++ -interface $(@:.cxx=) -I$(top_srcdir)/include -o $@ $< - verrormodule.cxx: VError.i swig -python -c++ -interface $(@:.cxx=) -I$(top_srcdir)/include -o $@ $< - vmaskmodule.cxx: VMask.i swig -python -c++ -interface $(@:.cxx=) -I$(top_srcdir)/include -o $@ $< @@ -39,7 +38,7 @@ vmaskmodule_la_LIBADD = ../../libsrcCC/libvipsCC.la $(VIPS_LIBS) nodist_vmaskmodule_la_SOURCES = vmaskmodule.cxx CLEANFILES = \ - vimagemodule.cxx VImage.h \ + vimagemodule.cxx \ verrormodule.cxx vdisplaymodule.cxx vmaskmodule.cxx \ VImage.py VDisplay.py VError.py VMask.py diff --git a/python/vipsCC/VImage.i b/python/vipsCC/VImage.i index 100ae445..e30e2730 100644 --- a/python/vipsCC/VImage.i +++ b/python/vipsCC/VImage.i @@ -13,6 +13,13 @@ */ %rename(__assign__) vips::VImage::operator=; +/* We wrap the C++ VImage class as VImage_core, then write the user-visible + * VImage class ourselves with a %pythoncode (see below). Our hand-made VImage + * class wraps all the operators from the VIPS image operation database via + * __getattr__. + */ +%rename(VImage_core) VImage; + %include "std_list.i" %include "std_complex.i" %include "std_vector.i" @@ -31,11 +38,16 @@ namespace std { /* VImage defines a lot of other operator overloads ... but SWIGs autowrapping * doesn't work well for them. Do by hand later. */ +%include vips/VImage.h -/* Need the expanded VImage.h in this directory. SWIG b0rks on #includes - * inside class definitions. +/* Now wrap SWIG's VImage_core with our own VImage class which does operations + * from the VIPS operation database. */ -%include VImage.h +%pythoncode %{ +class VImage (VImage_core): + def __getattr__ (self, name): + print "VImage getattr: ", name +%} /* Helper code for vips_init(). */