summaryrefslogtreecommitdiff
path: root/xcbgen
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-01-14 14:19:45 -0800
committerKeith Packard <keithp@keithp.com>2013-11-07 05:14:12 -0800
commitc57d265a90f4ed82acf72e0161b8d7bf35830884 (patch)
treec8c496d7f9e2bfdfd35dd5d7e3d5b5ae59a69c09 /xcbgen
parent82263254e1c115d60ad007ff29e0749de52ed514 (diff)
downloadxcb-proto-c57d265a90f4ed82acf72e0161b8d7bf35830884.tar.gz
Add support for file descriptor request fields
These are present in the API, but not present on the wire. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
Diffstat (limited to 'xcbgen')
-rw-r--r--xcbgen/expr.py3
-rw-r--r--xcbgen/xtypes.py20
2 files changed, 21 insertions, 2 deletions
diff --git a/xcbgen/expr.py b/xcbgen/expr.py
index 4f8af6f..f9d5179 100644
--- a/xcbgen/expr.py
+++ b/xcbgen/expr.py
@@ -13,7 +13,7 @@ class Field(object):
auto is true iff the field is on the wire but not in the request API (e.g. opcode)
enum is the enum name this field refers to, if any.
'''
- def __init__(self, type, field_type, field_name, visible, wire, auto, enum=None):
+ def __init__(self, type, field_type, field_name, visible, wire, auto, enum=None, isfd=False):
self.type = type
self.field_type = field_type
self.field_name = field_name
@@ -21,6 +21,7 @@ class Field(object):
self.visible = visible
self.wire = wire
self.auto = auto
+ self.isfd = isfd
class Expression(object):
diff --git a/xcbgen/xtypes.py b/xcbgen/xtypes.py
index 4b43957..951731a 100644
--- a/xcbgen/xtypes.py
+++ b/xcbgen/xtypes.py
@@ -75,6 +75,18 @@ class Type(object):
complex_type.fields.append(new_field)
+ def make_fd_of(self, module, complex_type, fd_name):
+ '''
+ Method for making a fd member of a structure.
+ '''
+ new_fd = Field(self, module.get_type_name('INT32'), fd_name, True, False, False, None, True)
+ # We dump the _placeholder_byte if any fields are added.
+ for (idx, field) in enumerate(complex_type.fields):
+ if field == _placeholder_byte:
+ complex_type.fields[idx] = new_fd
+ return
+
+ complex_type.fields.append(new_fd)
class SimpleType(Type):
'''
@@ -279,6 +291,7 @@ class ComplexType(Type):
self.nmemb = 1
self.size = 0
self.lenfield_parent = [self]
+ self.fds = []
def resolve(self, module):
if self.resolved:
@@ -324,9 +337,14 @@ class ComplexType(Type):
type.make_member_of(module, self, field_type, field_name, visible, True, False)
type.resolve(module)
continue
+ elif child.tag == 'fd':
+ fd_name = child.get('name')
+ type = module.get_type('INT32')
+ type.make_fd_of(module, self, fd_name)
+ continue
else:
# Hit this on Reply
- continue
+ continue
# Get the full type name for the field
field_type = module.get_type_name(fkey)