X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=xs-src%2FMouseAccessor.xs;h=5d6bcbf42fcf19e07a1df50e5e1aa4bf782e498b;hp=f93d25f8fc10e125cee029c3ccaf02a1a589fc35;hb=2468f1d7c798da84418ca56ba71f69b6f921996d;hpb=a17f63138ec09db5e362700f2ac72da67f104786 diff --git a/xs-src/MouseAccessor.xs b/xs-src/MouseAccessor.xs index f93d25f..5d6bcbf 100644 --- a/xs-src/MouseAccessor.xs +++ b/xs-src/MouseAccessor.xs @@ -254,15 +254,8 @@ XS(XS_Mouse_simple_accessor) if(items == 1){ /* reader */ value = get_slot(self, MOUSE_mg_slot(mg)); - if(!value) { - if(MOUSE_mg_ptr(mg)){ - /* the default value must be a SV */ - assert(MOUSE_mg_len(mg) == HEf_SVKEY); - value = (SV*)MOUSE_mg_ptr(mg); - } - else{ - value = &PL_sv_undef; - } + if(!value){ + value = &PL_sv_undef; } } else if(items == 2){ /* writer */ @@ -288,7 +281,18 @@ XS(XS_Mouse_simple_reader) } value = get_slot(self, MOUSE_mg_slot(mg)); - ST(0) = value ? value : &PL_sv_undef; + if(!value) { + if(MOUSE_mg_ptr(mg)){ + /* the default value must be a SV */ + assert(MOUSE_mg_len(mg) == HEf_SVKEY); + value = (SV*)MOUSE_mg_ptr(mg); + } + else{ + value = &PL_sv_undef; + } + } + + ST(0) = value; XSRETURN(1); } @@ -384,7 +388,8 @@ mouse_instance_set_slot(pTHX_ SV* const instance, SV* const slot, SV* const valu CHECK_INSTANCE(instance); he = hv_fetch_ent((HV*)SvRV(instance), slot, TRUE, 0U); sv = HeVAL(he); - sv_setsv_mg(sv, value); + sv_setsv(sv, value); + SvSETMAGIC(sv); return sv; }