[Xcb] Add sizeof tag to struct

Daniel Martin consume.noise at gmail.com
Sun Dec 23 06:29:22 PST 2012


Hi,

this is yet another proposal. It adds an additional sizeof tag to
structs, which simplifies size calculations for structs with a variadic
size if they provide a length field which references to the struct
itself.
In theory it could be used to work around alignment issues (see #23403),
but imho it shouldn't and the description states so.

It's usefull for various structs which can be found in XI1 and XI2.
Those structs have a common header (type/class and length field), where
the length field already gives the size of the whole struct including
lists attached to the struct, i.e.:
- INPUTINFO http://cgit.freedesktop.org/xorg/proto/inputproto/tree/specs/XIproto.txt#n320
- CLASS http://cgit.freedesktop.org/xorg/proto/inputproto/tree/specs/XI2proto.txt#n762
- HIERARCHYINFO http://cgit.freedesktop.org/xorg/proto/inputproto/tree/specs/XI2proto.txt#n1169


[PATCH proto 1/2] Add sizeof tag to struct
[PATCH lib] c_client.py: Handle sizeof expression
- Add and handle the sizeof tag.

[PATCH proto 2/2] xinput: Example for sizeof in struct on InputState
- An example how the sizeof can be used.


Cheers,
    Daniel Martin


More information about the Xcb mailing list