X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=Magic.xs;h=fd2046f987b82ffb50d70962f93e948031b5adb8;hb=234cf62c8daa5de094f5cbf115037a313203ef5e;hp=48c8bdd982c63981dc671ad1c447bc25965912d2;hpb=fbcb2462798d2fa931a5c97ebf0cec73177dce23;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/Magic.xs b/Magic.xs index 48c8bdd..fd2046f 100644 --- a/Magic.xs +++ b/Magic.xs @@ -552,6 +552,15 @@ STATIC SV *vmg_op_info(pTHX_ unsigned int opinfo) { /* ... 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) @@ -559,7 +568,6 @@ STATIC SV *vmg_op_info(pTHX_ unsigned int opinfo) { STATIC int vmg_cb_call(pTHX_ SV *cb, SV *sv, SV *data, unsigned int flags, ...){ va_list ap; - SV *svr; int ret; unsigned int i, args, opinfo, eval, has_err = 0; @@ -600,10 +608,7 @@ STATIC int vmg_cb_call(pTHX_ SV *cb, SV *sv, SV *data, unsigned int flags, ...){ ++PL_error_count; } - SPAGAIN; - svr = POPs; - ret = SvOK(svr) ? SvIV(svr) : 0; - PUTBACK; + VMG_CB_CALL_SET_RET(0); FREETMPS; LEAVE; @@ -640,7 +645,6 @@ STATIC int vmg_svt_set(pTHX_ SV *sv, MAGIC *mg) { } STATIC U32 vmg_svt_len(pTHX_ SV *sv, MAGIC *mg) { - SV *svr; const MGWIZ *w = SV2MGWIZ(mg->mg_ptr); unsigned int opinfo = w->opinfo; U32 len, ret; @@ -676,10 +680,7 @@ STATIC U32 vmg_svt_len(pTHX_ SV *sv, MAGIC *mg) { call_sv(w->cb_len, G_SCALAR); - SPAGAIN; - svr = POPs; - ret = SvOK(svr) ? SvUV(svr) : len; - PUTBACK; + VMG_CB_CALL_SET_RET(len); FREETMPS; LEAVE;