%module{Slic3r::XS}; %{ #include #include "Polyline.hpp" %} %name{Slic3r::Polyline} class Polyline { ~Polyline(); Polyline* clone() %code{% const char* CLASS = "Slic3r::Polyline"; RETVAL = new Polyline(*THIS); %}; SV* arrayref() %code{% RETVAL = THIS->to_SV(); %}; SV* pp() %code{% RETVAL = THIS->to_SV_pureperl(); %}; void pop_back() %code{% THIS->points.pop_back(); %}; void reverse(); Lines lines(); %{ Polyline* Polyline::new(...) CODE: RETVAL = new Polyline (); // ST(0) is class name, ST(1) is first point RETVAL->points.resize(items-1); for (unsigned int i = 1; i < items; i++) { RETVAL->points[i-1].from_SV_check( ST(i) ); } OUTPUT: RETVAL void Polyline::append(...) CODE: for (unsigned int i = 1; i < items; i++) { Point p; p.from_SV_check( ST(1) ); THIS->points.push_back(p); } %} };