Create new macros AMG_CALLun_var, AMG_CALLun_var and tryAMAGICun_var
Nicholas Clark [Tue, 7 Feb 2006 15:28:41 +0000 (15:28 +0000)]
which don't do the pre-processor string manipulation internally.

p4raw-id: //depot/perl@27122

pp.c
pp.h

diff --git a/pp.c b/pp.c
index 1a82a16..69a4e9d 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -2643,7 +2643,7 @@ PP(pp_atan2)
 
 PP(pp_sin)
 {
-    dVAR; dSP; dTARGET; tryAMAGICun(sin);
+    dVAR; dSP; dTARGET; tryAMAGICun_var(sin_amg);
     {
       const NV value = POPn;
       XPUSHn(Perl_sin(value));
@@ -2653,7 +2653,7 @@ PP(pp_sin)
 
 PP(pp_cos)
 {
-    dVAR; dSP; dTARGET; tryAMAGICun(cos);
+    dVAR; dSP; dTARGET; tryAMAGICun_var(cos_amg);
     {
       const NV value = POPn;
       XPUSHn(Perl_cos(value));
@@ -2707,7 +2707,7 @@ PP(pp_srand)
 
 PP(pp_exp)
 {
-    dVAR; dSP; dTARGET; tryAMAGICun(exp);
+    dVAR; dSP; dTARGET; tryAMAGICun_var(exp_amg);
     {
       NV value;
       value = POPn;
@@ -2719,7 +2719,7 @@ PP(pp_exp)
 
 PP(pp_log)
 {
-    dVAR; dSP; dTARGET; tryAMAGICun(log);
+    dVAR; dSP; dTARGET; tryAMAGICun_var(log_amg);
     {
       const NV value = POPn;
       if (value <= 0.0) {
@@ -2733,7 +2733,7 @@ PP(pp_log)
 
 PP(pp_sqrt)
 {
-    dVAR; dSP; dTARGET; tryAMAGICun(sqrt);
+    dVAR; dSP; dTARGET; tryAMAGICun_var(sqrt_amg);
     {
       const NV value = POPn;
       if (value < 0.0) {
diff --git a/pp.h b/pp.h
index 7992259..c4a700e 100644 (file)
--- a/pp.h
+++ b/pp.h
@@ -118,9 +118,9 @@ Pops a long off the stack.
 */
 
 #define PUTBACK                PL_stack_sp = sp
-#define RETURN         return PUTBACK, NORMAL
-#define RETURNOP(o)    return PUTBACK, o
-#define RETURNX(x)     return x, PUTBACK, NORMAL
+#define RETURN         return (PUTBACK, NORMAL)
+#define RETURNOP(o)    return (PUTBACK, o)
+#define RETURNX(x)     return (x, PUTBACK, NORMAL)
 
 #define POPs           (*sp--)
 #define POPp           (SvPVx(POPs, PL_na))            /* deprecated */
@@ -420,25 +420,30 @@ and C<PUSHu>.
 #define tryAMAGICbinSET_var(meth_enum,assign) \
     tryAMAGICbinW_var(meth_enum,assign,SETs)
 
-#define AMG_CALLun(sv,meth) amagic_call(sv,&PL_sv_undef,  \
-                                       CAT2(meth,_amg),AMGf_noright | AMGf_unary)
+#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_CALLbinL(left,right,meth) \
             amagic_call(left,right,CAT2(meth,_amg),AMGf_noright)
 
-#define tryAMAGICunW(meth,set,shift,ret) STMT_START { \
+#define tryAMAGICunW_var(meth_enum,set,shift,ret) STMT_START { \
            SV* tmpsv; \
            SV* arg= sp[shift]; \
           if(0) goto am_again;  /* shut up unused warning */ \
          am_again: \
            if ((SvAMAGIC(arg))&&\
-               (tmpsv=AMG_CALLun(arg,meth))) {\
+               (tmpsv=AMG_CALLun_var(arg,meth_enum))) {\
               SPAGAIN; if (shift) sp += shift; \
               set(tmpsv); ret; } \
        } STMT_END
+#define tryAMAGICunW(meth,set,shift,ret) \
+       tryAMAGICunW_var(CAT2(meth,_amg),set,shift,ret)
 
 #define FORCE_SETs(sv) STMT_START { sv_setsv(TARG, (sv)); SETTARG; } STMT_END
 
-#define tryAMAGICun(meth)      tryAMAGICunW(meth,SETsvUN,0,RETURN)
+#define tryAMAGICun_var(meth_enum) tryAMAGICunW_var(meth_enum,SETsvUN,0,RETURN)
+#define tryAMAGICun(meth)      tryAMAGICun_var(CAT2(meth,_amg))
 #define tryAMAGICunSET(meth)   tryAMAGICunW(meth,SETs,0,RETURN)
 #define tryAMAGICunTARGET(meth, shift)                                 \
        STMT_START { dSP; sp--;         /* get TARGET from below PL_stack_sp */         \