X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FClass%2FMOP.pm;h=be88dc7888a7f6332167ba029df0fcd082dee849;hb=8ee74136c5d5c5a6416844e7238898f47b00f553;hp=cfb9503bfaccd58bec1a2a93157b68395ed8577b;hpb=69e3ab0a5a391925610bbb917d81da8d53fd1b91;p=gitmo%2FClass-MOP.git diff --git a/lib/Class/MOP.pm b/lib/Class/MOP.pm index cfb9503..be88dc7 100644 --- a/lib/Class/MOP.pm +++ b/lib/Class/MOP.pm @@ -14,15 +14,20 @@ use Class::MOP::Method; use Class::MOP::Immutable; BEGIN { - our $VERSION = '0.51'; + our $VERSION = '0.53'; our $AUTHORITY = 'cpan:STEVAN'; use XSLoader; XSLoader::load( 'Class::MOP', $VERSION ); unless ($] < 5.009_005) { + require mro; no warnings 'redefine', 'prototype'; *check_package_cache_flag = \&mro::get_pkg_gen; + *IS_RUNNING_ON_5_10 = sub () { 1 }; + } + else { + *IS_RUNNING_ON_5_10 = sub () { 0 }; } } @@ -69,14 +74,14 @@ sub load_class { } sub is_class_loaded { - my $class = shift; - no strict 'refs'; - return 1 if defined ${"${class}::VERSION"} || defined @{"${class}::ISA"}; - foreach (keys %{"${class}::"}) { - next if substr($_, -2, 2) eq '::'; - return 1 if defined &{"${class}::$_"}; - } - return 0; + my $class = shift; + no strict 'refs'; + return 1 if defined ${"${class}::VERSION"} || defined @{"${class}::ISA"}; + foreach (keys %{"${class}::"}) { + next if substr($_, -2, 2) eq '::'; + return 1 if defined &{"${class}::$_"}; + } + return 0; } @@ -130,9 +135,7 @@ Class::MOP::Package->meta->add_attribute( # rather than re-produce it here 'namespace' => \&Class::MOP::Package::namespace }, - # NOTE: - # protect this from silliness - init_arg => '!............( DO NOT DO THIS )............!', + init_arg => undef, default => sub { \undef } )) ); @@ -167,9 +170,7 @@ Class::MOP::Module->meta->add_attribute( # rather than re-produce it here 'version' => \&Class::MOP::Module::version }, - # NOTE: - # protect this from silliness - init_arg => '!............( DO NOT DO THIS )............!', + init_arg => undef, default => sub { \undef } )) ); @@ -188,9 +189,7 @@ Class::MOP::Module->meta->add_attribute( # rather than re-produce it here 'authority' => \&Class::MOP::Module::authority }, - # NOTE: - # protect this from silliness - init_arg => '!............( DO NOT DO THIS )............!', + init_arg => undef, default => sub { \undef } )) ); @@ -235,9 +234,7 @@ Class::MOP::Class->meta->add_attribute( # rather than re-produce it here 'superclasses' => \&Class::MOP::Class::superclasses }, - # NOTE: - # protect this from silliness - init_arg => '!............( DO NOT DO THIS )............!', + init_arg => undef, default => sub { \undef } )) ); @@ -340,6 +337,14 @@ Class::MOP::Attribute->meta->add_attribute( ); Class::MOP::Attribute->meta->add_attribute( + Class::MOP::Attribute->new('$!initializer' => ( + init_arg => 'initializer', + reader => { 'initializer' => \&Class::MOP::Attribute::initializer }, + predicate => { 'has_initializer' => \&Class::MOP::Attribute::has_initializer }, + )) +); + +Class::MOP::Attribute->meta->add_attribute( Class::MOP::Attribute->new('$!writer' => ( init_arg => 'writer', reader => { 'writer' => \&Class::MOP::Attribute::writer }, @@ -724,6 +729,18 @@ See L for more details. =head1 FUNCTIONS +=head2 Constants + +=over 4 + +=item I + +We set this constant depending on what version perl we are on, this +allows us to take advantage of new 5.10 features and stay backwards +compat. + +=back + =head2 Utility functions =over 4