From: Tokuhiro Matsuno Date: Sun, 7 Dec 2008 07:49:25 +0000 (+0000) Subject: use Scalar::Util directly X-Git-Tag: 0.19~136^2~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6c169c5063b77a791818f5db2c1da3bd9b47d3f9;p=gitmo%2FMouse.git use Scalar::Util directly --- diff --git a/lib/Mouse.pm b/lib/Mouse.pm index 22d07eb..2f61610 100644 --- a/lib/Mouse.pm +++ b/lib/Mouse.pm @@ -18,7 +18,8 @@ BEGIN { } use Carp 'confess'; -use Mouse::Util 'blessed'; +use Scalar::Util 'blessed'; +use Mouse::Util; use Mouse::Meta::Attribute; use Mouse::Meta::Class; @@ -123,6 +124,7 @@ sub load_class { confess "Invalid class name ($display)"; } + return 1 if $class eq 'Mouse::Object'; return 1 if is_class_loaded($class); (my $file = "$class.pm") =~ s{::}{/}g; diff --git a/lib/Mouse/Meta/Attribute.pm b/lib/Mouse/Meta/Attribute.pm index 97cd5c0..2ce6ce4 100644 --- a/lib/Mouse/Meta/Attribute.pm +++ b/lib/Mouse/Meta/Attribute.pm @@ -5,7 +5,7 @@ use warnings; require overload; use Carp 'confess'; -require Mouse::Util; +use Scalar::Util (); sub new { my $class = shift; @@ -104,7 +104,7 @@ sub generate_accessor { $accessor .= $self.'->{'.$key.'} = '.$value.';' . "\n"; if ($is_weak) { - $accessor .= 'Mouse::Util::weaken('.$self.'->{'.$key.'}) if ref('.$self.'->{'.$key.'});' . "\n"; + $accessor .= 'Scalar::Util::weaken('.$self.'->{'.$key.'}) if ref('.$self.'->{'.$key.'});' . "\n"; } if ($trigger) { @@ -215,13 +215,13 @@ sub create { my $optimized_constraints = Mouse::TypeRegistry->optimized_constraints; if (@type_constraints == 1) { $code = $optimized_constraints->{$type_constraints[0]} || - sub { Mouse::Util::blessed($_) && Mouse::Util::blessed($_) eq $type_constraints[0] }; + sub { Scalar::Util::blessed($_) && Scalar::Util::blessed($_) eq $type_constraints[0] }; $args{type_constraint} = $type_constraints[0]; } else { my @code_list = map { my $type = $_; $optimized_constraints->{$type} || - sub { Mouse::Util::blessed($_) && Mouse::Util::blessed($_) eq $type } + sub { Scalar::Util::blessed($_) && Scalar::Util::blessed($_) eq $type } } @type_constraints; $code = sub { for my $code (@code_list) { diff --git a/lib/Mouse/Meta/Class.pm b/lib/Mouse/Meta/Class.pm index 966c27d..642f738 100644 --- a/lib/Mouse/Meta/Class.pm +++ b/lib/Mouse/Meta/Class.pm @@ -5,7 +5,8 @@ use warnings; use Mouse::Meta::Method::Constructor; use Mouse::Meta::Method::Destructor; -use Mouse::Util qw/get_linear_isa blessed/; +use Scalar::Util qw/blessed/; +use Mouse::Util qw/get_linear_isa/; use Carp 'confess'; do { diff --git a/lib/Mouse/Object.pm b/lib/Mouse/Object.pm index c7add33..900530d 100644 --- a/lib/Mouse/Object.pm +++ b/lib/Mouse/Object.pm @@ -3,7 +3,7 @@ package Mouse::Object; use strict; use warnings; -use Mouse::Util qw/weaken/; +use Scalar::Util qw/weaken/; use Carp 'confess'; sub new { diff --git a/lib/Mouse/Role.pm b/lib/Mouse/Role.pm index ec74bcc..37007e5 100644 --- a/lib/Mouse/Role.pm +++ b/lib/Mouse/Role.pm @@ -5,7 +5,7 @@ use warnings; use base 'Exporter'; use Carp 'confess'; -use Mouse::Util 'blessed'; +use Scalar::Util 'blessed'; use Mouse::Meta::Role; diff --git a/lib/Mouse/TypeRegistry.pm b/lib/Mouse/TypeRegistry.pm index 4a97237..7045382 100644 --- a/lib/Mouse/TypeRegistry.pm +++ b/lib/Mouse/TypeRegistry.pm @@ -4,7 +4,7 @@ use strict; use warnings; use Carp (); -use Mouse::Util qw/blessed looks_like_number openhandle/; +use Scalar::Util qw/blessed looks_like_number openhandle/; my %SUBTYPE; my %COERCE; diff --git a/lib/Mouse/Util.pm b/lib/Mouse/Util.pm index 7dc8187..c9fca63 100644 --- a/lib/Mouse/Util.pm +++ b/lib/Mouse/Util.pm @@ -4,10 +4,8 @@ use strict; use warnings; use base qw/Exporter/; use Carp; -use Scalar::Util qw(blessed looks_like_number openhandle reftype weaken); our @EXPORT_OK = qw( - blessed looks_like_number openhandle reftype weaken get_linear_isa ); our %EXPORT_TAGS = ( @@ -101,26 +99,5 @@ Mouse::Util - features, with or without their dependencies =head3 get_linear_isa -=head2 L - -=head3 blessed - -=head3 looks_like_number - -=head3 reftype - -=head3 openhandle - -=head3 weaken - -C I be implemented in XS. If the user tries to use C -without L, an error is thrown. - -=head2 Test::Exception - -=head3 throws_ok - -=head3 lives_ok - =cut diff --git a/lib/MouseX/Types/TypeDecorator.pm b/lib/MouseX/Types/TypeDecorator.pm index 244f88c..11ad46d 100644 --- a/lib/MouseX/Types/TypeDecorator.pm +++ b/lib/MouseX/Types/TypeDecorator.pm @@ -3,7 +3,7 @@ package MouseX::Types::TypeDecorator; use strict; use warnings; -use Mouse::Util 'blessed'; +use Scalar::Util 'blessed'; use overload( '""' => sub { ${ $_[0] } }, diff --git a/t/201-squirrel.t b/t/201-squirrel.t index 85c0fe5..8a37731 100644 --- a/t/201-squirrel.t +++ b/t/201-squirrel.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Mouse::Util 'blessed'; +use Scalar::Util 'blessed'; do { package Foo; diff --git a/t/202-squirrel-role.t b/t/202-squirrel-role.t index 7201754..5c70361 100644 --- a/t/202-squirrel-role.t +++ b/t/202-squirrel-role.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Mouse::Util 'blessed'; +use Scalar::Util 'blessed'; do { package Foo::Role;