X-Git-Url: http://git.demorecorder.com/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fc_client.py;h=2aba741cf38a8c6374a35a31253077879200a15f;hb=b9efd2a09a45616f6238e4da49b8f2127b6ec6d9;hp=d006d305d85947cc1c4a78c015e5a4f0414e6c2e;hpb=cc7fab2d5e912629d4a2a6adfb7666dc2ba45db2;p=free-sw%2Fxcb%2Flibxcb diff --git a/src/c_client.py b/src/c_client.py index d006d30..2aba741 100644 --- a/src/c_client.py +++ b/src/c_client.py @@ -5,6 +5,7 @@ from functools import reduce import getopt import os import sys +import errno import time import re @@ -175,6 +176,9 @@ def c_open(self): _h('') _h('#include "xcb.h"') + _c('#ifdef HAVE_CONFIG_H') + _c('#include "config.h"') + _c('#endif') _c('#include ') _c('#include ') _c('#include ') @@ -683,10 +687,20 @@ def _c_serialize_helper_switch(context, self, complex_name, switch_expr = _c_accessor_get_expr(self.expr, None) for b in self.bitcases: - bitcase_expr = _c_accessor_get_expr(b.type.expr, None) - code_lines.append(' if(%s & %s) {' % (switch_expr, bitcase_expr)) -# code_lines.append(' printf("switch %s: entering bitcase section %s (mask=%%%%d)...\\n", %s);' % -# (self.name[-1], b.type.name[-1], bitcase_expr)) + len_expr = len(b.type.expr) + for n, expr in enumerate(b.type.expr): + bitcase_expr = _c_accessor_get_expr(expr, None) + # only one in the + if len_expr == 1: + code_lines.append(' if(%s & %s) {' % (switch_expr, bitcase_expr)) + # multiple in the + elif n == 0: # first + code_lines.append(' if((%s & %s) ||' % (switch_expr, bitcase_expr)) + elif len_expr == (n + 1): # last + code_lines.append(' (%s & %s)) {' % (switch_expr, bitcase_expr)) + else: # between first and last + code_lines.append(' (%s & %s) ||' % (switch_expr, bitcase_expr)) + b_prefix = prefix if b.type.has_name: b_prefix = prefix + [(b.c_field_name, '.', b.type)] @@ -1118,11 +1132,11 @@ def _c_serialize(context, self): _c(' %s *xcb_out = *_buffer;', self.c_type) _c(' unsigned int xcb_out_pad = -sizeof(%s) & 3;', self.c_type) _c(' unsigned int xcb_buffer_len = sizeof(%s) + xcb_out_pad;', self.c_type) - _c(' unsigned int xcb_align_to;') + _c(' unsigned int xcb_align_to = 0;') else: _c(' char *xcb_out = *_buffer;') _c(' unsigned int xcb_buffer_len = 0;') - _c(' unsigned int xcb_align_to;') + _c(' unsigned int xcb_align_to = 0;') prefix = [('_aux', '->', self)] aux_ptr = 'xcb_out' @@ -1145,7 +1159,7 @@ def _c_serialize(context, self): _c(' unsigned int xcb_buffer_len = 0;') _c(' unsigned int xcb_block_len = 0;') _c(' unsigned int xcb_pad = 0;') - _c(' unsigned int xcb_align_to;') + _c(' unsigned int xcb_align_to = 0;') elif 'sizeof' == context: param_names = [p[2] for p in params] @@ -1190,7 +1204,7 @@ def _c_serialize(context, self): _c(' unsigned int xcb_buffer_len = 0;') _c(' unsigned int xcb_block_len = 0;') _c(' unsigned int xcb_pad = 0;') - _c(' unsigned int xcb_align_to;') + _c(' unsigned int xcb_align_to = 0;') _c('') for t in temp_vars: @@ -2612,7 +2626,7 @@ def _man_request(self, name, cookie_type, void, aux): (cookie_type, self.c_reply_name, base_func_name)) f.write('.SH ERRORS\n') if hasattr(self, "doc") and self.doc: - for errtype, errtext in self.doc.errors.iteritems(): + for errtype, errtext in self.doc.errors.items(): f.write('.IP \\fI%s\\fP 1i\n' % (_t(('xcb', errtype, 'error')))) errtext = re.sub(r'`([^`]+)`', r'\\fI\1\\fP', errtext) f.write('%s\n' % (errtext)) @@ -2630,7 +2644,7 @@ def _man_request(self, name, cookie_type, void, aux): see = ['.BR %s (3)' % 'xcb-requests'] if self.doc.example: see.append('.BR %s (3)' % 'xcb-examples') - for seename, seetype in self.doc.see.iteritems(): + for seename, seetype in self.doc.see.items(): if seetype == 'program': see.append('.BR %s (1)' % seename) elif seetype == 'event': @@ -2760,7 +2774,7 @@ def _man_event(self, name): see = ['.BR %s (3)' % 'xcb_generic_event_t'] if self.doc.example: see.append('.BR %s (3)' % 'xcb-examples') - for seename, seetype in self.doc.see.iteritems(): + for seename, seetype in self.doc.see.items(): if seetype == 'program': see.append('.BR %s (1)' % seename) elif seetype == 'event': @@ -2823,6 +2837,23 @@ def c_event(self, name): ''' Exported function that handles event declarations. ''' + + # The generic event structure xcb_ge_event_t has the full_sequence field + # at the 32byte boundary. That's why we've to inject this field into GE + # events while generating the structure for them. Otherwise we would read + # garbage (the internal full_sequence) when accessing normal event fields + # there. + if hasattr(self, 'is_ge_event') and self.is_ge_event and self.name == name: + event_size = 0 + for field in self.fields: + if field.type.size != None and field.type.nmemb != None: + event_size += field.type.size * field.type.nmemb + if event_size == 32: + full_sequence = Field(tcard32, tcard32.name, 'full_sequence', False, True, True) + idx = self.fields.index(field) + self.fields.insert(idx + 1, full_sequence) + break + _c_type_setup(self, name, ('event',)) # Opcode define @@ -2902,8 +2933,11 @@ Refer to the README file in xcb/proto for more info. raise # Ensure the man subdirectory exists -if not os.path.exists('man'): +try: os.mkdir('man') +except OSError as e: + if e.errno != errno.EEXIST: + raise today = time.strftime('%Y-%m-%d', time.gmtime(os.path.getmtime(args[0])))