diff options
author | David Mitchell <davem@iabyn.com> | 2010-12-30 16:29:12 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2010-12-31 12:01:48 +0000 |
commit | 31d632c315ee363ec7894471fe0f73dc96f5c042 (patch) | |
tree | dbfeaf1f0c28237ece34455e1c08645b62f2e1cc | |
parent | ada6eeb82df60fbe63c781f1a102393fd56d104b (diff) | |
download | perl-31d632c315ee363ec7894471fe0f73dc96f5c042.tar.gz |
standardise amagic method naming
Some amagic-related macros take the full method enumeration name,
(e.g. "add_amg"); while others "helpfully" allow you to pass a shortened
version, ("add"), and do a CAT2(meth,_amg) behind the scenes.
Standardise on passing the full name; this makes it less confusing and
allows you to grep for the enumeration name in the source.
It updates two macros to accept full enumeration names: tryAMAGICunTARGET
(which isn't used outside the core apparently), and AMG_CALLun, which is
replaced by a new AMG_CALLunary (since AMG_CALLun is used outside the
core).
-rw-r--r-- | gv.c | 2 | ||||
-rw-r--r-- | pp.c | 4 | ||||
-rw-r--r-- | pp.h | 9 | ||||
-rw-r--r-- | pp_ctl.c | 2 | ||||
-rw-r--r-- | pp_hot.c | 2 | ||||
-rw-r--r-- | pp_sort.c | 10 | ||||
-rw-r--r-- | pp_sys.c | 2 | ||||
-rw-r--r-- | sv.c | 16 |
8 files changed, 25 insertions, 22 deletions
@@ -2383,7 +2383,7 @@ Perl_amagic_call(pTHX_ SV *left, SV *right, int method, int flags) * information by hand */ SV *tmpRef = SvRV(left); SV *rv_copy; - if (SvREFCNT(tmpRef) > 1 && (rv_copy = AMG_CALLun(left,copy))) { + if (SvREFCNT(tmpRef) > 1 && (rv_copy = AMG_CALLunary(left,copy_amg))) { SvRV_set(left, rv_copy); SvSETMAGIC(left); SvREFCNT_dec(tmpRef); @@ -4835,8 +4835,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(sv,to_hv); - SV *maybe_av = AMG_CALLun(sv,to_av); + SV *maybe_hv = AMG_CALLunary(sv, to_hv_amg); + SV *maybe_av = AMG_CALLunary(sv, to_av_amg); 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 %%{}", @@ -425,8 +425,11 @@ Does not use C<TARG>. See also C<XPUSHu>, C<mPUSHu> and C<PUSHu>. return NORMAL; \ } STMT_END -#define AMG_CALLun(sv,meth) \ - amagic_call(sv,&PL_sv_undef, CAT2(meth,_amg), AMGf_noright | AMGf_unary) +#define AMG_CALLunary(sv,meth) \ + amagic_call(sv,&PL_sv_undef, meth, AMGf_noright | AMGf_unary) + +/* No longer used in core. Use AMG_CALLunary instead */ +#define AMG_CALLun(sv,meth) AMG_CALLunary(sv, CAT2(meth,_amg)) #define tryAMAGICunTARGET(meth, shift) \ STMT_START { \ @@ -438,7 +441,7 @@ Does not use C<TARG>. See also C<XPUSHu>, C<mPUSHu> and C<PUSHu>. SV *tmpsv; \ SV *arg= sp[shift]; \ if (SvAMAGIC(arg) && \ - (tmpsv = amagic_call(arg, &PL_sv_undef, CAT2(meth,_amg), \ + (tmpsv = amagic_call(arg, &PL_sv_undef, meth, \ AMGf_noright | AMGf_unary))) { \ SPAGAIN; \ sp += shift; \ @@ -98,7 +98,7 @@ PP(pp_regcomp) STMT_START { \ SvGETMAGIC(rx); \ if (SvROK(rx) && SvAMAGIC(rx)) { \ - SV *sv = AMG_CALLun(rx, regexp); \ + SV *sv = AMG_CALLunary(rx, regexp_amg); \ if (sv) { \ if (SvROK(sv)) \ sv = SvRV(sv); \ @@ -315,7 +315,7 @@ PP(pp_readline) { dVAR; dSP; SvGETMAGIC(TOPs); - tryAMAGICunTARGET(iter, 0); + tryAMAGICunTARGET(iter_amg, 0); PL_last_in_gv = MUTABLE_GV(*PL_stack_sp--); if (!isGV_with_GP(PL_last_in_gv)) { if (SvROK(PL_last_in_gv) && isGV_with_GP(SvRV(PL_last_in_gv))) @@ -1868,7 +1868,7 @@ S_sv_i_ncmp(pTHX_ SV *const a, SV *const b) #define tryCALL_AMAGICbin(left,right,meth) \ (SvAMAGIC(left)||SvAMAGIC(right)) \ - ? amagic_call(left, right, CAT2(meth,_amg), 0) \ + ? amagic_call(left, right, meth, 0) \ : NULL; #define SORT_NORMAL_RETURN_VALUE(val) (((val) > 0) ? 1 : ((val) ? -1 : 0)) @@ -1877,7 +1877,7 @@ static I32 S_amagic_ncmp(pTHX_ register SV *const a, register SV *const b) { dVAR; - SV * const tmpsv = tryCALL_AMAGICbin(a,b,ncmp); + SV * const tmpsv = tryCALL_AMAGICbin(a,b,ncmp_amg); PERL_ARGS_ASSERT_AMAGIC_NCMP; @@ -1898,7 +1898,7 @@ static I32 S_amagic_i_ncmp(pTHX_ register SV *const a, register SV *const b) { dVAR; - SV * const tmpsv = tryCALL_AMAGICbin(a,b,ncmp); + SV * const tmpsv = tryCALL_AMAGICbin(a,b,ncmp_amg); PERL_ARGS_ASSERT_AMAGIC_I_NCMP; @@ -1919,7 +1919,7 @@ static I32 S_amagic_cmp(pTHX_ register SV *const str1, register SV *const str2) { dVAR; - SV * const tmpsv = tryCALL_AMAGICbin(str1,str2,scmp); + SV * const tmpsv = tryCALL_AMAGICbin(str1,str2,scmp_amg); PERL_ARGS_ASSERT_AMAGIC_CMP; @@ -1940,7 +1940,7 @@ static I32 S_amagic_cmp_locale(pTHX_ register SV *const str1, register SV *const str2) { dVAR; - SV * const tmpsv = tryCALL_AMAGICbin(str1,str2,scmp); + SV * const tmpsv = tryCALL_AMAGICbin(str1,str2,scmp_amg); PERL_ARGS_ASSERT_AMAGIC_CMP_LOCALE; @@ -358,7 +358,7 @@ PP(pp_glob) { dVAR; OP *result; - tryAMAGICunTARGET(iter, -1); + tryAMAGICunTARGET(iter_amg, -1); /* Note that we only ever get here if File::Glob fails to load * without at the same time croaking, for some reason, or if @@ -2299,7 +2299,7 @@ Perl_sv_2iv_flags(pTHX_ register SV *const sv, const I32 flags) SV * tmpstr; if (flags & SV_SKIP_OVERLOAD) return 0; - tmpstr=AMG_CALLun(sv,numer); + tmpstr = AMG_CALLunary(sv, numer_amg); if (tmpstr && (!SvROK(tmpstr) || (SvRV(tmpstr) != SvRV(sv)))) { return SvIV(tmpstr); } @@ -2378,7 +2378,7 @@ Perl_sv_2uv_flags(pTHX_ register SV *const sv, const I32 flags) SV *tmpstr; if (flags & SV_SKIP_OVERLOAD) return 0; - tmpstr = AMG_CALLun(sv,numer); + tmpstr = AMG_CALLunary(sv, numer_amg); if (tmpstr && (!SvROK(tmpstr) || (SvRV(tmpstr) != SvRV(sv)))) { return SvUV(tmpstr); } @@ -2452,7 +2452,7 @@ Perl_sv_2nv_flags(pTHX_ register SV *const sv, const I32 flags) SV *tmpstr; if (flags & SV_SKIP_OVERLOAD) return 0; - tmpstr = AMG_CALLun(sv,numer); + tmpstr = AMG_CALLunary(sv, numer_amg); if (tmpstr && (!SvROK(tmpstr) || (SvRV(tmpstr) != SvRV(sv)))) { return SvNV(tmpstr); } @@ -2651,7 +2651,7 @@ Perl_sv_2num(pTHX_ register SV *const sv) if (!SvROK(sv)) return sv; if (SvAMAGIC(sv)) { - SV * const tmpsv = AMG_CALLun(sv,numer); + SV * const tmpsv = AMG_CALLunary(sv, numer_amg); TAINT_IF(tmpsv && SvTAINTED(tmpsv)); if (tmpsv && (!SvROK(tmpsv) || (SvRV(tmpsv) != SvRV(sv)))) return sv_2num(tmpsv); @@ -2770,7 +2770,7 @@ Perl_sv_2pv_flags(pTHX_ register SV *const sv, STRLEN *const lp, const I32 flags SV *tmpstr; if (flags & SV_SKIP_OVERLOAD) return NULL; - tmpstr = AMG_CALLun(sv,string); + tmpstr = AMG_CALLunary(sv, string_amg); TAINT_IF(tmpstr && SvTAINTED(tmpstr)); if (tmpstr && (!SvROK(tmpstr) || (SvRV(tmpstr) != SvRV(sv)))) { /* Unwrap this: */ @@ -3093,7 +3093,7 @@ Perl_sv_2bool_flags(pTHX_ register SV *const sv, const I32 flags) return 0; if (SvROK(sv)) { if (SvAMAGIC(sv)) { - SV * const tmpsv = AMG_CALLun(sv,bool_); + SV * const tmpsv = AMG_CALLunary(sv, bool__amg); if (tmpsv && (!SvROK(tmpsv) || (SvRV(tmpsv) != SvRV(sv)))) return cBOOL(SvTRUE(tmpsv)); } @@ -7827,7 +7827,7 @@ Perl_sv_inc_nomg(pTHX_ register SV *const sv) } if (SvROK(sv)) { IV i; - if (SvAMAGIC(sv) && AMG_CALLun(sv,inc)) + if (SvAMAGIC(sv) && AMG_CALLunary(sv, inc_amg)) return; i = PTR2IV(SvRV(sv)); sv_unref(sv); @@ -8008,7 +8008,7 @@ Perl_sv_dec_nomg(pTHX_ register SV *const sv) } if (SvROK(sv)) { IV i; - if (SvAMAGIC(sv) && AMG_CALLun(sv,dec)) + if (SvAMAGIC(sv) && AMG_CALLunary(sv, dec_amg)) return; i = PTR2IV(SvRV(sv)); sv_unref(sv); |