3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-10-09 17:31:59 +00:00

pyosys: fix ref-only classes, implicit conversions

+ cleanup
This commit is contained in:
Mohamed Gaber 2025-09-28 05:50:37 +03:00
parent c8404bf86b
commit 80fcce64da
No known key found for this signature in database
7 changed files with 122 additions and 67 deletions

View file

@ -21,7 +21,6 @@
// <!-- generated includes -->
#include <pybind11/pybind11.h>
#include <pybind11/native_enum.h>
#include "pyosys/hashlib.h"
namespace py = pybind11;
@ -35,7 +34,7 @@ using namespace RTLIL;
#include "wrappers.inc.cc"
namespace YOSYS_PYTHON {
namespace pyosys {
struct Globals {};
// Trampolines for Classes with Python-Overridable Virtual Methods
@ -160,12 +159,6 @@ namespace YOSYS_PYTHON {
}
};
/// @brief Use an auxiliary function to adapt the legacy function.
void log_to_stream(py::object object)
{
// TODO
};
PYBIND11_MODULE(libyosys, m) {
// this code is run on import
m.doc() = "python access to libyosys";
@ -195,9 +188,9 @@ namespace YOSYS_PYTHON {
auto global_variables = py::class_<Globals>(m, "Globals");
// Trampoline Classes
py::class_<Pass, YOSYS_PYTHON::PassTrampoline, std::unique_ptr<Pass, py::nodelete>>(m, "Pass")
py::class_<Pass, pyosys::PassTrampoline, std::unique_ptr<Pass, py::nodelete>>(m, "Pass")
.def(py::init([](std::string name, std::string short_help) {
auto created = new YOSYS_PYTHON::PassTrampoline(name, short_help);
auto created = new pyosys::PassTrampoline(name, short_help);
Pass::init_register();
return created;
}), py::arg("name"), py::arg("short_help"))
@ -219,9 +212,9 @@ namespace YOSYS_PYTHON {
.def("call", py::overload_cast<RTLIL::Design *,std::vector<std::string>>(&Pass::call))
;
py::class_<RTLIL::Monitor, YOSYS_PYTHON::MonitorTrampoline>(m, "Monitor")
py::class_<RTLIL::Monitor, pyosys::MonitorTrampoline>(m, "Monitor")
.def(py::init([]() {
return new YOSYS_PYTHON::MonitorTrampoline();
return new pyosys::MonitorTrampoline();
}))
.def("notify_module_add", &RTLIL::Monitor::notify_module_add)
.def("notify_module_del", &RTLIL::Monitor::notify_module_del)
@ -255,6 +248,9 @@ namespace YOSYS_PYTHON {
bind_autogenerated_opaque_containers(m);
// <!-- generated pymod-level code -->
py::implicitly_convertible<std::string, RTLIL::IdString>();
py::implicitly_convertible<const char *, RTLIL::IdString>();
};
};