|
|
fa5c65 |
From e602b653c191e18cbb63db6526aac77c368ed70b Mon Sep 17 00:00:00 2001
|
|
|
fa5c65 |
From: Daniel Martin <consume.noise@gmail.com>
|
|
|
fa5c65 |
Date: Mon, 13 May 2013 23:33:04 +0200
|
|
|
fa5c65 |
Subject: [PATCH] c_client.py: Handle multiple expr. in a bitcase
|
|
|
fa5c65 |
|
|
|
fa5c65 |
Adopt a change from xcbgen. With that modification the expression in a
|
|
|
fa5c65 |
bitcase became a list of expressions to support multiple <enumref> in a
|
|
|
fa5c65 |
<bitcase>.
|
|
|
fa5c65 |
|
|
|
fa5c65 |
Signed-off-by: Daniel Martin <consume.noise@gmail.com>
|
|
|
fa5c65 |
Signed-off-by: Peter Harris <pharris@opentext.com>
|
|
|
fa5c65 |
---
|
|
|
fa5c65 |
src/c_client.py | 18 ++++++++++++++----
|
|
|
fa5c65 |
1 file changed, 14 insertions(+), 4 deletions(-)
|
|
|
fa5c65 |
|
|
|
fa5c65 |
diff --git a/src/c_client.py b/src/c_client.py
|
|
|
fa5c65 |
index ec66223..942e78a 100644
|
|
|
fa5c65 |
--- a/src/c_client.py
|
|
|
fa5c65 |
+++ b/src/c_client.py
|
|
|
fa5c65 |
@@ -687,10 +687,20 @@ def _c_serialize_helper_switch(context, self, complex_name,
|
|
|
fa5c65 |
switch_expr = _c_accessor_get_expr(self.expr, None)
|
|
|
fa5c65 |
|
|
|
fa5c65 |
for b in self.bitcases:
|
|
|
fa5c65 |
- bitcase_expr = _c_accessor_get_expr(b.type.expr, None)
|
|
|
fa5c65 |
- code_lines.append(' if(%s & %s) {' % (switch_expr, bitcase_expr))
|
|
|
fa5c65 |
-# code_lines.append(' printf("switch %s: entering bitcase section %s (mask=%%%%d)...\\n", %s);' %
|
|
|
fa5c65 |
-# (self.name[-1], b.type.name[-1], bitcase_expr))
|
|
|
fa5c65 |
+ len_expr = len(b.type.expr)
|
|
|
fa5c65 |
+ for n, expr in enumerate(b.type.expr):
|
|
|
fa5c65 |
+ bitcase_expr = _c_accessor_get_expr(expr, None)
|
|
|
fa5c65 |
+ # only one <enumref> in the <bitcase>
|
|
|
fa5c65 |
+ if len_expr == 1:
|
|
|
fa5c65 |
+ code_lines.append(' if(%s & %s) {' % (switch_expr, bitcase_expr))
|
|
|
fa5c65 |
+ # multiple <enumref> in the <bitcase>
|
|
|
fa5c65 |
+ elif n == 0: # first
|
|
|
fa5c65 |
+ code_lines.append(' if((%s & %s) ||' % (switch_expr, bitcase_expr))
|
|
|
fa5c65 |
+ elif len_expr == (n + 1): # last
|
|
|
fa5c65 |
+ code_lines.append(' (%s & %s)) {' % (switch_expr, bitcase_expr))
|
|
|
fa5c65 |
+ else: # between first and last
|
|
|
fa5c65 |
+ code_lines.append(' (%s & %s) ||' % (switch_expr, bitcase_expr))
|
|
|
fa5c65 |
+
|
|
|
fa5c65 |
b_prefix = prefix
|
|
|
fa5c65 |
if b.type.has_name:
|
|
|
fa5c65 |
b_prefix = prefix + [(b.c_field_name, '.', b.type)]
|
|
|
fa5c65 |
--
|
|
|
fa5c65 |
2.1.0
|
|
|
fa5c65 |
|