Add Moose package
All checks were successful
release / release-plugins (push) Successful in 28s

This commit is contained in:
mschuepbach
2024-04-24 13:33:38 +02:00
parent 24101a5c1a
commit d95734d3d0
413 changed files with 47294 additions and 1 deletions

View File

@@ -0,0 +1,31 @@
package Moose::Meta::Method::Accessor::Native::String::append;
our $VERSION = '2.2207';
use strict;
use warnings;
use Moose::Role;
with 'Moose::Meta::Method::Accessor::Native::Writer';
sub _minimum_arguments { 1 }
sub _maximum_arguments { 1 }
sub _potential_value {
my $self = shift;
my ($slot_access) = @_;
return '( ' . $slot_access . ' . $_[0] )';
}
sub _inline_optimized_set_new_value {
my $self = shift;
my ($inv, $new, $slot_access) = @_;
return $slot_access . ' .= $_[0];';
}
no Moose::Role;
1;

View File

@@ -0,0 +1,40 @@
package Moose::Meta::Method::Accessor::Native::String::chomp;
our $VERSION = '2.2207';
use strict;
use warnings;
use Moose::Role;
with 'Moose::Meta::Method::Accessor::Native::Writer';
sub _maximum_arguments { 0 }
sub _potential_value {
my $self = shift;
my ($slot_access) = @_;
return '(do { '
. 'my $val = ' . $slot_access . '; '
. '@return = chomp $val; '
. '$val '
. '})';
}
sub _inline_optimized_set_new_value {
my $self = shift;
my ($inv, $new, $slot_access) = @_;
return '@return = chomp ' . $slot_access . ';';
}
sub _return_value {
my $self = shift;
my ($slot_access) = @_;
return '$return[0]';
}
no Moose::Role;
1;

View File

@@ -0,0 +1,40 @@
package Moose::Meta::Method::Accessor::Native::String::chop;
our $VERSION = '2.2207';
use strict;
use warnings;
use Moose::Role;
with 'Moose::Meta::Method::Accessor::Native::Writer';
sub _maximum_arguments { 0 }
sub _potential_value {
my $self = shift;
my ($slot_access) = @_;
return '(do { '
. 'my $val = ' . $slot_access . '; '
. '@return = chop $val; '
. '$val; '
. '})';
}
sub _inline_optimized_set_new_value {
my $self = shift;
my ($inv, $new, $slot_access) = @_;
return '@return = chop ' . $slot_access . ';';
}
sub _return_value {
my $self = shift;
my ($slot_access) = @_;
return '$return[0]';
}
no Moose::Role;
1;

View File

@@ -0,0 +1,24 @@
package Moose::Meta::Method::Accessor::Native::String::clear;
our $VERSION = '2.2207';
use strict;
use warnings;
use Moose::Role;
with 'Moose::Meta::Method::Accessor::Native::Writer';
sub _maximum_arguments { 0 }
sub _potential_value { '""' }
sub _inline_optimized_set_new_value {
my $self = shift;
my ($inv, $new, $slot_access) = @_;
return $slot_access . ' = "";';
}
no Moose::Role;
1;

View File

@@ -0,0 +1,33 @@
package Moose::Meta::Method::Accessor::Native::String::inc;
our $VERSION = '2.2207';
use strict;
use warnings;
use Moose::Role;
with 'Moose::Meta::Method::Accessor::Native::Writer';
sub _maximum_arguments { 0 }
sub _potential_value {
my $self = shift;
my ($slot_access) = @_;
return '(do { '
. 'my $val = ' . $slot_access . '; '
. '$val++; '
. '$val; '
. '})';
}
sub _inline_optimized_set_new_value {
my $self = shift;
my ($inv, $new, $slot_access) = @_;
return $slot_access . '++;';
}
no Moose::Role;
1;

View File

@@ -0,0 +1,22 @@
package Moose::Meta::Method::Accessor::Native::String::length;
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 'length ' . $slot_access;
}
no Moose::Role;
1;

View File

@@ -0,0 +1,42 @@
package Moose::Meta::Method::Accessor::Native::String::match;
our $VERSION = '2.2207';
use strict;
use warnings;
use Moose::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 (!Moose::Util::_STRINGLIKE0($_[0]) && !Params::Util::_REGEX($_[0])) {',
$self->_inline_throw_exception( InvalidArgumentToMethod =>
'argument => $_[0],'.
'type => "Str|RegexpRef",'.
'type_of_argument => "string or regexp reference",'.
'method_name => "match"',
) . ';',
'}',
);
}
sub _return_value {
my $self = shift;
my ($slot_access) = @_;
return $slot_access . ' =~ $_[0]';
}
no Moose::Role;
1;

View File

@@ -0,0 +1,31 @@
package Moose::Meta::Method::Accessor::Native::String::prepend;
our $VERSION = '2.2207';
use strict;
use warnings;
use Moose::Role;
with 'Moose::Meta::Method::Accessor::Native::Writer';
sub _minimum_arguments { 1 }
sub _maximum_arguments { 1 }
sub _potential_value {
my $self = shift;
my ($slot_access) = @_;
return '$_[0] . ' . $slot_access;
}
sub _inline_optimized_set_new_value {
my $self = shift;
my ($inv, $new, $slot_access) = @_;
return $slot_access . ' = $_[0] . ' . $slot_access . ';';
}
no Moose::Role;
1;

View File

@@ -0,0 +1,69 @@
package Moose::Meta::Method::Accessor::Native::String::replace;
our $VERSION = '2.2207';
use strict;
use warnings;
use Moose::Util ();
use Params::Util ();
use Moose::Role;
with 'Moose::Meta::Method::Accessor::Native::Writer';
sub _minimum_arguments { 1 }
sub _maximum_arguments { 2 }
sub _inline_check_arguments {
my $self = shift;
return (
'if (!Moose::Util::_STRINGLIKE0($_[0]) && !Params::Util::_REGEX($_[0])) {',
$self->_inline_throw_exception( InvalidArgumentToMethod =>
'argument => $_[0],'.
'method_name => "replace",'.
'ordinal => "first",'.
'type_of_argument => "string or regexp reference",'.
'type => "Str|RegexpRef"',
) . ';',
'}',
'if (!Moose::Util::_STRINGLIKE0($_[1]) && !Params::Util::_CODELIKE($_[1])) {',
$self->_inline_throw_exception( InvalidArgumentToMethod =>
'argument => $_[1],'.
'method_name => "replace",'.
'ordinal => "second",'.
'type_of_argument => "string or code reference",'.
'type => "Str|CodeRef"',
) . ';',
'}',
);
}
sub _potential_value {
my $self = shift;
my ($slot_access) = @_;
return '(do { '
. 'my $val = ' . $slot_access . '; '
. 'ref $_[1] '
. '? $val =~ s/$_[0]/$_[1]->()/e '
. ': $val =~ s/$_[0]/$_[1]/; '
. '$val; '
. '})';
}
sub _inline_optimized_set_new_value {
my $self = shift;
my ($inv, $new, $slot_access) = @_;
return (
'ref $_[1]',
'? ' . $slot_access . ' =~ s/$_[0]/$_[1]->()/e',
': ' . $slot_access . ' =~ s/$_[0]/$_[1]/;',
);
}
no Moose::Role;
1;

View File

@@ -0,0 +1,123 @@
package Moose::Meta::Method::Accessor::Native::String::substr;
our $VERSION = '2.2207';
use strict;
use warnings;
use Moose::Util ();
use Moose::Role;
with 'Moose::Meta::Method::Accessor::Native::Reader',
'Moose::Meta::Method::Accessor::Native::Writer';
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,
'if (@_ == 1 || @_ == 2) {',
$self->_inline_reader_core($inv, $slot_access),
'}',
'elsif (@_ == 3) {',
$self->_inline_writer_core($inv, $slot_access),
'}',
'else {',
$self->_inline_check_argument_count,
'}',
'}',
);
}
sub _minimum_arguments { 1 }
sub _maximum_arguments { 3 }
sub _inline_process_arguments {
my $self = shift;
my ($inv, $slot_access) = @_;
return (
'my $offset = shift;',
'my $length = @_ ? shift : length ' . $slot_access . ';',
'my $replacement = shift;',
);
}
sub _inline_check_arguments {
my $self = shift;
my ($for_writer) = @_;
my @code = (
'if ($offset !~ /^-?\d+$/) {',
$self->_inline_throw_exception( InvalidArgumentToMethod =>
'argument => $offset,'.
'ordinal => "first",'.
'type_of_argument => "integer",'.
'method_name => "substr",'.
'type => "Int"',
) . ';',
'}',
'if ($length !~ /^-?\d+$/) {',
$self->_inline_throw_exception( InvalidArgumentToMethod =>
'argument => $length,'.
'ordinal => "second",'.
'type_of_argument => "integer",'.
'method_name => "substr",'.
'type => "Int"',
) . ';',
'}',
);
if ($for_writer) {
push @code, (
'if (!Moose::Util::_STRINGLIKE0($replacement)) {',
$self->_inline_throw_exception( InvalidArgumentToMethod =>
'argument => $replacement,'.
'ordinal => "third",'.
'type_of_argument => "string",'.
'method_name => "substr",'.
'type => "Str"',
) . ';',
'}',
);
}
return @code;
}
sub _potential_value {
my $self = shift;
my ($slot_access) = @_;
return '(do { '
. 'my $potential = ' . $slot_access . '; '
. '@return = substr $potential, $offset, $length, $replacement; '
. '$potential; '
. '})';
}
sub _inline_optimized_set_new_value {
my $self = shift;
my ($inv, $new, $slot_access) = @_;
return '@return = substr ' . $slot_access . ', '
. '$offset, $length, $replacement;';
}
sub _return_value {
my $self = shift;
my ($slot_access, $for_writer) = @_;
return '$return[0]' if $for_writer;
return 'substr ' . $slot_access . ', $offset, $length';
}
no Moose::Role;
1;