diff --git a/TODO b/TODO index 6cb2f3aa..c413b735 100644 --- a/TODO +++ b/TODO @@ -16,6 +16,11 @@ +- vips_object_get_argument_to_string(), + vips_object_get_argument_needs_string(), + vips_object_set_argument_from_string() + + should all be vfuncs on object diff --git a/libvips/deprecated/dispatch_types.c b/libvips/deprecated/dispatch_types.c index 5f56e28a..af42eaee 100644 --- a/libvips/deprecated/dispatch_types.c +++ b/libvips/deprecated/dispatch_types.c @@ -113,7 +113,7 @@ input_image_init( im_object *obj, char *str ) { IMAGE **im = (IMAGE **) obj; - return( !(*im = vips_image_new_from_file( str, "rd" )) ); + return( !(*im = im_open( str, "rd" )) ); } /* Input image type. @@ -123,7 +123,7 @@ im_type_desc im__input_image = { 0, /* No storage needed */ IM_TYPE_ARG, /* It requires a command-line arg */ (im_init_obj_fn) input_image_init,/* Init function */ - (im_dest_obj_fn) vips_object_unref/* Destroy function */ + (im_dest_obj_fn) im_close /* Destroy function */ }; /* Init function for output images. @@ -133,7 +133,7 @@ output_image_init( im_object *obj, char *str ) { IMAGE **im = (IMAGE **) obj; - return( !(*im = vips_image_new_from_file( str, "w" )) ); + return( !(*im = im_open( str, "w" )) ); } /* Output image type. @@ -143,7 +143,7 @@ im_type_desc im__output_image = { 0, /* No storage to be allocated */ IM_TYPE_OUTPUT | IM_TYPE_ARG, /* Flags! */ (im_init_obj_fn) output_image_init,/* Init function */ - (im_dest_obj_fn) vips_object_unref/* Destroy function */ + (im_dest_obj_fn) im_close /* Destroy function */ }; /* Init function for RW images. @@ -153,7 +153,7 @@ rw_image_init( im_object *obj, char *str ) { IMAGE **im = (IMAGE **) obj; - return( !(*im = vips_image_new_from_file( str, "rw" )) ); + return( !(*im = im_open( str, "rw" )) ); } /* RW image type. @@ -163,7 +163,7 @@ im_type_desc im__rw_image = { 0, /* No storage to be allocated */ IM_TYPE_ARG | IM_TYPE_RW, /* Read-write object, needs an arg */ (im_init_obj_fn) rw_image_init, /* Init function */ - (im_dest_obj_fn) vips_object_unref/* Destroy function */ + (im_dest_obj_fn) im_close /* Destroy function */ }; /* im_imagevec_object destroy function. @@ -178,7 +178,7 @@ imagevec_dest( im_object obj ) for( i = 0; i < iv->n; i++ ) if( iv->vec[i] ) { - g_object_unref( iv->vec[i] ); + im_close( iv->vec[i] ); iv->vec[i] = NULL; } @@ -215,8 +215,7 @@ input_imagevec_init( im_object *obj, char *str ) iv->vec[i] = NULL; for( i = 0; i < nargs; i++ ) - if( !(iv->vec[i] = - vips_image_new_from_file( strv[i], "rd" )) ) { + if( !(iv->vec[i] = im_open( strv[i], "rd" )) ) { g_strfreev( strv ); return( -1 ); } diff --git a/libvips/deprecated/vips7compat.c b/libvips/deprecated/vips7compat.c index a2ac4575..b1b00ab4 100644 --- a/libvips/deprecated/vips7compat.c +++ b/libvips/deprecated/vips7compat.c @@ -52,6 +52,22 @@ #include #endif /*WITH_DMALLOC*/ +VipsImage * +im_open( const char *filename, const char *mode ) +{ + VipsImage *image; + + if( !(image = vips_image_new_from_file( filename, mode )) ) + return( NULL ); + + /* We have to refsink since the im_open() result is used like a hard + * reference. + */ + g_object_ref_sink( image ); + + return( image ); +} + /* Just for compatibility. New code should use vips_object_local() directly. */ VipsImage * @@ -60,7 +76,7 @@ im_open_local( VipsImage *parent, { VipsImage *image; - if( !(image = vips_image_new_from_file( filename, mode )) ) + if( !(image = im_open( filename, mode )) ) return( NULL ); vips_object_local( parent, image ); diff --git a/libvips/include/vips/vips7compat.h b/libvips/include/vips/vips7compat.h index aa9052ab..46f5d33f 100644 --- a/libvips/include/vips/vips7compat.h +++ b/libvips/include/vips/vips7compat.h @@ -153,7 +153,6 @@ extern "C" { #define im_cp_desc vips_image_copy_fields #define im_cp_descv vips_image_copy_fieldsv #define im_cp_desc_array vips_image_copy_fields_array -#define im_open vips_image_new_from_file #define im_image vips_image_new_from_memory #define im_binfile vips_image_new_from_file_raw #define im__open_temp vips_image_new_disc_temp @@ -198,6 +197,8 @@ extern "C" { /* Compat functions. */ +VipsImage *im_open( const char *filename, const char *mode ); + VipsImage *im_open_local( VipsImage *parent, const char *filename, const char *mode ); int im_open_local_array( VipsImage *parent, diff --git a/libvips/iofuncs/image.c b/libvips/iofuncs/image.c index 0b5be189..45e3c6e7 100644 --- a/libvips/iofuncs/image.c +++ b/libvips/iofuncs/image.c @@ -31,8 +31,8 @@ */ /* - */ #define VIPS_DEBUG + */ #ifdef HAVE_CONFIG_H #include @@ -2029,7 +2029,7 @@ vips_image_wio_input( VipsImage *image ) /* Change to VIPS_IMAGE_SETBUF. First, make a memory * buffer and copy into that. */ - if( !(t1 = vips_image_new_from_file( "vips_image_wio_input", "t" )) ) + if( !(t1 = vips_image_new_from_file( "wio_input", "t" )) ) return( -1 ); if( im_copy( image, t1 ) ) { g_object_unref( t1 ); diff --git a/libvips/iofuncs/object.c b/libvips/iofuncs/object.c index a1a6177e..462b131c 100644 --- a/libvips/iofuncs/object.c +++ b/libvips/iofuncs/object.c @@ -30,10 +30,10 @@ */ /* - */ #define DEBUG #define VIPS_DEBUG #define DEBUG_REF + */ #ifdef HAVE_CONFIG_H #include diff --git a/libvips/iofuncs/operation.c b/libvips/iofuncs/operation.c index ca5e2b50..7f198ee0 100644 --- a/libvips/iofuncs/operation.c +++ b/libvips/iofuncs/operation.c @@ -28,8 +28,8 @@ */ /* - */ #define VIPS_DEBUG + */ #ifdef HAVE_CONFIG_H #include