summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2018-03-15 00:26:19 -0700
committerOri Bernstein <ori@eigenstate.org>2018-03-15 00:26:19 -0700
commit2f3eb31cc305707dd39f3815ed7fc6243b5933de (patch)
tree2850c046257cfefcc2f91de5e290a91f77b9c376
parenta681ea0a49944112060fe1e0a5d6e0081dc010a7 (diff)
downloadlibxmyrb-2f3eb31cc305707dd39f3815ed7fc6243b5933de.tar.gz
Support for handling sent events.
-rwxr-xr-xgen.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/gen.py b/gen.py
index 9a58c9c..43a48bb 100755
--- a/gen.py
+++ b/gen.py
@@ -297,6 +297,7 @@ def genstruct(name, selt, isreq=False, isresp=False, isevent=False):
writeln(iface, 'sequence\t: uint16')
writeln(iface, 'length\t: uint32')
elif isevent:
+ writeln(iface, 'issent\t: bool')
if selt.get('xge') is not None:
writeln(iface, 'ext\t: byte')
writeln(iface, 'sequence\t:uint16')
@@ -560,23 +561,24 @@ def geneventunion(mods, elts):
writeln(iface, ';;')
for (k, v) in elts.items():
- writeln(impl, 'const get{} = {{dpy, evp', k.lower())
+ writeln(impl, 'const get{} = {{dpy, evp, issent', k.lower())
indent(impl)
writeln(impl, 'var v : {}', k.lower())
writeln(impl, 'unpack{}(dpy, &v)', k.lower())
+ writeln(impl, 'v.issent = issent')
writeln(impl, 'evp# = `{} v', k)
outdent(impl)
writeln(impl, '}}')
- writeln(iface, 'const event : (dpy : display#, ev : event# -> void)')
+ writeln(iface, 'const event : (dpy : display#, evp : event# -> void)')
writeln(impl, 'const event = {{dpy, evp')
indent(impl)
- writeln(impl, 'var evcode : byte, ext : byte, sequence : uint16, length : uint32, evtype : uint16')
+ writeln(impl, 'var evcode, ext : byte, sequence : uint16, length : uint32, evtype : uint16')
writeln(impl, '')
writeln(impl, 'unpackbyte(dpy, &evcode)')
- writeln(impl, 'match evcode')
+ writeln(impl, 'match evcode & 0x7f')
for (k, v) in elts.items():
- writeln(impl, '| {}: get{}(dpy, evp)', v.get('number'), k.lower())
+ writeln(impl, '| {}: get{}(dpy, evp, (evcode & 0x80) != 0)', v.get('number'), k.lower())
writeln(impl, '| _: std.fatal("invalid event {{}}\\n", evcode)')
writeln(impl, ';;')
writeln(impl, 'unpackalign(dpy, 32)')