From: Yuval Kogman Date: Wed, 13 Aug 2008 22:21:17 +0000 (+0000) Subject: make more things immutable X-Git-Tag: 0_55_01~27 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0779da922a64aa891bc2708b6fc8de4d4fdffa11;p=gitmo%2FMoose.git make more things immutable --- diff --git a/lib/Moose.pm b/lib/Moose.pm index 74fb31a..b4b75b0 100644 --- a/lib/Moose.pm +++ b/lib/Moose.pm @@ -20,9 +20,17 @@ use Moose::Meta::TypeCoercion; use Moose::Meta::Attribute; use Moose::Meta::Instance; +use Moose::Object; + use Moose::Meta::Role; +use Moose::Meta::Role::Composite; +use Moose::Meta::Role::Application; +use Moose::Meta::Role::Application::RoleSummation; +use Moose::Meta::Role::Application::ToClass; +use Moose::Meta::Role::Application::ToRole; +use Moose::Meta::Role::Application::ToInstance; +use Moose::Meta::Role::Application::ToMetaclassInstance; -use Moose::Object; use Moose::Util::TypeConstraints; use Moose::Util (); @@ -195,29 +203,45 @@ sub _get_caller { ## make 'em all immutable $_->meta->make_immutable( - inline_constructor => 0, + inline_constructor => 1, + constructor_name => "_new", inline_accessors => 1, # these are Class::MOP accessors, so they need inlining ) - for ( - 'Moose::Meta::Attribute', - 'Moose::Meta::Class', - 'Moose::Meta::Instance', - - 'Moose::Meta::TypeConstraint', - 'Moose::Meta::TypeConstraint::Union', - 'Moose::Meta::TypeConstraint::Parameterized', - 'Moose::Meta::TypeCoercion', - - 'Moose::Meta::Method', - 'Moose::Meta::Method::Accessor', - 'Moose::Meta::Method::Constructor', - 'Moose::Meta::Method::Destructor', - 'Moose::Meta::Method::Overriden', - - 'Moose::Meta::Role', - 'Moose::Meta::Role::Method', - 'Moose::Meta::Role::Method::Required', - ); + for (qw( + Moose::Meta::Attribute + Moose::Meta::Class + Moose::Meta::Instance + + Moose::Meta::TypeConstraint + Moose::Meta::TypeConstraint::Union + Moose::Meta::TypeConstraint::Parameterized + Moose::Meta::TypeConstraint::Enum + Moose::Meta::TypeConstraint::Class + Moose::Meta::TypeConstraint::Role + Moose::Meta::TypeConstraint::Registry + Moose::Meta::TypeCoercion + Moose::Meta::TypeCoercion::Union + + Moose::Meta::Method + Moose::Meta::Method::Accessor + Moose::Meta::Method::Constructor + Moose::Meta::Method::Destructor + Moose::Meta::Method::Overriden + Moose::Meta::Method::Augmented + + Moose::Meta::Role + Moose::Meta::Role::Method + Moose::Meta::Role::Method::Required + + Moose::Meta::Role::Composite + + Moose::Meta::Role::Application + Moose::Meta::Role::Application::RoleSummation + Moose::Meta::Role::Application::ToClass + Moose::Meta::Role::Application::ToRole + Moose::Meta::Role::Application::ToInstance + Moose::Meta::Role::Application::ToMetaclassInstance +)); 1; diff --git a/lib/Moose/Meta/Role/Application.pm b/lib/Moose/Meta/Role/Application.pm index b2d886d..dfad321 100644 --- a/lib/Moose/Meta/Role/Application.pm +++ b/lib/Moose/Meta/Role/Application.pm @@ -29,7 +29,7 @@ sub new { : [ $params{excludes} ]); } - $class->meta->new_object(%params); + $class->_new(%params); } sub is_method_excluded { diff --git a/lib/Moose/Meta/Role/Composite.pm b/lib/Moose/Meta/Role/Composite.pm index 8b01f4c..8d4690a 100644 --- a/lib/Moose/Meta/Role/Composite.pm +++ b/lib/Moose/Meta/Role/Composite.pm @@ -39,7 +39,7 @@ sub new { # and the name is created from the # roles if one has not been provided $params{name} ||= (join "|" => map { $_->name } @{$params{roles}}); - $class->meta->new_object(%params); + $class->_new(\%params); } # NOTE: diff --git a/lib/Moose/Meta/TypeConstraint.pm b/lib/Moose/Meta/TypeConstraint.pm index 9f0b4e3..11f8160 100644 --- a/lib/Moose/Meta/TypeConstraint.pm +++ b/lib/Moose/Meta/TypeConstraint.pm @@ -11,6 +11,8 @@ use overload '""' => sub { shift->name }, # stringify to tc name use Carp 'confess'; use Scalar::Util qw(blessed refaddr); +use base qw(Class::MOP::Object); + our $VERSION = '0.56'; our $AUTHORITY = 'cpan:STEVAN'; @@ -57,7 +59,7 @@ __PACKAGE__->meta->add_attribute('package_defined_in' => ( sub new { my $class = shift; - my $self = $class->meta->new_object(@_); + my $self = $class->_new(@_); $self->compile_type_constraint() unless $self->_has_compiled_type_constraint; return $self; diff --git a/lib/Moose/Meta/TypeConstraint/Class.pm b/lib/Moose/Meta/TypeConstraint/Class.pm index b153fe1..931ef32 100644 --- a/lib/Moose/Meta/TypeConstraint/Class.pm +++ b/lib/Moose/Meta/TypeConstraint/Class.pm @@ -20,7 +20,7 @@ sub new { my ( $class, %args ) = @_; $args{parent} = Moose::Util::TypeConstraints::find_type_constraint('Object'); - my $self = $class->meta->new_object(%args); + my $self = $class->_new(\%args); $self->_create_hand_optimized_type_constraint; $self->compile_type_constraint(); diff --git a/lib/Moose/Meta/TypeConstraint/Enum.pm b/lib/Moose/Meta/TypeConstraint/Enum.pm index a2619ec..570433f 100644 --- a/lib/Moose/Meta/TypeConstraint/Enum.pm +++ b/lib/Moose/Meta/TypeConstraint/Enum.pm @@ -20,7 +20,7 @@ sub new { $args{parent} = Moose::Util::TypeConstraints::find_type_constraint('Str'); - my $self = $class->meta->new_object(%args); + my $self = $class->_new(%args); $self->compile_type_constraint() unless $self->_has_compiled_type_constraint; diff --git a/lib/Moose/Meta/TypeConstraint/Registry.pm b/lib/Moose/Meta/TypeConstraint/Registry.pm index 4d95641..b4229c1 100644 --- a/lib/Moose/Meta/TypeConstraint/Registry.pm +++ b/lib/Moose/Meta/TypeConstraint/Registry.pm @@ -26,7 +26,7 @@ __PACKAGE__->meta->add_attribute('type_constraints' => ( sub new { my $class = shift; - my $self = $class->meta->new_object(@_); + my $self = $class->_new(@_); return $self; } diff --git a/lib/Moose/Meta/TypeConstraint/Role.pm b/lib/Moose/Meta/TypeConstraint/Role.pm index 090ff5f..f589217 100644 --- a/lib/Moose/Meta/TypeConstraint/Role.pm +++ b/lib/Moose/Meta/TypeConstraint/Role.pm @@ -20,7 +20,7 @@ sub new { my ( $class, %args ) = @_; $args{parent} = Moose::Util::TypeConstraints::find_type_constraint('Role'); - my $self = $class->meta->new_object(%args); + my $self = $class->_new(\%args); $self->_create_hand_optimized_type_constraint; $self->compile_type_constraint();