start fixing char->int enums use

oops was doing chart->int incorrectly for glib enums
This commit is contained in:
John Cupitt 2011-07-22 13:51:20 +01:00
parent 8dc7bb5c04
commit 0a4e314194
2 changed files with 51 additions and 0 deletions

32
TODO
View File

@ -1,3 +1,35 @@
- try:
edvips --format=IM_BANDFMT_FLOAT babe.v
leaves it set to uchar
im_char2BandFmt() in vips7compat.c must allow old names as well
- VIPS_ENUM_VALUE() returns a GEnumValue, see
http://developer.gnome.org/gobject/stable/gobject-Enumeration-and-Flag-Types.html#GEnumValue
you need a ->value after it (after checking for a NULL result) to get the
int
check all uses ... seems to be only vips7compat, phew
- turn wrap back on, with renames
vips im_subtract
is the old vips7 interface
vips subtract
is the new unfinished vips8 interface to the same function
- revisit orc conv

View File

@ -223,6 +223,25 @@ const char *im_dtype2char( VipsImageType n )
const char *im_dhint2char( VipsDemandStyle style )
{ return( VIPS_ENUM_STRING( VIPS_TYPE_DEMAND_STYLE, style ) ); }
/* enum string to int, try the GEnum first, then use a compat *char[] for old
* names.
*/
static int
lookup_enum( GType type, char *names[], const char *name )
{
GEnumValue *value;
int i;
if( (value = VIPS_ENUM_VALUE( type, name )) )
return( value->value );
for( i = 0; names[i]; i++ )
if( strcasecmp( names[i], name ) )
return( i );
return( -1 );
}
VipsInterpretation im_char2Type( const char *str )
{ return( VIPS_ENUM_VALUE( VIPS_TYPE_INTERPRETATION, str ) ); }
VipsBandFormat im_char2BandFmt( const char *str )