From: Dave Rolsky Date: Sun, 5 Apr 2009 21:11:11 +0000 (-0500) Subject: Merge branch 'renames-and-deprecations' X-Git-Tag: 0.73_01~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0772362ae1f8904c17329b1ff94671493e08b3ab;p=gitmo%2FMoose.git Merge branch 'renames-and-deprecations' Conflicts: lib/Moose/Meta/Attribute.pm lib/Moose/Meta/Method/Constructor.pm There are still some warnings and test failures to work out. --- 0772362ae1f8904c17329b1ff94671493e08b3ab diff --cc lib/Moose/Meta/Attribute.pm index 3ee8bcf,51099d4..4760f92 --- a/lib/Moose/Meta/Attribute.pm +++ b/lib/Moose/Meta/Attribute.pm @@@ -248,7 -248,7 +248,7 @@@ sub clone my ( @init, @non_init ); - foreach my $attr ( grep { $_->has_value($self) } Class::MOP::class_of($self)->compute_all_applicable_attributes ) { - foreach my $attr ( grep { $_->has_value($self) } $self->meta->get_all_attributes ) { ++ foreach my $attr ( grep { $_->has_value($self) } Class::MOP::class_of($self)->get_all_attributes ) { push @{ $attr->has_init_arg ? \@init : \@non_init }, $attr; } diff --cc lib/Moose/Meta/Method/Constructor.pm index 1c60f63,34ef580..997665c --- a/lib/Moose/Meta/Method/Constructor.pm +++ b/lib/Moose/Meta/Method/Constructor.pm @@@ -25,15 -25,15 +25,10 @@@ sub new || $class->throw_error("You must supply the package_name and name parameters $Class::MOP::Method::UPGRADE_ERROR_TEXT"); my $self = bless { 'body' => undef, 'package_name' => $options{package_name}, 'name' => $options{name}, -- # specific to this subclass 'options' => $options{options}, -- 'meta_instance' => $meta->get_meta_instance, - 'attributes' => [ $meta->compute_all_applicable_attributes ], - # ... - 'attributes' => [ $meta->get_all_attributes ], - # ... 'associated_metaclass' => $meta, } => $class; @@@ -108,14 -108,32 +103,9 @@@ sub _expected_constructor_class return 'Moose::Object'; } --## accessors -- --sub meta_instance { (shift)->{'meta_instance'} } --sub attributes { (shift)->{'attributes'} } -- ## method - sub initialize_body { -sub _generate_params { - my ($self, $var, $class_var) = @_; - "my $var = " . $self->_generate_BUILDARGS($class_var, '@_') . ";\n"; -} - -sub _generate_instance { - my ($self, $var, $class_var) = @_; - "my $var = " . $self->meta_instance->inline_create_instance($class_var) - . ";\n"; -} - -sub _generate_slot_initializers { - my ($self) = @_; - return (join ";\n" => map { - $self->_generate_slot_initializer($_) - } 0 .. (@{$self->attributes} - 1)) . ";\n"; -} - + sub _initialize_body { my $self = shift; # TODO: # the %options should also include a both @@@ -151,7 -169,7 +141,7 @@@ # because the inlined code is using the index of the attributes # to determine where to find the type constraint -- my $attrs = $self->attributes; ++ my $attrs = $self->_attributes; my @type_constraints = map { $_->can('type_constraint') ? $_->type_constraint : undef @@@ -174,24 -192,6 +164,24 @@@ $self->{'body'} = $code; } +sub _generate_params { + my ( $self, $var, $class_var ) = @_; + "my $var = " . $self->_generate_BUILDARGS( $class_var, '@_' ) . ";\n"; +} + +sub _generate_instance { + my ( $self, $var, $class_var ) = @_; + "my $var = " - . $self->meta_instance->inline_create_instance($class_var) . ";\n"; ++ . $self->_meta_instance->inline_create_instance($class_var) . ";\n"; +} + +sub _generate_slot_initializers { + my ($self) = @_; + return (join ";\n" => map { + $self->_generate_slot_initializer($_) - } 0 .. (@{$self->attributes} - 1)) . ";\n"; ++ } 0 .. (@{$self->_attributes} - 1)) . ";\n"; +} + sub _generate_BUILDARGS { my ( $self, $class, $args ) = @_; @@@ -222,8 -222,8 +212,8 @@@ sub _generate_BUILDALL sub _generate_triggers { my $self = shift; my @trigger_calls; -- foreach my $i ( 0 .. $#{ $self->attributes } ) { -- my $attr = $self->attributes->[$i]; ++ foreach my $i ( 0 .. $#{ $self->_attributes } ) { ++ my $attr = $self->_attributes->[$i]; next unless $attr->can('has_trigger') && $attr->has_trigger; @@@ -239,7 -239,7 +229,7 @@@ . $i . ']->trigger->(' . '$instance, ' -- . $self->meta_instance->inline_get_slot_value( ++ . $self->_meta_instance->inline_get_slot_value( '$instance', $attr->name, ) @@@ -254,7 -255,7 +244,7 @@@ sub _generate_slot_initializer my $self = shift; my $index = shift; -- my $attr = $self->attributes->[$index]; ++ my $attr = $self->_attributes->[$index]; my @source = ('## ' . $attr->name); @@@ -333,7 -334,7 +323,7 @@@ sub _generate_slot_assignment } else { $source = ( -- $self->meta_instance->inline_set_slot_value( ++ $self->_meta_instance->inline_set_slot_value( '$instance', $attr->name, $value @@@ -346,7 -347,7 +336,7 @@@ if ($is_moose && $attr->is_weak_ref) { $source .= ( "\n" . -- $self->meta_instance->inline_weaken_slot_value( ++ $self->_meta_instance->inline_weaken_slot_value( '$instance', $attr->name ) .