From ac3ce8b01051e0b7ad1c60df7589b0027befcfc6 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Sun, 28 Aug 2011 12:46:50 +0100 Subject: [PATCH] add VIPS_ARGUMENT_APPEND to give more control over arg ordering, fixes a problem in avg --- ChangeLog | 1 + TODO | 5 +++-- libvips/arithmetic/avg.c | 2 +- libvips/include/vips/object.h | 4 +++- libvips/iofuncs/enumtypes.c | 1 + libvips/iofuncs/object.c | 8 ++++++-- libvips/iofuncs/operation.c | 6 +++++- 7 files changed, 20 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6080aeea..1d07792f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/TODO b/TODO index 34e36cd4..f1370662 100644 --- a/TODO +++ b/TODO @@ -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 diff --git a/libvips/arithmetic/avg.c b/libvips/arithmetic/avg.c index 895e9d60..97642f07 100644 --- a/libvips/arithmetic/avg.c +++ b/libvips/arithmetic/avg.c @@ -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 ) ); } diff --git a/libvips/include/vips/object.h b/libvips/include/vips/object.h index 8f7af978..c5c2df87 100644 --- a/libvips/include/vips/object.h +++ b/libvips/include/vips/object.h @@ -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: diff --git a/libvips/iofuncs/enumtypes.c b/libvips/iofuncs/enumtypes.c index 7a311e7a..c87c2e9f 100644 --- a/libvips/iofuncs/enumtypes.c +++ b/libvips/iofuncs/enumtypes.c @@ -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} }; diff --git a/libvips/iofuncs/object.c b/libvips/iofuncs/object.c index 6a86998d..d0605b63 100644 --- a/libvips/iofuncs/object.c +++ b/libvips/iofuncs/object.c @@ -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. diff --git a/libvips/iofuncs/operation.c b/libvips/iofuncs/operation.c index ff63c076..cf96d009 100644 --- a/libvips/iofuncs/operation.c +++ b/libvips/iofuncs/operation.c @@ -28,8 +28,8 @@ */ /* -#define VIPS_DEBUG */ +#define VIPS_DEBUG #ifdef HAVE_CONFIG_H #include @@ -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;