From: Fuji, Goro Date: Mon, 27 Sep 2010 03:30:06 +0000 (+0900) Subject: Cleanup X-Git-Tag: 0.75~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1d76ae62bb4a259c0c107f1937e9db9f49ce8e10;p=gitmo%2FMouse.git Cleanup --- diff --git a/lib/Mouse/Meta/Class.pm b/lib/Mouse/Meta/Class.pm index 51c7d76..79af285 100644 --- a/lib/Mouse/Meta/Class.pm +++ b/lib/Mouse/Meta/Class.pm @@ -1,7 +1,7 @@ package Mouse::Meta::Class; use Mouse::Util qw/:meta/; # enables strict and warnings -use Scalar::Util qw/blessed weaken/; +use Scalar::Util (); use Mouse::Meta::Module; our @ISA = qw(Mouse::Meta::Module); @@ -194,7 +194,7 @@ sub add_attribute { my($attr, $name); - if(blessed $_[0]){ + if(Scalar::Util::blessed($_[0])){ $attr = $_[0]; $attr->isa('Mouse::Meta::Attribute') @@ -225,7 +225,7 @@ sub add_attribute { } } - weaken( $attr->{associated_class} = $self ); + Scalar::Util::weaken( $attr->{associated_class} = $self ); # install accessors first $attr->install_accessors(); diff --git a/lib/Mouse/Meta/Module.pm b/lib/Mouse/Meta/Module.pm index 3592530..d711877 100644 --- a/lib/Mouse/Meta/Module.pm +++ b/lib/Mouse/Meta/Module.pm @@ -1,5 +1,5 @@ package Mouse::Meta::Module; -use Mouse::Util qw/:meta get_code_package get_code_ref not_supported/; # enables strict and warnings +use Mouse::Util qw/:meta/; # enables strict and warnings use Carp (); use Scalar::Util (); @@ -87,7 +87,7 @@ my %foreign = map{ $_ => undef } qw( sub _code_is_mine{ # my($self, $code) = @_; - return !exists $foreign{ get_code_package($_[1]) }; + return !exists $foreign{ Mouse::Util::get_code_package($_[1]) }; } sub add_method; @@ -99,7 +99,7 @@ sub has_method { or $self->throw_error('You must define a method name'); return defined($self->{methods}{$method_name}) || do{ - my $code = get_code_ref($self->{package}, $method_name); + my $code = Mouse::Util::get_code_ref($self->{package}, $method_name); $code && $self->_code_is_mine($code); }; } @@ -111,7 +111,7 @@ sub get_method_body { or $self->throw_error('You must define a method name'); return $self->{methods}{$method_name} ||= do{ - my $code = get_code_ref($self->{package}, $method_name); + my $code = Mouse::Util::get_code_ref($self->{package}, $method_name); $code && $self->_code_is_mine($code) ? $code : undef; }; } diff --git a/lib/Mouse/PurePerl.pm b/lib/Mouse/PurePerl.pm index 80756cd..056d3d9 100644 --- a/lib/Mouse/PurePerl.pm +++ b/lib/Mouse/PurePerl.pm @@ -134,7 +134,7 @@ sub generate_can_predicate_for { package Mouse::Util::TypeConstraints; -use Scalar::Util qw(blessed looks_like_number openhandle); +use Scalar::Util (); sub Any { 1 } sub Item { 1 } @@ -143,7 +143,7 @@ sub Bool { $_[0] ? $_[0] eq '1' : 1 } sub Undef { !defined($_[0]) } sub Defined { defined($_[0]) } sub Value { defined($_[0]) && !ref($_[0]) } -sub Num { looks_like_number($_[0]) } +sub Num { Scalar::Util::looks_like_number($_[0]) } sub Str { # We need to use a copy here to flatten MAGICs, for instance as in # Str( substr($_, 0, 42) ). @@ -168,10 +168,12 @@ sub RegexpRef { ref($_[0]) eq 'Regexp' } sub GlobRef { ref($_[0]) eq 'GLOB' } sub FileHandle { - return openhandle($_[0]) || (blessed($_[0]) && $_[0]->isa("IO::Handle")) + my($value) = @_; + return Scalar::Util::openhandle($value) + || (Scalar::Util::blessed($value) && $value->isa("IO::Handle")) } -sub Object { blessed($_[0]) && blessed($_[0]) ne 'Regexp' } +sub Object { Scalar::Util::blessed($_[0]) && ref($_[0]) ne 'Regexp' } sub ClassName { Mouse::Util::is_class_loaded($_[0]) } sub RoleName { (Mouse::Util::class_of($_[0]) || return 0)->isa('Mouse::Meta::Role') } @@ -309,7 +311,7 @@ sub clone_object { my $object = shift; my $args = $object->Mouse::Object::BUILDARGS(@_); - (blessed($object) && $object->isa($class->name)) + (Scalar::Util::blessed($object) && $object->isa($class->name)) || $class->throw_error("You must pass an instance of the metaclass (" . $class->name . "), not ($object)"); my $cloned = bless { %$object }, ref $object; diff --git a/lib/Mouse/Role.pm b/lib/Mouse/Role.pm index cf8e7b7..e7b74ec 100644 --- a/lib/Mouse/Role.pm +++ b/lib/Mouse/Role.pm @@ -6,8 +6,6 @@ our $VERSION = '0.73'; use Carp qw(confess); use Scalar::Util qw(blessed); -use Mouse::Util qw(not_supported); -use Mouse::Meta::Role; use Mouse (); Mouse::Exporter->setup_import_methods( @@ -104,7 +102,7 @@ sub requires { } sub excludes { - not_supported; + Mouse::Util::not_supported(); } sub init_meta{ diff --git a/lib/Mouse/Util.pm b/lib/Mouse/Util.pm index 0513890..bd64d15 100644 --- a/lib/Mouse/Util.pm +++ b/lib/Mouse/Util.pm @@ -334,7 +334,7 @@ sub quoted_english_list { sub not_supported{ my($feature) = @_; - $feature ||= ( caller(1) )[3]; # subroutine name + $feature ||= ( caller(1) )[3] . '()'; # subroutine name local $Carp::CarpLevel = $Carp::CarpLevel + 1; Carp::confess("Mouse does not currently support $feature");