X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=xs-src%2FMouseUtil.xs;h=006eab252405213ac81e496e9e58ef13b49fb048;hp=e437c17333623dae3138bef52a4d89e53fd7f7f2;hb=73337709bfbc1dcba14487c8d7725e798c0713f7;hpb=fd16872522eea1e9d9c77c8e822c89721ce8cb06 diff --git a/xs-src/MouseUtil.xs b/xs-src/MouseUtil.xs index e437c17..006eab2 100644 --- a/xs-src/MouseUtil.xs +++ b/xs-src/MouseUtil.xs @@ -202,8 +202,7 @@ mouse_call1 (pTHX_ SV* const self, SV* const method, SV* const arg1) { int mouse_predicate_call(pTHX_ SV* const self, SV* const method) { - SV* const value = mcall0(self, method); - return SvTRUE(value); + return sv_true( mcall0(self, method) ); } SV* @@ -215,7 +214,7 @@ mouse_get_metaclass(pTHX_ SV* metaclass_name){ assert(MY_CXT.metas); if(IsObject(metaclass_name)){ - HV* const stash = SvSTASH(metaclass_name); + HV* const stash = SvSTASH(SvRV(metaclass_name)); metaclass_name = newSVpvn_share(HvNAME_get(stash), HvNAMELEN_get(stash), 0U); sv_2mortal(metaclass_name); @@ -347,29 +346,37 @@ OUTPUT: RETVAL void -generate_isa_predicate_for(SV* klass, SV* predicate_name = NULL) +generate_isa_predicate_for(SV* arg, SV* predicate_name = NULL) +ALIAS: + generate_isa_predicate_for = 0 + generate_can_predicate_for = 1 PPCODE: { const char* name_pv = NULL; CV* xsub; - SvGETMAGIC(klass); + SvGETMAGIC(arg); - if(!SvOK(klass)){ - croak("You must define a class name"); + if(!SvOK(arg)){ + croak("You must define %s", ix == 0 ? "a class name" : "method names"); } if(predicate_name){ SvGETMAGIC(predicate_name); if(!SvOK(predicate_name)){ - croak("You must define a predicate_name"); + croak("You must define %s", "a predicate name"); } name_pv = SvPV_nolen_const(predicate_name); } - xsub = mouse_generate_isa_predicate_for(aTHX_ klass, name_pv); + if(ix == 0){ + xsub = mouse_generate_isa_predicate_for(aTHX_ arg, name_pv); + } + else{ + xsub = mouse_generate_can_predicate_for(aTHX_ arg, name_pv); + } if(predicate_name == NULL){ /* anonymous predicate */ - XPUSHs( newRV_noinc((SV*)xsub) ); + mXPUSHs( newRV_inc((SV*)xsub) ); } }