mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-23 00:47:56 +01:00
Add a writer1.available method.
This commit is contained in:
1 parent
ac405d485b
commit
c3ae0534df
6 files changed
+32
-8
No files matched your search
@@ -213,6 +213,18 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, rp replacementPolicy, pp pare
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
if isThatMethod(g.tm, n, t.KeyAvailable, 0) {
|
||||||
|
if pp == parenthesesMandatory {
|
||||||
|
b.writeb('(')
|
||||||
|
}
|
||||||
|
// TODO: don't hard-code dst.
|
||||||
|
const wName = "dst"
|
||||||
|
b.printf("(uint64_t)(%swend_%s - %swptr_%s)", bPrefix, wName, bPrefix, wName)
|
||||||
|
if pp == parenthesesMandatory {
|
||||||
|
b.writeb(')')
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if isThatMethod(g.tm, n, g.tm.ByName("set_literal_width").Key(), 1) {
|
if isThatMethod(g.tm, n, g.tm.ByName("set_literal_width").Key(), 1) {
|
||||||
// TODO: don't hard-code lzw.
|
// TODO: don't hard-code lzw.
|
||||||
b.printf("%slzw_decoder_set_literal_width(&self->private_impl.f_lzw, ", g.pkgPrefix)
|
b.printf("%slzw_decoder_set_literal_width(&self->private_impl.f_lzw, ", g.pkgPrefix)
|
||||||
|
|||||||
+7
-2
@@ -1088,8 +1088,13 @@ puffs_flate_status puffs_flate_decoder_decode_uncompressed(
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
v_length -= v_n;
|
v_length -= v_n;
|
||||||
status = PUFFS_FLATE_SUSPENSION_SHORT_READ;
|
if (((uint64_t)(b_wend_dst - b_wptr_dst)) == 0) {
|
||||||
PUFFS_COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(3);
|
status = PUFFS_FLATE_SUSPENSION_SHORT_WRITE;
|
||||||
|
PUFFS_COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(3);
|
||||||
|
} else {
|
||||||
|
status = PUFFS_FLATE_SUSPENSION_SHORT_READ;
|
||||||
|
PUFFS_COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
label_0_break:;
|
label_0_break:;
|
||||||
|
|
||||||
|
|||||||
@@ -739,7 +739,7 @@ func (q *checker) bcheckExprOther(n *a.Expr, depth uint32) (*big.Int, *big.Int,
|
|||||||
return nil, nil, nil
|
return nil, nil, nil
|
||||||
}
|
}
|
||||||
// TODO: delete this hack that only matches "foo.length(etc)".
|
// TODO: delete this hack that only matches "foo.length(etc)".
|
||||||
if isThatMethod(q.tm, n, t.KeyLength, 0) {
|
if isThatMethod(q.tm, n, t.KeyLength, 0) || isThatMethod(q.tm, n, t.KeyAvailable, 0) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
return nil, nil, fmt.Errorf("check: unrecognized token.Key (0x%X) for bcheckExprOther", n.ID0().Key())
|
return nil, nil, fmt.Errorf("check: unrecognized token.Key (0x%X) for bcheckExprOther", n.ID0().Key())
|
||||||
|
|||||||
+2
-1
@@ -462,7 +462,8 @@ func (q *checker) tcheckExprOther(n *a.Expr, depth uint32) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
// TODO: delete this hack that only matches "foo.length(etc)".
|
// TODO: delete this hack that only matches "foo.length(etc)".
|
||||||
if isThatMethod(q.tm, n, t.KeyCopyFrom, 1) || isThatMethod(q.tm, n, t.KeyLength, 0) {
|
if isThatMethod(q.tm, n, t.KeyCopyFrom, 1) || isThatMethod(q.tm, n, t.KeyLength, 0) ||
|
||||||
|
isThatMethod(q.tm, n, t.KeyAvailable, 0) {
|
||||||
foo := n.LHS().Expr().LHS().Expr()
|
foo := n.LHS().Expr().LHS().Expr()
|
||||||
if err := q.tcheckExpr(foo, depth); err != nil {
|
if err := q.tcheckExpr(foo, depth); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
+5
-2
@@ -282,6 +282,7 @@ const (
|
|||||||
KeyCopyHistory32 = Key(IDCopyHistory32 >> KeyShift)
|
KeyCopyHistory32 = Key(IDCopyHistory32 >> KeyShift)
|
||||||
KeySlice = Key(IDSlice >> KeyShift)
|
KeySlice = Key(IDSlice >> KeyShift)
|
||||||
KeyLength = Key(IDLength >> KeyShift)
|
KeyLength = Key(IDLength >> KeyShift)
|
||||||
|
KeyAvailable = Key(IDAvailable >> KeyShift)
|
||||||
KeyPrefix = Key(IDPrefix >> KeyShift)
|
KeyPrefix = Key(IDPrefix >> KeyShift)
|
||||||
KeySuffix = Key(IDSuffix >> KeyShift)
|
KeySuffix = Key(IDSuffix >> KeyShift)
|
||||||
|
|
||||||
@@ -460,8 +461,9 @@ const (
|
|||||||
IDCopyHistory32 = ID(0xC8<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
IDCopyHistory32 = ID(0xC8<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||||
IDSlice = ID(0xC9<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
IDSlice = ID(0xC9<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||||
IDLength = ID(0xCA<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
IDLength = ID(0xCA<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||||
IDPrefix = ID(0xCB<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
IDAvailable = ID(0xCB<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||||
IDSuffix = ID(0xCC<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
IDPrefix = ID(0xCC<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||||
|
IDSuffix = ID(0xCD<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||||
)
|
)
|
||||||
|
|
||||||
// The IDXFoo IDs are not returned by the tokenizer. They are used by the
|
// The IDXFoo IDs are not returned by the tokenizer. They are used by the
|
||||||
@@ -660,6 +662,7 @@ var builtInsByKey = [nBuiltInKeys]struct {
|
|||||||
KeyCopyHistory32: {"copy_history32", IDCopyHistory32},
|
KeyCopyHistory32: {"copy_history32", IDCopyHistory32},
|
||||||
KeySlice: {"slice", IDSlice},
|
KeySlice: {"slice", IDSlice},
|
||||||
KeyLength: {"length", IDLength},
|
KeyLength: {"length", IDLength},
|
||||||
|
KeyAvailable: {"available", IDAvailable},
|
||||||
KeyPrefix: {"prefix", IDPrefix},
|
KeyPrefix: {"prefix", IDPrefix},
|
||||||
KeySuffix: {"suffix", IDSuffix},
|
KeySuffix: {"suffix", IDSuffix},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -204,8 +204,11 @@ pri func decoder.decode_uncompressed?(dst writer1, src reader1)() {
|
|||||||
return error "internal error: inconsistent Huffman decoder state"
|
return error "internal error: inconsistent Huffman decoder state"
|
||||||
}
|
}
|
||||||
length -= n
|
length -= n
|
||||||
// TODO: distinguish between reads and writes.
|
if in.dst.available() == 0 {
|
||||||
return suspension "short read"
|
return suspension "short write"
|
||||||
|
} else {
|
||||||
|
return suspension "short read"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user