Adopt XS containers everywhere (incomplete work)
This commit is contained in:
parent
339ba9e5c3
commit
9b582a11ff
30 changed files with 130 additions and 311 deletions
|
@ -48,7 +48,7 @@ sub clone {
|
|||
my ($self, %args) = @_;
|
||||
|
||||
return (ref $self)->_new(
|
||||
$args{polygon} // $self->as_polygon,
|
||||
$args{polygon} // $self->polygon,
|
||||
$args{role} // $self->role,
|
||||
$args{height} // $self->height,
|
||||
$args{flow_spacing} // $self->flow_spacing,
|
||||
|
@ -75,7 +75,7 @@ sub clone {
|
|||
my ($self, %args) = @_;
|
||||
|
||||
return (ref $self)->_new(
|
||||
$args{polyline} // $self->as_polyline,
|
||||
$args{polyline} // $self->polyline,
|
||||
$args{role} // $self->role,
|
||||
$args{height} // $self->height,
|
||||
$args{flow_spacing} // $self->flow_spacing,
|
||||
|
|
|
@ -16,11 +16,11 @@ my $path = Slic3r::ExtrusionPath->new(
|
|||
polyline => Slic3r::Polyline->new(@$points),
|
||||
role => Slic3r::ExtrusionPath::EXTR_ROLE_EXTERNAL_PERIMETER,
|
||||
);
|
||||
isa_ok $path->as_polyline, 'Slic3r::Polyline', 'path polyline';
|
||||
is_deeply $path->as_polyline->pp, $points, 'path points roundtrip';
|
||||
isa_ok $path->polyline, 'Slic3r::Polyline', 'path polyline';
|
||||
is_deeply $path->polyline->pp, $points, 'path points roundtrip';
|
||||
|
||||
$path->reverse;
|
||||
is_deeply $path->as_polyline->pp, [ reverse @$points ], 'reverse path';
|
||||
is_deeply $path->polyline->pp, [ reverse @$points ], 'reverse path';
|
||||
|
||||
$path->append([ 150, 150 ]);
|
||||
is scalar(@$path), 4, 'append to path';
|
||||
|
|
|
@ -17,8 +17,8 @@ my $loop = Slic3r::ExtrusionLoop->new(
|
|||
polygon => Slic3r::Polygon->new(@$square),
|
||||
role => Slic3r::ExtrusionPath::EXTR_ROLE_EXTERNAL_PERIMETER,
|
||||
);
|
||||
isa_ok $loop->as_polygon, 'Slic3r::Polygon', 'loop polygon';
|
||||
is_deeply $loop->as_polygon->pp, $square, 'polygon points roundtrip';
|
||||
isa_ok $loop->polygon, 'Slic3r::Polygon', 'loop polygon';
|
||||
is_deeply $loop->polygon->pp, $square, 'polygon points roundtrip';
|
||||
|
||||
$loop = $loop->clone;
|
||||
|
||||
|
@ -28,10 +28,10 @@ is $loop->role, Slic3r::ExtrusionPath::EXTR_ROLE_FILL, 'modify role';
|
|||
|
||||
{
|
||||
my $path = $loop->split_at_first_point;
|
||||
is_deeply $path->as_polyline->pp, $square, 'split_at_first_point';
|
||||
is_deeply $path->polyline->pp, $square, 'split_at_first_point';
|
||||
is $path->role, $loop->role, 'role preserved after split';
|
||||
|
||||
is_deeply $loop->split_at_index(2)->as_polyline->pp, [ @$square[2,3,0,1] ], 'split_at_index';
|
||||
is_deeply $loop->split_at_index(2)->polyline->pp, [ @$square[2,3,0,1] ], 'split_at_index';
|
||||
}
|
||||
|
||||
__END__
|
||||
|
|
|
@ -11,10 +11,6 @@
|
|||
%code{% RETVAL = THIS->polygon.to_SV(); %};
|
||||
SV* pp()
|
||||
%code{% RETVAL = THIS->polygon.to_SV_pureperl(); %};
|
||||
Polygon* as_polygon()
|
||||
%code{% const char* CLASS = "Slic3r::Polygon"; RETVAL = new Polygon(THIS->polygon); %};
|
||||
void set_polygon(SV* polygon_sv)
|
||||
%code{% THIS->polygon.from_SV_check(polygon_sv); %};
|
||||
ExtrusionPath* split_at_index(int index)
|
||||
%code{% const char* CLASS = "Slic3r::ExtrusionPath"; RETVAL = THIS->split_at_index(index); %};
|
||||
ExtrusionPath* split_at_first_point()
|
||||
|
@ -37,6 +33,18 @@ _new(CLASS, polygon_sv, role, height, flow_spacing)
|
|||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
Polygon*
|
||||
ExtrusionLoop::polygon(...)
|
||||
PREINIT:
|
||||
const char* CLASS = "Slic3r::Polygon";
|
||||
CODE:
|
||||
if (items > 1) {
|
||||
THIS->polygon.from_SV_check( ST(1) );
|
||||
}
|
||||
RETVAL = new Polygon(THIS->polygon);
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
ExtrusionRole
|
||||
ExtrusionLoop::role(...)
|
||||
CODE:
|
||||
|
|
|
@ -11,10 +11,6 @@
|
|||
%code{% RETVAL = THIS->polyline.to_SV(); %};
|
||||
SV* pp()
|
||||
%code{% RETVAL = THIS->polyline.to_SV_pureperl(); %};
|
||||
Polyline* as_polyline()
|
||||
%code{% const char* CLASS = "Slic3r::Polyline"; RETVAL = new Polyline(THIS->polyline); %};
|
||||
void set_polyline(SV* polyline_sv)
|
||||
%code{% THIS->polyline.from_SV_check(polyline_sv); %};
|
||||
void pop_back()
|
||||
%code{% THIS->polyline.points.pop_back(); %};
|
||||
void reverse();
|
||||
|
@ -36,6 +32,18 @@ _new(CLASS, polyline_sv, role, height, flow_spacing)
|
|||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
Polyline*
|
||||
ExtrusionPath::polyline(...)
|
||||
PREINIT:
|
||||
const char* CLASS = "Slic3r::Polyline";
|
||||
CODE:
|
||||
if (items > 1) {
|
||||
THIS->polyline.from_SV_check( ST(1) );
|
||||
}
|
||||
RETVAL = new Polyline(THIS->polyline);
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
ExtrusionRole
|
||||
ExtrusionPath::role(...)
|
||||
CODE:
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
%code{% RETVAL = THIS->to_SV(); %};
|
||||
SV* pp()
|
||||
%code{% RETVAL = THIS->to_SV_pureperl(); %};
|
||||
Point* a()
|
||||
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = new Point(THIS->a); %};
|
||||
Point* b()
|
||||
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = new Point(THIS->b); %};
|
||||
void reverse();
|
||||
%{
|
||||
|
||||
|
|
|
@ -34,5 +34,14 @@ Polygon::new(...)
|
|||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
void
|
||||
Polygon::rotate(angle, center_sv)
|
||||
double angle;
|
||||
SV* center_sv;
|
||||
CODE:
|
||||
Point center;
|
||||
center.from_SV_check(center_sv);
|
||||
THIS->rotate(angle, ¢er);
|
||||
|
||||
%}
|
||||
};
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
%code{% RETVAL = THIS->to_SV(); %};
|
||||
SV* pp()
|
||||
%code{% RETVAL = THIS->to_SV_pureperl(); %};
|
||||
void scale(double factor);
|
||||
void translate(double x, double y);
|
||||
void pop_back()
|
||||
%code{% THIS->points.pop_back(); %};
|
||||
void reverse();
|
||||
|
@ -40,5 +42,14 @@ Polyline::append(...)
|
|||
THIS->points.push_back(p);
|
||||
}
|
||||
|
||||
void
|
||||
Polyline::rotate(angle, center_sv)
|
||||
double angle;
|
||||
SV* center_sv;
|
||||
CODE:
|
||||
Point center;
|
||||
center.from_SV_check(center_sv);
|
||||
THIS->rotate(angle, ¢er);
|
||||
|
||||
%}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue