use MRO::Compat;
use Carp 'confess';
-use Scalar::Util 'weaken', 'reftype', 'blessed';
+use Scalar::Util 'weaken', 'isweak', 'reftype', 'blessed';
use Data::OptList;
use Try::Tiny;
*check_package_cache_flag = \&mro::get_pkg_gen;
}
-our $VERSION = '1.01';
+our $VERSION = '1.11';
our $XS_VERSION = $VERSION;
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
require XSLoader;
XSLoader::load( __PACKAGE__, $XS_VERSION );
-
{
# Metaclasses are singletons, so we cache them here.
# there is no need to worry about destruction though
sub get_metaclass_by_name { $METAS{$_[0]} }
sub store_metaclass_by_name { $METAS{$_[0]} = $_[1] }
sub weaken_metaclass { weaken($METAS{$_[0]}) }
+ sub metaclass_is_weak { isweak($METAS{$_[0]}) }
sub does_metaclass_exist { exists $METAS{$_[0]} && defined $METAS{$_[0]} }
sub remove_metaclass_by_name { delete $METAS{$_[0]}; return }
# NOTE:
# we just alias the original method
# rather than re-produce it here
- '_full_method_map' => \&Class::MOP::Mixin::HasMethods::_full_method_map
+ '_method_map' => \&Class::MOP::Mixin::HasMethods::_method_map
},
default => sub { {} }
))
))
);
-Class::MOP::Method->meta->add_method('clone' => sub {
- my $self = shift;
- my $clone = $self->meta->clone_object($self, @_);
- $clone->_set_original_method($self);
- return $clone;
-});
-
## --------------------------------------------------------
## Class::MOP::Method::Wrapped
),
);
+## --------------------------------------------------------
+## Class::MOP::Object
+
+# need to replace the meta method there with a real meta method object
+Class::MOP::Object->meta->_add_meta_method('meta');
+
+## --------------------------------------------------------
+## Class::MOP::Mixin
+
+# need to replace the meta method there with a real meta method object
+Class::MOP::Mixin->meta->_add_meta_method('meta');
+
require Class::MOP::Deprecated unless our $no_deprecated;
# we need the meta instance of the meta instance to be created now, in order
Class::MOP::Method::Accessor
Class::MOP::Method::Constructor
Class::MOP::Method::Wrapped
+
+ Class::MOP::Method::Meta
/;
$_->meta->make_immutable(
| A |<----| B |
+---------+ +---------+
+In actuality, I<all> of a class's metaclasses must be compatible,
+not just the class metaclass. That includes the instance, attribute,
+and method metaclasses, as well as the constructor and destructor
+classes.
+
+C<Class::MOP> will attempt to fix some simple types of
+incompatibilities. If all the metaclasses for the parent class are
+I<subclasses> of the child's metaclasses then we can simply replace
+the child's metaclasses with the parent's. In addition, if the child
+is missing a metaclass that the parent has, we can also just make the
+child use the parent's metaclass.
+
As I said this is a highly esoteric topic and one you will only run
into if you do a lot of subclassing of L<Class::MOP::Class>. If you
are interested in why this is an issue see the paper I<Uniform and
function will weaken the reference to the metaclass stored
in C<$name>.
+=item B<Class::MOP::metaclass_is_weak($name)>
+
+Returns true if the metaclass for C<$name> has been weakened
+(via C<weaken_metaclass>).
+
=item B<Class::MOP::does_metaclass_exist($name)>
This will return true of there exists a metaclass stored in the
=item L<http://svn.openfoundry.org/pugs/misc/Perl-MetaModel/>
-=item L<http://svn.openfoundry.org/pugs/perl5/Perl6-ObjectSpace>
+=item L<http://github.com/perl6/p5-modules/tree/master/Perl6-ObjectSpace/>
=back