better vips list classes output

This commit is contained in:
John Cupitt 2011-11-19 12:51:13 +00:00
parent 187212768d
commit b41b9ac19c
5 changed files with 25 additions and 34 deletions

11
TODO
View File

@ -1,21 +1,12 @@
- test docs - test docs
do polar.c
do we need a VipsUnary subclass for complex? needs to cast input to complex
before it starts
do polar/rectangular/conjugate in it
or maybe have a single thing with an enum for complex ops lke this
- look at the help message from the vips-7.27 script - look at the help message from the vips-7.27 script
try - try
$ vips join $ vips join
... usage ... ... usage ...

View File

@ -265,7 +265,7 @@ vips_format_map( VSListMap2Fn fn, void *a, void *b )
formats = NULL; formats = NULL;
(void) vips_class_map_all( g_type_from_name( "VipsFormat" ), (void) vips_class_map_all( g_type_from_name( "VipsFormat" ),
(VipsClassMap) format_add_class, (void *) &formats ); (VipsClassMapFn) format_add_class, (void *) &formats );
formats = g_slist_sort( formats, (GCompareFunc) format_compare ); formats = g_slist_sort( formats, (GCompareFunc) format_compare );
result = im_slist_map2( formats, fn, a, b ); result = im_slist_map2( formats, fn, a, b );

View File

@ -459,16 +459,17 @@ void vips_object_to_string( VipsObject *object, VipsBuf *buf );
void *vips_object_map( VipsSListMap2Fn fn, void *a, void *b ); void *vips_object_map( VipsSListMap2Fn fn, void *a, void *b );
typedef void *(*VipsTypeMap)( GType, void * ); typedef void *(*VipsTypeMapFn)( GType, void * );
typedef void *(*VipsTypeMap2)( GType, void *, void * ); typedef void *(*VipsTypeMap2Fn)( GType, void *, void * );
typedef void *(*VipsClassMap)( VipsObjectClass *, void * ); typedef void *(*VipsClassMapFn)( VipsObjectClass *, void * );
void *vips_type_map( GType base, VipsTypeMap2 fn, void *a, void *b ); void *vips_type_map( GType base, VipsTypeMap2Fn fn, void *a, void *b );
void *vips_type_map_all( GType base, VipsTypeMap fn, void *a ); void *vips_type_map_all( GType base, VipsTypeMapFn fn, void *a );
void *vips_class_map_all( GType base, VipsClassMap fn, void *a ); int vips_type_depth( GType type );
int vips_class_depth( VipsObjectClass *klass );
VipsObjectClass *vips_class_find( const char *basename, const char *nickname );
GType vips_type_find( const char *basename, const char *nickname ); GType vips_type_find( const char *basename, const char *nickname );
void *vips_class_map_all( GType base, VipsClassMapFn fn, void *a );
VipsObjectClass *vips_class_find( const char *basename, const char *nickname );
VipsObject **vips_object_local_array( VipsObject *parent, int n ); VipsObject **vips_object_local_array( VipsObject *parent, int n );
void vips_object_local_cb( VipsObject *vobject, GObject *gobject ); void vips_object_local_cb( VipsObject *vobject, GObject *gobject );

View File

@ -1658,7 +1658,7 @@ vips_object_map( VipsSListMap2Fn fn, void *a, void *b )
/* Map over all a type's children. /* Map over all a type's children.
*/ */
void * void *
vips_type_map( GType base, VipsTypeMap2 fn, void *a, void *b ) vips_type_map( GType base, VipsTypeMap2Fn fn, void *a, void *b )
{ {
GType *child; GType *child;
guint n_children; guint n_children;
@ -1677,21 +1677,21 @@ vips_type_map( GType base, VipsTypeMap2 fn, void *a, void *b )
/* Loop over all the subtypes of a base type. /* Loop over all the subtypes of a base type.
*/ */
void * void *
vips_type_map_all( GType base, VipsTypeMap fn, void *a ) vips_type_map_all( GType base, VipsTypeMapFn fn, void *a )
{ {
void *result; void *result;
if( !(result = fn( base, a )) ) if( !(result = fn( base, a )) )
result = vips_type_map( base, result = vips_type_map( base,
(VipsTypeMap2) vips_type_map_all, fn, a ); (VipsTypeMap2Fn) vips_type_map_all, fn, a );
return( result ); return( result );
} }
/* Loop over all the subclasses of a base type. /* Loop over all the subclasses of a base type. Non-abtract classes only.
*/ */
void * void *
vips_class_map_all( GType type, VipsClassMap fn, void *a ) vips_class_map_all( GType type, VipsClassMapFn fn, void *a )
{ {
void *result; void *result;
@ -1707,7 +1707,7 @@ vips_class_map_all( GType type, VipsClassMap fn, void *a )
} }
if( (result = vips_type_map( type, if( (result = vips_type_map( type,
(VipsTypeMap2) vips_class_map_all, fn, a )) ) (VipsTypeMap2Fn) vips_class_map_all, fn, a )) )
return( result ); return( result );
return( NULL ); return( NULL );
@ -1716,12 +1716,10 @@ vips_class_map_all( GType type, VipsClassMap fn, void *a )
/* How deeply nested is a class ... used to indent class lists. /* How deeply nested is a class ... used to indent class lists.
*/ */
int int
vips_class_depth( VipsObjectClass *class ) vips_type_depth( GType type )
{ {
int depth; int depth;
GType type;
type = G_TYPE_FROM_CLASS( class );
depth = 0; depth = 0;
while( type != VIPS_TYPE_OBJECT && (type = g_type_parent( type )) ) while( type != VIPS_TYPE_OBJECT && (type = g_type_parent( type )) )
depth += 1; depth += 1;
@ -1761,7 +1759,7 @@ vips_class_find( const char *basename, const char *nickname )
} }
if( !(class = vips_class_map_all( base, if( !(class = vips_class_map_all( base,
(VipsClassMap) test_name, (void *) nickname )) ) { (VipsClassMapFn) test_name, (void *) nickname )) ) {
vips_error( "VipsObject", vips_error( "VipsObject",
_( "class \"%s\" not found" ), nickname ); _( "class \"%s\" not found" ), nickname );
return( NULL ); return( NULL );

View File

@ -165,14 +165,15 @@ list_function( im_function *func )
} }
static void * static void *
list_class( VipsObjectClass *class ) list_class( GType type )
{ {
int depth = vips_class_depth( class ); int depth = vips_type_depth( type );
int i; int i;
for( i = 0; i < depth * 2; i++ ) for( i = 0; i < depth * 2; i++ )
printf( " " ); printf( " " );
vips_object_print_class( class ); vips_object_print_class(
VIPS_OBJECT_CLASS( g_type_class_ref( type ) ) );
return( NULL ); return( NULL );
} }
@ -183,8 +184,8 @@ print_list( int argc, char **argv )
if( !argv[0] || strcmp( argv[0], "packages" ) == 0 ) if( !argv[0] || strcmp( argv[0], "packages" ) == 0 )
im_map_packages( (VSListMap2Fn) list_package, NULL ); im_map_packages( (VSListMap2Fn) list_package, NULL );
else if( strcmp( argv[0], "classes" ) == 0 ) else if( strcmp( argv[0], "classes" ) == 0 )
vips_class_map_all( g_type_from_name( "VipsObject" ), vips_type_map_all( g_type_from_name( "VipsObject" ),
(VipsClassMap) list_class, NULL ); (VipsTypeMapFn) list_class, NULL );
else { else {
if( map_name( argv[0], list_function ) ) if( map_name( argv[0], list_function ) )
error_exit( "unknown package \"%s\"", argv[0] ); error_exit( "unknown package \"%s\"", argv[0] );