From b72818a2b85c0076993a9702f35380b1e35c266f Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 3 Feb 2014 13:23:58 +0000 Subject: [PATCH] add VIPS_OPERATION_DEPRECATED and fix a tiny problem in vipswrap7 --- ChangeLog | 1 + TODO | 14 ------------- libvips/deprecated/wrapvips7.c | 20 +++++++++++++----- libvips/include/vips/object.h | 36 +++++++------------------------- libvips/include/vips/operation.h | 3 ++- libvips/iofuncs/enumtypes.c | 1 + libvips/iofuncs/object.c | 29 +++++++++++++++++++++++++ libvips/iofuncs/operation.c | 4 ++++ 8 files changed, 60 insertions(+), 48 deletions(-) diff --git a/ChangeLog b/ChangeLog index ebac3ca5..a97c1924 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ - auto-decode for (almost) all operations - background render thread cleans up and quits neatly - colourspace has a source_space option +- operations can be tagged as "deprecated" 22/1/14 started 7.38.2 - auto RAD decode for affine diff --git a/TODO b/TODO index 6e7db58e..3831bfd4 100644 --- a/TODO +++ b/TODO @@ -1,17 +1,3 @@ -- can we deprecate classes? eg. VipsFormat and VipsWrap7 should be hidden - - we have - - gboolean output_needs_arg; - - in vipsobjectclass at the moment, but that's the only flag-like thing - - add a get_flags() member whose values include needs_arg and deprecated? - - add a couple of void * blank pointers to object and objectclass for future - expansion .. a couple of ints as well? - -- introspection example in gist should not list abstract classes? - check_uncoded() left to do: diff --git a/libvips/deprecated/wrapvips7.c b/libvips/deprecated/wrapvips7.c index 4b0165f6..bcb15c91 100644 --- a/libvips/deprecated/wrapvips7.c +++ b/libvips/deprecated/wrapvips7.c @@ -183,8 +183,7 @@ vips_wrap7_vargv_dispose( im_function *fn, im_object *vargv ) case VIPS_WRAP7_INTERPOLATE: case VIPS_WRAP7_IMAGE: - if( vargv[i] ) - VIPS_UNREF( vargv[i] ); + VIPS_UNREF( vargv[i] ); break; case VIPS_WRAP7_IMAGEVEC: @@ -193,13 +192,21 @@ vips_wrap7_vargv_dispose( im_function *fn, im_object *vargv ) int j; for( j = 0; j < iv->n; j++ ) - if( iv->vec[j] ) - VIPS_UNREF( iv->vec[j] ); + VIPS_UNREF( iv->vec[j] ); } break; case VIPS_WRAP7_GVALUE: - g_value_unset( vargv[i] ); + if( vargv[i] ) { + GValue *value = (GValue *) vargv[i]; + + if( G_VALUE_TYPE( value ) ) + g_value_unset( value ); + } + break; + + case VIPS_WRAP7_STRING: + VIPS_FREE( vargv[i] ); break; default: @@ -686,6 +693,7 @@ vips_wrap7_class_init( VipsWrap7Class *class ) { GObjectClass *gobject_class = (GObjectClass *) class; VipsObjectClass *vobject_class = (VipsObjectClass *) class; + VipsOperationClass *operation_class = (VipsOperationClass *) class; gobject_class->dispose = vips_wrap7_dispose; gobject_class->finalize = vips_wrap7_finalize; @@ -695,6 +703,8 @@ vips_wrap7_class_init( VipsWrap7Class *class ) vobject_class->build = vips_wrap7_build; vobject_class->summary_class = vips_wrap7_summary_class; vobject_class->dump = vips_wrap7_dump; + + operation_class->flags = VIPS_OPERATION_DEPRECATED; } static void diff --git a/libvips/include/vips/object.h b/libvips/include/vips/object.h index 5d27210a..2184491a 100644 --- a/libvips/include/vips/object.h +++ b/libvips/include/vips/object.h @@ -55,34 +55,6 @@ typedef struct _VipsObjectClass VipsObjectClass; /* Track extra stuff for arguments to objects */ -/** - * VipsArgumentFlags: - * @VIPS_ARGUMENT_NONE: no flags - * @VIPS_ARGUMENT_REQUIRED: must be set in the constructor - * @VIPS_ARGUMENT_CONSTRUCT: can only be set in the constructor - * @VIPS_ARGUMENT_SET_ONCE: can only be set once - * @VIPS_ARGUMENT_SET_ALWAYS: don't do use-before-set checks - * @VIPS_ARGUMENT_INPUT: is an input argument (one we depend on) - * @VIPS_ARGUMENT_OUTPUT: is an output argument (depends on us) - * @VIPS_ARGUMENT_DEPRECATED: just there for back-compat, hide - * - * Flags we associate with each object argument. - * - * Have separate input & output flags. Both set is an error; neither set is OK. - * - * Input gobjects are automatically reffed, output gobjects automatically ref - * us. We also automatically watch for "destroy" and unlink. - * - * @VIPS_ARGUMENT_SET_ALWAYS is handy for arguments which are set from C. For - * example, VipsImage::width is a property that gives access to the Xsize - * member of struct _VipsImage. We default its 'assigned' to TRUE - * since the field is always set directly by C. - * - * @VIPS_ARGUMENT_DEPRECATED arguments are not shown in help text, are not - * looked for if required, are not checked for "have-been-set". You can - * deprecate a required argument, but you must obviously add a new required - * argument if you do. - */ typedef enum /*< flags >*/ { VIPS_ARGUMENT_NONE = 0, VIPS_ARGUMENT_REQUIRED = 1, @@ -461,6 +433,7 @@ struct _VipsObject { * profiling. */ size_t local_memory; + }; struct _VipsObjectClass { @@ -561,6 +534,13 @@ struct _VipsObjectClass { */ GSList *argument_table_traverse; GType argument_table_traverse_gtype; + + /* Reserved for future expansion. + */ + void (*_vips_reserved1)( void ); + void (*_vips_reserved2)( void ); + void (*_vips_reserved3)( void ); + void (*_vips_reserved4)( void ); }; gboolean vips_value_is_null( GParamSpec *psoec, const GValue *value ); diff --git a/libvips/include/vips/operation.h b/libvips/include/vips/operation.h index 18270e13..e9697e61 100644 --- a/libvips/include/vips/operation.h +++ b/libvips/include/vips/operation.h @@ -41,7 +41,8 @@ typedef enum /*< flags >*/ { VIPS_OPERATION_NONE = 0, VIPS_OPERATION_SEQUENTIAL = 1, VIPS_OPERATION_SEQUENTIAL_UNBUFFERED = 2, - VIPS_OPERATION_NOCACHE = 4 + VIPS_OPERATION_NOCACHE = 4, + VIPS_OPERATION_DEPRECATED = 8 } VipsOperationFlags; #define VIPS_TYPE_OPERATION (vips_operation_get_type()) diff --git a/libvips/iofuncs/enumtypes.c b/libvips/iofuncs/enumtypes.c index 7ab61739..fec6fe77 100644 --- a/libvips/iofuncs/enumtypes.c +++ b/libvips/iofuncs/enumtypes.c @@ -624,6 +624,7 @@ vips_operation_flags_get_type( void ) {VIPS_OPERATION_SEQUENTIAL, "VIPS_OPERATION_SEQUENTIAL", "sequential"}, {VIPS_OPERATION_SEQUENTIAL_UNBUFFERED, "VIPS_OPERATION_SEQUENTIAL_UNBUFFERED", "sequential-unbuffered"}, {VIPS_OPERATION_NOCACHE, "VIPS_OPERATION_NOCACHE", "nocache"}, + {VIPS_OPERATION_DEPRECATED, "VIPS_OPERATION_DEPRECATED", "deprecated"}, {0, NULL, NULL} }; diff --git a/libvips/iofuncs/object.c b/libvips/iofuncs/object.c index 605a9c4a..37948b4f 100644 --- a/libvips/iofuncs/object.c +++ b/libvips/iofuncs/object.c @@ -79,6 +79,35 @@ * */ +/** + * VipsArgumentFlags: + * @VIPS_ARGUMENT_NONE: no flags + * @VIPS_ARGUMENT_REQUIRED: must be set in the constructor + * @VIPS_ARGUMENT_CONSTRUCT: can only be set in the constructor + * @VIPS_ARGUMENT_SET_ONCE: can only be set once + * @VIPS_ARGUMENT_SET_ALWAYS: don't do use-before-set checks + * @VIPS_ARGUMENT_INPUT: is an input argument (one we depend on) + * @VIPS_ARGUMENT_OUTPUT: is an output argument (depends on us) + * @VIPS_ARGUMENT_DEPRECATED: just there for back-compat, hide + * + * Flags we associate with each object argument. + * + * Have separate input & output flags. Both set is an error; neither set is OK. + * + * Input gobjects are automatically reffed, output gobjects automatically ref + * us. We also automatically watch for "destroy" and unlink. + * + * @VIPS_ARGUMENT_SET_ALWAYS is handy for arguments which are set from C. For + * example, VipsImage::width is a property that gives access to the Xsize + * member of struct _VipsImage. We default its 'assigned' to TRUE + * since the field is always set directly by C. + * + * @VIPS_ARGUMENT_DEPRECATED arguments are not shown in help text, are not + * looked for if required, are not checked for "have-been-set". You can + * deprecate a required argument, but you must obviously add a new required + * argument if you do. + */ + /* Our signals. */ enum { diff --git a/libvips/iofuncs/operation.c b/libvips/iofuncs/operation.c index 94a3592d..cd2e17e2 100644 --- a/libvips/iofuncs/operation.c +++ b/libvips/iofuncs/operation.c @@ -70,6 +70,7 @@ * @VIPS_OPERATION_NONE: no flags * @VIPS_OPERATION_SEQUENTIAL: can work sequentially * @VIPS_OPERATION_NOCACHE: must not be cached + * @VIPS_OPERATION_DEPRECATED: a compatibility thing * * Flags we associate with an operation. * @@ -83,6 +84,9 @@ * * @VIPS_OPERATION_NOCACHE means that the operation must not be cached by * vips. + * + * @VIPS_OPERATION_DEPRECATED means this is an old operation kept in vips for + * compatibility only and should be hidden from users. */ /* Abstract base class for operations.