[PATCH 1/2] Allow <enum> to have the same name as <xidtype>
Peter Harris
pharris at opentext.com
Wed Feb 25 13:56:19 PST 2009
Fixes compile errors with latest xcb/proto.
Signed-off-by: Peter Harris <pharris at opentext.com>
---
src/c_client.py | 20 +++++++++++++++++---
1 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/src/c_client.py b/src/c_client.py
index 73bd064..41d9d79 100755
--- a/src/c_client.py
+++ b/src/c_client.py
@@ -124,7 +124,21 @@ def _t(list):
else:
parts = [list[0]] + [_n_item(i) for i in list[1:]] + ['t']
return '_'.join(parts).lower()
-
+
+def _enum(list):
+ '''
+ Does C-name conversion on a tuple of strings representing a type.
+ Same as _t but adds an "_enum" on the end.
+ '''
+ if len(list) == 1:
+ parts = list
+ elif len(list) == 2:
+ parts = [list[0], _n_item(list[1]), 'enum']
+ elif _ns.is_ext:
+ parts = [list[0], _ext(list[1])] + [_n_item(i) for i in list[2:]] + ['enum']
+ else:
+ parts = [list[0]] + [_n_item(i) for i in list[1:]] + ['enum']
+ return '_'.join(parts).lower()
def c_open(self):
'''
@@ -222,7 +236,7 @@ def c_enum(self, name):
'''
_h_setlevel(0)
_h('')
- _h('typedef enum %s {', _t(name))
+ _h('typedef enum %s {', _enum(name))
count = len(self.values)
@@ -232,7 +246,7 @@ def c_enum(self, name):
comma = ',' if count > 0 else ''
_h(' %s%s%s%s', _n(name + (enam,)).upper(), equals, eval, comma)
- _h('} %s;', _t(name))
+ _h('} %s;', _enum(name))
def _c_type_setup(self, name, postfix):
'''
--
1.6.1.3
--------------050104050302000400060302--
More information about the Xcb
mailing list