return $self->get_meta_instance->inline_rebless_instance_structure(@_);
}
+sub _inline_get_mop_slot {
+ my $self = shift;
+
+ return $self->get_meta_instance->_inline_get_mop_slot(@_);
+}
+
+sub _inline_set_mop_slot {
+ my $self = shift;
+
+ return $self->get_meta_instance->_inline_set_mop_slot(@_);
+}
+
+sub _inline_clear_mop_slot {
+ my $self = shift;
+
+ return $self->get_meta_instance->_inline_clear_mop_slot(@_);
+}
+
sub clone_object {
my $class = shift;
my $instance = shift;
"bless $instance => $class_variable";
}
+sub _inline_get_mop_slot {
+ my ($self, $instance) = @_;
+ $self->inline_get_slot_value($instance, $RESERVED_MOP_SLOT);
+}
+
+sub _inline_set_mop_slot {
+ my ($self, $instance, $value) = @_;
+ $self->inline_set_slot_value($instance, $RESERVED_MOP_SLOT, $value);
+}
+
+sub _inline_clear_mop_slot {
+ my ($self, $instance) = @_;
+ $self->inline_deinitialize_slot($instance, $RESERVED_MOP_SLOT);
+}
+
1;
__END__
$source .= ";\n" . (join ";\n" => map {
$self->_generate_slot_initializer($_, $idx++)
} @{ $self->_attributes });
+ if (Class::MOP::metaclass_is_weak($self->associated_metaclass->name)) {
+ $source .= ";\n" . $self->associated_metaclass->_inline_set_mop_slot('$instance', 'Class::MOP::class_of($class)');
+ }
$source .= ";\n" . 'return $instance';
$source .= ";\n" . '}';
warn $source if $self->options->{debug};
instance_metaclass get_meta_instance
inline_create_instance
inline_rebless_instance
+ _inline_get_mop_slot _inline_set_mop_slot _inline_clear_mop_slot
create_meta_instance _create_meta_instance
new_object clone_object
construct_instance _construct_instance
}
{
+ my $meta = Class::MOP::Class->create_anon_class;
+ $meta->make_immutable;
+ $instance = $meta->name->new;
+}
+{
+ my $meta = Class::MOP::class_of($instance);
+ Scalar::Util::weaken($meta);
+ ok($meta, "anon class is kept alive by existing instances (immutable)");
+
+ undef $instance;
+ ok(!$meta, "anon class is collected once instances go away (immutable)");
+}
+
+{
$instance = Class::MOP::Class->create('Foo')->new_object;
my $meta = Class::MOP::Class->create_anon_class(superclasses => ['Foo']);
$meta->rebless_instance($instance);