if(items < 1){
croak("Too few arguments for %s", GvNAME(CvGV(cv)));
}
-
/* NOTE: If self has GETMAGIC, $self->accessor will invoke GETMAGIC
- * before calling methods, so SvGETMAGIC(self) is not necessarily needed here.
+ * before calling methods, so SvGETMAGIC(self) is not required here.
*/
-
return ST(0);
}
xsub = newXS(NULL, accessor_impl, __FILE__);
sv_2mortal((SV*)xsub);
- mg = sv_magicext((SV*)xsub, MOUSE_xa_slot(xa), PERL_MAGIC_ext, &mouse_accessor_vtbl, (char*)xa, HEf_SVKEY);
+ mg = sv_magicext((SV*)xsub, MOUSE_xa_slot(xa),
+ PERL_MAGIC_ext, &mouse_accessor_vtbl, (char*)xa, HEf_SVKEY);
MOUSE_mg_flags(mg) = (U16)MOUSE_xa_flags(xa);
/* NOTE:
- * although we use MAGIC for gc, we also store mg to CvXSUBANY for efficiency (gfx)
+ * although we use MAGIC for gc, we also store mg to
+ * CvXSUBANY for efficiency (gfx)
*/
CvXSUBANY(xsub).any_ptr = (void*)mg;
}
-#define PUSH_VALUE(value, flags) STMT_START { \
- if((flags) & MOUSEf_ATTR_SHOULD_AUTO_DEREF && GIMME_V == G_ARRAY){ \
- mouse_push_values(aTHX_ value, (flags)); \
- } \
- else{ \
- dSP; \
- XPUSHs(value ? value : &PL_sv_undef); \
- PUTBACK; \
- } \
- } STMT_END \
-
/* pushes return values, does auto-deref if needed */
static void
mouse_push_values(pTHX_ SV* const value, U16 const flags){
PUTBACK;
}
+STATIC_INLINE void
+mouse_push_value(pTHX_ SV* const value, U16 const flags) {
+ if(flags & MOUSEf_ATTR_SHOULD_AUTO_DEREF && GIMME_V == G_ARRAY){
+ mouse_push_values(aTHX_ value, flags);
+ }
+ else{
+ dSP;
+ XPUSHs(value ? value : &PL_sv_undef);
+ PUTBACK;
+ }
+}
+
static void
mouse_attr_get(pTHX_ SV* const self, MAGIC* const mg){
U16 const flags = MOUSE_mg_flags(mg);
value = mouse_xa_set_default(aTHX_ MOUSE_mg_xa(mg), self);
}
- PUSH_VALUE(value, flags);
+ mouse_push_value(aTHX_ value, flags);
}
static void
assert(SvTYPE(value) != SVTYPEMASK);
}
- PUSH_VALUE(value, flags);
+ mouse_push_value(aTHX_ value, flags);
}
XS(XS_Mouse_accessor)
MAGIC* mg;
if(!fq_name){
- /* anonymous xsubs need sv_2mortal */
+ /* anonymous xsubs need sv_2mortal() */
sv_2mortal((SV*)xsub);
}
- mg = sv_magicext((SV*)xsub, slot, PERL_MAGIC_ext, &mouse_accessor_vtbl, (char*)dptr, dlen);
+ mg = sv_magicext((SV*)xsub, slot,
+ PERL_MAGIC_ext, &mouse_accessor_vtbl, (char*)dptr, dlen);
+
SvREFCNT_dec(slot); /* sv_magicext() increases refcnt in mg_obj */
if(dlen == HEf_SVKEY){
SvREFCNT_dec(dptr);
}
/* NOTE:
- * although we use MAGIC for gc, we also store mg to CvXSUBANY for efficiency (gfx)
+ * although we use MAGIC for gc, we also store mg to CvXSUBANY
+ * for efficiency (gfx)
*/
CvXSUBANY(xsub).any_ptr = (void*)mg;