Revision history for Perl extension Class-MOP.
+0.59
+
+ * Class::MOP::Class
+ - now stores the instance of the instance
+ metaclass to avoid needless recomputation
+
+ * Class::MOP
+ Class::MOP::Class
+ Class::MOP::Method
+ Class::MOP::Method::Wrapped
+ Class::MOP::Attribute
+ - switched usage of reftype to ref because
+ it is much faster
+
0.58 Thurs. May 29, 2008
(late night release engineering)--
-Class::MOP version 0.58
+Class::MOP version 0.59
===========================
See the individual module documentation for more information
use Class::MOP::Immutable;
BEGIN {
- our $VERSION = '0.58';
+ our $VERSION = '0.59';
our $AUTHORITY = 'cpan:STEVAN';
*IS_RUNNING_ON_5_10 = ($] < 5.009_005)
my $code = shift;
my %options = @_;
- ('CODE' eq (Scalar::Util::reftype($code) || ''))
+ ('CODE' eq ref($code))
|| confess "You must supply a CODE reference to bless, not (" . ($code || 'undef') . ")";
($options{package_name} && $options{name})
use Class::MOP::Method::Accessor;
use Carp 'confess';
-use Scalar::Util 'blessed', 'reftype', 'weaken';
+use Scalar::Util 'blessed', 'weaken';
-our $VERSION = '0.25';
+our $VERSION = '0.26';
our $AUTHORITY = 'cpan:STEVAN';
use base 'Class::MOP::Object';
}
sub is_default_a_coderef {
- ('CODE' eq (reftype($_[0]->{'$!default'} || $_[0]->{default}) || ''))
+ ('CODE' eq ref($_[0]->{'$!default'} || $_[0]->{default}))
}
sub default {
sub process_accessors {
my ($self, $type, $accessor, $generate_as_inline_methods) = @_;
- if (reftype($accessor)) {
- (reftype($accessor) eq 'HASH')
+ if (ref($accessor)) {
+ (ref($accessor) eq 'HASH')
|| confess "bad accessor/reader/writer/predicate/clearer format, must be a HASH ref";
my ($name, $method) = %{$accessor};
$method = $self->accessor_metaclass->wrap(
{
my $_remove_accessor = sub {
my ($accessor, $class) = @_;
- if (reftype($accessor) && reftype($accessor) eq 'HASH') {
+ if (ref($accessor) && ref($accessor) eq 'HASH') {
($accessor) = keys %{$accessor};
}
my $method = $class->get_method($accessor);
use Class::MOP::Method::Wrapped;
use Carp 'confess';
-use Scalar::Util 'blessed', 'reftype', 'weaken';
+use Scalar::Util 'blessed', 'weaken';
-our $VERSION = '0.32';
+our $VERSION = '0.33';
our $AUTHORITY = 'cpan:STEVAN';
use base 'Class::MOP::Module';
# we can tell the first time the
# methods are fetched
# - SL
- '$!_package_cache_flag' => undef,
+ '$!_package_cache_flag' => undef,
+ '$!_meta_instance' => undef,
} => $class;
}
else {
# NOTE:
# this will only work for a HASH instance type
if ($class->is_anon_class) {
- (reftype($instance) eq 'HASH')
+ (Scalar::Util::reftype($instance) eq 'HASH')
|| confess "Currently only HASH based instances are supported with instance of anon-classes";
# NOTE:
# At some point we should make this official
return $instance;
}
+
sub get_meta_instance {
- my $class = shift;
- return $class->instance_metaclass->new(
- $class,
- $class->compute_all_applicable_attributes()
+ my $self = shift;
+ # NOTE:
+ # just about any fiddling with @ISA or
+ # any fiddling with attributes will
+ # also fiddle with the symbol table
+ # and therefore invalidate the package
+ # cache, in which case we should blow
+ # away the meta-instance cache. Of course
+ # this will invalidate it more often then
+ # is probably needed, but better safe
+ # then sorry.
+ # - SL
+ $self->{'$!_meta_instance'} = undef
+ if defined $self->{'$!_package_cache_flag'} &&
+ $self->{'$!_package_cache_flag'} == Class::MOP::check_package_cache_flag($self->name);
+ $self->{'$!_meta_instance'} ||= $self->instance_metaclass->new(
+ $self,
+ $self->compute_all_applicable_attributes()
);
}
}
else {
$body = $method;
- ('CODE' eq (reftype($body) || ''))
+ ('CODE' eq ref($body))
|| confess "Your code block must be a CODE reference";
$method = $self->method_metaclass->wrap(
$body => (
|| confess "You must define a method name";
my $body = (blessed($method) ? $method->body : $method);
- ('CODE' eq (reftype($body) || ''))
+ ('CODE' eq ref($body))
|| confess "Your code block must be a CODE reference";
$self->add_package_symbol("&${method_name}" => $body);
use warnings;
use Carp 'confess';
-use Scalar::Util 'reftype', 'blessed';
+use Scalar::Util 'blessed';
-our $VERSION = '0.08';
+our $VERSION = '0.09';
our $AUTHORITY = 'cpan:STEVAN';
use base 'Class::MOP::Object';
sub wrap {
my ( $class, $code, %params ) = @_;
- ('CODE' eq (reftype($code) || ''))
+ ('CODE' eq ref($code))
|| confess "You must supply a CODE reference to bless, not (" . ($code || 'undef') . ")";
($params{package_name} && $params{name})
use warnings;
use Carp 'confess';
-use Scalar::Util 'reftype', 'blessed';
+use Scalar::Util 'blessed';
-our $VERSION = '0.03';
+our $VERSION = '0.04';
our $AUTHORITY = 'cpan:STEVAN';
use base 'Class::MOP::Method';
use strict;
use warnings;
-use Test::More tests => 201;
+use Test::More tests => 200;
use Test::Exception;
BEGIN {
foreach my $non_method_name (qw(
confess
- blessed reftype
+ blessed
subname
svref_2object
)) {