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
This commit is contained in:
parent
a9c7a36670
commit
0c35f461dc
@ -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:
|
||||
|
@ -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}
|
||||
};
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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) ) {
|
||||
|
Loading…
Reference in New Issue
Block a user