PrusaSlicer-NonPlainar/xs/xsp/ExPolygon.xsp
Alessandro Ranellucci 21816acbd7 Merge branch 'master' into xsdata
Conflicts:
	xs/xsp/ExPolygon.xsp
2013-07-07 16:53:58 +02:00

55 lines
1.1 KiB
Plaintext

%module{Slic3r::XS};
%{
#include <myinit.h>
#include "ExPolygon.hpp"
%}
%name{Slic3r::ExPolygon::XS} class ExPolygon {
%name{_clone} ExPolygon(ExPolygon& self);
~ExPolygon();
%{
ExPolygon*
ExPolygon::new(...)
CODE:
RETVAL = new ExPolygon ();
// ST(0) is class name, ST(1) is contour and others are holes
perl2polygon(ST(1), RETVAL->contour);
RETVAL->holes.resize(items-2);
for (unsigned int i = 2; i < items; i++) {
perl2polygon(ST(i), RETVAL->holes[i-2]);
}
OUTPUT:
RETVAL
SV*
ExPolygon::arrayref()
CODE:
const unsigned int num_holes = THIS->holes.size();
AV* av = newAV();
av_fill(av, num_holes); // -1 +1
av_store(av, 0, polygon2perl(THIS->contour));
for (unsigned int i = 0; i < num_holes; i++) {
av_store(av, i+1, polygon2perl(THIS->holes[i]));
}
RETVAL = sv_bless(newRV_noinc((SV*)av), gv_stashpv("Slic3r::ExPolygon", GV_ADD));
OUTPUT:
RETVAL
%}
};
%package{Slic3r::ExPolygon::XS};
%{
PROTOTYPES: DISABLE
std::string
hello_world()
CODE:
RETVAL = "Hello world!";
OUTPUT:
RETVAL
%}