Merge branch 'renames-and-deprecations'
Dave Rolsky [Sun, 5 Apr 2009 21:11:11 +0000 (16:11 -0500)]
Conflicts:
lib/Moose/Meta/Attribute.pm
lib/Moose/Meta/Method/Constructor.pm

There are still some warnings and test failures to work out.

lib/Moose/Manual/Concepts.pod
lib/Moose/Meta/Attribute.pm
lib/Moose/Meta/Class.pm
lib/Moose/Meta/Method/Accessor.pm
lib/Moose/Meta/Method/Constructor.pm
lib/Moose/Meta/Role.pm
lib/Moose/Util.pm
t/060_compat/003_foreign_inheritence.t
t/200_examples/002_example_Moose_POOP.t
t/200_examples/006_example_Protomoose.t

index 33c8f4e..125ba9c 100644 (file)
@@ -312,7 +312,7 @@ class it represents.
 
   my $meta = User->meta();
 
-  for my $attribute ( $meta->compute_all_applicable_attributes ) {
+  for my $attribute ( $meta->get_all_attributes ) {
       print $attribute->name(), "\n";
 
       if ( $attribute->has_type_constraint ) {
@@ -320,7 +320,7 @@ class it represents.
       }
   }
 
-  for my $method ( $meta->compute_all_applicable_methods ) {
+  for my $method ( $meta->get_all_methods ) {
       print $method->name, "\n";
   }
 
index 3ee8bcf..4760f92 100644 (file)
@@ -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) } Class::MOP::class_of($self)->get_all_attributes ) {
         push @{ $attr->has_init_arg ? \@init : \@non_init }, $attr;
     }
 
index d76da79..5f2f535 100644 (file)
@@ -71,14 +71,14 @@ sub create {
     return $class;
 }
 
-sub check_metaclass_compatibility {
+sub _check_metaclass_compatibility {
     my $self = shift;
 
     if ( my @supers = $self->superclasses ) {
         $self->_fix_metaclass_incompatibility(@supers);
     }
 
-    $self->SUPER::check_metaclass_compatibility(@_);
+    $self->SUPER::_check_metaclass_compatibility(@_);
 }
 
 my %ANON_CLASSES;
@@ -164,7 +164,7 @@ sub new_object {
     my $params = @_ == 1 ? $_[0] : {@_};
     my $self   = $class->SUPER::new_object($params);
 
-    foreach my $attr ( $class->compute_all_applicable_attributes() ) {
+    foreach my $attr ( $class->get_all_attributes() ) {
 
         next unless $attr->can('has_trigger') && $attr->has_trigger;
 
@@ -187,7 +187,7 @@ sub new_object {
     return $self;
 }
 
-sub construct_instance {
+sub _construct_instance {
     my $class = shift;
     my $params = @_ == 1 ? $_[0] : {@_};
     my $meta_instance = $class->get_meta_instance;
@@ -196,7 +196,7 @@ sub construct_instance {
     # but this is foreign inheritance, so we might
     # have to kludge it in the end.
     my $instance = $params->{'__INSTANCE__'} || $meta_instance->create_instance();
-    foreach my $attr ($class->compute_all_applicable_attributes()) {
+    foreach my $attr ($class->get_all_attributes()) {
         $attr->initialize_instance_slot($meta_instance, $instance, $params);
     }
     return $instance;
index 21e56d0..d033555 100644 (file)
@@ -39,7 +39,7 @@ sub _eval_code {
         or $self->throw_error("Could not create writer for '${\$self->associated_attribute->name}' because $@ \n code: $code", error => $@, data => $code );
 }
 
-sub generate_accessor_method_inline {
+sub _generate_accessor_method_inline {
     my $self        = $_[0];
     my $attr        = $self->associated_attribute;
     my $attr_name   = $attr->name;
@@ -63,7 +63,7 @@ sub generate_accessor_method_inline {
     . ' }');
 }
 
-sub generate_writer_method_inline {
+sub _generate_writer_method_inline {
     my $self        = $_[0];
     my $attr        = $self->associated_attribute;
     my $attr_name   = $attr->name;
@@ -83,7 +83,7 @@ sub generate_writer_method_inline {
     . ' }');
 }
 
-sub generate_reader_method_inline {
+sub _generate_reader_method_inline {
     my $self        = $_[0];
     my $attr        = $self->associated_attribute;
     my $attr_name   = $attr->name;
@@ -109,11 +109,11 @@ sub _value_needs_copy {
     return $attr->should_coerce;
 }
 
-sub generate_reader_method { shift->generate_reader_method_inline(@_) }
-sub generate_writer_method { shift->generate_writer_method_inline(@_) }
-sub generate_accessor_method { shift->generate_accessor_method_inline(@_) }
-sub generate_predicate_method { shift->generate_predicate_method_inline(@_) }
-sub generate_clearer_method { shift->generate_clearer_method_inline(@_) }
+sub _generate_reader_method { shift->_generate_reader_method_inline(@_) }
+sub _generate_writer_method { shift->_generate_writer_method_inline(@_) }
+sub _generate_accessor_method { shift->_generate_accessor_method_inline(@_) }
+sub _generate_predicate_method { shift->_generate_predicate_method_inline(@_) }
+sub _generate_clearer_method { shift->_generate_clearer_method_inline(@_) }
 
 sub _inline_pre_body  { '' }
 sub _inline_post_body { '' }
index 1c60f63..997665c 100644 (file)
@@ -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 {
-        # from our superclass
         '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 ],
-        # ...
         'associated_metaclass' => $meta,
     } => $class;
 
@@ -42,7 +37,7 @@ sub new {
     # needed
     weaken($self->{'associated_metaclass'});
 
-    $self->initialize_body;
+    $self->_initialize_body;
 
     return $self;
 }
@@ -108,14 +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 _initialize_body {
     my $self = shift;
     # TODO:
     # the %options should also include a both
@@ -151,7 +141,7 @@ sub initialize_body {
     # 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
@@ -182,14 +172,14 @@ sub _generate_params {
 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 {
@@ -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 +229,7 @@ sub _generate_triggers {
             . $i
             . ']->trigger->('
             . '$instance, '
-            . $self->meta_instance->inline_get_slot_value(
+            . $self->_meta_instance->inline_get_slot_value(
                   '$instance',
                   $attr->name,
               )
@@ -254,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 +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 +336,7 @@ sub _generate_slot_assignment {
     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
             ) .
index 101be10..57d790a 100644 (file)
@@ -482,8 +482,6 @@ sub create {
         || confess "You must pass a HASH ref of methods"
             if exists $options{methods};
 
-    $role->SUPER::create(%options);
-
     my (%initialize_options) = %options;
     delete @initialize_options{qw(
         package
@@ -495,6 +493,8 @@ sub create {
 
     my $meta = $role->initialize( $package_name => %initialize_options );
 
+    $meta->_instantiate_module( $options{version}, $options{authority} );
+
     # FIXME totally lame
     $meta->add_method('meta' => sub {
         $role->initialize(ref($_[0]) || $_[0]);
index bc78ab9..f4437d5 100644 (file)
@@ -107,7 +107,7 @@ sub get_all_attribute_values {
     return +{
         map { $_->name => $_->get_value($instance) }
             grep { $_->has_value($instance) }
-                $class->compute_all_applicable_attributes
+                $class->get_all_attributes
     };
 }
 
@@ -117,7 +117,7 @@ sub get_all_init_args {
         map { $_->init_arg => $_->get_value($instance) }
             grep { $_->has_value($instance) }
                 grep { defined($_->init_arg) } 
-                    $class->compute_all_applicable_attributes
+                    $class->get_all_attributes
     };
 }
 
index d0acaa1..1086699 100644 (file)
@@ -9,41 +9,44 @@ use Test::Exception;
 
 
 {
-       package Elk;
-       use strict;
-       use warnings;
-       
-       sub new {
-               my $class = shift;
-               bless { no_moose => "Elk" } => $class;
-       }
-       
-       sub no_moose { $_[0]->{no_moose} }
-
-       package Foo::Moose;     
-       use Moose;
-       
-       extends 'Elk';
-       
-       has 'moose' => (is => 'ro', default => 'Foo');
-       
-       sub new {
-               my $class = shift;
-               my $super = $class->SUPER::new(@_);
-               return $class->meta->new_object('__INSTANCE__' => $super, @_);
-       }
-       
-       __PACKAGE__->meta->make_immutable(debug => 0);
+
+    package Elk;
+    use strict;
+    use warnings;
+
+    sub new {
+        my $class = shift;
+        bless { no_moose => "Elk" } => $class;
+    }
+
+    sub no_moose { $_[0]->{no_moose} }
+
+    package Foo::Moose;
+    use Moose;
+
+    extends 'Elk';
+
+    has 'moose' => ( is => 'ro', default => 'Foo' );
+
+    sub new {
+        my $class = shift;
+        my $super = $class->SUPER::new(@_);
+        return $class->meta->new_object( '__INSTANCE__' => $super, @_ );
+    }
+
+    __PACKAGE__->meta->make_immutable( debug => 0 );
 
     package Bucket;
     use metaclass 'Class::MOP::Class';
-    
-    __PACKAGE__->meta->add_attribute('squeegee' => (accessor => 'squeegee'));
-    
+
+    __PACKAGE__->meta->add_attribute(
+        'squeegee' => ( accessor => 'squeegee' ) );
+
     package Old::Bucket::Nose;
+
     # see http://www.moosefoundation.org/moose_facts.htm
     use Moose;
-    
+
     extends 'Bucket';
 
     package MyBase;
@@ -65,21 +68,25 @@ use Test::Exception;
     use metaclass 'Custom::Meta2';
     use Moose;
 
-  # XXX FIXME subclassing meta-attrs and immutable-ing the subclass fails
+    # XXX FIXME subclassing meta-attrs and immutable-ing the subclass fails
 }
 
 my $foo_moose = Foo::Moose->new();
-isa_ok($foo_moose, 'Foo::Moose');
-isa_ok($foo_moose, 'Elk');
+isa_ok( $foo_moose, 'Foo::Moose' );
+isa_ok( $foo_moose, 'Elk' );
 
-is($foo_moose->no_moose, 'Elk', '... got the right value from the Elk method');
-is($foo_moose->moose, 'Foo', '... got the right value from the Foo::Moose method');
+is( $foo_moose->no_moose, 'Elk',
+    '... got the right value from the Elk method' );
+is( $foo_moose->moose, 'Foo',
+    '... got the right value from the Foo::Moose method' );
+
+lives_ok {
+    Old::Bucket::Nose->meta->make_immutable( debug => 0 );
+}
+'Immutability on Moose class extending Class::MOP class ok';
 
-lives_ok { 
-    Old::Bucket::Nose->meta->make_immutable(debug => 0); 
-} 'Immutability on Moose class extending Class::MOP class ok';
-    
 lives_ok {
     SubClass2->meta->superclasses('MyBase');
-} 'Can subclass the same non-Moose class twice with different metaclasses';
+}
+'Can subclass the same non-Moose class twice with different metaclasses';
 
index a7e0153..79c864c 100644 (file)
@@ -72,19 +72,20 @@ BEGIN {
             
             $db->{$class}->[($oid - 1)] = {};
             
-            $self->bless_instance_structure({
+            bless {
                 oid      => $oid,
                 instance => $db->{$class}->[($oid - 1)]
-            });
+            }, $class;
         }
         
         sub find_instance {
             my ($self, $oid) = @_;
             my $instance = $db->{$self->associated_metaclass->name}->[($oid - 1)];  
-            $self->bless_instance_structure({
+
+            bless {
                 oid      => $oid,
-                instance => $instance
-            });                  
+                instance => $instance,
+            }, $self->associated_metaclass->name;
         } 
         
         sub clone_instance {
@@ -95,10 +96,10 @@ BEGIN {
                         
             my $clone = tied($instance)->clone;
             
-            $self->bless_instance_structure({
+            bless {
                 oid      => $oid,
-                instance => $clone
-            });        
+                instance => $clone,
+            }, $class;
         }               
     }
     
@@ -136,7 +137,7 @@ BEGIN {
     
     extends 'Moose::Meta::Class';    
     
-    override 'construct_instance' => sub {
+    override '_construct_instance' => sub {
         my $class = shift;
         my $params = @_ == 1 ? $_[0] : {@_};
         return $class->get_meta_instance->find_instance($params->{oid}) 
index 6719e57..123d785 100644 (file)
@@ -67,7 +67,7 @@ Well cause merlyn asked if it could :)
         return $instance;
     }
     
-    sub generate_accessor_method {
+    sub _generate_accessor_method {
         my $self = shift;
         my $attr = $self->associated_attribute; 
         return sub {
@@ -81,7 +81,7 @@ Well cause merlyn asked if it could :)
         };
     }
 
-    sub generate_reader_method {
+    sub _generate_reader_method {
         my $self = shift;
         my $attr = $self->associated_attribute; 
         return sub {
@@ -90,7 +90,7 @@ Well cause merlyn asked if it could :)
         };   
     }
 
-    sub generate_writer_method {
+    sub _generate_writer_method {
         my $self = shift;
         my $attr = $self->associated_attribute; 
         return sub {