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.
This commit is contained in:
Petr Ledvina 2014-04-27 19:18:53 +02:00
parent e68b6b6f4c
commit 115aa6885f
35 changed files with 426 additions and 173 deletions

View file

@ -4,26 +4,23 @@
#include <myinit.h>
#include "BoundingBox.hpp"
#include "Point.hpp"
#include "perlglue.hpp"
%}
%name{Slic3r::Geometry::BoundingBox} class BoundingBox {
~BoundingBox();
BoundingBox* clone()
%code{% const char* CLASS = "Slic3r::Geometry::BoundingBox"; RETVAL = new BoundingBox(*THIS); %};
Clone<BoundingBox> clone()
%code{% RETVAL = THIS; %};
void merge(BoundingBox* bb) %code{% THIS->merge(*bb); %};
void merge_point(Point* point) %code{% THIS->merge(*point); %};
void scale(double factor);
void translate(double x, double y);
Polygon* polygon()
%code{% const char* CLASS = "Slic3r::Polygon"; RETVAL = new Polygon(); THIS->polygon(RETVAL); %};
Point* size()
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = new Point(THIS->size()); %};
Point* center()
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = new Point(THIS->center()); %};
Point* min_point()
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = new Point(THIS->min); %};
Point* max_point()
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = new Point(THIS->max); %};
%code{% RETVAL = new Polygon(); THIS->polygon(RETVAL); %};
Clone<Point> size();
Clone<Point> center();
Clone<Point> min_point() %code{% RETVAL = THIS->min; %};
Clone<Point> max_point() %code{% RETVAL = THIS->max; %};
double x_min() %code{% RETVAL = THIS->min.x; %};
double x_max() %code{% RETVAL = THIS->max.x; %};
double y_min() %code{% RETVAL = THIS->min.y; %};
@ -45,15 +42,13 @@ new_from_points(CLASS, points)
%name{Slic3r::Geometry::BoundingBoxf3} class BoundingBoxf3 {
~BoundingBoxf3();
BoundingBoxf3* clone()
%code{% const char* CLASS = "Slic3r::Geometry::BoundingBoxf3"; RETVAL = new BoundingBoxf3(*THIS); %};
Clone<BoundingBoxf3> clone()
%code{% RETVAL = THIS; %};
void merge(BoundingBoxf3* bb) %code{% THIS->merge(*bb); %};
void scale(double factor);
void translate(double x, double y, double z);
Pointf3* size()
%code{% const char* CLASS = "Slic3r::Pointf3"; RETVAL = new Pointf3(THIS->size()); %};
Pointf3* center()
%code{% const char* CLASS = "Slic3r::Pointf3"; RETVAL = new Pointf3(THIS->center()); %};
Clone<Pointf3> size();
Clone<Pointf3> center();
double x_min() %code{% RETVAL = THIS->min.x; %};
double x_max() %code{% RETVAL = THIS->max.x; %};
double y_min() %code{% RETVAL = THIS->min.y; %};

View file

@ -3,18 +3,19 @@
%{
#include <myinit.h>
#include "ExPolygon.hpp"
#include "perlglue.hpp"
%}
%name{Slic3r::ExPolygon} class ExPolygon {
~ExPolygon();
ExPolygon* clone()
%code{% const char* CLASS = "Slic3r::ExPolygon"; RETVAL = new ExPolygon(*THIS); %};
Clone<ExPolygon> clone()
%code{% RETVAL = THIS; %};
SV* arrayref()
%code{% RETVAL = THIS->to_AV(); %};
SV* pp()
%code{% RETVAL = THIS->to_SV_pureperl(); %};
Polygon* contour()
%code{% const char* CLASS = "Slic3r::Polygon::Ref"; RETVAL = &(THIS->contour); %};
Ref<Polygon> contour()
%code{% RETVAL = &(THIS->contour); %};
Polygons* holes()
%code{% RETVAL = &(THIS->holes); %};
void scale(double factor);

View file

@ -3,12 +3,13 @@
%{
#include <myinit.h>
#include "ExPolygonCollection.hpp"
#include "perlglue.hpp"
%}
%name{Slic3r::ExPolygon::Collection} class ExPolygonCollection {
~ExPolygonCollection();
ExPolygonCollection* clone()
%code{% const char* CLASS = "Slic3r::ExPolygon::Collection"; RETVAL = new ExPolygonCollection(*THIS); %};
Clone<ExPolygonCollection> clone()
%code{% RETVAL = THIS; %};
void clear()
%code{% THIS->expolygons.clear(); %};
void scale(double factor);
@ -72,8 +73,6 @@ ExPolygonCollection::append(...)
Polygon*
ExPolygonCollection::convex_hull()
PREINIT:
const char* CLASS = "Slic3r::Polygon";
CODE:
RETVAL = new Polygon ();
THIS->convex_hull(RETVAL);

View file

@ -3,6 +3,7 @@
%{
#include <myinit.h>
#include "ExtrusionEntityCollection.hpp"
#include "perlglue.hpp"
%}
%name{Slic3r::ExtrusionPath::Collection} class ExtrusionEntityCollection {
@ -12,20 +13,16 @@
%code{% THIS->entities.clear(); %};
ExtrusionEntityCollection* chained_path(bool no_reverse)
%code{%
const char* CLASS = "Slic3r::ExtrusionPath::Collection";
RETVAL = new ExtrusionEntityCollection();
THIS->chained_path(RETVAL, no_reverse);
%};
ExtrusionEntityCollection* chained_path_from(Point* start_near, bool no_reverse)
%code{%
const char* CLASS = "Slic3r::ExtrusionPath::Collection";
RETVAL = new ExtrusionEntityCollection();
THIS->chained_path_from(*start_near, RETVAL, no_reverse);
%};
Point* first_point()
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = new Point(THIS->first_point()); %};
Point* last_point()
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = new Point(THIS->last_point()); %};
Clone<Point> first_point();
Clone<Point> last_point();
int count()
%code{% RETVAL = THIS->entities.size(); %};
std::vector<size_t> orig_indices()
@ -50,11 +47,13 @@ ExtrusionEntityCollection::arrayref()
SV* sv = newSV(0);
// return our item by reference
if (ExtrusionPath* path = dynamic_cast<ExtrusionPath*>(*it)) {
sv_setref_pv( sv, "Slic3r::ExtrusionPath::Ref", path );
sv_setref_pv( sv, perl_class_name_ref(path), path );
} else if (ExtrusionLoop* loop = dynamic_cast<ExtrusionLoop*>(*it)) {
sv_setref_pv( sv, "Slic3r::ExtrusionLoop::Ref", loop );
sv_setref_pv( sv, perl_class_name_ref(loop), loop );
} else if (ExtrusionEntityCollection* collection = dynamic_cast<ExtrusionEntityCollection*>(*it)) {
sv_setref_pv( sv, perl_class_name_ref(collection), collection );
} else {
sv_setref_pv( sv, "Slic3r::ExtrusionPath::Collection::Ref", *it );
croak("Unexpected type in ExtrusionEntityCollection");
}
av_store(av, i++, sv);
}
@ -66,14 +65,19 @@ void
ExtrusionEntityCollection::append(...)
CODE:
for (unsigned int i = 1; i < items; i++) {
if(!sv_isobject( ST(i) ) || (SvTYPE(SvRV( ST(i) )) != SVt_PVMG)) {
croak("Argument %d is not object", i);
}
ExtrusionEntity* entity = (ExtrusionEntity *)SvIV((SV*)SvRV( ST(i) ));
// append COPIES
if (ExtrusionPath* path = dynamic_cast<ExtrusionPath*>(entity)) {
THIS->entities.push_back( new ExtrusionPath(*path) );
} else if (ExtrusionLoop* loop = dynamic_cast<ExtrusionLoop*>(entity)) {
THIS->entities.push_back( new ExtrusionLoop(*loop) );
} else if(ExtrusionEntityCollection* collection = dynamic_cast<ExtrusionEntityCollection*>(entity)) {
THIS->entities.push_back( collection->clone() );
} else {
THIS->entities.push_back( (*(ExtrusionEntityCollection*)entity).clone() );
croak("Argument %d is of unknown type", i);
}
}
@ -89,8 +93,6 @@ ExtrusionEntityCollection::no_sort(...)
ExtrusionEntityCollection*
ExtrusionEntityCollection::chained_path_indices(bool no_reverse)
PREINIT:
const char* CLASS = "Slic3r::ExtrusionPath::Collection";
CODE:
RETVAL = new ExtrusionEntityCollection();
THIS->chained_path(RETVAL, no_reverse, &RETVAL->orig_indices);

View file

@ -3,6 +3,7 @@
%{
#include <myinit.h>
#include "ExtrusionEntity.hpp"
#include "perlglue.hpp"
%}
%name{Slic3r::ExtrusionLoop} class ExtrusionLoop {
@ -13,15 +14,11 @@
%code{% RETVAL = THIS->polygon.to_SV_pureperl(); %};
void reverse()
%code{% THIS->polygon.reverse(); %};
ExtrusionPath* split_at_index(int index)
%code{% const char* CLASS = "Slic3r::ExtrusionPath"; RETVAL = THIS->split_at_index(index); %};
ExtrusionPath* split_at_first_point()
%code{% const char* CLASS = "Slic3r::ExtrusionPath"; RETVAL = THIS->split_at_first_point(); %};
ExtrusionPath* split_at_index(int index);
ExtrusionPath* split_at_first_point();
bool make_counter_clockwise();
Point* first_point()
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = new Point(THIS->first_point()); %};
Point* last_point()
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = new Point(THIS->last_point()); %};
Clone<Point> first_point();
Clone<Point> last_point();
bool is_perimeter();
bool is_fill();
bool is_bridge();
@ -41,10 +38,8 @@ _new(CLASS, polygon_sv, role, mm3_per_mm)
OUTPUT:
RETVAL
Polygon*
Ref<Polygon>
ExtrusionLoop::polygon(...)
PREINIT:
const char* CLASS = "Slic3r::Polygon::Ref";
CODE:
if (items > 1) {
THIS->polygon.from_SV_check( ST(1) );

View file

@ -17,10 +17,8 @@
void reverse();
Lines lines()
%code{% RETVAL = THIS->polyline.lines(); %};
Point* first_point()
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = new Point(THIS->first_point()); %};
Point* last_point()
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = new Point(THIS->last_point()); %};
Clone<Point> first_point();
Clone<Point> last_point();
void clip_end(double distance);
void simplify(double tolerance);
double length();
@ -46,10 +44,8 @@ _new(CLASS, polyline_sv, role, mm3_per_mm)
OUTPUT:
RETVAL
Polyline*
Ref<Polyline>
ExtrusionPath::polyline(...)
PREINIT:
const char* CLASS = "Slic3r::Polyline::Ref";
CODE:
if (items > 1) {
THIS->polyline.from_SV_check( ST(1) );
@ -89,8 +85,6 @@ ExtrusionPath::append(...)
ExtrusionEntityCollection*
ExtrusionPath::intersect_expolygons(ExPolygonCollection* collection)
PREINIT:
const char* CLASS = "Slic3r::ExtrusionPath::Collection";
CODE:
RETVAL = new ExtrusionEntityCollection ();
THIS->intersect_expolygons(*collection, RETVAL);
@ -99,8 +93,6 @@ ExtrusionPath::intersect_expolygons(ExPolygonCollection* collection)
ExtrusionEntityCollection*
ExtrusionPath::subtract_expolygons(ExPolygonCollection* collection)
PREINIT:
const char* CLASS = "Slic3r::ExtrusionPath::Collection";
CODE:
RETVAL = new ExtrusionEntityCollection ();
THIS->subtract_expolygons(*collection, RETVAL);

View file

@ -3,6 +3,7 @@
%{
#include <myinit.h>
#include "Flow.hpp"
#include "perlglue.hpp"
%}
%name{Slic3r::Flow} class Flow {
@ -10,8 +11,8 @@
%name{_new} Flow(float width, float spacing, float nozzle_diameter);
void set_bridge(bool bridge)
%code{% THIS->bridge = bridge; %};
Flow* clone()
%code{% const char* CLASS = "Slic3r::Flow"; RETVAL = new Flow(*THIS); %};
Clone<Flow> clone()
%code{% RETVAL = THIS; %};
float width()
%code{% RETVAL = THIS->width; %};

View file

@ -13,8 +13,6 @@
Polygon*
convex_hull(points)
Points points
PREINIT:
const char* CLASS = "Slic3r::Polygon";
CODE:
RETVAL = new Polygon ();
Slic3r::Geometry::convex_hull(points, RETVAL);

View file

@ -3,32 +3,31 @@
%{
#include <myinit.h>
#include "Line.hpp"
#include "perlglue.hpp"
%}
%name{Slic3r::Line} class Line {
~Line();
Line* clone()
%code{% const char* CLASS = "Slic3r::Line"; RETVAL = new Line(*THIS); %};
Clone<Line> clone()
%code{% RETVAL = THIS; %};
SV* arrayref()
%code{% RETVAL = THIS->to_AV(); %};
SV* pp()
%code{% RETVAL = THIS->to_SV_pureperl(); %};
Point* a()
%code{% const char* CLASS = "Slic3r::Point::Ref"; RETVAL = &(THIS->a); %};
Point* b()
%code{% const char* CLASS = "Slic3r::Point::Ref"; RETVAL = &(THIS->b); %};
Ref<Point> a()
%code{% RETVAL=&THIS->a; %};
Ref<Point> b()
%code{% RETVAL=&THIS->b; %};
void reverse();
void scale(double factor);
void translate(double x, double y);
double length();
double atan2_();
double direction();
Point* midpoint()
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = THIS->midpoint(); %};
Point* point_at(double distance)
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = new Point(THIS->point_at(distance)); %};
Point* midpoint();
Clone<Point> point_at(double distance);
Polyline* as_polyline()
%code{% const char* CLASS = "Slic3r::Polyline"; RETVAL = new Polyline(*THIS); %};
%code{% RETVAL = new Polyline(*THIS); %};
%{
Line*

View file

@ -3,13 +3,14 @@
%{
#include <myinit.h>
#include "Point.hpp"
#include "perlglue.hpp"
%}
%name{Slic3r::Point} class Point {
Point(long _x = 0, long _y = 0);
~Point();
Point* clone()
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = new Point(*THIS); %};
Clone<Point> clone()
%code{% RETVAL=THIS; %};
void scale(double factor);
void translate(double x, double y);
SV* arrayref()
@ -22,7 +23,7 @@
%code{% RETVAL = THIS->y; %};
int nearest_point_index(Points points);
Point* nearest_point(Points points)
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = new Point(); THIS->nearest_point(points, RETVAL); %};
%code{% RETVAL = new Point(); THIS->nearest_point(points, RETVAL); %};
double distance_to(Point* point)
%code{% RETVAL = THIS->distance_to(*point); %};
double distance_to_line(Line* line)
@ -58,8 +59,8 @@ Point::coincides_with(point_sv)
%name{Slic3r::Pointf3} class Pointf3 {
Pointf3(double _x = 0, double _y = 0, double _z = 0);
~Pointf3();
Pointf3* clone()
%code{% const char* CLASS = "Slic3r::Pointf3"; RETVAL = new Pointf3(*THIS); %};
Clone<Pointf3> clone()
%code{% RETVAL = THIS; %};
double x()
%code{% RETVAL = THIS->x; %};
double y()

View file

@ -3,12 +3,13 @@
%{
#include <myinit.h>
#include "Polygon.hpp"
#include "perlglue.hpp"
%}
%name{Slic3r::Polygon} class Polygon {
~Polygon();
Polygon* clone()
%code{% const char* CLASS = "Slic3r::Polygon"; RETVAL = new Polygon(*THIS); %};
Clone<Polygon> clone()
%code{% RETVAL = THIS; %};
SV* arrayref()
%code{% RETVAL = THIS->to_AV(); %};
SV* pp()
@ -18,11 +19,11 @@
void reverse();
Lines lines();
Polyline* split_at(Point* point)
%code{% const char* CLASS = "Slic3r::Polyline"; RETVAL = THIS->split_at(*point); %};
%code{% RETVAL = THIS->split_at(*point); %};
Polyline* split_at_index(int index)
%code{% const char* CLASS = "Slic3r::Polyline"; RETVAL = THIS->split_at_index(index); %};
%code{% RETVAL = THIS->split_at_index(index); %};
Polyline* split_at_first_point()
%code{% const char* CLASS = "Slic3r::Polyline"; RETVAL = THIS->split_at_first_point(); %};
%code{% RETVAL = THIS->split_at_first_point(); %};
Points equally_spaced_points(double distance);
double length();
double area();
@ -31,8 +32,7 @@
bool make_counter_clockwise();
bool make_clockwise();
bool is_valid();
Point* first_point()
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = new Point(THIS->first_point()); %};
Clone<Point> first_point();
bool contains_point(Point* point)
%code{% RETVAL = THIS->contains_point(*point); %};
Polygons simplify(double tolerance);

View file

@ -4,12 +4,13 @@
#include <myinit.h>
#include "ClipperUtils.hpp"
#include "Polyline.hpp"
#include "perlglue.hpp"
%}
%name{Slic3r::Polyline} class Polyline {
~Polyline();
Polyline* clone()
%code{% const char* CLASS = "Slic3r::Polyline"; RETVAL = new Polyline(*THIS); %};
Clone<Polyline> clone()
%code{% RETVAL = THIS; %};
SV* arrayref()
%code{% RETVAL = THIS->to_AV(); %};
SV* pp()
@ -20,10 +21,8 @@
%code{% THIS->points.pop_back(); %};
void reverse();
Lines lines();
Point* first_point()
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = new Point(THIS->first_point()); %};
Point* last_point()
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = new Point(THIS->last_point()); %};
Clone<Point> first_point();
Clone<Point> last_point();
Points equally_spaced_points(double distance);
double length();
bool is_valid();

View file

@ -3,30 +3,28 @@
%{
#include <myinit.h>
#include "PolylineCollection.hpp"
#include "perlglue.hpp"
%}
%name{Slic3r::Polyline::Collection} class PolylineCollection {
~PolylineCollection();
PolylineCollection* clone()
%code{% const char* CLASS = "Slic3r::Polyline::Collection"; RETVAL = new PolylineCollection(*THIS); %};
Clone<PolylineCollection> clone()
%code{% RETVAL = THIS; %};
void clear()
%code{% THIS->polylines.clear(); %};
PolylineCollection* chained_path(bool no_reverse)
%code{%
const char* CLASS = "Slic3r::Polyline::Collection";
RETVAL = new PolylineCollection();
THIS->chained_path(RETVAL, no_reverse);
%};
PolylineCollection* chained_path_from(Point* start_near, bool no_reverse)
%code{%
const char* CLASS = "Slic3r::Polyline::Collection";
RETVAL = new PolylineCollection();
THIS->chained_path_from(*start_near, RETVAL, no_reverse);
%};
int count()
%code{% RETVAL = THIS->polylines.size(); %};
Point* leftmost_point()
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = new Point(THIS->leftmost_point()); %};
Clone<Point> leftmost_point();
%{
PolylineCollection*

View file

@ -4,12 +4,13 @@
#include <myinit.h>
#include "Surface.hpp"
#include "ClipperUtils.hpp"
#include "perlglue.hpp"
%}
%name{Slic3r::Surface} class Surface {
~Surface();
ExPolygon* expolygon()
%code{% const char* CLASS = "Slic3r::ExPolygon::Ref"; RETVAL = &(THIS->expolygon); %};
Ref<ExPolygon> expolygon()
%code{% RETVAL = &(THIS->expolygon); %};
double thickness()
%code{% RETVAL = THIS->thickness; %};
unsigned short thickness_layers()

View file

@ -3,13 +3,14 @@
%{
#include <myinit.h>
#include "TriangleMesh.hpp"
#include "perlglue.hpp"
%}
%name{Slic3r::TriangleMesh} class TriangleMesh {
TriangleMesh();
~TriangleMesh();
TriangleMesh* clone()
%code{% const char* CLASS = "Slic3r::TriangleMesh"; RETVAL = new TriangleMesh(*THIS); %};
Clone<TriangleMesh> clone()
%code{% RETVAL = THIS; %};
void ReadSTLFile(char* input_file);
void write_ascii(char* output_file);
void write_binary(char* output_file);
@ -31,7 +32,6 @@
%code{% THIS->horizontal_projection(RETVAL); %};
BoundingBoxf3* bounding_box()
%code{%
const char* CLASS = "Slic3r::Geometry::BoundingBoxf3";
RETVAL = new BoundingBoxf3();
THIS->bounding_box(RETVAL);
%};
@ -189,8 +189,6 @@ TriangleMesh::bb3()
Polygon*
TriangleMesh::convex_hull()
PREINIT:
const char* CLASS = "Slic3r::Polygon";
CODE:
RETVAL = new Polygon ();
THIS->convex_hull(RETVAL);

View file

@ -2,30 +2,80 @@ std::vector<Points::size_type> T_STD_VECTOR_INT
std::vector<size_t> T_STD_VECTOR_INT
t_config_option_key T_STD_STRING
BoundingBox* O_OBJECT
BoundingBoxf3* O_OBJECT
DynamicPrintConfig* O_OBJECT
PrintObjectConfig* O_OBJECT
PrintRegionConfig* O_OBJECT
PrintConfig* O_OBJECT
FullPrintConfig* O_OBJECT
ZTable* O_OBJECT
TriangleMesh* O_OBJECT
Point* O_OBJECT
Pointf3* O_OBJECT
Line* O_OBJECT
Polyline* O_OBJECT
PolylineCollection* O_OBJECT
Polygon* O_OBJECT
ExPolygon* O_OBJECT
ExPolygonCollection* O_OBJECT
ExtrusionEntityCollection* O_OBJECT
ExtrusionPath* O_OBJECT
ExtrusionLoop* O_OBJECT
Flow* O_OBJECT
PrintState* O_OBJECT
Surface* O_OBJECT
SurfaceCollection* O_OBJECT
BoundingBox* O_OBJECT_SLIC3R
Ref<BoundingBox> O_OBJECT_SLIC3R_T
Clone<BoundingBox> O_OBJECT_SLIC3R_T
BoundingBoxf3* O_OBJECT_SLIC3R
Ref<BoundingBoxf3> O_OBJECT_SLIC3R_T
Clone<BoundingBoxf3> O_OBJECT_SLIC3R_T
DynamicPrintConfig* O_OBJECT_SLIC3R
PrintObjectConfig* O_OBJECT_SLIC3R
PrintRegionConfig* O_OBJECT_SLIC3R
PrintConfig* O_OBJECT_SLIC3R
FullPrintConfig* O_OBJECT_SLIC3R
ZTable* O_OBJECT
TriangleMesh* O_OBJECT_SLIC3R
Ref<TriangleMesh> O_OBJECT_SLIC3R_T
Clone<TriangleMesh> O_OBJECT_SLIC3R_T
Point* O_OBJECT_SLIC3R
Ref<Point> O_OBJECT_SLIC3R_T
Clone<Point> O_OBJECT_SLIC3R_T
Pointf3* O_OBJECT_SLIC3R
Ref<Pointf3> O_OBJECT_SLIC3R_T
Clone<Pointf3> O_OBJECT_SLIC3R_T
Line* O_OBJECT_SLIC3R
Ref<Line> O_OBJECT_SLIC3R_T
Clone<Line> O_OBJECT_SLIC3R_T
Polyline* O_OBJECT_SLIC3R
Ref<Polyline> O_OBJECT_SLIC3R_T
Clone<Polyline> O_OBJECT_SLIC3R_T
PolylineCollection* O_OBJECT_SLIC3R
Ref<PolylineCollection> O_OBJECT_SLIC3R_T
Clone<PolylineCollection> O_OBJECT_SLIC3R_T
Polygon* O_OBJECT_SLIC3R
Ref<Polygon> O_OBJECT_SLIC3R_T
Clone<Polygon> O_OBJECT_SLIC3R_T
ExPolygon* O_OBJECT_SLIC3R
Ref<ExPolygon> O_OBJECT_SLIC3R_T
Clone<ExPolygon> O_OBJECT_SLIC3R_T
ExPolygonCollection* O_OBJECT_SLIC3R
Ref<ExPolygonCollection> O_OBJECT_SLIC3R_T
Clone<ExPolygonCollection> O_OBJECT_SLIC3R_T
ExtrusionEntityCollection* O_OBJECT_SLIC3R
Ref<ExtrusionEntityCollection> O_OBJECT_SLIC3R_T
Clone<ExtrusionEntityCollection> O_OBJECT_SLIC3R_T
ExtrusionPath* O_OBJECT_SLIC3R
Ref<ExtrusionPath> O_OBJECT_SLIC3R_T
Clone<ExtrusionPath> O_OBJECT_SLIC3R_T
ExtrusionLoop* O_OBJECT_SLIC3R
Ref<ExtrusionLoop> O_OBJECT_SLIC3R_T
Clone<ExtrusionLoop> O_OBJECT_SLIC3R_T
Flow* O_OBJECT_SLIC3R
Ref<Flow> O_OBJECT_SLIC3R_T
Clone<Flow> O_OBJECT_SLIC3R_T
PrintState* O_OBJECT_SLIC3R
Surface* O_OBJECT_SLIC3R
Ref<Surface> O_OBJECT_SLIC3R_T
Clone<Surface> O_OBJECT_SLIC3R_T
SurfaceCollection* O_OBJECT_SLIC3R
ExtrusionRole T_UV
FlowRole T_UV
@ -55,6 +105,19 @@ TriangleMeshPtrs T_PTR_ARRAYREF
INPUT
O_OBJECT_SLIC3R
if( sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG) ) {
if ( sv_isa($arg, perl_class_name($var) ) || sv_isa($arg, perl_class_name_ref($var) )) {
$var = ($type)SvIV((SV*)SvRV( $arg ));
} else {
croak(\"$var is not of type %s (got %s)\", perl_class_name($var), HvNAME(SvSTASH(SvRV($arg))));
XSRETURN_UNDEF;
}
} else {
warn( \"${Package}::$func_name() -- $var is not a blessed SV reference\" );
XSRETURN_UNDEF;
}
T_ARRAYREF
if (SvROK($arg) && SvTYPE(SvRV($arg)) == SVt_PVAV) {
AV* av = (AV*)SvRV($arg);
@ -72,6 +135,14 @@ T_ARRAYREF
\"$var\");
OUTPUT
# return object from pointer
O_OBJECT_SLIC3R
sv_setref_pv( $arg, perl_class_name($var), (void*)$var );
# return value handled by template class
O_OBJECT_SLIC3R_T
sv_setref_pv( $arg, $type\::CLASS(), (void*)$var );
T_ARRAYREF
AV* av = newAV();

View file

@ -10,23 +10,56 @@
%typemap{SV*};
%typemap{AV*};
%typemap{Point*};
%typemap{Ref<Point>}{simple};
%typemap{Clone<Point>}{simple};
%typemap{Pointf3*};
%typemap{Ref<Pointf3>}{simple};
%typemap{Clone<Pointf3>}{simple};
%typemap{BoundingBox*};
%typemap{Ref<BoundingBox>}{simple};
%typemap{Clone<BoundingBox>}{simple};
%typemap{BoundingBoxf3*};
%typemap{Ref<BoundingBoxf3>}{simple};
%typemap{Clone<BoundingBoxf3>}{simple};
%typemap{DynamicPrintConfig*};
%typemap{PrintObjectConfig*};
%typemap{PrintRegionConfig*};
%typemap{PrintConfig*};
%typemap{FullPrintConfig*};
%typemap{ExPolygon*};
%typemap{Ref<ExPolygon>}{simple};
%typemap{Clone<ExPolygon>}{simple};
%typemap{ExPolygonCollection*};
%typemap{Ref<ExPolygonCollection>}{simple};
%typemap{Clone<ExPolygonCollection>}{simple};
%typemap{Flow*};
%typemap{Ref<Flow>}{simple};
%typemap{Clone<Flow>}{simple};
%typemap{Line*};
%typemap{Ref<Line>}{simple};
%typemap{Clone<Line>}{simple};
%typemap{Polyline*};
%typemap{Ref<Polyline>}{simple};
%typemap{Clone<Polyline>}{simple};
%typemap{Polygon*};
%typemap{Ref<Polygon>}{simple};
%typemap{Clone<Polygon>}{simple};
%typemap{ExtrusionEntityCollection*};
%typemap{Ref<ExtrusionEntityCollection>}{simple};
%typemap{Clone<ExtrusionEntityCollection>}{simple};
%typemap{ExtrusionPath*};
%typemap{Ref<ExtrusionPath>}{simple};
%typemap{Clone<ExtrusionPath>}{simple};
%typemap{ExtrusionLoop*};
%typemap{Ref<ExtrusionLoop>}{simple};
%typemap{Clone<ExtrusionLoop>}{simple};
%typemap{TriangleMesh*};
%typemap{Ref<TriangleMesh>}{simple};
%typemap{Clone<TriangleMesh>}{simple};
%typemap{PolylineCollection*};
%typemap{Ref<PolylineCollection>}{simple};
%typemap{Clone<PolylineCollection>}{simple};
%typemap{Points};
%typemap{Pointfs};
%typemap{Lines};