[Xcb] new "length" element needs a type?

Tycho Andersen tycho at tycho.pizza
Mon Sep 20 14:47:30 UTC 2021


On Mon, Sep 20, 2021 at 04:21:25PM +0200, Uli Schlachter wrote:
> Hi,
> 
> Am 20.09.21 um 16:12 schrieb Tycho Andersen:
> > On Mon, Sep 20, 2021 at 04:05:11PM +0200, Uli Schlachter wrote:
> >> Am 19.09.21 um 15:34 schrieb Tycho Andersen:
> >>> There is a new length element for structs documented in c36dde3f4535
> >>> ("Add element to specify expression that defines length of a struct")
> >>> with a first use introduced in f0db8b7d31a3 ("xinput: Add length
> >>> specification for DeviceClass struct"), but as near as I can tell
> >>> there's no type information for this, either in the docs or in this
> >>> particular usage.
> >>
> >> Why does there need to be a type? Other uses of expressions in the XML
> >> are also untyped.
> >>
> >> For example:
> >>
> >>   <struct name="SetupAuthenticate">
> >>     <field type="CARD8" name="status" /> <!-- always 2 -> Authenticate -->
> >>     <pad bytes="5" />
> >>     <field type="CARD16" name="length" />
> >>     <list type="char" name="reason">
> >>       <op op="*">
> >>         <fieldref>length</fieldref>
> >>         <value>4</value>
> >>       </op>
> >>     </list>
> >>   </struct>
> >>
> >> Here, the length of the list is 4*length and there is again no explicit
> >> type given for the length.
> > 
> > Huh? The length field has type="CARD16" doesn't it?
> > 
> > The list itself as type="char". Which thing here doesn't have an
> > explicit type?
> 
> Nothing. So perhaps I am misunderstanding you.
> 
> What does not have an explicit type with the new <length> element? The
> field "len" has type="CARD16", doesn't it? Put differently: What is the
> difference to SetupAuthenticate above?
> 
>     <struct name="DeviceClass">
>         <length>
>             <op op="*">
>                 <fieldref>len</fieldref>
>                 <value>4</value>
>             </op>
>         </length>
>         <field type="CARD16"   name="type" enum="DeviceClassType" />
>         <field type="CARD16"   name="len" />
> [...]
>     </struct>

I see, I think we're both misunderstanding each other :). I understand
your comparison now, and I think this clears it up for me.

My initial confusion was that all other kinds of struct elements have
explicit types (because we need to know how big the thing will be on
the wire), and this one does not. However, this thing won't be present
on the wire, so we don't need an explicit type for it either.

Thanks!

Tycho


More information about the Xcb mailing list