cvsuser     04/06/22 01:36:00

  Modified:    .        CREDITS
               classes  parrotio.pmc
               include/parrot global.h
               ops      var.ops
               src      global.c packfile.c
               t/pmc    io.t
  Log:
  NCI and globals 1
  * convert ParrotIO to method calls (pass self in P2)
  * remove redundant ParrotIO meths
  * add Parrot global namespace interface functions
  
  Revision  Changes    Path
  1.23      +3 -0      parrot/CREDITS
  
  Index: CREDITS
  ===================================================================
  RCS file: /cvs/public/parrot/CREDITS,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -w -r1.22 -r1.23
  --- CREDITS   3 May 2004 12:28:58 -0000       1.22
  +++ CREDITS   22 Jun 2004 08:35:43 -0000      1.23
  @@ -71,6 +71,9 @@
   
   N: David M. Loyd
   
  +N: Dennis Rieks
  +D: Win32 config and build
  +
   N: Goplat
   D: Win98 and other fixes.
   
  
  
  
  1.23      +6 -14     parrot/classes/parrotio.pmc
  
  Index: parrotio.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/classes/parrotio.pmc,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -w -r1.22 -r1.23
  --- parrotio.pmc      28 May 2004 12:44:55 -0000      1.22
  +++ parrotio.pmc      22 Jun 2004 08:35:46 -0000      1.23
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: parrotio.pmc,v 1.22 2004/05/28 12:44:55 leo Exp $
  +$Id: parrotio.pmc,v 1.23 2004/06/22 08:35:46 leo Exp $
   
   =head1 NAME
   
  @@ -48,23 +48,15 @@
           Parrot_PerlUndef_class_init(interp, enum_class_PerlUndef);
   
           enter_nci_method(INTERP, enum_class_ParrotIO,
  -                         F2DPTR(PIO_close), "close", "iIP");
  +                         F2DPTR(PIO_flush), "flush", "vIO");
           enter_nci_method(INTERP, enum_class_ParrotIO,
  -                         F2DPTR(PIO_flush), "flush", "vIP");
  +                         F2DPTR(PIO_setbuf), "setbuf", "iIOi");
           enter_nci_method(INTERP, enum_class_ParrotIO,
  -                         F2DPTR(PIO_read), "read", "iIPii");
  +                         F2DPTR(PIO_setlinebuf), "setlinebuf", "iIO");
           enter_nci_method(INTERP, enum_class_ParrotIO,
  -                         F2DPTR(PIO_write), "write", "iIPii");
  +                         F2DPTR(PIO_puts), "puts", "iIOt");
           enter_nci_method(INTERP, enum_class_ParrotIO,
  -                         F2DPTR(PIO_setbuf), "setbuf", "iIPi");
  -        enter_nci_method(INTERP, enum_class_ParrotIO,
  -                         F2DPTR(PIO_setlinebuf), "setlinebuf", "iIP");
  -        enter_nci_method(INTERP, enum_class_ParrotIO,
  -                         F2DPTR(PIO_puts), "puts", "iIPt");
  -        enter_nci_method(INTERP, enum_class_ParrotIO,
  -                         F2DPTR(PIO_seek), "seek", "iIPiii");
  -        enter_nci_method(INTERP, enum_class_ParrotIO,
  -                         F2DPTR(PIO_eof), "eof", "iIP");
  +                         F2DPTR(PIO_eof), "eof", "iIO");
       }
   
   /*
  
  
  
  1.2       +4 -2      parrot/include/parrot/global.h
  
  Index: global.h
  ===================================================================
  RCS file: /cvs/public/parrot/include/parrot/global.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -w -r1.1 -r1.2
  --- global.h  19 May 2004 09:32:16 -0000      1.1
  +++ global.h  22 Jun 2004 08:35:51 -0000      1.2
  @@ -1,7 +1,7 @@
   /* global.h
    *  Copyright: 2004 The Perl Foundation.  All Rights Reserved.
    *  CVS Info
  - *     $Id: global.h,v 1.1 2004/05/19 09:32:16 jrieks Exp $
  + *     $Id: global.h,v 1.2 2004/06/22 08:35:51 leo Exp $
    *  Overview:
    *      Contains accessor functions for globals
    *  Data Structure and Algorithms:
  @@ -13,7 +13,9 @@
   #if !defined(PARROT_GLOBAL_H_GUARD)
   #define PARROT_GLOBAL_H_GUARD
   
  -PMC *Parrot_find_global(Parrot_Interp, STRING *class, STRING *globalname);
  +PMC *Parrot_find_global(Interp *, STRING *class, STRING *globalname);
  +PMC *Parrot_global_namespace(Interp *, PMC *globals, STRING *ns);
  +void Parrot_store_global(Interp *, STRING *class, STRING *globalname, PMC *pmc);
   
   #endif /* PARROT_GLOBAL_H_GUARD */
   
  
  
  
  1.19      +2 -14     parrot/ops/var.ops
  
  Index: var.ops
  ===================================================================
  RCS file: /cvs/public/parrot/ops/var.ops,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -w -r1.18 -r1.19
  --- var.ops   20 Jun 2004 10:31:35 -0000      1.18
  +++ var.ops   22 Jun 2004 08:35:54 -0000      1.19
  @@ -244,24 +244,12 @@
   =cut
   
   op store_global(in STR, in PMC) {
  -    /* XXX: All globals should go through an API */
  -    PMC * globals = interpreter->globals->stash_hash;
  -    VTABLE_set_pmc_keyed_str(interpreter, globals, $1, $2);
  +    Parrot_store_global(interpreter, NULL, $1, $2);
       goto NEXT();
   }
   
   op store_global(in STR, in STR, in PMC) {
  -    /* XXX: All globals should go through an API */
  -    PMC * globals = interpreter->globals->stash_hash;
  -    PMC * stash;
  -    if (!VTABLE_exists_keyed_str(interpreter, globals, $1)) {
  -     stash = pmc_new(interpreter, enum_class_OrderedHash);
  -     VTABLE_set_pmc_keyed_str(interpreter, globals, $1, stash);
  -    }
  -    else {
  -        stash = VTABLE_get_pmc_keyed_str(interpreter, globals, $1);
  -    }
  -    VTABLE_set_pmc_keyed_str(interpreter, stash, $2, $3);
  +    Parrot_store_global(interpreter, $1, $2, $3);
       goto NEXT();
   }
   
  
  
  
  1.2       +54 -1     parrot/src/global.c
  
  Index: global.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/global.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -w -r1.1 -r1.2
  --- global.c  19 May 2004 09:32:19 -0000      1.1
  +++ global.c  22 Jun 2004 08:35:57 -0000      1.2
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2004 The Perl Foundation.  All Rights Reserved.
  -$Id: global.c,v 1.1 2004/05/19 09:32:19 jrieks Exp $
  +$Id: global.c,v 1.2 2004/06/22 08:35:57 leo Exp $
   
   =head1 NAME
   
  @@ -87,6 +87,59 @@
   #endif
   }
   
  +/*
  +
  +=item C<PMC* Parrot_global_namespace(Interp *, PMC *globals, STRING *ns)>
  +
  +Return the stash hash of the given namespace in C<globals>.
  +If it doesn't exist yet, add it to the stash C<globals>.
  +
  +=cut
  +
  +*/
  +
  +PMC*
  +Parrot_global_namespace(Interp *interpreter, PMC *globals, STRING *names)
  +{
  +    PMC *stash;
  +
  +    if (!VTABLE_exists_keyed_str(interpreter, globals, names)) {
  +        stash = pmc_new(interpreter, enum_class_OrderedHash);
  +        VTABLE_set_pmc_keyed_str(interpreter, globals, names,
  +                stash);
  +    }
  +    else {
  +        stash = VTABLE_get_pmc_keyed_str(interpreter, globals,
  +                names);
  +    }
  +    return stash;
  +}
  +
  +/*
  +
  +=item C<void
  +Parrot_store_global(Parrot_Interp, STRING *class, STRING *globalname, PMC *)>
  +
  +Store the given PMC as global C<globalname> in the namespace C<class>. If
  +C<class> is NULL, the top-level global namespace is used.
  +
  +=cut
  +
  +*/
  +
  +void
  +Parrot_store_global(Interp *interpreter, STRING *class,
  +        STRING *globalname, PMC *pmc)
  +{
  +    PMC *globals = interpreter->globals->stash_hash;
  +    PMC *stash;
  +    if (class) {
  +        stash = Parrot_global_namespace(interpreter, globals, class);
  +    }
  +    else
  +        stash = globals;
  +    VTABLE_set_pmc_keyed_str(interpreter, stash, globalname, pmc);
  +}
   
   /*
   
  
  
  
  1.167     +3 -20     parrot/src/packfile.c
  
  Index: packfile.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/packfile.c,v
  retrieving revision 1.166
  retrieving revision 1.167
  diff -u -w -r1.166 -r1.167
  --- packfile.c        18 Jun 2004 13:07:06 -0000      1.166
  +++ packfile.c        22 Jun 2004 08:35:57 -0000      1.167
  @@ -2,7 +2,7 @@
   Copyright (C) 2001-2002 Gregor N. Purdy. All rights reserved.
   This program is free software. It is subject to the same license as
   Parrot itself.
  -$Id: packfile.c,v 1.166 2004/06/18 13:07:06 leo Exp $
  +$Id: packfile.c,v 1.167 2004/06/22 08:35:57 leo Exp $
   
   =head1 NAME
   
  @@ -2776,22 +2776,6 @@
   
   */
   
  -static PMC*
  -add_global(Parrot_Interp interpreter, PMC *globals, STRING *names)
  -{
  -    PMC *stash;
  -
  -    if (!VTABLE_exists_keyed_str(interpreter, globals, names)) {
  -        stash = pmc_new(interpreter, enum_class_OrderedHash);
  -        VTABLE_set_pmc_keyed_str(interpreter, globals, names,
  -                stash);
  -    }
  -    else {
  -        stash = VTABLE_get_pmc_keyed_str(interpreter, globals,
  -                names);
  -    }
  -    return stash;
  -}
   
   static void
   store_sub_in_namespace(Parrot_Interp interpreter, struct PackFile *pf,
  @@ -2830,8 +2814,7 @@
                   names = pfc_const->u.string;
                   if (!string_length(interpreter, names))
                       goto global_ns;
  -                stash = add_global(interpreter, globals, names);
  -                VTABLE_set_pmc_keyed_str(interpreter, stash, key, sub_pmc);
  +                Parrot_store_global(interpreter, names, key, sub_pmc);
                   break;
               case PFC_KEY:
                   part = pfc_const->u.key;
  @@ -2840,7 +2823,7 @@
   #if TRACE_PACKFILE_PMC
                       PIO_printf(interpreter, "key part %Ss\n", s);
   #endif
  -                    stash = add_global(interpreter, globals, s);
  +                    stash = Parrot_global_namespace(interpreter, globals, s);
                       globals = stash;
                   }
                   VTABLE_set_pmc_keyed_str(interpreter, stash, key, sub_pmc);
  
  
  
  1.29      +4 -4      parrot/t/pmc/io.t
  
  Index: io.t
  ===================================================================
  RCS file: /cvs/public/parrot/t/pmc/io.t,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -w -r1.28 -r1.29
  --- io.t      28 May 2004 12:45:06 -0000      1.28
  +++ io.t      22 Jun 2004 08:36:00 -0000      1.29
  @@ -1,6 +1,6 @@
   #! perl -w
   # Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -# $Id: io.t,v 1.28 2004/05/28 12:45:06 leo Exp $
  +# $Id: io.t,v 1.29 2004/06/22 08:36:00 leo Exp $
   
   =head1 NAME
   
  @@ -330,12 +330,12 @@
   
   output_is(<<'CODE', <<'OUTPUT', 'puts method');
          set S5, "ok 2\n"
  -       getstdout P5
  -       can I0, P5, "puts"
  +       getstdout P2
  +       can I0, P2, "puts"
          if I0, ok1
          print "not "
   ok1:   print "ok 1\n"
  -       find_method P0, P5, "puts"
  +       find_method P0, P2, "puts"
          invoke
          end
   CODE
  
  
  

Reply via email to