1 package Moose::Meta::Method::Accessor::Native::Array::splice;
8 with 'Moose::Meta::Method::Accessor::Native::Array::Writer' => {
12 _inline_process_arguments
13 _inline_check_arguments
14 _inline_optimized_set_new_value
20 sub _minimum_arguments { 1 }
22 sub _adds_members { 1 }
24 sub _inline_process_arguments {
27 'my $len = @_ ? shift : undef;',
31 sub _inline_check_arguments {
35 $self->_inline_check_var_is_valid_index('$idx'),
36 'if (defined($len) && $len !~ /^-?\d+$/) {',
37 $self->_inline_throw_error(
38 '"The length argument passed to splice must be an integer"',
44 sub _potential_value {
46 my ($slot_access) = @_;
49 . 'my @potential = @{ (' . $slot_access . ') }; '
50 . '@return = defined $len '
51 . '? (splice @potential, $idx, $len, @_) '
52 . ': (splice @potential, $idx); '
57 sub _inline_optimized_set_new_value {
59 my ($inv, $new, $slot_access) = @_;
62 '@return = defined $len',
63 '? (splice @{ (' . $slot_access . ') }, $idx, $len, @_)',
64 ': (splice @{ (' . $slot_access . ') }, $idx);',
70 my ($slot_access) = @_;
72 return 'wantarray ? @return : $return[-1]';