Re: [cairo] Re: cairo c++ bindings



Hi all,

I'm very interested in the development of a good C++ wrapper for cairo.
I was writting a wrapper for a personal project (and for the fun of it ;) ).

Here are my thoughts on this:

- Deriving from the cairo structures:
In my opinion this should _really_ be avoided. This is suposed to be a cairo wrapper, not an extension to it.
The wrapper classes should have a member that is the type they are wrapping.
If access to the underlying types is really necessary we should have the necessary inspectors in the wrapper classes.

- Reference handling
All the details about reference counted objects should be hidden from the user of the wrapper. The wrapper should make using cairo as straightforward as possible.
When possible (and logical) to copy an object,  copy assignment operator and/or constructor should be defined.

- Error handling
In the wrapper i was writting (am writting?, depends on where Cairomm is going ;) ) I was considering using policies (like Andrei Alexandrescu did in his book Modern C++ Design and his lib : loki ) to specify how I wanted cairo errors to be handled.
I was considering having a policy that would simply ignore the errors (and have no overhead). This would allow to take advantage of cairo's behaviour when an error is ignored : the operations on an "object" in an error state are also ignored.
The other policy I was considering would (automatically) check for errors after calling a function call that might generate them and would throw an adequate exception.

-  Inline  methods
I'm in favor of having the wrapper be completely/mostly defined in .hpp files. I don't think this should be a full blown library. I would personally prefer a using "thin" wrapper over a complete library, as long as it was designed elegantly and had little/no runtime overhead.
Also, my inclination to use policies implies that the wrapper classes would be templates ...


If you need any help developing Cairomm, I really would like to help.

Rui Pires



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]