This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Inline tryAMAGICunDEREF_var() into its callers and eliminate it.
authorNicholas Clark <nick@ccl4.org>
Wed, 3 Nov 2010 16:54:05 +0000 (16:54 +0000)
committerNicholas Clark <nick@ccl4.org>
Wed, 3 Nov 2010 16:54:05 +0000 (16:54 +0000)
Nothing outside the core was using this macro.

pp.c
pp.h
pp_hot.c
sv.c

diff --git a/pp.c b/pp.c
index 1386f38..757048c 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -142,7 +142,8 @@ PP(pp_rv2gv)
     if (!isGV(sv) || SvFAKE(sv)) SvGETMAGIC(sv);
     if (SvROK(sv)) {
       wasref:
-       tryAMAGICunDEREF(to_gv);
+       sv = amagic_deref_call(sv, to_gv_amg);
+       SPAGAIN;
 
        sv = SvRV(sv);
        if (SvTYPE(sv) == SVt_PVIO) {
@@ -283,7 +284,8 @@ PP(pp_rv2sv)
     if (!(PL_op->op_private & OPpDEREFed))
        SvGETMAGIC(sv);
     if (SvROK(sv)) {
-       tryAMAGICunDEREF(to_sv);
+       sv = amagic_deref_call(sv, to_sv_amg);
+       SPAGAIN;
 
        sv = SvRV(sv);
        switch (SvTYPE(sv)) {
diff --git a/pp.h b/pp.h
index 3f2aea9..2122ba7 100644 (file)
--- a/pp.h
+++ b/pp.h
@@ -449,14 +449,14 @@ Does not use C<TARG>.  See also C<XPUSHu>, C<mPUSHu> and C<PUSHu>.
        }                                                       \
     } STMT_END
 
-#define tryAMAGICunDEREF_var(meth_enum)                                        \
+/* This is no longer used anywhere in the core. You might wish to consider
+   calling amagic_deref_call() directly, as it has a cleaner interface.  */
+#define tryAMAGICunDEREF(meth)                                         \
     STMT_START {                                                       \
-       sv = amagic_deref_call(aTHX_ *sp, meth_enum);                   \
+       sv = amagic_deref_call(aTHX_ *sp, CAT2(meth,_amg));             \
        SPAGAIN;                                                        \
     } STMT_END
 
-#define tryAMAGICunDEREF(meth) tryAMAGICunDEREF_var(CAT2(meth,_amg))
-
 
 #define opASSIGN (PL_op->op_flags & OPf_STACKED)
 #define SETsv(sv)      STMT_START {                                    \
index a3fea5c..9beb604 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -827,7 +827,8 @@ PP(pp_rv2av)
     if (!(PL_op->op_private & OPpDEREFed))
        SvGETMAGIC(sv);
     if (SvROK(sv)) {
-       tryAMAGICunDEREF_var(is_pp_rv2av ? to_av_amg : to_hv_amg);
+       sv = amagic_deref_call(sv, is_pp_rv2av ? to_av_amg : to_hv_amg);
+       SPAGAIN;
 
        sv = SvRV(sv);
        if (SvTYPE(sv) != type)
@@ -2770,8 +2771,8 @@ PP(pp_entersub)
        }
        SvGETMAGIC(sv);
        if (SvROK(sv)) {
-           SV * const * sp = &sv;      /* Used in tryAMAGICunDEREF macro. */
-           tryAMAGICunDEREF(to_cv);
+           sv = amagic_deref_call(sv, to_cv_amg);
+           /* Don't SPAGAIN here.  */
        }
        else {
            const char *sym;
diff --git a/sv.c b/sv.c
index aefcde8..f3010af 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -8729,9 +8729,10 @@ Perl_sv_2cv(pTHX_ SV *sv, HV **const st, GV **const gvp, const I32 lref)
 
     default:
        if (SvROK(sv)) {
-           SV * const *sp = &sv;       /* Used in tryAMAGICunDEREF macro. */
            SvGETMAGIC(sv);
-           tryAMAGICunDEREF(to_cv);
+           sv = amagic_deref_call(sv, to_cv_amg);
+           /* At this point I'd like to do SPAGAIN, but really I need to
+              force it upon my callers. Hmmm. This is a mess... */
 
            sv = SvRV(sv);
            if (SvTYPE(sv) == SVt_PVCV) {