As what we're doing is generating subroutines, which are methods, we
Nicholas Clark [Tue, 27 Dec 2005 17:24:11 +0000 (17:24 +0000)]
need to invalidate cached methods. For constant.pm we need to create
&Internals::inc_sub_generation

p4raw-id: //depot/perl@26502

lib/ExtUtils/Constant/ProxySubs.pm
lib/constant.pm
universal.c

index 921da9a..4317e1e 100644 (file)
@@ -338,6 +338,9 @@ EOBOOT
     }
 
     print $xs_fh <<EOCONSTANT
+    /* As we've been creating subroutines, we better invalidate any cached
+       methods  */
+    ++PL_sub_generation;
   }
 
 void
index d6c8a09..0b8efb3 100644 (file)
@@ -109,6 +109,7 @@ sub import {
                    # constants from cv_const_sv are read only. So we have to:
                    Internals::SvREADONLY($scalar, 1);
                    $symtab->{$name} = \$scalar;
+                   Internals::inc_sub_generation;
                } else {
                    if(!exists $symtab->{$name}) {
                        print STDERR "$name $scalar\n";
index 24aa3b8..5c147b6 100644 (file)
@@ -199,6 +199,7 @@ XS(XS_Regexp_DESTROY);
 XS(XS_Internals_hash_seed);
 XS(XS_Internals_rehash_seed);
 XS(XS_Internals_HvREHASH);
+XS(XS_Internals_inc_sub_generation);
 
 void
 Perl_boot_core_UNIVERSAL(pTHX)
@@ -247,6 +248,8 @@ Perl_boot_core_UNIVERSAL(pTHX)
     newXSproto("Internals::hash_seed",XS_Internals_hash_seed, file, "");
     newXSproto("Internals::rehash_seed",XS_Internals_rehash_seed, file, "");
     newXSproto("Internals::HvREHASH", XS_Internals_HvREHASH, file, "\\%");
+    newXSproto("Internals::inc_sub_generation",XS_Internals_inc_sub_generation,
+              file, "");
 }
 
 
@@ -949,6 +952,17 @@ XS(XS_Internals_HvREHASH)  /* Subject to change  */
     Perl_croak(aTHX_ "Internals::HvREHASH $hashref");
 }
 
+XS(XS_Internals_inc_sub_generation)
+{
+    /* Using dXSARGS would also have dITEM and dSP,
+     * which define 2 unused local variables.  */
+    dAXMARK;
+    PERL_UNUSED_ARG(cv);
+    PERL_UNUSED_VAR(mark);
+    ++PL_sub_generation;
+    XSRETURN_EMPTY;
+}
+
 /*
  * Local variables:
  * c-indentation-style: bsd