mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-17 16:32:11 +01:00
Make writer1.slice's args implicitly (start, ptr).
This commit is contained in:
1 parent
fcf1f2b5ae
commit
4aa9fce311
5 files changed
+13
-24
No files matched your search
@@ -158,15 +158,9 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, rp replacementPolicy, pp pare
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if isInDst(g.tm, n, t.KeySlice, 2) {
|
||||
b.printf("puffs_base_make_slice_u8_from_ptrs(%sdst.buf ? %sdst.buf->ptr : NULL,", aPrefix, aPrefix)
|
||||
for _, o := range n.Args() {
|
||||
if err := g.writeExpr(b, o.Arg().Value(), rp, parenthesesOptional, depth); err != nil {
|
||||
return err
|
||||
}
|
||||
b.writes(".ptr,")
|
||||
}
|
||||
b.printf("%sdst.buf ? %swptr_dst : NULL)", aPrefix, bPrefix)
|
||||
if isInDst(g.tm, n, t.KeySlice, 0) {
|
||||
b.printf("((puffs_base_slice_u8){ .ptr = %swstart_dst, .len = %swptr_dst - %swstart_dst, })",
|
||||
bPrefix, bPrefix, bPrefix)
|
||||
return nil
|
||||
}
|
||||
if isThatMethod(g.tm, n, t.KeyCopyFrom, 1) {
|
||||
|
||||
+4
-9
@@ -648,9 +648,7 @@ puffs_flate_status puffs_flate_decoder_decode(puffs_flate_decoder* self,
|
||||
}
|
||||
puffs_flate_status status = PUFFS_FLATE_STATUS_OK;
|
||||
|
||||
puffs_base_buf1_mark v_m0;
|
||||
puffs_flate_status v_z;
|
||||
puffs_base_buf1_mark v_m1;
|
||||
puffs_base_slice_u8 v_written;
|
||||
uint64_t v_n;
|
||||
uint32_t v_already_full;
|
||||
@@ -673,9 +671,7 @@ puffs_flate_status puffs_flate_decoder_decode(puffs_flate_decoder* self,
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.c_decode[0].coro_susp_point;
|
||||
if (coro_susp_point) {
|
||||
v_m0 = ((puffs_base_buf1_mark){});
|
||||
v_z = self->private_impl.c_decode[0].v_z;
|
||||
v_m1 = ((puffs_base_buf1_mark){});
|
||||
v_written = ((puffs_base_slice_u8){});
|
||||
v_n = self->private_impl.c_decode[0].v_n;
|
||||
v_already_full = self->private_impl.c_decode[0].v_already_full;
|
||||
@@ -683,7 +679,6 @@ puffs_flate_status puffs_flate_decoder_decode(puffs_flate_decoder* self,
|
||||
switch (coro_susp_point) {
|
||||
PUFFS_COROUTINE_SUSPENSION_POINT(0);
|
||||
|
||||
v_m0 = ((puffs_base_buf1_mark){.ptr = b_wptr_dst});
|
||||
PUFFS_COROUTINE_SUSPENSION_POINT(1);
|
||||
if (a_dst.buf) {
|
||||
size_t n = b_wptr_dst - (a_dst.buf->ptr + a_dst.buf->wi);
|
||||
@@ -710,10 +705,10 @@ puffs_flate_status puffs_flate_decoder_decode(puffs_flate_decoder* self,
|
||||
}
|
||||
v_z = t_0;
|
||||
if (v_z > 0) {
|
||||
v_m1 = ((puffs_base_buf1_mark){.ptr = b_wptr_dst});
|
||||
v_written = puffs_base_make_slice_u8_from_ptrs(
|
||||
a_dst.buf ? a_dst.buf->ptr : NULL, v_m0.ptr, v_m1.ptr,
|
||||
a_dst.buf ? b_wptr_dst : NULL);
|
||||
v_written = ((puffs_base_slice_u8){
|
||||
.ptr = b_wstart_dst,
|
||||
.len = b_wptr_dst - b_wstart_dst,
|
||||
});
|
||||
if (((uint64_t)(v_written.len)) >= 32768) {
|
||||
v_written = puffs_base_slice_u8_suffix(v_written, 32768);
|
||||
puffs_base_slice_u8_copy_from(
|
||||
|
||||
@@ -654,7 +654,7 @@ func (q *checker) bcheckExprOther(n *a.Expr, depth uint32) (*big.Int, *big.Int,
|
||||
isInSrc(q.tm, n, t.KeySkip32, 1) ||
|
||||
isInDst(q.tm, n, t.KeyWrite, 1) || isInDst(q.tm, n, t.KeyWriteU8, 1) ||
|
||||
isInDst(q.tm, n, t.KeyCopyFrom32, 2) || isInDst(q.tm, n, t.KeyCopyHistory32, 2) ||
|
||||
isInDst(q.tm, n, t.KeyMark, 0) || isInDst(q.tm, n, t.KeySlice, 2) ||
|
||||
isInDst(q.tm, n, t.KeyMark, 0) || isInDst(q.tm, n, t.KeySlice, 0) ||
|
||||
isThisMethod(q.tm, n, "decode_header", 1) || isThisMethod(q.tm, n, "decode_lsd", 1) ||
|
||||
isThisMethod(q.tm, n, "decode_extension", 1) || isThisMethod(q.tm, n, "decode_id", 2) ||
|
||||
isThisMethod(q.tm, n, "decode_uncompressed", 2) || isThisMethod(q.tm, n, "decode_huffman", 2) ||
|
||||
|
||||
+2
-2
@@ -354,7 +354,7 @@ func (q *checker) tcheckExprOther(n *a.Expr, depth uint32) error {
|
||||
isInSrc(q.tm, n, t.KeySkip32, 1) ||
|
||||
isInDst(q.tm, n, t.KeyWrite, 1) || isInDst(q.tm, n, t.KeyWriteU8, 1) ||
|
||||
isInDst(q.tm, n, t.KeyCopyFrom32, 2) || isInDst(q.tm, n, t.KeyCopyHistory32, 2) ||
|
||||
isInDst(q.tm, n, t.KeyMark, 0) || isInDst(q.tm, n, t.KeySlice, 2) ||
|
||||
isInDst(q.tm, n, t.KeyMark, 0) || isInDst(q.tm, n, t.KeySlice, 0) ||
|
||||
isThisMethod(q.tm, n, "decode_header", 1) || isThisMethod(q.tm, n, "decode_lsd", 1) ||
|
||||
isThisMethod(q.tm, n, "decode_extension", 1) || isThisMethod(q.tm, n, "decode_id", 2) ||
|
||||
isThisMethod(q.tm, n, "decode_uncompressed", 2) || isThisMethod(q.tm, n, "decode_huffman", 2) ||
|
||||
@@ -378,7 +378,7 @@ func (q *checker) tcheckExprOther(n *a.Expr, depth uint32) error {
|
||||
n.SetMType(typeExprPlaceholder16) // HACK.
|
||||
} else if isInDst(q.tm, n, t.KeyMark, 0) {
|
||||
n.SetMType(typeExprBuf1Mark)
|
||||
} else if isInDst(q.tm, n, t.KeySlice, 2) {
|
||||
} else if isInDst(q.tm, n, t.KeySlice, 0) {
|
||||
n.SetMType(typeExprSliceU8) // HACK.
|
||||
} else {
|
||||
n.SetMType(typeExprPlaceholder) // HACK.
|
||||
|
||||
@@ -104,14 +104,14 @@ pub struct decoder?(
|
||||
)
|
||||
|
||||
pub func decoder.decode?(dst writer1, src reader1)() {
|
||||
var m0 buf1_mark = in.dst.mark()
|
||||
var z status = try this.decode_blocks?(dst:in.dst, src:in.src)
|
||||
if z.is_suspension() {
|
||||
var m1 buf1_mark = in.dst.mark()
|
||||
// TODO: should "slice" be "slice!", as the return value lets you
|
||||
// modify the state of in.dst, so future mutations (via the slice) can
|
||||
// change the veracity of any in.dst assertions?
|
||||
var written[] u8 = in.dst.slice(m0:m0, m1:m1)
|
||||
//
|
||||
// Should the RHS be "in.dst[:]" instead of a method call?
|
||||
var written[] u8 = in.dst.slice()
|
||||
// Append written, the decoded output, to the history ringbuffer.
|
||||
if written.length() >= 0x8000 {
|
||||
// If written is longer than the ringbuffer, we can ignore the
|
||||
|
||||
Reference in new issue
Block a user