From: Vincent Pit Date: Wed, 26 Oct 2011 15:50:13 +0000 (+0200) Subject: Rename vmg_wizard_* to vmg_wizard_sv_* and {MGWIZ,mgwiz}_* to vmg_wizard_* X-Git-Tag: v0.47~11 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=4e37d5bbd29a250b77d291a9135e082eecfd5a8f;p=perl%2Fmodules%2FVariable-Magic.git Rename vmg_wizard_* to vmg_wizard_sv_* and {MGWIZ,mgwiz}_* to vmg_wizard_* --- diff --git a/Magic.xs b/Magic.xs index a2dd6db..5d9c81f 100644 --- a/Magic.xs +++ b/Magic.xs @@ -470,7 +470,7 @@ STATIC vmg_vtable *vmg_vtable_alloc(pTHX) { #endif /* !VMG_THREADSAFE */ -/* --- MGWIZ structure ----------------------------------------------------- */ +/* --- structure ---------------------------------------------- */ typedef struct { vmg_vtable *vtable; @@ -488,16 +488,15 @@ typedef struct { #if VMG_UVAR SV *cb_fetch, *cb_store, *cb_exists, *cb_delete; #endif /* VMG_UVAR */ -} MGWIZ; +} vmg_wizard; STATIC void vmg_op_info_init(pTHX_ unsigned int opinfo); -STATIC MGWIZ *vmg_mgwiz_alloc(pTHX_ UV opinfo) { -#define vmg_mgwiz_alloc(O) vmg_mgwiz_alloc(aTHX_ (O)) - MGWIZ *w; - MGVTBL *t; +STATIC vmg_wizard *vmg_wizard_alloc(pTHX_ UV opinfo) { +#define vmg_wizard_alloc(O) vmg_wizard_alloc(aTHX_ (O)) + vmg_wizard *w; - Newx(w, 1, MGWIZ); + Newx(w, 1, vmg_wizard); w->uvar = 0; w->opinfo = (U8) ((opinfo < 255) ? opinfo : 255); @@ -509,8 +508,8 @@ STATIC MGWIZ *vmg_mgwiz_alloc(pTHX_ UV opinfo) { return w; } -STATIC void vmg_mgwiz_free(pTHX_ MGWIZ *w) { -#define vmg_mgwiz_free(W) vmg_mgwiz_free(aTHX_ (W)) +STATIC void vmg_wizard_free(pTHX_ vmg_wizard *w) { +#define vmg_wizard_free(W) vmg_wizard_free(aTHX_ (W)) if (!w) return; @@ -546,14 +545,14 @@ STATIC void vmg_mgwiz_free(pTHX_ MGWIZ *w) { z->cb_ ## N = (w->cb_ ## N) ? SvREFCNT_inc(sv_dup(w->cb_ ## N, params)) \ : NULL; -STATIC const MGWIZ *vmg_mgwiz_dup(pTHX_ const MGWIZ *w, CLONE_PARAMS *params) { -#define vmg_mgwiz_dup(W, P) vmg_mgwiz_dup(aTHX_ (W), (P)) - MGWIZ *z; +STATIC const vmg_wizard *vmg_wizard_dup(pTHX_ const vmg_wizard *w, CLONE_PARAMS *params) { +#define vmg_wizard_dup(W, P) vmg_wizard_dup(aTHX_ (W), (P)) + vmg_wizard *z; if (!w) return NULL; - Newx(z, 1, MGWIZ); + Newx(z, 1, vmg_wizard); z->vtable = vmg_vtable_dup(w->vtable); z->uvar = w->uvar; @@ -592,34 +591,32 @@ typedef struct { START_MY_CXT -/* --- Wizard objects ------------------------------------------------------ */ +/* --- Wizard SV objects --------------------------------------------------- */ -STATIC int vmg_wizard_free(pTHX_ SV *sv, MAGIC *mg); +STATIC int vmg_wizard_sv_free(pTHX_ SV *sv, MAGIC *mg); #if VMG_THREADSAFE -STATIC int vmg_wizard_dup(pTHX_ MAGIC *mg, CLONE_PARAMS *params); +STATIC int vmg_wizard_sv_dup(pTHX_ MAGIC *mg, CLONE_PARAMS *params); #endif -STATIC MGVTBL vmg_wizard_vtbl = { - NULL, /* get */ - NULL, /* set */ - NULL, /* len */ - NULL, /* clear */ - vmg_wizard_free, /* free */ - NULL, /* copy */ +STATIC MGVTBL vmg_wizard_sv_vtbl = { + NULL, /* get */ + NULL, /* set */ + NULL, /* len */ + NULL, /* clear */ + vmg_wizard_sv_free, /* free */ + NULL, /* copy */ #if VMG_THREADSAFE - vmg_wizard_dup, /* dup */ + vmg_wizard_sv_dup, /* dup */ #else - NULL, /* dup */ + NULL, /* dup */ #endif #if MGf_LOCAL - NULL, /* local */ + NULL, /* local */ #endif /* MGf_LOCAL */ }; -/* ... Wizard constructor .................................................. */ - -STATIC SV *vmg_wizard_new(pTHX_ const MGWIZ *w) { -#define vmg_wizard_new(W) vmg_wizard_new(aTHX_ (W)) +STATIC SV *vmg_wizard_sv_new(pTHX_ const vmg_wizard *w) { +#define vmg_wizard_sv_new(W) vmg_wizard_sv_new(aTHX_ (W)) SV *wiz; #if VMG_THREADSAFE @@ -629,7 +626,7 @@ STATIC SV *vmg_wizard_new(pTHX_ const MGWIZ *w) { #endif if (w) { - MAGIC *mg = sv_magicext(wiz, NULL, PERL_MAGIC_ext, &vmg_wizard_vtbl, + MAGIC *mg = sv_magicext(wiz, NULL, PERL_MAGIC_ext, &vmg_wizard_sv_vtbl, (const char *) w, 0); mg->mg_private = SIG_WZO; #if VMG_THREADSAFE @@ -641,8 +638,8 @@ STATIC SV *vmg_wizard_new(pTHX_ const MGWIZ *w) { return wiz; } -STATIC const SV *vmg_wizard_validate(pTHX_ const SV *wiz) { -#define vmg_wizard_validate(W) vmg_wizard_validate(aTHX_ (W)) +STATIC const SV *vmg_wizard_sv_validate(pTHX_ const SV *wiz) { +#define vmg_wizard_sv_validate(W) vmg_wizard_sv_validate(aTHX_ (W)) if (SvROK(wiz)) { wiz = SvRV_const(wiz); #if VMG_THREADSAFE @@ -660,44 +657,42 @@ STATIC const SV *vmg_wizard_validate(pTHX_ const SV *wiz) { #if VMG_THREADSAFE -STATIC const MGWIZ *vmg_wizard_mgwiz(const SV *wiz) { +STATIC const vmg_wizard *vmg_wizard_from_sv(const SV *wiz) { MAGIC *mg; for (mg = SvMAGIC(wiz); mg; mg = mg->mg_moremagic) { - if (mg->mg_type == PERL_MAGIC_ext && mg->mg_virtual == &vmg_wizard_vtbl) - return (const MGWIZ *) mg->mg_ptr; + if (mg->mg_type == PERL_MAGIC_ext && mg->mg_virtual == &vmg_wizard_sv_vtbl) + return (const vmg_wizard *) mg->mg_ptr; } return NULL; } -#define vmg_wizard_mgwiz(W) vmg_wizard_mgwiz((const SV *) (W)) +#define vmg_wizard_from_sv(W) vmg_wizard_from_sv((const SV *) (W)) -#define vmg_wizard_id(W) PTR2IV(vmg_vtable_vtbl(vmg_wizard_mgwiz(W)->vtable)) +#define vmg_wizard_sv_id(W) PTR2IV(vmg_vtable_vtbl(vmg_wizard_from_sv(W)->vtable)) #else -#define vmg_wizard_id(W) SvIVX((const SV *) (W)) +#define vmg_wizard_sv_id(W) SvIVX((const SV *) (W)) -#define vmg_wizard_mgwiz(W) INT2PTR(const MGWIZ *, vmg_wizard_id(W)) +#define vmg_wizard_from_sv(W) INT2PTR(const vmg_wizard *, vmg_wizard_sv_id(W)) #endif -/* ... Wizard destructor ................................................... */ - -STATIC int vmg_wizard_free(pTHX_ SV *sv, MAGIC *mg) { +STATIC int vmg_wizard_sv_free(pTHX_ SV *sv, MAGIC *mg) { if (PL_dirty) /* During global destruction, the context is already freed */ return 0; - vmg_mgwiz_free((MGWIZ *) mg->mg_ptr); + vmg_wizard_free((vmg_wizard *) mg->mg_ptr); return 0; } #if VMG_THREADSAFE -STATIC int vmg_wizard_dup(pTHX_ MAGIC *mg, CLONE_PARAMS *params) { - mg->mg_ptr = (char *) vmg_mgwiz_dup((const MGWIZ *) mg->mg_ptr, params); +STATIC int vmg_wizard_sv_dup(pTHX_ MAGIC *mg, CLONE_PARAMS *params) { + mg->mg_ptr = (char *) vmg_wizard_dup((const vmg_wizard *) mg->mg_ptr, params); return 0; } @@ -713,11 +708,11 @@ STATIC const MAGIC *vmg_find(const SV *sv, const SV *wiz) { if (SvTYPE(sv) < SVt_PVMG) return NULL; - wid = vmg_wizard_id(wiz); + wid = vmg_wizard_sv_id(wiz); for (mg = SvMAGIC(sv); mg; mg = moremagic) { moremagic = mg->mg_moremagic; if (mg->mg_type == PERL_MAGIC_ext && mg->mg_private == SIG_WIZ) { - IV zid = vmg_wizard_id(mg->mg_ptr); + IV zid = vmg_wizard_sv_id(mg->mg_ptr); if (zid == wid) return mg; } @@ -787,15 +782,15 @@ STATIC void vmg_uvar_del(SV *sv, MAGIC *prevmagic, MAGIC *mg, MAGIC *moremagic) STATIC UV vmg_cast(pTHX_ SV *sv, const SV *wiz, SV **args, I32 items) { #define vmg_cast(S, W, A, I) vmg_cast(aTHX_ (S), (W), (A), (I)) - MAGIC *mg; - SV *data; - const MGWIZ *w; - U32 oldgmg; + const vmg_wizard *w; + MAGIC *mg; + SV *data; + U32 oldgmg; if (vmg_find(sv, wiz)) return 1; - w = vmg_wizard_mgwiz(wiz); + w = vmg_wizard_from_sv(wiz); oldgmg = SvGMAGICAL(sv); data = (w->cb_data) ? vmg_data_new(w->cb_data, sv, args, items) : NULL; @@ -875,7 +870,7 @@ STATIC UV vmg_dispell(pTHX_ SV *sv, const SV *wiz) { U32 uvars = 0; #endif /* VMG_UVAR */ MAGIC *mg, *prevmagic, *moremagic = NULL; - IV wid = vmg_wizard_id(wiz); + IV wid = vmg_wizard_sv_id(wiz); if (SvTYPE(sv) < SVt_PVMG) return 0; @@ -884,9 +879,9 @@ STATIC UV vmg_dispell(pTHX_ SV *sv, const SV *wiz) { moremagic = mg->mg_moremagic; if (mg->mg_type == PERL_MAGIC_ext && mg->mg_private == SIG_WIZ) { #if VMG_UVAR - const MGWIZ *z = vmg_wizard_mgwiz(mg->mg_ptr); + const vmg_wizard *z = vmg_wizard_from_sv(mg->mg_ptr); #endif /* VMG_UVAR */ - IV zid = vmg_wizard_id(mg->mg_ptr); + IV zid = vmg_wizard_sv_id(mg->mg_ptr); if (zid == wid) { #if VMG_UVAR /* If the current has no uvar, short-circuit uvar deletion. */ @@ -924,7 +919,7 @@ STATIC UV vmg_dispell(pTHX_ SV *sv, const SV *wiz) { for (mg = moremagic; mg; mg = mg->mg_moremagic) { if (mg->mg_type == PERL_MAGIC_ext && mg->mg_private == SIG_WIZ) { - const MGWIZ *z = vmg_wizard_mgwiz(mg->mg_ptr); + const vmg_wizard *z = vmg_wizard_from_sv(mg->mg_ptr); if (z->uvar) { ++uvars; break; @@ -1082,17 +1077,17 @@ STATIC int vmg_cb_call(pTHX_ SV *cb, unsigned int flags, SV *sv, ...) { vmg_cb_call(aTHX_ (I), VMG_CB_FLAGS((OI), 3), (S), (A1), (A2), (A3)) STATIC int vmg_svt_get(pTHX_ SV *sv, MAGIC *mg) { - const MGWIZ *w = vmg_wizard_mgwiz(mg->mg_ptr); + const vmg_wizard *w = vmg_wizard_from_sv(mg->mg_ptr); return vmg_cb_call1(w->cb_get, w->opinfo, sv, mg->mg_obj); } STATIC int vmg_svt_set(pTHX_ SV *sv, MAGIC *mg) { - const MGWIZ *w = vmg_wizard_mgwiz(mg->mg_ptr); + const vmg_wizard *w = vmg_wizard_from_sv(mg->mg_ptr); return vmg_cb_call1(w->cb_set, w->opinfo, sv, mg->mg_obj); } STATIC U32 vmg_svt_len(pTHX_ SV *sv, MAGIC *mg) { - const MGWIZ *w = vmg_wizard_mgwiz(mg->mg_ptr); + const vmg_wizard *w = vmg_wizard_from_sv(mg->mg_ptr); unsigned int opinfo = w->opinfo; U32 len, ret; SV *svr; @@ -1146,12 +1141,12 @@ STATIC U32 vmg_svt_len(pTHX_ SV *sv, MAGIC *mg) { } STATIC int vmg_svt_clear(pTHX_ SV *sv, MAGIC *mg) { - const MGWIZ *w = vmg_wizard_mgwiz(mg->mg_ptr); + const vmg_wizard *w = vmg_wizard_from_sv(mg->mg_ptr); return vmg_cb_call1(w->cb_clear, w->opinfo, sv, mg->mg_obj); } STATIC int vmg_svt_free(pTHX_ SV *sv, MAGIC *mg) { - const MGWIZ *w; + const vmg_wizard *w; int ret = 0; SV *svr; @@ -1162,7 +1157,7 @@ STATIC int vmg_svt_free(pTHX_ SV *sv, MAGIC *mg) { if (PL_dirty) return 0; - w = vmg_wizard_mgwiz(mg->mg_ptr); + w = vmg_wizard_from_sv(mg->mg_ptr); /* So that it survives the temp cleanup below */ SvREFCNT_inc_simple_void(sv); @@ -1212,8 +1207,8 @@ STATIC int vmg_svt_copy(pTHX_ SV *sv, MAGIC *mg, SV *nsv, const char *key, int keylen # endif ) { + const vmg_wizard *w = vmg_wizard_from_sv(mg->mg_ptr); SV *keysv; - const MGWIZ *w = vmg_wizard_mgwiz(mg->mg_ptr); int ret; if (keylen == HEf_SVKEY) { @@ -1239,7 +1234,7 @@ STATIC int vmg_svt_dup(pTHX_ MAGIC *mg, CLONE_PARAMS *param) { #if MGf_LOCAL STATIC int vmg_svt_local(pTHX_ SV *nsv, MAGIC *mg) { - const MGWIZ *w = vmg_wizard_mgwiz(mg->mg_ptr); + const vmg_wizard *w = vmg_wizard_from_sv(mg->mg_ptr); return vmg_cb_call1(w->cb_local, w->opinfo, nsv, mg->mg_obj); } #endif /* MGf_LOCAL */ @@ -1268,7 +1263,7 @@ STATIC I32 vmg_svt_val(pTHX_ IV action, SV *sv) { action &= HV_FETCH_ISSTORE | HV_FETCH_ISEXISTS | HV_FETCH_LVALUE | HV_DELETE; for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) { - const MGWIZ *w; + const vmg_wizard *w; switch (mg->mg_type) { case PERL_MAGIC_ext: break; @@ -1279,7 +1274,7 @@ STATIC I32 vmg_svt_val(pTHX_ IV action, SV *sv) { continue; } if (mg->mg_private != SIG_WIZ) continue; - w = vmg_wizard_mgwiz(mg->mg_ptr); + w = vmg_wizard_from_sv(mg->mg_ptr); switch (w->uvar) { case 0: continue; @@ -1418,10 +1413,10 @@ PPCODE: SV *_wizard(...) PROTOTYPE: DISABLE PREINIT: - I32 i = 0; - MGWIZ *w; + vmg_wizard *w; MGVTBL *t; SV *cb, *op_info, *copy_key; + I32 i = 0; CODE: if (items != 9 #if MGf_LOCAL @@ -1433,7 +1428,7 @@ CODE: ) { croak(vmg_wrongargnum); } op_info = ST(i++); - w = vmg_mgwiz_alloc(SvOK(op_info) ? SvUV(op_info) : 0); + w = vmg_wizard_alloc(SvOK(op_info) ? SvUV(op_info) : 0); t = vmg_vtable_vtbl(w->vtable); VMG_SET_CB(ST(i++), data); @@ -1462,7 +1457,7 @@ CODE: w->uvar = SvTRUE(copy_key) ? 2 : 1; #endif /* VMG_UVAR */ - RETVAL = newRV_noinc(vmg_wizard_new(w)); + RETVAL = newRV_noinc(vmg_wizard_sv_new(w)); OUTPUT: RETVAL @@ -1476,7 +1471,7 @@ CODE: i = items - 2; args = &ST(2); } - RETVAL = newSVuv(vmg_cast(SvRV(sv), vmg_wizard_validate(wiz), args, i)); + RETVAL = newSVuv(vmg_cast(SvRV(sv), vmg_wizard_sv_validate(wiz), args, i)); OUTPUT: RETVAL @@ -1486,7 +1481,7 @@ PROTOTYPE: \[$@%&*]$ PREINIT: SV *data; PPCODE: - data = vmg_data_get(SvRV(sv), vmg_wizard_validate(wiz)); + data = vmg_data_get(SvRV(sv), vmg_wizard_sv_validate(wiz)); if (!data) XSRETURN_EMPTY; ST(0) = data; @@ -1495,6 +1490,6 @@ PPCODE: SV *dispell(SV *sv, SV *wiz) PROTOTYPE: \[$@%&*]$ CODE: - RETVAL = newSVuv(vmg_dispell(SvRV(sv), vmg_wizard_validate(wiz))); + RETVAL = newSVuv(vmg_dispell(SvRV(sv), vmg_wizard_sv_validate(wiz))); OUTPUT: RETVAL