From: Stevan Little Date: Sun, 24 Sep 2006 01:16:48 +0000 (+0000) Subject: foo X-Git-Tag: 0_35~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6d2118a4bab44f7bfbd3b6c4534c77ed3a4b9f02;p=gitmo%2FClass-MOP.git foo --- diff --git a/Changes b/Changes index 405872f..1c91d62 100644 --- a/Changes +++ b/Changes @@ -3,16 +3,17 @@ Revision history for Perl extension Class-MOP. 0.35 * Class::MOP - - non-generated accessors are no longer - copied, but instead are aliased from - the originals + - accessors are no longer generated, instead + they are aliased from the originals + - this means that the bootstrap will no longer + re-compiles accessors so as to keep the MOP + compile-time fast + - fixed tests to reflect - added Class::MOP::Method (and its subclasses) to the bootstrap - adjusted tests for this - added the Class::MOP::Instance attributes to the bootstrap - - bootstrap no longer re-compiles accessors - so as to keep the MOP compile-time fast * Class::MOP::Method *** API CHANGE *** diff --git a/lib/Class/MOP.pm b/lib/Class/MOP.pm index ce73d0c..9e5a23b 100644 --- a/lib/Class/MOP.pm +++ b/lib/Class/MOP.pm @@ -189,7 +189,12 @@ Class::MOP::Class->meta->add_attribute( Class::MOP::Class->meta->add_attribute( Class::MOP::Attribute->new('$:attribute_metaclass' => ( - reader => 'attribute_metaclass', + reader => { + # NOTE: + # we just alias the original method + # rather than re-produce it here + 'attribute_metaclass' => \&Class::MOP::Class::attribute_metaclass + }, init_arg => ':attribute_metaclass', default => 'Class::MOP::Attribute', )) @@ -197,7 +202,12 @@ Class::MOP::Class->meta->add_attribute( Class::MOP::Class->meta->add_attribute( Class::MOP::Attribute->new('$:method_metaclass' => ( - reader => 'method_metaclass', + reader => { + # NOTE: + # we just alias the original method + # rather than re-produce it here + 'method_metaclass' => \&Class::MOP::Class::method_metaclass + }, init_arg => ':method_metaclass', default => 'Class::MOP::Method', )) @@ -258,50 +268,50 @@ Class::MOP::Attribute->meta->add_attribute( Class::MOP::Attribute->meta->add_attribute( Class::MOP::Attribute->new('accessor' => ( - reader => 'accessor', - predicate => 'has_accessor', + reader => { 'accessor' => \&Class::MOP::Attribute::accessor }, + predicate => { 'has_accessor' => \&Class::MOP::Attribute::has_accessor }, )) ); Class::MOP::Attribute->meta->add_attribute( Class::MOP::Attribute->new('reader' => ( - reader => 'reader', - predicate => 'has_reader', + reader => { 'reader' => \&Class::MOP::Attribute::reader }, + predicate => { 'has_reader' => \&Class::MOP::Attribute::has_reader }, )) ); Class::MOP::Attribute->meta->add_attribute( Class::MOP::Attribute->new('writer' => ( - reader => 'writer', - predicate => 'has_writer', + reader => { 'writer' => \&Class::MOP::Attribute::writer }, + predicate => { 'has_writer' => \&Class::MOP::Attribute::has_writer }, )) ); Class::MOP::Attribute->meta->add_attribute( Class::MOP::Attribute->new('predicate' => ( - reader => 'predicate', - predicate => 'has_predicate', + reader => { 'predicate' => \&Class::MOP::Attribute::predicate }, + predicate => { 'has_predicate' => \&Class::MOP::Attribute::has_predicate }, )) ); Class::MOP::Attribute->meta->add_attribute( Class::MOP::Attribute->new('clearer' => ( - reader => 'clearer', - predicate => 'has_clearer', + reader => { 'clearer' => \&Class::MOP::Attribute::clearer }, + predicate => { 'has_clearer' => \&Class::MOP::Attribute::has_clearer }, )) ); Class::MOP::Attribute->meta->add_attribute( Class::MOP::Attribute->new('init_arg' => ( - reader => 'init_arg', - predicate => 'has_init_arg', + reader => { 'init_arg' => \&Class::MOP::Attribute::init_arg }, + predicate => { 'has_init_arg' => \&Class::MOP::Attribute::has_init_arg }, )) ); Class::MOP::Attribute->meta->add_attribute( Class::MOP::Attribute->new('default' => ( # default has a custom 'reader' method ... - predicate => 'has_default', + predicate => { 'has_default' => \&Class::MOP::Attribute::has_default }, )) ); @@ -340,7 +350,7 @@ Class::MOP::Attribute->meta->add_method('clone' => sub { Class::MOP::Method->meta->add_attribute( Class::MOP::Attribute->new('body' => ( - reader => 'body' + reader => { 'body' => \&Class::MOP::Method::body }, )) ); diff --git a/t/010_self_introspection.t b/t/010_self_introspection.t index 447898d..7f42a40 100644 --- a/t/010_self_introspection.t +++ b/t/010_self_introspection.t @@ -214,8 +214,8 @@ is($class_mop_package_meta->get_attribute('$:package')->init_arg, ':package', '. # ... class ok($class_mop_class_meta->get_attribute('%:attributes')->has_reader, '... Class::MOP::Class %:attributes has a reader'); -is(ref($class_mop_class_meta->get_attribute('%:attributes')->reader), - 'HASH', +is_deeply($class_mop_class_meta->get_attribute('%:attributes')->reader, + { 'get_attribute_map' => \&Class::MOP::Class::get_attribute_map }, '... Class::MOP::Class %:attributes\'s a reader is &get_attribute_map'); ok($class_mop_class_meta->get_attribute('%:attributes')->has_init_arg, '... Class::MOP::Class %:attributes has a init_arg'); @@ -229,8 +229,8 @@ is_deeply($class_mop_class_meta->get_attribute('%:attributes')->default('Foo'), '... Class::MOP::Class %:attributes\'s a default of {}'); ok($class_mop_class_meta->get_attribute('$:attribute_metaclass')->has_reader, '... Class::MOP::Class $:attribute_metaclass has a reader'); -is($class_mop_class_meta->get_attribute('$:attribute_metaclass')->reader, - 'attribute_metaclass', +is_deeply($class_mop_class_meta->get_attribute('$:attribute_metaclass')->reader, + { 'attribute_metaclass' => \&Class::MOP::Class::attribute_metaclass }, '... Class::MOP::Class $:attribute_metaclass\'s a reader is &attribute_metaclass'); ok($class_mop_class_meta->get_attribute('$:attribute_metaclass')->has_init_arg, '... Class::MOP::Class $:attribute_metaclass has a init_arg'); @@ -244,8 +244,8 @@ is($class_mop_class_meta->get_attribute('$:attribute_metaclass')->default, '... Class::MOP::Class $:attribute_metaclass\'s a default is Class::MOP:::Attribute'); ok($class_mop_class_meta->get_attribute('$:method_metaclass')->has_reader, '... Class::MOP::Class $:method_metaclass has a reader'); -is($class_mop_class_meta->get_attribute('$:method_metaclass')->reader, - 'method_metaclass', +is_deeply($class_mop_class_meta->get_attribute('$:method_metaclass')->reader, + { 'method_metaclass' => \&Class::MOP::Class::method_metaclass }, '... Class::MOP::Class $:method_metaclass\'s a reader is &method_metaclass'); ok($class_mop_class_meta->get_attribute('$:method_metaclass')->has_init_arg, '... Class::MOP::Class $:method_metaclass has a init_arg');