0

I have some C++ code wrapped using SWIG, and want to map a simple array of objects to a Python list. A much simplified example:

class Point {
  int x;
  int y;
};

class Polygon {
  Point *ptlist();
  int numPoints();
...
};

I want to be able to access ptlist() in Python as a sequence of Points, but can't find any obvious way of doing this using e.g. %extend or typemaps. Any help would be appreciated.

keith969
  • 93
  • 10
  • I wrote an answer that outlines a few approaches to this problem a while back: http://stackoverflow.com/a/8828454/168175 does that solve it for you? – Flexo Apr 08 '16 at 08:02
  • Thanks, the typemap example helped solve the problem. – keith969 Apr 09 '16 at 14:44
  • I've marked it as a duplicate then on that basis, but I'm more than happy to reopen this if you don't agree. – Flexo Apr 09 '16 at 15:03

0 Answers0