summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2010-12-30 16:29:12 +0000
committerDavid Mitchell <davem@iabyn.com>2010-12-31 12:01:48 +0000
commit31d632c315ee363ec7894471fe0f73dc96f5c042 (patch)
treedbfeaf1f0c28237ece34455e1c08645b62f2e1cc
parentada6eeb82df60fbe63c781f1a102393fd56d104b (diff)
downloadperl-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.c2
-rw-r--r--pp.c4
-rw-r--r--pp.h9
-rw-r--r--pp_ctl.c2
-rw-r--r--pp_hot.c2
-rw-r--r--pp_sort.c10
-rw-r--r--pp_sys.c2
-rw-r--r--sv.c16
8 files changed, 25 insertions, 22 deletions
diff --git a/gv.c b/gv.c
index 4e79171989..bebfb6e175 100644
--- a/gv.c
+++ b/gv.c
@@ -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);
diff --git a/pp.c b/pp.c
index 0713ec6786..1f4ef25e2a 100644
--- a/pp.c
+++ b/pp.c
@@ -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 %%{}",
diff --git a/pp.h b/pp.h
index 4e663bac3b..debdd2d3e9 100644
--- a/pp.h
+++ b/pp.h
@@ -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; \
diff --git a/pp_ctl.c b/pp_ctl.c
index 19657d8277..0a9739f5e1 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -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); \
diff --git a/pp_hot.c b/pp_hot.c
index 0e6417dee4..5c665366c4 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -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)))
diff --git a/pp_sort.c b/pp_sort.c
index 055b3ac55d..3d0e4b529d 100644
--- a/pp_sort.c
+++ b/pp_sort.c
@@ -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;
diff --git a/pp_sys.c b/pp_sys.c
index 6a89fb4e34..332abbbc11 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -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
diff --git a/sv.c b/sv.c
index 00b99b4fba..071ec45cee 100644
--- a/sv.c
+++ b/sv.c
@@ -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);