1
0
mirror of https://github.com/FULU-Foundation/OrcaSlicer-bambulab.git synced 2026-08-02 11:35:51 +00:00

Return objects by reference instead of always cloning

This commit is contained in:
Alessandro Ranellucci
2013-09-02 20:22:20 +02:00
parent 1741301973
commit c0789506e4
30 changed files with 158 additions and 54 deletions
+3 -3
View File
@@ -14,9 +14,9 @@
SV* pp()
%code{% RETVAL = THIS->to_SV_pureperl(); %};
Polygon* contour()
%code{% const char* CLASS = "Slic3r::Polygon"; RETVAL = new Polygon(THIS->contour); %};
Polygons holes()
%code{% RETVAL = THIS->holes; %};
%code{% const char* CLASS = "Slic3r::Polygon::Ref"; RETVAL = &(THIS->contour); %};
Polygons* holes()
%code{% RETVAL = &(THIS->holes); %};
void scale(double factor);
void translate(double x, double y);
double area();
+2 -2
View File
@@ -17,9 +17,9 @@
Lines lines()
%code{% RETVAL = THIS->polyline.lines(); %};
Point* first_point()
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = new Point(*(THIS->first_point())); %};
%code{% const char* CLASS = "Slic3r::Point::Ref"; RETVAL = THIS->first_point(); %};
Point* last_point()
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = new Point(*(THIS->last_point())); %};
%code{% const char* CLASS = "Slic3r::Point::Ref"; RETVAL = THIS->last_point(); %};
%{
ExtrusionPath*
+2 -2
View File
@@ -14,9 +14,9 @@
SV* pp()
%code{% RETVAL = THIS->to_SV_pureperl(); %};
Point* a()
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = new Point(THIS->a); %};
%code{% const char* CLASS = "Slic3r::Point::Ref"; RETVAL = &(THIS->a); %};
Point* b()
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = new Point(THIS->b); %};
%code{% const char* CLASS = "Slic3r::Point::Ref"; RETVAL = &(THIS->b); %};
void reverse();
void scale(double factor);
void translate(double x, double y);
+1 -1
View File
@@ -30,7 +30,7 @@
bool make_clockwise();
bool is_valid();
Point* first_point()
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = new Point(*(THIS->first_point())); %};
%code{% const char* CLASS = "Slic3r::Point::Ref"; RETVAL = THIS->first_point(); %};
%{
Polygon*
+2 -2
View File
@@ -20,9 +20,9 @@
void reverse();
Lines lines();
Point* first_point()
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = new Point(*(THIS->first_point())); %};
%code{% const char* CLASS = "Slic3r::Point::Ref"; RETVAL = THIS->first_point(); %};
Point* last_point()
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = new Point(*(THIS->last_point())); %};
%code{% const char* CLASS = "Slic3r::Point::Ref"; RETVAL = THIS->last_point(); %};
%{
Polyline*
+12 -1
View File
@@ -23,6 +23,8 @@ Lines T_ARRAYREF
Polygons T_ARRAYREF
ExPolygons T_ARRAYREF
Polygons* T_ARRAYREF_POLYGONS_PTR
INPUT
T_ARRAYREF
@@ -49,6 +51,15 @@ T_ARRAYREF
av_extend(av, $var.size()-1);
int i = 0;
for (${type}::iterator it = $var.begin(); it != $var.end(); ++it) {
av_store(av, i++, (*it).to_SV_ref());
av_store(av, i++, (*it).to_SV_clone_ref());
}
$var.clear();
T_ARRAYREF_POLYGONS_PTR
AV* av = newAV();
$arg = newRV_noinc((SV*)av);
av_extend(av, $var->size()-1);
int i = 0;
for (Polygons::iterator it = $var->begin(); it != $var->end(); ++it) {
av_store(av, i++, (*it).to_SV_ref());
}
+1
View File
@@ -14,6 +14,7 @@
%typemap{Lines};
%typemap{Polygons};
%typemap{ExPolygons};
%typemap{Polygons*};
%typemap{SurfaceType}{parsed}{
%cpp_type{SurfaceType};