From 0c35f461dc6f94c0f7aee375d844a6bdc8775001 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 7 Aug 2012 12:52:50 +0100 Subject: [PATCH] add "deprecated" flag to vips arguments deprecated arguments still work, but are not shown in help, nor are they checked for "have-been-set" you can tag required and optional args as deprecated ... obviously if you deprecate a required argument you must replace it with a new argument or scripts will break --- libvips/include/vips/object.h | 4 +++- libvips/iofuncs/enumtypes.c | 1 + libvips/iofuncs/object.c | 1 + libvips/iofuncs/operation.c | 15 +++++++++++---- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/libvips/include/vips/object.h b/libvips/include/vips/object.h index b916161f..392a3f54 100644 --- a/libvips/include/vips/object.h +++ b/libvips/include/vips/object.h @@ -53,6 +53,7 @@ typedef struct _VipsObjectClass VipsObjectClass; * @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. * @@ -73,7 +74,8 @@ typedef enum /*< flags >*/ { VIPS_ARGUMENT_SET_ONCE = 4, VIPS_ARGUMENT_SET_ALWAYS = 8, VIPS_ARGUMENT_INPUT = 16, - VIPS_ARGUMENT_OUTPUT = 32 + VIPS_ARGUMENT_OUTPUT = 32, + VIPS_ARGUMENT_DEPRECATED = 64 } VipsArgumentFlags; /* Useful flag combinations. User-visible ones are: diff --git a/libvips/iofuncs/enumtypes.c b/libvips/iofuncs/enumtypes.c index 676d279b..aa2634d7 100644 --- a/libvips/iofuncs/enumtypes.c +++ b/libvips/iofuncs/enumtypes.c @@ -526,6 +526,7 @@ vips_argument_flags_get_type( void ) {VIPS_ARGUMENT_SET_ALWAYS, "VIPS_ARGUMENT_SET_ALWAYS", "set-always"}, {VIPS_ARGUMENT_INPUT, "VIPS_ARGUMENT_INPUT", "input"}, {VIPS_ARGUMENT_OUTPUT, "VIPS_ARGUMENT_OUTPUT", "output"}, + {VIPS_ARGUMENT_DEPRECATED, "VIPS_ARGUMENT_DEPRECATED", "deprecated"}, {0, NULL, NULL} }; diff --git a/libvips/iofuncs/object.c b/libvips/iofuncs/object.c index 1c27fde7..a9693e14 100644 --- a/libvips/iofuncs/object.c +++ b/libvips/iofuncs/object.c @@ -144,6 +144,7 @@ vips_object_check_required( VipsObject *object, GParamSpec *pspec, if( (argument_class->flags & VIPS_ARGUMENT_REQUIRED) && (argument_class->flags & VIPS_ARGUMENT_CONSTRUCT) && + !(argument_class->flags & VIPS_ARGUMENT_DEPRECATED) && (argument_class->flags & *iomask) && !argument_instance->assigned ) { vips_error( class->nickname, diff --git a/libvips/iofuncs/operation.c b/libvips/iofuncs/operation.c index f93cc4a9..1d75eedf 100644 --- a/libvips/iofuncs/operation.c +++ b/libvips/iofuncs/operation.c @@ -85,7 +85,8 @@ vips_operation_class_usage_arg( VipsObjectClass *object_class, */ if( usage->required == ((argument_class->flags & VIPS_ARGUMENT_REQUIRED) != 0) && - (argument_class->flags & VIPS_ARGUMENT_CONSTRUCT) ) { + (argument_class->flags & VIPS_ARGUMENT_CONSTRUCT) && + !(argument_class->flags & VIPS_ARGUMENT_DEPRECATED) ) { if( usage->message && usage->n == 0 ) vips_buf_appendf( buf, "%s\n", usage->message ); @@ -775,12 +776,16 @@ vips_call_options_add( VipsObject *object, entry[0].long_name = name; entry[0].short_name = name[0]; + entry[0].description = g_param_spec_get_blurb( pspec ); + entry[0].flags = 0; if( !needs_string ) entry[0].flags |= G_OPTION_FLAG_NO_ARG; + if( argument_class->flags & VIPS_ARGUMENT_DEPRECATED ) + entry[0].flags |= G_OPTION_FLAG_HIDDEN; + entry[0].arg = G_OPTION_ARG_CALLBACK; entry[0].arg_data = (gpointer) vips_call_options_set; - entry[0].description = g_param_spec_get_blurb( pspec ); if( needs_string ) entry[0].arg_description = g_type_name( G_PARAM_SPEC_VALUE_TYPE( pspec ) ); @@ -837,7 +842,8 @@ vips_call_argv_input( VipsObject *object, /* Loop over all required construct args. */ if( (argument_class->flags & VIPS_ARGUMENT_REQUIRED) && - (argument_class->flags & VIPS_ARGUMENT_CONSTRUCT) ) { + (argument_class->flags & VIPS_ARGUMENT_CONSTRUCT) && + !(argument_class->flags & VIPS_ARGUMENT_DEPRECATED) ) { const char *name = g_param_spec_get_name( pspec ); if( (argument_class->flags & VIPS_ARGUMENT_INPUT) ) { @@ -872,7 +878,8 @@ vips_call_argv_output( VipsObject *object, /* Loop over all required construct args. */ if( (argument_class->flags & VIPS_ARGUMENT_REQUIRED) && - (argument_class->flags & VIPS_ARGUMENT_CONSTRUCT) ) { + (argument_class->flags & VIPS_ARGUMENT_CONSTRUCT) && + !(argument_class->flags & VIPS_ARGUMENT_DEPRECATED) ) { if( (argument_class->flags & VIPS_ARGUMENT_INPUT) ) call->i += 1; else if( (argument_class->flags & VIPS_ARGUMENT_OUTPUT) ) {