Support the global destruction flag in DEMOLISH()
gfx [Wed, 10 Feb 2010 08:13:50 +0000 (17:13 +0900)]
lib/Mouse/Meta/Method/Destructor.pm
lib/Mouse/PurePerl.pm
xs-src/Mouse.xs

index 1d08ac0..d083a6b 100644 (file)
@@ -13,7 +13,8 @@ sub _generate_destructor{
     my $demolishall = '';
     for my $class ($metaclass->linearized_isa) {
         if (Mouse::Util::get_code_ref($class, 'DEMOLISH')) {
-            $demolishall .= "${class}::DEMOLISH(\$self);\n";
+            $demolishall .= sprintf "%s::DEMOLISH(\$self, \$Mouse::Util::in_global_destruction);\n",
+                $class,
         }
     }
 
index f6c5e5b..802289d 100644 (file)
@@ -627,7 +627,7 @@ sub DESTROY {
                 my $demolish = Mouse::Util::get_code_ref($class, 'DEMOLISH')
                     || next;
 
-                $self->$demolish();
+                $self->$demolish($Mouse::Util::in_global_destruction);
             }
         };
         $@;
index 34ba351..86b7896 100644 (file)
@@ -650,6 +650,7 @@ CODE:
 
             PUSHMARK(SP);
             XPUSHs(object);
+            XPUSHs(boolSV(PL_dirty));
             PUTBACK;
 
             call_sv(AvARRAY(demolishall)[i], G_VOID | G_EVAL);