This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Replace usage of GvSTASH for storing the stash of C<our> with
authorNicholas Clark <nick@ccl4.org>
Fri, 24 Feb 2006 11:52:28 +0000 (11:52 +0000)
committerNicholas Clark <nick@ccl4.org>
Fri, 24 Feb 2006 11:52:28 +0000 (11:52 +0000)
OURSTASH. Set the stash with OURSTASH_SET.

p4raw-id: //depot/perl@27306

pad.c
pad.h
sv.h

diff --git a/pad.c b/pad.c
index 880902d..97e2615 100644 (file)
--- a/pad.c
+++ b/pad.c
@@ -321,7 +321,7 @@ offset.
 If C<typestash> is valid, the name is for a typed lexical; set the
 name's stash to that value.
 If C<ourstash> is valid, it's an our lexical, set the name's
-GvSTASH to that value
+OURSTASH to that value
 
 If fake, it means we're cloning an existing entry
 
@@ -347,7 +347,7 @@ Perl_pad_add_name(pTHX_ const char *name, HV* typestash, HV* ourstash, bool fake
     }
     if (ourstash) {
        SvPAD_OUR_on(namesv);
-       GvSTASH(namesv) = ourstash;
+       OURSTASH_set(namesv, ourstash);
        Perl_sv_add_backref(aTHX_ (SV*)ourstash, namesv);
     }
 
@@ -549,7 +549,7 @@ Perl_pad_check_dup(pTHX_ const char *name, bool is_our, const HV *ourstash)
                && sv != &PL_sv_undef
                && !SvFAKE(sv)
                && (SvIVX(sv) == PAD_MAX || SvIVX(sv) == 0)
-               && ((SvPAD_OUR(sv)) && GvSTASH(sv) == ourstash)
+               && OURSTASH(sv) == ourstash
                && strEQ(name, SvPVX_const(sv)))
            {
                Perl_warner(aTHX_ packWARN(WARN_MISC),
@@ -838,8 +838,7 @@ S_pad_findlex(pTHX_ const char *name, const CV* cv, U32 seq, int warn,
            SvPVX_const(*out_name_sv),
            SvPAD_TYPED(*out_name_sv)
                    ? SvSTASH(*out_name_sv) : NULL,
-           SvPAD_OUR(*out_name_sv)
-                   ? GvSTASH(*out_name_sv) : NULL,
+           OURSTASH(*out_name_sv),
            1  /* fake */
        );
 
diff --git a/pad.h b/pad.h
index b234e63..acfb58e 100644 (file)
--- a/pad.h
+++ b/pad.h
@@ -226,7 +226,7 @@ ling pad (lvalue) to C<gen>.  Note that C<SvCUR_set> is hijacked for this purpos
 #define PAD_COMPNAME_TYPE(po) pad_compname_type(po)
 
 #define PAD_COMPNAME_OURSTASH(po) \
-    (GvSTASH(*av_fetch(PL_comppad_name, (po), FALSE)))
+    (OURSTASH(*av_fetch(PL_comppad_name, (po), FALSE)))
 
 #define PAD_COMPNAME_GEN(po) SvCUR(AvARRAY(PL_comppad_name)[po])
 
diff --git a/sv.h b/sv.h
index 5474074..9e5ae2b 100644 (file)
--- a/sv.h
+++ b/sv.h
@@ -937,6 +937,13 @@ in gv.h: */
        ((SvFLAGS(sv) & (SVpad_NAME|SVpad_OUR)) == (SVpad_NAME|SVpad_OUR))
 #define SvPAD_OUR_on(sv)       (SvFLAGS(sv) |= SVpad_NAME|SVpad_OUR)
 
+#define OURSTASH(sv)   (SvPAD_OUR(sv) ? GvSTASH(sv) : NULL)
+#define OURSTASH_set(sv, st)                   \
+        STMT_START {                           \
+           assert(SvTYPE(sv) == SVt_PVGV);     \
+           GvSTASH(sv) = st;                   \
+       } STMT_END
+
 #ifdef PERL_DEBUG_COW
 #define SvRV(sv) (0 + (sv)->sv_u.svu_rv)
 #else