diff options
author | David Shah <davey1576@gmail.com> | 2018-07-02 15:29:58 +0200 |
---|---|---|
committer | David Shah <davey1576@gmail.com> | 2018-07-04 14:55:24 +0200 |
commit | 4bc12f2eadc2c369f38dfa54f086b8aa2c94fd05 (patch) | |
tree | b9d3662dcb014831fd202864663cbb52a55ba476 /ice40/pybindings.cc | |
parent | 65195513eb2676d974f1cef94be5e84f42a52f0f (diff) | |
download | nextpnr-4bc12f2eadc2c369f38dfa54f086b8aa2c94fd05.tar.gz nextpnr-4bc12f2eadc2c369f38dfa54f086b8aa2c94fd05.tar.bz2 nextpnr-4bc12f2eadc2c369f38dfa54f086b8aa2c94fd05.zip |
Progress on new wrapper system
Signed-off-by: David Shah <davey1576@gmail.com>
Diffstat (limited to 'ice40/pybindings.cc')
-rw-r--r-- | ice40/pybindings.cc | 72 |
1 files changed, 42 insertions, 30 deletions
diff --git a/ice40/pybindings.cc b/ice40/pybindings.cc index ea1c5547..3c86f10c 100644 --- a/ice40/pybindings.cc +++ b/ice40/pybindings.cc @@ -27,18 +27,24 @@ NEXTPNR_NAMESPACE_BEGIN namespace PythonConversion { -template <> struct string_converter<BelId> +template<> +struct string_converter<BelId> { - BelId from_str(Context *ctx, std::string name) { return ctx->getBelByName(ctx->id(name)); } + BelId from_str(Context *ctx, std::string name) + { return ctx->getBelByName(ctx->id(name)); } - std::string to_str(Context *ctx, BelId id) { return ctx->getBelName(id).str(ctx); } + std::string to_str(Context *ctx, BelId id) + { return ctx->getBelName(id).str(ctx); } }; -template <> struct string_converter<BelType> +template<> +struct string_converter<BelType> { - BelType from_str(Context *ctx, std::string name) { return ctx->belTypeFromId(ctx->id(name)); } + BelType from_str(Context *ctx, std::string name) + { return ctx->belTypeFromId(ctx->id(name)); } - std::string to_str(Context *ctx, BelType typ) { return ctx->belTypeToId(typ).str(ctx); } + std::string to_str(Context *ctx, BelType typ) + { return ctx->belTypeToId(typ).str(ctx); } }; } // namespace PythonConversion @@ -68,34 +74,40 @@ void arch_wrap_python() enum_<PortPin>("PortPin") #define X(t) .value("PIN_" #t, PIN_##t) + #include "portpins.inc" ; #undef X - auto arch_cls = class_<Arch, Arch *, bases<BaseCtx>, boost::noncopyable>("Arch", init<ArchArgs>()) - .def("getBelByName", &Arch::getBelByName) - .def("getWireByName", &Arch::getWireByName) - .def("getBelName", &Arch::getBelName) - .def("getWireName", &Arch::getWireName) - .def("getBels", &Arch::getBels) - .def("getWireBelPin", &Arch::getWireBelPin) - .def("getBelPinUphill", &Arch::getBelPinUphill) - .def("getBelPinsDownhill", &Arch::getBelPinsDownhill) - .def("getWires", &Arch::getWires) - .def("getPipByName", &Arch::getPipByName) - .def("getPipName", &Arch::getPipName) - .def("getPips", &Arch::getPips) - .def("getPipSrcWire", &Arch::getPipSrcWire) - .def("getPipDstWire", &Arch::getPipDstWire) - .def("getPipDelay", &Arch::getPipDelay) - .def("getPipsDownhill", &Arch::getPipsDownhill) - .def("getPipsUphill", &Arch::getPipsUphill) - .def("getWireAliases", &Arch::getWireAliases) - .def("estimatePosition", &Arch::estimatePosition) - .def("estimateDelay", &Arch::estimateDelay); - - /*fn_wrapper<Arch, typeof(&Arch::getBelType), &Arch::getBelType, conv_from_str<BelId>, - conv_to_str<BelType>>::def_wrap(arch_cls, "getBelType");*/ + 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).def("checksum", + &Context::checksum); + fn_wrapper<Context, typeof(&Context::getBelType), &Context::getBelType, conv_to_str<BelType>, + conv_from_str<BelId>>::def_wrap(ctx_cls, "getBelType"); + + /* + .def("getBelByName", &Arch::getBelByName) + .def("getWireByName", &Arch::getWireByName) + .def("getBelName", &Arch::getBelName) + .def("getWireName", &Arch::getWireName) + .def("getBels", &Arch::getBels) + .def("getWireBelPin", &Arch::getWireBelPin) + .def("getBelPinUphill", &Arch::getBelPinUphill) + .def("getBelPinsDownhill", &Arch::getBelPinsDownhill) + .def("getWires", &Arch::getWires) + .def("getPipByName", &Arch::getPipByName) + .def("getPipName", &Arch::getPipName) + .def("getPips", &Arch::getPips) + .def("getPipSrcWire", &Arch::getPipSrcWire) + .def("getPipDstWire", &Arch::getPipDstWire) + .def("getPipDelay", &Arch::getPipDelay) + .def("getPipsDownhill", &Arch::getPipsDownhill) + .def("getPipsUphill", &Arch::getPipsUphill) + .def("getWireAliases", &Arch::getWireAliases) + .def("estimatePosition", &Arch::estimatePosition) + .def("estimateDelay", &Arch::estimateDelay); + */ + WRAP_RANGE(Bel); WRAP_RANGE(BelPin); |