STATIC SV *vmg_wizard_new(pTHX_ const MGWIZ *w) {
#define vmg_wizard_new(W) vmg_wizard_new(aTHX_ (W))
- SV *wiz = newSVuv(PTR2UV(w));
+ SV *wiz = newSVuv(PTR2IV(w));
if (w) {
MAGIC *mg = sv_magicext(wiz, NULL, PERL_MAGIC_ext, &vmg_wizard_vtbl, NULL, 0);
return wiz;
}
-STATIC SV *vmg_wizard_validate(pTHX_ SV *wiz) {
+STATIC const SV *vmg_wizard_validate(pTHX_ const SV *wiz) {
#define vmg_wizard_validate(W) vmg_wizard_validate(aTHX_ (W))
if (SvROK(wiz)) {
wiz = SvRV(wiz);
croak(vmg_invalid_wiz);
}
-#define vmg_wizard_id(W) SvUV((SV *) (W))
+#define vmg_wizard_id(W) SvIVX((const SV *) (W))
#define vmg_wizard_main_mgwiz(W) INT2PTR(const MGWIZ *, vmg_wizard_id(W))
/* ... Wizard destructor ................................................... */
#if VMG_THREADSAFE
-STATIC const MGWIZ *vmg_wizard_mgwiz(pTHX_ SV *wiz) {
-#define vmg_wizard_mgwiz(W) vmg_wizard_mgwiz(aTHX_ ((SV *) (W)))
+STATIC const MGWIZ *vmg_wizard_mgwiz(pTHX_ const SV *wiz) {
+#define vmg_wizard_mgwiz(W) vmg_wizard_mgwiz(aTHX_ ((const SV *) (W)))
const MGWIZ *w;
w = vmg_wizard_main_mgwiz(wiz);
/* --- User-level functions implementation --------------------------------- */
-STATIC const MAGIC *vmg_find(pTHX_ const SV *sv, SV *wiz) {
-#define vmg_find(S, W) vmg_find(aTHX_ (S), (W))
+STATIC const MAGIC *vmg_find(const SV *sv, const SV *wiz) {
const MAGIC *mg, *moremagic;
UV wid;
return nsv;
}
-STATIC SV *vmg_data_get(pTHX_ SV *sv, SV *wiz) {
+STATIC SV *vmg_data_get(pTHX_ SV *sv, const SV *wiz) {
#define vmg_data_get(S, W) vmg_data_get(aTHX_ (S), (W))
const MAGIC *mg = vmg_find(sv, wiz);
return mg ? mg->mg_obj : NULL;
}
#endif /* VMG_UVAR */
-STATIC UV vmg_cast(pTHX_ SV *sv, SV *wiz, AV *args) {
+STATIC UV vmg_cast(pTHX_ SV *sv, const SV *wiz, AV *args) {
#define vmg_cast(S, W, A) vmg_cast(aTHX_ (S), (W), (A))
MAGIC *mg, *moremagic = NULL;
SV *data;
return 1;
}
-STATIC UV vmg_dispell(pTHX_ SV *sv, SV *wiz) {
+STATIC UV vmg_dispell(pTHX_ SV *sv, const SV *wiz) {
#define vmg_dispell(S, W) vmg_dispell(aTHX_ (S), (W))
#if VMG_UVAR
U32 uvars = 0;
AV *args = NULL;
SV *ret;
CODE:
- wiz = vmg_wizard_validate(wiz);
if (items > 2) {
I32 i;
args = newAV();
if (av_store(args, i - 2, arg) == NULL) croak(vmg_argstorefailed);
}
}
- ret = newSVuv(vmg_cast(SvRV(sv), wiz, args));
+ ret = newSVuv(vmg_cast(SvRV(sv), vmg_wizard_validate(wiz), args));
SvREFCNT_dec(args);
RETVAL = ret;
OUTPUT:
PREINIT:
SV *data;
PPCODE:
- wiz = vmg_wizard_validate(wiz);
- data = vmg_data_get(SvRV(sv), wiz);
+ data = vmg_data_get(SvRV(sv), vmg_wizard_validate(wiz));
if (!data)
XSRETURN_EMPTY;
ST(0) = data;
SV *dispell(SV *sv, SV *wiz)
PROTOTYPE: \[$@%&*]$
CODE:
- wiz = vmg_wizard_validate(wiz);
- RETVAL = newSVuv(vmg_dispell(SvRV(sv), wiz));
+ RETVAL = newSVuv(vmg_dispell(SvRV(sv), vmg_wizard_validate(wiz)));
OUTPUT:
RETVAL