add tests for wrapping a method metaobject
[gitmo/Class-MOP.git] / mop.c
diff --git a/mop.c b/mop.c
index 16d8f53..65aa925 100644 (file)
--- a/mop.c
+++ b/mop.c
@@ -1,7 +1,7 @@
 #include "mop.h"
 
 void
-mop_call_xs (pTHX_ void (*subaddr) (pTHX_ CV *), CV *cv, SV **mark)
+mop_call_xs (pTHX_ XSPROTO(subaddr), CV *cv, SV **mark)
 {
     dSP;
     PUSHMARK(mark);
@@ -93,17 +93,15 @@ mop_get_code_info (SV *coderef, char **pkg, char **name)
        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)) );
+        GV *gv   = CvGV(coderef);
+        *pkg     = HvNAME( GvSTASH(gv) ? GvSTASH(gv) : CvSTASH(coderef) );
         *name    = GvNAME( CvGV(coderef) );
-#ifdef isGV_with_GP
     } else {
         *pkg     = "__UNKNOWN__";
         *name    = "__ANON__";
     }
-#endif
 
     return 1;
 }
@@ -149,7 +147,7 @@ mop_get_package_symbols (HV *stash, type_filter_t filter, get_package_symbols_cb
                            but that's the API */
                         key = HePV(he, keylen);
                         package = HvNAME(stash);
-                        fq = newSVpvf("%s::%s", package, key);
+                        fq = sv_2mortal(newSVpvf("%s::%s", package, key));
                         sv = (SV *)get_cv(SvPV_nolen(fq), 0);
                         break;
                     }
@@ -253,7 +251,7 @@ XS(mop_xs_simple_reader)
     dXSARGS;
 #endif
     register HE *he;
-    mop_prehashed_key_t key = CvXSUBANY(cv).any_i32;
+    mop_prehashed_key_t key = (mop_prehashed_key_t)CvXSUBANY(cv).any_i32;
     SV *self;
 
     if (items != 1) {