[cairo] API completeness of reference/user_data pairs

Steve Chaplin stevech1097 at yahoo.com.au
Mon Jan 29 20:40:59 PST 2007


On Mon, 2007-01-29 at 16:13 -0500, Behdad Esfahbod wrote:
> I wanted to propose new API for cairo_font_options_reference().
> I reported this in bugzilla somewhere, but can't find it.
> In short, I think the required malloc for an opaque value type is
> unnecessary overhead.
> 
> But when I thought about it, I remembered that to make life
> easier for language bindings, all referenced types need to have
> destroy notification for the least, and user data preferably.  In
> cairo, both are available using the user_data idiom.
> 
> However, it seems like from the five referenced types in cairo:
> 
> $ grep '^cairo.*_reference' cairo.h
> cairo_reference (cairo_t *cr);
> cairo_font_face_reference (cairo_font_face_t *font_face);
> cairo_scaled_font_reference (cairo_scaled_font_t *scaled_font);
> cairo_surface_reference (cairo_surface_t *surface);
> cairo_pattern_reference (cairo_pattern_t *pattern);
> 
> Only two have user_data:
> 
> $ grep '^cairo.*_set_user_data' cairo.h
> cairo_font_face_set_user_data (cairo_font_face_t *font_face,
> cairo_surface_set_user_data (cairo_surface_t *surface,
> 
> Is there any reason that the other three don't have user_data?
> How do language bindings deal with this currently?

For Python, we ignore the _set_user_data and _get_user_data functions -
we do not provide Python bindings for them, nor do we use them to write
bindings for other functions, and we don't use the destroy notification.

We wrap cairo objects inside Python objects, calling _reference() (if
needed) when a new Python object is created, and call destroy() when the
Python object is destroyed. 

Steve

Send instant messages to your online friends http://au.messenger.yahoo.com 


More information about the cairo mailing list