move vips_operation_set_valist_optional() to obj

now a method on object, vips_object_set()
This commit is contained in:
John Cupitt 2012-07-09 14:51:37 +01:00
parent 87e37e83e2
commit 911a1c7e71
5 changed files with 65 additions and 41 deletions

11
TODO
View File

@ -1,7 +1,12 @@
- make vips_operation_set_valist_optional into a general thing on vipsobject
- have made vips_operation_set_valist_optional into a general thing on
vipsobject
vips_object_setv( VipsObject, va_list list );
needs docs
- should
vips_image_new_mode ()
@ -31,8 +36,6 @@
- update "how it works" to note we are now fully-functional ... there's
vips_image_write() now to create a sink
- we need to put out that new Windows build of nip2
- im_jpeg2vips() etc, currently use vips_call() and therefore have an extra
_write() ... this means that
@ -43,6 +46,8 @@
instead, they could be built on top of VipsFormat and use the compat layer
there
check nip2: is it really only decompressing large images once?
blocking bugs
=============

View File

@ -541,6 +541,10 @@ typedef void *(*VipsObjectSetArguments)( VipsObject *, void *, void * );
VipsObject *vips_object_new( GType type,
VipsObjectSetArguments set, void *a, void *b );
int vips_object_set_valist( VipsObject *object, va_list ap );
int vips_object_set( VipsObject *object, ... )
__attribute__((sentinel));
VipsObject *vips_object_new_from_string( VipsObjectClass *object_class,
const char *p );
void vips_object_to_string( VipsObject *object, VipsBuf *buf );

View File

@ -88,8 +88,10 @@ void vips_operation_class_print_usage( VipsOperationClass *operation_class );
int vips_operation_call_valist( VipsOperation *operation, va_list ap );
VipsOperation *vips_operation_new( const char *name );
int vips_call( const char *operation_name, ... );
int vips_call_split( const char *operation_name, va_list optional, ... );
int vips_call( const char *operation_name, ... )
__attribute__((sentinel));
int vips_call_split( const char *operation_name, va_list optional, ... )
__attribute__((sentinel));
void vips_call_options( GOptionGroup *group, VipsOperation *operation );
int vips_call_argv( VipsOperation *operation, int argc, char **argv );

View File

@ -1770,6 +1770,54 @@ vips_object_new( GType type, VipsObjectSetArguments set, void *a, void *b )
return( object );
}
int
vips_object_set_valist( VipsObject *object, va_list ap )
{
char *name;
VIPS_DEBUG_MSG( "vips_object_set_valist:\n" );
name = va_arg( ap, char * );
while( name ) {
GParamSpec *pspec;
VipsArgumentClass *argument_class;
VipsArgumentInstance *argument_instance;
VIPS_DEBUG_MSG( "\tname = '%s' (%p)\n", name, name );
if( vips_object_get_argument( VIPS_OBJECT( object ), name,
&pspec, &argument_class, &argument_instance ) )
return( -1 );
VIPS_ARGUMENT_COLLECT_SET( pspec, argument_class, ap );
g_object_set_property( G_OBJECT( object ),
name, &value );
VIPS_ARGUMENT_COLLECT_GET( pspec, argument_class, ap );
VIPS_ARGUMENT_COLLECT_END
name = va_arg( ap, char * );
}
return( 0 );
}
int
vips_object_set( VipsObject *object, ... )
{
va_list ap;
int result;
va_start( required, ap );
result = vips_object_set_valist( object, ap );
va_end( ap );
return( result );
}
/* Set object args from a string. @p should be the initial left bracket and
* there should be no tokens after the matching right bracket.
*/

View File

@ -347,41 +347,6 @@ vips_operation_set_valist_required( VipsOperation *operation, va_list ap )
return( 0 );
}
static int
vips_operation_set_valist_optional( VipsOperation *operation, va_list ap )
{
char *name;
VIPS_DEBUG_MSG( "vips_operation_set_valist_optional:\n" );
name = va_arg( ap, char * );
while( name ) {
GParamSpec *pspec;
VipsArgumentClass *argument_class;
VipsArgumentInstance *argument_instance;
VIPS_DEBUG_MSG( "\tname = '%s' (%p)\n", name, name );
if( vips_object_get_argument( VIPS_OBJECT( operation ), name,
&pspec, &argument_class, &argument_instance ) )
return( -1 );
VIPS_ARGUMENT_COLLECT_SET( pspec, argument_class, ap );
g_object_set_property( G_OBJECT( operation ),
name, &value );
VIPS_ARGUMENT_COLLECT_GET( pspec, argument_class, ap );
VIPS_ARGUMENT_COLLECT_END
name = va_arg( ap, char * );
}
return( 0 );
}
static int
vips_operation_get_valist_required( VipsOperation *operation, va_list ap )
{
@ -506,7 +471,7 @@ vips_call_required_optional( VipsOperation **operation,
va_copy( a, required );
va_copy( b, optional );
result = vips_operation_set_valist_required( *operation, a ) ||
vips_operation_set_valist_optional( *operation, b );
vips_object_set_valist( *operation, b );
va_end( a );
va_end( b );