[Xcb] RFC: parameters for structs (for XI1)

Daniel Martin consume.noise at gmail.com
Wed Jan 2 01:38:42 PST 2013


Hi everyone,

here's another show blocker in xcbgen/c_client.

In XI1 there's the GetDeviceMotionEvents request:
    http://cgit.freedesktop.org/xcb/proto/tree/src/xinput.xml#n238

    <request name="GetDeviceMotionEvents" opcode="10">
        <field type="TIMESTAMP" name="start" />
        <field type="TIMESTAMP" name="stop" altenum="Time" />
        <field type="CARD8" name="device_id" />
        <reply>
            <pad bytes="1" />
            <field type="CARD32" name="num_coords" />
            <field type="CARD8" name="num_axes" />
            <field type="CARD8" name="device_mode" enum="ValuatorMode" />
            <pad bytes="18" />
            <!-- Uninterpreted: list of DeviceTimeCoord structures -->
        </reply>
    </request>

    <struct name="DeviceTimeCoord">
        <field type="TIMESTAMP" name="time" />
        <!-- Uninterpreted: list of CARD16 -->
    </struct>

The length of the list of CARD16 in DeviceTimeCoord is num_axes from the
reply. So, we need a way to pass num_axes to the functions handling this
struct.
One way could be, just to hard code num_axes as fieldref in the list of
CARD16 and let the code generator guess that this field might come from
a parent. I wouldn't prefer this solution.

Instead I would like to introduce "parameters". In the struct it could
be implemented like:

    <struct name="DeviceTimeCoord">
        <paramdec type="CARD8" name="number_of_axes" />
        <!-- parameter declaration
             Now, the code generator knows that functions handling this
             this struct need an additional parameter. -->

        <field type="TIMESTAMP" name="time" />
        <list type="CARD16" name="data">
            <paramref>number_of_axes</paramref>
            <!-- parameter reference -->
        </list>
    </struct>

For the request I'm not totally sure what's the best way to make it as
obvious as possible that the parameter has to be used on the type of the
list:

    <request name="GetDeviceMotionEvents" opcode="10">
        <field type="TIMESTAMP" name="start" />
        <field type="TIMESTAMP" name="stop" altenum="Time" />
        <field type="CARD8" name="device_id" />
        <reply>
            <pad bytes="1" />
            <field type="CARD32" name="num_coords" />
            <field type="CARD8" name="num_axes" />
            <field type="CARD8" name="device_mode" enum="ValuatorMode" />
            <pad bytes="18" />
            <list type="DeviceTimeCoord" name="coords">
                <paramval name="number_of_axes">num_axes</paramval>
                <!-- Note: number_of_axes vs. num_axes. One is the
                     parameter, the other is the "fieldref". -->

                <fieldref>num_coords</fieldref>
            </list>
        </reply>
    </request>

paramdec should be derived from the field element (or it's base) and
paramref and paramval should be expressions.


Any comments are appreciated.


Cheers,
    Daniel Martin

PS: A happy new year to everyone.


More information about the Xcb mailing list