[cairo] cairomm enums

Jonathon Jongsma jonathon.jongsma at gmail.com
Sun Feb 26 20:07:54 PST 2006


Anyone that cares about the cairomm API:

Currently cairomm uses the base cairo enum types but typedef-ed in the
Cairo namespace.  For example, cairo_line_cap_t becomes Cairo::LineCap
due to something like:
typedef cairo_line_cap_t LineCap;

The enum values themselves are the same pseudo-namespaced values used
in Cairo, i.e.:
    CAIRO_LINE_CAP_BUTT,
    CAIRO_LINE_CAP_ROUND,
    CAIRO_LINE_CAP_SQUARE

gtkmm, on the other hand, generates its own enum values that are
defined in terms of the base enum values.  In the case of cairomm,
this might look something like:

typedef enum
{
    LINE_CAP_BUTT = CAIRO_LINE_CAP_BUTT,
    LINE_CAP_ROUND = CAIRO_LINE_CAP_ROUND,
    LINE_CAP_SQUARE = CAIRO_LINE_CAP_SQUARE
} LineCap;

Then the application would use a namespace-qualified value for the
enum value (e.g. Cairo::LINE_CAP_BUTT instead of CAIRO_LINE_CAP_BUTT).
  The obvious drawback to this method is that the values are defined
twice, so the C++ enum wrapper could get out of sync with the base C
enum values.  But it does seem nice to keep everything in the Cairo
namespace, and Cairo is a small enough library that it shouldn't be
too hard to keep things in sync.

Does anybody have any opinions on this?  I'm kind of inclined to wrap
them in the Cairo namespace, but I could be persuaded either way.

Jonner


More information about the cairo mailing list