On Tue, 21 Aug 2007 09:52:01 -0700
chromatic <[EMAIL PROTECTED]> wrote:

>       return unless -f $filename;
>       return retrieve($filename);
> 
> My preference is the latter, for clarity and context reasons.

Thanks, you're absolutely right.  Here's an updated patch.

Mark
Index: lib/Parrot/Pmc2c/Pmc2cMain.pm
===================================================================
--- lib/Parrot/Pmc2c/Pmc2cMain.pm	(revision 20762)
+++ lib/Parrot/Pmc2c/Pmc2cMain.pm	(working copy)
@@ -4,7 +4,7 @@
 use strict;
 use warnings;
 use FindBin;
-use Data::Dumper;
+use Storable;
 use Parrot::Vtable;
 use Parrot::PMC;
 use Parrot::Pmc2c::VTable;
@@ -226,7 +226,7 @@
   $self->read_dump('filename');
 
 B<Purpose:>  A F<.dump> file is the result of a call to C<dump_pmc()> and
-consists of a print-out of a hash reference Data::Dumper-style.
+consists of a binary dump of a hash reference, Storable-style.
 C<read_dump()> reads in the F<.dump> file, recreates the data structure and
 returns a new hash reference holding the data structure.
 
@@ -248,11 +248,8 @@
     my ( $self, $filename ) = @_;
     $filename = $self->find_file( filename($filename, '.dump'), 1 );
 
-    my $class;
-    eval do { slurp($filename); };
-    die $@ if $@;
-
-    return $class;
+    return unless -f $filename;
+    return retrieve($filename);
 }
 
 =head3 C<gen_c()>
Index: lib/Parrot/Pmc2c/VTable.pm
===================================================================
--- lib/Parrot/Pmc2c/VTable.pm	(revision 20762)
+++ lib/Parrot/Pmc2c/VTable.pm	(working copy)
@@ -5,7 +5,7 @@
 use warnings;
 use base qw( Exporter );
 our @EXPORT_OK = qw();
-use Data::Dumper;
+use Storable;
 use Parrot::Vtable;
 use Parrot::Pmc2c::Method;
 use Parrot::Pmc2c::UtilFunctions qw(spew);
@@ -73,9 +73,7 @@
 
     my $dump_filename = cwd() . q{/} . basename(
         Parrot::Pmc2c::UtilFunctions::filename($self->filename, '.dump') );
-    my $Dumper = Data::Dumper->new( [$self], ['class'] );
-    $Dumper->Indent(3);
-    spew($dump_filename, $Dumper->Dump);
+    store($self, $dump_filename);
     return $dump_filename;
 }
 
Index: lib/Parrot/Pmc2c/PMC.pm
===================================================================
--- lib/Parrot/Pmc2c/PMC.pm	(revision 20762)
+++ lib/Parrot/Pmc2c/PMC.pm	(working copy)
@@ -25,7 +25,7 @@
 use warnings;
 use base qw( Exporter );
 our @EXPORT_OK = qw();
-use Data::Dumper;
+use Storable;
 use Parrot::PMC;
 use Parrot::Pmc2c::UtilFunctions qw(spew);
 use Parrot::Pmc2c::Method;
@@ -61,9 +61,7 @@
     #gen_parent_lookup_info( $self, $pmc2cMain, $pmcs );
     #gen_parent_reverse_lookup_info( $self, $pmcs, $vtable_dump );
 
-    my $Dumper = Data::Dumper->new( [$self], ['class'] );
-    $Dumper->Indent(1);
-    spew($self->filename('.dump'), $Dumper->Dump);
+    store($self, $self->filename('.dump'));
 }
 
 #methods
Index: config/gen/makefiles/dynpmc_pl.in
===================================================================
--- config/gen/makefiles/dynpmc_pl.in	(revision 20762)
+++ config/gen/makefiles/dynpmc_pl.in	(working copy)
@@ -17,6 +17,10 @@
 use warnings;
 
 use File::Copy qw(copy);
+use FindBin;
+use lib "$FindBin::Bin/../..";
+use lib "$FindBin::Bin/../../lib";
+use Storable;
 
 # q[] isn't guaranteed to work, but it's safer than "" as some platforms
 # (eg FreeBSD) have ""s embedded in their substution values. q[] is used
@@ -189,8 +193,7 @@
 
     my ( %group_files, %group_libs, %pmc_group, %pmc_libs );
     for my $pmc (@pmcs) {
-        our $class;
-        require "$pmc.dump";
+        our $class = retrieve("$pmc.dump");
 
         # there can be many libs
         my %libs = %{ $class->{flags}{lib} || {} };

Reply via email to