[Xcb] sizeof paramters for length less lists

Vincent Chen noodlewiz at gmail.com
Thu Feb 26 16:30:05 PST 2015


On Thu, Feb 26, 2015 at 8:45 AM, Peter Harris <pharris at opentext.com> wrote:
> On 2015-02-26 01:58, chris at demorecorder.com wrote:
>> P.S.: @all: Here's some context, so people on this list can understand what's this about:
>>
>> In current XCB, the length of the rectangles list of request SetPictureClipRectangles
>> is not specified in render.xml:
>>   <request name="SetPictureClipRectangles" opcode="6">
>>     <field type="PICTURE" name="picture" />
>>     <field type="INT16" name="clip_x_origin" />
>>     <field type="INT16" name="clip_y_origin" />
>>     <list type="RECTANGLE" name="rectangles" />
>>   </request>
>>
>> This needs to be fixed for some applications, including server-side XCB.
>> So, the xml will be changed as follows, by using the length-field of the
>> request to compute the length of the rectangles-list:
>>
>>   <request name="SetPictureClipRectangles" opcode="6">
>>     <field type="PICTURE" name="picture" />
>>     <field type="INT16" name="clip_x_origin" />
>>     <field type="INT16" name="clip_y_origin" />
>>     <list type="RECTANGLE" name="rectangles" >
>>       <op op="/">
>>             <op op="-">
>>                 <fieldref>length</fieldref>
>>                 <value>3</value>
>>           </op>
>>             <value>2</value>
>>         </op>
>>     </list>
>>   </request>
>
> I'm confused. Earlier you said "so, don't use "(length - 3)/2" inside,
> but use rectangles_len", and then you went to a lot of manual effort to
> define rectangles_len as "(length - 3)/2".
>
> Given that rectangles_len is already implied by a list with no length,
> and given that creating all the <op>s by hand is error prone, I'd rather
> leave the XML as-is.
>
I agree with Peter that the XML is fine the way it is. Lengths of
lists have to be explicitly specified when dealing with reply, events,
and errors because the lengths are needed to properly decode what
comes in through the network. When sending a request, one has all the
information already on hand --- including the length of lists.
Therefore the length of lists should be calculated before sending over
the wire, not specified as part of XML.

One of the strengths of having an XML description of the X11 protocol
is that languages other than C can also use the XML description to
generate their own language bindings. I understand that you wish to
improve XCB, but please try to keep xcb-proto as language neutral as
possible.

Regards,

Vincent Chen


More information about the Xcb mailing list