This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Expand AMG_CALLun_var() into all its users, and eliminate it.
authorNicholas Clark <nick@ccl4.org>
Tue, 2 Nov 2010 15:38:31 +0000 (15:38 +0000)
committerNicholas Clark <nick@ccl4.org>
Tue, 2 Nov 2010 15:38:31 +0000 (15:38 +0000)
Aside from the 2 callers where it can be replaced with AMG_CALLun().
AMG_CALLun_var was only used in core.

gv.c
pp.c
pp.h

diff --git a/gv.c b/gv.c
index ab43177..f43706c 100644 (file)
--- a/gv.c
+++ b/gv.c
@@ -1934,7 +1934,8 @@ Perl_try_amagic_un(pTHX_ int method, int flags) {
 
     SvGETMAGIC(arg);
 
-    if (SvAMAGIC(arg) && (tmpsv = AMG_CALLun_var(arg,method))) {
+    if (SvAMAGIC(arg) && (tmpsv = amagic_call(arg, &PL_sv_undef, method,
+                                             AMGf_noright | AMGf_unary))) {
        if (flags & AMGf_set) {
            SETs(tmpsv);
        }
diff --git a/pp.c b/pp.c
index 4e45555..de72d4e 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -4651,8 +4651,8 @@ PP(pp_rkeys)
        SvGETMAGIC(sv);
        if (SvAMAGIC(sv)) {
            /* N.B.: AMG macros return sv if no overloading is found */
-           SV *maybe_hv = AMG_CALLun_var(sv,to_hv_amg);
-           SV *maybe_av = AMG_CALLun_var(sv,to_av_amg);
+           SV *maybe_hv = AMG_CALLun(sv,to_hv);
+           SV *maybe_av = AMG_CALLun(sv,to_av);
            if ( maybe_hv != sv && maybe_av != sv ) {
                Perl_ck_warner(aTHX_ packWARN(WARN_AMBIGUOUS), "%s",
                    Perl_form(aTHX_ "Ambiguous overloaded argument to %s resolved as %%{}",
diff --git a/pp.h b/pp.h
index d6d70d5..8c7967c 100644 (file)
--- a/pp.h
+++ b/pp.h
@@ -425,10 +425,8 @@ Does not use C<TARG>.  See also C<XPUSHu>, C<mPUSHu> and C<PUSHu>.
            return NORMAL; \
     } STMT_END
 
-#define AMG_CALLun_var(sv,meth_enum) amagic_call(sv,&PL_sv_undef,  \
-                                       meth_enum,AMGf_noright | AMGf_unary)
-#define AMG_CALLun(sv,meth) AMG_CALLun_var(sv,CAT2(meth,_amg))
-
+#define AMG_CALLun(sv,meth) \
+    amagic_call(sv,&PL_sv_undef, CAT2(meth,_amg), AMGf_noright | AMGf_unary)
 
 #define tryAMAGICunTARGET(meth, shift)                         \
     STMT_START {                                               \
@@ -440,7 +438,8 @@ Does not use C<TARG>.  See also C<XPUSHu>, C<mPUSHu> and C<PUSHu>.
            SV *tmpsv;                                          \
            SV *arg= sp[shift];                                 \
            if (SvAMAGIC(arg) &&                                \
-               (tmpsv=AMG_CALLun_var(arg,CAT2(meth,_amg)))) {  \
+               (tmpsv = amagic_call(arg, &PL_sv_undef, CAT2(meth,_amg), \
+                                    AMGf_noright | AMGf_unary))) {     \
                SPAGAIN;                                        \
                sp += shift;                                    \
                sv_setsv(TARG, tmpsv);                          \
@@ -456,7 +455,8 @@ Does not use C<TARG>.  See also C<XPUSHu>, C<mPUSHu> and C<PUSHu>.
        SV *arg = *sp;                                                  \
     am_again:                                                          \
        if (SvAMAGIC(arg) &&                                            \
-           (tmpsv=AMG_CALLun_var(arg,(meth_enum)))) {                  \
+           (tmpsv = amagic_call(arg, &PL_sv_undef, meth_enum,          \
+                                AMGf_noright | AMGf_unary))) {         \
            SPAGAIN;                                                    \
            sv = tmpsv;                                                 \
            if (!SvROK(tmpsv))                                          \