develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r34613 - branches/pdd22io_part3/src/pmc

From:
allison
Date:
December 29, 2008 21:28
Subject:
[svn:parrot] r34613 - branches/pdd22io_part3/src/pmc
Message ID:
20081230052844.7B577CB9FA@x12.develooper.com
Author: allison
Date: Mon Dec 29 21:28:43 2008
New Revision: 34613

Modified:
   branches/pdd22io_part3/src/pmc/stringhandle.pmc

Log:
[pdd22io] Store full set of options for buffer_type.


Modified: branches/pdd22io_part3/src/pmc/stringhandle.pmc
==============================================================================
--- branches/pdd22io_part3/src/pmc/stringhandle.pmc	(original)
+++ branches/pdd22io_part3/src/pmc/stringhandle.pmc	Mon Dec 29 21:28:43 2008
@@ -411,14 +411,42 @@
 
 =item C<METHOD buffer_type(STRING *new_type :optional)>
 
-StringHandles are always unbuffered.
+Set or retrieve the buffering attribute for the stringhandle. This attribute is
+ignored, but stored for mocking.
 
 =cut
 
 */
 
     METHOD buffer_type(STRING *new_type :optional, INTVAL got_type :opt_flag) {
-        STRING *nobuffer_string = const_string(INTERP, "unbuffered");
+        INTVAL flags;
+        STRING *nobuffer_string   = CONST_STRING(INTERP, "unbuffered");
+        STRING *linebuffer_string = CONST_STRING(INTERP, "line-buffered");
+        STRING *fullbuffer_string = CONST_STRING(INTERP, "full-buffered");
+
+        GET_ATTR_flags(INTERP, SELF, flags);
+
+        if (got_type) {
+            if (string_equal(INTERP, new_type, nobuffer_string) == 0) {
+                flags &= ~ PIO_F_LINEBUF;
+                flags &= ~ PIO_F_BLKBUF;
+            }
+            else if (string_equal(INTERP, new_type, linebuffer_string) == 0) {
+                flags |=   PIO_F_LINEBUF;
+                flags &= ~ PIO_F_BLKBUF;
+            }
+            else if (string_equal(INTERP, new_type, fullbuffer_string) == 0) {
+                flags &= ~ PIO_F_LINEBUF;
+                flags |=   PIO_F_BLKBUF;
+            }
+
+            SET_ATTR_flags(INTERP, SELF, flags);
+        }
+
+        if (flags & PIO_F_LINEBUF)
+            RETURN(STRING *linebuffer_string);
+        else if (flags & PIO_F_BLKBUF)
+            RETURN(STRING *fullbuffer_string);
         RETURN(STRING *nobuffer_string);
     }
 



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About