This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Change B::COP::stashlen to stashoff
authorFather Chrysostomos <sprout@cpan.org>
Tue, 5 Jun 2012 21:41:25 +0000 (14:41 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Wed, 6 Jun 2012 03:30:08 +0000 (20:30 -0700)
This was brought up in ticket #78742.

The stashlen method has never been in a stable release, and no longer
exists, as of d4d03940c, since it is dependent on a define that
d4d03940c removed.

So this commit removes stashlen from B.xs and adds stashoff in its
place, since this is what B::C needs.

It also adds a few basic tests for the stash and stashpv methods.

ext/B/B.pm
ext/B/B.xs
ext/B/t/b.t

index d7a5cdf..1dcaf99 100644 (file)
@@ -1213,7 +1213,7 @@ Only when perl was compiled with ithreads.
 
 =item stashpv
 
-=item stashlen
+=item stashoff (threaded only)
 
 =item file
 
index 69fc6bb..80bd0f9 100644 (file)
@@ -885,6 +885,7 @@ threadsv_names()
 
 #ifdef USE_ITHREADS
 #define COP_stashpv_ix         char_pp | offsetof(struct cop, cop_stashpv)
+#define COP_stashoff_ix            PADOFFSETp | offsetof(struct cop, cop_stashoff)
 #define COP_file_ix            char_pp | offsetof(struct cop, cop_file)
 #else
 #define COP_stash_ix           SVp | offsetof(struct cop, cop_stash)
@@ -1163,11 +1164,16 @@ BOOT:
 #ifdef USE_ITHREADS
         cv = newXS("B::PMOP::pmoffset", XS_B__OP_next, __FILE__);
         XSANY.any_i32 = PMOP_pmoffset_ix;
-# if PERL_VERSION >= 17 && defined(CopSTASH_len)
+# if PERL_VERSION >= 17
+#  ifdef CopSTASH_len
         cv = newXS("B::COP::stashpv", XS_B__OP_next, __FILE__);
         XSANY.any_i32 = COP_stashpv_ix;
         cv = newXS("B::COP::file", XS_B__OP_next, __FILE__);
         XSANY.any_i32 = COP_file_ix;
+#  else
+        cv = newXS("B::COP::stashoff", XS_B__OP_next, __FILE__);
+        XSANY.any_i32 = COP_stashoff_ix;
+#  endif
 # endif
 #else
         cv = newXS("B::COP::stash", XS_B__OP_next, __FILE__);
@@ -1229,9 +1235,6 @@ pv(o)
            ST(0) = newSVpvn_flags(o->op_pv, strlen(o->op_pv), SVs_TEMP);
 
 #define COP_label(o)   CopLABEL(o)
-#ifdef CopSTASH_len
-#define COP_stashlen(o)        CopSTASH_len(o)
-#endif
 
 MODULE = B     PACKAGE = B::COP                PREFIX = COP_
 
@@ -1255,14 +1258,6 @@ COP_stash(o)
        PUSHs(make_sv_object(aTHX_
                             ix ? (SV *)CopFILEGV(o) : (SV *)CopSTASH(o)));
 
-#ifdef CopSTASH_len
-
-U32
-COP_stashlen(o)
-       B::COP  o
-
-#endif
-
 #endif
 
 #if !defined(USE_ITHREADS) || (PERL_VERSION > 16 && !defined(CopSTASH_len))
index 2534c27..d046885 100644 (file)
@@ -295,4 +295,12 @@ foo
     can_ok $f, 'LINES';
 }
 
+my $sub1 = sub {die};
+my $cop = B::svref_2object($sub1)->ROOT->first->first;
+is $cop->stash->object_2svref, \%main::, 'COP->stash';
+is $cop->stashpv, 'main', 'COP->stashpv';
+if ($Config::Config{useithreads}) {
+    like $cop->stashoff, qr/^[1-9]\d*\z/a, 'COP->stashoff'
+}
+
 done_testing();