[Xcb] xproto test failed

Barton C Massey bart at cs.pdx.edu
Tue Feb 17 17:14:59 PST 2009


In message <eaa105840902161846l364e2430l18e8a7e9417915db at mail.gmail.com> you wrote:
> > So, yes. :-) It seems like it might be nice to modify the C
> > codegen to use the new annotations also, though?  Can't the
> > new annotations be used to do things like automatically
> > generate union types for altenums?  Or am I still confused?
> 
> I think you're still confused.

It's been known to happen. :-)

> "altenum" is for types like "WINDOW, but may also contain
> the magic values None or CopyFromParent", or "ATOM, but
> may also contain the magic value Any". So on the C side,
> it needs to be an XID.

Yes. The "natural" C type for the first of these would seem
to me to be something vaguely like

  typedef union {
    uint32_t xid;
    xcb_window_class_t window_class;
  } xcb_special_window_t;

You would then use an xcb_special_window_t in places like
xcb_create_window_request() where these special values can
appear.  This could all be generated from the XML given
altenum tags in the right places, it seems like?

We used to have a more extreme version of this for Drawables
in XCB, but everybody hated it so we ripped it out.

> If you make a union out of that, the compiler is free to turn the XID
> part into garbage, and then your on-wire will be broken (unless you
> start adding flags to indicate which part of the union you used, which
> would break the current API and ABI, and just generally make libxcb
> harder to use).

I'm certainly not proposing to add new flags.  I don't think
my proposal above would break anything. It's just a
convenience when you're working with gdb and can't remember
which magic constant corresponds to which semantics.  But it
also crufts things up quite a bit, so maybe it's a net loss.

> Honestly, altenum wasn't my idea. But it's not a terrible idea, and I
> figured I could get more discussion out of implementing it than by
> trying to attract more people to this thread (linked to the message
> that prompted me to cook up 'altenum'):
> http://lists.freedesktop.org/archives/xcb/2009-January/004226.html
> That thread just died as soon as I proposed altenum.

I think it's a fine extension and a fine attribute name.
Thanks much for doing it!

> Once I finish this pass of annotations (both to xproto and the
> extensions), my Grand Plan is to start adding type annotations to
> enums themselves, and attach those enums to <valueparam>s. This would
> allow us to auto-generate xcb/util/aux's xcb_aux_create_window (and
> xcb_params_cw_t) and friends if we wanted to. But that's in the rather
> distant future (unless someone else steps in, of course).

I'm not quite following the mechanism, because I'm slow
sometimes.  But auto-generating all that xcb_aux* cruft is a
worthy goal IMHO.

Again, thanks.

    Bart


More information about the Xcb mailing list