From 3f1c8551774c827c7124ec6b37c30aa4f23e6a6e Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 25 May 2011 13:25:18 +0100 Subject: [PATCH] vipsinterpolate uses new_from_string() vfunc system --- libvips/include/vips/object.h | 5 +++-- libvips/resample/interpolate.c | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/libvips/include/vips/object.h b/libvips/include/vips/object.h index 24435863..084a4d51 100644 --- a/libvips/include/vips/object.h +++ b/libvips/include/vips/object.h @@ -266,8 +266,9 @@ struct _VipsObjectClass { */ /* Given a command-line arg (eg. a filename), make an instance of the - * object. Don't call this directly, see - * vips_object_new_from_string(). + * object. Just do the g_object_new(), don't call _build(). + * + * Don't call this directly, see vips_object_new_from_string(). */ VipsObject *(*new_from_string)( const char *string ); diff --git a/libvips/resample/interpolate.c b/libvips/resample/interpolate.c index 72dee26c..92d41e99 100644 --- a/libvips/resample/interpolate.c +++ b/libvips/resample/interpolate.c @@ -167,16 +167,43 @@ vips_interpolate_real_get_window_offset( VipsInterpolate *interpolate ) } } +static VipsObject * +vips_interpolate_new_from_string( const char *string ) +{ + GType type; + + /* The main arg selects the subclass. + */ + if( !(type = vips_type_find( "VipsInterpolate", string )) ) + return( NULL ); + return( VIPS_OBJECT( g_object_new( type, NULL ) ) ); +} + +static void +vips_interpolate_to_string( VipsObject *object, VipsBuf *buf ) +{ + VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( object ); + + /* Just "bicubic" or whatever. + */ + vips_buf_appends( buf, class->nickname ); +} + static void vips_interpolate_class_init( VipsInterpolateClass *class ) { #ifdef DEBUG GObjectClass *gobject_class = G_OBJECT_CLASS( class ); #endif /*DEBUG*/ + VipsObjectClass *vobject_class = VIPS_OBJECT_CLASS( class ); #ifdef DEBUG gobject_class->finalize = vips_interpolate_finalize; #endif /*DEBUG*/ + + vobject_class->new_from_string = vips_interpolate_new_from_string; + vobject_class->to_string = vips_interpolate_to_string; + class->interpolate = NULL; class->get_window_size = vips_interpolate_real_get_window_size; class->get_window_offset = vips_interpolate_real_get_window_offset;