Merge branch 'master' into renames-and-deprecations
Dave Rolsky [Thu, 26 Mar 2009 21:33:35 +0000 (16:33 -0500)]
Conflicts:

t/010_self_introspection.t
t/073_make_mutable.t

16 files changed:
examples/ArrayBasedStorage.pod
examples/AttributesWithHistory.pod
examples/InsideOutClass.pod
examples/LazyClass.pod
lib/Class/MOP/Attribute.pm
lib/Class/MOP/Class.pm
lib/Class/MOP/Instance.pm
lib/Class/MOP/Method/Accessor.pm
lib/Class/MOP/Method/Constructor.pm
lib/Class/MOP/Module.pm
t/003_methods.t
t/004_advanced_methods.t
t/010_self_introspection.t
t/016_class_errors_and_edge_cases.t
t/050_scala_style_mixin_composition.t
t/073_make_mutable.t

index bff9baa..5c0369c 100644 (file)
@@ -23,7 +23,7 @@ sub new {
 
 sub create_instance {
     my $self = shift;
-    my $instance = $self->bless_instance_structure([]);
+    my $instance = bless [], $self->_class_name;
     $self->initialize_all_slots($instance);
     return $instance;
 }
index 54fcdc4..e7ae1c2 100644 (file)
@@ -47,7 +47,7 @@ use base 'Class::MOP::Method::Accessor';
 
 # generate the methods
 
-sub generate_history_accessor_method {
+sub _generate_history_accessor_method {
     my $attr_name = (shift)->associated_attribute->name;
     eval qq{sub {
         unless (ref \$_[0]->meta->get_attribute('$attr_name')->_history()->\{\$_[0]\}) \{
@@ -57,7 +57,7 @@ sub generate_history_accessor_method {
     }};    
 }
 
-sub generate_accessor_method {
+sub _generate_accessor_method {
     my $attr_name = (shift)->associated_attribute->name;
     eval qq{sub {
         if (scalar(\@_) == 2) {
@@ -71,7 +71,7 @@ sub generate_accessor_method {
     }};
 }
 
-sub generate_writer_method {
+sub _generate_writer_method {
     my $attr_name = (shift)->associated_attribute->name;
     eval qq{sub {
         unless (ref \$_[0]->meta->get_attribute('$attr_name')->_history()->\{\$_[0]\}) \{
index 5f94a25..07da94f 100644 (file)
@@ -45,7 +45,7 @@ use base 'Class::MOP::Method::Accessor';
 
 ## Method generation helpers
 
-sub generate_accessor_method {
+sub _generate_accessor_method {
     my $attr       = (shift)->associated_attribute;
     my $meta_class = $attr->associated_class;  
     my $attr_name  = $attr->name;
@@ -56,7 +56,7 @@ sub generate_accessor_method {
     };
 }
 
-sub generate_reader_method {
+sub _generate_reader_method {
     my $attr       = (shift)->associated_attribute;
     my $meta_class = $attr->associated_class;  
     my $attr_name  = $attr->name;
@@ -67,7 +67,7 @@ sub generate_reader_method {
     }; 
 }
 
-sub generate_writer_method {
+sub _generate_writer_method {
     my $attr       = (shift)->associated_attribute;
     my $meta_class = $attr->associated_class;  
     my $attr_name  = $attr->name;
@@ -77,7 +77,7 @@ sub generate_writer_method {
     };
 }
 
-sub generate_predicate_method {
+sub _generate_predicate_method {
     my $attr       = (shift)->associated_attribute;
     my $meta_class = $attr->associated_class;  
     my $attr_name  = $attr->name;
@@ -102,7 +102,7 @@ use base 'Class::MOP::Instance';
 
 sub create_instance {
        my ($self, $class) = @_;
-    $self->bless_instance_structure(\(my $instance));
+        bless \(my $instance), $self->_class_name;
 }
 
 sub get_slot_value {
index 262cd73..0c87b3a 100644 (file)
@@ -38,7 +38,7 @@ our $VERSION = '0.01';
 
 use base 'Class::MOP::Method::Accessor';
 
-sub generate_accessor_method {
+sub _generate_accessor_method {
     my $attr = (shift)->associated_attribute;
 
        my $attr_name = $attr->name;
@@ -59,7 +59,7 @@ sub generate_accessor_method {
     };
 }
 
-sub generate_reader_method {
+sub _generate_reader_method {
     my $attr = (shift)->associated_attribute;
 
        my $attr_name = $attr->name;
index 515aa5b..9340f35 100644 (file)
@@ -331,7 +331,7 @@ sub accessor_metaclass { 'Class::MOP::Method::Accessor' }
 sub process_accessors {
     warn 'The process_accessors method has been made private.'
         . " The public version is deprecated and will be removed in a future release.\n";
-    goto &_process_accessors;
+    shift->_process_accessors;
 }
 
 sub _process_accessors {
index 53e39cd..ef1d1a1 100644 (file)
@@ -35,7 +35,13 @@ sub initialize {
         || confess "You must pass a package name and it cannot be blessed";
 
     return Class::MOP::get_metaclass_by_name($package_name)
-        || $class->construct_class_instance(package => $package_name, @_);
+        || $class->_construct_class_instance(package => $package_name, @_);
+}
+
+sub construct_class_instance {
+    warn 'The construct_class_instance method has been made private.'
+        . " The public version is deprecated and will be removed in a future release.\n";
+    shift->_construct_class_instance;
 }
 
 # NOTE: (meta-circularity)
@@ -44,7 +50,7 @@ sub initialize {
 # meta-object instances for any Class::MOP::*
 # class. All other classes will use the more
 # normal &construct_instance.
-sub construct_class_instance {
+sub _construct_class_instance {
     my $class        = shift;
     my $options      = @_ == 1 ? $_[0] : {@_};
     my $package_name = $options->{package};
@@ -84,7 +90,7 @@ sub construct_class_instance {
     }
 
     # and check the metaclass compatibility
-    $meta->check_metaclass_compatibility();  
+    $meta->_check_metaclass_compatibility();  
 
     Class::MOP::store_metaclass_by_name($package_name, $meta);
 
@@ -146,7 +152,14 @@ sub update_package_cache_flag {
     $self->{'_package_cache_flag'} = Class::MOP::check_package_cache_flag($self->name);    
 }
 
+
 sub check_metaclass_compatibility {
+    warn 'The check_metaclass_compatibility method has been made private.'
+        . " The public version is deprecated and will be removed in a future release.\n";
+    shift->_check_metaclass_compatibility;
+}
+
+sub _check_metaclass_compatibility {
     my $self = shift;
 
     # this is always okay ...
@@ -263,8 +276,6 @@ sub create {
         || confess "You must pass a HASH ref of methods"
             if exists $options{methods};                  
 
-    $class->SUPER::create(%options);
-
     my (%initialize_options) = @args;
     delete @initialize_options{qw(
         package
@@ -276,6 +287,8 @@ sub create {
     )};
     my $meta = $class->initialize( $package_name => %initialize_options );
 
+    $meta->_instantiate_module( $options{version}, $options{authority} );
+
     # FIXME totally lame
     $meta->add_method('meta' => sub {
         $class->initialize(ref($_[0]) || $_[0]);
@@ -323,7 +336,7 @@ sub new_object {
     # Class::MOP::Class singletons here, so we
     # delegate this to &construct_class_instance
     # which will deal with the singletons
-    return $class->construct_class_instance(@_)
+    return $class->_construct_class_instance(@_)
         if $class->name->isa('Class::MOP::Class');
     return $class->construct_instance(@_);
 }
@@ -354,10 +367,16 @@ sub construct_instance {
 
 sub get_meta_instance {
     my $self = shift;
-    $self->{'_meta_instance'} ||= $self->create_meta_instance();
+    $self->{'_meta_instance'} ||= $self->_create_meta_instance();
 }
 
 sub create_meta_instance {
+    warn 'The create_meta_instance method has been made private.'
+        . " The public version is deprecated and will be removed in a future release.\n";
+    shift->_create_meta_instance;
+}
+
+sub _create_meta_instance {
     my $self = shift;
     
     my $instance = $self->instance_metaclass->new(
@@ -382,10 +401,16 @@ sub clone_object {
     # Class::MOP::Class singletons here, they
     # should not be cloned.
     return $instance if $instance->isa('Class::MOP::Class');
-    $class->clone_instance($instance, @_);
+    $class->_clone_instance($instance, @_);
 }
 
 sub clone_instance {
+    warn 'The clone_instance method has been made private.'
+        . " The public version is deprecated and will be removed in a future release.\n";
+    shift->_clone_instance;
+}
+
+sub _clone_instance {
     my ($class, $instance, %params) = @_;
     (blessed($instance))
         || confess "You can only clone instances, ($instance) is not a blessed instance";
@@ -471,7 +496,7 @@ sub superclasses {
         # not potentially creating an issues
         # we don't know about
 
-        $self->check_metaclass_compatibility();
+        $self->_check_metaclass_compatibility();
         $self->update_meta_instance_dependencies();
     }
     @{$self->get_package_symbol($var_spec)};
@@ -685,9 +710,9 @@ sub add_method {
 }
 
 sub alias_method {
-    my $self = shift;
+    warn "The alias_method method is deprecated. Use add_method instead.\n";
 
-    $self->add_method(@_);
+    shift->add_method;
 }
 
 sub has_method {
@@ -748,8 +773,10 @@ sub get_all_methods {
     return values %methods;
 }
 
-# compatibility
 sub compute_all_applicable_methods {
+    warn 'The compute_all_applicable_methods method is deprecated.'
+        . " Use get_all_methods instead.\n";
+
     return map {
         {
             name  => $_->name,
index 9500e91..546ffbf 100644 (file)
@@ -75,6 +75,9 @@ sub create_instance {
 
 # for compatibility
 sub bless_instance_structure {
+    warn 'The bless_instance_structure method is deprecated.'
+        . " It will be removed in a future release.\n";
+
     my ($self, $instance_structure) = @_;
     bless $instance_structure, $self->_class_name;
 }
index 6ef2043..6e40217 100644 (file)
@@ -36,7 +36,7 @@ sub new {
     # needed
     weaken($self->{'attribute'});
 
-    $self->initialize_body;
+    $self->_initialize_body;
 
     return $self;
 }
@@ -58,10 +58,16 @@ sub accessor_type        { (shift)->{'accessor_type'} }
 ## factory
 
 sub initialize_body {
+    warn 'The initialize_body method has been made private.'
+        . " The public version is deprecated and will be removed in a future release.\n";
+    shift->_initialize_body;
+}
+
+sub _initialize_body {
     my $self = shift;
 
     my $method_name = join "_" => (
-        'generate',
+        '_generate',
         $self->accessor_type,
         'method',
         ($self->is_inline ? 'inline' : ())
@@ -74,6 +80,12 @@ sub initialize_body {
 ## generators
 
 sub generate_accessor_method {
+    warn 'The generate_accessor_method method has been made private.'
+        . " The public version is deprecated and will be removed in a future release.\n";
+    shift->_generate_accessor_method;
+}
+
+sub _generate_accessor_method {
     my $attr = (shift)->associated_attribute;
     return sub {
         $attr->set_value($_[0], $_[1]) if scalar(@_) == 2;
@@ -82,6 +94,12 @@ sub generate_accessor_method {
 }
 
 sub generate_reader_method {
+    warn 'The generate_reader_method method has been made private.'
+        . " The public version is deprecated and will be removed in a future release.\n";
+    shift->_generate_reader_method;
+}
+
+sub _generate_reader_method {
     my $attr = (shift)->associated_attribute;
     return sub {
         confess "Cannot assign a value to a read-only accessor" if @_ > 1;
@@ -90,6 +108,12 @@ sub generate_reader_method {
 }
 
 sub generate_writer_method {
+    warn 'The generate_writer_method method has been made private.'
+        . " The public version is deprecated and will be removed in a future release.\n";
+    shift->_generate_writer_method;
+}
+
+sub _generate_writer_method {
     my $attr = (shift)->associated_attribute;
     return sub {
         $attr->set_value($_[0], $_[1]);
@@ -97,6 +121,12 @@ sub generate_writer_method {
 }
 
 sub generate_predicate_method {
+    warn 'The generate_predicate_method method has been made private.'
+        . " The public version is deprecated and will be removed in a future release.\n";
+    shift->_generate_predicate_method;
+}
+
+sub _generate_predicate_method {
     my $attr = (shift)->associated_attribute;
     return sub {
         $attr->has_value($_[0])
@@ -104,6 +134,12 @@ sub generate_predicate_method {
 }
 
 sub generate_clearer_method {
+    warn 'The generate_clearer_method method has been made private.'
+        . " The public version is deprecated and will be removed in a future release.\n";
+    shift->_generate_clearer_method;
+}
+
+sub _generate_clearer_method {
     my $attr = (shift)->associated_attribute;
     return sub {
         $attr->clear_value($_[0])
@@ -112,8 +148,13 @@ sub generate_clearer_method {
 
 ## Inline methods
 
-
 sub generate_accessor_method_inline {
+    warn 'The generate_accessor_method_inline method has been made private.'
+        . " The public version is deprecated and will be removed in a future release.\n";
+    shift->_generate_accessor_method_inline;
+}
+
+sub _generate_accessor_method_inline {
     my $self          = shift;
     my $attr          = $self->associated_attribute;
     my $attr_name     = $attr->name;
@@ -133,6 +174,12 @@ sub generate_accessor_method_inline {
 }
 
 sub generate_reader_method_inline {
+    warn 'The generate_reader_method_inline method has been made private.'
+        . " The public version is deprecated and will be removed in a future release.\n";
+    shift->_generate_reader_method_inline;
+}
+
+sub _generate_reader_method_inline {
     my $self          = shift;
     my $attr          = $self->associated_attribute;
     my $attr_name     = $attr->name;
@@ -151,6 +198,12 @@ sub generate_reader_method_inline {
 }
 
 sub generate_writer_method_inline {
+    warn 'The generate_writer_method_inline method has been made private.'
+        . " The public version is deprecated and will be removed in a future release.\n";
+    shift->_generate_writer_method_inline;
+}
+
+sub _generate_writer_method_inline {
     my $self          = shift;
     my $attr          = $self->associated_attribute;
     my $attr_name     = $attr->name;
@@ -167,8 +220,13 @@ sub generate_writer_method_inline {
     return $code;
 }
 
-
 sub generate_predicate_method_inline {
+    warn 'The generate_predicate_method_inline method has been made private.'
+        . " The public version is deprecated and will be removed in a future release.\n";
+    shift->_generate_predicate_method_inline;
+}
+
+sub _generate_predicate_method_inline {
     my $self          = shift;
     my $attr          = $self->associated_attribute;
     my $attr_name     = $attr->name;
@@ -186,6 +244,12 @@ sub generate_predicate_method_inline {
 }
 
 sub generate_clearer_method_inline {
+    warn 'The generate_clearer_method_inline method has been made private.'
+        . " The public version is deprecated and will be removed in a future release.\n";
+    shift->_generate_clearer_method_inline;
+}
+
+sub _generate_clearer_method_inline {
     my $self          = shift;
     my $attr          = $self->associated_attribute;
     my $attr_name     = $attr->name;
index 726200c..7f0fe51 100644 (file)
@@ -31,7 +31,7 @@ sub new {
     # needed
     weaken($self->{'associated_metaclass'});
 
-    $self->initialize_body;
+    $self->_initialize_body;
 
     return $self;
 }
@@ -62,11 +62,20 @@ sub associated_metaclass { (shift)->{'associated_metaclass'} }
 ## cached values ...
 
 sub meta_instance {
+    warn 'The meta_instance method has been made private.'
+        . " The public version is deprecated and will be removed in a future release.\n";
+    shift->_meta_instance;
+}
+
+sub _meta_instance {
     my $self = shift;
     $self->{'meta_instance'} ||= $self->associated_metaclass->get_meta_instance;
 }
 
 sub attributes {
+    warn 'The attributes method is deprecated.'
+        . " Use ->associated_metaclass->compute_all_applicable_attributes instead.\n";
+
     my $self = shift;
     $self->{'attributes'} ||= [ $self->associated_metaclass->compute_all_applicable_attributes ]
 }
@@ -74,8 +83,14 @@ sub attributes {
 ## method
 
 sub initialize_body {
+    warn 'The initialize_body method has been made private.'
+        . " The public version is deprecated and will be removed in a future release.\n";
+    shift->_initialize_body;
+}
+
+sub _initialize_body {
     my $self        = shift;
-    my $method_name = 'generate_constructor_method';
+    my $method_name = '_generate_constructor_method';
 
     $method_name .= '_inline' if $self->is_inline;
 
@@ -83,10 +98,22 @@ sub initialize_body {
 }
 
 sub generate_constructor_method {
+    warn 'The generate_constructor_method method has been made private.'
+        . " The public version is deprecated and will be removed in a future release.\n";
+    shift->_generate_constructor_method;
+}
+
+sub _generate_constructor_method {
     return sub { Class::MOP::Class->initialize(shift)->new_object(@_) }
 }
 
 sub generate_constructor_method_inline {
+    warn 'The generate_constructor_method_inline method has been made private.'
+        . " The public version is deprecated and will be removed in a future release.\n";
+    shift->_generate_constructor_method_inline;
+}
+
+sub _generate_constructor_method_inline {
     my $self = shift;
 
     my $close_over = {};
@@ -99,10 +126,10 @@ sub generate_constructor_method_inline {
 
     $source .= "\n" . 'my $params = @_ == 1 ? $_[0] : {@_};';
 
-    $source .= "\n" . 'my $instance = ' . $self->meta_instance->inline_create_instance('$class');
+    $source .= "\n" . 'my $instance = ' . $self->_meta_instance->inline_create_instance('$class');
     $source .= ";\n" . (join ";\n" => map {
         $self->_generate_slot_initializer($_, $close_over)
-    } @{$self->attributes});
+    } $self->associated_metaclass->compute_all_applicable_attributes);
     $source .= ";\n" . 'return $instance';
     $source .= ";\n" . '}';
     warn $source if $self->options->{debug};
@@ -148,12 +175,12 @@ sub _generate_slot_initializer {
     if ( defined $attr->init_arg ) {
       return (
           'if(exists $params->{\'' . $attr->init_arg . '\'}){' . "\n" .
-                $self->meta_instance->inline_set_slot_value(
+                $self->_meta_instance->inline_set_slot_value(
                     '$instance',
                     $attr->name,
                     '$params->{\'' . $attr->init_arg . '\'}' ) . "\n" .
            '} ' . (!defined $default ? '' : 'else {' . "\n" .
-                $self->meta_instance->inline_set_slot_value(
+                $self->_meta_instance->inline_set_slot_value(
                     '$instance',
                     $attr->name,
                      $default ) . "\n" .
@@ -161,7 +188,7 @@ sub _generate_slot_initializer {
         );
     } elsif ( defined $default ) {
         return (
-            $self->meta_instance->inline_set_slot_value(
+            $self->_meta_instance->inline_set_slot_value(
                 '$instance',
                 $attr->name,
                  $default ) . "\n"
index d6cdc7f..35294b1 100644 (file)
@@ -33,23 +33,25 @@ sub identifier {
 }
 
 sub create {
-    my ( $class, %options ) = @_;
+    confess "The Class::MOP::Module->create method has been made a private object method.\n";
+}
 
-    my $package_name = $options{package};
+sub _instantiate_module {
+    my $self      = shift;
+    my $version   = shift;
+    my $authority = shift;
 
-    (defined $package_name && $package_name)
-        || confess "You must pass a package name";
+    my $package_name = $self->name;
 
     my $code = "package $package_name;";
-    $code .= "\$$package_name\:\:VERSION = '" . $options{version} . "';"
-        if exists $options{version};
-    $code .= "\$$package_name\:\:AUTHORITY = '" . $options{authority} . "';"
-        if exists $options{authority};
+
+    $code .= "\$$package_name\:\:VERSION = '" . $version . "';"
+        if defined $version;
+    $code .= "\$$package_name\:\:AUTHORITY = '" . $authority . "';"
+        if defined $authority;
 
     eval $code;
     confess "creation of $package_name failed : $@" if $@;
-
-    return; # XXX: should this return some kind of meta object? ~sartak
 }
 
 1;
index 5088f50..e518c36 100644 (file)
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 67;
+use Test::More tests => 65;
 use Test::Exception;
 
 use Scalar::Util qw/reftype/;
@@ -137,17 +137,6 @@ for my $method_name (qw/
     }
 }
 
-{
-    package Foo::Aliasing;
-    use metaclass;
-    sub alias_me { '...' }
-}
-
-$Foo->alias_method('alias_me' => Foo::Aliasing->meta->get_method('alias_me'));
-
-ok($Foo->has_method('alias_me'), '... Foo->has_method(alias_me) (aliased from Foo::Aliasing)');
-ok(defined &Foo::alias_me, '... Foo does have a symbol table slow for alias_me though');
-
 ok(!$Foo->has_method('blessed'), '... !Foo->has_method(blessed) (imported into Foo)');
 ok(!$Foo->has_method('boom'), '... !Foo->has_method(boom) (defined in main:: using symbol tables and Sub::Name w/out package name)');
 
@@ -156,7 +145,7 @@ is($Foo->get_method('not_a_real_method'), undef, '... Foo->get_method(not_a_real
 
 is_deeply(
     [ sort $Foo->get_method_list ],
-    [ qw(FOO_CONSTANT alias_me baaz bang bar baz blah cake evaled_foo floob foo pie) ],
+    [ qw(FOO_CONSTANT baaz bang bar baz blah cake evaled_foo floob foo pie) ],
     '... got the right method list for Foo');
 
 is_deeply(
@@ -164,7 +153,6 @@ is_deeply(
     [
         map { $Foo->get_method($_) } qw(
             FOO_CONSTANT
-            alias_me
             baaz            
             bang 
             bar 
@@ -186,7 +174,7 @@ dies_ok { Foo->foo } '... cannot call Foo->foo because it is not there';
 
 is_deeply(
     [ sort $Foo->get_method_list ],
-    [ qw(FOO_CONSTANT alias_me baaz bang bar baz blah cake evaled_foo floob pie) ],
+    [ qw(FOO_CONSTANT baaz bang bar baz blah cake evaled_foo floob pie) ],
     '... got the right method list for Foo');
 
 
@@ -224,7 +212,6 @@ is_deeply(
     [ sort { $a->name cmp $b->name } $Bar->get_all_methods() ],
     [
         $Foo->get_method('FOO_CONSTANT'),
-        $Foo->get_method('alias_me'),
         $Foo->get_method('baaz'),
         $Foo->get_method('bang'),
         $Bar->get_method('bar'),
index 792b353..f598382 100644 (file)
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 12;
+use Test::More tests => 11;
 use Test::Exception;
 
 use Class::MOP;
@@ -106,38 +106,6 @@ is_deeply(
     ],
     '... got the right list of applicable methods for Foo::Bar');
 
-# test compute_all_applicable_methods once for compat
-is_deeply(
-    [ sort { $a->{name} cmp $b->{name} } Class::MOP::Class->initialize('Foo::Bar::Baz')->compute_all_applicable_methods() ],
-    [
-        {
-            name  => 'BUILD',
-            class => 'Foo::Bar::Baz',
-            code  => Class::MOP::Class->initialize('Foo::Bar::Baz')->get_method('BUILD')
-        },    
-        {
-            name  => 'bar',
-            class => 'Foo::Bar::Baz',
-            code  => Class::MOP::Class->initialize('Foo::Bar::Baz')->get_method('bar')
-        },
-        {
-            name  => 'baz',
-            class => 'Baz',
-            code  => Class::MOP::Class->initialize('Baz')->get_method('baz')
-        },        
-        {
-            name  => 'foo',
-            class => 'Foo',
-            code  => Class::MOP::Class->initialize('Foo')->get_method('foo')
-        },   
-        {
-            name  => 'foobarbaz',
-            class => 'Foo::Bar::Baz',
-            code  => Class::MOP::Class->initialize('Foo::Bar::Baz')->get_method('foobarbaz')
-        },            
-    ],
-    '... got the right list of applicable methods for Foo::Bar::Baz');
-
 ## find_all_methods_by_name
 
 is_deeply(
index b9b7e8b..6fc43ec 100644 (file)
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 250;
+use Test::More tests => 260;
 use Test::Exception;
 
 use Class::MOP;
@@ -40,6 +40,8 @@ my @class_mop_package_methods = qw(
 my @class_mop_module_methods = qw(
     _new
 
+    _instantiate_module
+
     version authority identifier create
 );
 
@@ -55,11 +57,14 @@ my @class_mop_class_methods = qw(
 
     create_anon_class is_anon_class
 
-    instance_metaclass get_meta_instance create_meta_instance
+    instance_metaclass get_meta_instance
+    create_meta_instance _create_meta_instance
     new_object clone_object
-    construct_instance construct_class_instance clone_instance
+    construct_instance
+    construct_class_instance _construct_class_instance
+    clone_instance _clone_instance
     rebless_instance rebless_instance_away
-    check_metaclass_compatibility
+    check_metaclass_compatibility _check_metaclass_compatibility
 
     add_meta_instance_dependencies remove_meta_instance_dependencies update_meta_instance_dependencies
     add_dependent_meta_instance remove_dependent_meta_instance
index 256d058..df5fe2a 100644 (file)
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 48;
+use Test::More tests => 43;
 use Test::Exception;
 
 use Class::MOP;
@@ -22,16 +22,16 @@ use Class::MOP;
 
 {
     dies_ok {
-        Class::MOP::Class->construct_class_instance();
-    } '... construct_class_instance requires an :package parameter';
+        Class::MOP::Class->_construct_class_instance();
+    } '... _construct_class_instance requires an :package parameter';
     
     dies_ok {
-        Class::MOP::Class->construct_class_instance(':package' => undef);
-    } '... construct_class_instance requires a defined :package parameter';     
+        Class::MOP::Class->_construct_class_instance(':package' => undef);
+    } '... _construct_class_instance requires a defined :package parameter';     
     
     dies_ok {
-        Class::MOP::Class->construct_class_instance(':package' => '');
-    } '... construct_class_instance requires a valid :package parameter'; 
+        Class::MOP::Class->_construct_class_instance(':package' => '');
+    } '... _construct_class_instance requires a valid :package parameter'; 
 }
 
 
@@ -58,10 +58,6 @@ use Class::MOP;
     dies_ok {
         Class::MOP::Class->clone_object(1);
     } '... can only clone instances';
-    
-    dies_ok {
-        Class::MOP::Class->clone_instance(1);
-    } '... can only clone instances';    
 }
 
 {
@@ -84,24 +80,6 @@ use Class::MOP;
 
 {
     dies_ok {
-        Class::MOP::Class->alias_method();
-    } '... alias_method dies as expected';
-    
-    dies_ok {
-        Class::MOP::Class->alias_method('');
-    } '... alias_method dies as expected';   
-
-    dies_ok {
-        Class::MOP::Class->alias_method('foo' => 'foo');
-    } '... alias_method dies as expected';
-    
-    dies_ok {
-        Class::MOP::Class->alias_method('foo' => []);
-    } '... alias_method dies as expected';     
-}
-
-{
-    dies_ok {
         Class::MOP::Class->has_method();
     } '... has_method dies as expected';
     
index 7dcc949..2078494 100644 (file)
@@ -101,7 +101,7 @@ sub ::with ($) {
 
     # add all the methods in ....    
     foreach my $method_name (keys %methods) {
-        $metaclass->alias_method($method_name => $methods{$method_name}) 
+        $metaclass->add_method($method_name => $methods{$method_name}) 
             unless $metaclass->has_method($method_name);
     }    
 }
index 1ad0c96..ae6210f 100644 (file)
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 114;
+use Test::More tests => 101;
 use Test::Exception;
 
 use Scalar::Util;
@@ -72,13 +72,6 @@ use Class::MOP;
     ok( $meta->add_method('xyz', sub{'xxx'}), '... added method');
     is( Baz->xyz, 'xxx',                      '... method xyz works');
 
-    ok(! $meta->has_method('zxy')             ,'...  we dont have the aliased method yet');    
-    ok( $meta->alias_method('zxy',sub{'xxx'}),'... aliased method');
-    ok( $meta->has_method('zxy')             ,'...  the aliased method does register');    
-    is( Baz->zxy, 'xxx',                      '... method zxy works');
-    ok( $meta->remove_method('xyz'),          '... removed method');
-    ok( $meta->remove_method('zxy'),          '... removed aliased method');
-
     ok($meta->add_attribute('fickle', accessor => 'fickle'), '... added attribute');
     ok(Baz->can('fickle'),                '... Baz can fickle');
     ok($meta->remove_attribute('fickle'), '... removed attribute');
@@ -111,8 +104,6 @@ use Class::MOP;
     lives_ok { $meta->make_immutable() } '... changed Baz to be immutable';
 
     dies_ok{ $meta->add_method('xyz', sub{'xxx'})  } '... exception thrown as expected';
-    dies_ok{ $meta->alias_method('zxy',sub{'xxx'}) } '... exception thrown as expected';
-    dies_ok{ $meta->remove_method('zxy')           } '... exception thrown as expected';
 
     dies_ok {
       $meta->add_attribute('fickle', accessor => 'fickle')
@@ -137,8 +128,8 @@ use Class::MOP;
     my $meta = Baz->meta->create_anon_class(superclasses => ['Baz']);
     my %orig_keys = map { $_ => 1 } grep { !/^_/ } keys %$meta;
     $orig_keys{immutable_transformer} = 1;
-    my @orig_meths = sort { $a->{name} cmp $b->{name} }
-      $meta->compute_all_applicable_methods;
+    my @orig_meths = sort { $a->name cmp $b->name }
+      $meta->get_all_methods;
     ok($meta->is_anon_class,                  'We have an anon metaclass');
     ok($meta->is_mutable,  '... our anon class is mutable');
     ok(!$meta->is_immutable,  '... our anon class is not immutable');
@@ -161,19 +152,16 @@ use Class::MOP;
     my $instance = $meta->new_object;
 
     my %new_keys  = map { $_ => 1 } grep { !/^_/ } keys %$meta;
-    my @new_meths = sort { $a->{name} cmp $b->{name} }
-      $meta->compute_all_applicable_methods;
+    my @new_meths = sort { $a->name cmp $b->name }
+      $meta->get_all_methods;
     is_deeply(\%orig_keys, \%new_keys, '... no extraneous hashkeys');
-    is_deeply(\@orig_meths, \@new_meths, '... no extraneous methods');
+    is_deeply(\@orig_meths, \@new_meths, '... no straneous methods');
 
     isa_ok($meta, 'Class::MOP::Class', '... Anon class isa Class::MOP::Class');
 
     ok( $meta->add_method('xyz', sub{'xxx'}), '... added method');
     is( $instance->xyz , 'xxx',               '... method xyz works');
-    ok( $meta->alias_method('zxy',sub{'xxx'}),'... aliased method');
-    is( $instance->zxy, 'xxx',                '... method zxy works');
     ok( $meta->remove_method('xyz'),          '... removed method');
-    ok( $meta->remove_method('zxy'),          '... removed aliased method');
 
     ok($meta->add_attribute('fickle', accessor => 'fickle'), '... added attribute');
     ok($instance->can('fickle'),          '... instance can fickle');
@@ -211,8 +199,6 @@ use Class::MOP;
     lives_ok {$meta->make_immutable  } '... changed class to be immutable';
 
     dies_ok{ $meta->add_method('xyz', sub{'xxx'})  } '... exception thrown as expected';
-    dies_ok{ $meta->alias_method('zxy',sub{'xxx'}) } '... exception thrown as expected';
-    dies_ok{ $meta->remove_method('zxy')           } '... exception thrown as expected';
 
     dies_ok {
       $meta->add_attribute('fickle', accessor => 'fickle')