[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
  Touch{Begin,End,Update}:
http://cgit.freedesktop.org/xorg/proto/inputproto/tree/specs/XI2proto.txt#n2204
- RawEvents
  Which are the raw equivalents to DeviceEvents:
http://cgit.freedesktop.org/xorg/proto/inputproto/tree/specs/XI2proto.txt#n2350

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> ⋅⋅⋅⋅⋅⋅⋅⋅
        </list>
        ...

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
http://cgit.freedesktop.org/xcb/proto/tree/src/xinput.xml#n65
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
    http://lists.freedesktop.org/archives/xcb/2013-January/008077.html
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 -->
            <fieldref>devices_len</fieldref>
        </list>

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">
            <sumof>../list[@name='devices']/field[@name='num_class_info']</sumof>

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


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


Cheers,
    Daniel Martin


More information about the Xcb mailing list