aboutsummaryrefslogtreecommitdiffstats
path: root/ecp5/arch_pybindings.h
diff options
context:
space:
mode:
Diffstat (limited to 'ecp5/arch_pybindings.h')
-rw-r--r--ecp5/arch_pybindings.h26
1 files changed, 24 insertions, 2 deletions
diff --git a/ecp5/arch_pybindings.h b/ecp5/arch_pybindings.h
index f18b5ff1..9bd7bcdf 100644
--- a/ecp5/arch_pybindings.h
+++ b/ecp5/arch_pybindings.h
@@ -44,14 +44,36 @@ template <> struct string_converter<WireId>
{
WireId from_str(Context *ctx, std::string name) { return ctx->getWireByName(ctx->id(name)); }
- std::string to_str(Context *ctx, WireId id) { return ctx->getWireName(id).str(ctx); }
+ std::string to_str(Context *ctx, WireId id)
+ {
+ if (id == WireId())
+ throw bad_wrap();
+ return ctx->getWireName(id).str(ctx);
+ }
+};
+
+template <> struct string_converter<const WireId>
+{
+ WireId from_str(Context *ctx, std::string name) { return ctx->getWireByName(ctx->id(name)); }
+
+ std::string to_str(Context *ctx, WireId id)
+ {
+ if (id == WireId())
+ throw bad_wrap();
+ return ctx->getWireName(id).str(ctx);
+ }
};
template <> struct string_converter<PipId>
{
PipId from_str(Context *ctx, std::string name) { return ctx->getPipByName(ctx->id(name)); }
- std::string to_str(Context *ctx, PipId id) { return ctx->getPipName(id).str(ctx); }
+ std::string to_str(Context *ctx, PipId id)
+ {
+ if (id == PipId())
+ throw bad_wrap();
+ return ctx->getPipName(id).str(ctx);
+ }
};
} // namespace PythonConversion