#include "mouse.h"
-#define CHECK_INSTANCE(instance) STMT_START{ \
- if(!(SvROK(instance) && SvTYPE(SvRV(instance)) == SVt_PVHV)){ \
- croak("Invalid object instance"); \
- } \
+#define CHECK_INSTANCE(instance) STMT_START{ \
+ if(!(SvROK(instance) && SvTYPE(SvRV(instance)) == SVt_PVHV)){ \
+ croak("Invalid object instance"); \
+ } \
} STMT_END
PUSHs(svp ? *svp : &PL_sv_undef);
}
}
- else if(flags & MOUSEf_TC_IS_HASHREF){
+ else{
HV* hv;
HE* he;
+ assert(flags & MOUSEf_TC_IS_HASHREF);
+
if(!IsHashRef(value)){
croak("Mouse-panic: Not a HASH reference");
}
SV* const trigger = mcall0s(MOUSE_mg_attribute(mg), "trigger");
dSP;
+ /* NOTE: triggers can remove value, so
+ value must be copied here,
+ revealed by Net::Google::DataAPI (DANJOU).
+ */
+ value = sv_mortalcopy(value);
+
PUSHMARK(SP);
EXTEND(SP, 2);
PUSHs(self);
PUSHs(value);
PUTBACK;
- call_sv(trigger, G_VOID | G_DISCARD);
+ call_sv_safe(trigger, G_VOID | G_DISCARD);
/* need not SPAGAIN */
+
+ assert(SvTYPE(value) != SVTYPEMASK);
}
PUSH_VALUE(value, flags);
_generate_clearer(klass, SV* attr, metaclass)
CODE:
{
- SV* const slot = mcall0s(attr, "name");
+ SV* const slot = mcall0(attr, mouse_name);
STRLEN len;
const char* const pv = SvPV_const(slot, len);
RETVAL = mouse_simple_accessor_generate(aTHX_ NULL, pv, len, XS_Mouse_simple_clearer, NULL, 0);
_generate_predicate(klass, SV* attr, metaclass)
CODE:
{
- SV* const slot = mcall0s(attr, "name");
+ SV* const slot = mcall0(attr, mouse_name);
STRLEN len;
const char* const pv = SvPV_const(slot, len);
RETVAL = mouse_simple_accessor_generate(aTHX_ NULL, pv, len, XS_Mouse_simple_predicate, NULL, 0);