generator: support lists of structs which contain a switch
authorChristian Linhart <chris@demorecorder.com>
Thu, 21 Aug 2014 20:35:55 +0000 (22:35 +0200)
committerChristian Linhart <chris@demorecorder.com>
Tue, 9 Sep 2014 00:05:44 +0000 (02:05 +0200)
commit546953a2edcc701d9dd15ece4f5e4b0369846588
tree3c69a4157a5b6be594bf1784528bdad6f37afc2e
parent94531849282a644e0307cf9f92e44f07ecf40272
generator: support lists of structs which contain a switch

This essentially requires to have a correct sizeof-function
for the struct.
This in turn requires a sizeof-function for the switch, too.

Making a sizeof-function for the switch is triggered by
replacing "elif" by "if" in the first change of this patch.
This way, c_need_sizeof is also set to True for switches if appropriate.

The _c_serialize_helper_switch_field function has to support
the context "sizeof":
This is done in the second change of this patch

The third change of this patch fixes an alignment error:
It does not make sense to base the padding on the struct-type
which is generated for switch because this struct does not
represent the protocol. Rather it is the output of deserialization.
( The implicit padding for var-sized fields has other issues, IMHO,
but I am not touching these now...)

The effect on the generated code for the current xml-files
is as follows:
* several additional sizeof-functions are generated
* the fix of the alignment error only changes one place
  in the XKB-extension for the GetKbdByName-reply.
  This is no problem because that reply in its current form
  is broken/unfinished anyways.

Note:
This patch also fixes a problem in the generator when
a fixed-size list is the last field of a case or bitcase.

Message-ID: <1408653356-21191-2-git-send-email-chris@demorecorder.com>
Patch-Thread-Subject: [Xcb] xinput:QueryDeviceState: full-support: generator and xml-changes
Patch-Set: QueryDeviceState
Patch-Number: libxcb 2/3
Patch-Version: V1
Signed-off-by: Christian Linhart <chris@DemoRecorder.com>
src/c_client.py