Fix the python generator for a bunch of const cases

Makes the below show up in the binding.

    .def<const char * (IdString::*)(void)>("c_str", &IdString::c_str)

    .def<boost::python::list (SigSpec::*)(void)>("chunks", &SigSpec::chunks)
    .def<boost::python::list (SigSpec::*)(void)>("bits", &SigSpec::bits)
    .def<SigBit (SigSpec::*)(int, const SigBit* )>("at", &SigSpec::at)

    .def<SigSpec (Cell::*)(const IdString* )>("getPort", &Cell::getPort)
    .def<boost::python::dict (Cell::*)(void)>("connections", &Cell::connections)
    .def<Const (Cell::*)(const IdString* )>("getParam", &Cell::getParam)

    .def<boost::python::list (Module::*)(void)>("connections", &Module::connections)

    def<const char * (*)(const SigSpec* )>("log_signal", YOSYS_PYTHON::log_signal);
    def<const char * (*)(const SigSpec* , bool)>("log_signal", YOSYS_PYTHON::log_signal);
    def<const char * (*)(const Const* )>("log_const", YOSYS_PYTHON::log_const);
    def<const char * (*)(const Const* , bool)>("log_const", YOSYS_PYTHON::log_const);
    def<const char * (*)(const IdString* )>("log_id", YOSYS_PYTHON::log_id);
This commit is contained in:
Martin Povišer 2023-04-05 12:36:56 +02:00
parent 53c0a6b780
commit f94f544b50
1 changed files with 8 additions and 2 deletions

View File

@ -178,6 +178,8 @@ class WType:
t.cont = None
t.attr_type = attr_types.default
if str_def.find("<") != -1:# and str_def.find("<") < str_def.find(" "):
str_def = str_def.replace("const ", "")
candidate = WContainer.from_string(str_def, containing_file, line_number)
if candidate == None:
return None
@ -203,8 +205,12 @@ class WType:
prefix = ""
if str.startswith(str_def, "const "):
if "char_p" in str_def:
prefix = "const "
str_def = str_def[6:]
if str.startswith(str_def, "unsigned "):
prefix = "unsigned "
prefix = "unsigned " + prefix
str_def = str_def[9:]
while str.startswith(str_def, "long "):
prefix= "long " + prefix
@ -1285,7 +1291,7 @@ class WFunction:
prefix = ""
i = 0
for part in parts:
if part in ["unsigned", "long", "short"]:
if part in ["unsigned", "long", "short", "const"]:
prefix += part + " "
i += 1
else: