generator: sumof of lists with varsized members ListInputDevices-V4
authorChristian Linhart <chris@demorecorder.com>
Wed, 3 Sep 2014 11:22:41 +0000 (13:22 +0200)
committerChristian Linhart <chris@demorecorder.com>
Tue, 9 Sep 2014 21:54:41 +0000 (23:54 +0200)
commit60603392c3cb2e64ad1f31a3608acbf322137a65
treef516ae4e93c8706e2616b7a596c6b1f063383a60
parent7dac764aac756be199c3afaa3d0f1c68c4337d7b
generator: sumof of lists with varsized members

Support sumof of lists with varsized members.
For these lists, iteration has to be done with iterators.

example:
<struct name="SumofTest_Element_Varsized">
   <field type="CARD16" name="foo" />
   <field type="CARD16" name="bar" />
   <list type="CARD16" name="list1">
<fieldref>foo</fieldref>
   </list>
</struct>

<struct name="SumofTest_FieldAccess_VarSized">
   <field type="CARD32" name="len" />
   <list type="SumofTest_Element_Varsized" name="mylist1">
   <fieldref>len</fieldref>
   </list>
   <list type="CARD16" name="mylist2">
<sumof ref="mylist1">
<fieldref>bar</fieldref>
</sumof>
   </list>
</struct>

generated tempvar:
    int xcb_pre_tmp_1; /* sumof length */
    int xcb_pre_tmp_2; /* sumof loop counter */
    int64_t xcb_pre_tmp_3; /* sumof sum */
    xcb_input_sumof_test_element_varsized_iterator_t xcb_pre_tmp_4; /* sumof list iterator */

generated code:
    /* mylist2 */
    /* sumof start */
    xcb_pre_tmp_1 = _aux->len;
    xcb_pre_tmp_3 = 0;
    xcb_pre_tmp_4 = xcb_input_sumof_test_field_access_var_sized_mylist_1_iterator(_aux);
    for ( xcb_pre_tmp_2 = 0; xcb_pre_tmp_2 < xcb_pre_tmp_1; xcb_pre_tmp_2++) {
        xcb_pre_tmp_3 += xcb_pre_tmp_4.data->bar;
        xcb_input_sumof_test_element_varsized_next(&xcb_pre_tmp_4);
    }
    /* sumof end. Result is in xcb_pre_tmp_3 */
    xcb_block_len += xcb_pre_tmp_3 * sizeof(uint16_t);

Message-ID: <1409743361-466-6-git-send-email-chris@demorecorder.com>
Patch-Thread-Subject: [Xcb] xinput: make ListInputDevices work, sumof with nested expr, ...
Patch-Set: ListInputDevices
Patch-Number: libxcb 6/6
Patch-Version: V1
Signed-off-by: Christian Linhart <chris@DemoRecorder.com>
src/c_client.py