[Xcb] RFC: expressions on lists

Daniel Martin consume.noise at gmail.com
Tue Jan 8 03:07:20 PST 2013

Hi everyone,

and here is yet something else I would like to request comments on. It's
(atm) the last one on my list: expressions on lists

1. <popcount> on a preceding list

This one affects 16 events (14 are eventcopys only) in XI2:
- DeviceEvents
  Which are {Button,Key}{Press,Release}, Motion and
- RawEvents
  Which are the raw equivalents to DeviceEvents:

I think this one is pretty clear - at least the implementation in the
xml. I.e. for DeviceEvents we need:
        <field type="CARD16" name="valuators_len" />
        <list type="char" name="valuator_mask"> <⋅⋅⋅⋅⋅⋅⋅
            <op op="*">                                :
                <fieldref>valuators_len</fieldref>     :
                <value>4</value>                       :
            </op>                                      :
        </list>                                        :
        <list type="FP3232" name="axisvaluas">         :
            <popcount>valuators_mask</popcount> ⋅⋅⋅⋅⋅⋅⋅⋅

Atm. the limiting factor is the generator, which raises an exception on
this. Therefor, I would like to patch it for the beginning, so that it
"ignores" such things and that it would end up as a "fixme" in the code.
Just, like it's done for unions with a _sizeof().
I think that's much better then hiding it with a comment, i.e.:
    <!-- Uninterpreted: list of Foo, length is <popcount> on bar -->

2. <sumof> on a field within a preceding list

This one affects 1 request in XI1:
- ListInputDevices
Well, the comment is wrong:
    <!-- Uninterpreted: list of deviceinfo structs of 3 the subtypes -->
correct would be:
    <!-- Uninterpreted: list of InputInfo structs -->
And to know the length of that list we've to sum up all num_class_info
fields from the preceding list of DeviceInfo structs.

Here we've the problem, that we can not reference to the num_class_info
field, because the DeviceInfo struct is declared somewhere else and we
don't know its fields from within the request.

Solving the first part of the problem might be the same as:
    [Xcb] RFC: nested field declarations in lists
When we apply this on DeviceInfo, we would get:
        <list type="DeviceInfo" name="devices">

            <!-- nested fields -->
            <field type="ATOM"  name="device_type" />
            <field type="CARD8" name="device_id" />
            <field type="CARD8" name="num_class_info" />
            <field type="CARD8" name="device_use" enum="DeviceUse" />
            <pad bytes="1" />

            <!-- usual length expression -->

And the second part to solve it would be an appropriate reference. Imho.
an XPath would be the best:
        ... <!-- just behind the "devices" list -->
        <list type="InputInfo" name="infos">

            <!-- That XPath might be wrong, havn't tested it with an
                 example. But, it should be sufficient to demonstrate my
                 idea. -->

I think, that's it for the moment. What do you think about this ideas?

    Daniel Martin

More information about the Xcb mailing list