[Xcb] [PATCH proto] Calculate length of lengthless lists

Christian Linhart chris at DemoRecorder.com
Wed Mar 11 12:06:36 PDT 2015


Hi Jaya,

Thank you for this patch, too.
There are also linewraps and indentation errors in that patch, too.
Can you please fix that, too?

I have also added a comment to your change in the spec.
There is probably a misunderstanding about what that spec describes.
Can you please change that accordingly, too.

Thank you,

Chris


On 03/09/15 07:43, Jaya Tiwari wrote:
> Added handling of length less list elements which are the only
> variable part of the request.
> Such lists that are the only variable part with all other fixed sized
> elements declared before it
> are identified here.
>
> Signed-off-by: Jaya Tiwari <tiwari.jaya18 at gmail.com>
> ---
>  doc/xml-xcb.txt  |  5 +++++
>  xcbgen/xtypes.py | 21 ++++++++++++++++++---
>  2 files changed, 23 insertions(+), 3 deletions(-)
>
> diff --git a/doc/xml-xcb.txt b/doc/xml-xcb.txt
> index f8129ea..4f7e706 100644
> --- a/doc/xml-xcb.txt
> +++ b/doc/xml-xcb.txt
> @@ -359,6 +359,11 @@ Expressions
>    This element represents the current list-element when used inside
>    a list-iteration expression such as <sumof>.
>
> +<op calculate_len/>
> +  This operator represents lengthless list element which is the only varibale
> +  part of a request and all the remaining fixed sized fields are declared above
> +  such list.
> +
The operator "calculate_len" is only used internally for communication between
proto/xcbgen and libxcb/src/c_client.py ( or other generators ).
Therefore, this operator cannot appear in the xml.

The file "xml-xcb.txt" documents only the xml-format.

Therefore I suggest that you add your description about lengthless lists
to the description of the <list> element in the file "xml-xcb.txt".

***

BTW, there is no documentation of the Python-interface between
proto/xcbgen and generators.
It would be useful to have such a documentation, though.

>  Documentation
>  -------------
>
> diff --git a/xcbgen/xtypes.py b/xcbgen/xtypes.py
> index 4d6bbc0..f9ea2dd 100644
> --- a/xcbgen/xtypes.py
> +++ b/xcbgen/xtypes.py
> @@ -176,16 +176,27 @@ class ListType(Type):
>      parent is the structure type containing the list.
>      expr is an Expression object containing the length information,
> for variable-sized lists.
>      '''
> -    def __init__(self, elt, member, *parent):
> +    def __init__(self, elt, member, no_of_var_fields, *parent):
>          Type.__init__(self, member.name)
>          self.is_list = True
>          self.member = member
>          self.parents = list(parent)
> +        lenfield_name = False
> +        has_request = False
> +        has_lenfield_ref = False
> +        dont_have_len = False
>
>          if elt.tag == 'list':
>              elts = list(elt)
> -            self.expr = Expression(elts[0] if len(elts) else elt, self)
>
> +        if 'Request' in str(self.parents):
> +         has_request = True
> +    if not len(elts) and has_request and no_of_var_fields == 1:
> + self.expr = Expression(elt,self)
> + self.expr.op = 'calculate_len'
This looks like two indentation errors.
> +    else:
> +                self.expr = Expression(elts[0] if len(elts) else elt, self)
> +
>          self.size = member.size if member.fixed_size() else None
>          self.nmemb = self.expr.nmemb if self.expr.fixed_size() else None
>
> @@ -302,7 +313,11 @@ class ComplexType(Type):
>          if self.resolved:
>              return
>          enum = None
> + no_of_var_fields = 0
>
> + for child in list(self.elt):
> +    if child.tag != 'pad' and child.tag != 'field':
> + no_of_var_fields = no_of_var_fields + 1
>          # Resolve all of our field datatypes.
>          for child in list(self.elt):
>              if child.tag == 'pad':
> @@ -325,7 +340,7 @@ class ComplexType(Type):
>              elif child.tag == 'list':
>                  field_name = child.get('name')
>                  fkey = child.get('type')
> -                type = ListType(child, module.get_type(fkey),
> *self.lenfield_parent)
> +                type = ListType(child, module.get_type(fkey),
> no_of_var_fields, *self.lenfield_parent)
>                  visible = True
>              elif child.tag == 'switch':
>                  field_name = child.get('name')



More information about the Xcb mailing list