[Xcb-commit] src

Peter Harris peterh at kemper.freedesktop.org
Thu May 23 07:52:39 PDT 2013


 src/c_client.py |   18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

New commits:
commit e602b653c191e18cbb63db6526aac77c368ed70b
Author: Daniel Martin <consume.noise at gmail.com>
Date:   Mon May 13 23:33:04 2013 +0200

    c_client.py: Handle multiple expr. in a bitcase
    
    Adopt a change from xcbgen. With that modification the expression in a
    bitcase became a list of expressions to support multiple <enumref> in a
    <bitcase>.
    
    Signed-off-by: Daniel Martin <consume.noise at gmail.com>
    Signed-off-by: Peter Harris <pharris at opentext.com>

diff --git a/src/c_client.py b/src/c_client.py
index ec66223..942e78a 100644
--- a/src/c_client.py
+++ b/src/c_client.py
@@ -687,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 <enumref> in the <bitcase>
+            if len_expr == 1:
+                code_lines.append('    if(%s & %s) {' % (switch_expr, bitcase_expr))
+            # multiple <enumref> in the <bitcase>
+            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)]


More information about the xcb-commit mailing list