#endif /* !VMG_THREADSAFE */
-/* --- MGWIZ structure ----------------------------------------------------- */
+/* --- <vmg_wizard> structure ---------------------------------------------- */
typedef struct {
vmg_vtable *vtable;
#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);
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;
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;
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
#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
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
#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;
}
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;
}
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;
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;
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. */
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;
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;
}
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;
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);
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) {
#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 */
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;
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;
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
) { 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);
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
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
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;
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