sync
This commit is contained in:
parent
958544e5cd
commit
bbaef3dad1
5
TODO
5
TODO
@ -1,3 +1,8 @@
|
|||||||
|
- see TODO comment on vips_call_options_set()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- cmd line interface needs to print optional output args, if requested
|
- cmd line interface needs to print optional output args, if requested
|
||||||
|
|
||||||
eg.
|
eg.
|
||||||
|
@ -504,43 +504,37 @@ vips_call_split( const char *operation_name, va_list optional, ... )
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
vips_call_char_option( VipsObject *object,
|
vips_call_find_pspec_char( VipsObject *object,
|
||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
VipsArgumentClass *argument_class,
|
VipsArgumentClass *argument_class,
|
||||||
VipsArgumentInstance *argument_instance,
|
VipsArgumentInstance *argument_instance,
|
||||||
void *a, void *b )
|
void *a, void *b )
|
||||||
{
|
{
|
||||||
const char *name = (const char *) a;
|
const char *name = (const char *) a;
|
||||||
const char *value = (const char *) b;
|
|
||||||
|
|
||||||
if( !(argument_class->flags & VIPS_ARGUMENT_REQUIRED) &&
|
if( !(argument_class->flags & VIPS_ARGUMENT_REQUIRED) &&
|
||||||
(argument_class->flags & VIPS_ARGUMENT_CONSTRUCT) &&
|
(argument_class->flags & VIPS_ARGUMENT_CONSTRUCT) &&
|
||||||
!argument_instance->assigned &&
|
!argument_instance->assigned &&
|
||||||
g_param_spec_get_name( pspec )[0] == name[0] )
|
g_param_spec_get_name( pspec )[0] == name[0] )
|
||||||
if( vips_object_set_argument_from_string( object,
|
return( pspec );
|
||||||
g_param_spec_get_name( pspec ), value ) )
|
|
||||||
return( object );
|
|
||||||
|
|
||||||
return( NULL );
|
return( NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
vips_call_name_option( VipsObject *object,
|
vips_call_find_pspec_name( VipsObject *object,
|
||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
VipsArgumentClass *argument_class,
|
VipsArgumentClass *argument_class,
|
||||||
VipsArgumentInstance *argument_instance,
|
VipsArgumentInstance *argument_instance,
|
||||||
void *a, void *b )
|
void *a, void *b )
|
||||||
{
|
{
|
||||||
const char *name = (const char *) a;
|
const char *name = (const char *) a;
|
||||||
const char *value = (const char *) b;
|
|
||||||
|
|
||||||
if( !(argument_class->flags & VIPS_ARGUMENT_REQUIRED) &&
|
if( !(argument_class->flags & VIPS_ARGUMENT_REQUIRED) &&
|
||||||
(argument_class->flags & VIPS_ARGUMENT_CONSTRUCT) &&
|
(argument_class->flags & VIPS_ARGUMENT_CONSTRUCT) &&
|
||||||
!argument_instance->assigned &&
|
!argument_instance->assigned &&
|
||||||
strcmp( g_param_spec_get_name( pspec ), name ) == 0 )
|
strcmp( g_param_spec_get_name( pspec ), name ) == 0 )
|
||||||
if( vips_object_set_argument_from_string( object,
|
return( pspec );
|
||||||
g_param_spec_get_name( pspec ), value ) )
|
|
||||||
return( object );
|
|
||||||
|
|
||||||
return( NULL );
|
return( NULL );
|
||||||
}
|
}
|
||||||
@ -551,6 +545,7 @@ vips_call_options_set( const gchar *option_name, const gchar *value,
|
|||||||
{
|
{
|
||||||
VipsOperation *operation = (VipsOperation *) data;
|
VipsOperation *operation = (VipsOperation *) data;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
GParamSpec *pspec;
|
||||||
|
|
||||||
VIPS_DEBUG_MSG( "vips_call_options_set: %s = %s\n",
|
VIPS_DEBUG_MSG( "vips_call_options_set: %s = %s\n",
|
||||||
option_name, value );
|
option_name, value );
|
||||||
@ -561,25 +556,34 @@ vips_call_options_set( const gchar *option_name, const gchar *value,
|
|||||||
;
|
;
|
||||||
|
|
||||||
/* If this is a single-character name, find the first unset pspec with
|
/* If this is a single-character name, find the first unset pspec with
|
||||||
* that initial. Otherwise, search for a spec of that nmae.
|
* that initial. Otherwise, search for a spec of that name.
|
||||||
*/
|
*/
|
||||||
if( strlen( name ) == 1 ) {
|
if( strlen( name ) == 1 )
|
||||||
if( vips_argument_map( VIPS_OBJECT( operation ),
|
pspec = (GParamSpec *) vips_argument_map(
|
||||||
vips_call_char_option,
|
VIPS_OBJECT( operation ),
|
||||||
(void *) name, (void *) value ) ) {
|
vips_call_find_pspec_char,
|
||||||
vips_error_g( error );
|
(void *) name, NULL );
|
||||||
return( FALSE );
|
else
|
||||||
}
|
pspec = (GParamSpec *) vips_argument_map(
|
||||||
}
|
VIPS_OBJECT( operation ),
|
||||||
else {
|
vips_call_find_pspec_name,
|
||||||
if( vips_argument_map( VIPS_OBJECT( operation ),
|
(void *) name, NULL );
|
||||||
vips_call_name_option,
|
if( !pspec ) {
|
||||||
(void *) name, (void *) value ) ) {
|
vips_error( VIPS_OBJECT( operation )->nickname,
|
||||||
vips_error_g( error );
|
_( "unknown argument '%s'" ), name );
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* FIXME ... for output args, need to attach a close callback to
|
||||||
|
* operation to write the value
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
if( vips_object_set_argument_from_string( VIPS_OBJECT( operation ),
|
||||||
|
name, value ) )
|
||||||
|
return( FALSE );
|
||||||
|
|
||||||
return( TRUE );
|
return( TRUE );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -596,23 +600,23 @@ vips_call_options_add( VipsObject *object,
|
|||||||
(argument_class->flags & VIPS_ARGUMENT_CONSTRUCT) &&
|
(argument_class->flags & VIPS_ARGUMENT_CONSTRUCT) &&
|
||||||
!argument_instance->assigned ) {
|
!argument_instance->assigned ) {
|
||||||
const char *name = g_param_spec_get_name( pspec );
|
const char *name = g_param_spec_get_name( pspec );
|
||||||
|
gboolean needs_string =
|
||||||
|
vips_object_get_argument_needs_string( object, name );
|
||||||
GOptionEntry entry[2];
|
GOptionEntry entry[2];
|
||||||
|
|
||||||
entry[0].long_name = name;
|
entry[0].long_name = name;
|
||||||
entry[0].short_name = name[0];
|
entry[0].short_name = name[0];
|
||||||
|
|
||||||
entry[0].flags = 0;
|
entry[0].flags = 0;
|
||||||
if( vips_object_get_argument_needs_string( object, name ) )
|
if( !needs_string )
|
||||||
entry[0].flags |= G_OPTION_FLAG_NO_ARG;
|
entry[0].flags |= G_OPTION_FLAG_NO_ARG;
|
||||||
|
|
||||||
entry[0].arg = G_OPTION_ARG_CALLBACK;
|
entry[0].arg = G_OPTION_ARG_CALLBACK;
|
||||||
entry[0].arg_data = (gpointer) vips_call_options_set;
|
entry[0].arg_data = (gpointer) vips_call_options_set;
|
||||||
entry[0].description = g_param_spec_get_blurb( pspec );
|
entry[0].description = g_param_spec_get_blurb( pspec );
|
||||||
if( G_IS_PARAM_SPEC_BOOLEAN( pspec ) )
|
if( needs_string )
|
||||||
entry[0].arg_description = NULL;
|
|
||||||
else
|
|
||||||
entry[0].arg_description =
|
entry[0].arg_description =
|
||||||
g_type_name( G_PARAM_SPEC_VALUE_TYPE( pspec ) );
|
g_type_name( G_PARAM_SPEC_VALUE_TYPE( pspec ) );
|
||||||
|
else
|
||||||
|
entry[0].arg_description = NULL;
|
||||||
|
|
||||||
entry[1].long_name = NULL;
|
entry[1].long_name = NULL;
|
||||||
|
|
||||||
@ -701,11 +705,12 @@ vips_call_argv_output( VipsObject *object,
|
|||||||
if( (argument_class->flags & VIPS_ARGUMENT_INPUT) )
|
if( (argument_class->flags & VIPS_ARGUMENT_INPUT) )
|
||||||
call->i += 1;
|
call->i += 1;
|
||||||
else if( (argument_class->flags & VIPS_ARGUMENT_OUTPUT) ) {
|
else if( (argument_class->flags & VIPS_ARGUMENT_OUTPUT) ) {
|
||||||
|
const char *name = g_param_spec_get_name( pspec );
|
||||||
const char *arg;
|
const char *arg;
|
||||||
|
|
||||||
arg = NULL;
|
arg = NULL;
|
||||||
if( vips_object_get_argument_needs_string( object,
|
if( vips_object_get_argument_needs_string( object,
|
||||||
g_param_spec_get_name( pspec ) ) ) {
|
name ) ) {
|
||||||
arg = vips_call_get_arg( call, call->i );
|
arg = vips_call_get_arg( call, call->i );
|
||||||
if( !arg )
|
if( !arg )
|
||||||
return( pspec );
|
return( pspec );
|
||||||
@ -714,7 +719,7 @@ vips_call_argv_output( VipsObject *object,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( vips_object_get_argument_to_string( object,
|
if( vips_object_get_argument_to_string( object,
|
||||||
g_param_spec_get_name( pspec ), arg ) )
|
name, arg ) )
|
||||||
return( pspec );
|
return( pspec );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user