Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
Pack requests using standard size and no alignment.
Browse files Browse the repository at this point in the history
By default, Python's struct module automatically adds alignment padding
between successive structure members. We need precise control over the
layout of requests, so it's important that we not let it do that.

Signed-off-by: Julien Danjou <julien@danjou.info>
  • Loading branch information
plotnick authored and tych0 committed Apr 15, 2012
1 parent c4797e2 commit c849010
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tools/py_client.py
Expand Up @@ -476,24 +476,24 @@ def _py_request_helper(self, name, void, regular):

(format, size, list) = _py_flush_format()
if size > 0:
_py(' buf.write(pack(\'%s\', %s))', format, list)
_py(' buf.write(pack(\'=%s\', %s))', format, list)

if field.type.is_expr:
_py(' buf.write(pack(\'%s\', %s))', field.type.py_format_str, _py_get_expr(field.type.expr))
_py(' buf.write(pack(\'=%s\', %s))', field.type.py_format_str, _py_get_expr(field.type.expr))
elif field.type.is_pad:
_py(' buf.write(pack(\'%sx\'))', field.type.nmemb)
elif field.type.is_container:
_py(' for elt in xcb.Iterator(%s, %d, \'%s\', False):', _n(field.field_name), field.type.py_format_len, _n(field.field_name))
_py(' buf.write(pack(\'%s\', *elt))', field.type.py_format_str)
_py(' buf.write(pack(\'=%s\', *elt))', field.type.py_format_str)
elif field.type.is_list and field.type.member.is_simple:
_py(' buf.write(str(buffer(array(\'%s\', %s))))', field.type.member.py_format_str, _n(field.field_name))
else:
_py(' for elt in xcb.Iterator(%s, %d, \'%s\', True):', _n(field.field_name), field.type.member.py_format_len, _n(field.field_name))
_py(' buf.write(pack(\'%s\', *elt))', field.type.member.py_format_str)
_py(' buf.write(pack(\'=%s\', *elt))', field.type.member.py_format_str)

(format, size, list) = _py_flush_format()
if size > 0:
_py(' buf.write(pack(\'%s\', %s))', format, list)
_py(' buf.write(pack(\'=%s\', %s))', format, list)

_py(' return self.send_request(xcb.Request(buf.getvalue(), %s, %s, %s),', self.opcode, _b(void), _b(func_flags))
_py(' %s()%s', func_cookie, ')' if void else ',')
Expand Down

0 comments on commit c849010

Please sign in to comment.