From 57934caa3fb207320c33312646d8e98290950f51 Mon Sep 17 00:00:00 2001 From: Bart Massey Date: Sun, 31 Aug 2008 00:45:17 -0700 Subject: [PATCH] made changes to support new value-mask-pad field of valueparam structures --- src/type.py | 2 +- src/xcb.xsd | 2 ++ src/xproto.xml | 1 + xcbgen/xtypes.py | 28 ++++++++++++++++++++++++---- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/type.py b/src/type.py index 8338232..873845b 100755 --- a/src/type.py +++ b/src/type.py @@ -47,7 +47,7 @@ class AnnotateType(XMLFilterBase): self.declareType(attrs['newname']) attnames = ['oldname', 'newname'] elif name == 'valueparam': - attnames = ['value-mask-type'] + attnames = ['value-mask-type', 'value-mask-pad'] elif attrs.has_key('type'): attnames = ['type'] newattrs = {} diff --git a/src/xcb.xsd b/src/xcb.xsd index b40ee6a..ba334d1 100644 --- a/src/xcb.xsd +++ b/src/xcb.xsd @@ -109,6 +109,8 @@ authorization from the authors. + + diff --git a/src/xproto.xml b/src/xproto.xml index 343e734..17f2c47 100644 --- a/src/xproto.xml +++ b/src/xproto.xml @@ -815,6 +815,7 @@ authorization from the authors. diff --git a/xcbgen/xtypes.py b/xcbgen/xtypes.py index d4b16e2..b234003 100644 --- a/xcbgen/xtypes.py +++ b/xcbgen/xtypes.py @@ -233,15 +233,15 @@ class ExprType(Type): def fixed_size(self): return True -class PadType(Type): +class SizedPadType(Type): ''' - Derived class which represents a padding field. + Derived class which represents a padding field of given size. ''' - def __init__(self, elt): + def __init__(self, size): Type.__init__(self, tcard8.name) self.is_pad = True self.size = 1 - self.nmemb = 1 if (elt == None) else int(elt.get('bytes')) + self.nmemb = int(size) def resolve(self, module): self.resolved = True @@ -249,6 +249,13 @@ class PadType(Type): def fixed_size(self): return True +class PadType(SizedPadType): + ''' + Derived class which represents a padding field of given type. + ''' + def __init__(self, elt): + self.nmemb = "1" if (elt == None) else elt.get('bytes') + SizedPadType.__init__(self, self.nmemb) class ComplexType(Type): ''' @@ -272,6 +279,7 @@ class ComplexType(Type): # Resolve all of our field datatypes. for child in list(self.elt): + value_mask_pad = None if child.tag == 'pad': field_name = 'pad' + str(pads) fkey = 'CARD8' @@ -298,6 +306,7 @@ class ComplexType(Type): fkey = 'CARD32' type = ListType(child, module.get_type(fkey), self) visible = True + value_mask_pad = child.get('value-mask-pad') else: # Hit this on Reply continue @@ -309,6 +318,17 @@ class ComplexType(Type): # Recursively resolve the type (could be another structure, list) type.resolve(module) + # Add a value-mask-pad if necessary + if value_mask_pad != None: + vmp_field_name = 'pad' + str(pads) + vmp_fkey = 'CARD8' + vmp_type = SizedPadType(value_mask_pad) + pads = pads + 1 + vmp_visible = False + vmp_field_type = module.get_type_name(vmp_fkey) + vmp_type.make_member_of(module, self, vmp_field_type, vmp_field_name, vmp_visible, True, False) + vmp_type.resolve(module) + self.calc_size() # Figure out how big we are self.resolved = True -- 2.34.1