package_name => $self->associated_class->name,
attribute => $self,
curried_arguments => \@curried_args,
+ root_types => [ $self->_root_types ],
);
}
# XXX - bridge code
}
};
+sub _root_types {
+ return $_[0]->_helper_type;
+}
+
sub _native_accessor_class_for {
my ( $self, $suffix ) = @_;
return bless $options, $class;
}
+sub root_types { (shift)->{'root_types'} }
+
sub _initialize_body {
my $self = shift;
}
}
-sub _constraint_must_be_checked {
- my $self = shift;
-
- my $attr = $self->associated_attribute;
-
- return $attr->has_type_constraint
- && ( $attr->type_constraint->name ne 'ArrayRef'
- || ( $attr->should_coerce && $attr->type_constraint->has_coercion ) );
-}
-
sub _check_new_members_only {
my $self = shift;
) . " for $new_value;";
}
-sub _inline_check_coercion {
- my ( $self, $value ) = @_;
-
- my $attr = $self->associated_attribute;
-
- return ''
- unless $attr->should_coerce && $attr->type_constraint->has_coercion;
-
- return "$value = \$type_constraint_obj->coerce($value);";
-}
-
sub _inline_check_constraint {
my $self = shift;
+++ /dev/null
-package Moose::Meta::Method::Accessor::Native::Bool::Writer;
-
-use strict;
-use warnings;
-
-our $VERSION = '1.13';
-$VERSION = eval $VERSION;
-our $AUTHORITY = 'cpan:STEVAN';
-
-use base 'Moose::Meta::Method::Accessor::Native::Writer';
-
-sub _new_value {q{}}
-sub _potential_value {q{}}
-
-sub _value_needs_copy {0}
-
-# The Bool type does not have any methods that take a user-provided value
-sub _inline_tc_code {q{}}
-
-1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Bool::Writer';
+use base 'Moose::Meta::Method::Accessor::Native::Writer';
sub _minimum_arguments { 0 }
sub _maximum_arguments { 0 }
+sub _potential_value { 1 }
+
sub _inline_optimized_set_new_value {
my ( $self, $inv, $new, $slot_access ) = @_;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Bool::Writer';
+use base 'Moose::Meta::Method::Accessor::Native::Writer';
sub _minimum_arguments { 0 }
sub _maximum_arguments { 0 }
+sub _potential_value {
+ my ( $self, $slot_access ) = @_;
+
+ return "$slot_access ? 0 : 1;";
+}
+
sub _inline_optimized_set_new_value {
my ( $self, $inv, $new, $slot_access ) = @_;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::Bool::Writer';
+use base 'Moose::Meta::Method::Accessor::Native::Writer';
sub _minimum_arguments { 0 }
sub _maximum_arguments { 0 }
+sub _potential_value { 0 }
+
sub _inline_optimized_set_new_value {
my ( $self, $inv, $new, $slot_access ) = @_;
+++ /dev/null
-package Moose::Meta::Method::Accessor::Native::String::Writer;
-
-use strict;
-use warnings;
-
-our $VERSION = '1.13';
-$VERSION = eval $VERSION;
-our $AUTHORITY = 'cpan:STEVAN';
-
-use base 'Moose::Meta::Method::Accessor::Native::Writer';
-
-sub _new_value {'$_[0]'}
-
-sub _constraint_must_be_checked {
- my $self = shift;
-
- my $attr = $self->associated_attribute;
-
- return $attr->has_type_constraint
- && ( $attr->type_constraint->name ne 'Str'
- || ( $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 '@_ = @{ $attr->type_constraint->coerce($value) };';
-}
-
-1;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::String::Writer';
+use base 'Moose::Meta::Method::Accessor::Native::Writer';
sub _minimum_arguments { 1 }
sub _maximum_arguments { 1 }
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::String::Writer';
+use base 'Moose::Meta::Method::Accessor::Native::Writer';
sub _minimum_arguments { 0 }
sub _maximum_arguments { 0 }
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::String::Writer';
+use base 'Moose::Meta::Method::Accessor::Native::Writer';
sub _minimum_arguments { 0 }
sub _maximum_arguments { 0 }
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::String::Writer';
+use base 'Moose::Meta::Method::Accessor::Native::Writer';
sub _minimum_arguments { 0 }
sub _maximum_arguments { 0 }
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::String::Writer';
+use base 'Moose::Meta::Method::Accessor::Native::Writer';
sub _minimum_arguments { 0 }
sub _maximum_arguments { 0 }
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::String::Writer';
+use base 'Moose::Meta::Method::Accessor::Native::Writer';
sub _minimum_arguments { 1 }
sub _maximum_arguments { 1 }
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-use base 'Moose::Meta::Method::Accessor::Native::String::Writer';
+use base 'Moose::Meta::Method::Accessor::Native::Writer';
sub _minimum_arguments { 1 }
sub _maximum_arguments { 2 }
use base qw(
Moose::Meta::Method::Accessor::Native::Reader
- Moose::Meta::Method::Accessor::Native::String::Writer
+ Moose::Meta::Method::Accessor::Native::Writer
);
sub _generate_method {
use strict;
use warnings;
+use List::MoreUtils qw( any );
+
our $VERSION = '1.13';
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
sub _inline_check_arguments {q{}}
+sub _new_value {'$_[0]'}
+
sub _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, $type) = @_;
+
+ my $name = $type->name();
+
+ return any { $name eq $_ } @{ $self->root_types };
+}
+
sub _inline_copy_value {
my ( $self, $potential_ref ) = @_;
}
sub _inline_check_coercion {
- die '_inline_check_coercion must be overridden by ' . ref $_[0];
+ 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 = \$type_constraint_obj->coerce($value);";
}
sub _inline_check_constraint {
return $self->SUPER::_inline_check_constraint( $_[0] );
}
-sub _constraint_must_be_checked {
- die '_constraint_must_be_checked must be overridden by ' . ref $_[0];
-}
-
sub _inline_capture_return_value { return q{} }
sub _inline_set_new_value {