[Xcb] Hello xcblist.
Thomas Heller
thom.heller at googlemail.com
Thu Feb 4 22:53:10 PST 2010
At first: Sorry Chris for hijacking your thread ...
On Thu, Feb 4, 2010 at 10:15 PM, Barton C Massey <bart at cs.pdx.edu> wrote:
> Thanks much for the post! Interesting stuff.
>
> What motivated you to write C++ bindings for XCB---what did
> you find deficient in the existing C binding?
Before i started writing the bindings i browsed a little through the
libxcb code base.
The main work which is done there (at least it seems like this to me)
is to get the asynchronous
stuff working. As you might know the boost library implements exactly
something like this
it is called asio, which is quite handy and similar to what you
already did. So i saw two options:
1) wrap xcb calls with the help of asio
2) writing it completely from scratch
At the beginning i considered the first option and found [1]. I liked
the general approach to it, but somehow it didn't feel right to me.
After browsing a little more through xcbs code I disliked several
things:
- all the casting of pointers from one type to another type. I
understand that this is common C practice but i believe
such things don't belong into a modern C++ Application
- through your naming scheme inside of libxcb you implicitly
introduce namespaces (with all the prefixes),
you work with lists and iterators.
It would be easy to wrap this into a C++ library, I agree. Though,
you still pull the functions into the global namespace. Additionally
the lists and the iterators come for free by using the stdlib.
After these few considerations I decided to implement the protocol
from scratch. Since you provide the descriptions in the nice xml
documents, this shouldn't be so hard (this was my initial guess). Now
it is 4 months later and i still don't have good results :)
Nevertheless I believe by providing a completely native language
binding (not just a wrapper) you can use the specific features of your
language (which you believe are superior to C, otherwise you wouldn't
program in that language ;)) and don't have to care about the legacy
code you try to wrap.
> Why did you try to write your own generator? What was
> deficient in the Python generator we're using for the C
> bindings?
The biggest problem i had with the python generator was, that it was
written in python ... I can't read that language very well.
Apart from that, I really wanted to get some experience on my own to
write such a compiler. I think the framework provided by Spirit is
quite nice.
On advantage my parsers has over the python generator: It can detect
an error if the given xml doesn't fulfill the "xcb language" defined
in xcb.xsd.
As for now I don't really know if it is easier to write different
output generators with my parser or with your python scripts. I would
like to hear some opinions to that.
I hope that gives you some insight on my motivation. Unfortunately I
currently don't have much time to finish my work in the near future
(aka next two months). It is exams time here :(
Thomas
1. http://www.trexity.de/en/software/xcbcc/
More information about the Xcb
mailing list