make native trait inlining work
[gitmo/Moose.git] / lib / Moose / Meta / Method / Accessor / Native / Array / delete.pm
1 package Moose::Meta::Method::Accessor::Native::Array::delete;
2
3 use strict;
4 use warnings;
5
6 our $VERSION = '1.19';
7 $VERSION = eval $VERSION;
8 our $AUTHORITY = 'cpan:STEVAN';
9
10 use Moose::Role;
11
12 with 'Moose::Meta::Method::Accessor::Native::Array::Writer' => {
13     -excludes => [
14         qw(
15             _minimum_arguments
16             _maximum_arguments
17             _inline_check_arguments
18             _optimized_set_new_value
19             _return_value
20             )
21     ],
22 };
23
24 sub _minimum_arguments { 1 }
25
26 sub _maximum_arguments { 1 }
27
28 sub _inline_check_arguments {
29     my $self = shift;
30
31     return $self->_inline_check_var_is_valid_index('$_[0]');
32 }
33
34 sub _adds_members { 0 }
35
36 sub _potential_value {
37     my $self = shift;
38     my ($slot_access) = @_;
39
40     return '(do { '
41              . 'my @potential = @{ (' . $slot_access . ') }; '
42              . '@return = splice @potential, $_[0], 1; '
43              . '\@potential; '
44          . '})';
45 }
46
47 sub _optimized_set_new_value {
48     my $self = shift;
49     my ($inv, $new, $slot_access) = @_;
50
51     return '@return = splice @{ (' . $slot_access . ') }, $_[0], 1';
52 }
53
54 sub _return_value {
55     my $self = shift;
56     my ($slot_access) = @_;
57
58     return '$return[0]';
59 }
60
61 no Moose::Role;
62
63 1;