diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2000-12-12 22:24:35 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2000-12-12 22:24:35 (GMT) |
commit | 27489d4c8ce63f1ee6b5079b6e48318a03f6f7ce (patch) | |
tree | e911ae6262fff22678144368169c748273ce6fc7 | |
parent | c1a4a04792456bc5e958337f8d18b805918040b3 (diff) | |
download | cpython-27489d4c8ce63f1ee6b5079b6e48318a03f6f7ce.zip cpython-27489d4c8ce63f1ee6b5079b6e48318a03f6f7ce.tar.gz cpython-27489d4c8ce63f1ee6b5079b6e48318a03f6f7ce.tar.bz2 |
Optionally weed out duplicate prototypes for the same function (which
happens because the scanner ignores preprocessor #ifs).
-rw-r--r-- | Tools/bgen/bgen/bgenGenerator.py | 4 | ||||
-rw-r--r-- | Tools/bgen/bgen/bgenGeneratorGroup.py | 6 | ||||
-rw-r--r-- | Tools/bgen/bgen/bgenObjectDefinition.py | 4 |
3 files changed, 11 insertions, 3 deletions
diff --git a/Tools/bgen/bgen/bgenGenerator.py b/Tools/bgen/bgen/bgenGenerator.py index 2c0a399..bf81096 100644 --- a/Tools/bgen/bgen/bgenGenerator.py +++ b/Tools/bgen/bgen/bgenGenerator.py @@ -67,6 +67,10 @@ class BaseFunctionGenerator: def docstring(self): return None + def __cmp__(self, other): + if not hasattr(other, 'name'): + return cmp(id(self), id(other)) + return cmp(self.name, other.name) _stringify_map = {'\n': '\\n', '\t': '\\t', '\r': '\\r', '\b': '\\b', '\e': '\\e', '\a': '\\a', '\f': '\\f', '"': '\\"'} diff --git a/Tools/bgen/bgen/bgenGeneratorGroup.py b/Tools/bgen/bgen/bgenGeneratorGroup.py index 294828f..5a62905 100644 --- a/Tools/bgen/bgen/bgenGeneratorGroup.py +++ b/Tools/bgen/bgen/bgenGeneratorGroup.py @@ -6,7 +6,11 @@ class GeneratorGroup: self.prefix = prefix self.generators = [] - def add(self, g): + def add(self, g, dupcheck=0): + if dupcheck: + if g in self.generators: + print 'DUP', g.name + return g.setprefix(self.prefix) self.generators.append(g) diff --git a/Tools/bgen/bgen/bgenObjectDefinition.py b/Tools/bgen/bgen/bgenObjectDefinition.py index d554f2f..f3d120c 100644 --- a/Tools/bgen/bgen/bgenObjectDefinition.py +++ b/Tools/bgen/bgen/bgenObjectDefinition.py @@ -23,9 +23,9 @@ class ObjectDefinition(GeneratorGroup): self.static = "static " # set to "" to make <type>_New and <type>_Convert public self.basechain = "NULL" # set to &<basetype>_chain to chain methods - def add(self, g): + def add(self, g, dupcheck=0): g.setselftype(self.objecttype, self.itselftype) - GeneratorGroup.add(self, g) + GeneratorGroup.add(self, g, dupcheck) def reference(self): # In case we are referenced from a module |