aboutsummaryrefslogtreecommitdiff
path: root/libxcb
diff options
context:
space:
mode:
Diffstat (limited to 'libxcb')
-rw-r--r--libxcb/src/c_client.py28
-rw-r--r--libxcb/xcb-proto/src/xcb.xsd3
-rw-r--r--libxcb/xcb-proto/src/xkb.xml60
-rw-r--r--libxcb/xcb-proto/xcbgen/state.py1
-rw-r--r--libxcb/xcb-proto/xcbgen/xtypes.py16
5 files changed, 35 insertions, 73 deletions
diff --git a/libxcb/src/c_client.py b/libxcb/src/c_client.py
index 8217029e9..794501a5d 100644
--- a/libxcb/src/c_client.py
+++ b/libxcb/src/c_client.py
@@ -982,15 +982,22 @@ def _c_serialize_helper_fields(context, self,
# fields with variable size
else:
- # switch/bitcase: always calculate padding before and after variable sized fields
- if need_padding or is_bitcase:
+ if field.type.is_pad:
+ # Variable length pad is <pad align= />
+ code_lines.append('%s xcb_align_to = %d;' % (space, field.type.align))
count += _c_serialize_helper_insert_padding(context, code_lines, space,
+ self.var_followed_by_fixed_fields)
+ continue
+ else:
+ # switch/bitcase: always calculate padding before and after variable sized fields
+ if need_padding or is_bitcase:
+ count += _c_serialize_helper_insert_padding(context, code_lines, space,
self.var_followed_by_fixed_fields)
- value, length = _c_serialize_helper_fields_variable_size(context, self, field,
- code_lines, temp_vars,
- space, prefix)
- prev_field_was_variable = True
+ value, length = _c_serialize_helper_fields_variable_size(context, self, field,
+ code_lines, temp_vars,
+ space, prefix)
+ prev_field_was_variable = True
# save (un)serialization C code
if '' != value:
@@ -1741,10 +1748,11 @@ def _c_accessors(self, name, base):
# else:
if True:
for field in self.fields:
- if field.type.is_list and not field.type.fixed_size():
- _c_accessors_list(self, field)
- elif field.prev_varsized_field is not None or not field.type.fixed_size():
- _c_accessors_field(self, field)
+ if not field.type.is_pad:
+ if field.type.is_list and not field.type.fixed_size():
+ _c_accessors_list(self, field)
+ elif field.prev_varsized_field is not None or not field.type.fixed_size():
+ _c_accessors_field(self, field)
def c_simple(self, name):
'''
diff --git a/libxcb/xcb-proto/src/xcb.xsd b/libxcb/xcb-proto/src/xcb.xsd
index 73dbf8a77..580d2588d 100644
--- a/libxcb/xcb-proto/src/xcb.xsd
+++ b/libxcb/xcb-proto/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/libxcb/xcb-proto/src/xkb.xml b/libxcb/xcb-proto/src/xkb.xml
index 1df0771e1..9ef4402ec 100644
--- a/libxcb/xcb-proto/src/xkb.xml
+++ b/libxcb/xcb-proto/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="&amp;">
- <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="&amp;">
- <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="&amp;">
- <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="&amp;">
- <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>
diff --git a/libxcb/xcb-proto/xcbgen/state.py b/libxcb/xcb-proto/xcbgen/state.py
index 10a8722ea..52b8d8da7 100644
--- a/libxcb/xcb-proto/xcbgen/state.py
+++ b/libxcb/xcb-proto/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/libxcb/xcb-proto/xcbgen/xtypes.py b/libxcb/xcb-proto/xcbgen/xtypes.py
index 5f45723ce..3cd90320e 100644
--- a/libxcb/xcb-proto/xcbgen/xtypes.py
+++ b/libxcb/xcb-proto/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):
@@ -296,16 +300,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 +400,6 @@ class SwitchType(ComplexType):
def resolve(self, module):
if self.resolved:
return
-# pads = 0
parents = list(self.parents) + [self]
@@ -560,6 +562,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)