[Xcb] names of nested structs of named bitcase/case are prone to nameclashes. Solution?

Christian Linhart chris at DemoRecorder.com
Tue Sep 2 09:43:51 PDT 2014


On 09/02/14 17:22, Josh Triplett wrote:
> 4: use 3 for any structs we've already named to avoid changing the API,
> deprecate the names, and avoid naming any new inner structs (2).  If
> application code *really* needs the inner struct types, there's always
> typeof().

Good idea.
This will need an attribute to tell the generator whether
to generate the old style code or whether to generate the new style code.

Reason:
the name-attribute of a case/bitcase is also used for 
the field-name, like "key" in the example below,
and that's still needed:

    typedef struct xcb_input_input_state_data_t {
        struct {
                uint8_t  num_keys; /**<  */
            uint8_t  pad0; /**<  */
            uint8_t  keys[32]; /**<  */
        } key;
       /* ^^^ Still needed */

In the xml, for existing xml-defs it will look like it always looked
which will create a type name as always:
            <case name="key">
will generate
        struct _key{
                uint8_t  num_keys; /**<  */
            uint8_t  pad0; /**<  */
            uint8_t  keys[32]; /**<  */
        } key;
as before.


For new xml-defs we could use an extra-attribute or using another attribute-name for the name:
            <case name="key" anon-struct="true">
or e.g.
            <case casename="key">

will generate
        struct{
                uint8_t  num_keys; /**<  */
            uint8_t  pad0; /**<  */
            uint8_t  keys[32]; /**<  */
        } key;
as before.

Which of the two attribute variants do you like more? ( extra attribute or other attribute-name for the name )

Chris




> 
> - Josh Triplett
> 



More information about the Xcb mailing list