X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=xs-src%2FMouseUtil.xs;h=d8e3f4cf5f59fdd128c3cc74ae2e6364696906e2;hp=93160fc13677103482531569328ba5579fcf04b8;hb=431e4817af5380b349d562cafde91777db982a2a;hpb=ebe91068002fbe34a924a0a9e2cd79553867938c diff --git a/xs-src/MouseUtil.xs b/xs-src/MouseUtil.xs index 93160fc..d8e3f4c 100644 --- a/xs-src/MouseUtil.xs +++ b/xs-src/MouseUtil.xs @@ -108,8 +108,12 @@ mouse_throw_error(SV* const metaobject, SV* const data /* not used */, const cha PUSHs(metaobject); mPUSHs(message); - mPUSHs(newSVpvs("depth")); - mPUSHi(-1); + if(data){ /* extra arg, might be useful for debugging */ + mPUSHs(newSVpsv("data")); + PUSHs(data); + mPUSHs(newSVpvs("depth")); + mPUSHi(-1); + } PUTBACK; @@ -202,8 +206,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* @@ -286,6 +289,29 @@ CODE: } bool +is_valid_class_name(SV* sv) +CODE: +{ + SvGETMAGIC(sv); + if(SvPOKp(sv) && SvCUR(sv) > 0){ + UV i; + RETVAL = TRUE; + for(i = 0; i < SvCUR(sv); i++){ + char const c = SvPVX(sv)[i]; + if(!(isALNUM(c) || c == ':')){ + RETVAL = FALSE; + break; + } + } + } + else{ + RETVAL = SvNIOKp(sv) ? TRUE : FALSE; + } +} +OUTPUT: + RETVAL + +bool is_class_loaded(SV* sv) void @@ -378,6 +404,6 @@ PPCODE: } if(predicate_name == NULL){ /* anonymous predicate */ - XPUSHs( newRV_noinc((SV*)xsub) ); + mXPUSHs( newRV_inc((SV*)xsub) ); } }