Use @CARP_NOT instead of %Carp::Internal
[gitmo/Mouse.git] / xs-src / MouseUtil.xs
index 006eab2..d8e3f4c 100644 (file)
@@ -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;
 
@@ -285,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