summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Harris <pharris@opentext.com>2009-03-13 15:24:55 -0400
committerPeter Harris <peter.harris@hummingbird.com>2009-03-14 12:34:31 -0400
commiteaa71eac02c6a862ab23e8afcce12d9f38590338 (patch)
tree0277fb3885681a4958ec7434f26c2997f7495eee
parente986d1ee5a126dc38113125075a1e986235ba7c7 (diff)
Avoid name collisions between xidtype and enum.
These changes are necessary to build with latest xcb/proto. Signed-off-by: Peter Harris <pharris@opentext.com>
-rwxr-xr-xsrc/c_client.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/c_client.py b/src/c_client.py
index 73bd064..d86d05e 100755
--- a/src/c_client.py
+++ b/src/c_client.py
@@ -135,6 +135,9 @@ def c_open(self):
_ns = self.namespace
_ns.c_ext_global_name = _n(_ns.prefix + ('id',))
+ # Build the type-name collision avoidance table used by c_enum
+ build_collision_table()
+
_h_setlevel(0)
_c_setlevel(0)
@@ -216,13 +219,26 @@ def c_close(self):
cfile.write('\n')
cfile.close()
+def build_collision_table():
+ global namecount
+ namecount = {}
+
+ for v in module.types.values():
+ name = _t(v[0])
+ namecount[name] = (namecount.get(name) or 0) + 1
+
def c_enum(self, name):
'''
Exported function that handles enum declarations.
'''
+
+ tname = _t(name)
+ if namecount[tname] > 1:
+ tname = _t(name + ('enum',))
+
_h_setlevel(0)
_h('')
- _h('typedef enum %s {', _t(name))
+ _h('typedef enum %s {', tname)
count = len(self.values)
@@ -232,7 +248,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;', tname)
def _c_type_setup(self, name, postfix):
'''