Ensure backward compatiblity
gfx [Sat, 31 Oct 2009 09:00:34 +0000 (18:00 +0900)]
xs-src/MouseTypeConstraints.xs

index 6f0fe6c..27bf1a3 100644 (file)
@@ -19,26 +19,22 @@ typedef int (*check_fptr_t)(pTHX_ SV* const data, SV* const sv);
 int
 mouse_tc_check(pTHX_ SV* const tc_code, SV* const sv) {
     CV* const cv = (CV*)SvRV(tc_code);
-    assert(SvTYPE(cv) == Svt_PVCV);
+    assert(SvTYPE(cv) == SVt_PVCV);
 
-    if(CvISXSUB(cv)){ /* can be built-in tc */
-        if(CvXSUB(cv) == XS_Mouse__Util__TypeConstraints_Item){
-            assert(CvXSUBANY(cv).any_iv > 0);
+    if(CvXSUB(cv) == XS_Mouse__Util__TypeConstraints_Item){ /* built-in */
+        assert(CvXSUBANY(cv).any_iv > 0);
 
-            return mouse_builtin_tc_check(aTHX_ CvXSUBANY(cv).any_iv, sv);
-        }
-        else if(CvXSUB(cv) == XS_Mouse_parameterized_check){
-            MAGIC* const mg = (MAGIC*)CvXSUBANY(cv).any_ptr;
+        return mouse_builtin_tc_check(aTHX_ CvXSUBANY(cv).any_iv, sv);
+    }
+    else if(CvXSUB(cv) == XS_Mouse_parameterized_check){ /* built-in, parameterizad */
+        MAGIC* const mg = (MAGIC*)CvXSUBANY(cv).any_ptr;
 
-            assert(CvXSUBANY(cv).any_ptr != NULL);
+        assert(CvXSUBANY(cv).any_ptr != NULL);
 
-            /* call the check function directly, skipping call_sv() */
-            return CALL_FPTR((check_fptr_t)mg->mg_ptr)(aTHX_ mg->mg_obj, sv);
-        }
+        /* call the check function directly, skipping call_sv() */
+        return CALL_FPTR((check_fptr_t)mg->mg_ptr)(aTHX_ mg->mg_obj, sv);
     }
-
-    /* user-defined type constraints */
-    {
+    else { /* custom */
         int ok;
         dSP;