[Xcb-commit] xcb/proto: 3 commits - src xcbgen

Peter Harris peterh at kemper.freedesktop.org
Tue Jan 21 12:26:20 PST 2014


 src/xcb.xsd      |    3 +-
 src/xkb.xml      |   60 +++----------------------------------------------------
 xcbgen/state.py  |    1 
 xcbgen/xtypes.py |   16 +++++++++-----
 4 files changed, 17 insertions(+), 63 deletions(-)

New commits:
commit d898fd39ad6c82207eb78666b2daad982dd757b5
Author: Peter Harris <pharris at opentext.com>
Date:   Tue Jan 14 14:48:22 2014 -0500

    xkb: Use <pad align="4" /> in GetMap
    
    There is a bug where lists of size other than one are automatically
    aligned by c_client.py. So alignment_pad3 and 4 were aligning twice
    and consuming too many bytes.
    
    Rather than change the type to CARD8 and wrap the <op> in yet another
    <op> to multiply by two, use the new <pad align> operation.
    
    Reviewed-By: Ran Benita <ran234 at gmail.com>
    Tested-By: Ran Benita <ran234 at gmail.com>
    Signed-off-by: Peter Harris <pharris at opentext.com>

diff --git a/src/xkb.xml b/src/xkb.xml
index 1df0771..9ef4402 100644
--- a/src/xkb.xml
+++ b/src/xkb.xml
@@ -1351,20 +1351,7 @@ authorization from the authors.
 					<list name="acts_rtrn_count" type="CARD8">
 						<fieldref>nKeyActions</fieldref>
 					</list>
-					<list type="CARD8" name="alignment_pad">
-					    <op op="-">
-						<op op="&">
-						    <op op="+">
-							<fieldref>nKeyActions</fieldref>
-							<value>3</value>
-						    </op>
-						    <unop op="~">
-							<value>3</value>
-						    </unop>
-						</op>
-						<fieldref>nKeyActions</fieldref>
-					    </op>
-					</list>
+                                        <pad align="4" />
 					<list name="acts_rtrn_acts" type="Action">
 						<fieldref>totalActions</fieldref>
 					</list>
@@ -1380,60 +1367,21 @@ authorization from the authors.
 					<list name="vmods_rtrn" type="CARD8" mask="ModMask">
 						<popcount><fieldref>virtualMods</fieldref></popcount>
 					</list>
-					<list type="CARD8" name="alignment_pad2">
-					    <op op="-">
-						<op op="&">
-						    <op op="+">
-							<popcount><fieldref>virtualMods</fieldref></popcount>
-							<value>3</value>
-						    </op>
-						    <unop op="~">
-							<value>3</value>
-						    </unop>
-						</op>
-						<popcount><fieldref>virtualMods</fieldref></popcount>
-					    </op>
-					</list>
+                                        <pad align="4" />
 				</bitcase>
 				<bitcase>
 					<enumref ref="MapPart">ExplicitComponents</enumref>
 					<list name="explicit_rtrn" type="SetExplicit">
 						<fieldref>totalKeyExplicit</fieldref>
 					</list>
-					<list type="CARD16" name="alignment_pad3">
-					    <op op="-">
-						<op op="&">
-						    <op op="+">
-							<fieldref>totalKeyExplicit</fieldref>
-							<value>1</value>
-						    </op>
-						    <unop op="~">
-							<value>1</value>
-						    </unop>
-						</op>
-						<fieldref>totalKeyExplicit</fieldref>
-					    </op>
-					</list>
+                                        <pad align="4" />
 				</bitcase>
 				<bitcase>
 					<enumref ref="MapPart">ModifierMap</enumref>
 					<list name="modmap_rtrn" type="KeyModMap">
 						<fieldref>totalModMapKeys</fieldref>
 					</list>
-					<list type="CARD16" name="alignment_pad4">
-					    <op op="-">
-						<op op="&">
-						    <op op="+">
-							<fieldref>totalModMapKeys</fieldref>
-							<value>1</value>
-						    </op>
-						    <unop op="~">
-							<value>1</value>
-						    </unop>
-						</op>
-						<fieldref>totalModMapKeys</fieldref>
-					    </op>
-					</list>
+                                        <pad align="4" />
 				</bitcase>
 				<bitcase>
 					<enumref ref="MapPart">VirtualModMap</enumref>
commit ee02385ce1920ac7d0a450a8fccba60f9656d1fb
Author: Peter Harris <pharris at opentext.com>
Date:   Tue Jan 14 14:45:36 2014 -0500

    Support <pad align="n" />
    
    Reviewed-By: Ran Benita <ran234 at gmail.com>
    Signed-off-by: Peter Harris <pharris at opentext.com>

diff --git a/src/xcb.xsd b/src/xcb.xsd
index 73dbf8a..580d258 100644
--- a/src/xcb.xsd
+++ b/src/xcb.xsd
@@ -42,7 +42,8 @@ authorization from the authors.
   <!-- Padding -->
   <xsd:element name="pad">
     <xsd:complexType>
-      <xsd:attribute name="bytes" type="xsd:integer" use="required" />
+      <xsd:attribute name="bytes" type="xsd:integer" use="optional" />
+      <xsd:attribute name="align" type="xsd:integer" use="optional" />
     </xsd:complexType>
   </xsd:element>
 
diff --git a/xcbgen/xtypes.py b/xcbgen/xtypes.py
index e9596a9..3cd9032 100644
--- a/xcbgen/xtypes.py
+++ b/xcbgen/xtypes.py
@@ -267,13 +267,17 @@ class PadType(Type):
         Type.__init__(self, tcard8.name)
         self.is_pad = True
         self.size = 1
-        self.nmemb = 1 if (elt == None) else int(elt.get('bytes'), 0)
+        self.nmemb = 1
+        self.align = 1
+        if elt != None:
+            self.nmemb = int(elt.get('bytes', "1"), 0)
+            self.align = int(elt.get('align', "1"), 0)
 
     def resolve(self, module):
         self.resolved = True
 
     def fixed_size(self):
-        return True
+        return self.align <= 1
 
     
 class ComplexType(Type):
commit a05a5106354c62d0862f8ed4f90d75bbf51e593f
Author: Peter Harris <pharris at opentext.com>
Date:   Tue Jan 14 14:45:15 2014 -0500

    Track pad count at the module level
    
    If the pad count is reset for each bitcase, the names will collide
    in the encompasing switch struct.
    
    Reviewed-By: Ran Benita <ran234 at gmail.com>
    Signed-off-by: Peter Harris <pharris at opentext.com>

diff --git a/xcbgen/state.py b/xcbgen/state.py
index 10a8722..52b8d8d 100644
--- a/xcbgen/state.py
+++ b/xcbgen/state.py
@@ -93,6 +93,7 @@ class Module(object):
     # Recursively resolve all types
     def resolve(self):
         for (name, item) in self.all:
+            self.pads = 0
             item.resolve(self)
 
     # Call all the output methods
diff --git a/xcbgen/xtypes.py b/xcbgen/xtypes.py
index 5f45723..e9596a9 100644
--- a/xcbgen/xtypes.py
+++ b/xcbgen/xtypes.py
@@ -296,16 +296,15 @@ class ComplexType(Type):
     def resolve(self, module):
         if self.resolved:
             return
-        pads = 0
         enum = None
 
         # Resolve all of our field datatypes.
         for child in list(self.elt):
             if child.tag == 'pad':
-                field_name = 'pad' + str(pads)
+                field_name = 'pad' + str(module.pads)
                 fkey = 'CARD8'
                 type = PadType(child)
-                pads = pads + 1
+                module.pads = module.pads + 1
                 visible = False
             elif child.tag == 'field':
                 field_name = child.get('name')
@@ -397,7 +396,6 @@ class SwitchType(ComplexType):
     def resolve(self, module):
         if self.resolved:
             return
-#        pads = 0
 
         parents = list(self.parents) + [self]
 
@@ -560,6 +558,8 @@ class Reply(ComplexType):
     def resolve(self, module):
         if self.resolved:
             return
+        # Reset pads count
+        module.pads = 0
         # Add the automatic protocol fields
         self.fields.append(Field(tcard8, tcard8.name, 'response_type', False, True, True))
         self.fields.append(_placeholder_byte)


More information about the xcb-commit mailing list