unless $accessor_class && $accessor_class->can('new');
return $accessor_class->new(
- name => $handle_name,
- package_name => $self->associated_class->name,
- attribute => $self,
- is_inline => 1,
- curried_arguments => \@curried_args,
- root_types => [ $self->_root_types ],
+ 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 _native_accessor_class_for {
my ( $self, $suffix ) = @_;
- return 'Moose::Meta::Method::Accessor::Native::' . $self->_native_type . '::' . $suffix;
+ my $role
+ = 'Moose::Meta::Method::Accessor::Native::'
+ . $self->_native_type . '::'
+ . $suffix;
+
+ return Moose::Meta::Class->create_anon_class(
+ superclasses =>
+ [ $self->accessor_metaclass, $self->delegation_metaclass ],
+ roles => [$role],
+ cache => 1,
+ )->name;
}
sub _build_native_type {
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor', 'Moose::Meta::Method::Delegation';
+use Moose::Role;
-sub new {
+around new => sub {
+ my $orig = shift;
my $class = shift;
my %options = @_;
- die "Cannot instantiate a $class object directly"
- if $class eq __PACKAGE__;
-
- ( exists $options{attribute} )
- || confess "You must supply an attribute to construct with";
-
- ( blessed( $options{attribute} )
- && $options{attribute}->isa('Class::MOP::Attribute') )
- || confess
- "You must supply an attribute which is a 'Class::MOP::Attribute' instance";
-
- ( $options{package_name} && $options{name} )
- || confess "You must supply the package_name and name parameters";
-
exists $options{curried_arguments}
|| ( $options{curried_arguments} = [] );
|| confess
'You must supply a curried_arguments which is an ARRAY reference';
- $options{delegate_to_method} = lc( ( split /::/, $class)[-1] );
-
$options{definition_context} = $options{attribute}->definition_context;
- my $self = $class->_new( \%options );
+ $options{accessor_type} = 'native';
- weaken( $self->{'attribute'} );
+ return $class->$orig(%options);
+};
- $self->_initialize_body;
-
- return $self;
-}
-
-sub _new {
+around _new => sub {
+ shift;
my $class = shift;
my $options = @_ == 1 ? $_[0] : {@_};
return bless $options, $class;
-}
+};
sub root_types { (shift)->{'root_types'} }
sub _minimum_arguments { 0 }
sub _maximum_arguments { undef }
-sub _inline_check_arguments { q{} }
-
-sub _inline_get {
+override _inline_get => sub {
my ( $self, $instance ) = @_;
return $self->_slot_access_can_be_inlined
- ? $self->SUPER::_inline_get($instance)
+ ? super()
: "${instance}->\$reader";
-}
+};
-sub _inline_store {
+override _inline_store => sub {
my ( $self, $instance, $value ) = @_;
return $self->_slot_access_can_be_inlined
- ? $self->SUPER::_inline_store( $instance, $value )
+ ? super()
: "${instance}->\$writer($value)";
-}
+};
-sub _eval_environment {
+override _eval_environment => sub {
my $self = shift;
- my $env = $self->SUPER::_eval_environment(@_);
+ my $env = super();
$env->{'@curried'} = $self->curried_arguments;
$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;
use strict;
use warnings;
+use Moose::Role;
+
use Scalar::Util qw( looks_like_number );
our $VERSION = '1.14';
. qq{ unless defined $var && $var =~ /^-?\\d+\$/;};
}
+no Moose::Role;
+
1;
use strict;
use warnings;
-use Class::MOP::MiniTrait;
-
our $VERSION = '1.14';
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Writer';
+use Moose::Role;
-Class::MOP::MiniTrait::apply( __PACKAGE__,
- 'Moose::Meta::Method::Accessor::Native::Array'
-);
-Class::MOP::MiniTrait::apply( __PACKAGE__,
- 'Moose::Meta::Method::Accessor::Native::Collection'
-);
+with 'Moose::Meta::Method::Accessor::Native::Writer',
+ 'Moose::Meta::Method::Accessor::Native::Array',
+ 'Moose::Meta::Method::Accessor::Native::Collection';
sub _new_members {'@_'}
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base qw(
- Moose::Meta::Method::Accessor::Native::Array::set
- Moose::Meta::Method::Accessor::Native::Array::get
-);
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Array::set' => {
+ -excludes => [
+ qw( _generate_method
+ _minimum_arguments
+ _maximum_arguments
+ _inline_process_arguments
+ _inline_check_arguments
+ _return_value)
+ ]
+ },
+ 'Moose::Meta::Method::Accessor::Native::Array::get' => {
+ -excludes => [
+ qw(
+ _generate_method
+ _minimum_arguments
+ _maximum_arguments
+ )
+ ]
+ };
sub _generate_method {
my $self = shift;
sub _minimum_arguments {2}
sub _maximum_arguments {2}
-sub _adds_members {1}
-
-sub _new_members {'$_[1]'}
+no Moose::Role;
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Array::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Array::Writer' => {
+ -excludes => [
+ qw(
+ _maximum_arguments
+ _inline_optimized_set_new_value
+ )
+ ]
+};
sub _maximum_arguments { 0 }
return "$slot_access = []";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Reader';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Reader' =>
+ { -excludes => ['_maximum_arguments'] };
sub _maximum_arguments { 0 }
return "scalar \@{ $slot_access }";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Array::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Array::Writer' => {
+ -excludes => [
+ qw(
+ _minimum_arguments
+ _maximum_arguments
+ _inline_check_arguments
+ _inline_optimized_set_new_value
+ )
+ ],
+};
sub _minimum_arguments { 1 }
return "splice \@{ $slot_access }, \$_[0], 1";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Reader';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Reader' =>
+ { -excludes => ['_maximum_arguments'] };
sub _maximum_arguments { 0 }
return "\@{ $slot_access }";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Reader';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Reader' => {
+ -excludes => [
+ qw(
+ _minimum_arguments
+ _maximum_arguments
+ _inline_check_arguments
+ )
+ ]
+};
sub _minimum_arguments { 1 }
return "&List::Util::first( \$_[0], \@{ ${slot_access} } )";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Reader';
-
-Class::MOP::MiniTrait::apply( __PACKAGE__,
- 'Moose::Meta::Method::Accessor::Native::Array'
-);
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Reader' => {
+ -excludes => [
+ qw(
+ _minimum_arguments
+ _maximum_arguments
+ _inline_check_arguments
+ )
+ ],
+ },
+ 'Moose::Meta::Method::Accessor::Native::Array';
sub _minimum_arguments { 1 }
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Reader';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Reader' => {
+ -excludes => [
+ qw(
+ _minimum_arguments
+ _maximum_arguments
+ _inline_check_arguments
+ )
+ ]
+};
sub _minimum_arguments { 1 }
return "grep { \$_[0]->() } \@{ $slot_access }";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Array::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Array::Writer' => {
+ -excludes => [
+ qw(
+ _minimum_arguments
+ _maximum_arguments
+ _new_members
+ _inline_optimized_set_new_value
+ )
+ ]
+};
sub _minimum_arguments { 2 }
return "splice \@{ $slot_access }, \$_[0], 0, \$_[1];";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Reader';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Reader' =>
+ { -excludes => ['_maximum_arguments'] };
+
+sub _maximum_arguments { 0 }
sub _return_value {
my $self = shift;
return "\@{ $slot_access } ? 0 : 1";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Reader';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Reader' => {
+ -excludes => [
+ qw(
+ _minimum_arguments
+ _maximum_arguments
+ _inline_check_arguments
+ )
+ ]
+};
sub _minimum_arguments { 1 }
return "join \$_[0], \@{ $slot_access }";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Reader';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Reader' => {
+ -excludes => [
+ qw(
+ _minimum_arguments
+ _maximum_arguments
+ _inline_check_arguments
+ )
+ ]
+};
sub _minimum_arguments { 1 }
return "map { \$_[0]->() } \@{ $slot_access }";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Reader';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Reader' => {
+ -excludes => [
+ qw(
+ _minimum_arguments
+ _maximum_arguments
+ _inline_check_arguments
+ _inline_return_value
+ )
+ ]
+};
sub _minimum_arguments {1}
. 'return $iter;' . "\n" . '}';
}
+# Not called, but needed to satisfy the Reader role
+sub _return_value { }
+
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Array::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Array::Writer' => {
+ -excludes => [
+ qw( _maximum_arguments
+ _inline_capture_return_value
+ _inline_optimized_set_new_value
+ _return_value )
+ ]
+};
sub _maximum_arguments { 0 }
return 'return $old;';
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Array::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Array::Writer' =>
+ { -excludes => ['_inline_optimized_set_new_value'] };
sub _adds_members { 1 }
return "push \@{ $slot_access }, \@_";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Reader';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Reader' => {
+ -excludes => [
+ qw(
+ _minimum_arguments
+ _maximum_arguments
+ _inline_check_arguments
+ )
+ ]
+};
sub _minimum_arguments { 1 }
return "List::Util::reduce { \$_[0]->( \$a, \$b ) } \@{ ${slot_access} }";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Array::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Array::Writer' => {
+ -excludes => [
+ qw(
+ _minimum_arguments
+ _maximum_arguments
+ _inline_check_arguments
+ _new_members
+ _inline_optimized_set_new_value
+ )
+ ]
+};
sub _minimum_arguments { 2 }
return "${slot_access}->[ \$_[0] ] = \$_[1]";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Array::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Array::Writer' => {
+ -excludes => [
+ qw(
+ _maximum_arguments
+ _inline_capture_return_value
+ _inline_optimized_set_new_value
+ _return_value
+ )
+ ]
+};
sub _maximum_arguments { 0 }
return 'return $old';
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Reader';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Reader' =>
+ { -excludes => ['_maximum_arguments'] };
sub _maximum_arguments { 0 }
return "List::Util::shuffle \@{ $slot_access }";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Reader';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Reader' => {
+ -excludes => [
+ qw(
+ _maximum_arguments
+ _inline_check_arguments
+ )
+ ]
+};
sub _maximum_arguments { 1 }
"\$_[0] ? sort { \$_[0]->( \$a, \$b ) } \@{ ${slot_access} } : sort \@{ $slot_access }";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Array::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Array::Writer' => {
+ -excludes => [
+ qw(
+ _maximum_arguments
+ _inline_check_arguments
+ )
+ ]
+};
sub _maximum_arguments { 1 }
"[ \$_[0] ? sort { \$_[0]->( \$a, \$b ) } \@{ $slot_access } : sort \@{ $slot_access} ]";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Array::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Array::Writer' => {
+ -excludes => [
+ qw(
+ _minimum_arguments
+ _inline_process_arguments
+ _inline_check_arguments
+ _inline_optimized_set_new_value
+ )
+ ]
+};
sub _minimum_arguments { 1 }
return "defined \$len ? ( splice \@{ $slot_access }, \$idx, \$len, \@_ ) : ( splice \@{ $slot_access }, \$idx )";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Reader';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Reader' =>
+ { -excludes => ['_maximum_arguments'] };
sub _maximum_arguments { 0 }
return "List::MoreUtils::uniq \@{ $slot_access }";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Array::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Array::Writer' =>
+ { -excludes => ['_inline_optimized_set_new_value'] };
sub _adds_members { 1 }
return "unshift \@{ $slot_access }, \@_";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Reader';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Reader' =>
+ { -excludes => ['_maximum_arguments'] };
-sub _minimum_arguments { 0 }
sub _maximum_arguments { 0 }
sub _return_value {
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Writer' => {
+ -excludes => [
+ qw(
+ _maximum_arguments
+ _inline_optimized_set_new_value
+ )
+ ]
+};
-sub _minimum_arguments { 0 }
sub _maximum_arguments { 0 }
sub _potential_value { 1 }
return "$slot_access = 1";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Writer' => {
+ -excludes => [
+ qw(
+ _maximum_arguments
+ _inline_optimized_set_new_value
+ )
+ ]
+};
-sub _minimum_arguments { 0 }
sub _maximum_arguments { 0 }
sub _potential_value {
return "$slot_access = $slot_access ? 0 : 1";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Writer' => {
+ -excludes => [
+ qw(
+ _maximum_arguments
+ _inline_optimized_set_new_value
+ )
+ ]
+};
-sub _minimum_arguments { 0 }
sub _maximum_arguments { 0 }
sub _potential_value { 0 }
return "$slot_access = 0";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Reader';
+use Moose::Role;
-sub _minimum_arguments { 0 }
-sub _maximum_arguments { undef }
+with 'Moose::Meta::Method::Accessor::Native::Reader';
sub _return_value {
my ( $self, $slot_access ) = @_;
return "${slot_access}->(\@_)";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Reader';
+use Moose::Role;
-sub _minimum_arguments { 0 }
-sub _maximum_arguments { undef }
+with 'Moose::Meta::Method::Accessor::Native::Reader';
sub _return_value {
my ( $self, $slot_access ) = @_;
return "${slot_access}->(\$self, \@_)";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-sub _value_needs_copy {
+use Moose::Role;
+
+requires qw( _adds_members );
+
+around _value_needs_copy => sub {
shift;
my $self = shift;
return $self->_constraint_must_be_checked
&& !$self->_check_new_members_only;
-}
+};
-sub _inline_tc_code {
+around _inline_tc_code => sub {
shift;
my ( $self, $potential_value ) = @_;
return $self->_inline_check_coercion($potential_value) . "\n"
. $self->_inline_check_constraint($potential_value);
}
-}
+};
sub _check_new_members_only {
my $self = shift;
) . " for $new_value;";
}
-sub _inline_check_constraint {
+around _inline_check_constraint => sub {
my $orig = shift;
my $self = shift;
return q{} unless $self->_constraint_must_be_checked;
return $self->$orig( $_[0] );
-}
+};
-sub _inline_get_old_value_for_trigger {
+around _inline_get_old_value_for_trigger => sub {
shift;
my ( $self, $instance ) = @_;
. $self->_inline_has($instance) . q{ ? }
. $self->_inline_copy_old_value( $self->_inline_get($instance) )
. ": ();\n";
-}
+};
-sub _eval_environment {
+around _eval_environment => sub {
my $orig = shift;
my $self = shift;
->_compiled_type_constraint );
return $env;
-}
+};
no Moose::Role;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Writer';
sub _constraint_must_be_checked {
my $self = shift;
|| ( $attr->should_coerce && $attr->type_constraint->has_coercion ) );
}
-sub _inline_check_coercion {
- my ( $self, $value ) = @_;
-
- my $attr = $self->associated_attribute;
-
- return ''
- unless $attr->should_coerce && $attr->type_constraint->has_coercion;
-
- # We want to break the aliasing in @_ in case the coercion tries to make a
- # destructive change to an array member.
- return "$value = $attr->type_constraint->coerce($value);";
-}
+no Moose::Role;
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Writer' => {
+ -excludes => [
+ qw(
+ _minimum_arguments
+ _maximum_arguments
+ _inline_optimized_set_new_value
+ )
+ ]
+};
sub _minimum_arguments {0}
sub _maximum_arguments {1}
return "$slot_access -= defined \$_[0] ? \$_[0] : 1";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Writer' => {
+ -excludes => [
+ qw(
+ _minimum_arguments
+ _maximum_arguments
+ _inline_optimized_set_new_value
+ )
+ ]
+};
sub _minimum_arguments { 0 }
sub _maximum_arguments { 1 }
return "$slot_access += defined \$_[0] ? \$_[0] : 1";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Writer' => {
+ -excludes => [
+ qw(
+ _maximum_arguments
+ _inline_optimized_set_new_value
+ )
+ ]
+};
-sub _minimum_arguments { 0 }
sub _maximum_arguments { 0 }
sub _potential_value {
return "$slot_access = \$attr->default(\$self)";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Writer' => {
+ -excludes => [
+ qw(
+ _minimum_arguments
+ _maximum_arguments
+ _inline_optimized_set_new_value
+ )
+ ]
+};
sub _minimum_arguments {1}
sub _maximum_arguments {1}
return "$slot_access = \$_[0];";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-# This package is really more of a role, so it doesn't inherit from anything.
+use Moose::Role;
sub _inline_check_var_is_valid_key {
my ( $self, $var ) = @_;
. qq{ unless defined $var;};
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Writer';
+use Moose::Role;
-Class::MOP::MiniTrait::apply( __PACKAGE__,
- 'Moose::Meta::Method::Accessor::Native::Hash'
-);
-Class::MOP::MiniTrait::apply( __PACKAGE__,
- 'Moose::Meta::Method::Accessor::Native::Collection'
-);
+with 'Moose::Meta::Method::Accessor::Native::Writer',
+ 'Moose::Meta::Method::Accessor::Native::Hash',
+ 'Moose::Meta::Method::Accessor::Native::Collection';
sub _new_values {'@values'}
return '{ %{' . $slot_access . '} }';
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base qw(
- Moose::Meta::Method::Accessor::Native::Hash::set
- Moose::Meta::Method::Accessor::Native::Hash::get
-);
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Hash::set' => {
+ -excludes => [
+ qw(
+ _generate_method
+ _minimum_arguments
+ _maximum_arguments
+ _inline_check_arguments
+ _return_value
+ )
+ ]
+ },
+ 'Moose::Meta::Method::Accessor::Native::Hash::get' => {
+ -excludes => [
+ qw(
+ _generate_method
+ _minimum_arguments
+ _maximum_arguments
+ _inline_check_argument_count
+ _inline_process_arguments
+ )
+ ]
+ };
sub _generate_method {
my $self = shift;
sub _minimum_arguments {2}
sub _maximum_arguments {2}
-sub _adds_members {1}
-
-sub _new_members {'$_[1]'}
+no Moose::Role;
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Hash::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Hash::Writer' => {
+ -excludes => [
+ qw(
+ _maximum_arguments
+ _inline_optimized_set_new_value
+ )
+ ]
+};
sub _maximum_arguments { 0 }
return "$slot_access = {}";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Reader';
+use Moose::Role;
-sub _minimum_arguments { 0 }
+with 'Moose::Meta::Method::Accessor::Native::Reader' =>
+ { -excludes => ['_maximum_arguments'] };
sub _maximum_arguments { 0 }
return "scalar keys \%{ $slot_access }";
}
+no Moose::Role;
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base qw(
- Moose::Meta::Method::Accessor::Native::Hash
- Moose::Meta::Method::Accessor::Native::Reader
-);
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Reader' => {
+ -excludes => [
+ qw(
+ _minimum_arguments
+ _maximum_arguments
+ _inline_check_arguments
+ )
+ ],
+ },
+ 'Moose::Meta::Method::Accessor::Native::Hash';
sub _minimum_arguments { 1 }
return "defined ${slot_access}->{ \$_[0] }";
}
+no Moose::Role;
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Hash::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Hash::Writer' =>
+ { -excludes => ['_inline_optimized_set_new_value'] };
sub _adds_members { 0 }
return "delete \@{ $slot_access }{\@_}";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Reader';
+use Moose::Role;
-sub _minimum_arguments { 0 }
+with 'Moose::Meta::Method::Accessor::Native::Reader' =>
+ { -excludes => ['_maximum_arguments'] };
sub _maximum_arguments { 0 }
return "map { \$_, ${slot_access}->{\$_} } keys \%{ $slot_access }";
}
+no Moose::Role;
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base qw(
- Moose::Meta::Method::Accessor::Native::Hash
- Moose::Meta::Method::Accessor::Native::Reader
-);
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Reader' => {
+ -excludes => [
+ qw(
+ _minimum_arguments
+ _maximum_arguments
+ _inline_check_arguments
+ )
+ ],
+ },
+ 'Moose::Meta::Method::Accessor::Native::Hash';
sub _minimum_arguments { 1 }
return "exists ${slot_access}->{ \$_[0] }";
}
+no Moose::Role;
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Reader';
-
-Class::MOP::MiniTrait::apply( __PACKAGE__,
- 'Moose::Meta::Method::Accessor::Native::Hash'
-);
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Reader' => {
+ -excludes => [
+ qw(
+ _minimum_arguments
+ _inline_check_arguments
+ )
+ ],
+ },
+ 'Moose::Meta::Method::Accessor::Native::Hash';
sub _minimum_arguments { 1 }
-sub _maximum_arguments { undef }
-
sub _inline_check_arguments {
my $self = shift;
return "\@_ > 1 ? \@{ $slot_access }{\@_} : ${slot_access}->{ \$_[0] }";
}
+no Moose::Role;
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Reader';
+use Moose::Role;
-sub _minimum_arguments { 0 }
+with 'Moose::Meta::Method::Accessor::Native::Reader' =>
+ { -excludes => ['_maximum_arguments'] };
sub _maximum_arguments { 0 }
return "scalar keys \%{ $slot_access } ? 0 : 1";
}
+no Moose::Role;
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Reader';
+use Moose::Role;
-sub _minimum_arguments { 0 }
+with 'Moose::Meta::Method::Accessor::Native::Reader' =>
+ { -excludes => ['_maximum_arguments'] };
sub _maximum_arguments { 0 }
return "keys \%{ $slot_access }";
}
+no Moose::Role;
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Reader';
+use Moose::Role;
-sub _minimum_arguments { 0 }
+with 'Moose::Meta::Method::Accessor::Native::Reader' =>
+ { -excludes => ['_maximum_arguments'] };
sub _maximum_arguments { 0 }
return "map { [ \$_, ${slot_access}->{\$_} ] } keys \%{ $slot_access }";
}
+no Moose::Role;
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Hash::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Hash::Writer' => {
+ -excludes => [
+ qw(
+ _minimum_arguments
+ _maximum_arguments
+ _inline_process_arguments
+ _inline_check_arguments
+ _inline_optimized_set_new_value
+ )
+ ],
+};
sub _minimum_arguments { 2 }
sub _maximum_arguments { undef }
-sub _inline_check_argument_count {
+around _inline_check_argument_count => sub {
+ my $orig = shift;
my $self = shift;
return
- $self->SUPER::_inline_check_argument_count(@_) . "\n"
+ $self->$orig(@_) . "\n"
. $self->_inline_throw_error(
q{'You must pass an even number of arguments to set'})
. ' if @_ % 2;';
-}
+};
sub _inline_process_arguments {
my $self = shift;
return "\@{ $slot_access }{ \@_[ \@keys_idx] } = \@_[ \@values_idx ]";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Reader';
+use Moose::Role;
-sub _minimum_arguments { 0 }
+with 'Moose::Meta::Method::Accessor::Native::Reader' =>
+ { -excludes => ['_maximum_arguments'] };
sub _maximum_arguments { 0 }
return "values \%{ $slot_access }";
}
+no Moose::Role;
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Writer' => {
+ -excludes => [
+ qw(
+ _maximum_arguments
+ _inline_optimized_set_new_value
+ )
+ ]
+};
-sub _minimum_arguments {0}
sub _maximum_arguments {0}
sub _potential_value {
return "$slot_access = abs($slot_access)";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Writer' => {
+ -excludes => [
+ qw(
+ _minimum_arguments
+ _maximum_arguments
+ _inline_optimized_set_new_value
+ )
+ ]
+};
sub _minimum_arguments {1}
+
sub _maximum_arguments {1}
sub _potential_value {
return "$slot_access += \$_[0]";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Writer' => {
+ -excludes => [
+ qw(
+ _minimum_arguments
+ _maximum_arguments
+ _inline_optimized_set_new_value
+ )
+ ]
+};
sub _minimum_arguments {1}
+
sub _maximum_arguments {1}
sub _potential_value {
return "$slot_access /= \$_[0]";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Writer' => {
+ -excludes => [
+ qw(
+ _minimum_arguments
+ _maximum_arguments
+ _inline_optimized_set_new_value
+ )
+ ]
+};
sub _minimum_arguments {1}
+
sub _maximum_arguments {1}
sub _potential_value {
return "$slot_access %= \$_[0]";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Writer' => {
+ -excludes => [
+ qw(
+ _minimum_arguments
+ _maximum_arguments
+ _inline_optimized_set_new_value
+ )
+ ]
+};
sub _minimum_arguments {1}
+
sub _maximum_arguments {1}
sub _potential_value {
return "$slot_access *= \$_[0]";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Writer' => {
+ -excludes => [
+ qw(
+ _minimum_arguments
+ _maximum_arguments
+ _inline_optimized_set_new_value
+ )
+ ]
+};
sub _minimum_arguments {1}
sub _maximum_arguments {1}
return "$slot_access = \$_[0]";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Writer' => {
+ -excludes => [
+ qw(
+ _minimum_arguments
+ _maximum_arguments
+ _inline_optimized_set_new_value
+ )
+ ]
+};
sub _minimum_arguments {1}
+
sub _maximum_arguments {1}
sub _potential_value {
return "$slot_access -= \$_[0]";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native';
+
+requires '_return_value';
sub _generate_method {
my $self = shift;
sub _inline_process_arguments {q{}}
+sub _inline_check_arguments {q{}}
+
sub _inline_return_value {
my ( $self, $slot_access ) = @_;
'return ' . $self->_return_value($slot_access) . ';';
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Writer' => {
+ -excludes => [
+ qw(
+ _minimum_arguments
+ _maximum_arguments
+ _inline_optimized_set_new_value
+ )
+ ]
+};
sub _minimum_arguments { 1 }
+
sub _maximum_arguments { 1 }
sub _potential_value {
return "$slot_access .= \$_[0]";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Writer' => {
+ -excludes => [
+ qw(
+ _maximum_arguments
+ _inline_optimized_set_new_value
+ )
+ ]
+};
-sub _minimum_arguments { 0 }
sub _maximum_arguments { 0 }
sub _potential_value {
return "chomp $slot_access";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Writer' => {
+ -excludes => [
+ qw(
+ _maximum_arguments
+ _inline_optimized_set_new_value
+ )
+ ]
+};
-sub _minimum_arguments { 0 }
sub _maximum_arguments { 0 }
sub _potential_value {
return "chop $slot_access";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Writer' => {
+ -excludes => [
+ qw(
+ _maximum_arguments
+ _inline_optimized_set_new_value
+ )
+ ]
+};
-sub _minimum_arguments { 0 }
sub _maximum_arguments { 0 }
sub _potential_value {
return "$slot_access = q{}";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Writer' => {
+ -excludes => [
+ qw(
+ _maximum_arguments
+ _inline_optimized_set_new_value
+ )
+ ]
+};
-sub _minimum_arguments { 0 }
sub _maximum_arguments { 0 }
sub _potential_value {
return "${slot_access}++";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Reader';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Reader' =>
+ { -excludes => ['_maximum_arguments'] };
-sub _minimum_arguments { 0 }
sub _maximum_arguments { 0 }
sub _return_value {
return "length $slot_access";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Reader';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Reader' => {
+ -excludes => [
+ qw(
+ _minimum_arguments
+ _maximum_arguments
+ _inline_check_arguments
+ )
+ ]
+};
sub _minimum_arguments { 1 }
+
sub _maximum_arguments { 1 }
sub _inline_check_arguments {
return "$slot_access =~ \$_[0]";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Writer' => {
+ -excludes => [
+ qw(
+ _minimum_arguments
+ _maximum_arguments
+ _inline_optimized_set_new_value
+ )
+ ]
+};
sub _minimum_arguments { 1 }
+
sub _maximum_arguments { 1 }
sub _potential_value {
return "$slot_access = \$_[0] . $slot_access";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Writer';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Writer' => {
+ -excludes => [
+ qw(
+ _minimum_arguments
+ _maximum_arguments
+ _inline_check_arguments
+ _inline_optimized_set_new_value
+ )
+ ]
+};
sub _minimum_arguments { 1 }
+
sub _maximum_arguments { 2 }
sub _inline_check_arguments {
return "if ( ref \$_[1] ) { $slot_access =~ s/\$_[0]/\$_[1]->()/e; } else { $slot_access =~ s/\$_[0]/\$_[1]/; }";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base qw(
- Moose::Meta::Method::Accessor::Native::Reader
- Moose::Meta::Method::Accessor::Native::Writer
-);
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native::Reader' => {
+ -excludes => [
+ qw( _generate_method
+ _minimum_arguments
+ _maximum_arguments
+ _inline_process_arguments
+ _inline_check_arguments
+ _return_value
+ )
+ ]
+ },
+ 'Moose::Meta::Method::Accessor::Native::Writer' => {
+ -excludes => [
+ qw(
+ _generate_method
+ _minimum_arguments
+ _maximum_arguments
+ _inline_process_arguments
+ _inline_check_arguments
+ _inline_optimized_set_new_value
+ _return_value
+ )
+ ]
+ };
sub _generate_method {
my $self = shift;
return "substr $slot_access, \$offset, \$length";
}
+no Moose::Role;
+
1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native';
+use Moose::Role;
+
+with 'Moose::Meta::Method::Accessor::Native';
+
+requires '_potential_value';
sub _generate_method {
my $self = shift;
return "$value = \$type_constraint_obj->coerce($value);";
}
-sub _inline_check_constraint {
+override _inline_check_constraint => sub {
my $self = shift;
return q{} unless $self->_constraint_must_be_checked;
- return $self->SUPER::_inline_check_constraint( $_[0] );
-}
+ return super();
+};
sub _inline_capture_return_value { return q{} }
sub _inline_set_new_value {
my $self = shift;
- return $self->SUPER::_inline_store(@_)
+ return $self->_inline_store(@_)
if $self->_value_needs_copy || !$self->_slot_access_can_be_inlined;
return $self->_inline_optimized_set_new_value(@_);
-}
+};
sub _inline_optimized_set_new_value {
my $self = shift;
- return $self->SUPER::_inline_store(@_)
+ return $self->_inline_store(@_);
}
sub _return_value { return q{} }
+no Moose::Role;
+
1;
use strict;
use warnings;
+use lib 't/lib';
+
use Moose ();
+use Moose::Util::MetaRole;
use Moose::Util::TypeConstraints;
+use NoInlineAttribute;
use Test::More;
use Test::Exception;
use Test::Moose;
superclasses => ['Moose::Object'],
);
+ my @traits = 'Array';
+ push @traits, 'NoInlineAttribute'
+ if delete $attr{no_inline};
+
$class->add_attribute(
_values => (
- traits => ['Array'],
+ traits => \@traits,
is => 'rw',
isa => 'ArrayRef[Int]',
default => sub { [] },
run_tests(build_class);
run_tests( build_class( lazy => 1, default => sub { [ 42, 84 ] } ) );
run_tests( build_class( trigger => sub { } ) );
+ run_tests( build_class( no_inline => 1 ) );
# Will force the inlining code to check the entire arrayref when it is modified.
subtype 'MyArrayRef', as 'ArrayRef', where { 1 };
'values is not empty after failed call to clear'
);
+ throws_ok { $obj->is_empty(50) }
+ qr/Cannot call is_empty with any arguments/,
+ 'throws an error when is_empty is called with an argument';
+
$obj->clear;
$obj->push( 1, 5, 10, 42 );
use strict;
use warnings;
+use lib 't/lib';
+
use Moose ();
use Moose::Util::TypeConstraints;
+use NoInlineAttribute;
use Test::More;
use Test::Exception;
use Test::Moose;
superclasses => ['Moose::Object'],
);
+ my @traits = 'Bool';
+ push @traits, 'NoInlineAttribute'
+ if delete $attr{no_inline};
+
$class->add_attribute(
is_lit => (
- traits => ['Bool'],
+ traits => \@traits,
is => 'rw',
isa => 'Bool',
default => 0,
run_tests(build_class);
run_tests( build_class( lazy => 1 ) );
run_tests( build_class( trigger => sub { } ) );
+ run_tests( build_class( no_inline => 1 ) );
# Will force the inlining code to check the entire hashref when it is modified.
subtype 'MyBool', as 'Bool', where { 1 };
use strict;
use warnings;
+use lib 't/lib';
+
use Moose ();
+use NoInlineAttribute;
use Test::More;
use Test::Exception;
use Test::Moose;
my $name = 'Foo1';
sub build_class {
- my ( $attr1, $attr2, $attr3 ) = @_;
+ my ( $attr1, $attr2, $attr3, $no_inline ) = @_;
my $class = Moose::Meta::Class->create(
$name++,
superclasses => ['Moose::Object'],
);
+ my @traits = 'Code';
+ push @traits, 'NoInlineAttribute'
+ if $no_inline;
+
$class->add_attribute(
callback => (
- traits => ['Code'],
+ traits => \@traits,
isa => 'CodeRef',
required => 1,
handles => { 'invoke_callback' => 'execute' },
$class->add_attribute(
callback_method => (
- traits => ['Code'],
+ traits => \@traits,
isa => 'CodeRef',
required => 1,
handles => { 'invoke_method_callback' => 'execute_method' },
$class->add_attribute(
multiplier => (
- traits => ['Code'],
+ traits => \@traits,
isa => 'CodeRef',
required => 1,
handles => { 'multiply' => 'execute' },
run_tests( build_class, \$i, \%subs );
+ run_tests( build_class( undef, undef, undef, 1 ), \$i, \%subs );
+
run_tests(
build_class(
{
use strict;
use warnings;
+use lib 't/lib';
+
use Moose ();
use Moose::Util::TypeConstraints;
+use NoInlineAttribute;
use Test::Exception;
use Test::More;
use Test::Moose;
superclasses => ['Moose::Object'],
);
+ my @traits = 'Counter';
+ push @traits, 'NoInlineAttribute'
+ if delete $attr{no_inline};
+
$class->add_attribute(
counter => (
- traits => ['Counter'],
+ traits => \@traits,
is => 'ro',
isa => 'Int',
default => 0,
run_tests(build_class);
run_tests( build_class( lazy => 1 ) );
run_tests( build_class( trigger => sub { } ) );
+ run_tests( build_class( no_inline => 1 ) );
# Will force the inlining code to check the entire hashref when it is modified.
subtype 'MyInt', as 'Int', where { 1 };
use strict;
use warnings;
+use lib 't/lib';
+
use Moose ();
use Moose::Util::TypeConstraints;
+use NoInlineAttribute;
use Test::Exception;
use Test::More;
use Test::Moose;
superclasses => ['Moose::Object'],
);
+ my @traits = 'Hash';
+ push @traits, 'NoInlineAttribute'
+ if delete $attr{no_inline};
+
$class->add_attribute(
options => (
- traits => ['Hash'],
+ traits => \@traits,
is => 'ro',
isa => 'HashRef[Str]',
default => sub { {} },
run_tests(build_class);
run_tests( build_class( lazy => 1, default => sub { { x => 1 } } ) );
run_tests( build_class( trigger => sub { } ) );
+ run_tests( build_class( no_inline => 1 ) );
# Will force the inlining code to check the entire hashref when it is modified.
subtype 'MyHashRef', as 'HashRef[Str]', where { 1 };
use strict;
use warnings;
+use lib 't/lib';
+
use Moose ();
use Moose::Util::TypeConstraints;
+use NoInlineAttribute;
use Test::Exception;
use Test::More;
use Test::Moose;
superclasses => ['Moose::Object'],
);
+ my @traits = 'Number';
+ push @traits, 'NoInlineAttribute'
+ if delete $attr{no_inline};
+
$class->add_attribute(
integer => (
- traits => ['Number'],
+ traits => \@traits,
is => 'ro',
isa => 'Int',
default => 5,
run_tests(build_class);
run_tests( build_class( lazy => 1 ) );
run_tests( build_class( trigger => sub { } ) );
+ run_tests( build_class( no_inline => 1 ) );
# Will force the inlining code to check the entire hashref when it is modified.
subtype 'MyInt', as 'Int', where { 1 };
use strict;
use warnings;
+use lib 't/lib';
+
use Moose ();
use Moose::Util::TypeConstraints;
+use NoInlineAttribute;
use Test::More;
use Test::Exception;
use Test::Moose;
superclasses => ['Moose::Object'],
);
+ my @traits = 'String';
+ push @traits, 'NoInlineAttribute'
+ if delete $attr{no_inline};
+
$class->add_attribute(
_string => (
- traits => ['String'],
+ traits => \@traits,
is => 'rw',
isa => 'Str',
default => q{},
run_tests(build_class);
run_tests( build_class( lazy => 1, default => q{} ) );
run_tests( build_class( trigger => sub { } ) );
+ run_tests( build_class( no_inline => 1 ) );
# Will force the inlining code to check the entire hashref when it is modified.
subtype 'MyStr', as 'Str', where { 1 };
--- /dev/null
+package NoInlineAttribute;
+
+use Moose::Meta::Class;
+use Moose::Role;
+
+around accessor_metaclass => sub {
+ my $orig = shift;
+ my $self = shift;
+
+ my $class = $self->$orig();
+
+ return Moose::Meta::Class->create_anon_class(
+ superclasses => [$class],
+ roles => ['NoInlineAccessor'],
+ cache => 1,
+ )->name;
+};
+
+no Moose::Role;
+
+{
+ package NoInlineAccessor;
+
+ use Moose::Role;
+
+ sub is_inline { 0 }
+}
+
+1;