Add mouse_get_xa()
[gitmo/Mouse.git] / xs-src / MouseUtil.xs
index 2e7f50b..f99c6f6 100644 (file)
@@ -156,9 +156,8 @@ mouse_is_class_loaded(pTHX_ SV * const klass){
 }
 
 
-SV *
-mouse_call0 (pTHX_ SV *const self, SV *const method)
-{
+SV*
+mouse_call0 (pTHX_ SV* const self, SV* const method) {
     dSP;
     SV *ret;
 
@@ -175,9 +174,8 @@ mouse_call0 (pTHX_ SV *const self, SV *const method)
     return ret;
 }
 
-SV *
-mouse_call1 (pTHX_ SV *const self, SV *const method, SV* const arg1)
-{
+SV*
+mouse_call1 (pTHX_ SV* const self, SV* const method, SV* const arg1) {
     dSP;
     SV *ret;
 
@@ -196,12 +194,26 @@ mouse_call1 (pTHX_ SV *const self, SV *const method, SV* const arg1)
     return ret;
 }
 
+int
+mouse_predicate_call(pTHX_ SV* const self, SV* const method) {
+    SV* const value = mcall0(self, method);
+    return SvTRUE(value);
+}
+
 SV*
-mouse_get_metaclass_by_name(pTHX_ SV* const metaclass_name){
+mouse_get_metaclass(pTHX_ SV* metaclass_name){
     CV* const get_metaclass  = get_cvs("Mouse::Util::get_metaclass_by_name", TRUE);
     SV* metaclass;
     dSP;
 
+    assert(metaclass_name);
+    if(IsObject(metaclass_name)){
+        HV* const stash = SvSTASH(metaclass_name);
+
+        metaclass_name = newSVpvn_share(HvNAME_get(stash), HvNAMELEN_get(stash), 0U);
+        sv_2mortal(metaclass_name);
+    }
+
     PUSHMARK(SP);
     XPUSHs(metaclass_name);
     PUTBACK;