fixing theplers test
[gitmo/Class-MOP.git] / MOP.xs
diff --git a/MOP.xs b/MOP.xs
index 47d02d4..f1071dd 100644 (file)
--- a/MOP.xs
+++ b/MOP.xs
@@ -5,10 +5,6 @@
 #include "ppport.h"
 
 /*
-check_method_cache_flag:
-  check the PL_sub_generation 
-  ISA/method cache thing
-
 get_code_info:
   Pass in a coderef, returns:
   [ $pkg_name, $coderef_name ] ie:
@@ -17,13 +13,7 @@ get_code_info:
 
 MODULE = Class::MOP   PACKAGE = Class::MOP
 
-SV*
-check_package_cache_flag(pkg)
-  SV* pkg
-  CODE:
-    RETVAL = newSViv(PL_sub_generation);
-  OUTPUT:
-    RETVAL
+PROTOTYPES: ENABLE
 
 void
 get_code_info(coderef)
@@ -34,8 +24,21 @@ get_code_info(coderef)
   PPCODE:
     if( SvOK(coderef) && SvROK(coderef) && SvTYPE(SvRV(coderef)) == SVt_PVCV){
       coderef = SvRV(coderef);
-      name    = GvNAME( CvGV(coderef) );
-      pkg     = HvNAME( GvSTASH(CvGV(coderef)) );
+      /* I think this only gets triggered with a mangled coderef, but if
+         we hit it without the guard, we segfault. The slightly odd return
+         value strikes me as an improvement (mst)
+      */
+#ifdef isGV_with_GP
+      if ( isGV_with_GP(CvGV(coderef))) {
+#endif
+        pkg     = HvNAME( GvSTASH(CvGV(coderef)) );
+        name    = GvNAME( CvGV(coderef) );
+#ifdef isGV_with_GP
+      } else {
+        pkg     = "__UNKNOWN__";
+        name    = "__ANON__";
+      }
+#endif
 
       EXTEND(SP, 2);
       PUSHs(newSVpvn(pkg, strlen(pkg)));