summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Zakharevich <ilya@math.berkeley.edu>1998-10-30 13:36:20 -0500
committerGurusamy Sarathy <gsar@cpan.org>1998-10-31 09:40:31 +0000
commite8c20960f1361f5ece79a169ec3ac2d3421a8427 (patch)
treec38853bff7024c87478223eaf92ced1979e2164e
parent2efaeb471b8b92d7180a656a22c05b363d242664 (diff)
downloadperl-e8c20960f1361f5ece79a169ec3ac2d3421a8427.tar.gz
Re: [PATCH 5.00552] Overloaded <> and deref again
Message-Id: <199810302336.SAA17336@monk.mps.ohio-state.edu> p4raw-id: //depot/perl@2162
-rw-r--r--pp.h17
1 files changed, 11 insertions, 6 deletions
diff --git a/pp.h b/pp.h
index 08e10a7dc8..442fdc60ca 100644
--- a/pp.h
+++ b/pp.h
@@ -195,7 +195,7 @@
#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]; \
@@ -203,20 +203,25 @@
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,)
#define opASSIGN (PL_op->op_flags & OPf_STACKED)
#define SETsv(sv) STMT_START { \