From 0099218f61215dfaa9d0fd1ff3f8b5cb27406f94 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sun, 14 Jul 2013 13:11:01 +0200 Subject: [PATCH] Cleaner clone() implementation --- xs/lib/Slic3r/XS.pm | 4 ---- xs/xsp/ExPolygon.xsp | 3 ++- xs/xsp/ExPolygonCollection.xsp | 3 ++- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/xs/lib/Slic3r/XS.pm b/xs/lib/Slic3r/XS.pm index cf275ae40..05ef2355f 100644 --- a/xs/lib/Slic3r/XS.pm +++ b/xs/lib/Slic3r/XS.pm @@ -15,8 +15,6 @@ package Slic3r::ExPolygon::XS; use overload '@{}' => sub { $_[0]->arrayref }; -sub clone { (ref $_[0])->_clone($_[0]) } - # to handle legacy code sub rotate { my $self = shift; @@ -30,8 +28,6 @@ package Slic3r::ExPolygon::Collection; use overload '@{}' => sub { $_[0]->arrayref }; -sub clone { (ref $_[0])->_clone($_[0]) } - package Slic3r::Surface; sub new { diff --git a/xs/xsp/ExPolygon.xsp b/xs/xsp/ExPolygon.xsp index fe7237008..b12d8c0b6 100644 --- a/xs/xsp/ExPolygon.xsp +++ b/xs/xsp/ExPolygon.xsp @@ -6,8 +6,9 @@ %} %name{Slic3r::ExPolygon::XS} class ExPolygon { - %name{_clone} ExPolygon(ExPolygon& self); ~ExPolygon(); + ExPolygon* clone() + %code{% const char* CLASS = "Slic3r::ExPolygon::XS"; RETVAL = new ExPolygon(*THIS); %}; SV* arrayref() %code{% RETVAL = expolygon2perl(*THIS); %}; void scale(double factor); diff --git a/xs/xsp/ExPolygonCollection.xsp b/xs/xsp/ExPolygonCollection.xsp index 8696f301e..0c5fba488 100644 --- a/xs/xsp/ExPolygonCollection.xsp +++ b/xs/xsp/ExPolygonCollection.xsp @@ -6,8 +6,9 @@ %} %name{Slic3r::ExPolygon::Collection} class ExPolygonCollection { - %name{_clone} ExPolygonCollection(ExPolygonCollection& self); ~ExPolygonCollection(); + ExPolygonCollection* clone() + %code{% const char* CLASS = "Slic3r::ExPolygon::Collection"; RETVAL = new ExPolygonCollection(*THIS); %}; void scale(double factor); void translate(double x, double y); void rotate(double angle, Point* center);