From: Vincent Pit Date: Wed, 26 Oct 2011 19:56:15 +0000 (+0200) Subject: vmg_cast() should set mg_flags according to the vtable X-Git-Tag: v0.47~6 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=9313f2dc8e1f534131fee3e6235f4a533396a0ac;p=perl%2Fmodules%2FVariable-Magic.git vmg_cast() should set mg_flags according to the vtable And not according to the Perl callbacks. --- diff --git a/Magic.xs b/Magic.xs index a095332..bf413ff 100644 --- a/Magic.xs +++ b/Magic.xs @@ -770,9 +770,10 @@ STATIC void vmg_uvar_del(SV *sv, MAGIC *prevmagic, MAGIC *mg, MAGIC *moremagic) 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; @@ -780,19 +781,22 @@ STATIC UV vmg_cast(pTHX_ SV *sv, const vmg_wizard *w, const SV *wiz, SV **args, 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 */