mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
Optionally weed out duplicate prototypes for the same function (which
happens because the scanner ignores preprocessor #ifs).
This commit is contained in:
parent
c1a4a04792
commit
27489d4c8c
3 changed files with 11 additions and 3 deletions
|
|
@ -67,6 +67,10 @@ class BaseFunctionGenerator:
|
||||||
def docstring(self):
|
def docstring(self):
|
||||||
return None
|
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',
|
_stringify_map = {'\n': '\\n', '\t': '\\t', '\r': '\\r', '\b': '\\b',
|
||||||
'\e': '\\e', '\a': '\\a', '\f': '\\f', '"': '\\"'}
|
'\e': '\\e', '\a': '\\a', '\f': '\\f', '"': '\\"'}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,11 @@ class GeneratorGroup:
|
||||||
self.prefix = prefix
|
self.prefix = prefix
|
||||||
self.generators = []
|
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)
|
g.setprefix(self.prefix)
|
||||||
self.generators.append(g)
|
self.generators.append(g)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,9 @@ class ObjectDefinition(GeneratorGroup):
|
||||||
self.static = "static " # set to "" to make <type>_New and <type>_Convert public
|
self.static = "static " # set to "" to make <type>_New and <type>_Convert public
|
||||||
self.basechain = "NULL" # set to &<basetype>_chain to chain methods
|
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)
|
g.setselftype(self.objecttype, self.itselftype)
|
||||||
GeneratorGroup.add(self, g)
|
GeneratorGroup.add(self, g, dupcheck)
|
||||||
|
|
||||||
def reference(self):
|
def reference(self):
|
||||||
# In case we are referenced from a module
|
# In case we are referenced from a module
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue