This commit is contained in:
27
CPAN/Moose/Meta/Method/Accessor/Native/Array/Writer.pm
Normal file
27
CPAN/Moose/Meta/Method/Accessor/Native/Array/Writer.pm
Normal file
@@ -0,0 +1,27 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Array::Writer;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Writer',
|
||||
'Moose::Meta::Method::Accessor::Native::Array',
|
||||
'Moose::Meta::Method::Accessor::Native::Collection';
|
||||
|
||||
sub _inline_coerce_new_values {
|
||||
my $self = shift;
|
||||
$self->Moose::Meta::Method::Accessor::Native::Collection::_inline_coerce_new_values(@_);
|
||||
}
|
||||
|
||||
sub _new_members { '@_' }
|
||||
|
||||
sub _copy_old_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return '[ @{(' . $slot_access . ')} ]';
|
||||
}
|
||||
|
||||
1;
|
||||
56
CPAN/Moose/Meta/Method/Accessor/Native/Array/accessor.pm
Normal file
56
CPAN/Moose/Meta/Method/Accessor/Native/Array/accessor.pm
Normal file
@@ -0,0 +1,56 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Array::accessor;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Array::set',
|
||||
'Moose::Meta::Method::Accessor::Native::Array::get';
|
||||
|
||||
sub _inline_process_arguments {
|
||||
my $self = shift;
|
||||
$self->Moose::Meta::Method::Accessor::Native::Array::get::_inline_process_arguments(@_);
|
||||
}
|
||||
|
||||
sub _inline_check_arguments {
|
||||
my $self = shift;
|
||||
$self->Moose::Meta::Method::Accessor::Native::Array::get::_inline_check_arguments(@_);
|
||||
}
|
||||
|
||||
sub _return_value {
|
||||
my $self = shift;
|
||||
$self->Moose::Meta::Method::Accessor::Native::Array::get::_return_value(@_);
|
||||
}
|
||||
|
||||
sub _generate_method {
|
||||
my $self = shift;
|
||||
|
||||
my $inv = '$self';
|
||||
my $slot_access = $self->_get_value($inv);
|
||||
|
||||
return (
|
||||
'sub {',
|
||||
'my ' . $inv . ' = shift;',
|
||||
$self->_inline_curried_arguments,
|
||||
$self->_inline_check_lazy($inv, '$type_constraint', '$type_coercion', '$type_message'),
|
||||
# get
|
||||
'if (@_ == 1) {',
|
||||
$self->_inline_check_var_is_valid_index('$_[0]'),
|
||||
$self->Moose::Meta::Method::Accessor::Native::Array::get::_inline_return_value($slot_access),
|
||||
'}',
|
||||
# set
|
||||
'else {',
|
||||
$self->_inline_writer_core($inv, $slot_access),
|
||||
'}',
|
||||
'}',
|
||||
);
|
||||
}
|
||||
|
||||
sub _minimum_arguments { 1 }
|
||||
sub _maximum_arguments { 2 }
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
28
CPAN/Moose/Meta/Method/Accessor/Native/Array/clear.pm
Normal file
28
CPAN/Moose/Meta/Method/Accessor/Native/Array/clear.pm
Normal file
@@ -0,0 +1,28 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Array::clear;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Array::Writer';
|
||||
|
||||
sub _maximum_arguments { 0 }
|
||||
|
||||
sub _adds_members { 0 }
|
||||
|
||||
sub _potential_value { '[]' }
|
||||
|
||||
sub _inline_optimized_set_new_value {
|
||||
my $self = shift;
|
||||
my ($inv, $new, $slot_access) = @_;
|
||||
|
||||
return $slot_access . ' = [];';
|
||||
}
|
||||
|
||||
sub _return_value { '' }
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
22
CPAN/Moose/Meta/Method/Accessor/Native/Array/count.pm
Normal file
22
CPAN/Moose/Meta/Method/Accessor/Native/Array/count.pm
Normal file
@@ -0,0 +1,22 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Array::count;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Reader';
|
||||
|
||||
sub _maximum_arguments { 0 }
|
||||
|
||||
sub _return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return 'scalar @{ (' . $slot_access . ') }';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
50
CPAN/Moose/Meta/Method/Accessor/Native/Array/delete.pm
Normal file
50
CPAN/Moose/Meta/Method/Accessor/Native/Array/delete.pm
Normal file
@@ -0,0 +1,50 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Array::delete;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Array::Writer';
|
||||
|
||||
sub _minimum_arguments { 1 }
|
||||
|
||||
sub _maximum_arguments { 1 }
|
||||
|
||||
sub _inline_check_arguments {
|
||||
my $self = shift;
|
||||
|
||||
return $self->_inline_check_var_is_valid_index('$_[0]');
|
||||
}
|
||||
|
||||
sub _adds_members { 0 }
|
||||
|
||||
sub _potential_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return '(do { '
|
||||
. 'my @potential = @{ (' . $slot_access . ') }; '
|
||||
. '@return = splice @potential, $_[0], 1; '
|
||||
. '\@potential; '
|
||||
. '})';
|
||||
}
|
||||
|
||||
sub _inline_optimized_set_new_value {
|
||||
my $self = shift;
|
||||
my ($inv, $new, $slot_access) = @_;
|
||||
|
||||
return '@return = splice @{ (' . $slot_access . ') }, $_[0], 1;';
|
||||
}
|
||||
|
||||
sub _return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return '$return[0]';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
22
CPAN/Moose/Meta/Method/Accessor/Native/Array/elements.pm
Normal file
22
CPAN/Moose/Meta/Method/Accessor/Native/Array/elements.pm
Normal file
@@ -0,0 +1,22 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Array::elements;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Reader';
|
||||
|
||||
sub _maximum_arguments { 0 }
|
||||
|
||||
sub _return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return '@{ (' . $slot_access . ') }';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
42
CPAN/Moose/Meta/Method/Accessor/Native/Array/first.pm
Normal file
42
CPAN/Moose/Meta/Method/Accessor/Native/Array/first.pm
Normal file
@@ -0,0 +1,42 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Array::first;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use List::Util ();
|
||||
use Params::Util ();
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Reader';
|
||||
|
||||
sub _minimum_arguments { 1 }
|
||||
|
||||
sub _maximum_arguments { 1 }
|
||||
|
||||
sub _inline_check_arguments {
|
||||
my $self = shift;
|
||||
|
||||
return (
|
||||
'if (!Params::Util::_CODELIKE($_[0])) {',
|
||||
$self->_inline_throw_exception( InvalidArgumentToMethod =>
|
||||
'argument => $_[0],'.
|
||||
'method_name => "first",'.
|
||||
'type_of_argument => "code reference",'.
|
||||
'type => "CodeRef",',
|
||||
) . ';',
|
||||
'}',
|
||||
);
|
||||
}
|
||||
|
||||
sub _return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return '&List::Util::first($_[0], @{ (' . $slot_access . ') })';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
51
CPAN/Moose/Meta/Method/Accessor/Native/Array/first_index.pm
Normal file
51
CPAN/Moose/Meta/Method/Accessor/Native/Array/first_index.pm
Normal file
@@ -0,0 +1,51 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Array::first_index;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Params::Util ();
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Reader';
|
||||
|
||||
sub _minimum_arguments { 1 }
|
||||
|
||||
sub _maximum_arguments { 1 }
|
||||
|
||||
sub _inline_check_arguments {
|
||||
my $self = shift;
|
||||
|
||||
return (
|
||||
'if (!Params::Util::_CODELIKE($_[0])) {',
|
||||
$self->_inline_throw_exception( InvalidArgumentToMethod =>
|
||||
'argument => $_[0],'.
|
||||
'method_name => "first_index",'.
|
||||
'type_of_argument => "code reference",'.
|
||||
'type => "CodeRef",',
|
||||
) . ';',
|
||||
'}',
|
||||
);
|
||||
}
|
||||
|
||||
sub _inline_return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return join '',
|
||||
'my @values = @{ (' . $slot_access . ') };',
|
||||
'my $f = $_[0];',
|
||||
'foreach my $i ( 0 .. $#values ) {',
|
||||
'local *_ = \\$values[$i];',
|
||||
'return $i if $f->();',
|
||||
'}',
|
||||
'return -1;';
|
||||
}
|
||||
|
||||
# Not called, but needed to satisfy the Reader role
|
||||
sub _return_value { }
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
31
CPAN/Moose/Meta/Method/Accessor/Native/Array/get.pm
Normal file
31
CPAN/Moose/Meta/Method/Accessor/Native/Array/get.pm
Normal file
@@ -0,0 +1,31 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Array::get;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Class::MOP::MiniTrait;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Reader',
|
||||
'Moose::Meta::Method::Accessor::Native::Array';
|
||||
|
||||
sub _minimum_arguments { 1 }
|
||||
|
||||
sub _maximum_arguments { 1 }
|
||||
|
||||
sub _inline_check_arguments {
|
||||
my $self = shift;
|
||||
|
||||
return $self->_inline_check_var_is_valid_index('$_[0]');
|
||||
}
|
||||
|
||||
sub _return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return $slot_access . '->[ $_[0] ]';
|
||||
}
|
||||
|
||||
1;
|
||||
41
CPAN/Moose/Meta/Method/Accessor/Native/Array/grep.pm
Normal file
41
CPAN/Moose/Meta/Method/Accessor/Native/Array/grep.pm
Normal file
@@ -0,0 +1,41 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Array::grep;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Params::Util ();
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Reader';
|
||||
|
||||
sub _minimum_arguments { 1 }
|
||||
|
||||
sub _maximum_arguments { 1 }
|
||||
|
||||
sub _inline_check_arguments {
|
||||
my $self = shift;
|
||||
|
||||
return (
|
||||
'if (!Params::Util::_CODELIKE($_[0])) {',
|
||||
$self->_inline_throw_exception( InvalidArgumentToMethod =>
|
||||
'argument => $_[0],'.
|
||||
'method_name => "grep",'.
|
||||
'type_of_argument => "code reference",'.
|
||||
'type => "CodeRef",',
|
||||
) . ';',
|
||||
'}',
|
||||
);
|
||||
}
|
||||
|
||||
sub _return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return 'grep { $_[0]->() } @{ (' . $slot_access . ') }';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
58
CPAN/Moose/Meta/Method/Accessor/Native/Array/insert.pm
Normal file
58
CPAN/Moose/Meta/Method/Accessor/Native/Array/insert.pm
Normal file
@@ -0,0 +1,58 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Array::insert;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Array::Writer';
|
||||
|
||||
sub _minimum_arguments { 2 }
|
||||
|
||||
sub _maximum_arguments { 2 }
|
||||
|
||||
sub _adds_members { 1 }
|
||||
|
||||
sub _potential_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return '(do { '
|
||||
. 'my @potential = @{ (' . $slot_access . ') }; '
|
||||
. 'splice @potential, $_[0], 0, $_[1]; '
|
||||
. '\@potential; '
|
||||
. '})';
|
||||
}
|
||||
|
||||
# We need to override this because while @_ can be written to, we cannot write
|
||||
# directly to $_[1].
|
||||
sub _inline_coerce_new_values {
|
||||
my $self = shift;
|
||||
|
||||
return unless $self->associated_attribute->should_coerce;
|
||||
|
||||
return unless $self->_tc_member_type_can_coerce;
|
||||
|
||||
return '@_ = ($_[0], $member_coercion->($_[1]));';
|
||||
};
|
||||
|
||||
sub _new_members { '$_[1]' }
|
||||
|
||||
sub _inline_optimized_set_new_value {
|
||||
my $self = shift;
|
||||
my ($inv, $new, $slot_access) = @_;
|
||||
|
||||
return 'splice @{ (' . $slot_access . ') }, $_[0], 0, $_[1];';
|
||||
}
|
||||
|
||||
sub _return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return $slot_access . '->[ $_[0] ]';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
22
CPAN/Moose/Meta/Method/Accessor/Native/Array/is_empty.pm
Normal file
22
CPAN/Moose/Meta/Method/Accessor/Native/Array/is_empty.pm
Normal file
@@ -0,0 +1,22 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Array::is_empty;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Reader';
|
||||
|
||||
sub _maximum_arguments { 0 }
|
||||
|
||||
sub _return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return '@{ (' . $slot_access . ') } ? 0 : 1';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
41
CPAN/Moose/Meta/Method/Accessor/Native/Array/join.pm
Normal file
41
CPAN/Moose/Meta/Method/Accessor/Native/Array/join.pm
Normal file
@@ -0,0 +1,41 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Array::join;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Moose::Util ();
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Reader';
|
||||
|
||||
sub _minimum_arguments { 1 }
|
||||
|
||||
sub _maximum_arguments { 1 }
|
||||
|
||||
sub _inline_check_arguments {
|
||||
my $self = shift;
|
||||
|
||||
return (
|
||||
'if (!Moose::Util::_STRINGLIKE0($_[0])) {',
|
||||
$self->_inline_throw_exception( InvalidArgumentToMethod =>
|
||||
'argument => $_[0],'.
|
||||
'method_name => "join",'.
|
||||
'type_of_argument => "string",'.
|
||||
'type => "Str",',
|
||||
) . ';',
|
||||
'}',
|
||||
);
|
||||
}
|
||||
|
||||
sub _return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return 'join $_[0], @{ (' . $slot_access . ') }';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
41
CPAN/Moose/Meta/Method/Accessor/Native/Array/map.pm
Normal file
41
CPAN/Moose/Meta/Method/Accessor/Native/Array/map.pm
Normal file
@@ -0,0 +1,41 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Array::map;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Params::Util ();
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Reader';
|
||||
|
||||
sub _minimum_arguments { 1 }
|
||||
|
||||
sub _maximum_arguments { 1 }
|
||||
|
||||
sub _inline_check_arguments {
|
||||
my $self = shift;
|
||||
|
||||
return (
|
||||
'if (!Params::Util::_CODELIKE($_[0])) {',
|
||||
$self->_inline_throw_exception( InvalidArgumentToMethod =>
|
||||
'argument => $_[0],'.
|
||||
'method_name => "map",'.
|
||||
'type_of_argument => "code reference",'.
|
||||
'type => "CodeRef",',
|
||||
) . ';',
|
||||
'}',
|
||||
);
|
||||
}
|
||||
|
||||
sub _return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return 'map { $_[0]->() } @{ (' . $slot_access . ') }';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
66
CPAN/Moose/Meta/Method/Accessor/Native/Array/natatime.pm
Normal file
66
CPAN/Moose/Meta/Method/Accessor/Native/Array/natatime.pm
Normal file
@@ -0,0 +1,66 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Array::natatime;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Params::Util ();
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Reader';
|
||||
|
||||
sub _minimum_arguments { 1 }
|
||||
|
||||
sub _maximum_arguments { 2 }
|
||||
|
||||
sub _inline_check_arguments {
|
||||
my $self = shift;
|
||||
|
||||
return (
|
||||
'if (!defined($_[0]) || $_[0] !~ /^\d+$/) {',
|
||||
$self->_inline_throw_exception( InvalidArgumentToMethod =>
|
||||
'argument => $_[0],'.
|
||||
'method_name => "natatime",'.
|
||||
'type_of_argument => "integer",'.
|
||||
'type => "Int",'.
|
||||
'argument_noun => "n value"',
|
||||
) . ';',
|
||||
'}',
|
||||
'if (@_ == 2 && !Params::Util::_CODELIKE($_[1])) {',
|
||||
$self->_inline_throw_exception( InvalidArgumentToMethod =>
|
||||
'argument => $_[1],'.
|
||||
'method_name => "natatime",'.
|
||||
'type_of_argument => "code reference",'.
|
||||
'type => "CodeRef",'.
|
||||
'ordinal => "second"',
|
||||
) . ';',
|
||||
'}',
|
||||
);
|
||||
}
|
||||
|
||||
sub _inline_return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return (
|
||||
'my $step = $_[0];',
|
||||
'my @values = @{ (' . $slot_access . ') };',
|
||||
'my $iter = sub { splice @values, 0, $step };',
|
||||
'if ($_[1]) {',
|
||||
'while (my @vals = $iter->()) {',
|
||||
'$_[1]->(@vals);',
|
||||
'}',
|
||||
'}',
|
||||
'else {',
|
||||
'return $iter;',
|
||||
'}',
|
||||
);
|
||||
}
|
||||
|
||||
# Not called, but needed to satisfy the Reader role
|
||||
sub _return_value { }
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
47
CPAN/Moose/Meta/Method/Accessor/Native/Array/pop.pm
Normal file
47
CPAN/Moose/Meta/Method/Accessor/Native/Array/pop.pm
Normal file
@@ -0,0 +1,47 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Array::pop;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Array::Writer';
|
||||
|
||||
sub _maximum_arguments { 0 }
|
||||
|
||||
sub _adds_members { 0 }
|
||||
|
||||
sub _potential_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return '[ @{ (' . $slot_access . ') } > 1 '
|
||||
. '? @{ (' . $slot_access . ') }[0..$#{ (' . $slot_access . ') } - 1] '
|
||||
. ': () ]';
|
||||
}
|
||||
|
||||
sub _inline_capture_return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return 'my $old = ' . $slot_access . '->[-1];';
|
||||
}
|
||||
|
||||
sub _inline_optimized_set_new_value {
|
||||
my $self = shift;
|
||||
my ($inv, $new, $slot_access) = @_;
|
||||
|
||||
return 'pop @{ (' . $slot_access . ') };';
|
||||
}
|
||||
|
||||
sub _return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return '$old';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
36
CPAN/Moose/Meta/Method/Accessor/Native/Array/push.pm
Normal file
36
CPAN/Moose/Meta/Method/Accessor/Native/Array/push.pm
Normal file
@@ -0,0 +1,36 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Array::push;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Array::Writer';
|
||||
|
||||
sub _adds_members { 1 }
|
||||
|
||||
sub _potential_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return '[ @{ (' . $slot_access . ') }, @_ ]';
|
||||
}
|
||||
|
||||
sub _inline_optimized_set_new_value {
|
||||
my $self = shift;
|
||||
my ($inv, $new, $slot_access) = @_;
|
||||
|
||||
return 'push @{ (' . $slot_access . ') }, @_;';
|
||||
}
|
||||
|
||||
sub _return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return 'scalar @{ (' . $slot_access . ') }';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
42
CPAN/Moose/Meta/Method/Accessor/Native/Array/reduce.pm
Normal file
42
CPAN/Moose/Meta/Method/Accessor/Native/Array/reduce.pm
Normal file
@@ -0,0 +1,42 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Array::reduce;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use List::Util ();
|
||||
use Params::Util ();
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Reader';
|
||||
|
||||
sub _minimum_arguments { 1 }
|
||||
|
||||
sub _maximum_arguments { 1 }
|
||||
|
||||
sub _inline_check_arguments {
|
||||
my $self = shift;
|
||||
|
||||
return (
|
||||
'if (!Params::Util::_CODELIKE($_[0])) {',
|
||||
$self->_inline_throw_exception( InvalidArgumentToMethod =>
|
||||
'argument => $_[0],'.
|
||||
'method_name => "reduce",'.
|
||||
'type_of_argument => "code reference",'.
|
||||
'type => "CodeRef",',
|
||||
) . ';',
|
||||
'}',
|
||||
);
|
||||
}
|
||||
|
||||
sub _return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return 'List::Util::reduce { $_[0]->($a, $b) } @{ (' . $slot_access . ') }';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
64
CPAN/Moose/Meta/Method/Accessor/Native/Array/set.pm
Normal file
64
CPAN/Moose/Meta/Method/Accessor/Native/Array/set.pm
Normal file
@@ -0,0 +1,64 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Array::set;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Array::Writer';
|
||||
|
||||
sub _minimum_arguments { 2 }
|
||||
|
||||
sub _maximum_arguments { 2 }
|
||||
|
||||
sub _inline_check_arguments {
|
||||
my $self = shift;
|
||||
|
||||
return $self->_inline_check_var_is_valid_index('$_[0]');
|
||||
}
|
||||
|
||||
sub _adds_members { 1 }
|
||||
|
||||
sub _potential_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return '(do { '
|
||||
. 'my @potential = @{ (' . $slot_access . ') }; '
|
||||
. '$potential[$_[0]] = $_[1]; '
|
||||
. '\@potential; '
|
||||
. '})';
|
||||
}
|
||||
|
||||
# We need to override this because while @_ can be written to, we cannot write
|
||||
# directly to $_[1].
|
||||
sub _inline_coerce_new_values {
|
||||
my $self = shift;
|
||||
|
||||
return unless $self->associated_attribute->should_coerce;
|
||||
|
||||
return unless $self->_tc_member_type_can_coerce;
|
||||
|
||||
return '@_ = ($_[0], $member_coercion->($_[1]));';
|
||||
};
|
||||
|
||||
sub _new_members { '$_[1]' }
|
||||
|
||||
sub _inline_optimized_set_new_value {
|
||||
my $self = shift;
|
||||
my ($inv, $new, $slot_access) = @_;
|
||||
|
||||
return $slot_access . '->[$_[0]] = $_[1];';
|
||||
}
|
||||
|
||||
sub _return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return $slot_access . '->[$_[0]]';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
@@ -0,0 +1,26 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Array::shallow_clone;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Params::Util ();
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Reader';
|
||||
|
||||
sub _minimum_arguments { 0 }
|
||||
|
||||
sub _maximum_arguments { 0 }
|
||||
|
||||
sub _return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return '[ @{ (' . $slot_access . ') } ]';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
47
CPAN/Moose/Meta/Method/Accessor/Native/Array/shift.pm
Normal file
47
CPAN/Moose/Meta/Method/Accessor/Native/Array/shift.pm
Normal file
@@ -0,0 +1,47 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Array::shift;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Array::Writer';
|
||||
|
||||
sub _maximum_arguments { 0 }
|
||||
|
||||
sub _adds_members { 0 }
|
||||
|
||||
sub _potential_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return '[ @{ (' . $slot_access . ') } > 1 '
|
||||
. '? @{ (' . $slot_access . ') }[1..$#{ (' . $slot_access . ') }] '
|
||||
. ': () ]';
|
||||
}
|
||||
|
||||
sub _inline_capture_return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return 'my $old = ' . $slot_access . '->[0];';
|
||||
}
|
||||
|
||||
sub _inline_optimized_set_new_value {
|
||||
my $self = shift;
|
||||
my ($inv, $new, $slot_access) = @_;
|
||||
|
||||
return 'shift @{ (' . $slot_access . ') };';
|
||||
}
|
||||
|
||||
sub _return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return '$old';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
24
CPAN/Moose/Meta/Method/Accessor/Native/Array/shuffle.pm
Normal file
24
CPAN/Moose/Meta/Method/Accessor/Native/Array/shuffle.pm
Normal file
@@ -0,0 +1,24 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Array::shuffle;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use List::Util ();
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Reader';
|
||||
|
||||
sub _maximum_arguments { 0 }
|
||||
|
||||
sub _return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return 'List::Util::shuffle @{ (' . $slot_access . ') }';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
44
CPAN/Moose/Meta/Method/Accessor/Native/Array/sort.pm
Normal file
44
CPAN/Moose/Meta/Method/Accessor/Native/Array/sort.pm
Normal file
@@ -0,0 +1,44 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Array::sort;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Params::Util ();
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Reader';
|
||||
|
||||
sub _maximum_arguments { 1 }
|
||||
|
||||
sub _inline_check_arguments {
|
||||
my $self = shift;
|
||||
|
||||
return (
|
||||
'if (@_ && !Params::Util::_CODELIKE($_[0])) {',
|
||||
$self->_inline_throw_exception( InvalidArgumentToMethod =>
|
||||
'argument => $_[0],'.
|
||||
'method_name => "sort",'.
|
||||
'type_of_argument => "code reference",'.
|
||||
'type => "CodeRef",',
|
||||
) . ';',
|
||||
'}',
|
||||
);
|
||||
}
|
||||
|
||||
sub _return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return
|
||||
'wantarray ? ( ' .
|
||||
'$_[0] '
|
||||
. '? sort { $_[0]->($a, $b) } @{ (' . $slot_access . ') } '
|
||||
. ': sort @{ (' . $slot_access . ') }'
|
||||
. ' ) : @{ (' . $slot_access . ') }';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
@@ -0,0 +1,45 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Array::sort_in_place;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Params::Util ();
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Array::Writer';
|
||||
|
||||
sub _maximum_arguments { 1 }
|
||||
|
||||
sub _inline_check_arguments {
|
||||
my $self = shift;
|
||||
|
||||
return (
|
||||
'if (@_ && !Params::Util::_CODELIKE($_[0])) {',
|
||||
$self->_inline_throw_exception( InvalidArgumentToMethod =>
|
||||
'argument => $_[0],'.
|
||||
'method_name => "sort_in_place",'.
|
||||
'type_of_argument => "code reference",'.
|
||||
'type => "CodeRef",',
|
||||
) . ';',
|
||||
'}',
|
||||
);
|
||||
}
|
||||
|
||||
sub _adds_members { 0 }
|
||||
|
||||
sub _potential_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return '[ $_[0] '
|
||||
. '? sort { $_[0]->($a, $b) } @{ (' . $slot_access . ') } '
|
||||
. ': sort @{ (' . $slot_access . ') } ]';
|
||||
}
|
||||
|
||||
sub _return_value { '' }
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
72
CPAN/Moose/Meta/Method/Accessor/Native/Array/splice.pm
Normal file
72
CPAN/Moose/Meta/Method/Accessor/Native/Array/splice.pm
Normal file
@@ -0,0 +1,72 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Array::splice;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Array::Writer';
|
||||
|
||||
sub _minimum_arguments { 1 }
|
||||
|
||||
sub _adds_members { 1 }
|
||||
|
||||
sub _inline_process_arguments {
|
||||
return (
|
||||
'my $idx = shift;',
|
||||
'my $len = @_ ? shift : undef;',
|
||||
);
|
||||
}
|
||||
|
||||
sub _inline_check_arguments {
|
||||
my $self = shift;
|
||||
|
||||
return (
|
||||
$self->_inline_check_var_is_valid_index('$idx'),
|
||||
'if (defined($len) && $len !~ /^-?\d+$/) {',
|
||||
$self->_inline_throw_exception( InvalidArgumentToMethod =>
|
||||
'argument => $len,'.
|
||||
'method_name => "splice",'.
|
||||
'type_of_argument => "integer",'.
|
||||
'type => "Int",'.
|
||||
'argument_noun => "length argument"',
|
||||
) . ';',
|
||||
'}',
|
||||
);
|
||||
}
|
||||
|
||||
sub _potential_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return '(do { '
|
||||
. 'my @potential = @{ (' . $slot_access . ') }; '
|
||||
. '@return = defined $len '
|
||||
. '? (splice @potential, $idx, $len, @_) '
|
||||
. ': (splice @potential, $idx); '
|
||||
. '\@potential;'
|
||||
. '})';
|
||||
}
|
||||
|
||||
sub _inline_optimized_set_new_value {
|
||||
my $self = shift;
|
||||
my ($inv, $new, $slot_access) = @_;
|
||||
|
||||
return (
|
||||
'@return = defined $len',
|
||||
'? (splice @{ (' . $slot_access . ') }, $idx, $len, @_)',
|
||||
': (splice @{ (' . $slot_access . ') }, $idx);',
|
||||
);
|
||||
}
|
||||
|
||||
sub _return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return 'wantarray ? @return : $return[-1]';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
24
CPAN/Moose/Meta/Method/Accessor/Native/Array/uniq.pm
Normal file
24
CPAN/Moose/Meta/Method/Accessor/Native/Array/uniq.pm
Normal file
@@ -0,0 +1,24 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Array::uniq;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use List::Util 1.45 ();
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Reader';
|
||||
|
||||
sub _maximum_arguments { 0 }
|
||||
|
||||
sub _return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return 'List::Util::uniq @{ (' . $slot_access . ') }';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
36
CPAN/Moose/Meta/Method/Accessor/Native/Array/unshift.pm
Normal file
36
CPAN/Moose/Meta/Method/Accessor/Native/Array/unshift.pm
Normal file
@@ -0,0 +1,36 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Array::unshift;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Array::Writer';
|
||||
|
||||
sub _adds_members { 1 }
|
||||
|
||||
sub _potential_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return '[ @_, @{ (' . $slot_access . ') } ]';
|
||||
}
|
||||
|
||||
sub _inline_optimized_set_new_value {
|
||||
my $self = shift;
|
||||
my ($inv, $new, $slot_access) = @_;
|
||||
|
||||
return 'unshift @{ (' . $slot_access . ') }, @_;';
|
||||
}
|
||||
|
||||
sub _return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return 'scalar @{ (' . $slot_access . ') }';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
Reference in New Issue
Block a user