diff options
author | Miodrag Milanovic <mmicko@gmail.com> | 2020-07-23 18:35:18 +0200 |
---|---|---|
committer | Miodrag Milanovic <mmicko@gmail.com> | 2020-07-23 18:35:18 +0200 |
commit | 8f2b707d026597018333ac60e707e5ab78c25a91 (patch) | |
tree | ebf5c6490a56269d674a5d1d5357c7b5e2210872 /ecp5 | |
parent | 444e535f000fd7b53dadf6726d5cd29ac34cc75f (diff) | |
download | nextpnr-8f2b707d026597018333ac60e707e5ab78c25a91.tar.gz nextpnr-8f2b707d026597018333ac60e707e5ab78c25a91.tar.bz2 nextpnr-8f2b707d026597018333ac60e707e5ab78c25a91.zip |
Initial conversion to pybind11
Diffstat (limited to 'ecp5')
-rw-r--r-- | ecp5/arch_pybindings.cc | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/ecp5/arch_pybindings.cc b/ecp5/arch_pybindings.cc index 951745af..b8e48ccf 100644 --- a/ecp5/arch_pybindings.cc +++ b/ecp5/arch_pybindings.cc @@ -26,21 +26,19 @@ NEXTPNR_NAMESPACE_BEGIN -void arch_wrap_python() +void arch_wrap_python(py::module &m) { using namespace PythonConversion; - class_<ArchArgs>("ArchArgs").def_readwrite("type", &ArchArgs::type); + py::class_<ArchArgs>(m, "ArchArgs").def_readwrite("type", &ArchArgs::type); - class_<BelId>("BelId").def_readwrite("index", &BelId::index); + py::class_<BelId>(m, "BelId").def_readwrite("index", &BelId::index); - class_<WireId>("WireId").def_readwrite("index", &WireId::index); + py::class_<WireId>(m, "WireId").def_readwrite("index", &WireId::index); - class_<PipId>("PipId").def_readwrite("index", &PipId::index); + py::class_<PipId>(m, "PipId").def_readwrite("index", &PipId::index); - class_<BelPin>("BelPin").def_readwrite("bel", &BelPin::bel).def_readwrite("pin", &BelPin::pin); - - auto arch_cls = class_<Arch, Arch *, bases<BaseCtx>, boost::noncopyable>("Arch", init<ArchArgs>()); - auto ctx_cls = class_<Context, Context *, bases<Arch>, boost::noncopyable>("Context", no_init) + auto arch_cls = py::class_<Arch, BaseCtx>(m, "Arch").def(py::init<ArchArgs>()); + auto ctx_cls = py::class_<Context, Arch>(m, "Context") .def("checksum", &Context::checksum) .def("pack", &Context::pack) .def("place", &Context::place) @@ -54,21 +52,21 @@ void arch_wrap_python() typedef std::unordered_map<IdString, IdString> AliasMap; typedef std::unordered_map<IdString, HierarchicalCell> HierarchyMap; - auto belpin_cls = class_<ContextualWrapper<BelPin>>("BelPin", no_init); + auto belpin_cls = py::class_<ContextualWrapper<BelPin>>(m, "BelPin"); readonly_wrapper<BelPin, decltype(&BelPin::bel), &BelPin::bel, conv_to_str<BelId>>::def_wrap(belpin_cls, "bel"); readonly_wrapper<BelPin, decltype(&BelPin::pin), &BelPin::pin, conv_to_str<IdString>>::def_wrap(belpin_cls, "pin"); #include "arch_pybindings_shared.h" - WRAP_RANGE(Bel, conv_to_str<BelId>); - WRAP_RANGE(Wire, conv_to_str<WireId>); - WRAP_RANGE(AllPip, conv_to_str<PipId>); - WRAP_RANGE(Pip, conv_to_str<PipId>); - WRAP_RANGE(BelPin, wrap_context<BelPin>); + WRAP_RANGE(m, Bel, conv_to_str<BelId>); + WRAP_RANGE(m, Wire, conv_to_str<WireId>); + WRAP_RANGE(m, AllPip, conv_to_str<PipId>); + WRAP_RANGE(m, Pip, conv_to_str<PipId>); + WRAP_RANGE(m, BelPin, wrap_context<BelPin>); - WRAP_MAP_UPTR(CellMap, "IdCellMap"); - WRAP_MAP_UPTR(NetMap, "IdNetMap"); - WRAP_MAP(HierarchyMap, wrap_context<HierarchicalCell &>, "HierarchyMap"); + WRAP_MAP_UPTR(m, CellMap, "IdCellMap"); + WRAP_MAP_UPTR(m, NetMap, "IdNetMap"); + WRAP_MAP(m, HierarchyMap, wrap_context<HierarchicalCell &>, "HierarchyMap"); } NEXTPNR_NAMESPACE_END |