Rename buf1, reader1, etc to io_buffer, io_reader

Also remove the unused Buf1, Buf2 and Usize tokens.
This commit is contained in:
Nigel Tao committed 2018-04-05 20:49:48 +10:00
1 parent 82a48796c8
commit 97aab37462
46 files changed
+823 -847

No files matched your search

+4 -4
View File
@@ -121,7 +121,7 @@ pub struct decoder?(
end_of_block bool,
)
pub func decoder.decode?(dst writer1, src reader1)() {
pub func decoder.decode?(dst io_writer, src io_reader)() {
while true {
in.dst.mark()
var z status = try this.decode_blocks?(dst:in.dst, src:in.src)
@@ -173,7 +173,7 @@ pub func decoder.decode?(dst writer1, src reader1)() {
}
}
pri func decoder.decode_blocks?(dst writer1, src reader1)() {
pri func decoder.decode_blocks?(dst io_writer, src io_reader)() {
var final u32
while final == 0 {
while this.n_bits < 3,
@@ -213,7 +213,7 @@ pri func decoder.decode_blocks?(dst writer1, src reader1)() {
// decode_uncompressed decodes an uncompresed block as per the RFC section
// 3.2.4.
pri func decoder.decode_uncompressed?(dst writer1, src reader1)() {
pri func decoder.decode_uncompressed?(dst io_writer, src io_reader)() {
// TODO: make this "if" into a function invariant?
//
// Ditto for decode_huffman_slow and decode_huffman_fast.
@@ -272,7 +272,7 @@ pri func decoder.init_fixed_huffman?()() {
}
// init_dynamic_huffman initializes this.huffs as per the RFC section 3.2.7.
pri func decoder.init_dynamic_huffman?(src reader1)() {
pri func decoder.init_dynamic_huffman?(src io_reader)() {
var bits u32 = this.bits
var n_bits u32 = this.n_bits
while n_bits < 14,
+1 -1
View File
@@ -14,7 +14,7 @@
// TODO: describe how the xxx_fast version differs from the xxx_slow one, the
// assumptions that xxx_fast makes, and how that makes it fast.
pri func decoder.decode_huffman_fast?(dst writer1, src reader1)() {
pri func decoder.decode_huffman_fast?(dst io_writer, src io_reader)() {
// When editing this function, consider making the equivalent change to the
// decode_huffman_slow function. Keep the diff between the two
// decode_huffman_*.wuffs files as small as possible, while retaining both
+1 -1
View File
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
pri func decoder.decode_huffman_slow?(dst writer1, src reader1)() {
pri func decoder.decode_huffman_slow?(dst io_writer, src io_reader)() {
// When editing this function, consider making the equivalent change to the
// decode_huffman_fast function. Keep the diff between the two
// decode_huffman_*.wuffs files as small as possible, while retaining both
+10 -10
View File
@@ -60,7 +60,7 @@ pub struct decoder?(
)
// TODO: should dst be an nptr instead of a ptr?
pub func decoder.decode_config?(dst ptr image_config, src reader1)() {
pub func decoder.decode_config?(dst ptr image_config, src io_reader)() {
if this.call_sequence >= 1 {
return error "invalid call sequence"
}
@@ -85,7 +85,7 @@ pub func decoder.decode_config?(dst ptr image_config, src reader1)() {
this.call_sequence = 1
}
pub func decoder.decode_frame?(dst writer1, src reader1)() {
pub func decoder.decode_frame?(dst io_writer, src io_reader)() {
if this.call_sequence < 1 {
return error "invalid call sequence"
}
@@ -121,7 +121,7 @@ pub func decoder.decode_frame?(dst writer1, src reader1)() {
// decode_header reads either "GIF87a" or "GIF89a".
//
// See the spec section 17 "Header" on page 7.
pri func decoder.decode_header?(src reader1)() {
pri func decoder.decode_header?(src io_reader)() {
var c[6] u8
var i u32
while i < 6 {
@@ -137,7 +137,7 @@ pri func decoder.decode_header?(src reader1)() {
// decode_lsd reads the Logical Screen Descriptor.
//
// See the spec section 18 "Logical Screen Descriptor" on page 8.
pri func decoder.decode_lsd?(src reader1)() {
pri func decoder.decode_lsd?(src io_reader)() {
var c[7] u8
var i u32
while i < 7 {
@@ -172,7 +172,7 @@ pri func decoder.decode_lsd?(src reader1)() {
// - section 24 "Comment Extension" on page 17.
// - section 25 "Plain Text Extension" on page 18.
// - section 26 "Application Extension" on page 21.
pri func decoder.decode_extension?(src reader1)() {
pri func decoder.decode_extension?(src io_reader)() {
var label u8 = in.src.read_u8?()
if label == 0xF9 { // The spec calls 0xF9 the "Graphic Control Label".
// TODO.
@@ -185,7 +185,7 @@ pri func decoder.decode_extension?(src reader1)() {
this.skip_blocks?(src:in.src)
}
pri func decoder.skip_blocks?(src reader1)() {
pri func decoder.skip_blocks?(src io_reader)() {
while true {
var block_size u8 = in.src.read_u8?()
if block_size == 0 {
@@ -206,7 +206,7 @@ pri const netscape2dot0[11] u8 = $(
)
// decode_ae reads an Application Extension.
pri func decoder.decode_ae?(src reader1)() {
pri func decoder.decode_ae?(src io_reader)() {
// This "while true" always executes exactly once, as it ends with a
// "break", but using "break"s throughout simplifies the control flow.
while true {
@@ -275,7 +275,7 @@ pri func decoder.decode_ae?(src reader1)() {
// been read.
//
// See the spec section 20 "Image Descriptor" on page 11.
pri func decoder.decode_id?(dst writer1, src reader1)() {
pri func decoder.decode_id?(dst io_writer, src io_reader)() {
// TODO: check that the frame rect is inside the image rect??
this.frame_left = in.src.read_u16le?() as u32
this.frame_top = in.src.read_u16le?() as u32
@@ -312,9 +312,9 @@ pri func decoder.decode_id?(dst writer1, src reader1)() {
break
}
while true {
var r reader1 = in.src
var r io_reader = in.src
// TODO: should "mark" be "set_mark"? Unlike "limit", "mark" does
// not return a different reader1.
// not return a different io_reader.
r.mark()
// TODO: remove the dummy param. It's needed for now so that
// writeSaveExprDerivedVars updates e.g. the b_rptr_src derived
+1 -1
View File
@@ -28,7 +28,7 @@ pri func lzw_decoder.set_literal_width!(lw u32[2..8] = 8)() {
this.literal_width = in.lw
}
pri func lzw_decoder.decode?(dst writer1, src reader1)() {
pri func lzw_decoder.decode?(dst io_writer, src io_reader)() {
// These variables don't change over the lifetime of this func.
var clear_code u32[4..256] = (1 as u32) << this.literal_width
var end_code u32[5..257] = clear_code + 1
+1 -1
View File
@@ -32,7 +32,7 @@ pub func decoder.set_ignore_checksum!(ic bool)() {
this.ignore_checksum = in.ic
}
pub func decoder.decode?(dst writer1, src reader1)() {
pub func decoder.decode?(dst io_writer, src io_reader)() {
// Read the header.
if in.src.read_u8?() != 0x1F {
return error "bad gzip header"
+1 -1
View File
@@ -33,7 +33,7 @@ pub func decoder.set_ignore_checksum!(ic bool)() {
this.ignore_checksum = in.ic
}
pub func decoder.decode?(dst writer1, src reader1)() {
pub func decoder.decode?(dst io_writer, src io_reader)() {
var x u16 = in.src.read_u16be?()
if ((x >> 8) & 0x0F) != 0x08 {
return error "invalid zlib compression method"