[Xcb] Lua binding for XCB

Peter Harris peter.harris at hummingbird.com
Wed Nov 7 08:51:11 PST 2007


Barton C Massey wrote:
> Very cool!  Thanks much for letting us know about it!

No problem.

> Please keep us updated on what you're using it for and how
> it goes!

What I'm actually using it for is a program that will play back an
annotated network trace. This is very helpful for debugging remote problems.

In that case, I use perl with XML::Twig to generate a set of Lua
functions. Each one will take apart a given X request, byte swap if
needed, replace all the XIDs and ATOMs and so on with valid XIDs and
ATOMs for the current server, and then call the matching XCB function.

As to how it goes, it seems to work surprisingly well given the amount
of effort I've spent on it so far. I believe I've spent more time on my
visual-id-matching algorithm than I have spent with XCB, which speaks
well to the ease-of-use of XCB. The predecessor to this project (which
requires manually implementing each function with Xlib) certainly took a
lot more work to get to a similar state.

There are a few nits, of course. I seem to recall that GetProperty was
surprising to implement correctly. XCB does not provide an iterator (or
a set of iterators), only a byte (well, void *) buffer. But the
xcb_get_property_value_length function returns a number of units, not
bytes. Compare and contrast to xcb_get_image_data_length, which appears
to return the number of bytes, not the number of units (pixels). Or any
other xcb_*_length function that isn't matched with an iterator.

ChangeProperty is not correctly implemented in luaxcb because I haven't
gotten around to inverting "op". My current plan is to wait until you
finish xserver-XCB and borrow that code.

The other minor nit is the lack of type information for the
CreateWindow, ChangeWindowAttributes, Create/ChangeGC, and
ConfigureWindow bit masks. This is the only place (so far) where I've
had to manually set type information (XID vs integer).

Right now, I'm optimistic that XCB will make my life much easier when it
comes to implementing extensions. With one exception: It looks like GLX
won't be possible to implement with the current XML definition. I need
to be able to take apart the contents of Render/RenderLarge in order to
byte swap if necessary. Implementing all the possible GLX/Render
sub-requests is a huge chore, but at least I'm not the only person who
would use such a thing. Any xmond, xscope, or similar based on XCB will
want to be able to take apart the contents of GLX/Render, too.

Thanks for XCB!

Peter Harris

-- 
     Hummingbird Connectivity - A Division of Open Text
Peter Harris                    http://connectivity.hummingbird.com
Research and Development        Phone: +1 905 762 6001
peter.harris at hummingbird.com    Toll Free: 1 877 359 4866


More information about the Xcb mailing list