/* ... svt callbacks ....................................................... */
-#define VMG_CB_CALL_SET_RET(D) \
- { \
- SV *svr; \
- SPAGAIN; \
- svr = POPs; \
- ret = SvOK(svr) ? SvIV(svr) : (D); \
- PUTBACK; \
- }
-
#define VMG_CB_CALL_ARGS_MASK 15
#define VMG_CB_CALL_ARGS_SHIFT 4
#define VMG_CB_CALL_OPINFO (VMG_OP_INFO_NAME|VMG_OP_INFO_OBJECT)
STATIC int vmg_cb_call(pTHX_ SV *cb, unsigned int flags, SV *sv, ...) {
va_list ap;
- int ret;
+ int ret = 0;
unsigned int i, args, opinfo;
+ SV *svr;
dSP;
call_sv(cb, G_SCALAR);
- VMG_CB_CALL_SET_RET(0);
+ SPAGAIN;
+ svr = POPs;
+ if (SvOK(svr))
+ ret = (int) SvIV(svr);
+ PUTBACK;
FREETMPS;
LEAVE;
const MGWIZ *w = vmg_wizard_mgwiz(mg->mg_ptr);
unsigned int opinfo = w->opinfo;
U32 len, ret;
+ SV *svr;
svtype t = SvTYPE(sv);
dSP;
call_sv(w->cb_len, G_SCALAR);
- VMG_CB_CALL_SET_RET(len);
+ SPAGAIN;
+ svr = POPs;
+ ret = SvOK(svr) ? (U32) SvUV(svr) : len;
+ if (t == SVt_PVAV)
+ --ret;
+ PUTBACK;
FREETMPS;
LEAVE;
- return t == SVt_PVAV ? ret - 1 : ret;
+ return ret;
}
STATIC int vmg_svt_clear(pTHX_ SV *sv, MAGIC *mg) {
#endif
I32 had_err, has_err, flags = G_SCALAR | G_EVAL;
int ret = 0;
+ SV *svr;
dSP;
if (IN_PERL_COMPILETIME && !had_err && has_err)
++PL_error_count;
- VMG_CB_CALL_SET_RET(0);
+ SPAGAIN;
+ svr = POPs;
+ if (SvOK(svr))
+ ret = (int) SvIV(svr);
+ PUTBACK;
FREETMPS;
LEAVE;