Rename HasMethod & HasAttributes as Class::MOP::Mixin::...
Dave Rolsky [Fri, 25 Dec 2009 16:57:52 +0000 (10:57 -0600)]
lib/Class/MOP.pm
lib/Class/MOP/Class.pm
lib/Class/MOP/Mixin/HasAttributes.pm [moved from lib/Class/MOP/HasAttributes.pm with 98% similarity]
lib/Class/MOP/Mixin/HasMethods.pm [moved from lib/Class/MOP/HasMethods.pm with 99% similarity]
lib/Class/MOP/Package.pm
t/000_load.t
t/010_self_introspection.t
xs/HasMethods.xs
xs/MOP.xs

index 10d998a..5749ce7 100644 (file)
@@ -12,8 +12,8 @@ use Carp          'confess';
 use Scalar::Util  'weaken', 'reftype', 'blessed';
 use Try::Tiny;
 
-use Class::MOP::HasAttributes;
-use Class::MOP::HasMethods;
+use Class::MOP::Mixin::HasAttributes;
+use Class::MOP::Mixin::HasMethods;
 use Class::MOP::Class;
 use Class::MOP::Attribute;
 use Class::MOP::Method;
@@ -162,48 +162,48 @@ sub _is_valid_class_name {
 # inherit them using _construct_instance
 
 ## --------------------------------------------------------
-## Class::MOP::HasMethods
+## Class::MOP::Mixin::HasMethods
 
-Class::MOP::HasMethods->meta->add_attribute(
+Class::MOP::Mixin::HasMethods->meta->add_attribute(
     Class::MOP::Attribute->new('_methods' => (
         reader   => {
             # NOTE:
             # we just alias the original method
             # rather than re-produce it here
-            '_full_method_map' => \&Class::MOP::HasMethods::_full_method_map
+            '_full_method_map' => \&Class::MOP::Mixin::HasMethods::_full_method_map
         },
         default => sub { {} }
     ))
 );
 
-Class::MOP::HasMethods->meta->add_attribute(
+Class::MOP::Mixin::HasMethods->meta->add_attribute(
     Class::MOP::Attribute->new('method_metaclass' => (
         reader   => {
             # NOTE:
             # we just alias the original method
             # rather than re-produce it here
-            'method_metaclass' => \&Class::MOP::HasMethods::method_metaclass
+            'method_metaclass' => \&Class::MOP::Mixin::HasMethods::method_metaclass
         },
         default  => 'Class::MOP::Method',
     ))
 );
 
-Class::MOP::HasMethods->meta->add_attribute(
+Class::MOP::Mixin::HasMethods->meta->add_attribute(
     Class::MOP::Attribute->new('wrapped_method_metaclass' => (
         reader   => {
             # NOTE:
             # we just alias the original method
             # rather than re-produce it here
-            'wrapped_method_metaclass' => \&Class::MOP::HasMethods::wrapped_method_metaclass
+            'wrapped_method_metaclass' => \&Class::MOP::Mixin::HasMethods::wrapped_method_metaclass
         },
         default  => 'Class::MOP::Method::Wrapped',
     ))
 );
 
 ## --------------------------------------------------------
-## Class::MOP::HasMethods
+## Class::MOP::Mixin::HasMethods
 
-Class::MOP::HasAttributes->meta->add_attribute(
+Class::MOP::Mixin::HasAttributes->meta->add_attribute(
     Class::MOP::Attribute->new('attributes' => (
         reader   => {
             # NOTE: we need to do this in order
@@ -212,19 +212,19 @@ Class::MOP::HasAttributes->meta->add_attribute(
             #
             # we just alias the original method
             # rather than re-produce it here
-            '_attribute_map' => \&Class::MOP::HasAttributes::_attribute_map
+            '_attribute_map' => \&Class::MOP::Mixin::HasAttributes::_attribute_map
         },
         default  => sub { {} }
     ))
 );
 
-Class::MOP::HasAttributes->meta->add_attribute(
+Class::MOP::Mixin::HasAttributes->meta->add_attribute(
     Class::MOP::Attribute->new('attribute_metaclass' => (
         reader   => {
             # NOTE:
             # we just alias the original method
             # rather than re-produce it here
-            'attribute_metaclass' => \&Class::MOP::HasAttributes::attribute_metaclass
+            'attribute_metaclass' => \&Class::MOP::Mixin::HasAttributes::attribute_metaclass
         },
         default  => 'Class::MOP::Attribute',
     ))
@@ -697,8 +697,8 @@ $_->meta->make_immutable(
     constructor_name    => undef,
     inline_accessors => 0,
 ) for qw/
-    Class::MOP::HasAttributes
-    Class::MOP::HasMethods
+    Class::MOP::Mixin::HasAttributes
+    Class::MOP::Mixin::HasMethods
 /;
 
 1;
index 88e9af4..1d23967 100644 (file)
@@ -19,7 +19,7 @@ our $VERSION   = '0.97';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
-use base 'Class::MOP::Module', 'Class::MOP::HasAttributes';
+use base 'Class::MOP::Module', 'Class::MOP::Mixin::HasAttributes';
 
 # Creation
 
similarity index 98%
rename from lib/Class/MOP/HasAttributes.pm
rename to lib/Class/MOP/Mixin/HasAttributes.pm
index e2806da..55d42ec 100644 (file)
@@ -1,4 +1,4 @@
-package Class::MOP::HasAttributes;
+package Class::MOP::Mixin::HasAttributes;
 
 use strict;
 use warnings;
similarity index 99%
rename from lib/Class/MOP/HasMethods.pm
rename to lib/Class/MOP/Mixin/HasMethods.pm
index 44579df..75cb51a 100644 (file)
@@ -1,4 +1,4 @@
-package Class::MOP::HasMethods;
+package Class::MOP::Mixin::HasMethods;
 
 use strict;
 use warnings;
index 8fb1090..e9f388c 100644 (file)
@@ -11,7 +11,7 @@ our $VERSION   = '0.97';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
-use base 'Class::MOP::HasMethods';
+use base 'Class::MOP::Mixin::HasMethods';
 
 # creation ...
 
index 2bc17cc..47ce599 100644 (file)
@@ -5,8 +5,8 @@ use Test::More;
 
 BEGIN {
     use_ok('Class::MOP');
-    use_ok('Class::MOP::HasAttributes');
-    use_ok('Class::MOP::HasMethods');
+    use_ok('Class::MOP::Mixin::HasAttributes');
+    use_ok('Class::MOP::Mixin::HasMethods');
     use_ok('Class::MOP::Package');
     use_ok('Class::MOP::Module');
     use_ok('Class::MOP::Class');
@@ -31,8 +31,8 @@ my %METAS = (
     'Class::MOP::Method::Accessor'  => Class::MOP::Method::Accessor->meta,
     'Class::MOP::Method::Constructor' =>
         Class::MOP::Method::Constructor->meta,
-    'Class::MOP::HasAttributes'   => Class::MOP::HasAttributes->meta,
-    'Class::MOP::HasMethods'      => Class::MOP::HasMethods->meta,
+    'Class::MOP::Mixin::HasAttributes'   => Class::MOP::Mixin::HasAttributes->meta,
+    'Class::MOP::Mixin::HasMethods'      => Class::MOP::Mixin::HasMethods->meta,
     'Class::MOP::Package'         => Class::MOP::Package->meta,
     'Class::MOP::Module'          => Class::MOP::Module->meta,
     'Class::MOP::Class'           => Class::MOP::Class->meta,
@@ -74,8 +74,6 @@ is_deeply(
         Class::MOP::Class->meta,
         Class::MOP::Class::Immutable::Class::MOP::Class->meta,
         Class::MOP::class_of('Class::MOP::Class::Immutable::Trait'),
-        Class::MOP::HasAttributes->meta,
-        Class::MOP::HasMethods->meta,
         Class::MOP::Instance->meta,
         Class::MOP::Method->meta,
         Class::MOP::Method::Accessor->meta,
@@ -83,6 +81,8 @@ is_deeply(
         Class::MOP::Method::Generated->meta,
         Class::MOP::Method::Inlined->meta,
         Class::MOP::Method::Wrapped->meta,
+        Class::MOP::Mixin::HasAttributes->meta,
+        Class::MOP::Mixin::HasMethods->meta,
         Class::MOP::Module->meta,
         Class::MOP::Object->meta,
         Class::MOP::Package->meta,
@@ -98,8 +98,8 @@ is_deeply(
             Class::MOP::Class
             Class::MOP::Class::Immutable::Class::MOP::Class
             Class::MOP::Class::Immutable::Trait
-            Class::MOP::HasAttributes
-            Class::MOP::HasMethods
+            Class::MOP::Mixin::HasAttributes
+            Class::MOP::Mixin::HasMethods
             Class::MOP::Instance
             Class::MOP::Method
             Class::MOP::Method::Accessor
index ea4bdd5..cb95b6b 100644 (file)
@@ -242,7 +242,7 @@ is($class_mop_package_meta->get_attribute('package')->init_arg, 'package', '...
 # ... package, but inherited from HasMethods
 ok($class_mop_package_meta->find_attribute_by_name('method_metaclass')->has_reader, '... Class::MOP::Package method_metaclass has a reader');
 is_deeply($class_mop_package_meta->find_attribute_by_name('method_metaclass')->reader,
-   { 'method_metaclass' => \&Class::MOP::HasMethods::method_metaclass },
+   { 'method_metaclass' => \&Class::MOP::Mixin::HasMethods::method_metaclass },
    '... Class::MOP::Package method_metaclass\'s a reader is &method_metaclass');
 
 ok($class_mop_package_meta->find_attribute_by_name('method_metaclass')->has_init_arg, '... Class::MOP::Package method_metaclass has a init_arg');
@@ -257,7 +257,7 @@ is($class_mop_package_meta->find_attribute_by_name('method_metaclass')->default,
 
 ok($class_mop_package_meta->find_attribute_by_name('wrapped_method_metaclass')->has_reader, '... Class::MOP::Package wrapped_method_metaclass has a reader');
 is_deeply($class_mop_package_meta->find_attribute_by_name('wrapped_method_metaclass')->reader,
-   { 'wrapped_method_metaclass' => \&Class::MOP::HasMethods::wrapped_method_metaclass },
+   { 'wrapped_method_metaclass' => \&Class::MOP::Mixin::HasMethods::wrapped_method_metaclass },
    '... Class::MOP::Package wrapped_method_metaclass\'s a reader is &wrapped_method_metaclass');
 
 ok($class_mop_package_meta->find_attribute_by_name('wrapped_method_metaclass')->has_init_arg, '... Class::MOP::Package wrapped_method_metaclass has a init_arg');
@@ -275,7 +275,7 @@ is($class_mop_package_meta->find_attribute_by_name('method_metaclass')->default,
 
 ok($class_mop_class_meta->find_attribute_by_name('attributes')->has_reader, '... Class::MOP::Class attributes has a reader');
 is_deeply($class_mop_class_meta->find_attribute_by_name('attributes')->reader,
-   { '_attribute_map' => \&Class::MOP::HasAttributes::_attribute_map },
+   { '_attribute_map' => \&Class::MOP::Mixin::HasAttributes::_attribute_map },
    '... Class::MOP::Class attributes\'s a reader is &_attribute_map');
 
 ok($class_mop_class_meta->find_attribute_by_name('attributes')->has_init_arg, '... Class::MOP::Class attributes has a init_arg');
@@ -290,7 +290,7 @@ is_deeply($class_mop_class_meta->find_attribute_by_name('attributes')->default('
 
 ok($class_mop_class_meta->find_attribute_by_name('attribute_metaclass')->has_reader, '... Class::MOP::Class attribute_metaclass has a reader');
 is_deeply($class_mop_class_meta->find_attribute_by_name('attribute_metaclass')->reader,
-   { 'attribute_metaclass' => \&Class::MOP::HasAttributes::attribute_metaclass },
+   { 'attribute_metaclass' => \&Class::MOP::Mixin::HasAttributes::attribute_metaclass },
   '... Class::MOP::Class attribute_metaclass\'s a reader is &attribute_metaclass');
 
 ok($class_mop_class_meta->find_attribute_by_name('attribute_metaclass')->has_init_arg, '... Class::MOP::Class attribute_metaclass has a init_arg');
@@ -315,7 +315,7 @@ is(${$class_mop_class_meta->get_package_symbol('$VERSION')},
 
 is_deeply(
     [ $class_mop_class_meta->superclasses ],
-    [ qw/Class::MOP::Module Class::MOP::HasAttributes/ ],
+    [ qw/Class::MOP::Module Class::MOP::Mixin::HasAttributes/ ],
     '... Class::MOP::Class->superclasses == [ Class::MOP::Module ]');
 
 is_deeply(
@@ -324,9 +324,9 @@ is_deeply(
         Class::MOP::Class
         Class::MOP::Module
         Class::MOP::Package
-        Class::MOP::HasMethods
+        Class::MOP::Mixin::HasMethods
         Class::MOP::Object
-        Class::MOP::HasAttributes
+        Class::MOP::Mixin::HasAttributes
         Class::MOP::Object
     / ],
     '... Class::MOP::Class->class_precedence_list == [ Class::MOP::Class Class::MOP::Module Class::MOP::Package ]');
index 36099e0..35f5168 100644 (file)
@@ -89,7 +89,7 @@ mop_update_method_map(pTHX_ SV *const self, SV *const class_name, HV *const stas
     }
 }
 
-MODULE = Class::MOP::HasMethods   PACKAGE = Class::MOP::HasMethods
+MODULE = Class::MOP::Mixin::HasMethods   PACKAGE = Class::MOP::Mixin::HasMethods
 
 PROTOTYPES: DISABLE
 
index 48c695f..a0a29fd 100644 (file)
--- a/xs/MOP.xs
+++ b/xs/MOP.xs
@@ -11,7 +11,7 @@ find_method (const char *key, STRLEN keylen, SV *val, void *ud)
     return FALSE;
 }
 
-EXTERN_C XS(boot_Class__MOP__HasMethods);
+EXTERN_C XS(boot_Class__MOP__Mixin__HasMethods);
 EXTERN_C XS(boot_Class__MOP__Package);
 EXTERN_C XS(boot_Class__MOP__Attribute);
 EXTERN_C XS(boot_Class__MOP__Method);
@@ -23,7 +23,7 @@ PROTOTYPES: DISABLE
 BOOT:
     mop_prehash_keys();
 
-    MOP_CALL_BOOT (boot_Class__MOP__HasMethods);
+    MOP_CALL_BOOT (boot_Class__MOP__Mixin__HasMethods);
     MOP_CALL_BOOT (boot_Class__MOP__Package);
     MOP_CALL_BOOT (boot_Class__MOP__Attribute);
     MOP_CALL_BOOT (boot_Class__MOP__Method);