From: gfx Date: Wed, 23 Sep 2009 02:51:45 +0000 (+0900) Subject: Always load Mouse::Util first, which will be load Mouse::XS in the future X-Git-Tag: 0.33~12 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6d28c5cf89bfd4c00e675e95aff6c31b61aeb805;p=gitmo%2FMouse.git Always load Mouse::Util first, which will be load Mouse::XS in the future --- diff --git a/lib/Mouse.pm b/lib/Mouse.pm index 6a08ba6..34108fb 100644 --- a/lib/Mouse.pm +++ b/lib/Mouse.pm @@ -10,14 +10,15 @@ sub moose_version(){ 0.90 } # which Mouse is a subset of use Carp 'confess'; use Scalar::Util 'blessed'; + use Mouse::Util qw(load_class is_class_loaded); -use Mouse::Meta::Attribute; use Mouse::Meta::Module; use Mouse::Meta::Class; use Mouse::Meta::Role; +use Mouse::Meta::Attribute; use Mouse::Object; -use Mouse::Util::TypeConstraints; +use Mouse::Util::TypeConstraints (); our @EXPORT = qw(extends has before after around override super blessed confess with); @@ -120,8 +121,8 @@ sub init_meta { unless $metaclass->isa('Mouse::Meta::Class'); # make a subtype for each Mouse class - class_type($class) - unless find_type_constraint($class); + Mouse::Util::TypeConstraints::class_type($class) + unless Mouse::Util::TypeConstraints::find_type_constraint($class); my $meta = $metaclass->initialize($class); $meta->superclasses($base_class) diff --git a/lib/Mouse/Meta/Attribute.pm b/lib/Mouse/Meta/Attribute.pm index 77d935a..429b6f9 100644 --- a/lib/Mouse/Meta/Attribute.pm +++ b/lib/Mouse/Meta/Attribute.pm @@ -2,6 +2,8 @@ package Mouse::Meta::Attribute; use strict; use warnings; +use Mouse::Util; + use Mouse::Meta::TypeConstraint; use Mouse::Meta::Method::Accessor; diff --git a/lib/Mouse/Meta/Class.pm b/lib/Mouse/Meta/Class.pm index 9ede6f8..46b4a15 100644 --- a/lib/Mouse/Meta/Class.pm +++ b/lib/Mouse/Meta/Class.pm @@ -2,11 +2,14 @@ package Mouse::Meta::Class; use strict; use warnings; -use Mouse::Meta::Method::Constructor; -use Mouse::Meta::Method::Destructor; use Scalar::Util qw/blessed weaken/; + use Mouse::Util qw/get_linear_isa not_supported/; +use Mouse::Meta::Method::Constructor; +use Mouse::Meta::Method::Destructor; +use Mouse::Meta::Module; + use base qw(Mouse::Meta::Module); sub method_metaclass(){ 'Mouse::Meta::Method' } # required for get_method() diff --git a/lib/Mouse/Meta/Module.pm b/lib/Mouse/Meta/Module.pm index 74a8468..712e5e1 100755 --- a/lib/Mouse/Meta/Module.pm +++ b/lib/Mouse/Meta/Module.pm @@ -2,9 +2,11 @@ package Mouse::Meta::Module; use strict; use warnings; -use Mouse::Util qw/get_code_info not_supported load_class/; +use Carp (); use Scalar::Util qw/blessed weaken/; +use Mouse::Util qw/get_code_info not_supported load_class/; + { my %METACLASS_CACHE; diff --git a/lib/Mouse/Meta/Role.pm b/lib/Mouse/Meta/Role.pm index 48e1b81..4b5c26f 100644 --- a/lib/Mouse/Meta/Role.pm +++ b/lib/Mouse/Meta/Role.pm @@ -3,6 +3,8 @@ use strict; use warnings; use Mouse::Util qw(not_supported english_list); +use Mouse::Meta::Module; + use base qw(Mouse::Meta::Module); sub method_metaclass(){ 'Mouse::Meta::Role::Method' } # required for get_method() diff --git a/lib/Mouse/Meta/TypeConstraint.pm b/lib/Mouse/Meta/TypeConstraint.pm index 7b8732d..916acc1 100644 --- a/lib/Mouse/Meta/TypeConstraint.pm +++ b/lib/Mouse/Meta/TypeConstraint.pm @@ -1,11 +1,14 @@ package Mouse::Meta::TypeConstraint; use strict; use warnings; -use Carp (); use overload '""' => sub { shift->{name} }, # stringify to tc name fallback => 1; +use Carp (); + +use Mouse::Util (); + sub new { my $class = shift; my %args = @_; diff --git a/lib/Mouse/Object.pm b/lib/Mouse/Object.pm index 3eef06b..911954d 100644 --- a/lib/Mouse/Object.pm +++ b/lib/Mouse/Object.pm @@ -2,6 +2,8 @@ package Mouse::Object; use strict; use warnings; +use Mouse::Util; + sub new { my $class = shift; diff --git a/lib/Mouse/Role.pm b/lib/Mouse/Role.pm index 7104736..9872397 100644 --- a/lib/Mouse/Role.pm +++ b/lib/Mouse/Role.pm @@ -3,11 +3,11 @@ use strict; use warnings; use base 'Exporter'; -use Carp 'confess', 'croak'; +use Carp 'confess'; use Scalar::Util 'blessed'; -use Mouse::Meta::Role; -use Mouse::Util qw(load_class); +use Mouse::Util qw(load_class not_supported); +use Mouse (); our @EXPORT = qw(before after around super override inner augment has extends with requires excludes confess blessed); our %is_removable = map{ $_ => undef } @EXPORT; @@ -56,8 +56,8 @@ sub override { my $fullname = "${classname}::${name}"; defined &$fullname - && confess "Cannot add an override of method '$fullname' " . - "because there is a local version of '$fullname'"; + && $meta->throw_error("Cannot add an override of method '$fullname' " + . "because there is a local version of '$fullname'"); $meta->add_override_method_modifier($name => sub { local $Mouse::SUPER_PACKAGE = shift; @@ -70,11 +70,11 @@ sub override { # We keep the same errors messages as Moose::Role emits, here. sub inner { - croak "Moose::Role cannot support 'inner'"; + Carp::croak "Roles cannot support 'inner'"; } sub augment { - croak "Moose::Role cannot support 'augment'"; + Carp::croak "Roles cannot support 'augment'"; } sub has { @@ -86,7 +86,9 @@ sub has { $meta->add_attribute($name => \%opts); } -sub extends { confess "Roles do not support 'extends'" } +sub extends { + Carp::croak "Roles do not support 'extends'" +} sub with { my $meta = Mouse::Meta::Role->initialize(scalar caller); @@ -95,11 +97,13 @@ sub with { sub requires { my $meta = Mouse::Meta::Role->initialize(scalar caller); - Carp::croak "Must specify at least one method" unless @_; + $meta->throw_error("Must specify at least one method") unless @_; $meta->add_required_methods(@_); } -sub excludes { confess "Mouse::Role does not currently support 'excludes'" } +sub excludes { + not_supported; +} sub import { my $class = shift; diff --git a/lib/Mouse/Util.pm b/lib/Mouse/Util.pm index da769b5..1e8d028 100644 --- a/lib/Mouse/Util.pm +++ b/lib/Mouse/Util.pm @@ -2,6 +2,7 @@ package Mouse::Util; use strict; use warnings; use base qw/Exporter/; + use Carp qw(confess); use B (); diff --git a/lib/Mouse/Util/TypeConstraints.pm b/lib/Mouse/Util/TypeConstraints.pm index a012e9d..a11a478 100644 --- a/lib/Mouse/Util/TypeConstraints.pm +++ b/lib/Mouse/Util/TypeConstraints.pm @@ -5,6 +5,8 @@ use base 'Exporter'; use Carp (); use Scalar::Util qw/blessed looks_like_number openhandle/; + +use Mouse::Util; use Mouse::Meta::TypeConstraint; our @EXPORT = qw(