[Xcb] Funky casts

Jamey Sharp jamey at minilop.net
Fri Mar 10 22:02:15 PST 2006


On Fri, Mar 10, 2006 at 02:17:36PM -0500, Jeremy A. Kolb wrote:
> So for some reason I can't wrap my head around this.  Don't laugh!

I didn't and won't. :-) I read your e-mail and thought, "Oh, crap.
That's a pain."

> So I have a XCBGlxDRAWABLE.  XCBGlxMakecurrent takes one of these.  I 
> SHOULD just be able to pass in an XCBWINDOW since both are xid types and a 
> window can be used as a glx drawable (this is how xlib does it).  However 
> I cannot pass this into the function and no amount of casting results in 
> compileable code.  Most likely my grasp of c sucks ;)

No, it's just that XCB is trying to help you. ;-)

Bart and I discussed the problem and decided that glx.xml needs a
declaration something like this (except that my grasp of the XML
protocol descriptions is fairly shaky):

<union name="DRAWABLE">
  <field type="WINDOW" name="window" />
  <field type="DRAWABLE" name="core" />
</union>

It was never correct to declare the glx DRAWABLE as an <xidtype>: it
isn't something you can allocate, only a union of several other
<xidtype>s.

Anyway, this remains a bit of a pain to use in C. You'll need to declare
an XCBGlxDRAWABLE somewhere, then assign your XCBWINDOW into the
core.window member, and finally pass that into your function. An
optimizing compiler will hopefully generate no code for that process:
it's just a hint (or a blow to the head) for the type-checker.

Perhaps Alp's idea of using inheritance to model these unions is a good
idea, for those languages that support it?

--Jamey
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.freedesktop.org/archives/xcb/attachments/20060310/7a8cf471/attachment.pgp


More information about the Xcb mailing list