From: Vincent Pit Date: Wed, 11 Mar 2015 01:04:33 +0000 (-0300) Subject: Set the mg_flags inside vmg_sv_magicext() according to the vtbl entries X-Git-Tag: v0.56~5 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=c77fbf03cffe6f4a24764ba311a9ac1650c08237;p=perl%2Fmodules%2FVariable-Magic.git Set the mg_flags inside vmg_sv_magicext() according to the vtbl entries --- diff --git a/Magic.xs b/Magic.xs index c6d7454..1349a9c 100644 --- a/Magic.xs +++ b/Magic.xs @@ -288,6 +288,17 @@ STATIC MAGIC *vmg_sv_magicext(pTHX_ SV *sv, SV *obj, const MGVTBL *vtbl, const v mg->mg_private = 0; + if (vtbl->svt_copy) + mg->mg_flags |= MGf_COPY; +#if MGf_DUP + if (vtbl->svt_dup) + mg->mg_flags |= MGf_DUP; +#endif /* MGf_DUP */ +#if MGf_LOCAL + if (vtbl->svt_local) + mg->mg_flags |= MGf_LOCAL; +#endif /* MGf_LOCAL */ + if (mg->mg_flags & MGf_REFCOUNTED) SvREFCNT_dec(obj); @@ -722,13 +733,8 @@ STATIC SV *vmg_wizard_sv_new(pTHX_ const vmg_wizard *w) { wiz = newSViv(PTR2IV(w)); #endif - if (w) { - MAGIC *mg; - mg = vmg_sv_magicext(wiz, NULL, &vmg_wizard_sv_vtbl, w, 0); -#if VMG_THREADSAFE - mg->mg_flags |= MGf_DUP; -#endif - } + vmg_sv_magicext(wiz, NULL, &vmg_wizard_sv_vtbl, w, 0); + SvREADONLY_on(wiz); return wiz; @@ -919,17 +925,6 @@ STATIC UV vmg_cast(pTHX_ SV *sv, const vmg_wizard *w, const SV *wiz, SV **args, t = vmg_vtable_vtbl(w->vtable); mg = vmg_sv_magicext(sv, data, t, wiz, HEf_SVKEY); - if (t->svt_copy) - mg->mg_flags |= MGf_COPY; -#if 0 - if (t->svt_dup) - mg->mg_flags |= MGf_DUP; -#endif -#if MGf_LOCAL - if (t->svt_local) - mg->mg_flags |= MGf_LOCAL; -#endif /* MGf_LOCAL */ - if (SvTYPE(sv) < SVt_PVHV) goto done;