[Xcb] [PATCH proto 00/18] Use explicit enum values and use hex value

Ran Benita ran234 at gmail.com
Sun Aug 18 09:29:27 PDT 2013


On Sun, Aug 18, 2013 at 04:54:00PM +0200, Daniel Martin wrote:
> Hi folks,
> 
> explicit is better than implicit. This applies for padding and in my
> opinion for enum item values too.

FWIW, I agree this is better.

> 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.)
> 
> 
> 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.

I've noticed you've changed some enums but left the single-digit values
without the the 0x prefix. I think it's more consistent to change them
as well, but that's just me :)

Oh and the xkb: ones are
Reviewed-By: Ran Benita <ran234 at gmail.com> (and tested)

Ran

> 
> 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
> 
>  src/composite.xml   |   4 +-
>  src/damage.xml      |   8 +--
>  src/dpms.xml        |   8 +--
>  src/dri2.xml        |  26 +++++-----
>  src/glx.xml         |   2 +-
>  src/randr.xml       |   6 +--
>  src/render.xml      | 140 ++++++++++++++++++++++++++--------------------------
>  src/screensaver.xml |  14 +++---
>  src/shape.xml       |  16 +++---
>  src/sync.xml        |  18 +++----
>  src/xcb.xsd         |   5 +-
>  src/xevie.xml       |   4 +-
>  src/xfixes.xml      |  22 ++++-----
>  src/xinput.xml      | 112 ++++++++++++++++++++---------------------
>  src/xkb.xml         |  70 +++++++++++++-------------
>  src/xproto.xml      | 136 +++++++++++++++++++++++++-------------------------
>  src/xv.xml          |  34 ++++++-------
>  17 files changed, 314 insertions(+), 311 deletions(-)
> 
> -- 
> 1.8.3.3
> 
> _______________________________________________
> Xcb mailing list
> Xcb at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/xcb


More information about the Xcb mailing list