[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xcb-proto: Changes to 'debian/unstable'



 NEWS                |   27 +
 configure.ac        |    2 
 debian/changelog    |    8 
 debian/control      |    2 
 debian/copyright    |    2 
 debian/watch        |    2 
 doc/xml-xcb.txt     |   92 +++++-
 src/glx.xml         |   13 
 src/present.xml     |    6 
 src/randr.xml       |   48 +++
 src/render.xml      |  119 +++++++-
 src/screensaver.xml |   68 ++++
 src/shm.xml         |    2 
 src/sync.xml        |    1 
 src/xcb.xsd         |   42 +-
 src/xfixes.xml      |    2 
 src/xinput.xml      |  769 +++++++++++++++++++++++++++++++++++++++-------------
 src/xkb.xml         |   33 +-
 src/xprint.xml      |   26 -
 src/xproto.xml      |  436 +++++++++++++++++++++++++++--
 src/xselinux.xml    |    2 
 src/xv.xml          |    2 
 xcbgen/Makefile.am  |    2 
 xcbgen/align.py     |  177 +++++++++++
 xcbgen/expr.py      |   59 +++
 xcbgen/xtypes.py    |  627 ++++++++++++++++++++++++++++++++++++++++--
 26 files changed, 2238 insertions(+), 331 deletions(-)

New commits:
commit 6c126fa91e95ffa1f484613a630bf46e38f0370a
Author: Julien Cristau <jcristau@debian.org>
Date:   Sat Sep 24 19:48:28 2016 +0200

    Upload to unstable

diff --git a/debian/changelog b/debian/changelog
index 227a972..058b7dd 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,10 +1,10 @@
-xcb-proto (1.12-1) UNRELEASED; urgency=medium
+xcb-proto (1.12-1) unstable; urgency=medium
 
   * New upstream release.
   * Update upstream URLs in packaging to use https.
   * Cherry-pick "Update XML schema to fix 'make check'" from master.
 
- -- Julien Cristau <jcristau@debian.org>  Sat, 24 Sep 2016 16:09:00 +0200
+ -- Julien Cristau <jcristau@debian.org>  Sat, 24 Sep 2016 19:48:05 +0200
 
 xcb-proto (1.11-1) unstable; urgency=medium
 

commit ab1fcf767148cc6a1450d4f3770b9799a4a08796
Author: Julien Cristau <jcristau@debian.org>
Date:   Sat Sep 24 16:35:02 2016 +0200

    Document cherry-pick

diff --git a/debian/changelog b/debian/changelog
index 580a6e9..227a972 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,7 @@ xcb-proto (1.12-1) UNRELEASED; urgency=medium
 
   * New upstream release.
   * Update upstream URLs in packaging to use https.
+  * Cherry-pick "Update XML schema to fix 'make check'" from master.
 
  -- Julien Cristau <jcristau@debian.org>  Sat, 24 Sep 2016 16:09:00 +0200
 

commit f8fa975afbaa98ab94454edd01dfc248a22526b6
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Wed Feb 3 16:41:57 2016 +0000

    Update XML schema to fix 'make check'
    
    Here is an attempt at updating the schema to add serialize attribute to pad
    element and required_start_align element.
    
    Not sure if I've added required_start_align element in the right place. The
    default case in the switch element is removed as it doesn't seem to be used, and
    otherwise makes the schema ambiguous.
    
    $ make check
    Making check in src
    make[1]: Entering directory '/jhbuild/x86_64-pc-cygwin/build/xcb/proto/src'
    make  check-local
    make[2]: Entering directory '/jhbuild/x86_64-pc-cygwin/build/xcb/proto/src'
    /usr/bin/xmllint --noout --schema /jhbuild/checkout/xcb/proto/src/xcb.xsd
    /jhbuild/checkout/xcb/proto/src/*.xml
    /jhbuild/checkout/xcb/proto/src/bigreq.xml validates
    /jhbuild/checkout/xcb/proto/src/composite.xml validates
    /jhbuild/checkout/xcb/proto/src/damage.xml validates
    /jhbuild/checkout/xcb/proto/src/dpms.xml validates
    /jhbuild/checkout/xcb/proto/src/dri2.xml validates
    /jhbuild/checkout/xcb/proto/src/dri3.xml validates
    /jhbuild/checkout/xcb/proto/src/ge.xml validates
    Element 'required_start_align': This element is not expected. Expected is one of ( pad, field, list, fd ).
    Element 'required_start_align': This element is not expected. Expected is one of ( pad, field, list, fd ).
    Element 'required_start_align': This element is not expected. Expected is one of ( pad, field, list, fd ).
    Element 'required_start_align': This element is not expected. Expected is one of ( pad, field, list, fd ).
    /jhbuild/checkout/xcb/proto/src/glx.xml fails to validate
    Element 'required_start_align': This element is not expected. Expected is one of ( pad, field, list, fd, exprfield, switch, reply, doc ).
    Element 'required_start_align': This element is not expected. Expected is one of ( pad, field, list, fd, exprfield, switch, reply, doc ).
    Element 'required_start_align': This element is not expected. Expected is one of ( pad, field, list, fd, doc ).
    Element 'required_start_align': This element is not expected. Expected is one of ( pad, field, list, fd, doc ).
    /jhbuild/checkout/xcb/proto/src/present.xml fails to validate
    /jhbuild/checkout/xcb/proto/src/randr.xml validates
    /jhbuild/checkout/xcb/proto/src/record.xml validates
    /jhbuild/checkout/xcb/proto/src/render.xml validates
    /jhbuild/checkout/xcb/proto/src/res.xml validates
    /jhbuild/checkout/xcb/proto/src/screensaver.xml validates
    /jhbuild/checkout/xcb/proto/src/shape.xml validates
    /jhbuild/checkout/xcb/proto/src/shm.xml validates
    /jhbuild/checkout/xcb/proto/src/sync.xml validates
    /jhbuild/checkout/xcb/proto/src/xc_misc.xml validates
    /jhbuild/checkout/xcb/proto/src/xevie.xml validates
    /jhbuild/checkout/xcb/proto/src/xf86dri.xml validates
    /jhbuild/checkout/xcb/proto/src/xf86vidmode.xml validates
    /jhbuild/checkout/xcb/proto/src/xfixes.xml validates
    /jhbuild/checkout/xcb/proto/src/xinerama.xml validates
    Element 'required_start_align': This element is not expected. Expected is one of ( bitcase, case, pad, field, list, fd ).
    Element 'required_start_align': This element is not expected. Expected is one of ( bitcase, case, pad, field, list, fd ).
    Element 'required_start_align': This element is not expected. Expected is one of ( bitcase, case, pad, field, list, fd ).
    /jhbuild/checkout/xcb/proto/src/xinput.xml fails to validate
    Element 'pad', attribute 'serialize': The attribute 'serialize' is not allowed.
    Element 'pad', attribute 'serialize': The attribute 'serialize' is not allowed.
    Element 'pad', attribute 'serialize': The attribute 'serialize' is not allowed.
    Element 'pad', attribute 'serialize': The attribute 'serialize' is not allowed.
    Element 'pad', attribute 'serialize': The attribute 'serialize' is not allowed.
    /jhbuild/checkout/xcb/proto/src/xkb.xml fails to validate
    /jhbuild/checkout/xcb/proto/src/xprint.xml validates
    /jhbuild/checkout/xcb/proto/src/xproto.xml validates
    /jhbuild/checkout/xcb/proto/src/xselinux.xml validates
    /jhbuild/checkout/xcb/proto/src/xtest.xml validates
    /jhbuild/checkout/xcb/proto/src/xv.xml validates
    /jhbuild/checkout/xcb/proto/src/xvmc.xml validates
    Makefile:534: recipe for target 'check-local' failed
    
    Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95494
    Reviewd-by: Ran Benita <ran234@gmail.com>
    Signed-off-by: Uli Schlachter <psychon@znc.in>
    (cherry picked from commit 95a262e0e66cd88b9d7a133917b3ba70ace77301)

diff --git a/src/xcb.xsd b/src/xcb.xsd
index c1dce3e..f0c5f44 100644
--- a/src/xcb.xsd
+++ b/src/xcb.xsd
@@ -44,6 +44,15 @@ authorization from the authors.
     <xsd:complexType>
       <xsd:attribute name="bytes" type="xsd:integer" use="optional" />
       <xsd:attribute name="align" type="xsd:integer" use="optional" />
+      <xsd:attribute name="serialize" type="xsd:boolean" use="optional" />
+    </xsd:complexType>
+  </xsd:element>
+
+  <!-- Alignment -->
+  <xsd:element name="required_start_align" >
+    <xsd:complexType>
+      <xsd:attribute name="align" type="xsd:integer" use="required" />
+      <xsd:attribute name="offset" type="xsd:integer" use="optional" />
     </xsd:complexType>
   </xsd:element>
 
@@ -76,14 +85,13 @@ authorization from the authors.
     <xsd:sequence>
       <!-- switch(expression) -->
       <xsd:group ref="expression" minOccurs="1" maxOccurs="1" />
+      <xsd:element ref="required_start_align" minOccurs="0" maxOccurs="1" />
       <xsd:choice>
         <!-- bitcase expression - bit test -->
         <xsd:element name="bitcase" type="caseexpr" minOccurs="0" maxOccurs="unbounded" />
         <!-- case expression - value test -->
         <xsd:element name="case" type="caseexpr" minOccurs="0" maxOccurs="unbounded" />
       </xsd:choice>
-      <!-- default: -->
-      <xsd:group ref="fields" minOccurs="0" maxOccurs="1" />
     </xsd:sequence>
     <xsd:attribute name="name" type="xsd:string" use="required" />
   </xsd:complexType>
@@ -201,6 +209,7 @@ authorization from the authors.
       <xsd:element ref="field" />
       <xsd:element ref="list" />
       <xsd:element ref="fd" />
+      <xsd:element ref="required_start_align" />
     </xsd:choice>
   </xsd:group>
 

commit 2d5af11f1f6a70b07885c91cda0806861b36d6a0
Author: Julien Cristau <jcristau@debian.org>
Date:   Sat Sep 24 16:10:59 2016 +0200

    Update upstream URLs in packaging to use https.

diff --git a/debian/changelog b/debian/changelog
index 31c107a..580a6e9 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,7 @@
 xcb-proto (1.12-1) UNRELEASED; urgency=medium
 
   * New upstream release.
+  * Update upstream URLs in packaging to use https.
 
  -- Julien Cristau <jcristau@debian.org>  Sat, 24 Sep 2016 16:09:00 +0200
 
diff --git a/debian/control b/debian/control
index 7db291f..e14b417 100644
--- a/debian/control
+++ b/debian/control
@@ -11,7 +11,7 @@ Build-Depends:
  automake
 Standards-Version: 3.9.6
 X-Python-Version: >= 2.5
-Homepage: http://xcb.freedesktop.org
+Homepage: https://xcb.freedesktop.org
 Vcs-Git: https://anonscm.debian.org/git/pkg-xorg/proto/xcb-proto.git
 Vcs-Browser: https://anonscm.debian.org/cgit/pkg-xorg/proto/xcb-proto.git
 
diff --git a/debian/copyright b/debian/copyright
index 4eac1e9..c1bea00 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -3,7 +3,7 @@ Thu, 18 Mar 2004 00:48:42 -0800, and later updated by Josh Triplett
 <josh@freedesktop.org>.  The package is co-maintained by the XCB developers
 via the XCB mailing list <xcb@lists.freedesktop.org>.
 
-It was downloaded from http://xcb.freedesktop.org/dist
+It was downloaded from https://xcb.freedesktop.org/dist
 
 Upstream Authors: Jamey Sharp <sharpone@debian.org>
                   Josh Triplett <josh@freedesktop.org>
diff --git a/debian/watch b/debian/watch
index 3d87793..d406ec5 100644
--- a/debian/watch
+++ b/debian/watch
@@ -1,2 +1,2 @@
 version=3
-http://xcb.freedesktop.org/dist/xcb-proto-([0-9].*)\.tar\.gz
+https://xcb.freedesktop.org/dist/xcb-proto-([0-9].*)\.tar\.gz

commit 7de78984f01751597a174c26e42955f93c3633bf
Author: Julien Cristau <jcristau@debian.org>
Date:   Sat Sep 24 16:09:26 2016 +0200

    Bump changelog to 1.12

diff --git a/debian/changelog b/debian/changelog
index 4978198..31c107a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+xcb-proto (1.12-1) UNRELEASED; urgency=medium
+
+  * New upstream release.
+
+ -- Julien Cristau <jcristau@debian.org>  Sat, 24 Sep 2016 16:09:00 +0200
+
 xcb-proto (1.11-1) unstable; urgency=medium
 
   [ Laurent Bigonville ]

commit 6398e42131eedddde0d98759067dde933191f049
Author: Uli Schlachter <psychon@znc.in>
Date:   Sat May 14 10:32:42 2016 +0200

    Release xcb-proto 1.12
    
    There were more than 100 commits since the last release. The NEWS file only
    provides an overview of these changes.
    
    Signed-off-by: Uli Schlachter <psychon@znc.in>

diff --git a/NEWS b/NEWS
index 3ab5cc0..caf1ffa 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,30 @@
+Release 1.12 (2016-05-18)
+=========================
+* xinput: Various padding-related additions and fixes
+* xinput: Various type fixes
+* xinput: Various mask fixes
+* xinput: Various additions of enums
+* Define new "altmask" attribute
+* Define new switch-case construct
+* xinput: Convert various construct from bitcase to case
+* xinput: Add full support for various requests
+* Define new sumof with nested expressions
+* present: Specify length of RedirectNotify.notifies
+* Define new listelement-ref construct
+* xinput: Support list axisvalues in events
+* Define new paramref construct
+* xfixes: Fix GetCursorImageAndName cursor image support
+* Replace valueparam with other construct in various extensions
+* Remove support for the valueparam construct
+* xprint: Fix some list definitions
+* randr: Add RandR 1.5 requests and data types
+* shm: Mark PutImage.send_event field as boolean
+* glx: Add IsEnabled request
+* Make padding explicit in various places
+* Fix typos in some documentation examples
+* Add an automatic alignment checker
+* Optionally enforce serilization of pads for ABI compatibility
+
 Release 1.11 (2014-08-01)
 =========================
 * Add support for <pad align="n" />
diff --git a/configure.ac b/configure.ac
index d140bfe..540a8dd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,7 +3,7 @@
 
 AC_PREREQ(2.57)
 AC_INIT([XCB Proto],
-        1.11,
+        1.12,
         [xcb@lists.freedesktop.org])
 AC_CONFIG_SRCDIR([xcb-proto.pc.in])
 AM_INIT_AUTOMAKE([foreign dist-bzip2])

commit 2ba8cdb2ef7d12b9615329b50ff14d69e6fa4a37
Author: Christian Linhart <chris@demorecorder.com>
Date:   Mon Jan 18 06:52:03 2016 +0100

    enforce serialization of pads where needed for ABI compat
    
    Signed-off-by: Christian Linhart <chris@demorecorder.com>

diff --git a/src/xkb.xml b/src/xkb.xml
index 06488e7..8778c07 100644
--- a/src/xkb.xml
+++ b/src/xkb.xml
@@ -1356,7 +1356,7 @@ authorization from the authors.
 					<list name="acts_rtrn_count" type="CARD8">
 						<fieldref>nKeyActions</fieldref>
 					</list>
-                                        <pad align="4" />
+                                        <pad align="4" serialize="true"/>
 					<list name="acts_rtrn_acts" type="Action">
 						<fieldref>totalActions</fieldref>
 					</list>
@@ -1372,21 +1372,21 @@ authorization from the authors.
 					<list name="vmods_rtrn" type="CARD8" mask="ModMask">
 						<popcount><fieldref>virtualMods</fieldref></popcount>
 					</list>
-                                        <pad align="4" />
+                                        <pad align="4" serialize="true" />
 				</bitcase>
 				<bitcase>
 					<enumref ref="MapPart">ExplicitComponents</enumref>
 					<list name="explicit_rtrn" type="SetExplicit">
 						<fieldref>totalKeyExplicit</fieldref>
 					</list>
-                                        <pad align="4" />
+                                        <pad align="4" serialize="true" />
 				</bitcase>
 				<bitcase>
 					<enumref ref="MapPart">ModifierMap</enumref>
 					<list name="modmap_rtrn" type="KeyModMap">
 						<fieldref>totalModMapKeys</fieldref>
 					</list>
-                                        <pad align="4" />
+                                        <pad align="4" serialize="true" />
 				</bitcase>
 				<bitcase>
 					<enumref ref="MapPart">VirtualModMap</enumref>
@@ -1670,7 +1670,7 @@ authorization from the authors.
 					       <fieldref>nKTLevels</fieldref> -->
 					        <fieldref>nTypes</fieldref>
 					</list>
-					<pad align="4" />
+					<pad align="4" serialize="true" />
 					<list name="ktLevelNames" type="ATOM">
 						<sumof ref="nLevelsPerType" />
 					</list>

commit 21b11ee553a0bf074e9672be9107e11c97704195
Author: Christian Linhart <chris@demorecorder.com>
Date:   Mon Jan 18 06:52:02 2016 +0100

    optionally enforce serialization of pads
    
    From now on, due to a patch in libxcb, pads will not be serialized
    anymore. This is to maintain ABI-compatibility when adding
    explicit align pads.
    
    However, some align pads were already be serialized in prior
    official versions of libxcb. Therefore we need a method to
    enforce serialization, so we can maintainn ABI compatibility
    with that legacy.
    
    Signed-off-by: Christian Linhart <chris@demorecorder.com>

diff --git a/doc/xml-xcb.txt b/doc/xml-xcb.txt
index 12c0881..9cef1de 100644
--- a/doc/xml-xcb.txt
+++ b/doc/xml-xcb.txt
@@ -191,11 +191,18 @@ enum; the value is restricted to one of the constants named in the enum.
 "mask" refers to an exhaustive enum to be used as a bitmask.
 "altmask" may be a mask from the referred enum, but it need not be.
 
-<pad bytes="integer" />
+<pad bytes="integer" serialize="bool" />
 
   This element declares some padding in a data structure.  The bytes
   attribute declares the number of bytes of padding.
 
+  If serialize="true", then the pad will be serialized/deserialized.
+  This is only needed for ABI compatibility with legacy.
+  Newly added pads should not be defined with serialize="true".
+
+  The serialize attribute may be omitted.
+  Default is serialize="false".
+
 <field type="identifier" name="identifier" />
 
   This element represents a field in a data structure.  The type attribute
diff --git a/xcbgen/xtypes.py b/xcbgen/xtypes.py
index 1f604de..c3b5758 100644
--- a/xcbgen/xtypes.py
+++ b/xcbgen/xtypes.py
@@ -6,6 +6,7 @@ from xcbgen.align import Alignment, AlignmentLog
 import __main__
 
 verbose_align_log = False
+true_values = ['true', '1', 'yes']
 
 class Type(object):
     '''
@@ -429,6 +430,7 @@ class PadType(Type):
         if elt != None:
             self.nmemb = int(elt.get('bytes', "1"), 0)
             self.align = int(elt.get('align', "1"), 0)
+            self.serialize = elt.get('serialize', "false").lower() in true_values
 
         # pads don't require any alignment at their start
         self.required_start_align = Alignment(1,0)

commit 811e038c9501dfe95301d5f148be1f2b1bafbc1e
Author: Jaya Tiwari <tiwari.jaya18@gmail.com>
Date:   Wed Nov 11 01:01:32 2015 +0100

    calculate lengthless list
    
    Some rework done by Christian Linhart
    
    Signed-off-by: Jaya Tiwari <tiwari.jaya18@gmail.com>
    Signed-off-by: Christian Linhart <chris@demorecorder.com>

diff --git a/xcbgen/xtypes.py b/xcbgen/xtypes.py
index f5302be..1f604de 100644
--- a/xcbgen/xtypes.py
+++ b/xcbgen/xtypes.py
@@ -268,10 +268,17 @@ class ListType(Type):
         self.is_list = True
         self.member = member
         self.parents = list(parent)
+        lenfield_name = False
 
         if elt.tag == 'list':
             elts = list(elt)
             self.expr = Expression(elts[0] if len(elts) else elt, self)
+            is_list_in_parent = self.parents[0].elt.tag in ('request', 'event', 'reply', 'error')
+            if not len(elts) and is_list_in_parent:
+                self.expr = Expression(elt,self)
+                self.expr.op = 'calculate_len'
+            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

commit fe8ae2426d0064972a2f612d5d520879ffbd9278
Author: Christian Linhart <chris@demorecorder.com>
Date:   Sun Nov 1 19:44:29 2015 +0100

    make xkb pass the alignment checker
    
    These are just minimal adjustments to get xkb through
    the checks of the alignment checker.
    
    It is not the big fixup which I have already posted an RFC patch
    a while ago.
    
    V2 of this patch:
      make indentation consistent with the file
      (tabs vs spaces)
    
    Signed-off-by: Christian Linhart <chris@demorecorder.com>

diff --git a/src/xkb.xml b/src/xkb.xml
index ad52ea2..06488e7 100644
--- a/src/xkb.xml
+++ b/src/xkb.xml
@@ -745,6 +745,7 @@ authorization from the authors.
 		<list name="string" type="STRING8">
 			<fieldref>length</fieldref>
 		</list>
+		<pad align="2" />
 	</struct>
 
 	<struct name="DeviceLedInfo">
@@ -1443,6 +1444,7 @@ authorization from the authors.
 				<list name="actionsCount" type="CARD8">
 					<fieldref>nKeyActions</fieldref>
 				</list>
+				<pad align="4" />
 				<list name="actions" type="Action">
 					<fieldref>totalActions</fieldref>
 				</list>
@@ -1458,6 +1460,7 @@ authorization from the authors.
 				<list name="vmods" type="CARD8">
 					<popcount><fieldref>virtualMods</fieldref></popcount>
 				</list>
+				<pad align="4" />
 			</bitcase>
 			<bitcase>
 				<enumref ref="MapPart">ExplicitComponents</enumref>
@@ -1667,20 +1670,7 @@ authorization from the authors.
 					       <fieldref>nKTLevels</fieldref> -->
 					        <fieldref>nTypes</fieldref>
 					</list>
-					<list type="CARD8" name="alignment_pad">
-					    <op op="-">
-						<op op="&amp;">
-						    <op op="+">
-							<fieldref>nTypes</fieldref>
-							<value>3</value>
-						    </op>
-						    <unop op="~">
-							<value>3</value>
-						    </unop>
-						</op>
-						<fieldref>nTypes</fieldref>
-					    </op>
-					</list>
+					<pad align="4" />
 					<list name="ktLevelNames" type="ATOM">
 						<sumof ref="nLevelsPerType" />
 					</list>
@@ -1784,6 +1774,7 @@ authorization from the authors.
 				<list name="nLevelsPerType" type="CARD8">
 					<fieldref>nTypes</fieldref>
 				</list>
+				<pad align="4"/>
 				<list name="ktLevelNames" type="ATOM">
 					<sumof ref="nLevelsPerType" />
 				</list>
@@ -2092,6 +2083,7 @@ authorization from the authors.
 							<list name="acts_rtrn_count" type="CARD8">
 								<fieldref>nKeyActions</fieldref>
 							</list>
+							<pad align="4" />
 							<list name="acts_rtrn_acts" type="Action">
 								<fieldref>totalActions</fieldref>
 							</list>
@@ -2107,18 +2099,21 @@ authorization from the authors.
 							<list name="vmods_rtrn" type="CARD8" mask="ModMask">
 								<popcount><fieldref>virtualMods</fieldref></popcount>
 							</list>
+							<pad align="4" />
 						</bitcase>
 						<bitcase>
 							<enumref ref="MapPart">ExplicitComponents</enumref>
 							<list name="explicit_rtrn" type="SetExplicit">
 								<fieldref>totalKeyExplicit</fieldref>
 							</list>
+							<pad align="4" />
 						</bitcase>
 						<bitcase>
 							<enumref ref="MapPart">ModifierMap</enumref>
 							<list name="modmap_rtrn" type="KeyModMap">
 								<fieldref>totalModMapKeys</fieldref>
 							</list>
+							<pad align="4" />
 						</bitcase>
 						<bitcase>
 							<enumref ref="MapPart">VirtualModMap</enumref>
@@ -2226,6 +2221,7 @@ authorization from the authors.
 							<list name="nLevelsPerType" type="CARD8">
 								<fieldref>nTypes</fieldref>
 							</list>
+							<pad align="4" />
 							<list name="ktLevelNames" type="ATOM">
 								<sumof ref="nLevelsPerType" />
 							</list>
@@ -2352,6 +2348,7 @@ authorization from the authors.
 			<list name="name" type="STRING8">
 				<fieldref>nameLen</fieldref>
 			</list>
+			<pad align="4" />
 			<list name="btnActions" type="Action">
 				<fieldref>nBtnsRtrn</fieldref>
 			</list>

commit c499401bdac3b87bd4f9cd4bc64cfd1781ab447f
Author: Christian Linhart <chris@demorecorder.com>
Date:   Sun Nov 1 18:26:33 2015 +0100

    automatic alignment checker / manual offsets
    
    The verification algorithm basically traverses the protocol-description
    of a protocol entity by recursively processing all fields and their
    types.
    
    A start-align consists of two numbers:
    * the alignment: This is a power of 2, and guarantees that the
      address (or protocol position) minus the offset can be divided
      by this number.
    
    * the offset: how many bytes the current position is after a
      position that can be divided by the alignment.
    
    The algorithm starts with the start-alignment and computes the alignment
    of each field from the start-align of the previous field as follows:
    * if the previous field is a primitive type then the offset is increased
      by the size of the primitive type module the alignment.
      If the alignment or offset are incompatible with the primitive type,
      then an error is reported.
    * if the previous field is a complex type, then it is processed recursively.
    * if the previous field is an alignment-pad, then the alignment is
      adjusted accordingly, as to be expected by the alignment-pad.
    
    Start-aligns can also be set manually with the xml-element
    "required_start_align" which has two attributes: "align" and "offset"
    If "offset" is omitted, it is assumed to 0.
    
    All toplevel protocol entities default to 4-byte start-alignment with offset 0.
    
    All non-toplevel complex entities, such as structs, switch, case, ...
    do not have a default alignment.
    If no alignment is explicitly specified for them, their alignment
    is computed by their usage in other entities.
    In that case, if they are used with aligments that violate the
    alignment requirements of some of their fields, an error is issued.
    
    If they are used with an alignment with non-zero offset,
    a warning is issued, which recommends to specify the required_start_align
    explicitly. (Reason: I don't want non-zero offsets to be silently
    computed automatically. These non-zero offsets have to be reviewed
    by a human and specified explicitely to record that this was reviewed
    by a human)
    
    If the required_start_align is explicitly specified for an entity
    then an error will be issued if it is used with an aligment that's
    incompatible with the explicitly specified alignment.
    
    If an entity is used in different contexts with different start-aligns
    then those start-aligns are combined to an align which is compatible
    with all aligns.
    E.g. (align 4, offset 0) and (align 4, offset 2) are combined
    to (align 2, offset 0).
    
    Error reports include the relevant context for a misalignment.
    For non-toplevel entities this includes the entity-usage stack.
    There is some complexity in the algorithm for reducing the size
    of the error-reports to include only the relevant info.
    
    This alignment verifier is also a prerequisite for getting
    rid of implicit alignment altogether.
    (This will then simplify the generated code and make it faster.)
    
    Signed-off-by: Christian Linhart <chris@demorecorder.com>

diff --git a/xcbgen/Makefile.am b/xcbgen/Makefile.am
index 110a992..d6c7adc 100644
--- a/xcbgen/Makefile.am
+++ b/xcbgen/Makefile.am
@@ -1,3 +1,3 @@
 pkgpythondir = $(pythondir)/xcbgen
 
-pkgpython_PYTHON = __init__.py error.py expr.py matcher.py state.py xtypes.py
+pkgpython_PYTHON = __init__.py error.py expr.py align.py matcher.py state.py xtypes.py
diff --git a/xcbgen/align.py b/xcbgen/align.py
new file mode 100644
index 0000000..5e31838
--- /dev/null
+++ b/xcbgen/align.py
@@ -0,0 +1,177 @@
+'''
+This module contains helper classes for alignment arithmetic and checks
+'''
+
+from fractions import gcd
+
+class Alignment(object):
+
+    def __init__(self, align=4, offset=0):
+        self.align = align
+        # normalize the offset (just in case)
+        self.offset = offset % align
+
+
+    def __eq__(self, other):
+        return self.align == other.align and self.offset == other.offset
+
+    def __str__(self):
+	return "(align=%d, offset=%d)" % (self.align, self.offset)
+
+    @staticmethod
+    def for_primitive_type(size):
+	# compute the required start_alignment based on the size of the type
+	if size % 8 == 0:
+            # do 8-byte primitives require 8-byte alignment in X11?
+            return Alignment(8,0)
+        elif size % 4 == 0:
+            return Alignment(4,0)
+        elif size % 2 == 0:
+            return Alignment(2,0)
+        else:
+            return Alignment(1,0)
+
+
+    def align_after_fixed_size(self, size):
+	new_offset = (self.offset + size) % self.align
+        return Alignment(self.align, new_offset)
+
+
+    def is_guaranteed_at(self, external_align):
+        '''
+        Assuming the given external_align, checks whether
+        self is fulfilled for all cases.
+	Returns True if yes, False otherwise.
+        '''
+        if self.align == 1 and self.offset == 0:
+            # alignment 1 with offset 0 is always fulfilled
+            return True
+
+        if external_align is None:
+            # there is no external align -> fail
+            return False
+
+        if external_align.align < self.align:
+            # the external align guarantees less alignment -> not guaranteed
+            return False
+
+	if external_align.align % self.align != 0:
+            # the external align cannot be divided by our align
+	    # -> not guaranteed
+            # (this can only happen if there are alignments that are not
+            # a power of 2, which is highly discouraged. But better be
+            # safe and check for it)
+            return False
+
+        if external_align.offset % self.align != self.offset:
+            # offsets do not match
+            return False
+
+        return True
+
+
+    def combine_with(self, other):
+        # returns the alignment that is guaranteed when
+	# both, self or other, can happen
+        new_align = gcd(self.align, other.align)
+        new_offset_candidate1 = self.offset % new_align
+        new_offset_candidate2 = other.offset % new_align
+        if new_offset_candidate1 == new_offset_candidate2:
+            new_offset = new_offset_candidate1
+        else:
+            offset_diff = abs(new_offset_candidate2 - new_offset_candidate1)
+            new_align = gcd(new_align, offset_diff)
+            new_offset_candidate1 = self.offset % new_align
+            new_offset_candidate2 = other.offset % new_align
+	    assert new_offset_candidate1 == new_offset_candidate2
+	    new_offset = new_offset_candidate1
+        # return the result
+        return Alignment(new_align, new_offset)
+
+
+class AlignmentLog(object):
+
+    def __init__(self):
+	self.ok_list = []
+	self.fail_list = []
+	self.verbosity = 1
+
+    def __str__(self):
+	result = ""
+
+	# output the OK-list
+	for (align_before, field_name, type_obj, callstack, align_after) in self.ok_list:
+	    stacksize = len(callstack)
+            indent = '  ' * stacksize
+	    if self.ok_callstack_is_relevant(callstack):
+                if field_name is None or field_name == "":
+	            result += ("    %sok: %s:\n\t%sbefore: %s, after: %s\n"
+		        % (indent, str(type_obj), indent, str(align_before), str(align_after)))
+	        else:
+		    result += ("    %sok: field \"%s\" in %s:\n\t%sbefore: %s, after: %s\n"
+		        % (indent, str(field_name), str(type_obj),
+		           indent, str(align_before), str(align_after)))
+                if self.verbosity >= 1:
+		    result += self.callstack_to_str(indent, callstack)
+
+	# output the fail-list
+	for (align_before, field_name, type_obj, callstack, reason) in self.fail_list:
+	    stacksize = len(callstack)
+            indent = '  ' * stacksize
+	    if field_name is None or field_name == "":
+	        result += ("    %sfail: align %s is incompatible with\n\t%s%s\n\t%sReason: %s\n"
+		    % (indent, str(align_before), indent, str(type_obj), indent, reason))
+	    else:
+		result += ("    %sfail: align %s is incompatible with\n\t%sfield \"%s\" in %s\n\t%sReason: %s\n"
+		    % (indent, str(align_before), indent, str(field_name), str(type_obj), indent, reason))
+
+            if self.verbosity >= 1:
+	        result += self.callstack_to_str(indent, callstack)
+
+
+	return result
+
+
+    def callstack_to_str(self, indent, callstack):
+        result = "\t%scallstack: [\n" % indent
+        for stack_elem in callstack:
+            result += "\t  %s%s\n" % (indent, str(stack_elem))
+        result += "\t%s]\n" % indent
+	return result
+
+
+    def ok_callstack_is_relevant(self, ok_callstack):
+        # determine whether an ok callstack is relevant for logging
+	if self.verbosity >= 2:
+	    return True
+
+        # empty callstacks are always relevant
+	if len(ok_callstack) == 0:
+            return True
+
+	# check whether the ok_callstack is a subset or equal to a fail_callstack
+        for (align_before, field_name, type_obj, fail_callstack, reason) in self.fail_list:
+            if len(ok_callstack) <= len(fail_callstack):
+                zipped = zip(ok_callstack, fail_callstack[:len(ok_callstack)])
+		is_subset = all([i == j for i, j in zipped])
+		if is_subset:
+                    return True
+
+        return False
+
+
+    def ok(self, align_before, field_name, type_obj, callstack, align_after):
+	self.ok_list.append((align_before, field_name, type_obj, callstack, align_after))
+
+    def fail(self, align_before, field_name, type_obj, callstack, reason):
+	self.fail_list.append((align_before, field_name, type_obj, callstack, reason))
+
+    def append(self, other):
+	self.ok_list.extend(other.ok_list)
+	self.fail_list.extend(other.fail_list)
+
+    def ok_count(self):
+	return len(self.ok_list)
+
+
+
diff --git a/xcbgen/expr.py b/xcbgen/expr.py
index e4ee8c6..a716d34 100644
--- a/xcbgen/expr.py
+++ b/xcbgen/expr.py
@@ -24,6 +24,17 @@ class Field(object):
         self.isfd = isfd
         self.parent = None
 
+    def __str__(self):
+        field_string = "Field"
+        if self.field_name is None:
+            if self.field_type is not None:
+                field_string += " with type " + str(self.type)
+        else:
+            field_string += " \"" + self.field_name + "\""
+        if self.parent is not None:
+            field_string += " in " + str(self.parent)
+
+        return field_string
 
 class Expression(object):
     '''
@@ -122,6 +133,21 @@ class Expression(object):
     def fixed_size(self):
         return self.nmemb != None
 
+    def get_value(self):
+        return self.nmemb
+
+    # if the value of the expression is a guaranteed multiple of a number
+    # return this number, else return 1 (which is trivially guaranteed for integers)
+    def get_multiple(self):
+        multiple = 1
+        if self.op == '*':
+            if self.lhs.fixed_size():
+                multiple *= self.lhs.get_value()
+            if self.rhs.fixed_size():
+                multiple *= self.rhs.get_value()
+
+        return multiple
+
     def recursive_resolve_tasks(self, module, parents):
         for subexpr in (self.lhs, self.rhs):
             if subexpr != None:
diff --git a/xcbgen/xtypes.py b/xcbgen/xtypes.py
index 4d6bbc0..f5302be 100644
--- a/xcbgen/xtypes.py
+++ b/xcbgen/xtypes.py
@@ -2,8 +2,11 @@
 This module contains the classes which represent XCB data types.
 '''
 from xcbgen.expr import Field, Expression
+from xcbgen.align import Alignment, AlignmentLog
 import __main__
 
+verbose_align_log = False
+
 class Type(object):
     '''
     Abstract base class for all XCB data types.
@@ -36,6 +39,10 @@ class Type(object):
         self.is_case_or_bitcase = False
         self.is_bitcase = False
         self.is_case = False
+        self.required_start_align = Alignment()
+
+        # the biggest align value of an align-pad contained in this type
+        self.max_align_pad = 1
 
     def resolve(self, module):
         '''
@@ -91,7 +98,91 @@ class Type(object):
 
         complex_type.fields.append(new_fd)
 
-class SimpleType(Type):
+
+    def get_total_size(self):
+        '''
+        get the total size of this type if it is fixed-size, otherwise None
+        '''
+        if self.fixed_size():
+            if self.nmemb is None:
+                return self.size
+            else:
+                return self.size * self.nmemb
+        else:
+            return None
+
+    def get_align_offset(self):
+        if self.required_start_align is None:
+            return 0
+        else:
+            return self.required_start_align.offset
+
+    def is_acceptable_start_align(self, start_align, callstack, log):
+        return self.get_alignment_after(start_align, callstack, log) is not None
+
+    def get_alignment_after(self, start_align, callstack, log):
+        '''
+        get the alignment after this type based on the given start_align.
+        the start_align is checked for compatibility with the
+        internal start align. If it is not compatible, then None is returned
+        '''
+        if self.required_start_align is None or self.required_start_align.is_guaranteed_at(start_align):
+            return self.unchecked_get_alignment_after(start_align, callstack, log)
+        else:
+            if log is not None:
+                log.fail(start_align, "", self, callstack + [self],
+                    "start_align is incompatible with required_start_align %s"
+                    % (str(self.required_start_align)))
+            return None
+
+    def unchecked_get_alignment_after(self, start_align, callstack, log):
+        '''
+        Abstract method for geting the alignment after this type
+        when the alignment at the start is given, and when this type
+        has variable size.
+        '''
+        raise Exception('abstract unchecked_get_alignment_after method not overridden!')
+
+
+    @staticmethod
+    def type_name_to_str(type_name):
+        if isinstance(type_name, str):
+            #already a string
+            return type_name
+        else:
+            return ".".join(type_name)
+
+
+    def __str__(self):
+        return type(self).__name__ + " \"" + Type.type_name_to_str(self.name) + "\""
+
+class PrimitiveType(Type):
+
+    def __init__(self, name, size):
+        Type.__init__(self, name)


Reply to: