This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add isGV_or_RVCV macro
authorFather Chrysostomos <sprout@cpan.org>
Sun, 3 Sep 2017 18:12:11 +0000 (11:12 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 8 Oct 2017 20:02:03 +0000 (13:02 -0700)
This will be useful for a few code paths that need to treat a sub
ref in a stash the same way as a GV.

sv.h

diff --git a/sv.h b/sv.h
index a31bd73..0fdb8c8 100644 (file)
--- a/sv.h
+++ b/sv.h
@@ -2146,6 +2146,10 @@ See also C<L</PL_sv_yes>> and C<L</PL_sv_no>>.
        assert (!SvIOKp(sv));                                          \
        (SvFLAGS(sv) &= ~SVpgv_GP);                                    \
     } STMT_END
+#ifdef PERL_CORE
+# define isGV_or_RVCV(kadawp) \
+    (isGV(kadawp) || (SvROK(kadawp) && SvTYPE(SvRV(kadawp)) == SVt_PVCV))
+#endif
 #define isREGEXP(sv) \
     (SvTYPE(sv) == SVt_REGEXP                                \
      || (SvFLAGS(sv) & (SVTYPEMASK|SVpgv_GP|SVf_FAKE))        \