cvsuser     04/03/06 00:43:57

  Modified:    classes  perlstring.pmc
               t/pmc    freeze.t
  Log:
  freeze() and thaw() for PerlStrings.
  
  Revision  Changes    Path
  1.65      +43 -1     parrot/classes/perlstring.pmc
  
  Index: perlstring.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/classes/perlstring.pmc,v
  retrieving revision 1.64
  retrieving revision 1.65
  diff -u -w -r1.64 -r1.65
  --- perlstring.pmc    22 Feb 2004 17:48:41 -0000      1.64
  +++ perlstring.pmc    6 Mar 2004 08:43:52 -0000       1.65
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: perlstring.pmc,v 1.64 2004/02/22 17:48:41 mikescott Exp $
  +$Id: perlstring.pmc,v 1.65 2004/03/06 08:43:52 brentdax Exp $
   
   =head1 NAME
   
  @@ -758,6 +758,37 @@
               return s->encoding->decode(s->encoding->skip_forward(s->strstart,
                   PMC_int_val(key)));
       }
  +
  +/*
  +
  +=item C<void freeze(visit_info *info)>
  +
  +Used to archive the string.
  +
  +=cut
  +
  +*/
  +    void freeze(visit_info *info) {
  +        IMAGE_IO *io = info->image_io;
  +        SUPER(info);
  +        io->vtable->push_string(INTERP, io, PMC_str_val(SELF));
  +    }
  +
  +/*
  +
  +=item C<void thaw(visit_info *info)>
  +
  +Used to unarchive the string.
  +
  +=cut
  +
  +*/
  +    void thaw(visit_info *info) {
  +        IMAGE_IO *io = info->image_io;
  +        SUPER(info);
  +        if (info->extra_flags == EXTRA_IS_NULL)
  +            PMC_str_val(SELF) = io->vtable->shift_string(INTERP, io);
  +    }
   }
   
   /*
  @@ -777,3 +808,14 @@
    *
    * vim: expandtab shiftwidth=4:
   */
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  
  
  
  1.8       +19 -2     parrot/t/pmc/freeze.t
  
  Index: freeze.t
  ===================================================================
  RCS file: /cvs/public/parrot/t/pmc/freeze.t,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -w -r1.7 -r1.8
  --- freeze.t  22 Feb 2004 22:55:29 -0000      1.7
  +++ freeze.t  6 Mar 2004 08:43:56 -0000       1.8
  @@ -1,6 +1,6 @@
   #! perl -w
   # Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -# $Id: freeze.t,v 1.7 2004/02/22 22:55:29 mikescott Exp $
  +# $Id: freeze.t,v 1.8 2004/03/06 08:43:56 brentdax Exp $
   
   =head1 NAME
   
  @@ -16,7 +16,7 @@
   
   =cut
   
  -use Parrot::Test tests => 11;
  +use Parrot::Test tests => 12;
   use Test::More;
   
   output_is(<<'CODE', <<'OUTPUT', "freeze/thaw a PerlInt");
  @@ -34,6 +34,23 @@
   CODE
   PerlInt 777
   OUTPUT
  +
  +output_is(<<'CODE', <<'OUTPUT', "freeze/thaw a PerlString");
  +    new P1, .PerlString
  +    set P1, "foo"
  +    freeze S0, P1
  +
  +    thaw P10, S0
  +    typeof S10, P10
  +    print S10
  +    print " "
  +    print P10
  +    print "\n"
  +    end
  +CODE
  +PerlString foo
  +OUTPUT
  +
   
   output_is(<<'CODE', <<'OUTPUT', "freeze/thaw a PerlArray");
       new P0, .PerlArray
  
  
  

Reply via email to