[Xcb] [PATCH proto 1/3] Add optional packed attribute to struct elements
Daniel Martin
consume.noise at gmail.com
Sun Dec 23 04:51:47 PST 2012
When the packed attribute is set, it marks a struct that it mustn't be
aligned.
Signed-off-by: Daniel Martin <consume.noise at gmail.com>
---
doc/xml-xcb.txt | 6 +++++-
src/xcb.xsd | 1 +
xcbgen/xtypes.py | 4 ++++
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/doc/xml-xcb.txt b/doc/xml-xcb.txt
index 7057727..15121be 100644
--- a/doc/xml-xcb.txt
+++ b/doc/xml-xcb.txt
@@ -61,13 +61,17 @@ Top-Level Elements
root node. Note that types from xproto are automatically available, without
explicitly importing them.
-<struct name="identifier">structure contents</struct>
+<struct name="identifier" [packed="true"]>structure contents</struct>
This element represents a data structure. The name attribute gives the name
of the structure. The content represents the fields of the structure, and
consists of one or more of the field, pad, and list elements described in
the section "Structure Contents" below.
+ If the optional packed attribute is true, this means that the fixed size
+ part of the data structure is not a multiple of 4 and it mustn't be
+ aligned to the next 4byte boundary.
+
<union name="identifier">structure contents</union>
This element represents a union of data types, which can hold one value of
diff --git a/src/xcb.xsd b/src/xcb.xsd
index cfa90c9..bcad558 100644
--- a/src/xcb.xsd
+++ b/src/xcb.xsd
@@ -197,6 +197,7 @@ authorization from the authors.
</xsd:choice>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
+ <xsd:attribute name="packed" type="xsd:boolean" use="optional" />
</xsd:complexType>
<!-- Type for a packet structure -->
diff --git a/xcbgen/xtypes.py b/xcbgen/xtypes.py
index f6d4634..e6d15c8 100644
--- a/xcbgen/xtypes.py
+++ b/xcbgen/xtypes.py
@@ -461,6 +461,10 @@ class Struct(ComplexType):
'''
Derived class representing a struct data type.
'''
+ def __init__(self, name, elt):
+ ComplexType.__init__(self, name, elt)
+ self.packed = elt.get('packed')
+
out = __main__.output['struct']
--
1.8.0.2
More information about the Xcb
mailing list