package Mouse::Meta::Method::Accessor;
use Mouse::Util qw(:meta); # enables strict and warnings
+use constant _MOUSE_DEBUG => !!$ENV{MOUSE_DEBUG};
+
sub _inline_slot{
my(undef, $self_var, $attr_name) = @_;
return sprintf '%s->{q{%s}}', $self_var, $attr_name;
$accessor .= "return $slot;\n}\n";
- #print $accessor, "\n";
+ warn $accessor if _MOUSE_DEBUG;
my $code;
my $e = do{
local $@;
package Mouse::Meta::Method::Constructor;
use Mouse::Util qw(:meta); # enables strict and warnings
+use constant _MOUSE_DEBUG => !!$ENV{MOUSE_DEBUG};
+
sub _inline_slot{
my(undef, $self_var, $attr_name) = @_;
return sprintf '%s->{q{%s}}', $self_var, $attr_name;
my $initializer = $metaclass->{_initialize_object} ||= do {
$class->_generate_initialize_object($metaclass);
};
- my $source = sprintf(<<'EOT', __LINE__, __FILE__, $metaclass->name, $buildargs, $buildall);
-#line %d %s
+ my $source = sprintf(<<'EOT', __FILE__, $metaclass->name, $buildargs, $buildall);
+#line 1 "%s"
package %s;
sub {
my $class = shift;
return $instance;
}
EOT
- #warn $source;
+ warn $source if _MOUSE_DEBUG;
my $body;
my $e = do{
local $@;
push @res, q{$_->[0]->($instance, $_->[1]) for @triggers;};
}
- my $source = sprintf <<'EOT', __LINE__, __FILE__, $metaclass->name, join "\n", @res;
-#line %d %s
+ my $source = sprintf <<'EOT', __FILE__, $metaclass->name, join "\n", @res;
+#line 1 "%s"
package %s;
sub {
my($meta, $instance, $args, $is_cloning) = @_;
return $instance;
}
EOT
- warn $source if $ENV{MOUSE_DEBUG};
+ warn $source if _MOUSE_DEBUG;
my $body;
my $e = do {
local $@;
package Mouse::Meta::Method::Destructor;
use Mouse::Util qw(:meta); # enables strict and warnings
+use constant _MOUSE_DEBUG => !!$ENV{MOUSE_DEBUG};
+
sub _generate_destructor{
my (undef, $metaclass) = @_;
my $demolishall = '';
for my $class ($metaclass->linearized_isa) {
if (Mouse::Util::get_code_ref($class, 'DEMOLISH')) {
- $demolishall .= sprintf "%s::DEMOLISH(\$self, \$Mouse::Util::in_global_destruction);\n",
- $class,
+ $demolishall .= ' ' . $class
+ . '::DEMOLISH($self, $Mouse::Util::in_global_destruction);'
+ . "\n",
}
}
- my $name = $metaclass->name;
- my $source = sprintf(<<'EOT', __LINE__, __FILE__, $name, $demolishall);
-#line %d %s
- package %s;
- sub {
- my $self = shift;
- return $self->Mouse::Object::DESTROY()
- if ref($self) ne __PACKAGE__;
+ if($demolishall) {
+ $demolishall = sprintf <<'EOT', $demolishall;
my $e = do{
local $?;
local $@;
eval{
- # demolishall
%s;
};
$@;
};
no warnings 'misc';
die $e if $e; # rethrow
+EOT
+ }
+
+ my $name = $metaclass->name;
+ my $source = sprintf(<<'EOT', __FILE__, $name, $demolishall);
+#line 1 "%s"
+ package %s;
+ sub {
+ my($self) = @_;
+ return $self->Mouse::Object::DESTROY()
+ if ref($self) ne __PACKAGE__;
+ # DEMOLISHALL
+ %s;
+ return;
}
EOT
+ warn $source if _MOUSE_DEBUG;
+
my $code;
my $e = do{
local $@;