[Xcb] RFC: nested field declarations in lists

Daniel Martin consume.noise at gmail.com
Mon Jan 7 11:34:32 PST 2013


On Wed, Jan 02, 2013 at 10:38:42AM +0100, Daniel Martin wrote:
> 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:

Dismissed! As discussed on IRC such information as num_axis shouldn't
leave its scope. To achieve that we would need to nest declarations.
I.e. like this:

    <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">

                <!-- nested fields -->
                <field type="TIMESTAMP" name="time" />
                <list type="CARD16" name="data">
                    <fieldref>num_axes</fieldref>
                </list>

                <!-- usual length expression -->
                <fieldref>num_coors</fieldref>
            </list>
        </reply>
    </request>


Cheers,
    Daniel Martin


More information about the Xcb mailing list