[Xcb] xpyb bub
Aldo Cortesi
aldo at nullcube.com
Wed Dec 16 21:23:06 PST 2009
Hi folks,
I'm porting a window manger over from a Python Xlib implementation, to
xpyb. I'm tripping over a bug in the generated definition for
QueryTextExtents:
def QueryTextExtents(self, font, string_len, string):
buf = cStringIO.StringIO()
buf.write(pack('x', ))
buf.write(pack('B', (self.string_len & 1)))
^^^^^^^^^^^^^^^^^
The enclosing xprotoExtension object does not have a string_len attribute - the
definition should look like this:
def QueryTextExtents(self, font, string_len, string):
buf = cStringIO.StringIO()
buf.write(pack('x', ))
buf.write(pack('B', (string_len & 1)))
Below is a small patch that fixes this problem. It checks whether the
enclosing object is a Request, and uses the appropriate scope. The
patch can be made nicer by adding an is_request attribute to Request
(similar to the existing is_reply attribute on Reply), so someone with
commit to both the xpyb and xcbgen projects could clean it up a bit.
The patch can also be pulled from my repo here:
git://github.com/cortesi/xpyb.git
Regards,
Aldo
--
Aldo Cortesi
www.nullcube.com
+64 210 718 900
diff --git a/src/py_client.py b/src/py_client.py
index c056fd6..c25e39d 100755
--- a/src/py_client.py
+++ b/src/py_client.py
@@ -257,7 +257,11 @@ def _py_get_length_field(expr):
Otherwise, just reference the structure field directly.
'''
if expr.lenfield_name != None:
- return 'self.%s' % expr.lenfield_name
+ # This would be nicer if Request had an is_request attribute...
+ if hasattr(expr.parent.parent, "opcode"):
+ return expr.lenfield_name
+ else:
+ return 'self.%s' % expr.lenfield_name
else:
return str(expr.nmemb)
More information about the Xcb
mailing list