[Bps-public-commit] r18205 - in String-BufferStack: .

alexmv at bestpractical.com alexmv at bestpractical.com
Wed Feb 4 14:42:28 EST 2009


Author: alexmv
Date: Wed Feb  4 14:42:28 2009
New Revision: 18205

Modified:
   String-BufferStack/   (props changed)
   String-BufferStack/META.yml
   String-BufferStack/lib/String/BufferStack.pm

Log:
 r41799 at kohr-ah:  chmrr | 2009-02-04 14:40:52 -0500
  * Add buffer_ref, for direct modification of current buffer frame output
  * Adjust docs a bit
  * Version bump to 1.12


Modified: String-BufferStack/META.yml
==============================================================================
--- String-BufferStack/META.yml	(original)
+++ String-BufferStack/META.yml	Wed Feb  4 14:42:28 2009
@@ -15,4 +15,4 @@
     - t
 requires: 
   perl: 5.8.0
-version: 1.10
+version: 1.12

Modified: String-BufferStack/lib/String/BufferStack.pm
==============================================================================
--- String-BufferStack/lib/String/BufferStack.pm	(original)
+++ String-BufferStack/lib/String/BufferStack.pm	Wed Feb  4 14:42:28 2009
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-our $VERSION; $VERSION = "1.10";
+our $VERSION; $VERSION = "1.12";
 
 =head1 NAME
 
@@ -128,7 +128,7 @@
     my $filter = "";
     my $buffer = "";
     $frame->{buffer} = \$buffer if delete $frame->{private};
-    $frame->{length} = (defined ${$frame->{buffer}}) ? length ${$frame->{buffer}} : 0;
+    $frame->{length} = (defined ${$frame->{buffer}}) ? CORE::length(${$frame->{buffer}}) : 0;
     $frame->{pre_filter} = $frame->{filter} ? \$filter : $frame->{buffer};
     $self->{top} = $frame;
     local $self->{local_frame} = $frame;
@@ -283,7 +283,7 @@
 sub filter {
     my $self = shift;
     my $frame = shift || $self->{top};
-    return unless $frame and $frame->{filter} and length ${$frame->{pre_filter}};
+    return unless $frame and $frame->{filter} and CORE::length(${$frame->{pre_filter}});
 
     # We remove the input before we shell out to the filter, so we
     # don't get into infinite loops.
@@ -329,6 +329,44 @@
     }
 }
 
+=head2 buffer
+
+Returns the contents of the output buffer of the topmost frame; if
+there are no frames, returns the output buffer.
+
+=cut
+
+sub buffer {
+    my $self = shift;
+    return $self->{top} ? ${$self->{top}{buffer}} : ${$self->{output}};
+}
+
+=head2 buffer_ref
+
+Returns a reference to the output buffer of the topmost frame; if
+there are no frames, returns a reference to the output buffer.  Note
+that adjusting this skips pre-append and filter hooks.
+
+=cut
+
+sub buffer_ref {
+    my $self = shift;
+    return $self->{top} ? $self->{top}{buffer} : $self->{output};
+}
+
+=head2 length
+
+Returns the number of characters appended to the current frame; if
+there are no frames, returns the length of the output buffer.
+
+=cut
+
+sub length {
+    my $self = shift;
+    return $self->{top} ? CORE::length(${$self->{top}{buffer}}) - $self->{top}{length} : CORE::length(${$self->{output}});
+}
+
+
 =head2 flush_output
 
 Flushes all filters using L</flush_filters>, then flushes output from
@@ -341,7 +379,7 @@
     $self->flush_filters;
 
     # Look at what we have at the end
-    return unless length ${$self->{output}};
+    return unless CORE::length(${$self->{output}});
     $self->{out_method}->(${$self->{output}});
     ${$self->{output}} = "";
     return "";
@@ -349,7 +387,8 @@
 
 =head2 output_buffer
 
-Returns the pending output buffer.
+Returns the pending output buffer, which sits below all existing
+frames.
 
 =cut
 
@@ -360,7 +399,8 @@
 
 =head2 output_buffer_ref
 
-Returns a reference to the output buffer, allowing you to modify the output buffer.
+Returns a reference to the pending output buffer, allowing you to
+modify it.
 
 =cut
 
@@ -369,30 +409,6 @@
     return $self->{output};
 }
 
-=head2 buffer
-
-Returns the contents of the output buffer of the topmost frame; if
-there are no frames, returns the output buffer.
-
-=cut
-
-sub buffer {
-    my $self = shift;
-    return $self->{top} ? ${$self->{top}{buffer}} : ${$self->{output}};
-}
-
-=head2 length
-
-Returns the number of characters appended to the current frame; if
-there are no frames, returns the length of the output buffer.
-
-=cut
-
-sub length {
-    my $self = shift;
-    return $self->{top} ? length(${$self->{top}{buffer}}) - $self->{top}{length} : length(${$self->{output}});
-}
-
 =head2 clear
 
 Clears I<all> buffers in the stack, including the output buffer.
@@ -425,7 +441,8 @@
 
 =head2 out_method [CALLBACK]
 
-Gets or sets the output method callback.
+Gets or sets the output method callback, which is given content from
+the pending output buffer, which sits below all frames.
 
 =cut
 



More information about the Bps-public-commit mailing list