add VIPS_ARGUMENT_APPEND

to give more control over arg ordering, fixes a problem in avg
This commit is contained in:
John Cupitt 2011-08-28 12:46:50 +01:00
parent b26dcb284d
commit ac3ce8b010
7 changed files with 20 additions and 7 deletions

View File

@ -1,6 +1,7 @@
20/8/11 started 7.27.0
- version bump for new dev cycle
- im_subtract(), im_avg() redone as classes
- added VIPS_ARGUMENT_APPEND to help control arg ordering
10/8/11 started 7.26.3
- don't use G_VALUE_COLLECT_INIT(), many platforms do not have a glib this

5
TODO
View File

@ -1,9 +1,10 @@
- oops
$ vips im_avg babe.jpg
$ vips avg
Segmentation fault
test 7.26 as well, argh
because we don't test that all args have been set until the end of build,
and statistic_build assumes that in has been set

View File

@ -256,7 +256,7 @@ vips_avg_class_init( VipsAvgClass *class )
g_object_class_install_property( gobject_class,
PROP_OUTPUT, pspec );
vips_object_class_install_argument( object_class, pspec,
VIPS_ARGUMENT_REQUIRED_OUTPUT,
VIPS_ARGUMENT_REQUIRED_OUTPUT | VIPS_ARGUMENT_APPEND,
G_STRUCT_OFFSET( VipsAvg, avg ) );
}

View File

@ -52,6 +52,7 @@ typedef struct _VipsObjectClass VipsObjectClass;
* @VIPS_ARGUMENT_SET_ONCE: can only be set once
* @VIPS_ARGUMENT_INPUT: is an input argument (one we depend on)
* @VIPS_ARGUMENT_OUTPUT: is an output argument (depends on us)
* @VIPS_ARGUMENT_APPEND: add to end of arg list (default is prepend)
*
* Flags we associate with each object argument.
*
@ -66,7 +67,8 @@ typedef enum {
VIPS_ARGUMENT_CONSTRUCT = 2,
VIPS_ARGUMENT_SET_ONCE = 4,
VIPS_ARGUMENT_INPUT = 8,
VIPS_ARGUMENT_OUTPUT = 16
VIPS_ARGUMENT_OUTPUT = 16,
VIPS_ARGUMENT_APPEND = 32
} VipsArgumentFlags;
/* Useful flag combinations. User-visible ones are:

View File

@ -158,6 +158,7 @@ vips_argument_flags_get_type( void )
{VIPS_ARGUMENT_SET_ONCE, "VIPS_ARGUMENT_SET_ONCE", "set-once"},
{VIPS_ARGUMENT_INPUT, "VIPS_ARGUMENT_INPUT", "input"},
{VIPS_ARGUMENT_OUTPUT, "VIPS_ARGUMENT_OUTPUT", "output"},
{VIPS_ARGUMENT_APPEND, "VIPS_ARGUMENT_APPEND", "append"},
{0, NULL, NULL}
};

View File

@ -1119,8 +1119,12 @@ vips_object_class_install_argument( VipsObjectClass *object_class,
vips_argument_table_replace( object_class->argument_table,
(VipsArgument *) argument_class );
object_class->argument_table_traverse = g_slist_prepend(
object_class->argument_table_traverse, argument_class );
if( flags & VIPS_ARGUMENT_APPEND )
object_class->argument_table_traverse = g_slist_append(
object_class->argument_table_traverse, argument_class );
else
object_class->argument_table_traverse = g_slist_prepend(
object_class->argument_table_traverse, argument_class );
}
/* Set a named arg from a string.

View File

@ -28,8 +28,8 @@
*/
/*
#define VIPS_DEBUG
*/
#define VIPS_DEBUG
#ifdef HAVE_CONFIG_H
#include <config.h>
@ -718,8 +718,12 @@ vips_call_argv( VipsOperation *operation, int argc, char **argv )
printf( "vips_call_argv: " );
vips_object_print_name( VIPS_OBJECT( operation ) );
printf( "\n" );
{
int i;
for( i = 0; i < argc; i++ )
printf( "%d) %s\n", i, argv[i] );
}
#endif /*VIPS_DEBUG*/
call.operation = operation;