[Xcb] C code mapping of <switch>

Peter Harris pharris at opentext.com
Wed Jun 9 08:49:34 PDT 2010


On 2010-06-05 03:47, Christoph Reimann wrote:
> This, again, looks a lot like xcb_aux_create_window.
> Last I would like to serialize switch element-wise (see my other
> mail), i.e. generate as many if statements as there are fields in
> xcb_create_window_value_list_t and send only those struct fields on
> the wire where value_mask  indicates it, in pseudo-code for
> fixed-sized bitcase fields:

Looks good.

> if ((switch_mask & bitcase_mask) == bitcase_mask) {

Except for this line, which is indicative of a mind poisoned by Java. :-)

That will work, but the C idiom is:

if (switch_mask & bitcase_mask) {

when only one bit is set in bitcase_mask.

> I am glad for any comments, please note that I would only like to test
> switch at this stage, so this is not necessarily a proposal to replace
> all valueparams with it (especially as the API would change).

If you were to generate the switch as a helper function that populated a
buffer passed into it, and generated the request function such that it
takes a void pointer where the switch is, then the function signature of
the rest of the function wouldn't change sufficiently to break the API.

IMO, one of the goals of XCB is to allow efficient usage, and push
complexity into helpers and wrappers. If you *want* to hand-roll (and/or
cache) the complex part of the request, you should be able to.

But I don't have strong feelings on this. Would anybody else on the list
like to comment?

Peter Harris
-- 
               Open Text Connectivity Solutions Group
Peter Harris                    http://connectivity.opentext.com/
Research and Development        Phone: +1 905 762 6001
pharris at opentext.com            Toll Free: 1 877 359 4866


More information about the Xcb mailing list