Many changes and fixes to remove leaks and return objects by reference

This commit is contained in:
Alessandro Ranellucci 2013-09-03 19:26:58 +02:00
parent 275422fac7
commit a49dc603cc
27 changed files with 67 additions and 46 deletions

View file

@ -73,14 +73,14 @@ ExPolygon::to_SV_ref() {
}
SV*
ExPolygon::to_SV_clone_ref() {
ExPolygon::to_SV_clone_ref() const {
SV* sv = newSV(0);
sv_setref_pv( sv, "Slic3r::ExPolygon", new ExPolygon(*this) );
return sv;
}
SV*
ExPolygon::to_SV_pureperl()
ExPolygon::to_SV_pureperl() const
{
const unsigned int num_holes = this->holes.size();
AV* av = newAV();

View file

@ -15,8 +15,8 @@ class ExPolygon
void from_SV_check(SV* poly_sv);
SV* to_SV();
SV* to_SV_ref();
SV* to_SV_clone_ref();
SV* to_SV_pureperl();
SV* to_SV_clone_ref() const;
SV* to_SV_pureperl() const;
void scale(double factor);
void translate(double x, double y);
void rotate(double angle, Point* center);

View file

@ -84,14 +84,14 @@ Line::to_SV_ref() {
}
SV*
Line::to_SV_clone_ref() {
Line::to_SV_clone_ref() const {
SV* sv = newSV(0);
sv_setref_pv( sv, "Slic3r::Line", new Line(*this) );
return sv;
}
SV*
Line::to_SV_pureperl() {
Line::to_SV_pureperl() const {
AV* av = newAV();
av_extend(av, 1);
av_store(av, 0, this->a.to_SV_pureperl());

View file

@ -17,8 +17,8 @@ class Line
void from_SV_check(SV* line_sv);
SV* to_SV();
SV* to_SV_ref();
SV* to_SV_clone_ref();
SV* to_SV_pureperl();
SV* to_SV_clone_ref() const;
SV* to_SV_pureperl() const;
void scale(double factor);
void translate(double x, double y);
void rotate(double angle, Point* center);

View file

@ -73,7 +73,7 @@ MultiPoint::to_SV() {
}
SV*
MultiPoint::to_SV_pureperl() {
MultiPoint::to_SV_pureperl() const {
const unsigned int num_points = this->points.size();
AV* av = newAV();
av_extend(av, num_points-1);

View file

@ -14,7 +14,7 @@ class MultiPoint
void from_SV(SV* poly_sv);
void from_SV_check(SV* poly_sv);
SV* to_SV();
SV* to_SV_pureperl();
SV* to_SV_pureperl() const;
void scale(double factor);
void translate(double x, double y);
void rotate(double angle, Point* center);

View file

@ -73,7 +73,7 @@ Point::distance_to(const Point* point) const
}
SV*
Point::to_SV_ref() const {
Point::to_SV_ref() {
SV* sv = newSV(0);
sv_setref_pv( sv, "Slic3r::Point::Ref", (void*)this );
return sv;

View file

@ -18,7 +18,7 @@ class Point
explicit Point(long _x = 0, long _y = 0): x(_x), y(_y) {};
void from_SV(SV* point_sv);
void from_SV_check(SV* point_sv);
SV* to_SV_ref() const;
SV* to_SV_ref();
SV* to_SV_clone_ref() const;
SV* to_SV_pureperl() const;
void scale(double factor);

View file

@ -12,7 +12,7 @@ Polygon::last_point() const
}
SV*
Polygon::to_SV_ref() const {
Polygon::to_SV_ref() {
SV* sv = newSV(0);
sv_setref_pv( sv, "Slic3r::Polygon::Ref", (void*)this );
return sv;
@ -26,7 +26,7 @@ Polygon::to_SV_clone_ref() const {
}
Lines
Polygon::lines()
Polygon::lines() const
{
Lines lines;
for (int i = 0; i < this->points.size()-1; i++) {

View file

@ -12,9 +12,9 @@ namespace Slic3r {
class Polygon : public MultiPoint {
public:
Point* last_point() const;
SV* to_SV_ref() const;
SV* to_SV_ref();
SV* to_SV_clone_ref() const;
Lines lines();
Lines lines() const;
Polyline* split_at(const Point* point);
Polyline* split_at_index(int index);
Polyline* split_at_first_point();

View file

@ -8,18 +8,17 @@ Polyline::last_point() const
return new Point(this->points.back());
}
Lines
Polyline::lines()
void
Polyline::lines(Lines &lines) const
{
Lines lines;
lines.clear();
for (int i = 0; i < this->points.size()-1; i++) {
lines.push_back(Line(this->points[i], this->points[i+1]));
}
return lines;
}
SV*
Polyline::to_SV_ref() const
Polyline::to_SV_ref()
{
SV* sv = newSV(0);
sv_setref_pv( sv, "Slic3r::Polyline::Ref", (void*)this );

View file

@ -9,8 +9,8 @@ namespace Slic3r {
class Polyline : public MultiPoint {
public:
Point* last_point() const;
Lines lines();
SV* to_SV_ref() const;
void lines(Lines &lines) const;
SV* to_SV_ref();
SV* to_SV_clone_ref() const;
};