From 8f2b707d026597018333ac60e707e5ab78c25a91 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Thu, 23 Jul 2020 18:35:18 +0200 Subject: Initial conversion to pybind11 --- ecp5/arch_pybindings.cc | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'ecp5') 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").def_readwrite("type", &ArchArgs::type); + py::class_(m, "ArchArgs").def_readwrite("type", &ArchArgs::type); - class_("BelId").def_readwrite("index", &BelId::index); + py::class_(m, "BelId").def_readwrite("index", &BelId::index); - class_("WireId").def_readwrite("index", &WireId::index); + py::class_(m, "WireId").def_readwrite("index", &WireId::index); - class_("PipId").def_readwrite("index", &PipId::index); + py::class_(m, "PipId").def_readwrite("index", &PipId::index); - class_("BelPin").def_readwrite("bel", &BelPin::bel).def_readwrite("pin", &BelPin::pin); - - auto arch_cls = class_, boost::noncopyable>("Arch", init()); - auto ctx_cls = class_, boost::noncopyable>("Context", no_init) + auto arch_cls = py::class_(m, "Arch").def(py::init()); + auto ctx_cls = py::class_(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 AliasMap; typedef std::unordered_map HierarchyMap; - auto belpin_cls = class_>("BelPin", no_init); + auto belpin_cls = py::class_>(m, "BelPin"); readonly_wrapper>::def_wrap(belpin_cls, "bel"); readonly_wrapper>::def_wrap(belpin_cls, "pin"); #include "arch_pybindings_shared.h" - WRAP_RANGE(Bel, conv_to_str); - WRAP_RANGE(Wire, conv_to_str); - WRAP_RANGE(AllPip, conv_to_str); - WRAP_RANGE(Pip, conv_to_str); - WRAP_RANGE(BelPin, wrap_context); + WRAP_RANGE(m, Bel, conv_to_str); + WRAP_RANGE(m, Wire, conv_to_str); + WRAP_RANGE(m, AllPip, conv_to_str); + WRAP_RANGE(m, Pip, conv_to_str); + WRAP_RANGE(m, BelPin, wrap_context); - WRAP_MAP_UPTR(CellMap, "IdCellMap"); - WRAP_MAP_UPTR(NetMap, "IdNetMap"); - WRAP_MAP(HierarchyMap, wrap_context, "HierarchyMap"); + WRAP_MAP_UPTR(m, CellMap, "IdCellMap"); + WRAP_MAP_UPTR(m, NetMap, "IdNetMap"); + WRAP_MAP(m, HierarchyMap, wrap_context, "HierarchyMap"); } NEXTPNR_NAMESPACE_END -- cgit v1.2.3