From f52d195e7771c470a3f01715b81a90741d46de5b Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Thu, 16 Oct 2008 14:08:12 +0000 Subject: [PATCH] rename to VipsObject etc --- include/vips/interpolate.h | 113 +++++++++++++++++ include/vips/{vipsobject.h => object.h} | 60 +++++---- include/vips/vipsinterpolate.h | 107 ---------------- libsrc/iofuncs/Makefile.am | 2 +- libsrc/iofuncs/{vobject.c => object.c} | 117 +++++++++--------- libsrc/mosaicing/Makefile.am | 2 +- .../{vinterpolate.c => interpolate.c} | 0 7 files changed, 211 insertions(+), 190 deletions(-) create mode 100644 include/vips/interpolate.h rename include/vips/{vipsobject.h => object.h} (56%) delete mode 100644 include/vips/vipsinterpolate.h rename libsrc/iofuncs/{vobject.c => object.c} (50%) rename libsrc/mosaicing/{vinterpolate.c => interpolate.c} (100%) diff --git a/include/vips/interpolate.h b/include/vips/interpolate.h new file mode 100644 index 00000000..5269efe2 --- /dev/null +++ b/include/vips/interpolate.h @@ -0,0 +1,113 @@ +/* Various interpolators. + * + * J.Cupitt, 15/10/08 + */ + +/* + + This file is part of VIPS. + + VIPS is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + */ + +/* + + These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk + + */ + +#ifndef VIPS_INTERPOLATE_H +#define VIPS_INTERPOLATE_H + +#ifdef __cplusplus +extern "C" { +#endif /*__cplusplus*/ + +#define VIPS_TYPE_INTERPOLATE (vips_interpolate_get_type()) +#define VIPS_INTERPOLATE( obj ) \ + (G_TYPE_CHECK_INSTANCE_CAST( (obj), \ + VIPS_TYPE_INTERPOLATE, VipsInterpolate )) +#define VIPS_INTERPOLATE_CLASS( klass ) \ + (G_TYPE_CHECK_CLASS_CAST( (klass), \ + VIPS_TYPE_INTERPOLATE, VipsInterpolateClass)) +#define VIPS_IS_INTERPOLATE( obj ) \ + (G_TYPE_CHECK_INSTANCE_TYPE( (obj), VIPS_TYPE_INTERPOLATE )) +#define VIPS_IS_INTERPOLATE_CLASS( klass ) \ + (G_TYPE_CHECK_CLASS_TYPE( (klass), VIPS_TYPE_INTERPOLATE )) +#define VIPS_INTERPOLATE_GET_CLASS( obj ) \ + (G_TYPE_INSTANCE_GET_CLASS( (obj), \ + VIPS_TYPE_INTERPOLATE, VipsInterpolateClass )) + +typedef struct _VipsInterpolate { + VipsObject parent_object; + +} VipsInterpolate; + +typedef struct _VipsInterpolateClass { + VipsObjectClass parent_class; + + /* Write to pixel out(x,y), interpolating from in(x,y). The caller has + * to set the regions up. + */ + void (*interpolate)( VipsInterpolate *, REGION *out, REGION *in, + int out_x, int out_y, double in_x, double in_y ); + + /* This interpolator needs a window of pixels this big. + */ + int window; + +} VipsInterpolateClass; + +VipsInterpolate *vips_interpolate_bilinear_new( void ); + +/* Convenience: return a static bilinear, so no need to free it. + */ +VipsInterpolate *vips_interpolate_bilinear(); + +#define VIPS_TYPE_INTERPOLATE_YAFR (vips_interpolate_yafr_get_type()) +#define VIPS_INTERPOLATE_YAFR( obj ) \ + (G_TYPE_CHECK_INSTANCE_CAST( (obj), \ + VIPS_TYPE_INTERPOLATE_YAFR, VipsInterpolateYafr )) +#define VIPS_INTERPOLATE_YAFR_CLASS( klass ) \ + (G_TYPE_CHECK_CLASS_CAST( (klass), \ + VIPS_TYPE_INTERPOLATE_YAFR, VipsInterpolateYafrClass)) +#define VIPS_IS_INTERPOLATE_YAFR( obj ) \ + (G_TYPE_CHECK_INSTANCE_TYPE( (obj), VIPS_TYPE_INTERPOLATE_YAFR )) +#define VIPS_IS_INTERPOLATE_YAFR_CLASS( klass ) \ + (G_TYPE_CHECK_CLASS_TYPE( (klass), VIPS_TYPE_INTERPOLATE_YAFR )) +#define VIPS_INTERPOLATE_YAFR_GET_CLASS( obj ) \ + (G_TYPE_INSTANCE_GET_CLASS( (obj), \ + VIPS_TYPE_INTERPOLATE_YAFR, VipsInterpolateYafrClass )) + +typedef struct _VipsInterpolateYafr { + VipsObject parent_object; + +} VipsInterpolateYafr; + +typedef struct _VipsInterpolateYafrClass { + VipsObjectClass parent_class; + +} VipsInterpolateYafrClass; + +VipsInterpolateYafr *vips_interpolate_yafr_new( void ); +void vips_interpolate_yafr_set_thing( VipsInterpolateYafr *, double thing ); + +#ifdef __cplusplus +} +#endif /*__cplusplus*/ + +#endif /*VIPS_INTERPOLATE_H*/ + diff --git a/include/vips/vipsobject.h b/include/vips/object.h similarity index 56% rename from include/vips/vipsobject.h rename to include/vips/object.h index 0a90ee3e..468f0deb 100644 --- a/include/vips/vipsobject.h +++ b/include/vips/object.h @@ -27,28 +27,35 @@ */ -#define TYPE_VOBJECT (vobject_get_type()) -#define VOBJECT( obj ) \ - (G_TYPE_CHECK_INSTANCE_CAST( (obj), TYPE_VOBJECT, VObject )) -#define VOBJECT_CLASS( klass ) \ - (G_TYPE_CHECK_CLASS_CAST( (klass), TYPE_VOBJECT, VObjectClass)) -#define IS_VOBJECT( obj ) \ - (G_TYPE_CHECK_INSTANCE_TYPE( (obj), TYPE_VOBJECT )) -#define IS_VOBJECT_CLASS( klass ) \ - (G_TYPE_CHECK_CLASS_TYPE( (klass), TYPE_VOBJECT )) -#define VOBJECT_GET_CLASS( obj ) \ - (G_TYPE_INSTANCE_GET_CLASS( (obj), TYPE_VOBJECT, VObjectClass )) +#ifndef VIPS_OBJECT_H +#define VIPS_OBJECT_H -/* Handy vobject_destroy() shortcut. +#ifdef __cplusplus +extern "C" { +#endif /*__cplusplus*/ + +#define VIPS_TYPE_OBJECT (vips_object_get_type()) +#define VIPS_OBJECT( obj ) \ + (G_TYPE_CHECK_INSTANCE_CAST( (obj), VIPS_TYPE_OBJECT, VipsObject )) +#define VIPS_OBJECT_CLASS( klass ) \ + (G_TYPE_CHECK_CLASS_CAST( (klass), VIPS_TYPE_OBJECT, VipsObjectClass)) +#define VIPS_IS_OBJECT( obj ) \ + (G_TYPE_CHECK_INSTANCE_TYPE( (obj), VIPS_TYPE_OBJECT )) +#define VIPS_IS_OBJECT_CLASS( klass ) \ + (G_TYPE_CHECK_CLASS_TYPE( (klass), VIPS_TYPE_OBJECT )) +#define VIPS_OBJECT_GET_CLASS( obj ) \ + (G_TYPE_INSTANCE_GET_CLASS( (obj), VIPS_TYPE_OBJECT, VipsObjectClass )) + +/* Handy vips_object_destroy() shortcut. */ #define IDESTROY( O ) { \ if( O ) { \ - (void) vobject_destroy( VOBJECT( O ) ); \ + (void) vips_object_destroy( VIPS_OBJECT( O ) ); \ ( O ) = NULL; \ } \ } -typedef struct _VObject { +typedef struct _VipsObject { GObject parent_object; /* True when created ... the 1 reference that gobject makes is @@ -61,24 +68,31 @@ typedef struct _VObject { /* Stop destroy loops with this. */ gboolean in_destruction; -} VObject; +} VipsObject; -typedef struct _VObjectClass { +typedef struct _VipsObjectClass { GObjectClass parent_class; /* End object's lifetime, just like gtk_object_destroy. */ - void (*destroy)( VObject * ); + void (*destroy)( VipsObject * ); /* Something about the object has changed. Should use glib's properties * but fix this later. */ - void (*changed)( VObject * ); -} VObjectClass; + void (*changed)( VipsObject * ); +} VipsObjectClass; -void *vobject_destroy( VObject *vobject ); -void *vobject_changed( VObject *vobject ); -void vobject_sink( VObject *vobject ); +void *vips_object_destroy( VipsObject *vips_object ); +void *vips_object_changed( VipsObject *vips_object ); +void vips_object_sink( VipsObject *vips_object ); + +GType vips_object_get_type( void ); + +#ifdef __cplusplus +} +#endif /*__cplusplus*/ + +#endif /*VIPS_OBJECT_H*/ -GType vobject_get_type( void ); diff --git a/include/vips/vipsinterpolate.h b/include/vips/vipsinterpolate.h deleted file mode 100644 index 2e2d0595..00000000 --- a/include/vips/vipsinterpolate.h +++ /dev/null @@ -1,107 +0,0 @@ -/* Various interpolators. - * - * J.Cupitt, 15/10/08 - */ - -/* - - This file is part of VIPS. - - VIPS is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - */ - -/* - - These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk - - */ - -#ifndef IM_VINTERPOLATE_H -#define IM_VINTERPOLATE_H - -#ifdef __cplusplus -extern "C" { -#endif /*__cplusplus*/ - -#define TYPE_VINTERPOLATE (vinterpolate_get_type()) -#define VINTERPOLATE( obj ) \ - (G_TYPE_CHECK_INSTANCE_CAST( (obj), TYPE_VINTERPOLATE, VInterpolate )) -#define VINTERPOLATE_CLASS( klass ) \ - (G_TYPE_CHECK_CLASS_CAST( (klass), \ - TYPE_VINTERPOLATE, VInterpolateClass)) -#define IS_VINTERPOLATE( obj ) \ - (G_TYPE_CHECK_INSTANCE_TYPE( (obj), TYPE_VINTERPOLATE )) -#define IS_VINTERPOLATE_CLASS( klass ) \ - (G_TYPE_CHECK_CLASS_TYPE( (klass), TYPE_VINTERPOLATE )) -#define VINTERPOLATE_GET_CLASS( obj ) \ - (G_TYPE_INSTANCE_GET_CLASS( (obj), \ - TYPE_VINTERPOLATE, VInterpolateClass )) - -typedef struct _VInterpolate { - VObject parent; - -} VInterpolate; - -typedef struct _VInterpolateClass { - VObjectClass parent_class; - - /* Write to pixel out(x,y), interpolating from in(x,y). The caller has - * to set the regions up. - */ - void (*interpolate)( VInterpolate *, REGION *out, REGION *in, - int out_x, int out_y, double in_x, double in_y ); - - /* This interpolator needs a window of pixels this big. - */ - int window; - -} VInterpolateClass; - -#define TYPE_VINTERPOLATE_YAFR (vinterpolate_yafr_get_type()) -#define VINTERPOLATE_YAFR( obj ) \ - (G_TYPE_CHECK_INSTANCE_CAST( (obj), TYPE_VINTERPOLATE_YAFR, VInterpolateYafr )) -#define VINTERPOLATE_YAFR_CLASS( klass ) \ - (G_TYPE_CHECK_CLASS_CAST( (klass), \ - TYPE_VINTERPOLATE_YAFR, VInterpolateYafrClass)) -#define IS_VINTERPOLATE_YAFR( obj ) \ - (G_TYPE_CHECK_INSTANCE_TYPE( (obj), TYPE_VINTERPOLATE_YAFR )) -#define IS_VINTERPOLATE_YAFR_CLASS( klass ) \ - (G_TYPE_CHECK_CLASS_TYPE( (klass), TYPE_VINTERPOLATE_YAFR )) -#define VINTERPOLATE_YAFR_GET_CLASS( obj ) \ - (G_TYPE_INSTANCE_GET_CLASS( (obj), \ - TYPE_VINTERPOLATE_YAFR, VInterpolateYafrClass )) - -typedef struct _VInterpolateYafr { - VObject parent; - -} VInterpolateYafr; - -typedef struct _VInterpolateYafrClass { - VObjectClass parent_class; - -} VInterpolateYafrClass; - -VInterpolate *vinterpolate_bilinear_new( void ); - -VInterpolateYafr *vinterpolate_yafr_new( void ); -void vinterpolate_yafr_set_thing( VInterpolateYafr *, double thing ); - -#ifdef __cplusplus -} -#endif /*__cplusplus*/ - -#endif /*IM_VINTERPOLATE_H*/ - diff --git a/libsrc/iofuncs/Makefile.am b/libsrc/iofuncs/Makefile.am index d28b66ce..0c0a853a 100644 --- a/libsrc/iofuncs/Makefile.am +++ b/libsrc/iofuncs/Makefile.am @@ -1,7 +1,7 @@ noinst_LTLIBRARIES = libiofuncs.la libiofuncs_la_SOURCES = \ - vobject.c \ + object.c \ meta.c \ base64.h \ base64.c \ diff --git a/libsrc/iofuncs/vobject.c b/libsrc/iofuncs/object.c similarity index 50% rename from libsrc/iofuncs/vobject.c rename to libsrc/iofuncs/object.c index 0ee5a6a9..3e3d7c95 100644 --- a/libsrc/iofuncs/vobject.c +++ b/libsrc/iofuncs/object.c @@ -51,166 +51,167 @@ */ enum { SIG_DESTROY, /* End lifetime */ - SIG_CHANGED, /* VObject has changed somehow */ + SIG_CHANGED, /* VipsObject has changed somehow */ SIG_LAST }; static GObjectClass *parent_class = NULL; -static guint vobject_signals[SIG_LAST] = { 0 }; +static guint vips_object_signals[SIG_LAST] = { 0 }; /* Don't emit "destroy" immediately, do it from the _dispose handler. */ void * -vobject_destroy( VObject *vobject ) +vips_object_destroy( VipsObject *vips_object ) { #ifdef DEBUG - printf( "vobject_destroy: " ); - vobject_print( vobject ); + printf( "vips_object_destroy: " ); + vips_object_print( vips_object ); #endif /*DEBUG*/ - if( !vobject->in_destruction ) - g_object_run_dispose( G_OBJECT( vobject ) ); + if( !vips_object->in_destruction ) + g_object_run_dispose( G_OBJECT( vips_object ) ); return( NULL ); } void * -vobject_changed( VObject *vobject ) +vips_object_changed( VipsObject *vips_object ) { - g_return_val_if_fail( vobject != NULL, NULL ); - g_return_val_if_fail( IS_VOBJECT( vobject ), NULL ); + g_return_val_if_fail( vips_object != NULL, NULL ); + g_return_val_if_fail( VIPS_IS_OBJECT( vips_object ), NULL ); #ifdef DEBUG - printf( "vobject_changed: " ); - vobject_print( vobject ); + printf( "vips_object_changed: " ); + vips_object_print( vips_object ); #endif /*DEBUG*/ - g_signal_emit( G_OBJECT( vobject ), vobject_signals[SIG_CHANGED], 0 ); + g_signal_emit( G_OBJECT( vips_object ), + vips_object_signals[SIG_CHANGED], 0 ); return( NULL ); } static void -vobject_dispose( GObject *gobject ) +vips_object_dispose( GObject *gobject ) { - VObject *vobject = VOBJECT( gobject ); + VipsObject *vips_object = VIPS_OBJECT( gobject ); #ifdef DEBUG - printf( "vobject_dispose: " ); - vobject_print( vobject ); + printf( "vips_object_dispose: " ); + vips_object_print( vips_object ); #endif /*DEBUG*/ - if( !vobject->in_destruction ) { - vobject->in_destruction = TRUE; - g_signal_emit( G_OBJECT( vobject ), - vobject_signals[SIG_DESTROY], 0 ); - vobject->in_destruction = FALSE; + if( !vips_object->in_destruction ) { + vips_object->in_destruction = TRUE; + g_signal_emit( G_OBJECT( vips_object ), + vips_object_signals[SIG_DESTROY], 0 ); + vips_object->in_destruction = FALSE; } G_OBJECT_CLASS( parent_class )->dispose( gobject ); } static void -vobject_finalize( GObject *gobject ) +vips_object_finalize( GObject *gobject ) { #ifdef DEBUG - VObject *vobject = VOBJECT( gobject ); + VipsObject *vips_object = VIPS_OBJECT( gobject ); - printf( "vobject_finalize: " ); - vobject_print( vobject ); + printf( "vips_object_finalize: " ); + vips_object_print( vips_object ); #endif /*DEBUG*/ /* Unlike GTK, we allow floating objects to be finalized. Handy if a - * _new() fails. So don't assert( !vobject->floating ); + * _new() fails. So don't assert( !vips_object->floating ); */ G_OBJECT_CLASS( parent_class )->finalize( gobject ); } static void -vobject_real_destroy( VObject *vobject ) +vips_object_real_destroy( VipsObject *vips_object ) { } static void -vobject_real_changed( VObject *vobject ) +vips_object_real_changed( VipsObject *vips_object ) { } static void -vobject_class_init( VObjectClass *class ) +vips_object_class_init( VipsObjectClass *class ) { GObjectClass *gobject_class = G_OBJECT_CLASS( class ); parent_class = g_type_class_peek_parent( class ); - gobject_class->dispose = vobject_dispose; - gobject_class->finalize = vobject_finalize; + gobject_class->dispose = vips_object_dispose; + gobject_class->finalize = vips_object_finalize; - class->destroy = vobject_real_destroy; - class->changed = vobject_real_changed; + class->destroy = vips_object_real_destroy; + class->changed = vips_object_real_changed; - vobject_signals[SIG_DESTROY] = g_signal_new( "destroy", + vips_object_signals[SIG_DESTROY] = g_signal_new( "destroy", G_TYPE_FROM_CLASS( gobject_class ), G_SIGNAL_RUN_CLEANUP | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, - G_STRUCT_OFFSET( VObjectClass, destroy ), + G_STRUCT_OFFSET( VipsObjectClass, destroy ), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0 ); - vobject_signals[SIG_CHANGED] = g_signal_new( "changed", + vips_object_signals[SIG_CHANGED] = g_signal_new( "changed", G_OBJECT_CLASS_TYPE( gobject_class ), G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET( VObjectClass, changed ), + G_STRUCT_OFFSET( VipsObjectClass, changed ), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0 ); } static void -vobject_init( VObject *vobject ) +vips_object_init( VipsObject *vips_object ) { #ifdef DEBUG - printf( "vobject_init: " ); - vobject_print( vobject ); + printf( "vips_object_init: " ); + vips_object_print( vips_object ); #endif /*DEBUG*/ - vobject->floating = TRUE; - vobject->in_destruction = FALSE; + vips_object->floating = TRUE; + vips_object->in_destruction = FALSE; } GType -vobject_get_type( void ) +vips_object_get_type( void ) { - static GType vobject_type = 0; + static GType vips_object_type = 0; - if( !vobject_type ) { + if( !vips_object_type ) { static const GTypeInfo info = { - sizeof( VObjectClass ), + sizeof( VipsObjectClass ), NULL, /* base_init */ NULL, /* base_finalize */ - (GClassInitFunc) vobject_class_init, + (GClassInitFunc) vips_object_class_init, NULL, /* class_finalize */ NULL, /* class_data */ - sizeof( VObject ), + sizeof( VipsObject ), 32, /* n_preallocs */ - (GInstanceInitFunc) vobject_init, + (GInstanceInitFunc) vips_object_init, }; - vobject_type = g_type_register_static( G_TYPE_OBJECT, - "VObject", &info, 0 ); + vips_object_type = g_type_register_static( G_TYPE_OBJECT, + "VipsObject", &info, 0 ); } - return( vobject_type ); + return( vips_object_type ); } void -vobject_sink( VObject *vobject ) +vips_object_sink( VipsObject *vips_object ) { - g_assert( IS_VOBJECT( vobject ) ); + g_assert( VIPS_IS_OBJECT( vips_object ) ); - if( vobject->floating ) { - vobject->floating = FALSE; - g_object_unref( G_OBJECT( vobject ) ); + if( vips_object->floating ) { + vips_object->floating = FALSE; + g_object_unref( G_OBJECT( vips_object ) ); } } diff --git a/libsrc/mosaicing/Makefile.am b/libsrc/mosaicing/Makefile.am index eaf9280a..9df850fa 100644 --- a/libsrc/mosaicing/Makefile.am +++ b/libsrc/mosaicing/Makefile.am @@ -11,7 +11,7 @@ libmosaicing_la_SOURCES = \ im_avgdxdy.c \ im_chkpair.c \ im_clinear.c \ - vinterpolate.c \ + interpolate.c \ im_improve.c \ im_initialize.c \ im_lrcalcon.c \ diff --git a/libsrc/mosaicing/vinterpolate.c b/libsrc/mosaicing/interpolate.c similarity index 100% rename from libsrc/mosaicing/vinterpolate.c rename to libsrc/mosaicing/interpolate.c