[Xcb] Using COMMENT, and a Better Way for enums

James Mastros james@mastros.biz
Thu, 06 Nov 2003 22:56:09 +0100

Hello, all.
   I'm working on a perl version of XCB (can we get a name that isn't 
tied to C, BTW?), and I've got a minor rant, and a proposal.

First, the minor rant: While COMMENT is defined, it's almost never used. 
  The m4 files contain comments in the form of /* ... */.  This makes it 
quite obnoxious to try to generate things other then c with it.

That one is easy, since there's already a defined API for it.  enums, my 
next topic, require a new one, since the existing one is rather poor.

I propose the following.
ENUM(`CW', `
   ENUMELEM(`BackPixmap', NTHBIT(0))
   ENUMELEM(`BackPixel', NTHBIT(1))

The definition of ENUM needn't change in this proposal (I'm using ENUM 
instead of XCBENUM here.  The only difference seems to be that XCBENUM 
prepends XCB to the name given.

The definitions of the other two macros could be, for client-c.xcb:
DEFINE(`ENUMELEM', $1` = '$2)
DEFINE(`NTHBIT', `1L<<'$1)

That should allow me to define them the way I need for perl.  Other 
languages may be a problem if they have different ideas of numeric 
literals then C, but this seems unlikely in practice.  (In particular, 
almost all enums will be 42, 0x2a, or NTHBIT(4).)

Oh, one other thing.  The extensions/ files seem to have another sort of 
literal C -- typedefs.  I'd much rather see TYPEDEF(`INT32', `FIXED'), 
and the related make_fixed be in some higher layer completely.

BTW, the perl implementation isn't nearly ready for public perusal yet. 
  While I think I'm done making huge changes to the existing pieces of 
infrastructure, there's a whole two layers that aren't there yet.  This 
is my first low-level X programming, so I'm taking it a bit on the slow 

	-=- James Mastros

PS -- If I'm a bit harsh or unpolished in spots, I blame my mail client, 
which ate the first version of this mail.