/* ... Construct private data .............................................. */
-STATIC SV *vmg_data_new(pTHX_ SV *ctor, SV *sv, AV *args) {
-#define vmg_data_new(C, S, A) vmg_data_new(aTHX_ (C), (S), (A))
+STATIC SV *vmg_data_new(pTHX_ SV *ctor, SV *sv, SV **args, I32 items) {
+#define vmg_data_new(C, S, A, I) vmg_data_new(aTHX_ (C), (S), (A), (I))
+ I32 i;
SV *nsv;
- I32 i, alen = (args == NULL) ? 0 : av_len(args);
dSP;
SAVETMPS;
PUSHMARK(SP);
- EXTEND(SP, alen + 1);
+ EXTEND(SP, items + 1);
PUSHs(sv_2mortal(newRV_inc(sv)));
- for (i = 0; i < alen; ++i)
- PUSHs(*av_fetch(args, i, 0));
+ for (i = 0; i < items; ++i)
+ PUSHs(args[i]);
PUTBACK;
call_sv(ctor, G_SCALAR);
}
#endif /* VMG_UVAR */
-STATIC UV vmg_cast(pTHX_ SV *sv, const SV *wiz, AV *args) {
-#define vmg_cast(S, W, A) vmg_cast(aTHX_ (S), (W), (A))
+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, *moremagic = NULL;
SV *data;
const MGWIZ *w;
w = vmg_wizard_mgwiz(wiz);
oldgmg = SvGMAGICAL(sv);
- data = (w->cb_data) ? vmg_data_new(w->cb_data, sv, args) : NULL;
+ data = (w->cb_data) ? vmg_data_new(w->cb_data, sv, args, items) : NULL;
mg = sv_magicext(sv, data, PERL_MAGIC_ext, w->vtbl, (const char *) wiz, HEf_SVKEY);
mg->mg_private = SIG_WIZ;
#if MGf_COPY
SV *cast(SV *sv, SV *wiz, ...)
PROTOTYPE: \[$@%&*]$@
PREINIT:
- AV *args = NULL;
+ SV **args = NULL;
+ I32 i = 0;
SV *ret;
CODE:
if (items > 2) {
- I32 i;
- args = newAV();
- av_fill(args, items - 2);
- for (i = 2; i < items; ++i) {
- SV *arg = ST(i);
- SvREFCNT_inc(arg);
- if (av_store(args, i - 2, arg) == NULL) croak(vmg_argstorefailed);
- }
+ i = items - 2;
+ args = &ST(2);
}
- ret = newSVuv(vmg_cast(SvRV(sv), vmg_wizard_validate(wiz), args));
+ ret = newSVuv(vmg_cast(SvRV(sv), vmg_wizard_validate(wiz), args, i));
SvREFCNT_dec(args);
RETVAL = ret;
OUTPUT: