[Question] How do you deal with inheritance
mantielero opened this issue · comments
mantielero commented
I have the following inheritance tree:
where I have the following code:
csource "BRepBuilderAPI_Transform.hxx":
type
BRepBuilderAPI_Transform* = object of CClass
converter toTopoDS_Shape*(self: BRepBuilderAPI_Transform):TopoDS_Shape {.importcpp:"(#)".}
How would you call a method from BRepBuilderAPI_MakeShape
given than Nim doesn't have multiple inheritance?
Ryan Blonna commented
Multiple inheritance can be mimicked using converters + single inheritance + cexpr^
in most cases. converters + single inheritance takes care of implicit conversion between related types, and cexpr^
takes care of accessing inherited fields.
In the worst case scenario, you may have to write your own C++ to wrap functionality that can be translated to Nim via cinterop.
mantielero commented
Yes. I used cexpr^
and it simply worked. Thanks.