[cairo] Missing const in cairo API ?

Damien Carbonne aetdcarbonne at free.fr
Sun Oct 1 14:43:44 PDT 2006


Hello,

I'm new to this list. I'm presently trying to write an Ada binding to 
Cairo and have some questions about usage of const in C API. Sorry if 
this has already been asked in this list.
I'll give two examples :

   cairo_public void
   cairo_scaled_font_extents (cairo_scaled_font_t  *scaled_font,
                                               cairo_font_extents_t 
*extents);

   cairo_public cairo_status_t
   cairo_font_face_status (cairo_font_face_t *font_face);


Why aren't they defined as :
   cairo_public void
   cairo_scaled_font_get_extents (const cairo_scaled_font_t  *scaled_font,
                                                      
cairo_font_extents_t *extents);

   cairo_public cairo_status_t
   cairo_font_face_get_status (const cairo_font_face_t *font_face);

 From documentation, it would seem legitimate to believe that such 
functions should not modify scaled font or font face objects.
When reading cairomm API, I've the feeling they sometimes make the same 
assumption, using const_cast.

    inline ErrorStatus get_status() const
   { return 
cairo_font_face_status(const_cast<cairo_font_face_t*>(cobj())); }

I've met many other places where I've such comments.
If this is meaningful, I can list all of them.

Thanks

Damien Carbonne


More information about the cairo mailing list