From: Stevan Little Date: Tue, 11 Mar 2008 16:14:29 +0000 (+0000) Subject: Class::MOP fixes X-Git-Tag: 0_64~83 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d7b2249e7fbce92cc716fea172cf338727478b78;p=gitmo%2FClass-MOP.git Class::MOP fixes --- diff --git a/Changes b/Changes index fba4db9..d16baca 100644 --- a/Changes +++ b/Changes @@ -10,11 +10,24 @@ Revision history for Perl extension Class-MOP. * Class::MOP::Class - make_{immutable,mutable} now return 1 (cause Sartak asked) + - improved error handling in ->create method * Class::MOP::Object - localizing the Data::Dumper configurations so that it does not pollute others (RT #33509) + * Class::MOP::Class + Class::MOP::Package + Class::MOP::Module + Class::MOP::Method + Class::MOP::Attribute + - these classes no longer define their own ->meta, + but instead just inherit from Class::MOP::Object + + * Class::MOP::Instance + Class::MOP::Immutable + - these classes now inherit from Class::MOP::Object + * t/ - fixed the filename length on several test files so we install on VMS better diff --git a/lib/Class/MOP/Attribute.pm b/lib/Class/MOP/Attribute.pm index 5d4994c..6042f5c 100644 --- a/lib/Class/MOP/Attribute.pm +++ b/lib/Class/MOP/Attribute.pm @@ -9,16 +9,11 @@ use Class::MOP::Method::Accessor; use Carp 'confess'; use Scalar::Util 'blessed', 'reftype', 'weaken'; -our $VERSION = '0.23'; +our $VERSION = '0.24'; our $AUTHORITY = 'cpan:STEVAN'; use base 'Class::MOP::Object'; -sub meta { - require Class::MOP::Class; - Class::MOP::Class->initialize(blessed($_[0]) || $_[0]); -} - # NOTE: (meta-circularity) # This method will be replaced in the # boostrap section of Class::MOP, by diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index ecce121..d5384f6 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -17,10 +17,6 @@ our $AUTHORITY = 'cpan:STEVAN'; use base 'Class::MOP::Module'; -# Self-introspection - -sub meta { Class::MOP::Class->initialize(blessed($_[0]) || $_[0]) } - # Creation sub initialize { @@ -243,6 +239,18 @@ sub create { "(I found an uneven number of params in \@_)"; my (%options) = @_; + + (ref $options{superclasses} eq 'ARRAY') + || confess "You must pass an ARRAY ref of superclasses" + if exists $options{superclasses}; + + (ref $options{attributes} eq 'ARRAY') + || confess "You must pass an ARRAY ref of attributes" + if exists $options{attributes}; + + (ref $options{methods} eq 'HASH') + || confess "You must pass an HASH ref of methods" + if exists $options{methods}; my $code = "package $package_name;"; $code .= "\$$package_name\:\:VERSION = '" . $options{version} . "';" diff --git a/lib/Class/MOP/Immutable.pm b/lib/Class/MOP/Immutable.pm index 2b4e0d3..3cb1054 100644 --- a/lib/Class/MOP/Immutable.pm +++ b/lib/Class/MOP/Immutable.pm @@ -9,9 +9,11 @@ use Class::MOP::Method::Constructor; use Carp 'confess'; use Scalar::Util 'blessed'; -our $VERSION = '0.04'; +our $VERSION = '0.05'; our $AUTHORITY = 'cpan:STEVAN'; +use base 'Class::MOP::Object'; + sub new { my ($class, $metaclass, $options) = @_; diff --git a/lib/Class/MOP/Instance.pm b/lib/Class/MOP/Instance.pm index 90bddbc..5632772 100644 --- a/lib/Class/MOP/Instance.pm +++ b/lib/Class/MOP/Instance.pm @@ -6,13 +6,10 @@ use warnings; use Scalar::Util 'weaken', 'blessed'; -our $VERSION = '0.04'; +our $VERSION = '0.05'; our $AUTHORITY = 'cpan:STEVAN'; -sub meta { - require Class::MOP::Class; - Class::MOP::Class->initialize(blessed($_[0]) || $_[0]); -} +use base 'Class::MOP::Object'; sub new { my ($class, $meta, @attrs) = @_; diff --git a/lib/Class/MOP/Method.pm b/lib/Class/MOP/Method.pm index 56b3037..b726e7c 100644 --- a/lib/Class/MOP/Method.pm +++ b/lib/Class/MOP/Method.pm @@ -6,9 +6,8 @@ use warnings; use Carp 'confess'; use Scalar::Util 'reftype', 'blessed'; -#use B 'svref_2object'; -our $VERSION = '0.05'; +our $VERSION = '0.06'; our $AUTHORITY = 'cpan:STEVAN'; use base 'Class::MOP::Object'; @@ -18,13 +17,6 @@ use base 'Class::MOP::Object'; # they should act like CODE refs. use overload '&{}' => sub { $_[0]->body }, fallback => 1; -# introspection - -sub meta { - require Class::MOP::Class; - Class::MOP::Class->initialize(blessed($_[0]) || $_[0]); -} - # construction sub wrap { diff --git a/lib/Class/MOP/Module.pm b/lib/Class/MOP/Module.pm index 8c9fccd..bb5859f 100644 --- a/lib/Class/MOP/Module.pm +++ b/lib/Class/MOP/Module.pm @@ -6,18 +6,11 @@ use warnings; use Scalar::Util 'blessed'; -our $VERSION = '0.02'; +our $VERSION = '0.03'; our $AUTHORITY = 'cpan:STEVAN'; use base 'Class::MOP::Package'; -# introspection - -sub meta { - require Class::MOP::Class; - Class::MOP::Class->initialize(blessed($_[0]) || $_[0]); -} - sub version { my $self = shift; ${$self->get_package_symbol('$VERSION')}; diff --git a/lib/Class/MOP/Package.pm b/lib/Class/MOP/Package.pm index 0e09c7f..dd43d6b 100644 --- a/lib/Class/MOP/Package.pm +++ b/lib/Class/MOP/Package.pm @@ -7,18 +7,11 @@ use warnings; use Scalar::Util 'blessed'; use Carp 'confess'; -our $VERSION = '0.07'; +our $VERSION = '0.08'; our $AUTHORITY = 'cpan:STEVAN'; use base 'Class::MOP::Object'; -# introspection - -sub meta { - require Class::MOP::Class; - Class::MOP::Class->initialize(blessed($_[0]) || $_[0]); -} - # creation ... sub initialize { diff --git a/t/010_self_introspection.t b/t/010_self_introspection.t index 2c9e9a7..d321c63 100644 --- a/t/010_self_introspection.t +++ b/t/010_self_introspection.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 205; +use Test::More tests => 199; use Test::Exception; BEGIN { @@ -28,7 +28,6 @@ my $class_mop_module_meta = Class::MOP::Module->meta(); isa_ok($class_mop_module_meta, 'Class::MOP::Module'); my @class_mop_package_methods = qw( - meta initialize @@ -42,13 +41,11 @@ my @class_mop_package_methods = qw( ); my @class_mop_module_methods = qw( - meta version authority identifier ); my @class_mop_class_methods = qw( - meta initialize reinitialize create diff --git a/t/014_attribute_introspection.t b/t/014_attribute_introspection.t index 8c8f878..1ead853 100644 --- a/t/014_attribute_introspection.t +++ b/t/014_attribute_introspection.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 61; +use Test::More tests => 60; use Test::Exception; BEGIN { @@ -20,7 +20,6 @@ BEGIN { isa_ok($meta, 'Class::MOP::Class'); my @methods = qw( - meta new clone initialize_instance_slot