1 package Moose::Meta::Method::Accessor::Native::Array::splice;
6 our $VERSION = '1.9900';
7 $VERSION = eval $VERSION;
8 our $AUTHORITY = 'cpan:STEVAN';
12 with 'Moose::Meta::Method::Accessor::Native::Array::Writer' => {
16 _inline_process_arguments
17 _inline_check_arguments
18 _inline_optimized_set_new_value
24 sub _minimum_arguments { 1 }
26 sub _adds_members { 1 }
28 sub _inline_process_arguments {
31 'my $len = @_ ? shift : undef;',
35 sub _inline_check_arguments {
39 $self->_inline_check_var_is_valid_index('$idx'),
40 'if (defined($len) && $len !~ /^-?\d+$/) {',
41 $self->_inline_throw_error(
42 '"The length argument passed to splice must be an integer"',
48 sub _potential_value {
50 my ($slot_access) = @_;
53 . 'my @potential = @{ (' . $slot_access . ') }; '
54 . '@return = defined $len '
55 . '? (splice @potential, $idx, $len, @_) '
56 . ': (splice @potential, $idx); '
61 sub _inline_optimized_set_new_value {
63 my ($inv, $new, $slot_access) = @_;
66 '@return = defined $len',
67 '? (splice @{ (' . $slot_access . ') }, $idx, $len, @_)',
68 ': (splice @{ (' . $slot_access . ') }, $idx);',
74 my ($slot_access) = @_;
76 return 'wantarray ? @return : $return[-1]';