Commit 1df92c1f authored by Tom Niget's avatar Tom Niget

Fix error for initless classes

parent 88065e00
......@@ -124,11 +124,12 @@ class ModuleVisitorExt(NodeVisitor):
def visit_ClassDef(self, node: ast.ClassDef) -> Iterable[str]:
yield f"py::class_<PROGRAMNS::{node.name}_s::py_type>(m, \"{node.name}\")"
init = node.type.fields["__init__"].type.resolve().remove_self()
init_params = init.parameters
yield ".def(py::init<"
yield from join(", ", map(self.visit, init_params))
yield ">())"
if init := node.type.fields.get("__init__", None):
init = init.type.resolve().remove_self()
init_params = init.parameters
yield ".def(py::init<"
yield from join(", ", map(self.visit, init_params))
yield ">())"
yield f'.def("__repr__", [](const PROGRAMNS::{node.name}_s::py_type& self)'
yield "{ return repr(self); })"
for f, v in node.type.fields.items():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment