[cairo] [API] unbreak CAIRO_FONT_TYPE_ATSUI

Vladimir Vukicevic vladimir at pobox.com
Mon Mar 24 14:00:48 PDT 2008

On Mar 24, 2008, at 12:38 PM, Torsten Schoenfeld wrote:

> On Mon, 2008-03-24 at 12:20 -0700, Vladimir Vukicevic wrote:
>> The only thing that breaks with this is that you can't use the values
>> in case statements any more, but I'd think that's pretty uncommon in
>> user code.
> But I think it's a pretty common thing for bindings to do.  When they,
> for example, try to find out how to represent a surface, they switch
> over its type.  The switch statement can be replaced with if - else  
> if -
> else of course, but then you'd need to use strncmp instead of simply  
> ==
> too if enums are replaced with strings.

No, you would use ==; the string isn't relevant, just the address of  
the string.  (Much like the way user data keys are done.)

There may be a bit of extra work that needs to be done, I agree; but I  
think that it would be worth it to avoid problems like this in the  
future, and to allow people to create experimental backends without  
worrying about clashing enum values.  We could also hardcode the  
current values (0, 1, 2, 3, etc.) so that switch-using bindings would  
continue to work.. only when they wanted to wrap new types would they  
have to change their code.

     - Vlad

More information about the cairo mailing list