[svn:parrot] r38932 - in trunk: . lib/Parrot/Pmc2c

Infinoid at svn.parrot.org Infinoid at svn.parrot.org
Tue May 19 14:40:19 UTC 2009


Author: Infinoid
Date: Tue May 19 14:40:19 2009
New Revision: 38932
URL: https://trac.parrot.org/parrot/changeset/38932

Log:
[pmc2c] If your filename doesn't match your pmclass name, pmc2c should emit a big nasty warning.
(It can't die() without a deprecation cycle, so this is the first step of fixing TT #665.)

Modified:
   trunk/DEPRECATED.pod
   trunk/lib/Parrot/Pmc2c/Parser.pm

Modified: trunk/DEPRECATED.pod
==============================================================================
--- trunk/DEPRECATED.pod	Tue May 19 14:39:21 2009	(r38931)
+++ trunk/DEPRECATED.pod	Tue May 19 14:40:19 2009	(r38932)
@@ -332,8 +332,8 @@
 
 When foo.pmc contains a the line "pmclass bar", pmc2c generates a pmc_foo.h
 but tries to include pmc_bar.h.  This is a bug, but it's possible someone out
-there is using it.  After deprecation, this usage will result in an error
-message.
+there is using it.  This usage will result in a warning for now; after
+deprecation, this warning will be upgraded to an error.
 
 L<https://trac.parrot.org/parrot/ticket/665>
 

Modified: trunk/lib/Parrot/Pmc2c/Parser.pm
==============================================================================
--- trunk/lib/Parrot/Pmc2c/Parser.pm	Tue May 19 14:39:21 2009	(r38931)
+++ trunk/lib/Parrot/Pmc2c/Parser.pm	Tue May 19 14:40:19 2009	(r38932)
@@ -15,6 +15,7 @@
 use Parrot::Pmc2c::Emitter ();
 use Parrot::Pmc2c::UtilFunctions qw(count_newlines filename slurp);
 use Text::Balanced 'extract_bracketed';
+use File::Basename qw(basename);
 
 =head1 NAME
 
@@ -65,6 +66,11 @@
     my ( $preamble, $pmcname, $flags, $parents, $pmcbody, $post, $chewed_lines ) =
         parse_top_level($code);
 
+    my $filebase = basename($filename);
+    $filebase =~ s/\.pmc$//;
+    # Note: this can be changed to a die() after the 1.4 release. (TT #665)
+    warn("PMC filename $filebase.pmc does not match pmclass name $pmcname!\n")
+        unless lc($filebase) eq lc($pmcname);
     my $pmc = Parrot::Pmc2c::PMC->create($pmcname);
     $pmc->preamble( Parrot::Pmc2c::Emitter->text( $preamble, $filename, 1 ) );
     $pmc->name($pmcname);


More information about the parrot-commits mailing list