PrusaSlicer-NonPlainar/xs/xsp/Geometry.xsp
Petr Ledvina 115aa6885f Implement type checking for XS objects
Type handling is mainly done using templates.
Template Slic3r::ClassTraits is used to store info about exported types (perl class name). Currently only perl class name and refference name is used.
Template values are initialized by REGISTER_CLASS macro. This macro is used in .cpp file of class ( it needs to be used exactly for each type).

Ref<type> class is used to return value as perl reference. Operator overloading is used to make c++ and XSpp happy, only pointer value should be possible to return.

Clone<type> class is used to return copy of value ( using new and copy constructor). Copy is created on assigment, this should be probably improved (memory leak on multiple assignments).
It is overloaded to be able to return type, type* and type&.

Typechecking in ExtrusionEntityCollection updated to check all passed types.
2014-04-27 19:38:56 +02:00

40 lines
683 B
Plaintext

%module{Slic3r::XS};
%{
#include <myinit.h>
#include "Geometry.hpp"
%}
%package{Slic3r::Geometry};
%{
Polygon*
convex_hull(points)
Points points
CODE:
RETVAL = new Polygon ();
Slic3r::Geometry::convex_hull(points, RETVAL);
OUTPUT:
RETVAL
std::vector<Points::size_type>
chained_path(points)
Points points
CODE:
Slic3r::Geometry::chained_path(points, RETVAL);
OUTPUT:
RETVAL
std::vector<Points::size_type>
chained_path_from(points, start_from)
Points points
Point* start_from
CODE:
Slic3r::Geometry::chained_path(points, RETVAL, *start_from);
OUTPUT:
RETVAL
%}