/* pp.h
*
- * Copyright (c) 1991-1997, Larry Wall
+ * Copyright (c) 1991-1999, Larry Wall
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
#define RETURNX(x) return x, PUTBACK, NORMAL
#define POPs (*sp--)
-#define POPp (SvPVx(POPs, PL_na))
+#define POPp (SvPVx(POPs, PL_na)) /* deprecated */
+#define POPpx (SvPVx(POPs, n_a))
#define POPn (SvNVx(POPs))
#define POPi ((IV)SvIVx(POPs))
#define POPu ((UV)SvUVx(POPs))
#define POPl ((long)SvIVx(POPs))
#define TOPs (*sp)
-#define TOPp (SvPV(TOPs, PL_na))
+#define TOPp (SvPV(TOPs, PL_na)) /* deprecated */
+#define TOPpx (SvPV(TOPs, n_a))
#define TOPn (SvNV(TOPs))
#define TOPi ((IV)SvIV(TOPs))
#define TOPu ((UV)SvUV(TOPs))
#define SWITCHSTACK(f,t) \
STMT_START { \
- AvFILLp(f) = sp - PL_stack_base; \
+ AvFILLp(f) = sp - PL_stack_base; \
PL_stack_base = AvARRAY(t); \
- PL_stack_max = PL_stack_base + AvMAX(t); \
+ PL_stack_max = PL_stack_base + AvMAX(t); \
sp = PL_stack_sp = PL_stack_base + AvFILLp(t); \
- PL_curstack = t; \
+ PL_curstack = t; \
} STMT_END
#define EXTEND_MORTAL(n) \
- STMT_START { \
- if (PL_tmps_ix + (n) >= PL_tmps_max) \
- Renew(PL_tmps_stack, PL_tmps_max = PL_tmps_ix + (n) + 1, SV*); \
- } STMT_END
-
-#ifdef OVERLOAD
+ STMT_START { \
+ if (PL_tmps_ix + (n) >= PL_tmps_max) \
+ tmps_grow(n); \
+ } STMT_END
#define AMGf_noright 1
#define AMGf_noleft 2
#define AMG_CALLbinL(left,right,meth) \
amagic_call(left,right,CAT2(meth,_amg),AMGf_noright)
-#define tryAMAGICunW(meth,set,shift) STMT_START { \
+#define tryAMAGICunW(meth,set,shift,ret) STMT_START { \
if (PL_amagic_generation) { \
SV* tmpsv; \
SV* arg= sp[shift]; \
if ((SvAMAGIC(arg))&&\
(tmpsv=AMG_CALLun(arg,meth))) {\
SPAGAIN; if (shift) sp += shift; \
- set(tmpsv); RETURN; } \
+ set(tmpsv); ret; } \
} \
} STMT_END
#define FORCE_SETs(sv) STMT_START { sv_setsv(TARG, (sv)); SETTARG; } STMT_END
#define tryAMAGICun tryAMAGICunSET
-#define tryAMAGICunSET(meth) tryAMAGICunW(meth,SETs,0)
+#define tryAMAGICunSET(meth) tryAMAGICunW(meth,SETs,0,RETURN)
#define tryAMAGICunTARGET(meth, shift) \
{ dSP; sp--; /* get TARGET from below PL_stack_sp */ \
{ dTARGETSTACKED; \
- { dSP; tryAMAGICunW(meth,FORCE_SETs,shift);}}}
-#define setAGAIN(ref) sv = arg = ref; goto am_again;
-#define tryAMAGICunDEREF(meth) tryAMAGICunW(meth,setAGAIN,0)
+ { dSP; tryAMAGICunW(meth,FORCE_SETs,shift,RETURN);}}}
+
+#define setAGAIN(ref) sv = arg = ref; \
+ if (!SvROK(ref)) \
+ croak("Overloaded dereference did not return a reference"); \
+ goto am_again;
+
+#define tryAMAGICunDEREF(meth) tryAMAGICunW(meth,setAGAIN,0,(void)0)
#define opASSIGN (PL_op->op_flags & OPf_STACKED)
#define SETsv(sv) STMT_START { \
SvREFCNT_dec(tmpRef); \
SvRV(rv)=AMG_CALLun(rv,copy); \
} } STMT_END
-#else
-
-#define tryAMAGICbin(a,b)
-#define tryAMAGICbinSET(a,b)
-#define tryAMAGICun(a)
-#define tryAMAGICunSET(a)
-
-#endif /* OVERLOAD */