[Xcb] PATCH: Removing macros in xcl.h and adding casts to Xlib types

Jamey Sharp jamey at minilop.net
Fri Jul 22 16:41:49 EST 2005


On Sun, 2005-07-17 at 09:11 -0700, Travis Spencer wrote:
> On 7/17/05, Barton C Massey <bart at cs.pdx.edu> wrote:
> > If the cast macros in the source are confusing, I think
> > there are two better options: (1) move the cast function
> > generation into the XCB-XML, 
> 
> Plus, I don't think any of XCL is being generated with
> XCB-XML at the momement, ...

True, but there's some checked-in code that once upon a time was
auto-generated from the m4. It'd be nice to pick that up again and
extend it to cover more of the protocol.

> > or (2) document the macros
> > properly.  
> 
> That wouldn't hurt.  I didn't even notice them for a while.  I just
> harry C code and glanced right by 'em.

Yeah, I wrote them long enough ago that I tend to forget about them
myself, despite having written about them in the XCL paper.

> > The features of macro-based generation are (a)
> > fixes to the generation code propagate to all the cast
> > functions, and 
> 
> There are only 14 macros.  That isn't a big job if they all need to be
> modified in some way.

No. Copy/paste code is wrong and I will rip it out if it gets committed.

Hmmm. That's perhaps excessively harsh wording. I feel strongly about
this though.

> > Definitely bug the list before you work on something like
> > this; 
> 
> It only took an hour or so, so I'm not worried about it.  By "bug
> list" do you mean send an e-mail describing the idea to the list first
> and get some feedback before setting out on the work?

I don't completely agree with Bart on this. It doesn't hurt the rest of
us to see a patch go by for something, and the process of trying to
implement your idea may sometimes help you realize that it wasn't a good
one. Also, a patch can sometimes illustrate an idea much better than
some quickly-written English.

That said, I think both Bart and I would like to help you do as much
work on your actual course project as possible, and a little discussion
every once in a while might give us the opportunity to suggest easier
ways to get done whatever work you need to do.

> > we'd be happy to discuss it with you.  Thanks much, in
> > any case, for the thought and the submission!
> 
> Even if the patch isn't accepted, I want the functionality to cast
> from XCB types to Xlib types.  I really hope you'll reconsider
> accepting this patch, but if not, I would like to add these other
> casts somewhere in the XCL.

I don't understand why. Just accessing the .xid or .id member is a lot
simpler in every way that I can see. You're not gaining any type-safety
by putting the structure member access inside a function; doing the
conversion requires more typing this way; and it's really easy to just
write a structure member access wherever you need it.

Can you explain why you preferred the extra functions?

--Jamey



More information about the xcb mailing list