mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 08:55:11 +01:00
Fix some built-in methods' effects
This commit is contained in:
1 parent
2919e51575
commit
131732e7eb
8 files changed
+21
-24
No files matched your search
+8
-11
@@ -79,9 +79,6 @@ var Types = []string{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var Funcs = []string{
|
var Funcs = []string{
|
||||||
// TODO: some methods like "mark" and "set_limit" should probably have a
|
|
||||||
// trailing "!".
|
|
||||||
|
|
||||||
"u8.high_bits(n u32[..8])(ret u8)",
|
"u8.high_bits(n u32[..8])(ret u8)",
|
||||||
"u8.low_bits(n u32[..8])(ret u8)",
|
"u8.low_bits(n u32[..8])(ret u8)",
|
||||||
"u16.high_bits(n u32[..16])(ret u16)",
|
"u16.high_bits(n u32[..16])(ret u16)",
|
||||||
@@ -109,8 +106,8 @@ var Funcs = []string{
|
|||||||
"io_reader.read_u64le?()(ret u64)",
|
"io_reader.read_u64le?()(ret u64)",
|
||||||
|
|
||||||
"io_reader.available()(ret u64)",
|
"io_reader.available()(ret u64)",
|
||||||
"io_reader.set_limit(l u64)()",
|
"io_reader.set_limit!(l u64)()",
|
||||||
"io_reader.set_mark()()",
|
"io_reader.set_mark!()()",
|
||||||
"io_reader.since_mark()(ret slice u8)",
|
"io_reader.since_mark()(ret slice u8)",
|
||||||
|
|
||||||
"io_reader.skip32?(n u32)()",
|
"io_reader.skip32?(n u32)()",
|
||||||
@@ -127,14 +124,14 @@ var Funcs = []string{
|
|||||||
"io_writer.write_u64le?(x u64)()",
|
"io_writer.write_u64le?(x u64)()",
|
||||||
|
|
||||||
"io_writer.available()(ret u64)",
|
"io_writer.available()(ret u64)",
|
||||||
"io_writer.set_limit(l u64)()",
|
"io_writer.set_limit!(l u64)()",
|
||||||
"io_writer.set_mark()()",
|
"io_writer.set_mark!()()",
|
||||||
"io_writer.since_mark()(ret slice u8)",
|
"io_writer.since_mark()(ret slice u8)",
|
||||||
|
|
||||||
"io_writer.copy_from_history32(distance u32, length u32)(ret u32)",
|
"io_writer.copy_from_history32!(distance u32, length u32)(ret u32)",
|
||||||
"io_writer.copy_from_reader32(r io_reader, length u32)(ret u32)",
|
"io_writer.copy_from_reader32!(r io_reader, length u32)(ret u32)",
|
||||||
"io_writer.copy_from_slice(s slice u8)(ret u64)",
|
"io_writer.copy_from_slice!(s slice u8)(ret u64)",
|
||||||
"io_writer.copy_from_slice32(s slice u8, length u32)(ret u32)",
|
"io_writer.copy_from_slice32!(s slice u8, length u32)(ret u32)",
|
||||||
|
|
||||||
// ---- image_config
|
// ---- image_config
|
||||||
|
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ pub struct decoder?(
|
|||||||
|
|
||||||
pub func decoder.decode?(dst base.io_writer, src base.io_reader)() {
|
pub func decoder.decode?(dst base.io_writer, src base.io_reader)() {
|
||||||
while true {
|
while true {
|
||||||
in.dst.set_mark()
|
in.dst.set_mark!()
|
||||||
var z base.status = try this.decode_blocks?(dst:in.dst, src:in.src)
|
var z base.status = try this.decode_blocks?(dst:in.dst, src:in.src)
|
||||||
if not z.is_suspension() {
|
if not z.is_suspension() {
|
||||||
return z
|
return z
|
||||||
@@ -229,7 +229,7 @@ pri func decoder.decode_uncompressed?(dst base.io_writer, src base.io_reader)()
|
|||||||
}
|
}
|
||||||
length = length.low_bits(n:16)
|
length = length.low_bits(n:16)
|
||||||
while true {
|
while true {
|
||||||
var n_copied base.u32 = in.dst.copy_from_reader32(r:in.src, length:length)
|
var n_copied base.u32 = in.dst.copy_from_reader32!(r:in.src, length:length)
|
||||||
if length <= n_copied {
|
if length <= n_copied {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -318,13 +318,13 @@ pri func decoder.decode_huffman_fast?(dst base.io_writer, src base.io_reader)()
|
|||||||
// TODO: copy_from_slice32 should probably update the
|
// TODO: copy_from_slice32 should probably update the
|
||||||
// "in.dst.available() >= 258" fact. It should certainly
|
// "in.dst.available() >= 258" fact. It should certainly
|
||||||
// invalidate any fact that was "<=" instead of ">=".
|
// invalidate any fact that was "<=" instead of ">=".
|
||||||
n_copied = in.dst.copy_from_slice32(
|
n_copied = in.dst.copy_from_slice32!(
|
||||||
s:this.history[hdist & 0x7FFF:], length:hlen)
|
s:this.history[hdist & 0x7FFF:], length:hlen)
|
||||||
if hlen <= n_copied {
|
if hlen <= n_copied {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
hlen -= n_copied
|
hlen -= n_copied
|
||||||
in.dst.copy_from_slice32(s:this.history[:], length:hlen)
|
in.dst.copy_from_slice32!(s:this.history[:], length:hlen)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -348,7 +348,7 @@ pri func decoder.decode_huffman_fast?(dst base.io_writer, src base.io_reader)()
|
|||||||
assert (length as base.u64) <= in.dst.available() via "a <= b: a <= c; c <= b"(c:258)
|
assert (length as base.u64) <= in.dst.available() via "a <= b: a <= c; c <= b"(c:258)
|
||||||
|
|
||||||
// Copy from in.dst.
|
// Copy from in.dst.
|
||||||
in.dst.copy_from_history32(distance:(dist_minus_1 + 1), length:length)
|
in.dst.copy_from_history32!(distance:(dist_minus_1 + 1), length:length)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ pri func decoder.decode_huffman_slow?(dst base.io_writer, src base.io_reader)()
|
|||||||
|
|
||||||
// Copy from hdist to the end of this.history.
|
// Copy from hdist to the end of this.history.
|
||||||
while true {
|
while true {
|
||||||
n_copied = in.dst.copy_from_slice32(
|
n_copied = in.dst.copy_from_slice32!(
|
||||||
s:this.history[hdist & 0x7FFF:], length:hlen)
|
s:this.history[hdist & 0x7FFF:], length:hlen)
|
||||||
if hlen <= n_copied {
|
if hlen <= n_copied {
|
||||||
hlen = 0
|
hlen = 0
|
||||||
@@ -226,7 +226,7 @@ pri func decoder.decode_huffman_slow?(dst base.io_writer, src base.io_reader)()
|
|||||||
// Copy from the start of this.history, if we wrapped around.
|
// Copy from the start of this.history, if we wrapped around.
|
||||||
if hlen > 0 {
|
if hlen > 0 {
|
||||||
while true {
|
while true {
|
||||||
n_copied = in.dst.copy_from_slice32(
|
n_copied = in.dst.copy_from_slice32!(
|
||||||
s:this.history[hdist & 0x7FFF:], length:hlen)
|
s:this.history[hdist & 0x7FFF:], length:hlen)
|
||||||
if hlen <= n_copied {
|
if hlen <= n_copied {
|
||||||
hlen = 0
|
hlen = 0
|
||||||
@@ -246,7 +246,7 @@ pri func decoder.decode_huffman_slow?(dst base.io_writer, src base.io_reader)()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Copy from in.dst.
|
// Copy from in.dst.
|
||||||
n_copied = in.dst.copy_from_history32(distance:(dist_minus_1 + 1), length:length)
|
n_copied = in.dst.copy_from_history32!(distance:(dist_minus_1 + 1), length:length)
|
||||||
if length <= n_copied {
|
if length <= n_copied {
|
||||||
length = 0
|
length = 0
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -334,7 +334,7 @@ pri func decoder.decode_id?(dst base.io_writer, src base.io_reader)() {
|
|||||||
this.previous_lzw_decode_ended_abruptly = true
|
this.previous_lzw_decode_ended_abruptly = true
|
||||||
|
|
||||||
while true {
|
while true {
|
||||||
in.src.set_mark()
|
in.src.set_mark!()
|
||||||
io_bind (in.src) {
|
io_bind (in.src) {
|
||||||
// TODO: enforce that calling r.set_limit has a precondition
|
// TODO: enforce that calling r.set_limit has a precondition
|
||||||
// that r.is_bound(), and that you can't suspend inside an
|
// that r.is_bound(), and that you can't suspend inside an
|
||||||
@@ -342,7 +342,7 @@ pri func decoder.decode_id?(dst base.io_writer, src base.io_reader)() {
|
|||||||
// complicated if we must save and re-apply limits.
|
// complicated if we must save and re-apply limits.
|
||||||
//
|
//
|
||||||
// Should calling r.set_mark also require r.is_bound()?
|
// Should calling r.set_mark also require r.is_bound()?
|
||||||
in.src.set_limit(l:block_size)
|
in.src.set_limit!(l:block_size)
|
||||||
var z base.status = try this.lzw.decode?(dst:in.dst, src:in.src)
|
var z base.status = try this.lzw.decode?(dst:in.dst, src:in.src)
|
||||||
}
|
}
|
||||||
if z.is_ok() {
|
if z.is_ok() {
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ pri func lzw_decoder.decode?(dst base.io_writer, src base.io_reader)() {
|
|||||||
inv c < 256,
|
inv c < 256,
|
||||||
{
|
{
|
||||||
var expansion slice base.u8 = this.stack[s:]
|
var expansion slice base.u8 = this.stack[s:]
|
||||||
var n_copied base.u64 = in.dst.copy_from_slice(s:expansion)
|
var n_copied base.u64 = in.dst.copy_from_slice!(s:expansion)
|
||||||
if n_copied == expansion.length() {
|
if n_copied == expansion.length() {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ pub func decoder.decode?(dst base.io_writer, src base.io_reader)() {
|
|||||||
var checksum_got base.u32
|
var checksum_got base.u32
|
||||||
var decoded_length_got base.u32
|
var decoded_length_got base.u32
|
||||||
while true {
|
while true {
|
||||||
in.dst.set_mark()
|
in.dst.set_mark!()
|
||||||
var z base.status = try this.flate.decode?(dst:in.dst, src:in.src)
|
var z base.status = try this.flate.decode?(dst:in.dst, src:in.src)
|
||||||
if not this.ignore_checksum {
|
if not this.ignore_checksum {
|
||||||
checksum_got = this.checksum.update(x:in.dst.since_mark())
|
checksum_got = this.checksum.update(x:in.dst.since_mark())
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ pub func decoder.decode?(dst base.io_writer, src base.io_reader)() {
|
|||||||
// Decode and checksum the DEFLATE-encoded payload.
|
// Decode and checksum the DEFLATE-encoded payload.
|
||||||
var checksum_got base.u32
|
var checksum_got base.u32
|
||||||
while true {
|
while true {
|
||||||
in.dst.set_mark()
|
in.dst.set_mark!()
|
||||||
var z base.status = try this.flate.decode?(dst:in.dst, src:in.src)
|
var z base.status = try this.flate.decode?(dst:in.dst, src:in.src)
|
||||||
if not this.ignore_checksum {
|
if not this.ignore_checksum {
|
||||||
checksum_got = this.checksum.update(x:in.dst.since_mark())
|
checksum_got = this.checksum.update(x:in.dst.since_mark())
|
||||||
|
|||||||
Reference in new issue
Block a user