[Xcb] [PATCH proto 00/18] Use explicit enum values and use hex value
Josh Triplett
josh at joshtriplett.org
Sun Aug 18 09:48:34 PDT 2013
On Sun, Aug 18, 2013 at 04:54:00PM +0200, Daniel Martin wrote:
> explicit is better than implicit. This applies for padding and in my
> opinion for enum item values too.
>
> Values for enum items don't change dynamically. We have the values at
> hand when adding an enum to an xml specification. We should have this
> information where it belongs and not omit it.
> And there're programming languages not having support for enumerations
> (or at least to in the beginning - see Java and Python). Such a language
> would need to adopt the c compilers counting scheme for enum items
> without a value. That's not a big deal, but won't be necessary if we
> simply add the value we already have.
>
> That's what the first 15 patches do: add those values. Number 16 makes
> sure that new enums can't be added without a bit or value by changing
> the xml schema accordingly. (Side note: without this patch one could
> write any expression into an enum item, i.e. <fieldref>foo</fieldref>
> would've been allowed by the schema.)
I can actually imagine a sensible meaning for fieldref in an enum
(referencing another enum value), but yes. :)
> The last 2 patches use hex values instead of decimal values if
> applicable (if there was a comment with a hex value). The schema allows
> it, c_client.py passes them 1:1 into the header. So, I don't see why no
> one did that before (maybe didn't worked when those comments had been
> added, didn't checked).
>
> Hex values can be more descriptive than decimal values. Examples:
> - In glx there was GL_ALL_ATTRIB_BITS=16777215, 16777215 is a big number
> but I don't see directly that this is a number with all last bits set
> to one, as 16777215 == 0x000ffffff.
> - In XKB have been enum items with 256, 512, 768, ... as values. Those
> could've been changed to bits. But, the XKB spec. uses hex values
> there: 0x100, 0x200, 0x300, ... So, I've choosen the hex values.
>
>
> Cheers,
>
> Daniel Martin (18):
> composite: Use explicit enum value
> damage: Use explicit enum value
> dpms: Use explicit enum value
> randr: Use explicit enum value
> dri2: Use explicit enum value
> render: Use explicit enum value
> screensaver: Use explicit enum value
> shape: Use explicit enum value
> sync: Use explicit enum value
> xevie: Use explicit enum value
> xfixes: Use explicit enum value
> xinput: Use explicit enum value
> xkb: Use explicit enum value
> xproto: Use explicit enum value
> xv: Use explicit enum value
> Enforce a bit or value in enum items
> glx: Use hex value for enum item GL_ALL_ATTRIB_BITS
> xkb: Use hex values in enum items
For this whole series:
Reviewed-by: Josh Triplett <josh at joshtriplett.org>
More information about the Xcb
mailing list