mirror of https://github.com/YosysHQ/yosys.git
py_wrap_generator: Fix handling of method name collisions
If two methods have the same signature but for qualifiers the Python binding doesn't care about ('const'), do not generate a mangled name for the method. Fixes .def<Wire (Module::*)(const IdString* )>("wire__YOSYS_NAMESPACE_RTLIL_IdString", &Module::wire__YOSYS_NAMESPACE_RTLIL_IdString) .def<Cell (Module::*)(const IdString* )>("cell__YOSYS_NAMESPACE_RTLIL_IdString", &Module::cell__YOSYS_NAMESPACE_RTLIL_IdString) in the output after the previous change.
This commit is contained in:
parent
f94f544b50
commit
bd06338172
|
@ -1367,10 +1367,17 @@ class WFunction:
|
||||||
func.args.append(parsed)
|
func.args.append(parsed)
|
||||||
return func
|
return func
|
||||||
|
|
||||||
|
@property
|
||||||
|
def mangled_name(self):
|
||||||
|
mangled_typename = lambda code: code.replace("::", "_").replace("<","_").replace(">","_") \
|
||||||
|
.replace(" ","").replace("*","").replace(",","")
|
||||||
|
|
||||||
|
return self.name + "".join(
|
||||||
|
f"__{mangled_typename(arg.wtype.gen_text_cpp())}" for arg in self.args
|
||||||
|
)
|
||||||
|
|
||||||
def gen_alias(self):
|
def gen_alias(self):
|
||||||
self.alias = self.name
|
self.alias = self.mangled_name
|
||||||
for arg in self.args:
|
|
||||||
self.alias += "__" + arg.wtype.gen_text_cpp().replace("::", "_").replace("<","_").replace(">","_").replace(" ","").replace("*","").replace(",","")
|
|
||||||
|
|
||||||
def gen_decl(self):
|
def gen_decl(self):
|
||||||
if self.duplicate:
|
if self.duplicate:
|
||||||
|
@ -2196,12 +2203,15 @@ def clean_duplicates():
|
||||||
for fun in class_.found_funs:
|
for fun in class_.found_funs:
|
||||||
if fun.gen_decl_hash_py() in known_decls:
|
if fun.gen_decl_hash_py() in known_decls:
|
||||||
debug("Multiple declarations of " + fun.gen_decl_hash_py(),3)
|
debug("Multiple declarations of " + fun.gen_decl_hash_py(),3)
|
||||||
|
|
||||||
other = known_decls[fun.gen_decl_hash_py()]
|
other = known_decls[fun.gen_decl_hash_py()]
|
||||||
other.gen_alias()
|
if fun.mangled_name == other.mangled_name:
|
||||||
fun.gen_alias()
|
|
||||||
if fun.gen_decl_hash_py() == other.gen_decl_hash_py():
|
|
||||||
fun.duplicate = True
|
fun.duplicate = True
|
||||||
debug("Disabled \"" + fun.gen_decl_hash_py() + "\"", 3)
|
debug("Disabled \"" + fun.gen_decl_hash_py() + "\"", 3)
|
||||||
|
continue
|
||||||
|
|
||||||
|
other.gen_alias()
|
||||||
|
fun.gen_alias()
|
||||||
else:
|
else:
|
||||||
known_decls[fun.gen_decl_hash_py()] = fun
|
known_decls[fun.gen_decl_hash_py()] = fun
|
||||||
known_decls = []
|
known_decls = []
|
||||||
|
|
Loading…
Reference in New Issue