summaryrefslogtreecommitdiff
path: root/src/c_client.py
diff options
context:
space:
mode:
authorChristian Linhart <chris@demorecorder.com>2017-01-25 10:21:05 +0100
committerChristian Linhart <chris@demorecorder.com>2017-03-11 10:51:50 +0100
commitee9dfc9a7658e7fe75d27483bb5ed1ba4d1e2c86 (patch)
treed5d8d0efdfdc33576f7df694d8798bf31e3ec2b6 /src/c_client.py
parent0c2c5d50f8670da3e7601feb6a29b53509513da5 (diff)
add support for eventstruct
eventstruct allows to use events as part of requests. This is, e.g., needed by xcb_input_send_extension_event. Signed-off-by: Christian Linhart <chris@demorecorder.com>
Diffstat (limited to 'src/c_client.py')
-rw-r--r--src/c_client.py32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/c_client.py b/src/c_client.py
index b0eb47c..0cbdf30 100644
--- a/src/c_client.py
+++ b/src/c_client.py
@@ -437,7 +437,11 @@ def _c_type_setup(self, name, postfix):
first_field_after_varsized = None
for field in self.fields:
- field.c_field_type = _t(field.field_type)
+ if field.type.is_event:
+ field.c_field_type = _t(field.field_type + ('event',))
+ else:
+ field.c_field_type = _t(field.field_type)
+
field.c_field_const_type = ('' if field.type.nmemb == 1 else 'const ') + field.c_field_type
field.c_field_name = _cpp(field.field_name)
field.c_subscript = '[%d]' % field.type.nmemb if (field.type.nmemb and field.type.nmemb > 1) else ''
@@ -3156,6 +3160,28 @@ def c_request(self, name):
# TODO: what about aux helpers?
_man_request(self, name, void=not self.reply, aux=False)
+
+def c_eventstruct(self, name):
+ #add fields that are needed to get the event-type in a generic way
+ self.fields.append( Field( tevent, tevent.name, 'event_header', False, True, True) )
+
+ if self.contains_ge_events:
+ #TODO: add header of ge-events as an extra field
+ raise Exception( 'eventstructs with ge-events are not yet supported' )
+
+ _c_type_setup(self, name, ())
+
+ #correct the format of the field names
+ for field in self.fields:
+ field.c_field_name = _n_item(field.c_field_name).lower()
+
+ _c_complex(self)
+ _c_iterator(self, name)
+
+ if not self.fixed_size():
+ #TODO: Create sizeof function (and maybe other accessors) for var-sized eventstructs
+ raise Exception( 'var sized eventstructs are not yet supported' )
+
def c_event(self, name):
'''
Exported function that handles event declarations.
@@ -3253,6 +3279,7 @@ output = {'open' : c_open,
'struct' : c_struct,
'union' : c_union,
'request' : c_request,
+ 'eventstruct' : c_eventstruct,
'event' : c_event,
'error' : c_error,
}
@@ -3296,6 +3323,9 @@ Refer to the README file in xcb/proto for more info.
''')
raise
+# predefined datatype globals.
+tevent = SimpleType(('xcb_raw_generic_event_t',), 32)
+
# Ensure the man subdirectory exists
try:
os.mkdir('man')