generator: sumof with nested expression ListInputDevices-V5
authorChristian Linhart <chris@demorecorder.com>
Wed, 3 Sep 2014 11:22:40 +0000 (13:22 +0200)
committerChristian Linhart <chris@demorecorder.com>
Mon, 20 Oct 2014 10:21:21 +0000 (12:21 +0200)
commit083325adc11159e69e5d342aa59058e7dee8674f
tree2c3b951c3d4b4038f93877c95b2a86b6a9f36c90
parentd2dbbc56761f279a9988e3e2ebbdd532ac7a30cc
generator: sumof with nested expression

Support sumof with a nested expression.
The nested expression is computed for every list-element
and the result of the computation is added to the sum.

This way, sumof can be applied to a list of structs,
and, e.g., compute the sum of a specific field of that struct.

example:
<struct name="SumofTest_Element">
   <field type="CARD16" name="foo" />
   <field type="CARD16" name="bar" />
</struct>

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

generated tmpvar:
    int xcb_pre_tmp_1; /* sumof length */
    int xcb_pre_tmp_2; /* sumof loop counter */
    int64_t xcb_pre_tmp_3; /* sumof sum */
    const xcb_input_sumof_test_element_t* xcb_pre_tmp_4; /* sumof list ptr */

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_mylist_1(_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->bar;
        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-5-git-send-email-chris@demorecorder.com>
Patch-Thread-Subject: [Xcb] xinput: make ListInputDevices work, sumof with nested expr, ...
Patch-Set: ListInputDevices
Patch-Number: libxcb 5/6
Patch-Version: V1
Signed-off-by: Christian Linhart <chris@DemoRecorder.com>
src/c_client.py