[svn:mod_parrot] r344 - mod_parrot/trunk/lib/ModParrot

[email protected] Fri, 30 May 2008 12:57:23 -0700 (PDT)
Newsgroups perl.cvs.mod_parrot
Message-ID <[email protected]>
Author: jhorwitz
Date: Fri May 30 12:57:22 2008
New Revision: 344

Modified:
   mod_parrot/trunk/lib/ModParrot/Interpreter.pir

Log:
support functions for ModPerl6::Registry


Modified: mod_parrot/trunk/lib/ModParrot/Interpreter.pir
==============================================================================
--- mod_parrot/trunk/lib/ModParrot/Interpreter.pir	(original)
+++ mod_parrot/trunk/lib/ModParrot/Interpreter.pir	Fri May 30 12:57:22 2008
@@ -144,8 +144,57 @@
     .return($S0)
 .end
 
+=item C<capture_stdout(INT flag)>
+
+=over 4
+
+WARNING: This method is temporary and WILL go away.  Enables capture of
+standard output to an internal string buffer.
+
+=back
+
 =cut
 
+.sub capture_stdout :method
+    .param int enabled
+    .local pmc pio
+
+    pio = getstdout
+    unless enabled goto disable_capture
+    push pio, "string"
+    goto done
+  disable_capture:
+    $S0 = pop pio
+  done:
+.end
+
+=item C<STRING dump_stdout(INT flag)>
+
+=over 4
+
+WARNING: This method is temporary and WILL go away.  Returns the contents of
+the stdout string buffer created by C<capture_stdout()>.
+
+=back
+
+=cut
+
+.sub dump_stdout :method
+    .local pmc pio
+    .local string buf, data
+
+    pio = getstdout
+    data = ""
+
+  read_loop:
+    buf = read pio, 4096
+    data .= buf
+    $I0 = length buf
+    if $I0 == 4096 goto read_loop
+
+  .return(data)
+.end
+
 =back
 
 =head1 AUTHOR