generator: fix align-pads for switches which start at unaligned pos QueryDeviceState-V2
authorChristian Linhart <chris@DemoRecorder.com>
Tue, 2 Sep 2014 16:13:04 +0000 (18:13 +0200)
committerChristian Linhart <chris@demorecorder.com>
Sat, 6 Sep 2014 18:26:35 +0000 (20:26 +0200)
commitb698c81f1415623c07dbc712e57cdf54ec58aaf9
treeead0b3d2d5b63d5c5af71587cc8e99c46efc6eb3
parent5c2f43d370a112c3d713a8277bb5dd907bbb69d5
generator: fix align-pads for switches which start at unaligned pos

Fix the alignment computation inside switches which start at
an unaligned pos.
This affects both explicit and implicit align pads.

The alignment offset is derived from the lowest 3 bits of
the pointer to the protocol-data at the start of the switch.
This is sufficient for correcting all alignments up to 8-byte alignment.
As far as I know there is no bigger alignment than 8-byte for the
X-protocol.

Example:
struct InputState, where the switch starts after two 1-byte fields,
which is a 2 byte offset for 4-byte and 8-byte alignment.

The previous problem can be demonstrated when adding a
<pad align="4"/> at the end of case "key".

(Or when finding a testcase which reports the case "valuator" not
at the last position of the QueryDeviceState-reply.
I didn't find such a testcase, so I have used the pad align
as described above.)

V2: patch modified in order to fix bugs which I found when working on the
next issue:
* xcb_padding_offset has to be set 0 when xcb_block_len is set 0
* xcb_padding_offset cannot be "const" therefore
* for unpack and unserialize, the padding_offset must computed
  from _buffer instead of from the aux_var.

Message-ID: <5405EC90.4040203@DemoRecorder.com>
Patch-Thread-Subject: [Xcb] xinput:QueryDeviceState: full-support: generator and xml-changes
Patch-Set: QueryDeviceState
Patch-Number: libxcb 4/4
Patch-Version: V2
Signed-off-by: Christian Linhart <chris@DemoRecorder.com>
src/c_client.py