STATIC UV vmg_cast(pTHX_ SV *sv, const vmg_wizard *w, const SV *wiz, SV **args, I32 items) {
#define vmg_cast(S, W, WIZ, A, I) vmg_cast(aTHX_ (S), (W), (WIZ), (A), (I))
- MAGIC *mg;
- SV *data;
- U32 oldgmg;
+ MAGIC *mg;
+ MGVTBL *t;
+ SV *data;
+ U32 oldgmg;
if (vmg_find(sv, w))
return 1;
oldgmg = SvGMAGICAL(sv);
data = (w->cb_data) ? vmg_data_new(w->cb_data, sv, args, items) : NULL;
+
+ t = vmg_vtable_vtbl(w->vtable);
+ mg = sv_magicext(sv, data, PERL_MAGIC_ext, t, (const char *) wiz, HEf_SVKEY);
+ mg->mg_private = 0;
+
/* sv_magicext() calls mg_magical and increments data's refcount */
- mg = sv_magicext(sv, data, PERL_MAGIC_ext, vmg_vtable_vtbl(w->vtable),
- (const char *) wiz, HEf_SVKEY);
SvREFCNT_dec(data);
- mg->mg_private = 0;
- if (w->cb_copy)
+
+ if (t->svt_copy)
mg->mg_flags |= MGf_COPY;
#if 0
- if (w->cb_dup)
+ if (t->svt_dup)
mg->mg_flags |= MGf_DUP;
#endif
#if MGf_LOCAL
- if (w->cb_local)
+ if (t->svt_local)
mg->mg_flags |= MGf_LOCAL;
#endif /* MGf_LOCAL */