Include method name in immutable methods (fixes #49680)
[gitmo/Class-MOP.git] / xs / MOP.xs
index e185fa4..959df7a 100644 (file)
--- a/xs/MOP.xs
+++ b/xs/MOP.xs
@@ -3,7 +3,6 @@
 SV *mop_method_metaclass;
 SV *mop_associated_metaclass;
 SV *mop_wrap;
-SV *mop_namespace;
 
 static bool
 find_method (const char *key, STRLEN keylen, SV *val, void *ud)
@@ -30,7 +29,6 @@ BOOT:
     mop_method_metaclass     = newSVpvs("method_metaclass");
     mop_wrap                 = newSVpvs("wrap");
     mop_associated_metaclass = newSVpvs("associated_metaclass");
-    mop_namespace            = newSVpvs("namespace");
 
     MOP_CALL_BOOT (boot_Class__MOP__Package);
     MOP_CALL_BOOT (boot_Class__MOP__Attribute);
@@ -45,6 +43,7 @@ get_code_info(coderef)
         char *pkg  = NULL;
         char *name = NULL;
     PPCODE:
+        SvGETMAGIC(coderef);
         if (mop_get_code_info(coderef, &pkg, &name)) {
             EXTEND(SP, 2);
             mPUSHs(newSVpv(pkg, 0));
@@ -61,7 +60,8 @@ is_class_loaded(klass=&PL_sv_undef)
         HV *stash;
         bool found_method = FALSE;
     PPCODE:
-        if (!SvPOK(klass) || !SvCUR(klass)) {
+        SvGETMAGIC(klass);
+        if (!(SvPOKp(klass) && SvCUR(klass))) { /* XXX: SvPOK does not work with magical scalars */
             XSRETURN_NO;
         }