[svn:parrot] r47513 - in trunk: src/pmc t/pmc

NotFound at svn.parrot.org NotFound at svn.parrot.org
Wed Jun 9 18:31:20 UTC 2010


Author: NotFound
Date: Wed Jun  9 18:31:20 2010
New Revision: 47513
URL: https://trac.parrot.org/parrot/changeset/47513

Log:
ByteBuffer get_iter using an ArrayIterator

Modified:
   trunk/src/pmc/bytebuffer.pmc
   trunk/t/pmc/bytebuffer.t

Modified: trunk/src/pmc/bytebuffer.pmc
==============================================================================
--- trunk/src/pmc/bytebuffer.pmc	Wed Jun  9 14:48:57 2010	(r47512)
+++ trunk/src/pmc/bytebuffer.pmc	Wed Jun  9 18:31:20 2010	(r47513)
@@ -211,6 +211,20 @@
 
 /*
 
+=item C<PMC *get_iter()>
+
+Return a new Iterator for this PMC.
+
+=cut
+
+*/
+
+    VTABLE PMC *get_iter() {
+        return Parrot_pmc_new_init(INTERP, enum_class_ArrayIterator, SELF);
+    }
+
+/*
+
 =back
 
 =head2 Methods

Modified: trunk/t/pmc/bytebuffer.t
==============================================================================
--- trunk/t/pmc/bytebuffer.t	Wed Jun  9 14:48:57 2010	(r47512)
+++ trunk/t/pmc/bytebuffer.t	Wed Jun  9 18:31:20 2010	(r47513)
@@ -17,16 +17,18 @@
 =cut
 
 .include 'iglobals.pasm'
+.include 'iterator.pasm'
 
 .sub 'main' :main
     .include 'test_more.pir'
-    plan(18)
+    plan(19)
 
     test_init()
     test_set_string()
     test_set_byte()
     test_get_string()
     test_alloc()
+    test_iterate()
 .end
 
 .sub test_init
@@ -182,6 +184,27 @@
 end:
 .end
 
+.sub test_iterate
+    .local pmc bb, it, arr
+    .local string s
+    s = 'abcd'
+    bb = new ['ByteBuffer']
+    bb = s
+    it = iter bb
+    it = .ITERATE_FROM_START
+    arr = new ['ResizableStringArray']
+loop:
+    unless it goto donearray
+    $I0 = shift it
+    $S0 = chr $I0
+    push arr, $S0
+    goto loop
+donearray:
+    .local string r
+    r = join '', arr
+    is(r, s, 'iterate buffer content')
+.end
+
 # Local Variables:
 #   mode: pir
 #   fill-column: 100


More information about the parrot-commits mailing list