]> git.vpit.fr Git - perl/modules/Variable-Magic.git/commitdiff
Fix the B stashes cache cloning, and really use it for blessing op objects
authorVincent Pit <vince@profvince.com>
Tue, 24 Feb 2009 13:33:19 +0000 (14:33 +0100)
committerVincent Pit <vince@profvince.com>
Tue, 24 Feb 2009 13:33:19 +0000 (14:33 +0100)
Magic.xs
t/40-threads.t
t/41-clone.t

index 25d1d1c05dca695df4b81a2ed1d2fa7e9fb03373..9772cd7fbf60ff9b6bd5da55f183a82540984fe4 100644 (file)
--- a/Magic.xs
+++ b/Magic.xs
@@ -646,7 +646,7 @@ STATIC SV *vmg_op_info(pTHX_ unsigned int opinfo) {
   case VMG_OP_INFO_OBJECT: {
    dMY_CXT;
    return sv_bless(sv_2mortal(newRV_noinc(newSViv(PTR2IV(PL_op)))),
-                           gv_stashpv(vmg_opclassnames[vmg_opclass(PL_op)], 1));
+                   MY_CXT.b__op_stashes[vmg_opclass(PL_op)]);
   }
   default:
    break;
@@ -1247,7 +1247,7 @@ CODE:
   MY_CXT.wizards     = hv;
   for (c = 0; c < OPc_MAX; ++c) {
    MY_CXT.b__op_stashes[c] = (had_b__op_stash & (((U32) 1) << c))
-                              ? gv_stashpv("B::OP", 1) : NULL;
+                              ? gv_stashpv(vmg_opclassnames[c], 1) : NULL;
   }
  }
 
index 6fb1d36a6a743893ce766e2eef839b6ed4b54b21..0b16c6aeb44acc8e18a4ae81ef2b055acb7d57dd 100644 (file)
@@ -41,9 +41,14 @@ sub try {
          sig     => $sig,
          get     => sub { ++$c; 0 },
          set     => sub {
-                     my $name = $_[-1];
-                     $name = $name->name if $op_info == VMG_OP_INFO_OBJECT;
-                     is $name, 'sassign', "opname for op_info $op_info in thread $tid is correct";
+                     my $op = $_[-1];
+                     if ($op_info == VMG_OP_INFO_OBJECT) {
+                      is_deeply { class => ref($op),   name => $op->name },
+                                { class => 'B::BINOP', name => 'sassign' },
+                                "op object in thread $tid is correct";
+                     } else {
+                      is $op, 'sassign', "op name in thread $tid is correct";
+                     }
                      0
                     },
          free    => sub { ++$destroyed; 0 },
index 90f15e0fc08fceb517af25711869b441f1862524..e410f88888396122ed5df51804b03f60ea317bfc 100644 (file)
@@ -40,10 +40,15 @@ sub spawn_wiz {
   wizard data    => sub { $_[1] + threads->tid() },
          get     => sub { ++$c; 0 },
          set     => sub {
-                     my $name = $_[-1];
-                     $name = $name->name if $op_info == VMG_OP_INFO_OBJECT;
+                     my $op = $_[-1];
                      my $tid = threads->tid();
-                     is $name, 'sassign', "opname for op_info $op_info in thread $tid is correct";
+                     if ($op_info == VMG_OP_INFO_OBJECT) {
+                      is_deeply { class => ref($op),   name => $op->name },
+                                { class => 'B::BINOP', name => 'sassign' },
+                                "op object in thread $tid is correct";
+                     } else {
+                      is $op, 'sassign', "op name in thread $tid is correct";
+                     }
                      0
                     },
          free    => sub { ++$destroyed; 0 },