cvsuser     04/07/21 04:42:41

  Modified:    classes  coroutine.pmc iterator.pmc
               languages/python pie-thon.pl
               languages/python/t/basic oo_attr.t
               src      objects.c py_func.c
  Log:
  Pie-thon 85 - more iteration on objects
  
  Revision  Changes    Path
  1.38      +8 -1      parrot/classes/coroutine.pmc
  
  Index: coroutine.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/classes/coroutine.pmc,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -w -r1.37 -r1.38
  --- coroutine.pmc     20 Jul 2004 06:52:00 -0000      1.37
  +++ coroutine.pmc     21 Jul 2004 11:42:32 -0000      1.38
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: coroutine.pmc,v 1.37 2004/07/20 06:52:00 leo Exp $
  +$Id: coroutine.pmc,v 1.38 2004/07/21 11:42:32 leo Exp $
   
   =head1 NAME
   
  @@ -64,6 +64,13 @@
   
   pmclass Coroutine extends Sub {
   
  +    void class_init() {
  +        if (pass) {
  +            enter_nci_method(INTERP, enum_class_Coroutine,
  +                    F2DPTR(Parrot_Coroutine_shift_pmc), "next", "PIO");
  +        }
  +    }
  +
   /*
   
   =item C<void init()>
  
  
  
  1.29      +7 -3      parrot/classes/iterator.pmc
  
  Index: iterator.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/classes/iterator.pmc,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -w -r1.28 -r1.29
  --- iterator.pmc      17 Jul 2004 16:01:05 -0000      1.28
  +++ iterator.pmc      21 Jul 2004 11:42:32 -0000      1.29
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: iterator.pmc,v 1.28 2004/07/17 16:01:05 leo Exp $
  +$Id: iterator.pmc,v 1.29 2004/07/21 11:42:32 leo Exp $
   
   =head1 NAME
   
  @@ -414,9 +414,13 @@
           INTVAL ires;
   
           if (REG_INT(3) == 1) {       /* iterator constructor */
  -            PMC *iter;
  +            PMC *iter, *arg = REG_PMC(5);
  +            if (PObj_is_object_TEST(arg)) {
  +                REG_PMC(5) = iter = VTABLE_get_iter(INTERP, arg);
  +                return next;
  +            }
               REG_PMC(5) = iter = pmc_new_init(INTERP,
  -                    enum_class_Iterator, REG_PMC(5));
  +                    enum_class_Iterator, arg);
               VTABLE_set_integer_native(INTERP, iter, 0);
               return next;
           }
  
  
  
  1.58      +4 -4      parrot/languages/python/pie-thon.pl
  
  Index: pie-thon.pl
  ===================================================================
  RCS file: /cvs/public/parrot/languages/python/pie-thon.pl,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -w -r1.57 -r1.58
  --- pie-thon.pl       21 Jul 2004 08:45:49 -0000      1.57
  +++ pie-thon.pl       21 Jul 2004 11:42:35 -0000      1.58
  @@ -661,11 +661,11 @@
   sub RETURN_VALUE
   {
       my ($n, $c, $cmt) = @_;
  -    my $tos = pop @stack;
  +    my $tos = promote(pop @stack);
       unless ($cur_func eq 'test::main') {
        print <<EOC;
        .pcc_begin_return $cmt
  -     .return $tos->[1]
  +     .return $tos
        .pcc_end_return
   EOC
       }
  @@ -679,10 +679,10 @@
   sub YIELD_VALUE
   {
       my ($n, $c, $cmt) = @_;
  -    my $tos = pop @stack;
  +    my $tos = promote(pop @stack);
       print <<EOC;
        .pcc_begin_yield $cmt
  -     .return $tos->[1]
  +     .return $tos
        .pcc_end_yield
   EOC
   }
  
  
  
  1.6       +53 -2     parrot/languages/python/t/basic/oo_attr.t
  
  Index: oo_attr.t
  ===================================================================
  RCS file: /cvs/public/parrot/languages/python/t/basic/oo_attr.t,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -w -r1.5 -r1.6
  --- oo_attr.t 21 Jul 2004 08:45:52 -0000      1.5
  +++ oo_attr.t 21 Jul 2004 11:42:38 -0000      1.6
  @@ -1,9 +1,9 @@
  -# $Id: oo_attr.t,v 1.5 2004/07/21 08:45:52 leo Exp $
  +# $Id: oo_attr.t,v 1.6 2004/07/21 11:42:38 leo Exp $
   
   use strict;
   use lib '../../lib';
   
  -use Parrot::Test tests => 6;
  +use Parrot::Test tests => 9;
   
   sub test {
       language_output_is('python', $_[0], '', $_[1]);
  @@ -70,3 +70,54 @@
   
   main()
   CODE
  +
  +test(<<'CODE', 'override __iter__');
  +class C(object):
  +    def __iter__(self):
  +     print "in iter"
  +     yield 1
  +
  +def main():
  +    c = C()
  +    for i in c:
  +     print i
  +
  +main()
  +CODE
  +
  +test(<<'CODE', 'override __iter__ 2');
  +class C(object):
  +    def __iter__(self):
  +     print "in iter"
  +     yield 1
  +     yield 2
  +     yield 3
  +     yield 4
  +
  +def main():
  +    c = C()
  +    for i in c:
  +     print i,
  +    print "ok"
  +
  +main()
  +CODE
  +
  +test(<<'CODE', 'override __iter__  next');
  +class C(object):
  +    def __iter__(self):
  +     print "in iter"
  +     yield 1
  +     yield 2
  +     yield 3
  +     yield 4
  +
  +def main():
  +    c = C()
  +    i = iter(c)
  +    print i.next()
  +    print i.next()
  +    print "ok"
  +
  +main()
  +CODE
  
  
  
  1.108     +3 -2      parrot/src/objects.c
  
  Index: objects.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/objects.c,v
  retrieving revision 1.107
  retrieving revision 1.108
  diff -u -w -r1.107 -r1.108
  --- objects.c 21 Jul 2004 08:45:55 -0000      1.107
  +++ objects.c 21 Jul 2004 11:42:41 -0000      1.108
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: objects.c,v 1.107 2004/07/21 08:45:55 leo Exp $
  +$Id: objects.c,v 1.108 2004/07/21 11:42:41 leo Exp $
   
   =head1 NAME
   
  @@ -556,6 +556,7 @@
           if (!PObj_is_class_TEST(parent_class)) {
               PMC *attr;
               SLOTTYPE *obj_data = PMC_data(object);
  +            if (!parent_class->vtable->base_type == enum_class_ParrotClass)
               VTABLE_invoke(interpreter, parent_class, NULL);
               attr = REG_PMC(5);
               set_attrib_num(obj_data, POD_FIRST_ATTRIB, attr);
  
  
  
  1.37      +1 -6      parrot/src/py_func.c
  
  Index: py_func.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/py_func.c,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -w -r1.36 -r1.37
  --- py_func.c 21 Jul 2004 08:45:55 -0000      1.36
  +++ py_func.c 21 Jul 2004 11:42:41 -0000      1.37
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2004 The Perl Foundation.  All Rights Reserved.
  -$Id: py_func.c,v 1.36 2004/07/21 08:45:55 leo Exp $
  +$Id: py_func.c,v 1.37 2004/07/21 11:42:41 leo Exp $
   
   =head1 NAME
   
  @@ -402,11 +402,6 @@
       return (INTVAL) pmc;
   }
   
  -static PMC *
  -parrot_py_iter(Interp *interpreter, PMC *pmc)
  -{
  -    return pmc_new_init(interpreter, enum_class_Iterator, pmc);
  -}
   
   static PMC *
   parrot_py_range(Interp *interpreter, PMC *pstart, PMC *pend, PMC *pstep)
  
  
  

Reply via email to