This commit is contained in:
1810
CPAN/Moose/Meta/Attribute.pm
Normal file
1810
CPAN/Moose/Meta/Attribute.pm
Normal file
File diff suppressed because it is too large
Load Diff
299
CPAN/Moose/Meta/Attribute/Native.pm
Normal file
299
CPAN/Moose/Meta/Attribute/Native.pm
Normal file
@@ -0,0 +1,299 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
package Moose::Meta::Attribute::Native;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use Module::Runtime 'require_module';
|
||||
|
||||
my @trait_names = qw(Bool Counter Number String Array Hash Code);
|
||||
|
||||
for my $trait_name (@trait_names) {
|
||||
my $trait_class = "Moose::Meta::Attribute::Native::Trait::$trait_name";
|
||||
my $meta = Class::MOP::Class->initialize(
|
||||
"Moose::Meta::Attribute::Custom::Trait::$trait_name"
|
||||
);
|
||||
|
||||
if ($meta->find_method_by_name('register_implementation')) {
|
||||
my $class = $meta->name->register_implementation;
|
||||
die "An implementation for $trait_name already exists " .
|
||||
"(found '$class' when trying to register '$trait_class')"
|
||||
}
|
||||
$meta->add_method(register_implementation => sub {
|
||||
# resolve_metatrait_alias will load classes anyway, but throws away
|
||||
# their error message; we WANT to die if there's a problem
|
||||
require_module($trait_class);
|
||||
return $trait_class;
|
||||
});
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
# ABSTRACT: Delegate to native Perl types
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Moose::Meta::Attribute::Native - Delegate to native Perl types
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 2.2207
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
package MyClass;
|
||||
use Moose;
|
||||
|
||||
has 'mapping' => (
|
||||
traits => ['Hash'],
|
||||
is => 'rw',
|
||||
isa => 'HashRef[Str]',
|
||||
default => sub { {} },
|
||||
handles => {
|
||||
exists_in_mapping => 'exists',
|
||||
ids_in_mapping => 'keys',
|
||||
get_mapping => 'get',
|
||||
set_mapping => 'set',
|
||||
set_quantity => [ set => 'quantity' ],
|
||||
},
|
||||
);
|
||||
|
||||
my $obj = MyClass->new;
|
||||
$obj->set_quantity(10); # quantity => 10
|
||||
$obj->set_mapping('foo', 4); # foo => 4
|
||||
$obj->set_mapping('bar', 5); # bar => 5
|
||||
$obj->set_mapping('baz', 6); # baz => 6
|
||||
|
||||
# prints 5
|
||||
print $obj->get_mapping('bar') if $obj->exists_in_mapping('bar');
|
||||
|
||||
# prints 'quantity, foo, bar, baz'
|
||||
print join ', ', $obj->ids_in_mapping;
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Native delegations allow you to delegate to native Perl data
|
||||
structures as if they were objects. For example, in the L</SYNOPSIS> you can
|
||||
see a hash reference being treated as if it has methods named C<exists()>,
|
||||
C<keys()>, C<get()>, and C<set()>.
|
||||
|
||||
The delegation methods (mostly) map to Perl builtins and operators. The return
|
||||
values of these delegations should be the same as the corresponding Perl
|
||||
operation. Any deviations will be explicitly documented.
|
||||
|
||||
=head1 API
|
||||
|
||||
Native delegations are enabled by passing certain options to C<has> when
|
||||
creating an attribute.
|
||||
|
||||
=head2 traits
|
||||
|
||||
To enable this feature, pass the appropriate name in the C<traits> array
|
||||
reference for the attribute. For example, to enable this feature for hash
|
||||
reference, we include C<'Hash'> in the list of traits.
|
||||
|
||||
=head2 isa
|
||||
|
||||
You will need to make sure that the attribute has an appropriate type. For
|
||||
example, to use this with a Hash you must specify that your attribute is some
|
||||
sort of C<HashRef>.
|
||||
|
||||
=head2 handles
|
||||
|
||||
This is just like any other delegation, but only a hash reference is allowed
|
||||
when defining native delegations. The keys are the methods to be created in
|
||||
the class which contains the attribute. The values are the methods provided by
|
||||
the associated trait. Currying works the same way as it does with any other
|
||||
delegation.
|
||||
|
||||
See the docs for each native trait for details on what methods are available.
|
||||
|
||||
=head1 TRAITS FOR NATIVE DELEGATIONS
|
||||
|
||||
Below are some simple examples of each native trait. More features are
|
||||
available than what is shown here; this is just a quick synopsis.
|
||||
|
||||
=over
|
||||
|
||||
=item Array (L<Moose::Meta::Attribute::Native::Trait::Array>)
|
||||
|
||||
has 'queue' => (
|
||||
traits => ['Array'],
|
||||
is => 'ro',
|
||||
isa => 'ArrayRef[Str]',
|
||||
default => sub { [] },
|
||||
handles => {
|
||||
add_item => 'push',
|
||||
next_item => 'shift',
|
||||
# ...
|
||||
}
|
||||
);
|
||||
|
||||
=item Bool (L<Moose::Meta::Attribute::Native::Trait::Bool>)
|
||||
|
||||
has 'is_lit' => (
|
||||
traits => ['Bool'],
|
||||
is => 'ro',
|
||||
isa => 'Bool',
|
||||
default => 0,
|
||||
handles => {
|
||||
illuminate => 'set',
|
||||
darken => 'unset',
|
||||
flip_switch => 'toggle',
|
||||
is_dark => 'not',
|
||||
# ...
|
||||
}
|
||||
);
|
||||
|
||||
=item Code (L<Moose::Meta::Attribute::Native::Trait::Code>)
|
||||
|
||||
has 'callback' => (
|
||||
traits => ['Code'],
|
||||
is => 'ro',
|
||||
isa => 'CodeRef',
|
||||
default => sub {
|
||||
sub {'called'}
|
||||
},
|
||||
handles => {
|
||||
call => 'execute',
|
||||
# ...
|
||||
}
|
||||
);
|
||||
|
||||
=item Counter (L<Moose::Meta::Attribute::Native::Trait::Counter>)
|
||||
|
||||
has 'counter' => (
|
||||
traits => ['Counter'],
|
||||
is => 'ro',
|
||||
isa => 'Num',
|
||||
default => 0,
|
||||
handles => {
|
||||
inc_counter => 'inc',
|
||||
dec_counter => 'dec',
|
||||
reset_counter => 'reset',
|
||||
# ...
|
||||
}
|
||||
);
|
||||
|
||||
=item Hash (L<Moose::Meta::Attribute::Native::Trait::Hash>)
|
||||
|
||||
has 'options' => (
|
||||
traits => ['Hash'],
|
||||
is => 'ro',
|
||||
isa => 'HashRef[Str]',
|
||||
default => sub { {} },
|
||||
handles => {
|
||||
set_option => 'set',
|
||||
get_option => 'get',
|
||||
has_option => 'exists',
|
||||
# ...
|
||||
}
|
||||
);
|
||||
|
||||
=item Number (L<Moose::Meta::Attribute::Native::Trait::Number>)
|
||||
|
||||
has 'integer' => (
|
||||
traits => ['Number'],
|
||||
is => 'ro',
|
||||
isa => 'Int',
|
||||
default => 5,
|
||||
handles => {
|
||||
set => 'set',
|
||||
add => 'add',
|
||||
sub => 'sub',
|
||||
mul => 'mul',
|
||||
div => 'div',
|
||||
mod => 'mod',
|
||||
abs => 'abs',
|
||||
# ...
|
||||
}
|
||||
);
|
||||
|
||||
=item String (L<Moose::Meta::Attribute::Native::Trait::String>)
|
||||
|
||||
has 'text' => (
|
||||
traits => ['String'],
|
||||
is => 'ro',
|
||||
isa => 'Str',
|
||||
default => q{},
|
||||
handles => {
|
||||
add_text => 'append',
|
||||
replace_text => 'replace',
|
||||
# ...
|
||||
}
|
||||
);
|
||||
|
||||
=back
|
||||
|
||||
=head1 COMPATIBILITY WITH MooseX::AttributeHelpers
|
||||
|
||||
This feature used to be a separated CPAN distribution called
|
||||
L<MooseX::AttributeHelpers>.
|
||||
|
||||
When the feature was incorporated into the Moose core, some of the API details
|
||||
were changed. The underlying capabilities are the same, but some details of
|
||||
the API were changed.
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
See L<Moose/BUGS> for details on reporting bugs.
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
=over 4
|
||||
|
||||
=item *
|
||||
|
||||
Stevan Little <stevan@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Dave Rolsky <autarch@urth.org>
|
||||
|
||||
=item *
|
||||
|
||||
Jesse Luehrs <doy@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Shawn M Moore <sartak@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
|
||||
|
||||
=item *
|
||||
|
||||
Karen Etheridge <ether@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Florian Ragwitz <rafl@debian.org>
|
||||
|
||||
=item *
|
||||
|
||||
Hans Dieter Pearcey <hdp@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Chris Prather <chris@prather.org>
|
||||
|
||||
=item *
|
||||
|
||||
Matt S Trout <mstrout@cpan.org>
|
||||
|
||||
=back
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2006 by Infinity Interactive, Inc.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
244
CPAN/Moose/Meta/Attribute/Native/Trait.pm
Normal file
244
CPAN/Moose/Meta/Attribute/Native/Trait.pm
Normal file
@@ -0,0 +1,244 @@
|
||||
package Moose::Meta::Attribute::Native::Trait;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use Moose::Role;
|
||||
use Module::Runtime 'require_module';
|
||||
use Moose::Deprecated;
|
||||
use Moose::Util 'throw_exception';
|
||||
use Moose::Util::TypeConstraints;
|
||||
|
||||
requires '_helper_type';
|
||||
|
||||
before '_process_options' => sub {
|
||||
my ( $self, $name, $options ) = @_;
|
||||
|
||||
$self->_check_helper_type( $options, $name );
|
||||
};
|
||||
|
||||
sub _check_helper_type {
|
||||
my ( $self, $options, $name ) = @_;
|
||||
|
||||
my $type = $self->_helper_type;
|
||||
|
||||
$options->{isa} = $type
|
||||
unless exists $options->{isa};
|
||||
|
||||
my $isa;
|
||||
my $isa_name;
|
||||
|
||||
if ( blessed( $options->{isa} )
|
||||
&& $options->{isa}->can('does')
|
||||
&& $options->{isa}->does('Specio::Constraint::Role::Interface') ) {
|
||||
|
||||
$isa = $options->{isa};
|
||||
require Specio::Library::Builtins;
|
||||
return if $isa->is_a_type_of( Specio::Library::Builtins::t($type) );
|
||||
$isa_name = $isa->name() || $isa->description();
|
||||
}
|
||||
else {
|
||||
$isa = Moose::Util::TypeConstraints::find_or_create_type_constraint(
|
||||
$options->{isa} );
|
||||
return if $isa->is_a_type_of($type);
|
||||
$isa_name = $isa->name();
|
||||
}
|
||||
|
||||
throw_exception( WrongTypeConstraintGiven => required_type => $type,
|
||||
given_type => $isa_name,
|
||||
attribute_name => $name,
|
||||
params => $options
|
||||
);
|
||||
}
|
||||
|
||||
before 'install_accessors' => sub { (shift)->_check_handles_values };
|
||||
|
||||
sub _check_handles_values {
|
||||
my $self = shift;
|
||||
|
||||
my %handles = $self->_canonicalize_handles;
|
||||
|
||||
for my $original_method ( values %handles ) {
|
||||
my $name = $original_method->[0];
|
||||
|
||||
my $accessor_class = $self->_native_accessor_class_for($name);
|
||||
|
||||
( $accessor_class && $accessor_class->can('new') )
|
||||
|| confess
|
||||
"$name is an unsupported method type - $accessor_class";
|
||||
}
|
||||
}
|
||||
|
||||
around '_canonicalize_handles' => sub {
|
||||
shift;
|
||||
my $self = shift;
|
||||
my $handles = $self->handles;
|
||||
|
||||
return unless $handles;
|
||||
|
||||
unless ( 'HASH' eq ref $handles ) {
|
||||
throw_exception( HandlesMustBeAHashRef => instance => $self,
|
||||
given_handles => $handles
|
||||
);
|
||||
}
|
||||
|
||||
return
|
||||
map { $_ => $self->_canonicalize_handles_value( $handles->{$_} ) }
|
||||
keys %$handles;
|
||||
};
|
||||
|
||||
sub _canonicalize_handles_value {
|
||||
my $self = shift;
|
||||
my $value = shift;
|
||||
|
||||
if ( ref $value && 'ARRAY' ne ref $value ) {
|
||||
throw_exception( InvalidHandleValue => instance => $self,
|
||||
handle_value => $value
|
||||
);
|
||||
}
|
||||
|
||||
return ref $value ? $value : [$value];
|
||||
}
|
||||
|
||||
around '_make_delegation_method' => sub {
|
||||
my $next = shift;
|
||||
my ( $self, $handle_name, $method_to_call ) = @_;
|
||||
|
||||
my ( $name, @curried_args ) = @$method_to_call;
|
||||
|
||||
my $accessor_class = $self->_native_accessor_class_for($name);
|
||||
|
||||
die "Cannot find an accessor class for $name"
|
||||
unless $accessor_class && $accessor_class->can('new');
|
||||
|
||||
return $accessor_class->new(
|
||||
name => $handle_name,
|
||||
package_name => $self->associated_class->name,
|
||||
delegate_to_method => $name,
|
||||
attribute => $self,
|
||||
is_inline => 1,
|
||||
curried_arguments => \@curried_args,
|
||||
root_types => [ $self->_root_types ],
|
||||
);
|
||||
};
|
||||
|
||||
sub _root_types {
|
||||
return $_[0]->_helper_type;
|
||||
}
|
||||
|
||||
sub _native_accessor_class_for {
|
||||
my ( $self, $suffix ) = @_;
|
||||
|
||||
my $role
|
||||
= 'Moose::Meta::Method::Accessor::Native::'
|
||||
. $self->_native_type . '::'
|
||||
. $suffix;
|
||||
|
||||
require_module($role);
|
||||
return Moose::Meta::Class->create_anon_class(
|
||||
superclasses =>
|
||||
[ $self->accessor_metaclass, $self->delegation_metaclass ],
|
||||
roles => [$role],
|
||||
cache => 1,
|
||||
)->name;
|
||||
}
|
||||
|
||||
sub _build_native_type {
|
||||
my $self = shift;
|
||||
|
||||
for my $role_name ( map { $_->name } $self->meta->calculate_all_roles ) {
|
||||
return $1 if $role_name =~ /::Native::Trait::(\w+)$/;
|
||||
}
|
||||
|
||||
throw_exception( CannotCalculateNativeType => instance => $self );
|
||||
}
|
||||
|
||||
has '_native_type' => (
|
||||
is => 'ro',
|
||||
isa => 'Str',
|
||||
lazy => 1,
|
||||
builder => '_build_native_type',
|
||||
);
|
||||
|
||||
no Moose::Role;
|
||||
no Moose::Util::TypeConstraints;
|
||||
|
||||
1;
|
||||
|
||||
# ABSTRACT: Shared role for native delegation traits
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Moose::Meta::Attribute::Native::Trait - Shared role for native delegation traits
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 2.2207
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
See L<Moose/BUGS> for details on reporting bugs.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
Documentation for Moose native traits can be found in
|
||||
L<Moose::Meta::Attribute::Native>.
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
=over 4
|
||||
|
||||
=item *
|
||||
|
||||
Stevan Little <stevan@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Dave Rolsky <autarch@urth.org>
|
||||
|
||||
=item *
|
||||
|
||||
Jesse Luehrs <doy@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Shawn M Moore <sartak@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
|
||||
|
||||
=item *
|
||||
|
||||
Karen Etheridge <ether@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Florian Ragwitz <rafl@debian.org>
|
||||
|
||||
=item *
|
||||
|
||||
Hans Dieter Pearcey <hdp@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Chris Prather <chris@prather.org>
|
||||
|
||||
=item *
|
||||
|
||||
Matt S Trout <mstrout@cpan.org>
|
||||
|
||||
=back
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2006 by Infinity Interactive, Inc.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
387
CPAN/Moose/Meta/Attribute/Native/Trait/Array.pm
Normal file
387
CPAN/Moose/Meta/Attribute/Native/Trait/Array.pm
Normal file
@@ -0,0 +1,387 @@
|
||||
package Moose::Meta::Attribute::Native::Trait::Array;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use Moose::Role;
|
||||
with 'Moose::Meta::Attribute::Native::Trait';
|
||||
|
||||
sub _helper_type { 'ArrayRef' }
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
|
||||
# ABSTRACT: Helper trait for ArrayRef attributes
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Moose::Meta::Attribute::Native::Trait::Array - Helper trait for ArrayRef attributes
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 2.2207
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
package Stuff;
|
||||
use Moose;
|
||||
|
||||
has 'options' => (
|
||||
traits => ['Array'],
|
||||
is => 'ro',
|
||||
isa => 'ArrayRef[Str]',
|
||||
default => sub { [] },
|
||||
handles => {
|
||||
all_options => 'elements',
|
||||
add_option => 'push',
|
||||
map_options => 'map',
|
||||
filter_options => 'grep',
|
||||
find_option => 'first',
|
||||
get_option => 'get',
|
||||
join_options => 'join',
|
||||
count_options => 'count',
|
||||
has_options => 'count',
|
||||
has_no_options => 'is_empty',
|
||||
sorted_options => 'sort',
|
||||
},
|
||||
);
|
||||
|
||||
no Moose;
|
||||
1;
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This trait provides native delegation methods for array references.
|
||||
|
||||
=head1 DEFAULT TYPE
|
||||
|
||||
If you don't provide an C<isa> value for your attribute, it will default to
|
||||
C<ArrayRef>.
|
||||
|
||||
=head1 PROVIDED METHODS
|
||||
|
||||
=over 4
|
||||
|
||||
=item * B<count>
|
||||
|
||||
Returns the number of elements in the array.
|
||||
|
||||
$stuff = Stuff->new;
|
||||
$stuff->options( [ "foo", "bar", "baz", "boo" ] );
|
||||
|
||||
print $stuff->count_options; # prints 4
|
||||
|
||||
This method does not accept any arguments.
|
||||
|
||||
=item * B<is_empty>
|
||||
|
||||
Returns a boolean value that is true when the array has no elements.
|
||||
|
||||
$stuff->has_no_options ? die "No options!\n" : print "Good boy.\n";
|
||||
|
||||
This method does not accept any arguments.
|
||||
|
||||
=item * B<elements>
|
||||
|
||||
In list context, returns all of the elements of the array as a list.
|
||||
|
||||
In scalar context, returns the number of elements in the array.
|
||||
|
||||
my @options = $stuff->all_options;
|
||||
print "@options"; # prints "foo bar baz boo"
|
||||
print scalar $stuff->all_options; # prints 4
|
||||
|
||||
This method does not accept any arguments.
|
||||
|
||||
=item * B<get($index)>
|
||||
|
||||
Returns an element of the array by its index. You can also use negative index
|
||||
numbers, just as with Perl's core array handling.
|
||||
|
||||
my $option = $stuff->get_option(1);
|
||||
print "$option\n"; # prints "bar"
|
||||
|
||||
If the specified element does not exist, this will return C<undef>.
|
||||
|
||||
This method accepts just one argument.
|
||||
|
||||
=item * B<pop>
|
||||
|
||||
Just like Perl's builtin C<pop>.
|
||||
|
||||
This method does not accept any arguments.
|
||||
|
||||
=item * B<push($value1, $value2, value3 ...)>
|
||||
|
||||
Just like Perl's builtin C<push>. Returns the number of elements in the new
|
||||
array.
|
||||
|
||||
This method accepts any number of arguments.
|
||||
|
||||
=item * B<shift>
|
||||
|
||||
Just like Perl's builtin C<shift>.
|
||||
|
||||
This method does not accept any arguments.
|
||||
|
||||
=item * B<unshift($value1, $value2, value3 ...)>
|
||||
|
||||
Just like Perl's builtin C<unshift>. Returns the number of elements in the new
|
||||
array.
|
||||
|
||||
This method accepts any number of arguments.
|
||||
|
||||
=item * B<splice($offset, $length, @values)>
|
||||
|
||||
Just like Perl's builtin C<splice>. In scalar context, this returns the last
|
||||
element removed, or C<undef> if no elements were removed. In list context,
|
||||
this returns all the elements removed from the array.
|
||||
|
||||
This method requires at least one argument.
|
||||
|
||||
=item * B<first( sub { ... } )>
|
||||
|
||||
This method returns the first matching item in the array, just like
|
||||
L<List::Util>'s C<first> function. The matching is done with a subroutine
|
||||
reference you pass to this method. The subroutine will be called against each
|
||||
element in the array until one matches or all elements have been checked.
|
||||
Each list element will be available to the sub in C<$_>.
|
||||
|
||||
my $found = $stuff->find_option( sub {/^b/} );
|
||||
print "$found\n"; # prints "bar"
|
||||
|
||||
This method requires a single argument.
|
||||
|
||||
=item * B<first_index( sub { ... } )>
|
||||
|
||||
This method returns the index of the first matching item in the array, just
|
||||
like L<List::SomeUtils/first_index>. The matching is done with a
|
||||
subroutine reference you pass to this method. The subroutine will be called
|
||||
against each element in the array until one matches or all elements have been
|
||||
checked. Each list element will be available to the sub in C<$_>.
|
||||
If no match is made, -1 is returned.
|
||||
|
||||
This method requires a single argument.
|
||||
|
||||
=item * B<grep( sub { ... } )>
|
||||
|
||||
This method returns every element matching a given criteria, just like Perl's
|
||||
core C<grep> function. This method requires a subroutine which implements the
|
||||
matching logic; each list element will be available to the sub in C<$_>.
|
||||
|
||||
my @found = $stuff->filter_options( sub {/^b/} );
|
||||
print "@found\n"; # prints "bar baz boo"
|
||||
|
||||
This method requires a single argument.
|
||||
|
||||
=item * B<map( sub { ... } )>
|
||||
|
||||
This method transforms every element in the array and returns a new array,
|
||||
just like Perl's core C<map> function. This method requires a subroutine which
|
||||
implements the transformation; each list element will be available to the sub
|
||||
in C<$_>.
|
||||
|
||||
my @mod_options = $stuff->map_options( sub { $_ . "-tag" } );
|
||||
print "@mod_options\n"; # prints "foo-tag bar-tag baz-tag boo-tag"
|
||||
|
||||
This method requires a single argument.
|
||||
|
||||
=item * B<reduce( sub { ... } )>
|
||||
|
||||
This method turns an array into a single value, by passing a function the
|
||||
value so far and the next value in the array, just like L<List::Util>'s
|
||||
C<reduce> function. The reducing is done with a subroutine reference you pass
|
||||
to this method; each list element will be available to the sub in C<$_>.
|
||||
|
||||
my $found = $stuff->reduce_options( sub { $_[0] . $_[1] } );
|
||||
print "$found\n"; # prints "foobarbazboo"
|
||||
|
||||
This method requires a single argument.
|
||||
|
||||
=item * B<sort>
|
||||
|
||||
=item * B<sort( sub { ... } )>
|
||||
|
||||
Returns the elements of the array (not an array reference) in sorted order,
|
||||
or, like C<elements>, returns the number of elements in the array in scalar context.
|
||||
|
||||
You can provide an optional subroutine reference to sort with (as you can with
|
||||
Perl's core C<sort> function). However, instead of using C<$a> and C<$b> in
|
||||
this subroutine, you will need to use C<$_[0]> and C<$_[1]>.
|
||||
|
||||
# ascending ASCIIbetical
|
||||
my @sorted = $stuff->sort_options();
|
||||
|
||||
# Descending alphabetical order
|
||||
my @sorted_options = $stuff->sort_options( sub { lc $_[1] cmp lc $_[0] } );
|
||||
print "@sorted_options\n"; # prints "foo boo baz bar"
|
||||
|
||||
This method accepts a single argument.
|
||||
|
||||
=item * B<sort_in_place>
|
||||
|
||||
=item * B<sort_in_place( sub { ... } )>
|
||||
|
||||
Sorts the array I<in place>, modifying the value of the attribute.
|
||||
|
||||
You can provide an optional subroutine reference to sort with (as you can with
|
||||
Perl's core C<sort> function). However, instead of using C<$a> and C<$b>, you
|
||||
will need to use C<$_[0]> and C<$_[1]> instead.
|
||||
|
||||
This method does not define a return value.
|
||||
|
||||
This method accepts a single argument.
|
||||
|
||||
=item * B<shuffle>
|
||||
|
||||
Returns the elements of the array in random order, like C<shuffle> from
|
||||
L<List::Util>.
|
||||
|
||||
This method does not accept any arguments.
|
||||
|
||||
=item * B<uniq>
|
||||
|
||||
Returns the array with all duplicate elements removed, like L<List::Util/uniq>.
|
||||
|
||||
This method does not accept any arguments.
|
||||
|
||||
=item * B<join($str)>
|
||||
|
||||
Joins every element of the array using the separator given as argument, just
|
||||
like Perl's core C<join> function.
|
||||
|
||||
my $joined = $stuff->join_options(':');
|
||||
print "$joined\n"; # prints "foo:bar:baz:boo"
|
||||
|
||||
This method requires a single argument.
|
||||
|
||||
=item * B<set($index, $value)>
|
||||
|
||||
Given an index and a value, sets the specified array element's value.
|
||||
|
||||
This method returns the value at C<$index> after the set.
|
||||
|
||||
This method requires two arguments.
|
||||
|
||||
=item * B<delete($index)>
|
||||
|
||||
Removes the element at the given index from the array.
|
||||
|
||||
This method returns the deleted value. Note that if no value exists, it will
|
||||
return C<undef>.
|
||||
|
||||
This method requires one argument.
|
||||
|
||||
=item * B<insert($index, $value)>
|
||||
|
||||
Inserts a new element into the array at the given index.
|
||||
|
||||
This method returns the new value at C<$index>.
|
||||
|
||||
This method requires two arguments.
|
||||
|
||||
=item * B<clear>
|
||||
|
||||
Empties the entire array, like C<@array = ()>.
|
||||
|
||||
This method does not define a return value.
|
||||
|
||||
This method does not accept any arguments.
|
||||
|
||||
=item * B<accessor($index)>
|
||||
|
||||
=item * B<accessor($index, $value)>
|
||||
|
||||
This method provides a get/set accessor for the array, based on array indexes.
|
||||
If passed one argument, it returns the value at the specified index. If
|
||||
passed two arguments, it sets the value of the specified index.
|
||||
|
||||
When called as a setter, this method returns the new value at C<$index>.
|
||||
|
||||
This method accepts one or two arguments.
|
||||
|
||||
=item * B<natatime($n)>
|
||||
|
||||
=item * B<natatime($n, $code)>
|
||||
|
||||
This method returns an iterator which, on each call, returns C<$n> more items
|
||||
from the array, in order, like L<List::SomeUtils/natatime>.
|
||||
|
||||
If you pass a coderef as the second argument, then this code ref will be
|
||||
called on each group of C<$n> elements in the array until the array is
|
||||
exhausted.
|
||||
|
||||
This method accepts one or two arguments.
|
||||
|
||||
=item * B<shallow_clone>
|
||||
|
||||
This method returns a shallow clone of the array reference. The return value
|
||||
is a reference to a new array with the same elements. It is I<shallow>
|
||||
because any elements that were references in the original will be the I<same>
|
||||
references in the clone.
|
||||
|
||||
=back
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
See L<Moose/BUGS> for details on reporting bugs.
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
=over 4
|
||||
|
||||
=item *
|
||||
|
||||
Stevan Little <stevan@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Dave Rolsky <autarch@urth.org>
|
||||
|
||||
=item *
|
||||
|
||||
Jesse Luehrs <doy@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Shawn M Moore <sartak@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
|
||||
|
||||
=item *
|
||||
|
||||
Karen Etheridge <ether@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Florian Ragwitz <rafl@debian.org>
|
||||
|
||||
=item *
|
||||
|
||||
Hans Dieter Pearcey <hdp@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Chris Prather <chris@prather.org>
|
||||
|
||||
=item *
|
||||
|
||||
Matt S Trout <mstrout@cpan.org>
|
||||
|
||||
=back
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2006 by Infinity Interactive, Inc.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
146
CPAN/Moose/Meta/Attribute/Native/Trait/Bool.pm
Normal file
146
CPAN/Moose/Meta/Attribute/Native/Trait/Bool.pm
Normal file
@@ -0,0 +1,146 @@
|
||||
package Moose::Meta::Attribute::Native::Trait::Bool;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use Moose::Role;
|
||||
with 'Moose::Meta::Attribute::Native::Trait';
|
||||
|
||||
sub _helper_type { 'Bool' }
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
|
||||
# ABSTRACT: Helper trait for Bool attributes
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Moose::Meta::Attribute::Native::Trait::Bool - Helper trait for Bool attributes
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 2.2207
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
package Room;
|
||||
use Moose;
|
||||
|
||||
has 'is_lit' => (
|
||||
traits => ['Bool'],
|
||||
is => 'rw',
|
||||
isa => 'Bool',
|
||||
default => 0,
|
||||
handles => {
|
||||
illuminate => 'set',
|
||||
darken => 'unset',
|
||||
flip_switch => 'toggle',
|
||||
is_dark => 'not',
|
||||
},
|
||||
);
|
||||
|
||||
my $room = Room->new();
|
||||
$room->illuminate; # same as $room->is_lit(1);
|
||||
$room->darken; # same as $room->is_lit(0);
|
||||
$room->flip_switch; # same as $room->is_lit(not $room->is_lit);
|
||||
return $room->is_dark; # same as !$room->is_lit
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This trait provides native delegation methods for boolean values. A boolean is
|
||||
a scalar which can be C<1>, C<0>, C<"">, or C<undef>.
|
||||
|
||||
=head1 DEFAULT TYPE
|
||||
|
||||
If you don't provide an C<isa> value for your attribute, it will default to
|
||||
C<Bool>.
|
||||
|
||||
=head1 PROVIDED METHODS
|
||||
|
||||
None of these methods accept arguments.
|
||||
|
||||
=over 4
|
||||
|
||||
=item * B<set>
|
||||
|
||||
Sets the value to C<1> and returns C<1>.
|
||||
|
||||
=item * B<unset>
|
||||
|
||||
Set the value to C<0> and returns C<0>.
|
||||
|
||||
=item * B<toggle>
|
||||
|
||||
Toggles the value. If it's true, set to false, and vice versa.
|
||||
|
||||
Returns the new value.
|
||||
|
||||
=item * B<not>
|
||||
|
||||
Equivalent of 'not C<$value>'.
|
||||
|
||||
=back
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
See L<Moose/BUGS> for details on reporting bugs.
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
=over 4
|
||||
|
||||
=item *
|
||||
|
||||
Stevan Little <stevan@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Dave Rolsky <autarch@urth.org>
|
||||
|
||||
=item *
|
||||
|
||||
Jesse Luehrs <doy@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Shawn M Moore <sartak@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
|
||||
|
||||
=item *
|
||||
|
||||
Karen Etheridge <ether@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Florian Ragwitz <rafl@debian.org>
|
||||
|
||||
=item *
|
||||
|
||||
Hans Dieter Pearcey <hdp@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Chris Prather <chris@prather.org>
|
||||
|
||||
=item *
|
||||
|
||||
Matt S Trout <mstrout@cpan.org>
|
||||
|
||||
=back
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2006 by Infinity Interactive, Inc.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
129
CPAN/Moose/Meta/Attribute/Native/Trait/Code.pm
Normal file
129
CPAN/Moose/Meta/Attribute/Native/Trait/Code.pm
Normal file
@@ -0,0 +1,129 @@
|
||||
package Moose::Meta::Attribute::Native::Trait::Code;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use Moose::Role;
|
||||
with 'Moose::Meta::Attribute::Native::Trait';
|
||||
|
||||
sub _helper_type { 'CodeRef' }
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
|
||||
# ABSTRACT: Helper trait for CodeRef attributes
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Moose::Meta::Attribute::Native::Trait::Code - Helper trait for CodeRef attributes
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 2.2207
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
package Foo;
|
||||
use Moose;
|
||||
|
||||
has 'callback' => (
|
||||
traits => ['Code'],
|
||||
is => 'ro',
|
||||
isa => 'CodeRef',
|
||||
default => sub {
|
||||
sub { print "called" }
|
||||
},
|
||||
handles => {
|
||||
call => 'execute',
|
||||
},
|
||||
);
|
||||
|
||||
my $foo = Foo->new;
|
||||
$foo->call; # prints "called"
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This trait provides native delegation methods for code references.
|
||||
|
||||
=head1 DEFAULT TYPE
|
||||
|
||||
If you don't provide an C<isa> value for your attribute, it will default to
|
||||
C<CodeRef>.
|
||||
|
||||
=head1 PROVIDED METHODS
|
||||
|
||||
=over 4
|
||||
|
||||
=item * B<execute(@args)>
|
||||
|
||||
Calls the coderef with the given args.
|
||||
|
||||
=item * B<execute_method(@args)>
|
||||
|
||||
Calls the coderef with the instance as invocant and given args.
|
||||
|
||||
=back
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
See L<Moose/BUGS> for details on reporting bugs.
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
=over 4
|
||||
|
||||
=item *
|
||||
|
||||
Stevan Little <stevan@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Dave Rolsky <autarch@urth.org>
|
||||
|
||||
=item *
|
||||
|
||||
Jesse Luehrs <doy@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Shawn M Moore <sartak@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
|
||||
|
||||
=item *
|
||||
|
||||
Karen Etheridge <ether@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Florian Ragwitz <rafl@debian.org>
|
||||
|
||||
=item *
|
||||
|
||||
Hans Dieter Pearcey <hdp@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Chris Prather <chris@prather.org>
|
||||
|
||||
=item *
|
||||
|
||||
Matt S Trout <mstrout@cpan.org>
|
||||
|
||||
=back
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2006 by Infinity Interactive, Inc.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
157
CPAN/Moose/Meta/Attribute/Native/Trait/Counter.pm
Normal file
157
CPAN/Moose/Meta/Attribute/Native/Trait/Counter.pm
Normal file
@@ -0,0 +1,157 @@
|
||||
package Moose::Meta::Attribute::Native::Trait::Counter;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use Moose::Role;
|
||||
with 'Moose::Meta::Attribute::Native::Trait';
|
||||
|
||||
sub _helper_type { 'Num' }
|
||||
sub _root_types { 'Num', 'Int' }
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
|
||||
# ABSTRACT: Helper trait for Int attributes which represent counters
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Moose::Meta::Attribute::Native::Trait::Counter - Helper trait for Int attributes which represent counters
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 2.2207
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
package MyHomePage;
|
||||
use Moose;
|
||||
|
||||
has 'counter' => (
|
||||
traits => ['Counter'],
|
||||
is => 'ro',
|
||||
isa => 'Num',
|
||||
default => 0,
|
||||
handles => {
|
||||
inc_counter => 'inc',
|
||||
dec_counter => 'dec',
|
||||
reset_counter => 'reset',
|
||||
},
|
||||
);
|
||||
|
||||
my $page = MyHomePage->new();
|
||||
$page->inc_counter; # same as $page->counter( $page->counter + 1 );
|
||||
$page->dec_counter; # same as $page->counter( $page->counter - 1 );
|
||||
|
||||
my $count_by_twos = 2;
|
||||
$page->inc_counter($count_by_twos);
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This trait provides native delegation methods for counters. A counter can be
|
||||
any sort of number (integer or not). The delegation methods allow you to
|
||||
increment, decrement, or reset the value.
|
||||
|
||||
=head1 DEFAULT TYPE
|
||||
|
||||
If you don't provide an C<isa> value for your attribute, it will default to
|
||||
C<Num>.
|
||||
|
||||
=head1 PROVIDED METHODS
|
||||
|
||||
=over 4
|
||||
|
||||
=item * B<set($value)>
|
||||
|
||||
Sets the counter to the specified value and returns the new value.
|
||||
|
||||
This method requires a single argument.
|
||||
|
||||
=item * B<inc>
|
||||
|
||||
=item * B<inc($arg)>
|
||||
|
||||
Increases the attribute value by the amount of the argument, or by 1 if no
|
||||
argument is given. This method returns the new value.
|
||||
|
||||
This method accepts a single argument.
|
||||
|
||||
=item * B<dec>
|
||||
|
||||
=item * B<dec($arg)>
|
||||
|
||||
Decreases the attribute value by the amount of the argument, or by 1 if no
|
||||
argument is given. This method returns the new value.
|
||||
|
||||
This method accepts a single argument.
|
||||
|
||||
=item * B<reset>
|
||||
|
||||
Resets the value stored in this slot to its default value, and returns the new
|
||||
value.
|
||||
|
||||
=back
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
See L<Moose/BUGS> for details on reporting bugs.
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
=over 4
|
||||
|
||||
=item *
|
||||
|
||||
Stevan Little <stevan@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Dave Rolsky <autarch@urth.org>
|
||||
|
||||
=item *
|
||||
|
||||
Jesse Luehrs <doy@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Shawn M Moore <sartak@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
|
||||
|
||||
=item *
|
||||
|
||||
Karen Etheridge <ether@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Florian Ragwitz <rafl@debian.org>
|
||||
|
||||
=item *
|
||||
|
||||
Hans Dieter Pearcey <hdp@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Chris Prather <chris@prather.org>
|
||||
|
||||
=item *
|
||||
|
||||
Matt S Trout <mstrout@cpan.org>
|
||||
|
||||
=back
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2006 by Infinity Interactive, Inc.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
227
CPAN/Moose/Meta/Attribute/Native/Trait/Hash.pm
Normal file
227
CPAN/Moose/Meta/Attribute/Native/Trait/Hash.pm
Normal file
@@ -0,0 +1,227 @@
|
||||
package Moose::Meta::Attribute::Native::Trait::Hash;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use Moose::Role;
|
||||
with 'Moose::Meta::Attribute::Native::Trait';
|
||||
|
||||
sub _helper_type { 'HashRef' }
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
|
||||
# ABSTRACT: Helper trait for HashRef attributes
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Moose::Meta::Attribute::Native::Trait::Hash - Helper trait for HashRef attributes
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 2.2207
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
package Stuff;
|
||||
use Moose;
|
||||
|
||||
has 'options' => (
|
||||
traits => ['Hash'],
|
||||
is => 'ro',
|
||||
isa => 'HashRef[Str]',
|
||||
default => sub { {} },
|
||||
handles => {
|
||||
set_option => 'set',
|
||||
get_option => 'get',
|
||||
has_no_options => 'is_empty',
|
||||
num_options => 'count',
|
||||
delete_option => 'delete',
|
||||
option_pairs => 'kv',
|
||||
},
|
||||
);
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This trait provides native delegation methods for hash references.
|
||||
|
||||
=head1 PROVIDED METHODS
|
||||
|
||||
=head2 get($key, $key2, $key3...)
|
||||
|
||||
Returns values from the hash.
|
||||
|
||||
In list context it returns a list of values in the hash for the given keys. In
|
||||
scalar context it returns the value for the last key specified.
|
||||
|
||||
This method requires at least one argument.
|
||||
|
||||
=head2 set($key =E<gt> $value, $key2 =E<gt> $value2...)
|
||||
|
||||
Sets the elements in the hash to the given values. It returns the new values
|
||||
set for each key, in the same order as the keys passed to the method.
|
||||
|
||||
This method requires at least two arguments, and expects an even number of
|
||||
arguments.
|
||||
|
||||
=head2 delete($key, $key2, $key3...)
|
||||
|
||||
Removes the elements with the given keys.
|
||||
|
||||
In list context it returns a list of values in the hash for the deleted
|
||||
keys. In scalar context it returns the value for the last key specified.
|
||||
|
||||
=head2 keys
|
||||
|
||||
Returns the list of keys in the hash.
|
||||
|
||||
This method does not accept any arguments.
|
||||
|
||||
=head2 exists($key)
|
||||
|
||||
Returns true if the given key is present in the hash.
|
||||
|
||||
This method requires a single argument.
|
||||
|
||||
=head2 defined($key)
|
||||
|
||||
Returns true if the value of a given key is defined.
|
||||
|
||||
This method requires a single argument.
|
||||
|
||||
=head2 values
|
||||
|
||||
Returns the list of values in the hash.
|
||||
|
||||
This method does not accept any arguments.
|
||||
|
||||
=head2 kv
|
||||
|
||||
Returns the key/value pairs in the hash as an array of array references.
|
||||
|
||||
for my $pair ( $object->option_pairs ) {
|
||||
print "$pair->[0] = $pair->[1]\n";
|
||||
}
|
||||
|
||||
This method does not accept any arguments.
|
||||
|
||||
=head2 elements
|
||||
|
||||
In list context, this returns the key/value pairs in the hash.
|
||||
|
||||
In scalar context, this returns the count of keys plus values. In other words,
|
||||
it's the same as L<keys> times two.
|
||||
|
||||
This method does not accept any arguments.
|
||||
|
||||
=head2 clear
|
||||
|
||||
Resets the hash to an empty value, like C<%hash = ()>.
|
||||
|
||||
This method does not accept any arguments.
|
||||
|
||||
=head2 count
|
||||
|
||||
Returns the number of elements in the hash. Also useful to check for a nonempty hash, because C<count> returns a true (nonzero) value if there is something in the hash:
|
||||
C<< has_options => 'count' >>.
|
||||
|
||||
This method does not accept any arguments.
|
||||
|
||||
=head2 is_empty
|
||||
|
||||
If the hash is populated, returns false. Otherwise, returns true.
|
||||
|
||||
This method does not accept any arguments.
|
||||
|
||||
=head2 accessor($key)
|
||||
|
||||
=head2 accessor($key, $value)
|
||||
|
||||
If passed one argument, returns the value of the specified key. If passed two
|
||||
arguments, sets the value of the specified key.
|
||||
|
||||
When called as a setter, this method returns the value that was set.
|
||||
|
||||
=head2 shallow_clone
|
||||
|
||||
This method returns a shallow clone of the hash reference. The return value
|
||||
is a reference to a new hash with the same keys and values. It is I<shallow>
|
||||
because any values that were references in the original will be the I<same>
|
||||
references in the clone.
|
||||
|
||||
=head2 Why no C<each>?
|
||||
|
||||
We have deliberately omitted a method for C<each>, due to its stateful
|
||||
interaction with the hash iterator. Using C<keys> or C<kv> is much safer.
|
||||
|
||||
=head2 Moose::Meta::Attribute->meta
|
||||
|
||||
This will return a L<Class::MOP::Class> instance for this class.
|
||||
|
||||
It should also be noted that L<Class::MOP> will actually bootstrap
|
||||
this module by installing a number of attribute meta-objects into its
|
||||
metaclass.
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
See L<Moose/BUGS> for details on reporting bugs.
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
=over 4
|
||||
|
||||
=item *
|
||||
|
||||
Stevan Little <stevan@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Dave Rolsky <autarch@urth.org>
|
||||
|
||||
=item *
|
||||
|
||||
Jesse Luehrs <doy@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Shawn M Moore <sartak@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
|
||||
|
||||
=item *
|
||||
|
||||
Karen Etheridge <ether@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Florian Ragwitz <rafl@debian.org>
|
||||
|
||||
=item *
|
||||
|
||||
Hans Dieter Pearcey <hdp@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Chris Prather <chris@prather.org>
|
||||
|
||||
=item *
|
||||
|
||||
Matt S Trout <mstrout@cpan.org>
|
||||
|
||||
=back
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2006 by Infinity Interactive, Inc.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
155
CPAN/Moose/Meta/Attribute/Native/Trait/Number.pm
Normal file
155
CPAN/Moose/Meta/Attribute/Native/Trait/Number.pm
Normal file
@@ -0,0 +1,155 @@
|
||||
package Moose::Meta::Attribute::Native::Trait::Number;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use Moose::Role;
|
||||
with 'Moose::Meta::Attribute::Native::Trait';
|
||||
|
||||
sub _helper_type { 'Num' }
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
|
||||
# ABSTRACT: Helper trait for Num attributes
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Moose::Meta::Attribute::Native::Trait::Number - Helper trait for Num attributes
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 2.2207
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
package Real;
|
||||
use Moose;
|
||||
|
||||
has 'integer' => (
|
||||
traits => ['Number'],
|
||||
is => 'ro',
|
||||
isa => 'Num',
|
||||
default => 5,
|
||||
handles => {
|
||||
set => 'set',
|
||||
add => 'add',
|
||||
sub => 'sub',
|
||||
mul => 'mul',
|
||||
div => 'div',
|
||||
mod => 'mod',
|
||||
abs => 'abs',
|
||||
},
|
||||
);
|
||||
|
||||
my $real = Real->new();
|
||||
$real->add(5); # same as $real->integer($real->integer + 5);
|
||||
$real->sub(2); # same as $real->integer($real->integer - 2);
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This trait provides native delegation methods for numbers. All of the
|
||||
operations correspond to arithmetic operations like addition or
|
||||
multiplication.
|
||||
|
||||
=head1 DEFAULT TYPE
|
||||
|
||||
If you don't provide an C<isa> value for your attribute, it will default to
|
||||
C<Num>.
|
||||
|
||||
=head1 PROVIDED METHODS
|
||||
|
||||
All of these methods modify the attribute's value in place. All methods return
|
||||
the new value.
|
||||
|
||||
=over 4
|
||||
|
||||
=item * B<add($value)>
|
||||
|
||||
Adds the current value of the attribute to C<$value>.
|
||||
|
||||
=item * B<sub($value)>
|
||||
|
||||
Subtracts C<$value> from the current value of the attribute.
|
||||
|
||||
=item * B<mul($value)>
|
||||
|
||||
Multiplies the current value of the attribute by C<$value>.
|
||||
|
||||
=item * B<div($value)>
|
||||
|
||||
Divides the current value of the attribute by C<$value>.
|
||||
|
||||
=item * B<mod($value)>
|
||||
|
||||
Returns the current value of the attribute modulo C<$value>.
|
||||
|
||||
=item * B<abs>
|
||||
|
||||
Sets the current value of the attribute to its absolute value.
|
||||
|
||||
=back
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
See L<Moose/BUGS> for details on reporting bugs.
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
=over 4
|
||||
|
||||
=item *
|
||||
|
||||
Stevan Little <stevan@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Dave Rolsky <autarch@urth.org>
|
||||
|
||||
=item *
|
||||
|
||||
Jesse Luehrs <doy@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Shawn M Moore <sartak@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
|
||||
|
||||
=item *
|
||||
|
||||
Karen Etheridge <ether@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Florian Ragwitz <rafl@debian.org>
|
||||
|
||||
=item *
|
||||
|
||||
Hans Dieter Pearcey <hdp@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Chris Prather <chris@prather.org>
|
||||
|
||||
=item *
|
||||
|
||||
Matt S Trout <mstrout@cpan.org>
|
||||
|
||||
=back
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2006 by Infinity Interactive, Inc.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
187
CPAN/Moose/Meta/Attribute/Native/Trait/String.pm
Normal file
187
CPAN/Moose/Meta/Attribute/Native/Trait/String.pm
Normal file
@@ -0,0 +1,187 @@
|
||||
package Moose::Meta::Attribute::Native::Trait::String;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use Moose::Role;
|
||||
with 'Moose::Meta::Attribute::Native::Trait';
|
||||
|
||||
sub _helper_type { 'Str' }
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
|
||||
# ABSTRACT: Helper trait for Str attributes
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Moose::Meta::Attribute::Native::Trait::String - Helper trait for Str attributes
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 2.2207
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
package MyHomePage;
|
||||
use Moose;
|
||||
|
||||
has 'text' => (
|
||||
traits => ['String'],
|
||||
is => 'rw',
|
||||
isa => 'Str',
|
||||
default => q{},
|
||||
handles => {
|
||||
add_text => 'append',
|
||||
replace_text => 'replace',
|
||||
},
|
||||
);
|
||||
|
||||
my $page = MyHomePage->new();
|
||||
$page->add_text("foo"); # same as $page->text($page->text . "foo");
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This trait provides native delegation methods for strings.
|
||||
|
||||
=head1 DEFAULT TYPE
|
||||
|
||||
If you don't provide an C<isa> value for your attribute, it will default to
|
||||
C<Str>.
|
||||
|
||||
=head1 PROVIDED METHODS
|
||||
|
||||
=over 4
|
||||
|
||||
=item * B<inc>
|
||||
|
||||
Increments the value stored in this slot using the magical string autoincrement
|
||||
operator. Note that Perl doesn't provide analogous behavior in C<-->, so
|
||||
C<dec> is not available. This method returns the new value.
|
||||
|
||||
This method does not accept any arguments.
|
||||
|
||||
=item * B<append($string)>
|
||||
|
||||
Appends to the string, like C<.=>, and returns the new value.
|
||||
|
||||
This method requires a single argument.
|
||||
|
||||
=item * B<prepend($string)>
|
||||
|
||||
Prepends to the string and returns the new value.
|
||||
|
||||
This method requires a single argument.
|
||||
|
||||
=item * B<replace($pattern, $replacement)>
|
||||
|
||||
Performs a regexp substitution (L<perlop/s>). There is no way to provide the
|
||||
C<g> flag, but code references will be accepted for the replacement, causing
|
||||
the regex to be modified with a single C<e>. C</smxi> can be applied using the
|
||||
C<qr> operator. This method returns the new value.
|
||||
|
||||
This method requires two arguments.
|
||||
|
||||
=item * B<match($pattern)>
|
||||
|
||||
Runs the regex against the string and returns the matching value(s).
|
||||
|
||||
This method requires a single argument.
|
||||
|
||||
=item * B<chop>
|
||||
|
||||
Just like L<perlfunc/chop>. This method returns the chopped character.
|
||||
|
||||
This method does not accept any arguments.
|
||||
|
||||
=item * B<chomp>
|
||||
|
||||
Just like L<perlfunc/chomp>. This method returns the number of characters
|
||||
removed.
|
||||
|
||||
This method does not accept any arguments.
|
||||
|
||||
=item * B<clear>
|
||||
|
||||
Sets the string to the empty string (not the value passed to C<default>).
|
||||
|
||||
This method does not have a defined return value.
|
||||
|
||||
This method does not accept any arguments.
|
||||
|
||||
=item * B<length>
|
||||
|
||||
Just like L<perlfunc/length>, returns the length of the string.
|
||||
|
||||
=item * B<substr>
|
||||
|
||||
This acts just like L<perlfunc/substr>. When called as a writer, it returns
|
||||
the substring that was replaced, just like the Perl builtin.
|
||||
|
||||
This method requires at least one argument, and accepts no more than three.
|
||||
|
||||
=back
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
See L<Moose/BUGS> for details on reporting bugs.
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
=over 4
|
||||
|
||||
=item *
|
||||
|
||||
Stevan Little <stevan@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Dave Rolsky <autarch@urth.org>
|
||||
|
||||
=item *
|
||||
|
||||
Jesse Luehrs <doy@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Shawn M Moore <sartak@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
|
||||
|
||||
=item *
|
||||
|
||||
Karen Etheridge <ether@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Florian Ragwitz <rafl@debian.org>
|
||||
|
||||
=item *
|
||||
|
||||
Hans Dieter Pearcey <hdp@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Chris Prather <chris@prather.org>
|
||||
|
||||
=item *
|
||||
|
||||
Matt S Trout <mstrout@cpan.org>
|
||||
|
||||
=back
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2006 by Infinity Interactive, Inc.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
1014
CPAN/Moose/Meta/Class.pm
Normal file
1014
CPAN/Moose/Meta/Class.pm
Normal file
File diff suppressed because it is too large
Load Diff
123
CPAN/Moose/Meta/Class/Immutable/Trait.pm
Normal file
123
CPAN/Moose/Meta/Class/Immutable/Trait.pm
Normal file
@@ -0,0 +1,123 @@
|
||||
package Moose::Meta::Class::Immutable::Trait;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Class::MOP;
|
||||
use Scalar::Util qw( blessed );
|
||||
|
||||
use parent 'Class::MOP::Class::Immutable::Trait';
|
||||
|
||||
use Moose::Util 'throw_exception';
|
||||
|
||||
sub add_role { $_[1]->_immutable_cannot_call }
|
||||
|
||||
sub calculate_all_roles {
|
||||
my $orig = shift;
|
||||
my $self = shift;
|
||||
@{ $self->{__immutable}{calculate_all_roles} ||= [ $self->$orig ] };
|
||||
}
|
||||
|
||||
sub calculate_all_roles_with_inheritance {
|
||||
my $orig = shift;
|
||||
my $self = shift;
|
||||
@{ $self->{__immutable}{calculate_all_roles_with_inheritance} ||= [ $self->$orig ] };
|
||||
}
|
||||
|
||||
sub does_role {
|
||||
shift;
|
||||
my $self = shift;
|
||||
my $role = shift;
|
||||
|
||||
(defined $role)
|
||||
|| throw_exception( RoleNameRequired => class_name => $self->name );
|
||||
|
||||
$self->{__immutable}{does_role} ||= { map { $_->name => 1 } $self->calculate_all_roles_with_inheritance };
|
||||
|
||||
my $name = blessed $role ? $role->name : $role;
|
||||
|
||||
return $self->{__immutable}{does_role}{$name};
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
# ABSTRACT: Implements immutability for metaclass objects
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Moose::Meta::Class::Immutable::Trait - Implements immutability for metaclass objects
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 2.2207
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This class makes some Moose-specific metaclass methods immutable. This
|
||||
is deep guts.
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
See L<Moose/BUGS> for details on reporting bugs.
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
=over 4
|
||||
|
||||
=item *
|
||||
|
||||
Stevan Little <stevan@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Dave Rolsky <autarch@urth.org>
|
||||
|
||||
=item *
|
||||
|
||||
Jesse Luehrs <doy@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Shawn M Moore <sartak@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
|
||||
|
||||
=item *
|
||||
|
||||
Karen Etheridge <ether@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Florian Ragwitz <rafl@debian.org>
|
||||
|
||||
=item *
|
||||
|
||||
Hans Dieter Pearcey <hdp@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Chris Prather <chris@prather.org>
|
||||
|
||||
=item *
|
||||
|
||||
Matt S Trout <mstrout@cpan.org>
|
||||
|
||||
=back
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2006 by Infinity Interactive, Inc.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
109
CPAN/Moose/Meta/Instance.pm
Normal file
109
CPAN/Moose/Meta/Instance.pm
Normal file
@@ -0,0 +1,109 @@
|
||||
package Moose::Meta::Instance;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Class::MOP::MiniTrait;
|
||||
|
||||
use parent 'Class::MOP::Instance';
|
||||
|
||||
Class::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait');
|
||||
|
||||
1;
|
||||
|
||||
# ABSTRACT: The Moose Instance metaclass
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Moose::Meta::Instance - The Moose Instance metaclass
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 2.2207
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
# nothing to see here
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This class provides the low level data storage abstractions for
|
||||
attributes.
|
||||
|
||||
Using this API directly in your own code violates encapsulation, and
|
||||
we recommend that you use the appropriate APIs in
|
||||
L<Moose::Meta::Class> and L<Moose::Meta::Attribute> instead. Those
|
||||
APIs in turn call the methods in this class as appropriate.
|
||||
|
||||
At present, this is an empty subclass of L<Class::MOP::Instance>, so
|
||||
you should see that class for all API details.
|
||||
|
||||
=head1 INHERITANCE
|
||||
|
||||
C<Moose::Meta::Instance> is a subclass of L<Class::MOP::Instance>.
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
See L<Moose/BUGS> for details on reporting bugs.
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
=over 4
|
||||
|
||||
=item *
|
||||
|
||||
Stevan Little <stevan@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Dave Rolsky <autarch@urth.org>
|
||||
|
||||
=item *
|
||||
|
||||
Jesse Luehrs <doy@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Shawn M Moore <sartak@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
|
||||
|
||||
=item *
|
||||
|
||||
Karen Etheridge <ether@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Florian Ragwitz <rafl@debian.org>
|
||||
|
||||
=item *
|
||||
|
||||
Hans Dieter Pearcey <hdp@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Chris Prather <chris@prather.org>
|
||||
|
||||
=item *
|
||||
|
||||
Matt S Trout <mstrout@cpan.org>
|
||||
|
||||
=back
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2006 by Infinity Interactive, Inc.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
100
CPAN/Moose/Meta/Method.pm
Normal file
100
CPAN/Moose/Meta/Method.pm
Normal file
@@ -0,0 +1,100 @@
|
||||
package Moose::Meta::Method;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Class::MOP::MiniTrait;
|
||||
|
||||
use parent 'Class::MOP::Method';
|
||||
|
||||
Class::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait');
|
||||
|
||||
1;
|
||||
|
||||
# ABSTRACT: A Moose Method metaclass
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Moose::Meta::Method - A Moose Method metaclass
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 2.2207
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This class is a subclass of L<Class::MOP::Method> that provides
|
||||
additional Moose-specific functionality, all of which is private.
|
||||
|
||||
To understand this class, you should read the L<Class::MOP::Method>
|
||||
documentation.
|
||||
|
||||
=head1 INHERITANCE
|
||||
|
||||
C<Moose::Meta::Method> is a subclass of L<Class::MOP::Method>.
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
See L<Moose/BUGS> for details on reporting bugs.
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
=over 4
|
||||
|
||||
=item *
|
||||
|
||||
Stevan Little <stevan@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Dave Rolsky <autarch@urth.org>
|
||||
|
||||
=item *
|
||||
|
||||
Jesse Luehrs <doy@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Shawn M Moore <sartak@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
|
||||
|
||||
=item *
|
||||
|
||||
Karen Etheridge <ether@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Florian Ragwitz <rafl@debian.org>
|
||||
|
||||
=item *
|
||||
|
||||
Hans Dieter Pearcey <hdp@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Chris Prather <chris@prather.org>
|
||||
|
||||
=item *
|
||||
|
||||
Matt S Trout <mstrout@cpan.org>
|
||||
|
||||
=back
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2006 by Infinity Interactive, Inc.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
208
CPAN/Moose/Meta/Method/Accessor.pm
Normal file
208
CPAN/Moose/Meta/Method/Accessor.pm
Normal file
@@ -0,0 +1,208 @@
|
||||
package Moose::Meta::Method::Accessor;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Try::Tiny;
|
||||
|
||||
use parent 'Moose::Meta::Method',
|
||||
'Class::MOP::Method::Accessor';
|
||||
|
||||
use Moose::Util 'throw_exception';
|
||||
|
||||
# multiple inheritance is terrible
|
||||
sub new {
|
||||
goto &Class::MOP::Method::Accessor::new;
|
||||
}
|
||||
|
||||
sub _new {
|
||||
goto &Class::MOP::Method::Accessor::_new;
|
||||
}
|
||||
|
||||
sub _error_thrower {
|
||||
my $self = shift;
|
||||
return $self->associated_attribute
|
||||
if ref($self) && defined($self->associated_attribute);
|
||||
return $self->SUPER::_error_thrower;
|
||||
}
|
||||
|
||||
sub _compile_code {
|
||||
my $self = shift;
|
||||
my @args = @_;
|
||||
try {
|
||||
$self->SUPER::_compile_code(@args);
|
||||
}
|
||||
catch {
|
||||
throw_exception( CouldNotCreateWriter => attribute => $self->associated_attribute,
|
||||
error => $_,
|
||||
instance => $self
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
sub _eval_environment {
|
||||
my $self = shift;
|
||||
return $self->associated_attribute->_eval_environment;
|
||||
}
|
||||
|
||||
sub _instance_is_inlinable {
|
||||
my $self = shift;
|
||||
return $self->associated_attribute->associated_class->instance_metaclass->is_inlinable;
|
||||
}
|
||||
|
||||
sub _generate_reader_method {
|
||||
my $self = shift;
|
||||
$self->_instance_is_inlinable ? $self->_generate_reader_method_inline(@_)
|
||||
: $self->SUPER::_generate_reader_method(@_);
|
||||
}
|
||||
|
||||
sub _generate_writer_method {
|
||||
my $self = shift;
|
||||
$self->_instance_is_inlinable ? $self->_generate_writer_method_inline(@_)
|
||||
: $self->SUPER::_generate_writer_method(@_);
|
||||
}
|
||||
|
||||
sub _generate_accessor_method {
|
||||
my $self = shift;
|
||||
$self->_instance_is_inlinable ? $self->_generate_accessor_method_inline(@_)
|
||||
: $self->SUPER::_generate_accessor_method(@_);
|
||||
}
|
||||
|
||||
sub _generate_predicate_method {
|
||||
my $self = shift;
|
||||
$self->_instance_is_inlinable ? $self->_generate_predicate_method_inline(@_)
|
||||
: $self->SUPER::_generate_predicate_method(@_);
|
||||
}
|
||||
|
||||
sub _generate_clearer_method {
|
||||
my $self = shift;
|
||||
$self->_instance_is_inlinable ? $self->_generate_clearer_method_inline(@_)
|
||||
: $self->SUPER::_generate_clearer_method(@_);
|
||||
}
|
||||
|
||||
sub _writer_value_needs_copy {
|
||||
shift->associated_attribute->_writer_value_needs_copy(@_);
|
||||
}
|
||||
|
||||
sub _inline_tc_code {
|
||||
shift->associated_attribute->_inline_tc_code(@_);
|
||||
}
|
||||
|
||||
sub _inline_check_coercion {
|
||||
shift->associated_attribute->_inline_check_coercion(@_);
|
||||
}
|
||||
|
||||
sub _inline_check_constraint {
|
||||
shift->associated_attribute->_inline_check_constraint(@_);
|
||||
}
|
||||
|
||||
sub _inline_check_lazy {
|
||||
shift->associated_attribute->_inline_check_lazy(@_);
|
||||
}
|
||||
|
||||
sub _inline_store_value {
|
||||
shift->associated_attribute->_inline_instance_set(@_) . ';';
|
||||
}
|
||||
|
||||
sub _inline_get_old_value_for_trigger {
|
||||
shift->associated_attribute->_inline_get_old_value_for_trigger(@_);
|
||||
}
|
||||
|
||||
sub _inline_trigger {
|
||||
shift->associated_attribute->_inline_trigger(@_);
|
||||
}
|
||||
|
||||
sub _get_value {
|
||||
shift->associated_attribute->_inline_instance_get(@_);
|
||||
}
|
||||
|
||||
sub _has_value {
|
||||
shift->associated_attribute->_inline_instance_has(@_);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
# ABSTRACT: A Moose Method metaclass for accessors
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Moose::Meta::Method::Accessor - A Moose Method metaclass for accessors
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 2.2207
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This class is a subclass of L<Class::MOP::Method::Accessor> that
|
||||
provides additional Moose-specific functionality, all of which is
|
||||
private.
|
||||
|
||||
To understand this class, you should read the
|
||||
L<Class::MOP::Method::Accessor> documentation.
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
See L<Moose/BUGS> for details on reporting bugs.
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
=over 4
|
||||
|
||||
=item *
|
||||
|
||||
Stevan Little <stevan@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Dave Rolsky <autarch@urth.org>
|
||||
|
||||
=item *
|
||||
|
||||
Jesse Luehrs <doy@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Shawn M Moore <sartak@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
|
||||
|
||||
=item *
|
||||
|
||||
Karen Etheridge <ether@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Florian Ragwitz <rafl@debian.org>
|
||||
|
||||
=item *
|
||||
|
||||
Hans Dieter Pearcey <hdp@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Chris Prather <chris@prather.org>
|
||||
|
||||
=item *
|
||||
|
||||
Matt S Trout <mstrout@cpan.org>
|
||||
|
||||
=back
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2006 by Infinity Interactive, Inc.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
157
CPAN/Moose/Meta/Method/Accessor/Native.pm
Normal file
157
CPAN/Moose/Meta/Method/Accessor/Native.pm
Normal file
@@ -0,0 +1,157 @@
|
||||
package Moose::Meta::Method::Accessor::Native;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Carp qw( confess );
|
||||
use Scalar::Util qw( blessed );
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
use Moose::Util 'throw_exception';
|
||||
|
||||
around new => sub {
|
||||
my $orig = shift;
|
||||
my $class = shift;
|
||||
my %options = @_;
|
||||
|
||||
$options{curried_arguments} = []
|
||||
unless exists $options{curried_arguments};
|
||||
|
||||
throw_exception( MustSupplyArrayRefAsCurriedArguments => params => \%options,
|
||||
class_name => $class
|
||||
)
|
||||
unless $options{curried_arguments}
|
||||
&& ref($options{curried_arguments}) eq 'ARRAY';
|
||||
|
||||
my $attr_context = $options{attribute}->definition_context;
|
||||
my $desc = 'native delegation method ';
|
||||
$desc .= $options{attribute}->associated_class->name;
|
||||
$desc .= '::' . $options{name};
|
||||
$desc .= " ($options{delegate_to_method})";
|
||||
$desc .= " of attribute " . $options{attribute}->name;
|
||||
$options{definition_context} = {
|
||||
%{ $attr_context || {} },
|
||||
description => $desc,
|
||||
};
|
||||
|
||||
$options{accessor_type} = 'native';
|
||||
|
||||
return $class->$orig(%options);
|
||||
};
|
||||
|
||||
sub _new {
|
||||
my $class = shift;
|
||||
my $options = @_ == 1 ? $_[0] : {@_};
|
||||
|
||||
return bless $options, $class;
|
||||
}
|
||||
|
||||
sub root_types { (shift)->{'root_types'} }
|
||||
|
||||
sub _initialize_body {
|
||||
my $self = shift;
|
||||
|
||||
$self->{'body'} = $self->_compile_code( [$self->_generate_method] );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
sub _inline_curried_arguments {
|
||||
my $self = shift;
|
||||
|
||||
return unless @{ $self->curried_arguments };
|
||||
|
||||
return 'unshift @_, @curried;';
|
||||
}
|
||||
|
||||
sub _inline_check_argument_count {
|
||||
my $self = shift;
|
||||
|
||||
my @code;
|
||||
|
||||
if (my $min = $self->_minimum_arguments) {
|
||||
push @code, (
|
||||
'if (@_ < ' . $min . ') {',
|
||||
$self->_inline_throw_exception( MethodExpectsMoreArgs =>
|
||||
'method_name => "'.$self->delegate_to_method.'",'.
|
||||
"minimum_args => ".$min,
|
||||
) . ';',
|
||||
'}',
|
||||
);
|
||||
}
|
||||
|
||||
if (defined(my $max = $self->_maximum_arguments)) {
|
||||
push @code, (
|
||||
'if (@_ > ' . $max . ') {',
|
||||
$self->_inline_throw_exception( MethodExpectsFewerArgs =>
|
||||
'method_name => "'.$self->delegate_to_method.'",'.
|
||||
'maximum_args => '.$max,
|
||||
) . ';',
|
||||
'}',
|
||||
);
|
||||
}
|
||||
|
||||
return @code;
|
||||
}
|
||||
|
||||
sub _inline_return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access, $for_writer) = @_;
|
||||
|
||||
return 'return ' . $self->_return_value($slot_access, $for_writer) . ';';
|
||||
}
|
||||
|
||||
sub _minimum_arguments { 0 }
|
||||
sub _maximum_arguments { undef }
|
||||
|
||||
override _get_value => sub {
|
||||
my $self = shift;
|
||||
my ($instance) = @_;
|
||||
|
||||
return $self->_slot_access_can_be_inlined
|
||||
? super()
|
||||
: $instance . '->$reader';
|
||||
};
|
||||
|
||||
override _inline_store_value => sub {
|
||||
my $self = shift;
|
||||
my ($instance, $value) = @_;
|
||||
|
||||
return $self->_slot_access_can_be_inlined
|
||||
? super()
|
||||
: $instance . '->$writer(' . $value . ');';
|
||||
};
|
||||
|
||||
override _eval_environment => sub {
|
||||
my $self = shift;
|
||||
|
||||
my $env = super();
|
||||
|
||||
$env->{'@curried'} = $self->curried_arguments;
|
||||
|
||||
return $env if $self->_slot_access_can_be_inlined;
|
||||
|
||||
my $reader = $self->associated_attribute->get_read_method_ref;
|
||||
$reader = $reader->body if blessed $reader;
|
||||
|
||||
$env->{'$reader'} = \$reader;
|
||||
|
||||
my $writer = $self->associated_attribute->get_write_method_ref;
|
||||
$writer = $writer->body if blessed $writer;
|
||||
|
||||
$env->{'$writer'} = \$writer;
|
||||
|
||||
return $env;
|
||||
};
|
||||
|
||||
sub _slot_access_can_be_inlined {
|
||||
my $self = shift;
|
||||
|
||||
return $self->is_inline && $self->_instance_is_inlinable;
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
28
CPAN/Moose/Meta/Method/Accessor/Native/Array.pm
Normal file
28
CPAN/Moose/Meta/Method/Accessor/Native/Array.pm
Normal file
@@ -0,0 +1,28 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Array;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
sub _inline_check_var_is_valid_index {
|
||||
my $self = shift;
|
||||
my ($var) = @_;
|
||||
|
||||
return (
|
||||
'if (!defined(' . $var . ') || ' . $var . ' !~ /^-?\d+$/) {',
|
||||
$self->_inline_throw_exception( InvalidArgumentToMethod =>
|
||||
'argument => '.$var.','.
|
||||
'method_name => "'.$self->delegate_to_method.'",'.
|
||||
'type_of_argument => "integer",'.
|
||||
'type => "Int",'.
|
||||
'argument_noun => "index"',
|
||||
) . ';',
|
||||
'}',
|
||||
);
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
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;
|
||||
20
CPAN/Moose/Meta/Method/Accessor/Native/Bool/not.pm
Normal file
20
CPAN/Moose/Meta/Method/Accessor/Native/Bool/not.pm
Normal file
@@ -0,0 +1,20 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Bool::not;
|
||||
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;
|
||||
}
|
||||
|
||||
1;
|
||||
24
CPAN/Moose/Meta/Method/Accessor/Native/Bool/set.pm
Normal file
24
CPAN/Moose/Meta/Method/Accessor/Native/Bool/set.pm
Normal file
@@ -0,0 +1,24 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Bool::set;
|
||||
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 { 1 }
|
||||
|
||||
sub _inline_optimized_set_new_value {
|
||||
my $self = shift;
|
||||
my ($inv, $new, $slot_access) = @_;
|
||||
|
||||
return $slot_access . ' = 1;';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
29
CPAN/Moose/Meta/Method/Accessor/Native/Bool/toggle.pm
Normal file
29
CPAN/Moose/Meta/Method/Accessor/Native/Bool/toggle.pm
Normal file
@@ -0,0 +1,29 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Bool::toggle;
|
||||
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 $slot_access . ' ? 0 : 1';
|
||||
}
|
||||
|
||||
sub _inline_optimized_set_new_value {
|
||||
my $self = shift;
|
||||
my ($inv, $new, $slot_access) = @_;
|
||||
|
||||
return $slot_access . ' = ' . $slot_access . ' ? 0 : 1;';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
24
CPAN/Moose/Meta/Method/Accessor/Native/Bool/unset.pm
Normal file
24
CPAN/Moose/Meta/Method/Accessor/Native/Bool/unset.pm
Normal file
@@ -0,0 +1,24 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Bool::unset;
|
||||
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 { 0 }
|
||||
|
||||
sub _inline_optimized_set_new_value {
|
||||
my $self = shift;
|
||||
my ($inv, $new, $slot_access) = @_;
|
||||
|
||||
return $slot_access . ' = 0;';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
20
CPAN/Moose/Meta/Method/Accessor/Native/Code/execute.pm
Normal file
20
CPAN/Moose/Meta/Method/Accessor/Native/Code/execute.pm
Normal file
@@ -0,0 +1,20 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Code::execute;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Reader';
|
||||
|
||||
sub _return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return $slot_access . '->(@_)';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
@@ -0,0 +1,20 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Code::execute_method;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Reader';
|
||||
|
||||
sub _return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return $slot_access . '->($self, @_)';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
167
CPAN/Moose/Meta/Method/Accessor/Native/Collection.pm
Normal file
167
CPAN/Moose/Meta/Method/Accessor/Native/Collection.pm
Normal file
@@ -0,0 +1,167 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Collection;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
requires qw( _adds_members _new_members );
|
||||
|
||||
sub _inline_coerce_new_values {
|
||||
my $self = shift;
|
||||
|
||||
return unless $self->associated_attribute->should_coerce;
|
||||
|
||||
return unless $self->_tc_member_type_can_coerce;
|
||||
|
||||
return (
|
||||
'(' . $self->_new_members . ') = map { $member_coercion->($_) }',
|
||||
$self->_new_members . ';',
|
||||
);
|
||||
}
|
||||
|
||||
sub _tc_member_type_can_coerce {
|
||||
my $self = shift;
|
||||
|
||||
my $member_tc = $self->_tc_member_type;
|
||||
|
||||
return $member_tc && $member_tc->has_coercion;
|
||||
}
|
||||
|
||||
sub _tc_member_type {
|
||||
my $self = shift;
|
||||
|
||||
my $tc = $self->associated_attribute->type_constraint;
|
||||
while ($tc) {
|
||||
return $tc->type_parameter
|
||||
if $tc->can('type_parameter');
|
||||
$tc = $tc->parent;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
sub _writer_value_needs_copy {
|
||||
my $self = shift;
|
||||
|
||||
return $self->_constraint_must_be_checked
|
||||
&& !$self->_check_new_members_only;
|
||||
}
|
||||
|
||||
sub _inline_tc_code {
|
||||
my $self = shift;
|
||||
my ($value, $tc, $coercion, $message, $is_lazy) = @_;
|
||||
|
||||
return unless $self->_constraint_must_be_checked;
|
||||
|
||||
if ($self->_check_new_members_only) {
|
||||
return unless $self->_adds_members;
|
||||
|
||||
return $self->_inline_check_member_constraint($self->_new_members);
|
||||
}
|
||||
else {
|
||||
return (
|
||||
$self->_inline_check_coercion($value, $tc, $coercion, $is_lazy),
|
||||
$self->_inline_check_constraint($value, $tc, $message, $is_lazy),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
sub _check_new_members_only {
|
||||
my $self = shift;
|
||||
|
||||
my $attr = $self->associated_attribute;
|
||||
|
||||
my $tc = $attr->type_constraint;
|
||||
|
||||
# If we have a coercion, we could come up with an entirely new value after
|
||||
# coercing, so we need to check everything,
|
||||
return 0 if $attr->should_coerce && $tc->has_coercion;
|
||||
|
||||
# If the parent is our root type (ArrayRef, HashRef, etc), that means we
|
||||
# can just check the new members of the collection, because we know that
|
||||
# we will always be generating an appropriate collection type.
|
||||
#
|
||||
# However, if this type has its own constraint (it's Parameteriz_able_,
|
||||
# not Paramet_erized_), we don't know what is being checked by the
|
||||
# constraint, so we need to check the whole value, not just the members.
|
||||
return 1
|
||||
if $self->_is_root_type( $tc->parent )
|
||||
&& ( $tc->isa('Moose::Meta::TypeConstraint::Parameterized')
|
||||
|| !$tc->can('parameterize') );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub _inline_check_member_constraint {
|
||||
my $self = shift;
|
||||
my ($new_value) = @_;
|
||||
|
||||
my $attr_name = $self->associated_attribute->name;
|
||||
|
||||
my $check
|
||||
= $self->_tc_member_type->can_be_inlined
|
||||
? '! (' . $self->_tc_member_type->_inline_check('$new_val') . ')'
|
||||
: ' !$member_tc->($new_val) ';
|
||||
|
||||
return (
|
||||
'for my $new_val (' . $new_value . ') {',
|
||||
"if ($check) {",
|
||||
'my $msg = do { local $_ = $new_val; $member_message->($new_val) };'.
|
||||
$self->_inline_throw_exception( ValidationFailedForInlineTypeConstraint =>
|
||||
"attribute_name => '".$attr_name."',".
|
||||
'type_constraint_message => $msg,'.
|
||||
'class_name => $class_name,'.
|
||||
'value => $new_val,'.
|
||||
'new_member => 1',
|
||||
) . ';',
|
||||
'}',
|
||||
'}',
|
||||
);
|
||||
}
|
||||
|
||||
sub _inline_get_old_value_for_trigger {
|
||||
my $self = shift;
|
||||
my ($instance, $old) = @_;
|
||||
|
||||
my $attr = $self->associated_attribute;
|
||||
return unless $attr->has_trigger;
|
||||
|
||||
return (
|
||||
'my ' . $old . ' = ' . $self->_has_value($instance),
|
||||
'? ' . $self->_copy_old_value($self->_get_value($instance)),
|
||||
': ();',
|
||||
);
|
||||
}
|
||||
|
||||
around _eval_environment => sub {
|
||||
my $orig = shift;
|
||||
my $self = shift;
|
||||
|
||||
my $env = $self->$orig(@_);
|
||||
|
||||
my $member_tc = $self->_tc_member_type;
|
||||
|
||||
return $env unless $member_tc;
|
||||
|
||||
$env->{'$member_tc'} = \( $member_tc->_compiled_type_constraint );
|
||||
$env->{'$member_coercion'} = \(
|
||||
$member_tc->coercion->_compiled_type_coercion
|
||||
) if $member_tc->has_coercion;
|
||||
$env->{'$member_message'} = \(
|
||||
$member_tc->has_message
|
||||
? $member_tc->message
|
||||
: $member_tc->_default_message
|
||||
);
|
||||
|
||||
my $tc_env = $member_tc->inline_environment();
|
||||
|
||||
$env = { %{$env}, %{$tc_env} };
|
||||
|
||||
return $env;
|
||||
};
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
24
CPAN/Moose/Meta/Method/Accessor/Native/Counter/Writer.pm
Normal file
24
CPAN/Moose/Meta/Method/Accessor/Native/Counter/Writer.pm
Normal file
@@ -0,0 +1,24 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Counter::Writer;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Writer';
|
||||
|
||||
sub _constraint_must_be_checked {
|
||||
my $self = shift;
|
||||
|
||||
my $attr = $self->associated_attribute;
|
||||
|
||||
return $attr->has_type_constraint
|
||||
&& ($attr->type_constraint->name =~ /^(?:Num|Int)$/
|
||||
|| ($attr->should_coerce && $attr->type_constraint->has_coercion)
|
||||
);
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
30
CPAN/Moose/Meta/Method/Accessor/Native/Counter/dec.pm
Normal file
30
CPAN/Moose/Meta/Method/Accessor/Native/Counter/dec.pm
Normal file
@@ -0,0 +1,30 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Counter::dec;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Writer';
|
||||
|
||||
sub _minimum_arguments { 0 }
|
||||
sub _maximum_arguments { 1 }
|
||||
|
||||
sub _potential_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return $slot_access . ' - (defined $_[0] ? $_[0] : 1)';
|
||||
}
|
||||
|
||||
sub _inline_optimized_set_new_value {
|
||||
my $self = shift;
|
||||
my ($inv, $new, $slot_access) = @_;
|
||||
|
||||
return $slot_access . ' -= defined $_[0] ? $_[0] : 1;';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
30
CPAN/Moose/Meta/Method/Accessor/Native/Counter/inc.pm
Normal file
30
CPAN/Moose/Meta/Method/Accessor/Native/Counter/inc.pm
Normal file
@@ -0,0 +1,30 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Counter::inc;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Writer';
|
||||
|
||||
sub _minimum_arguments { 0 }
|
||||
sub _maximum_arguments { 1 }
|
||||
|
||||
sub _potential_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return $slot_access . ' + (defined $_[0] ? $_[0] : 1)';
|
||||
}
|
||||
|
||||
sub _inline_optimized_set_new_value {
|
||||
my $self = shift;
|
||||
my ($inv, $new, $slot_access) = @_;
|
||||
|
||||
return $slot_access . ' += defined $_[0] ? $_[0] : 1;';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
36
CPAN/Moose/Meta/Method/Accessor/Native/Counter/reset.pm
Normal file
36
CPAN/Moose/Meta/Method/Accessor/Native/Counter/reset.pm
Normal file
@@ -0,0 +1,36 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Counter::reset;
|
||||
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) = @_;
|
||||
|
||||
my $attr = $self->associated_attribute;
|
||||
|
||||
return '(do { '
|
||||
. join(' ', $attr->_inline_generate_default(
|
||||
'$self', '$default_for_reset'
|
||||
)) . ' '
|
||||
. '$default_for_reset; '
|
||||
. '})';
|
||||
}
|
||||
|
||||
sub _inline_optimized_set_new_value {
|
||||
my $self = shift;
|
||||
my ($inv, $new, $slot_access) = @_;
|
||||
|
||||
return $slot_access . ' = ' . $self->_potential_value . ';';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
25
CPAN/Moose/Meta/Method/Accessor/Native/Counter/set.pm
Normal file
25
CPAN/Moose/Meta/Method/Accessor/Native/Counter/set.pm
Normal file
@@ -0,0 +1,25 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Counter::set;
|
||||
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 { '$_[0]' }
|
||||
|
||||
sub _inline_optimized_set_new_value {
|
||||
my $self = shift;
|
||||
my ($inv, $new, $slot_access) = @_;
|
||||
|
||||
return $slot_access . ' = $_[0];';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
28
CPAN/Moose/Meta/Method/Accessor/Native/Hash.pm
Normal file
28
CPAN/Moose/Meta/Method/Accessor/Native/Hash.pm
Normal file
@@ -0,0 +1,28 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Hash;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
sub _inline_check_var_is_valid_key {
|
||||
my $self = shift;
|
||||
my ($var) = @_;
|
||||
|
||||
return (
|
||||
'if (!defined(' . $var . ')) {',
|
||||
$self->_inline_throw_exception( InvalidArgumentToMethod =>
|
||||
'argument => '.$var.','.
|
||||
'method_name => "'.$self->delegate_to_method.'",'.
|
||||
'type_of_argument => "defined value",'.
|
||||
'type => "Defined",'.
|
||||
'argument_noun => "key"',
|
||||
) . ';',
|
||||
'}',
|
||||
);
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
41
CPAN/Moose/Meta/Method/Accessor/Native/Hash/Writer.pm
Normal file
41
CPAN/Moose/Meta/Method/Accessor/Native/Hash/Writer.pm
Normal file
@@ -0,0 +1,41 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Hash::Writer;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Class::MOP::MiniTrait;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Writer',
|
||||
'Moose::Meta::Method::Accessor::Native::Hash',
|
||||
'Moose::Meta::Method::Accessor::Native::Collection';
|
||||
|
||||
sub _inline_coerce_new_values {
|
||||
my $self = shift;
|
||||
|
||||
return unless $self->associated_attribute->should_coerce;
|
||||
|
||||
return unless $self->_tc_member_type_can_coerce;
|
||||
|
||||
return <<'EOF';
|
||||
if (@_) {
|
||||
my %h = @_;
|
||||
@h{ sort keys %h } = map { $member_coercion->($_) } @h{ sort keys %h };
|
||||
}
|
||||
EOF
|
||||
}
|
||||
|
||||
sub _new_members { 'values %{ { @_ } }' }
|
||||
|
||||
sub _copy_old_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return '{ %{ (' . $slot_access . ') } }';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
61
CPAN/Moose/Meta/Method/Accessor/Native/Hash/accessor.pm
Normal file
61
CPAN/Moose/Meta/Method/Accessor/Native/Hash/accessor.pm
Normal file
@@ -0,0 +1,61 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Hash::accessor;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Hash::set',
|
||||
'Moose::Meta::Method::Accessor::Native::Hash::get';
|
||||
|
||||
sub _inline_process_arguments {
|
||||
my $self = shift;
|
||||
$self->Moose::Meta::Method::Accessor::Native::Hash::set::_inline_process_arguments(@_);
|
||||
}
|
||||
|
||||
sub _inline_check_argument_count {
|
||||
my $self = shift;
|
||||
$self->Moose::Meta::Method::Accessor::Native::Hash::set::_inline_check_argument_count(@_);
|
||||
}
|
||||
|
||||
sub _inline_check_arguments {
|
||||
my $self = shift;
|
||||
$self->Moose::Meta::Method::Accessor::Native::Hash::set::_inline_check_arguments(@_);
|
||||
}
|
||||
|
||||
sub _return_value {
|
||||
my $self = shift;
|
||||
$self->Moose::Meta::Method::Accessor::Native::Hash::set::_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_key('$_[0]'),
|
||||
$slot_access . '->{$_[0]}',
|
||||
'}',
|
||||
# set
|
||||
'else {',
|
||||
$self->_inline_writer_core($inv, $slot_access),
|
||||
'}',
|
||||
'}',
|
||||
);
|
||||
}
|
||||
|
||||
sub _minimum_arguments { 1 }
|
||||
sub _maximum_arguments { 2 }
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
37
CPAN/Moose/Meta/Method/Accessor/Native/Hash/clear.pm
Normal file
37
CPAN/Moose/Meta/Method/Accessor/Native/Hash/clear.pm
Normal file
@@ -0,0 +1,37 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Hash::clear;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Hash::Writer';
|
||||
|
||||
sub _maximum_arguments { 0 }
|
||||
|
||||
sub _adds_members { 0 }
|
||||
|
||||
# The inner () in this expression is for the benefit of inlining code that
|
||||
# might end up looking like "values %{ {} }". This is a syntax error in perl
|
||||
# but 'values %{ { () } }' is not.
|
||||
sub _potential_value { '{ ( ) }' }
|
||||
|
||||
# There are no new members so we don't need to coerce new values (none exist)
|
||||
# and we always want to check the new (empty) hash as a whole.
|
||||
sub _inline_coerce_new_values { '' }
|
||||
|
||||
sub _check_new_members_only { 0 }
|
||||
|
||||
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/Hash/count.pm
Normal file
22
CPAN/Moose/Meta/Method/Accessor/Native/Hash/count.pm
Normal file
@@ -0,0 +1,22 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Hash::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 keys %{ (' . $slot_access . ') }';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
31
CPAN/Moose/Meta/Method/Accessor/Native/Hash/defined.pm
Normal file
31
CPAN/Moose/Meta/Method/Accessor/Native/Hash/defined.pm
Normal file
@@ -0,0 +1,31 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Hash::defined;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Reader',
|
||||
'Moose::Meta::Method::Accessor::Native::Hash';
|
||||
|
||||
sub _minimum_arguments { 1 }
|
||||
|
||||
sub _maximum_arguments { 1 }
|
||||
|
||||
sub _inline_check_arguments {
|
||||
my $self = shift;
|
||||
|
||||
return $self->_inline_check_var_is_valid_key('$_[0]');
|
||||
}
|
||||
|
||||
sub _return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return 'defined ' . $slot_access . '->{ $_[0] }';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
46
CPAN/Moose/Meta/Method/Accessor/Native/Hash/delete.pm
Normal file
46
CPAN/Moose/Meta/Method/Accessor/Native/Hash/delete.pm
Normal file
@@ -0,0 +1,46 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Hash::delete;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Hash::Writer';
|
||||
|
||||
sub _adds_members { 0 }
|
||||
|
||||
# There are no new members so we don't need to coerce new values (none exist)
|
||||
# and we always want to check the new (empty) hash as a whole.
|
||||
sub _inline_coerce_new_values { '' }
|
||||
|
||||
sub _check_new_members_only { 0 }
|
||||
|
||||
sub _potential_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return '(do { '
|
||||
. 'my %potential = %{ (' . $slot_access . ') }; '
|
||||
. '@return = delete @potential{@_}; '
|
||||
. '\%potential; '
|
||||
. '})';
|
||||
}
|
||||
|
||||
sub _inline_optimized_set_new_value {
|
||||
my $self = shift;
|
||||
my ($inv, $new, $slot_access) = @_;
|
||||
|
||||
return '@return = delete @{ (' . $slot_access . ') }{@_};';
|
||||
}
|
||||
|
||||
sub _return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return 'wantarray ? @return : $return[-1]';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
23
CPAN/Moose/Meta/Method/Accessor/Native/Hash/elements.pm
Normal file
23
CPAN/Moose/Meta/Method/Accessor/Native/Hash/elements.pm
Normal file
@@ -0,0 +1,23 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Hash::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 'map { $_, ' . $slot_access . '->{$_} } '
|
||||
. 'keys %{ (' . $slot_access . ') }';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
31
CPAN/Moose/Meta/Method/Accessor/Native/Hash/exists.pm
Normal file
31
CPAN/Moose/Meta/Method/Accessor/Native/Hash/exists.pm
Normal file
@@ -0,0 +1,31 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Hash::exists;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Reader',
|
||||
'Moose::Meta::Method::Accessor::Native::Hash';
|
||||
|
||||
sub _minimum_arguments { 1 }
|
||||
|
||||
sub _maximum_arguments { 1 }
|
||||
|
||||
sub _inline_check_arguments {
|
||||
my $self = shift;
|
||||
|
||||
return $self->_inline_check_var_is_valid_key('$_[0]');
|
||||
}
|
||||
|
||||
sub _return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = shift;
|
||||
|
||||
return 'exists ' . $slot_access . '->{ $_[0] }';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
35
CPAN/Moose/Meta/Method/Accessor/Native/Hash/get.pm
Normal file
35
CPAN/Moose/Meta/Method/Accessor/Native/Hash/get.pm
Normal file
@@ -0,0 +1,35 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Hash::get;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Reader',
|
||||
'Moose::Meta::Method::Accessor::Native::Hash';
|
||||
|
||||
sub _minimum_arguments { 1 }
|
||||
|
||||
sub _inline_check_arguments {
|
||||
my $self = shift;
|
||||
|
||||
return (
|
||||
'for (@_) {',
|
||||
$self->_inline_check_var_is_valid_key('$_'),
|
||||
'}',
|
||||
);
|
||||
}
|
||||
|
||||
sub _return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return '@_ > 1 '
|
||||
. '? @{ (' . $slot_access . ') }{@_} '
|
||||
. ': ' . $slot_access . '->{$_[0]}';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
22
CPAN/Moose/Meta/Method/Accessor/Native/Hash/is_empty.pm
Normal file
22
CPAN/Moose/Meta/Method/Accessor/Native/Hash/is_empty.pm
Normal file
@@ -0,0 +1,22 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Hash::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 'scalar keys %{ (' . $slot_access . ') } ? 0 : 1';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
22
CPAN/Moose/Meta/Method/Accessor/Native/Hash/keys.pm
Normal file
22
CPAN/Moose/Meta/Method/Accessor/Native/Hash/keys.pm
Normal file
@@ -0,0 +1,22 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Hash::keys;
|
||||
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 'keys %{ (' . $slot_access . ') }';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
23
CPAN/Moose/Meta/Method/Accessor/Native/Hash/kv.pm
Normal file
23
CPAN/Moose/Meta/Method/Accessor/Native/Hash/kv.pm
Normal file
@@ -0,0 +1,23 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Hash::kv;
|
||||
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 'map { [ $_, ' . $slot_access . '->{$_} ] } '
|
||||
. 'keys %{ (' . $slot_access . ') }';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
99
CPAN/Moose/Meta/Method/Accessor/Native/Hash/set.pm
Normal file
99
CPAN/Moose/Meta/Method/Accessor/Native/Hash/set.pm
Normal file
@@ -0,0 +1,99 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Hash::set;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use List::Util 1.32;
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native::Hash::Writer';
|
||||
|
||||
sub _minimum_arguments { 2 }
|
||||
|
||||
sub _maximum_arguments { undef }
|
||||
|
||||
around _inline_check_argument_count => sub {
|
||||
my $orig = shift;
|
||||
my $self = shift;
|
||||
|
||||
return (
|
||||
$self->$orig(@_),
|
||||
'if (@_ % 2) {',
|
||||
$self->_inline_throw_exception( MustPassEvenNumberOfArguments =>
|
||||
"method_name => '".$self->delegate_to_method."',".
|
||||
'args => \@_',
|
||||
) . ';',
|
||||
'}',
|
||||
);
|
||||
};
|
||||
|
||||
sub _inline_process_arguments {
|
||||
my $self = shift;
|
||||
|
||||
return (
|
||||
'my @keys_idx = grep { ! ($_ % 2) } 0..$#_;',
|
||||
'my @values_idx = grep { $_ % 2 } 0..$#_;',
|
||||
);
|
||||
}
|
||||
|
||||
sub _inline_check_arguments {
|
||||
my $self = shift;
|
||||
|
||||
return (
|
||||
'for (@keys_idx) {',
|
||||
'if (!defined($_[$_])) {',
|
||||
$self->_inline_throw_exception( UndefinedHashKeysPassedToMethod =>
|
||||
'hash_keys => \@keys_idx,'.
|
||||
"method_name => '".$self->delegate_to_method."'",
|
||||
) . ';',
|
||||
'}',
|
||||
'}',
|
||||
);
|
||||
}
|
||||
|
||||
sub _adds_members { 1 }
|
||||
|
||||
# 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;
|
||||
|
||||
# Is there a simpler way to do this?
|
||||
return (
|
||||
'@_ = List::Util::pairmap { $a => $member_coercion->($b) } @_;',
|
||||
);
|
||||
};
|
||||
|
||||
sub _potential_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return '{ %{ (' . $slot_access . ') }, @_ }';
|
||||
}
|
||||
|
||||
sub _new_members { '@_[ @values_idx ]' }
|
||||
|
||||
sub _inline_optimized_set_new_value {
|
||||
my $self = shift;
|
||||
my ($inv, $new, $slot_access) = @_;
|
||||
|
||||
return '@{ (' . $slot_access . ') }{ @_[@keys_idx] } = @_[@values_idx];';
|
||||
}
|
||||
|
||||
sub _return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return 'wantarray '
|
||||
. '? @{ (' . $slot_access . ') }{ @_[@keys_idx] } '
|
||||
. ': ' . $slot_access . '->{ $_[$keys_idx[0]] }';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
26
CPAN/Moose/Meta/Method/Accessor/Native/Hash/shallow_clone.pm
Normal file
26
CPAN/Moose/Meta/Method/Accessor/Native/Hash/shallow_clone.pm
Normal file
@@ -0,0 +1,26 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Hash::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;
|
||||
22
CPAN/Moose/Meta/Method/Accessor/Native/Hash/values.pm
Normal file
22
CPAN/Moose/Meta/Method/Accessor/Native/Hash/values.pm
Normal file
@@ -0,0 +1,22 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Hash::values;
|
||||
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 'values %{ (' . $slot_access . ') }';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
29
CPAN/Moose/Meta/Method/Accessor/Native/Number/abs.pm
Normal file
29
CPAN/Moose/Meta/Method/Accessor/Native/Number/abs.pm
Normal file
@@ -0,0 +1,29 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Number::abs;
|
||||
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 'abs(' . $slot_access . ')';
|
||||
}
|
||||
|
||||
sub _inline_optimized_set_new_value {
|
||||
my $self = shift;
|
||||
my ($inv, $new, $slot_access) = @_;
|
||||
|
||||
return $slot_access . ' = abs(' . $slot_access . ');';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
31
CPAN/Moose/Meta/Method/Accessor/Native/Number/add.pm
Normal file
31
CPAN/Moose/Meta/Method/Accessor/Native/Number/add.pm
Normal file
@@ -0,0 +1,31 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Number::add;
|
||||
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;
|
||||
31
CPAN/Moose/Meta/Method/Accessor/Native/Number/div.pm
Normal file
31
CPAN/Moose/Meta/Method/Accessor/Native/Number/div.pm
Normal file
@@ -0,0 +1,31 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Number::div;
|
||||
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;
|
||||
31
CPAN/Moose/Meta/Method/Accessor/Native/Number/mod.pm
Normal file
31
CPAN/Moose/Meta/Method/Accessor/Native/Number/mod.pm
Normal file
@@ -0,0 +1,31 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Number::mod;
|
||||
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;
|
||||
31
CPAN/Moose/Meta/Method/Accessor/Native/Number/mul.pm
Normal file
31
CPAN/Moose/Meta/Method/Accessor/Native/Number/mul.pm
Normal file
@@ -0,0 +1,31 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Number::mul;
|
||||
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;
|
||||
25
CPAN/Moose/Meta/Method/Accessor/Native/Number/set.pm
Normal file
25
CPAN/Moose/Meta/Method/Accessor/Native/Number/set.pm
Normal file
@@ -0,0 +1,25 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Number::set;
|
||||
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 { '$_[0]' }
|
||||
|
||||
sub _inline_optimized_set_new_value {
|
||||
my $self = shift;
|
||||
my ($inv, $new, $slot_access) = @_;
|
||||
|
||||
return $slot_access . ' = $_[0];';
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
31
CPAN/Moose/Meta/Method/Accessor/Native/Number/sub.pm
Normal file
31
CPAN/Moose/Meta/Method/Accessor/Native/Number/sub.pm
Normal file
@@ -0,0 +1,31 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Number::sub;
|
||||
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;
|
||||
47
CPAN/Moose/Meta/Method/Accessor/Native/Reader.pm
Normal file
47
CPAN/Moose/Meta/Method/Accessor/Native/Reader.pm
Normal file
@@ -0,0 +1,47 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Reader;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native';
|
||||
|
||||
requires '_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_reader_core($inv, $slot_access, @_),
|
||||
'}',
|
||||
);
|
||||
}
|
||||
|
||||
sub _inline_reader_core {
|
||||
my $self = shift;
|
||||
my ($inv, $slot_access, @extra) = @_;
|
||||
|
||||
return (
|
||||
$self->_inline_check_argument_count,
|
||||
$self->_inline_process_arguments($inv, $slot_access),
|
||||
$self->_inline_check_arguments,
|
||||
$self->_inline_check_lazy($inv, '$type_constraint', '$type_coercion', '$type_message'),
|
||||
$self->_inline_return_value($slot_access),
|
||||
);
|
||||
}
|
||||
|
||||
sub _inline_process_arguments { return }
|
||||
|
||||
sub _inline_check_arguments { return }
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
31
CPAN/Moose/Meta/Method/Accessor/Native/String/append.pm
Normal file
31
CPAN/Moose/Meta/Method/Accessor/Native/String/append.pm
Normal 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;
|
||||
40
CPAN/Moose/Meta/Method/Accessor/Native/String/chomp.pm
Normal file
40
CPAN/Moose/Meta/Method/Accessor/Native/String/chomp.pm
Normal 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;
|
||||
40
CPAN/Moose/Meta/Method/Accessor/Native/String/chop.pm
Normal file
40
CPAN/Moose/Meta/Method/Accessor/Native/String/chop.pm
Normal 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;
|
||||
24
CPAN/Moose/Meta/Method/Accessor/Native/String/clear.pm
Normal file
24
CPAN/Moose/Meta/Method/Accessor/Native/String/clear.pm
Normal 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;
|
||||
33
CPAN/Moose/Meta/Method/Accessor/Native/String/inc.pm
Normal file
33
CPAN/Moose/Meta/Method/Accessor/Native/String/inc.pm
Normal 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;
|
||||
22
CPAN/Moose/Meta/Method/Accessor/Native/String/length.pm
Normal file
22
CPAN/Moose/Meta/Method/Accessor/Native/String/length.pm
Normal 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;
|
||||
42
CPAN/Moose/Meta/Method/Accessor/Native/String/match.pm
Normal file
42
CPAN/Moose/Meta/Method/Accessor/Native/String/match.pm
Normal 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;
|
||||
31
CPAN/Moose/Meta/Method/Accessor/Native/String/prepend.pm
Normal file
31
CPAN/Moose/Meta/Method/Accessor/Native/String/prepend.pm
Normal 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;
|
||||
69
CPAN/Moose/Meta/Method/Accessor/Native/String/replace.pm
Normal file
69
CPAN/Moose/Meta/Method/Accessor/Native/String/replace.pm
Normal 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;
|
||||
123
CPAN/Moose/Meta/Method/Accessor/Native/String/substr.pm
Normal file
123
CPAN/Moose/Meta/Method/Accessor/Native/String/substr.pm
Normal 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;
|
||||
174
CPAN/Moose/Meta/Method/Accessor/Native/Writer.pm
Normal file
174
CPAN/Moose/Meta/Method/Accessor/Native/Writer.pm
Normal file
@@ -0,0 +1,174 @@
|
||||
package Moose::Meta::Method::Accessor::Native::Writer;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use List::Util 1.33 qw( any );
|
||||
use Moose::Util;
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
with 'Moose::Meta::Method::Accessor::Native';
|
||||
|
||||
requires '_potential_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_writer_core($inv, $slot_access),
|
||||
'}',
|
||||
);
|
||||
}
|
||||
|
||||
sub _inline_writer_core {
|
||||
my $self = shift;
|
||||
my ($inv, $slot_access) = @_;
|
||||
|
||||
my $potential = $self->_potential_value($slot_access);
|
||||
my $old = '@old';
|
||||
|
||||
my @code;
|
||||
push @code, (
|
||||
$self->_inline_check_argument_count,
|
||||
$self->_inline_process_arguments($inv, $slot_access),
|
||||
$self->_inline_check_arguments('for writer'),
|
||||
$self->_inline_check_lazy($inv, '$type_constraint', '$type_coercion', '$type_message'),
|
||||
);
|
||||
|
||||
if ($self->_return_value($slot_access)) {
|
||||
# some writers will save the return value in this variable when they
|
||||
# generate the potential value.
|
||||
push @code, 'my @return;'
|
||||
}
|
||||
|
||||
push @code, (
|
||||
$self->_inline_coerce_new_values,
|
||||
$self->_inline_copy_native_value(\$potential),
|
||||
$self->_inline_tc_code($potential, '$type_constraint', '$type_coercion', '$type_message'),
|
||||
$self->_inline_get_old_value_for_trigger($inv, $old),
|
||||
$self->_inline_capture_return_value($slot_access),
|
||||
$self->_inline_set_new_value($inv, $potential, $slot_access),
|
||||
$self->_inline_trigger($inv, $slot_access, $old),
|
||||
$self->_inline_return_value($slot_access, 'for writer'),
|
||||
);
|
||||
|
||||
return @code;
|
||||
}
|
||||
|
||||
sub _inline_process_arguments { return }
|
||||
|
||||
sub _inline_check_arguments { return }
|
||||
|
||||
sub _inline_coerce_new_values { return }
|
||||
|
||||
sub _writer_value_needs_copy {
|
||||
my $self = shift;
|
||||
|
||||
return $self->_constraint_must_be_checked;
|
||||
}
|
||||
|
||||
sub _constraint_must_be_checked {
|
||||
my $self = shift;
|
||||
|
||||
my $attr = $self->associated_attribute;
|
||||
|
||||
return $attr->has_type_constraint
|
||||
&& ( !$self->_is_root_type( $attr->type_constraint )
|
||||
|| ( $attr->should_coerce && $attr->type_constraint->has_coercion ) );
|
||||
}
|
||||
|
||||
sub _is_root_type {
|
||||
my $self = shift;
|
||||
my $type = shift;
|
||||
|
||||
if ( blessed($type)
|
||||
&& $type->can('does')
|
||||
&& $type->does('Specio::Constraint::Role::Interface') )
|
||||
{
|
||||
require Specio::Library::Builtins;
|
||||
return
|
||||
any { $type->is_same_type_as( Specio::Library::Builtins::t($_) ) }
|
||||
@{ $self->root_types };
|
||||
}
|
||||
else {
|
||||
my $name = $type->name;
|
||||
return any { $name eq $_ } @{ $self->root_types };
|
||||
}
|
||||
}
|
||||
|
||||
sub _inline_copy_native_value {
|
||||
my $self = shift;
|
||||
my ($potential_ref) = @_;
|
||||
|
||||
return unless $self->_writer_value_needs_copy;
|
||||
|
||||
my $code = 'my $potential = ' . ${$potential_ref} . ';';
|
||||
|
||||
${$potential_ref} = '$potential';
|
||||
|
||||
return $code;
|
||||
}
|
||||
|
||||
around _inline_tc_code => sub {
|
||||
my $orig = shift;
|
||||
my $self = shift;
|
||||
my ($value, $tc, $coercion, $message, $for_lazy) = @_;
|
||||
|
||||
return unless $for_lazy || $self->_constraint_must_be_checked;
|
||||
|
||||
return $self->$orig(@_);
|
||||
};
|
||||
|
||||
around _inline_check_constraint => sub {
|
||||
my $orig = shift;
|
||||
my $self = shift;
|
||||
my ($value, $tc, $message, $for_lazy) = @_;
|
||||
|
||||
return unless $for_lazy || $self->_constraint_must_be_checked;
|
||||
|
||||
return $self->$orig(@_);
|
||||
};
|
||||
|
||||
sub _inline_capture_return_value { return }
|
||||
|
||||
sub _inline_set_new_value {
|
||||
my $self = shift;
|
||||
|
||||
return $self->_inline_store_value(@_)
|
||||
if $self->_writer_value_needs_copy
|
||||
|| !$self->_slot_access_can_be_inlined
|
||||
|| !$self->_get_is_lvalue;
|
||||
|
||||
return $self->_inline_optimized_set_new_value(@_);
|
||||
}
|
||||
|
||||
sub _get_is_lvalue {
|
||||
my $self = shift;
|
||||
|
||||
return $self->associated_attribute->associated_class->instance_metaclass->inline_get_is_lvalue;
|
||||
}
|
||||
|
||||
sub _inline_optimized_set_new_value {
|
||||
my $self = shift;
|
||||
|
||||
return $self->_inline_store_value(@_);
|
||||
}
|
||||
|
||||
sub _return_value {
|
||||
my $self = shift;
|
||||
my ($slot_access) = @_;
|
||||
|
||||
return $slot_access;
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
|
||||
1;
|
||||
171
CPAN/Moose/Meta/Method/Augmented.pm
Normal file
171
CPAN/Moose/Meta/Method/Augmented.pm
Normal file
@@ -0,0 +1,171 @@
|
||||
package Moose::Meta::Method::Augmented;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use parent 'Moose::Meta::Method';
|
||||
|
||||
use Moose::Util 'throw_exception';
|
||||
|
||||
sub new {
|
||||
my ( $class, %args ) = @_;
|
||||
|
||||
# the package can be overridden by roles
|
||||
# it is really more like body's compilation stash
|
||||
# this is where we need to override the definition of super() so that the
|
||||
# body of the code can call the right overridden version
|
||||
my $name = $args{name};
|
||||
my $meta = $args{class};
|
||||
|
||||
my $super = $meta->find_next_method_by_name($name);
|
||||
|
||||
(defined $super)
|
||||
|| throw_exception( CannotAugmentNoSuperMethod => params => \%args,
|
||||
class => $class,
|
||||
method_name => $name
|
||||
);
|
||||
|
||||
my $_super_package = $super->package_name;
|
||||
# BUT!,... if this is an overridden method ....
|
||||
if ($super->isa('Moose::Meta::Method::Overridden')) {
|
||||
# we need to be sure that we actually
|
||||
# find the next method, which is not
|
||||
# an 'override' method, the reason is
|
||||
# that an 'override' method will not
|
||||
# be the one calling inner()
|
||||
my $real_super = $meta->_find_next_method_by_name_which_is_not_overridden($name);
|
||||
$_super_package = $real_super->package_name;
|
||||
}
|
||||
|
||||
my $super_body = $super->body;
|
||||
|
||||
my $method = $args{method};
|
||||
|
||||
my $body = sub {
|
||||
local $Moose::INNER_ARGS{$_super_package} = [ @_ ];
|
||||
local $Moose::INNER_BODY{$_super_package} = $method;
|
||||
$super_body->(@_);
|
||||
};
|
||||
|
||||
# FIXME store additional attrs
|
||||
$class->wrap(
|
||||
$body,
|
||||
package_name => $meta->name,
|
||||
name => $name
|
||||
);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
# ABSTRACT: A Moose Method metaclass for augmented methods
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Moose::Meta::Method::Augmented - A Moose Method metaclass for augmented methods
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 2.2207
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This class implements method augmentation logic for the L<Moose>
|
||||
C<augment> keyword.
|
||||
|
||||
The augmentation subroutine reference will be invoked explicitly using
|
||||
the C<inner> keyword from the parent class's method definition.
|
||||
|
||||
=head1 INHERITANCE
|
||||
|
||||
C<Moose::Meta::Method::Augmented> is a subclass of L<Moose::Meta::Method>.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
=head2 Moose::Meta::Method::Augmented->new(%options)
|
||||
|
||||
This constructs a new object. It accepts the following options:
|
||||
|
||||
=over 4
|
||||
|
||||
=item * class
|
||||
|
||||
The metaclass object for the class in which the augmentation is being
|
||||
declared. This option is required.
|
||||
|
||||
=item * name
|
||||
|
||||
The name of the method which we are augmenting. This method must exist
|
||||
in one of the class's superclasses. This option is required.
|
||||
|
||||
=item * method
|
||||
|
||||
The subroutine reference which implements the augmentation. This
|
||||
option is required.
|
||||
|
||||
=back
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
See L<Moose/BUGS> for details on reporting bugs.
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
=over 4
|
||||
|
||||
=item *
|
||||
|
||||
Stevan Little <stevan@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Dave Rolsky <autarch@urth.org>
|
||||
|
||||
=item *
|
||||
|
||||
Jesse Luehrs <doy@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Shawn M Moore <sartak@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
|
||||
|
||||
=item *
|
||||
|
||||
Karen Etheridge <ether@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Florian Ragwitz <rafl@debian.org>
|
||||
|
||||
=item *
|
||||
|
||||
Hans Dieter Pearcey <hdp@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Chris Prather <chris@prather.org>
|
||||
|
||||
=item *
|
||||
|
||||
Matt S Trout <mstrout@cpan.org>
|
||||
|
||||
=back
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2006 by Infinity Interactive, Inc.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
145
CPAN/Moose/Meta/Method/Constructor.pm
Normal file
145
CPAN/Moose/Meta/Method/Constructor.pm
Normal file
@@ -0,0 +1,145 @@
|
||||
package Moose::Meta::Method::Constructor;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Scalar::Util 'weaken';
|
||||
|
||||
use parent 'Moose::Meta::Method',
|
||||
'Class::MOP::Method::Constructor';
|
||||
|
||||
use Moose::Util 'throw_exception';
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my %options = @_;
|
||||
|
||||
my $meta = $options{metaclass};
|
||||
|
||||
(ref $options{options} eq 'HASH')
|
||||
|| throw_exception( MustPassAHashOfOptions => params => \%options,
|
||||
class => $class
|
||||
);
|
||||
|
||||
($options{package_name} && $options{name})
|
||||
|| throw_exception( MustSupplyPackageNameAndName => params => \%options,
|
||||
class => $class
|
||||
);
|
||||
|
||||
my $self = bless {
|
||||
'body' => undef,
|
||||
'package_name' => $options{package_name},
|
||||
'name' => $options{name},
|
||||
'options' => $options{options},
|
||||
'associated_metaclass' => $meta,
|
||||
'definition_context' => $options{definition_context},
|
||||
'_expected_method_class' => $options{_expected_method_class} || 'Moose::Object',
|
||||
} => $class;
|
||||
|
||||
# we don't want this creating
|
||||
# a cycle in the code, if not
|
||||
# needed
|
||||
weaken($self->{'associated_metaclass'});
|
||||
|
||||
$self->_initialize_body;
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
## method
|
||||
|
||||
sub _initialize_body {
|
||||
my $self = shift;
|
||||
$self->{'body'} = $self->_generate_constructor_method_inline;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
# ABSTRACT: Method Meta Object for constructors
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Moose::Meta::Method::Constructor - Method Meta Object for constructors
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 2.2207
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This class is a subclass of L<Class::MOP::Method::Constructor> that
|
||||
provides additional Moose-specific functionality
|
||||
|
||||
To understand this class, you should read the
|
||||
L<Class::MOP::Method::Constructor> documentation as well.
|
||||
|
||||
=head1 INHERITANCE
|
||||
|
||||
C<Moose::Meta::Method::Constructor> is a subclass of
|
||||
L<Moose::Meta::Method> I<and> L<Class::MOP::Method::Constructor>.
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
See L<Moose/BUGS> for details on reporting bugs.
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
=over 4
|
||||
|
||||
=item *
|
||||
|
||||
Stevan Little <stevan@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Dave Rolsky <autarch@urth.org>
|
||||
|
||||
=item *
|
||||
|
||||
Jesse Luehrs <doy@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Shawn M Moore <sartak@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
|
||||
|
||||
=item *
|
||||
|
||||
Karen Etheridge <ether@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Florian Ragwitz <rafl@debian.org>
|
||||
|
||||
=item *
|
||||
|
||||
Hans Dieter Pearcey <hdp@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Chris Prather <chris@prather.org>
|
||||
|
||||
=item *
|
||||
|
||||
Matt S Trout <mstrout@cpan.org>
|
||||
|
||||
=back
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2006 by Infinity Interactive, Inc.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
307
CPAN/Moose/Meta/Method/Delegation.pm
Normal file
307
CPAN/Moose/Meta/Method/Delegation.pm
Normal file
@@ -0,0 +1,307 @@
|
||||
package Moose::Meta::Method::Delegation;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Scalar::Util 'blessed', 'weaken';
|
||||
use Try::Tiny;
|
||||
|
||||
use parent 'Moose::Meta::Method',
|
||||
'Class::MOP::Method::Generated';
|
||||
|
||||
use Moose::Util 'throw_exception';
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my %options = @_;
|
||||
|
||||
( exists $options{attribute} )
|
||||
|| throw_exception( MustSupplyAnAttributeToConstructWith => params => \%options,
|
||||
class => $class
|
||||
);
|
||||
|
||||
( blessed( $options{attribute} )
|
||||
&& $options{attribute}->isa('Moose::Meta::Attribute') )
|
||||
|| throw_exception( MustSupplyAMooseMetaAttributeInstance => params => \%options,
|
||||
class => $class
|
||||
);
|
||||
|
||||
( $options{package_name} && $options{name} )
|
||||
|| throw_exception( MustSupplyPackageNameAndName => params => \%options,
|
||||
class => $class
|
||||
);
|
||||
|
||||
( $options{delegate_to_method} && ( !ref $options{delegate_to_method} )
|
||||
|| ( 'CODE' eq ref $options{delegate_to_method} ) )
|
||||
|| throw_exception( MustSupplyADelegateToMethod => params => \%options,
|
||||
class => $class
|
||||
);
|
||||
|
||||
exists $options{curried_arguments}
|
||||
|| ( $options{curried_arguments} = [] );
|
||||
|
||||
( $options{curried_arguments} &&
|
||||
( 'ARRAY' eq ref $options{curried_arguments} ) )
|
||||
|| throw_exception( MustSupplyArrayRefAsCurriedArguments => params => \%options,
|
||||
class_name => $class
|
||||
);
|
||||
|
||||
my $self = $class->_new( \%options );
|
||||
|
||||
weaken( $self->{'attribute'} );
|
||||
|
||||
$self->_initialize_body;
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub _new {
|
||||
my $class = shift;
|
||||
my $options = @_ == 1 ? $_[0] : {@_};
|
||||
|
||||
return bless $options, $class;
|
||||
}
|
||||
|
||||
sub curried_arguments { (shift)->{'curried_arguments'} }
|
||||
|
||||
sub associated_attribute { (shift)->{'attribute'} }
|
||||
|
||||
sub delegate_to_method { (shift)->{'delegate_to_method'} }
|
||||
|
||||
sub _initialize_body {
|
||||
my $self = shift;
|
||||
|
||||
my $method_to_call = $self->delegate_to_method;
|
||||
return $self->{body} = $method_to_call
|
||||
if ref $method_to_call;
|
||||
|
||||
# We don't inline because it's faster, we do it because when the method is
|
||||
# inlined, any errors thrown because of the delegated method have a _much_
|
||||
# nicer stack trace, as the trace doesn't include any Moose internals.
|
||||
$self->{body} = $self->_generate_inline_method;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
sub _generate_inline_method {
|
||||
my $self = shift;
|
||||
|
||||
my $attr = $self->associated_attribute;
|
||||
my $delegate = $self->delegate_to_method;
|
||||
|
||||
my $method_name = B::perlstring( $self->name );
|
||||
my $attr_name = B::perlstring( $self->associated_attribute->name );
|
||||
|
||||
my $undefined_attr_throw = $self->_inline_throw_exception(
|
||||
'AttributeValueIsNotDefined',
|
||||
sprintf( <<'EOF', $method_name, $attr_name ) );
|
||||
method => $self->meta->find_method_by_name(%s),
|
||||
instance => $self,
|
||||
attribute => $self->meta->find_attribute_by_name(%s),
|
||||
EOF
|
||||
|
||||
my $not_an_object_throw = $self->_inline_throw_exception(
|
||||
'AttributeValueIsNotAnObject',
|
||||
sprintf( <<'EOF', $method_name, $attr_name ) );
|
||||
method => $self->meta->find_method_by_name(%s),
|
||||
instance => $self,
|
||||
attribute => $self->meta->find_attribute_by_name(%s),
|
||||
given_value => $proxy,
|
||||
EOF
|
||||
|
||||
my $get_proxy
|
||||
= $attr->has_read_method ? $attr->get_read_method : '$reader';
|
||||
|
||||
my $args = @{ $self->curried_arguments } ? '@curried, @_' : '@_';
|
||||
my $source = sprintf(
|
||||
<<'EOF', $get_proxy, $undefined_attr_throw, $not_an_object_throw, $delegate, $args );
|
||||
sub {
|
||||
my $self = shift;
|
||||
|
||||
my $proxy = $self->%s;
|
||||
if ( !defined $proxy ) {
|
||||
%s;
|
||||
}
|
||||
elsif ( ref $proxy && !Scalar::Util::blessed($proxy) ) {
|
||||
%s;
|
||||
}
|
||||
return $proxy->%s( %s );
|
||||
}
|
||||
EOF
|
||||
|
||||
my $description
|
||||
= 'inline delegation in '
|
||||
. $self->package_name . ' for '
|
||||
. $attr->name . '->'
|
||||
. $delegate;
|
||||
|
||||
my $definition = $attr->definition_context;
|
||||
# While all attributes created in the usual way (via Moose's has()) will
|
||||
# define this, there's no guarantee that this must be defined. For
|
||||
# example, when Moo inflates a class to Moose it does not define these (as
|
||||
# of Moo 2.003).
|
||||
$description .= " (attribute declared in $definition->{file} at line $definition->{line})"
|
||||
if defined $definition->{file} && defined $definition->{line};
|
||||
|
||||
return try {
|
||||
$self->_compile_code(
|
||||
source => $source,
|
||||
description => $description,
|
||||
);
|
||||
}
|
||||
catch {
|
||||
$self->_throw_exception(
|
||||
'CouldNotGenerateInlineAttributeMethod',
|
||||
instance => $self,
|
||||
error => $_,
|
||||
option => 'handles for ' . $attr->name . '->' . $delegate,
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
sub _eval_environment {
|
||||
my $self = shift;
|
||||
|
||||
my %env;
|
||||
if ( @{ $self->curried_arguments } ) {
|
||||
$env{'@curried'} = $self->curried_arguments;
|
||||
}
|
||||
|
||||
unless ( $self->associated_attribute->has_read_method ) {
|
||||
$env{'$reader'} = \( $self->_get_delegate_accessor );
|
||||
}
|
||||
|
||||
return \%env;
|
||||
}
|
||||
|
||||
sub _get_delegate_accessor {
|
||||
my $self = shift;
|
||||
|
||||
my $accessor = $self->associated_attribute->get_read_method_ref;
|
||||
|
||||
# If it's blessed it's a Moose::Meta::Method
|
||||
return blessed $accessor
|
||||
? ( $accessor->body )
|
||||
: $accessor;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
# ABSTRACT: A Moose Method metaclass for delegation methods
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Moose::Meta::Method::Delegation - A Moose Method metaclass for delegation methods
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 2.2207
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This is a subclass of L<Moose::Meta::Method> for delegation
|
||||
methods.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
=head2 Moose::Meta::Method::Delegation->new(%options)
|
||||
|
||||
This creates the delegation methods based on the provided C<%options>.
|
||||
|
||||
=over 4
|
||||
|
||||
=item I<attribute>
|
||||
|
||||
This must be an instance of C<Moose::Meta::Attribute> which this
|
||||
accessor is being generated for. This options is B<required>.
|
||||
|
||||
=item I<delegate_to_method>
|
||||
|
||||
The method in the associated attribute's value to which we
|
||||
delegate. This can be either a method name or a code reference.
|
||||
|
||||
=item I<curried_arguments>
|
||||
|
||||
An array reference of arguments that will be prepended to the argument list for
|
||||
any call to the delegating method.
|
||||
|
||||
=back
|
||||
|
||||
=head2 $metamethod->associated_attribute
|
||||
|
||||
Returns the attribute associated with this method.
|
||||
|
||||
=head2 $metamethod->curried_arguments
|
||||
|
||||
Return any curried arguments that will be passed to the delegated method.
|
||||
|
||||
=head2 $metamethod->delegate_to_method
|
||||
|
||||
Returns the method to which this method delegates, as passed to the
|
||||
constructor.
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
See L<Moose/BUGS> for details on reporting bugs.
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
=over 4
|
||||
|
||||
=item *
|
||||
|
||||
Stevan Little <stevan@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Dave Rolsky <autarch@urth.org>
|
||||
|
||||
=item *
|
||||
|
||||
Jesse Luehrs <doy@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Shawn M Moore <sartak@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
|
||||
|
||||
=item *
|
||||
|
||||
Karen Etheridge <ether@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Florian Ragwitz <rafl@debian.org>
|
||||
|
||||
=item *
|
||||
|
||||
Hans Dieter Pearcey <hdp@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Chris Prather <chris@prather.org>
|
||||
|
||||
=item *
|
||||
|
||||
Matt S Trout <mstrout@cpan.org>
|
||||
|
||||
=back
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2006 by Infinity Interactive, Inc.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
251
CPAN/Moose/Meta/Method/Destructor.pm
Normal file
251
CPAN/Moose/Meta/Method/Destructor.pm
Normal file
@@ -0,0 +1,251 @@
|
||||
package Moose::Meta::Method::Destructor;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Devel::GlobalDestruction ();
|
||||
use Scalar::Util 'blessed', 'weaken';
|
||||
use Try::Tiny;
|
||||
|
||||
use parent 'Moose::Meta::Method',
|
||||
'Class::MOP::Method::Inlined';
|
||||
|
||||
use Moose::Util 'throw_exception';
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my %options = @_;
|
||||
|
||||
(ref $options{options} eq 'HASH')
|
||||
|| throw_exception( MustPassAHashOfOptions => params => \%options,
|
||||
class => $class
|
||||
);
|
||||
|
||||
($options{package_name} && $options{name})
|
||||
|| throw_exception( MustSupplyPackageNameAndName => params => \%options,
|
||||
class => $class
|
||||
);
|
||||
|
||||
my $self = bless {
|
||||
# from our superclass
|
||||
'body' => undef,
|
||||
'package_name' => $options{package_name},
|
||||
'name' => $options{name},
|
||||
# ...
|
||||
'options' => $options{options},
|
||||
'definition_context' => $options{definition_context},
|
||||
'associated_metaclass' => $options{metaclass},
|
||||
} => $class;
|
||||
|
||||
# we don't want this creating
|
||||
# a cycle in the code, if not
|
||||
# needed
|
||||
weaken($self->{'associated_metaclass'});
|
||||
|
||||
$self->_initialize_body;
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
## accessors
|
||||
|
||||
sub options { (shift)->{'options'} }
|
||||
|
||||
## method
|
||||
|
||||
sub is_needed {
|
||||
my $self = shift;
|
||||
my $metaclass = shift;
|
||||
|
||||
( blessed $metaclass && $metaclass->isa('Class::MOP::Class') )
|
||||
|| throw_exception( MethodExpectedAMetaclassObject => metaclass => $metaclass,
|
||||
class => $self
|
||||
);
|
||||
|
||||
return $metaclass->find_method_by_name("DEMOLISHALL");
|
||||
}
|
||||
|
||||
sub _initialize_body {
|
||||
my $self = shift;
|
||||
# TODO:
|
||||
# the %options should also include a both
|
||||
# a call 'initializer' and call 'SUPER::'
|
||||
# options, which should cover approx 90%
|
||||
# of the possible use cases (even if it
|
||||
# requires some adaption on the part of
|
||||
# the author, after all, nothing is free)
|
||||
|
||||
my $class = $self->associated_metaclass->name;
|
||||
my @source = (
|
||||
'sub {',
|
||||
'my $self = shift;',
|
||||
'return ' . $self->_generate_fallback_destructor('$self'),
|
||||
'if Scalar::Util::blessed($self) ne \'' . $class . '\';',
|
||||
$self->_generate_DEMOLISHALL('$self'),
|
||||
'return;',
|
||||
'}',
|
||||
);
|
||||
warn join("\n", @source) if $self->options->{debug};
|
||||
|
||||
my $code = try {
|
||||
$self->_compile_code(source => \@source);
|
||||
}
|
||||
catch {
|
||||
my $source = join("\n", @source);
|
||||
throw_exception( CouldNotEvalDestructor => method_destructor_object => $self,
|
||||
source => $source,
|
||||
error => $_
|
||||
);
|
||||
};
|
||||
|
||||
$self->{'body'} = $code;
|
||||
}
|
||||
|
||||
sub _generate_fallback_destructor {
|
||||
my $self = shift;
|
||||
my ($inv) = @_;
|
||||
|
||||
return $inv . '->Moose::Object::DESTROY(@_)';
|
||||
}
|
||||
|
||||
sub _generate_DEMOLISHALL {
|
||||
my $self = shift;
|
||||
my ($inv) = @_;
|
||||
|
||||
my @methods = $self->associated_metaclass->find_all_methods_by_name('DEMOLISH');
|
||||
return unless @methods;
|
||||
|
||||
return (
|
||||
'local $?;',
|
||||
'my $igd = Devel::GlobalDestruction::in_global_destruction;',
|
||||
'Try::Tiny::try {',
|
||||
(map { $inv . '->' . $_->{class} . '::DEMOLISH($igd);' } @methods),
|
||||
'}',
|
||||
'Try::Tiny::catch {',
|
||||
'die $_;',
|
||||
'};',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
# ABSTRACT: Method Meta Object for destructors
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Moose::Meta::Method::Destructor - Method Meta Object for destructors
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 2.2207
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This class is a subclass of L<Class::MOP::Method::Inlined> that
|
||||
provides Moose-specific functionality for inlining destructors.
|
||||
|
||||
To understand this class, you should read the
|
||||
L<Class::MOP::Method::Inlined> documentation as well.
|
||||
|
||||
=head1 INHERITANCE
|
||||
|
||||
C<Moose::Meta::Method::Destructor> is a subclass of
|
||||
L<Moose::Meta::Method> I<and> L<Class::MOP::Method::Inlined>.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
=head2 Moose::Meta::Method::Destructor->new(%options)
|
||||
|
||||
This constructs a new object. It accepts the following options:
|
||||
|
||||
=over 4
|
||||
|
||||
=item * package_name
|
||||
|
||||
The package for the class in which the destructor is being
|
||||
inlined. This option is required.
|
||||
|
||||
=item * name
|
||||
|
||||
The name of the destructor method. This option is required.
|
||||
|
||||
=item * metaclass
|
||||
|
||||
The metaclass for the class this destructor belongs to. This is
|
||||
optional, as it can be set later by calling C<<
|
||||
$metamethod->attach_to_class >>.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Moose::Meta;:Method::Destructor->is_needed($metaclass)
|
||||
|
||||
Given a L<Moose::Meta::Class> object, this method returns a boolean
|
||||
indicating whether the class needs a destructor. If the class or any
|
||||
of its parents defines a C<DEMOLISH> method, it needs a destructor.
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
See L<Moose/BUGS> for details on reporting bugs.
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
=over 4
|
||||
|
||||
=item *
|
||||
|
||||
Stevan Little <stevan@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Dave Rolsky <autarch@urth.org>
|
||||
|
||||
=item *
|
||||
|
||||
Jesse Luehrs <doy@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Shawn M Moore <sartak@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
|
||||
|
||||
=item *
|
||||
|
||||
Karen Etheridge <ether@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Florian Ragwitz <rafl@debian.org>
|
||||
|
||||
=item *
|
||||
|
||||
Hans Dieter Pearcey <hdp@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Chris Prather <chris@prather.org>
|
||||
|
||||
=item *
|
||||
|
||||
Matt S Trout <mstrout@cpan.org>
|
||||
|
||||
=back
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2006 by Infinity Interactive, Inc.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
112
CPAN/Moose/Meta/Method/Meta.pm
Normal file
112
CPAN/Moose/Meta/Method/Meta.pm
Normal file
@@ -0,0 +1,112 @@
|
||||
package Moose::Meta::Method::Meta;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use parent 'Moose::Meta::Method',
|
||||
'Class::MOP::Method::Meta';
|
||||
|
||||
sub _is_caller_mop_internal {
|
||||
my $self = shift;
|
||||
my ($caller) = @_;
|
||||
return 1 if $caller =~ /^Moose(?:::|$)/;
|
||||
return $self->SUPER::_is_caller_mop_internal($caller);
|
||||
}
|
||||
|
||||
# XXX: ugh multiple inheritance
|
||||
sub wrap {
|
||||
my $class = shift;
|
||||
return $class->Class::MOP::Method::Meta::wrap(@_);
|
||||
}
|
||||
|
||||
sub _make_compatible_with {
|
||||
my $self = shift;
|
||||
return $self->Class::MOP::Method::Meta::_make_compatible_with(@_);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
# ABSTRACT: A Moose Method metaclass for C<meta> methods
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Moose::Meta::Method::Meta - A Moose Method metaclass for C<meta> methods
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 2.2207
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This class is a subclass of L<Class::MOP::Method::Meta> that
|
||||
provides additional Moose-specific functionality, all of which is
|
||||
private.
|
||||
|
||||
To understand this class, you should read the
|
||||
L<Class::MOP::Method::Meta> documentation.
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
See L<Moose/BUGS> for details on reporting bugs.
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
=over 4
|
||||
|
||||
=item *
|
||||
|
||||
Stevan Little <stevan@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Dave Rolsky <autarch@urth.org>
|
||||
|
||||
=item *
|
||||
|
||||
Jesse Luehrs <doy@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Shawn M Moore <sartak@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
|
||||
|
||||
=item *
|
||||
|
||||
Karen Etheridge <ether@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Florian Ragwitz <rafl@debian.org>
|
||||
|
||||
=item *
|
||||
|
||||
Hans Dieter Pearcey <hdp@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Chris Prather <chris@prather.org>
|
||||
|
||||
=item *
|
||||
|
||||
Matt S Trout <mstrout@cpan.org>
|
||||
|
||||
=back
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2006 by Infinity Interactive, Inc.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
160
CPAN/Moose/Meta/Method/Overridden.pm
Normal file
160
CPAN/Moose/Meta/Method/Overridden.pm
Normal file
@@ -0,0 +1,160 @@
|
||||
package Moose::Meta::Method::Overridden;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use parent 'Moose::Meta::Method';
|
||||
|
||||
use Moose::Util 'throw_exception';
|
||||
|
||||
sub new {
|
||||
my ( $class, %args ) = @_;
|
||||
|
||||
# the package can be overridden by roles
|
||||
# it is really more like body's compilation stash
|
||||
# this is where we need to override the definition of super() so that the
|
||||
# body of the code can call the right overridden version
|
||||
my $super_package = $args{package} || $args{class}->name;
|
||||
|
||||
my $name = $args{name};
|
||||
|
||||
my $super = $args{class}->find_next_method_by_name($name);
|
||||
|
||||
(defined $super)
|
||||
|| throw_exception( CannotOverrideNoSuperMethod => class => $class,
|
||||
params => \%args,
|
||||
method_name => $name
|
||||
);
|
||||
|
||||
my $super_body = $super->body;
|
||||
|
||||
my $method = $args{method};
|
||||
|
||||
my $body = sub {
|
||||
local $Moose::SUPER_PACKAGE = $super_package;
|
||||
local @Moose::SUPER_ARGS = @_;
|
||||
local $Moose::SUPER_BODY = $super_body;
|
||||
return $method->(@_);
|
||||
};
|
||||
|
||||
# FIXME do we need this make sure this works for next::method?
|
||||
# subname "${super_package}::${name}", $method;
|
||||
|
||||
# FIXME store additional attrs
|
||||
$class->wrap(
|
||||
$body,
|
||||
package_name => $args{class}->name,
|
||||
name => $name
|
||||
);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
# ABSTRACT: A Moose Method metaclass for overridden methods
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Moose::Meta::Method::Overridden - A Moose Method metaclass for overridden methods
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 2.2207
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This class implements method overriding logic for the L<Moose>
|
||||
C<override> keyword.
|
||||
|
||||
The overriding subroutine's parent will be invoked explicitly using
|
||||
the C<super> keyword from the parent class's method definition.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
=head2 Moose::Meta::Method::Overridden->new(%options)
|
||||
|
||||
This constructs a new object. It accepts the following options:
|
||||
|
||||
=over 4
|
||||
|
||||
=item * class
|
||||
|
||||
The metaclass object for the class in which the override is being
|
||||
declared. This option is required.
|
||||
|
||||
=item * name
|
||||
|
||||
The name of the method which we are overriding. This method must exist
|
||||
in one of the class's superclasses. This option is required.
|
||||
|
||||
=item * method
|
||||
|
||||
The subroutine reference which implements the overriding. This option
|
||||
is required.
|
||||
|
||||
=back
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
See L<Moose/BUGS> for details on reporting bugs.
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
=over 4
|
||||
|
||||
=item *
|
||||
|
||||
Stevan Little <stevan@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Dave Rolsky <autarch@urth.org>
|
||||
|
||||
=item *
|
||||
|
||||
Jesse Luehrs <doy@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Shawn M Moore <sartak@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
|
||||
|
||||
=item *
|
||||
|
||||
Karen Etheridge <ether@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Florian Ragwitz <rafl@debian.org>
|
||||
|
||||
=item *
|
||||
|
||||
Hans Dieter Pearcey <hdp@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Chris Prather <chris@prather.org>
|
||||
|
||||
=item *
|
||||
|
||||
Matt S Trout <mstrout@cpan.org>
|
||||
|
||||
=back
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2006 by Infinity Interactive, Inc.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
185
CPAN/Moose/Meta/Mixin/AttributeCore.pm
Normal file
185
CPAN/Moose/Meta/Mixin/AttributeCore.pm
Normal file
@@ -0,0 +1,185 @@
|
||||
package Moose::Meta::Mixin::AttributeCore;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use parent 'Class::MOP::Mixin::AttributeCore';
|
||||
|
||||
__PACKAGE__->meta->add_attribute(
|
||||
'isa' => (
|
||||
reader => '_isa_metadata',
|
||||
Class::MOP::_definition_context(),
|
||||
)
|
||||
);
|
||||
|
||||
__PACKAGE__->meta->add_attribute(
|
||||
'does' => (
|
||||
reader => '_does_metadata',
|
||||
Class::MOP::_definition_context(),
|
||||
)
|
||||
);
|
||||
|
||||
__PACKAGE__->meta->add_attribute(
|
||||
'is' => (
|
||||
reader => '_is_metadata',
|
||||
Class::MOP::_definition_context(),
|
||||
)
|
||||
);
|
||||
|
||||
__PACKAGE__->meta->add_attribute(
|
||||
'required' => (
|
||||
reader => 'is_required',
|
||||
Class::MOP::_definition_context(),
|
||||
)
|
||||
);
|
||||
|
||||
__PACKAGE__->meta->add_attribute(
|
||||
'lazy' => (
|
||||
reader => 'is_lazy',
|
||||
Class::MOP::_definition_context(),
|
||||
)
|
||||
);
|
||||
|
||||
__PACKAGE__->meta->add_attribute(
|
||||
'lazy_build' => (
|
||||
reader => 'is_lazy_build',
|
||||
Class::MOP::_definition_context(),
|
||||
)
|
||||
);
|
||||
|
||||
__PACKAGE__->meta->add_attribute(
|
||||
'coerce' => (
|
||||
reader => 'should_coerce',
|
||||
Class::MOP::_definition_context(),
|
||||
)
|
||||
);
|
||||
|
||||
__PACKAGE__->meta->add_attribute(
|
||||
'weak_ref' => (
|
||||
reader => 'is_weak_ref',
|
||||
Class::MOP::_definition_context(),
|
||||
)
|
||||
);
|
||||
|
||||
__PACKAGE__->meta->add_attribute(
|
||||
'auto_deref' => (
|
||||
reader => 'should_auto_deref',
|
||||
Class::MOP::_definition_context(),
|
||||
)
|
||||
);
|
||||
|
||||
__PACKAGE__->meta->add_attribute(
|
||||
'type_constraint' => (
|
||||
reader => 'type_constraint',
|
||||
predicate => 'has_type_constraint',
|
||||
Class::MOP::_definition_context(),
|
||||
)
|
||||
);
|
||||
|
||||
__PACKAGE__->meta->add_attribute(
|
||||
'trigger' => (
|
||||
reader => 'trigger',
|
||||
predicate => 'has_trigger',
|
||||
Class::MOP::_definition_context(),
|
||||
)
|
||||
);
|
||||
|
||||
__PACKAGE__->meta->add_attribute(
|
||||
'handles' => (
|
||||
reader => 'handles',
|
||||
writer => '_set_handles',
|
||||
predicate => 'has_handles',
|
||||
Class::MOP::_definition_context(),
|
||||
)
|
||||
);
|
||||
|
||||
__PACKAGE__->meta->add_attribute(
|
||||
'documentation' => (
|
||||
reader => 'documentation',
|
||||
predicate => 'has_documentation',
|
||||
Class::MOP::_definition_context(),
|
||||
)
|
||||
);
|
||||
|
||||
1;
|
||||
|
||||
# ABSTRACT: Core attributes shared by attribute metaclasses
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Moose::Meta::Mixin::AttributeCore - Core attributes shared by attribute metaclasses
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 2.2207
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This class implements the core attributes (aka properties) shared by all Moose
|
||||
attributes. See the L<Moose::Meta::Attribute> documentation for API details.
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
See L<Moose/BUGS> for details on reporting bugs.
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
=over 4
|
||||
|
||||
=item *
|
||||
|
||||
Stevan Little <stevan@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Dave Rolsky <autarch@urth.org>
|
||||
|
||||
=item *
|
||||
|
||||
Jesse Luehrs <doy@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Shawn M Moore <sartak@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
|
||||
|
||||
=item *
|
||||
|
||||
Karen Etheridge <ether@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Florian Ragwitz <rafl@debian.org>
|
||||
|
||||
=item *
|
||||
|
||||
Hans Dieter Pearcey <hdp@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Chris Prather <chris@prather.org>
|
||||
|
||||
=item *
|
||||
|
||||
Matt S Trout <mstrout@cpan.org>
|
||||
|
||||
=back
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2006 by Infinity Interactive, Inc.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
107
CPAN/Moose/Meta/Object/Trait.pm
Normal file
107
CPAN/Moose/Meta/Object/Trait.pm
Normal file
@@ -0,0 +1,107 @@
|
||||
package Moose::Meta::Object::Trait;
|
||||
our $VERSION = '2.2207';
|
||||
|
||||
use Scalar::Util qw(blessed);
|
||||
|
||||
sub _get_compatible_metaclass {
|
||||
my $orig = shift;
|
||||
my $self = shift;
|
||||
return $self->$orig(@_)
|
||||
|| $self->_get_compatible_metaclass_by_role_reconciliation(@_);
|
||||
}
|
||||
|
||||
sub _get_compatible_metaclass_by_role_reconciliation {
|
||||
my $self = shift;
|
||||
my ($other_name) = @_;
|
||||
my $meta_name = blessed($self) ? $self->_real_ref_name : $self;
|
||||
|
||||
return unless Moose::Util::_classes_differ_by_roles_only(
|
||||
$meta_name, $other_name
|
||||
);
|
||||
|
||||
return Moose::Util::_reconcile_roles_for_metaclass(
|
||||
$meta_name, $other_name
|
||||
);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
# ABSTRACT: Some overrides for L<Class::MOP::Object> functionality
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Moose::Meta::Object::Trait - Some overrides for L<Class::MOP::Object> functionality
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 2.2207
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module is entirely private, you shouldn't ever need to interact with
|
||||
it directly.
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
See L<Moose/BUGS> for details on reporting bugs.
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
=over 4
|
||||
|
||||
=item *
|
||||
|
||||
Stevan Little <stevan@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Dave Rolsky <autarch@urth.org>
|
||||
|
||||
=item *
|
||||
|
||||
Jesse Luehrs <doy@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Shawn M Moore <sartak@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
|
||||
|
||||
=item *
|
||||
|
||||
Karen Etheridge <ether@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Florian Ragwitz <rafl@debian.org>
|
||||
|
||||
=item *
|
||||
|
||||
Hans Dieter Pearcey <hdp@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Chris Prather <chris@prather.org>
|
||||
|
||||
=item *
|
||||
|
||||
Matt S Trout <mstrout@cpan.org>
|
||||
|
||||
=back
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2006 by Infinity Interactive, Inc.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
1059
CPAN/Moose/Meta/Role.pm
Normal file
1059
CPAN/Moose/Meta/Role.pm
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user