mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-22 16:47:28 +01:00
Rename the copy_from_xxx methods for consistency.
This commit is contained in:
1 parent
66f712039b
commit
0384c5e4a8
7 files changed
+62
-68
No files matched your search
@@ -159,7 +159,7 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, rp replacementPolicy, pp pare
|
|||||||
b.writes(")")
|
b.writes(")")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if isInDst(g.tm, n, t.KeyCopyFrom32, 2) {
|
if isInDst(g.tm, n, t.KeyCopyFromReader32, 2) {
|
||||||
b.printf("puffs_base_writer1_copy_from32(&%swptr_dst, %swend_dst", bPrefix, bPrefix)
|
b.printf("puffs_base_writer1_copy_from32(&%swptr_dst, %swend_dst", bPrefix, bPrefix)
|
||||||
// TODO: don't assume that the first argument is "in.src".
|
// TODO: don't assume that the first argument is "in.src".
|
||||||
b.printf(", &%srptr_src, %srend_src,", bPrefix, bPrefix)
|
b.printf(", &%srptr_src, %srend_src,", bPrefix, bPrefix)
|
||||||
@@ -170,7 +170,7 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, rp replacementPolicy, pp pare
|
|||||||
b.writeb(')')
|
b.writeb(')')
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if isInDst(g.tm, n, t.KeyCopyHistory32, 2) {
|
if isInDst(g.tm, n, t.KeyCopyFromHistory32, 2) {
|
||||||
b.printf("puffs_base_writer1_copy_history32(&%swptr_dst, %swstart_dst, %swend_dst",
|
b.printf("puffs_base_writer1_copy_history32(&%swptr_dst, %swstart_dst, %swend_dst",
|
||||||
bPrefix, bPrefix, bPrefix)
|
bPrefix, bPrefix, bPrefix)
|
||||||
for _, o := range n.Args() {
|
for _, o := range n.Args() {
|
||||||
@@ -187,7 +187,7 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, rp replacementPolicy, pp pare
|
|||||||
bPrefix, bPrefix, bPrefix)
|
bPrefix, bPrefix, bPrefix)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if isThatMethod(g.tm, n, t.KeyCopyFrom, 1) {
|
if isThatMethod(g.tm, n, t.KeyCopyFromSlice, 1) {
|
||||||
b.writes("puffs_base_slice_u8_copy_from(")
|
b.writes("puffs_base_slice_u8_copy_from(")
|
||||||
receiver := n.LHS().Expr().LHS().Expr()
|
receiver := n.LHS().Expr().LHS().Expr()
|
||||||
if err := g.writeExpr(b, receiver, rp, parenthesesMandatory, depth); err != nil {
|
if err := g.writeExpr(b, receiver, rp, parenthesesMandatory, depth); err != nil {
|
||||||
|
|||||||
@@ -368,7 +368,7 @@ func (g *gen) writeCallSuspendibles(b *buffer, n *a.Expr, depth uint32) error {
|
|||||||
g.currFunk.shortReads = append(g.currFunk.shortReads, "src")
|
g.currFunk.shortReads = append(g.currFunk.shortReads, "src")
|
||||||
b.printf("%srptr_src += %s;\n", bPrefix, scratchName)
|
b.printf("%srptr_src += %s;\n", bPrefix, scratchName)
|
||||||
|
|
||||||
} else if isInDst(g.tm, n, t.KeyWrite, 1) {
|
} else if isInDst(g.tm, n, t.KeyCopyFromSlice, 1) {
|
||||||
// TODO: don't assume that the argument is "this.stack[s:]".
|
// TODO: don't assume that the argument is "this.stack[s:]".
|
||||||
b.printf("if (%sdst.buf && %sdst.buf->closed) { status = %sERROR_CLOSED_FOR_WRITES;",
|
b.printf("if (%sdst.buf && %sdst.buf->closed) { status = %sERROR_CLOSED_FOR_WRITES;",
|
||||||
aPrefix, aPrefix, g.PKGPREFIX)
|
aPrefix, aPrefix, g.PKGPREFIX)
|
||||||
@@ -618,8 +618,8 @@ func isInSrc(tm *t.Map, n *a.Expr, methodName t.Key, nArgs int) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func isInDst(tm *t.Map, n *a.Expr, methodName t.Key, nArgs int) bool {
|
func isInDst(tm *t.Map, n *a.Expr, methodName t.Key, nArgs int) bool {
|
||||||
callSuspendible := methodName != t.KeyCopyFrom32 &&
|
callSuspendible := methodName != t.KeyCopyFromReader32 &&
|
||||||
methodName != t.KeyCopyHistory32 &&
|
methodName != t.KeyCopyFromHistory32 &&
|
||||||
methodName != t.KeySlice
|
methodName != t.KeySlice
|
||||||
// TODO: check that n.Args() is "(x:bar)".
|
// TODO: check that n.Args() is "(x:bar)".
|
||||||
if n.ID0().Key() != t.KeyOpenParen || n.CallSuspendible() != callSuspendible || len(n.Args()) != nArgs {
|
if n.ID0().Key() != t.KeyOpenParen || n.CallSuspendible() != callSuspendible || len(n.Args()) != nArgs {
|
||||||
|
|||||||
@@ -663,8 +663,8 @@ func (q *checker) bcheckExprOther(n *a.Expr, depth uint32) (*big.Int, *big.Int,
|
|||||||
isInSrc(q.tm, n, t.KeyReadU16BE, 0) || isInSrc(q.tm, n, t.KeyReadU32BE, 0) ||
|
isInSrc(q.tm, n, t.KeyReadU16BE, 0) || isInSrc(q.tm, n, t.KeyReadU32BE, 0) ||
|
||||||
isInSrc(q.tm, n, t.KeyReadU32BE, 0) || isInSrc(q.tm, n, t.KeyReadU32LE, 0) ||
|
isInSrc(q.tm, n, t.KeyReadU32BE, 0) || isInSrc(q.tm, n, t.KeyReadU32LE, 0) ||
|
||||||
isInSrc(q.tm, n, t.KeySkip32, 1) ||
|
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.KeyCopyFromSlice, 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.KeyCopyFromReader32, 2) || isInDst(q.tm, n, t.KeyCopyFromHistory32, 2) ||
|
||||||
isInDst(q.tm, n, t.KeySlice, 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_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_extension", 1) || isThisMethod(q.tm, n, "decode_id", 2) ||
|
||||||
@@ -735,8 +735,8 @@ 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.copy_from(etc)".
|
// TODO: delete this hack that only matches "foo.copy_from_slice(etc)".
|
||||||
if isThatMethod(q.tm, n, t.KeyCopyFrom, 1) {
|
if isThatMethod(q.tm, n, t.KeyCopyFromSlice, 1) {
|
||||||
for _, o := range n.Args() {
|
for _, o := range n.Args() {
|
||||||
a := o.Arg().Value()
|
a := o.Arg().Value()
|
||||||
aMin, aMax, err := q.bcheckExpr(a, depth)
|
aMin, aMax, err := q.bcheckExpr(a, depth)
|
||||||
|
|||||||
+6
-6
@@ -373,8 +373,8 @@ func (q *checker) tcheckExprOther(n *a.Expr, depth uint32) error {
|
|||||||
isInSrc(q.tm, n, t.KeyReadU16BE, 0) || isInSrc(q.tm, n, t.KeyReadU32BE, 0) ||
|
isInSrc(q.tm, n, t.KeyReadU16BE, 0) || isInSrc(q.tm, n, t.KeyReadU32BE, 0) ||
|
||||||
isInSrc(q.tm, n, t.KeyReadU32BE, 0) || isInSrc(q.tm, n, t.KeyReadU32LE, 0) ||
|
isInSrc(q.tm, n, t.KeyReadU32BE, 0) || isInSrc(q.tm, n, t.KeyReadU32LE, 0) ||
|
||||||
isInSrc(q.tm, n, t.KeySkip32, 1) ||
|
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.KeyCopyFromSlice, 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.KeyCopyFromReader32, 2) || isInDst(q.tm, n, t.KeyCopyFromHistory32, 2) ||
|
||||||
isInDst(q.tm, n, t.KeySlice, 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_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_extension", 1) || isThisMethod(q.tm, n, "decode_id", 2) ||
|
||||||
@@ -399,7 +399,7 @@ func (q *checker) tcheckExprOther(n *a.Expr, depth uint32) error {
|
|||||||
n.SetMType(typeExprPlaceholder16) // HACK.
|
n.SetMType(typeExprPlaceholder16) // HACK.
|
||||||
} else if isInDst(q.tm, n, t.KeySlice, 0) {
|
} else if isInDst(q.tm, n, t.KeySlice, 0) {
|
||||||
n.SetMType(typeExprSliceU8) // HACK.
|
n.SetMType(typeExprSliceU8) // HACK.
|
||||||
} else if isInDst(q.tm, n, t.KeyCopyFrom32, 2) || isInDst(q.tm, n, t.KeyCopyHistory32, 2) {
|
} else if isInDst(q.tm, n, t.KeyCopyFromReader32, 2) || isInDst(q.tm, n, t.KeyCopyFromHistory32, 2) {
|
||||||
n.SetMType(typeExprU32) // HACK.
|
n.SetMType(typeExprU32) // HACK.
|
||||||
} else {
|
} else {
|
||||||
n.SetMType(typeExprPlaceholder) // HACK.
|
n.SetMType(typeExprPlaceholder) // HACK.
|
||||||
@@ -473,7 +473,7 @@ 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.KeyCopyFromSlice, 1) || isThatMethod(q.tm, n, t.KeyLength, 0) ||
|
||||||
isThatMethod(q.tm, n, t.KeyAvailable, 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 {
|
||||||
@@ -615,8 +615,8 @@ func isInSrc(tm *t.Map, n *a.Expr, methodName t.Key, nArgs int) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func isInDst(tm *t.Map, n *a.Expr, methodName t.Key, nArgs int) bool {
|
func isInDst(tm *t.Map, n *a.Expr, methodName t.Key, nArgs int) bool {
|
||||||
callSuspendible := methodName != t.KeyCopyFrom32 &&
|
callSuspendible := methodName != t.KeyCopyFromReader32 &&
|
||||||
methodName != t.KeyCopyHistory32 &&
|
methodName != t.KeyCopyFromHistory32 &&
|
||||||
methodName != t.KeySlice
|
methodName != t.KeySlice
|
||||||
// TODO: check that n.Args() is "(x:bar)".
|
// TODO: check that n.Args() is "(x:bar)".
|
||||||
if n.ID0().Key() != t.KeyOpenParen || n.CallSuspendible() != callSuspendible || len(n.Args()) != nArgs {
|
if n.ID0().Key() != t.KeyOpenParen || n.CallSuspendible() != callSuspendible || len(n.Args()) != nArgs {
|
||||||
|
|||||||
+39
-45
@@ -273,7 +273,6 @@ const (
|
|||||||
KeyReadU32LE = Key(IDReadU32LE >> KeyShift)
|
KeyReadU32LE = Key(IDReadU32LE >> KeyShift)
|
||||||
KeyReadU64BE = Key(IDReadU64BE >> KeyShift)
|
KeyReadU64BE = Key(IDReadU64BE >> KeyShift)
|
||||||
KeyReadU64LE = Key(IDReadU64LE >> KeyShift)
|
KeyReadU64LE = Key(IDReadU64LE >> KeyShift)
|
||||||
KeyWrite = Key(IDWrite >> KeyShift)
|
|
||||||
KeyWriteU8 = Key(IDWriteU8 >> KeyShift)
|
KeyWriteU8 = Key(IDWriteU8 >> KeyShift)
|
||||||
KeyWriteU16BE = Key(IDWriteU16BE >> KeyShift)
|
KeyWriteU16BE = Key(IDWriteU16BE >> KeyShift)
|
||||||
KeyWriteU16LE = Key(IDWriteU16LE >> KeyShift)
|
KeyWriteU16LE = Key(IDWriteU16LE >> KeyShift)
|
||||||
@@ -282,20 +281,19 @@ const (
|
|||||||
KeyWriteU64BE = Key(IDWriteU64BE >> KeyShift)
|
KeyWriteU64BE = Key(IDWriteU64BE >> KeyShift)
|
||||||
KeyWriteU64LE = Key(IDWriteU64LE >> KeyShift)
|
KeyWriteU64LE = Key(IDWriteU64LE >> KeyShift)
|
||||||
|
|
||||||
KeyIsError = Key(IDIsError >> KeyShift)
|
KeyIsError = Key(IDIsError >> KeyShift)
|
||||||
KeyIsOK = Key(IDIsOK >> KeyShift)
|
KeyIsOK = Key(IDIsOK >> KeyShift)
|
||||||
KeyIsSuspension = Key(IDIsSuspension >> KeyShift)
|
KeyIsSuspension = Key(IDIsSuspension >> KeyShift)
|
||||||
KeyCopyFrom = Key(IDCopyFrom >> KeyShift)
|
KeyCopyFromHistory32 = Key(IDCopyFromHistory32 >> KeyShift)
|
||||||
KeyCopyFrom32 = Key(IDCopyFrom32 >> KeyShift)
|
KeyCopyFromReader32 = Key(IDCopyFromReader32 >> KeyShift)
|
||||||
KeyCopyFrom64 = Key(IDCopyFrom64 >> KeyShift)
|
KeyCopyFromSlice = Key(IDCopyFromSlice >> KeyShift)
|
||||||
KeySkip32 = Key(IDSkip32 >> KeyShift)
|
KeySkip32 = Key(IDSkip32 >> KeyShift)
|
||||||
KeySkip64 = Key(IDSkip64 >> KeyShift)
|
KeySkip64 = Key(IDSkip64 >> 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)
|
||||||
KeyAvailable = Key(IDAvailable >> KeyShift)
|
KeyPrefix = Key(IDPrefix >> KeyShift)
|
||||||
KeyPrefix = Key(IDPrefix >> KeyShift)
|
KeySuffix = Key(IDSuffix >> KeyShift)
|
||||||
KeySuffix = Key(IDSuffix >> KeyShift)
|
|
||||||
|
|
||||||
KeyXUnaryPlus = Key(IDXUnaryPlus >> KeyShift)
|
KeyXUnaryPlus = Key(IDXUnaryPlus >> KeyShift)
|
||||||
KeyXUnaryMinus = Key(IDXUnaryMinus >> KeyShift)
|
KeyXUnaryMinus = Key(IDXUnaryMinus >> KeyShift)
|
||||||
@@ -452,7 +450,6 @@ const (
|
|||||||
IDReadU32LE = ID(0xB5<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
IDReadU32LE = ID(0xB5<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||||
IDReadU64BE = ID(0xB6<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
IDReadU64BE = ID(0xB6<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||||
IDReadU64LE = ID(0xB7<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
IDReadU64LE = ID(0xB7<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||||
IDWrite = ID(0xB8<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
|
||||||
IDWriteU8 = ID(0xB9<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
IDWriteU8 = ID(0xB9<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||||
IDWriteU16BE = ID(0xBA<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
IDWriteU16BE = ID(0xBA<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||||
IDWriteU16LE = ID(0xBB<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
IDWriteU16LE = ID(0xBB<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||||
@@ -461,20 +458,19 @@ const (
|
|||||||
IDWriteU64BE = ID(0xBE<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
IDWriteU64BE = ID(0xBE<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||||
IDWriteU64LE = ID(0xBF<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
IDWriteU64LE = ID(0xBF<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||||
|
|
||||||
IDIsError = ID(0xC0<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
IDIsError = ID(0xC0<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||||
IDIsOK = ID(0xC1<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
IDIsOK = ID(0xC1<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||||
IDIsSuspension = ID(0xC2<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
IDIsSuspension = ID(0xC2<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||||
IDCopyFrom = ID(0xC3<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
IDCopyFromHistory32 = ID(0xC3<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||||
IDCopyFrom32 = ID(0xC4<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
IDCopyFromReader32 = ID(0xC4<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||||
IDCopyFrom64 = ID(0xC5<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
IDCopyFromSlice = ID(0xC5<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||||
IDSkip32 = ID(0xC6<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
IDSkip32 = ID(0xC6<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||||
IDSkip64 = ID(0xC7<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
IDSkip64 = ID(0xC7<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||||
IDCopyHistory32 = ID(0xC8<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
IDSlice = ID(0xC8<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||||
IDSlice = ID(0xC9<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
IDLength = ID(0xC9<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||||
IDLength = ID(0xCA<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
IDAvailable = ID(0xCA<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||||
IDAvailable = ID(0xCB<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
IDPrefix = ID(0xCB<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||||
IDPrefix = ID(0xCC<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
IDSuffix = 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
|
||||||
@@ -653,7 +649,6 @@ var builtInsByKey = [nBuiltInKeys]struct {
|
|||||||
KeyReadU32LE: {"read_u32le", IDReadU32LE},
|
KeyReadU32LE: {"read_u32le", IDReadU32LE},
|
||||||
KeyReadU64BE: {"read_u64be", IDReadU64BE},
|
KeyReadU64BE: {"read_u64be", IDReadU64BE},
|
||||||
KeyReadU64LE: {"read_u64le", IDReadU64LE},
|
KeyReadU64LE: {"read_u64le", IDReadU64LE},
|
||||||
KeyWrite: {"write", IDWrite},
|
|
||||||
KeyWriteU8: {"write_u8", IDWriteU8},
|
KeyWriteU8: {"write_u8", IDWriteU8},
|
||||||
KeyWriteU16BE: {"write_u16be", IDWriteU16BE},
|
KeyWriteU16BE: {"write_u16be", IDWriteU16BE},
|
||||||
KeyWriteU16LE: {"write_u16le", IDWriteU16LE},
|
KeyWriteU16LE: {"write_u16le", IDWriteU16LE},
|
||||||
@@ -662,20 +657,19 @@ var builtInsByKey = [nBuiltInKeys]struct {
|
|||||||
KeyWriteU64BE: {"write_u64be", IDWriteU64BE},
|
KeyWriteU64BE: {"write_u64be", IDWriteU64BE},
|
||||||
KeyWriteU64LE: {"write_u64le", IDWriteU64LE},
|
KeyWriteU64LE: {"write_u64le", IDWriteU64LE},
|
||||||
|
|
||||||
KeyIsError: {"is_error", IDIsError},
|
KeyIsError: {"is_error", IDIsError},
|
||||||
KeyIsOK: {"is_ok", IDIsOK},
|
KeyIsOK: {"is_ok", IDIsOK},
|
||||||
KeyIsSuspension: {"is_suspension", IDIsSuspension},
|
KeyIsSuspension: {"is_suspension", IDIsSuspension},
|
||||||
KeyCopyFrom: {"copy_from", IDCopyFrom},
|
KeyCopyFromHistory32: {"copy_from_history32", IDCopyFromHistory32},
|
||||||
KeyCopyFrom32: {"copy_from32", IDCopyFrom32},
|
KeyCopyFromReader32: {"copy_from_reader32", IDCopyFromReader32},
|
||||||
KeyCopyFrom64: {"copy_from64", IDCopyFrom64},
|
KeyCopyFromSlice: {"copy_from_slice", IDCopyFromSlice},
|
||||||
KeySkip32: {"skip32", IDSkip32},
|
KeySkip32: {"skip32", IDSkip32},
|
||||||
KeySkip64: {"skip64", IDSkip64},
|
KeySkip64: {"skip64", IDSkip64},
|
||||||
KeyCopyHistory32: {"copy_history32", IDCopyHistory32},
|
KeySlice: {"slice", IDSlice},
|
||||||
KeySlice: {"slice", IDSlice},
|
KeyLength: {"length", IDLength},
|
||||||
KeyLength: {"length", IDLength},
|
KeyAvailable: {"available", IDAvailable},
|
||||||
KeyAvailable: {"available", IDAvailable},
|
KeyPrefix: {"prefix", IDPrefix},
|
||||||
KeyPrefix: {"prefix", IDPrefix},
|
KeySuffix: {"suffix", IDSuffix},
|
||||||
KeySuffix: {"suffix", IDSuffix},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var builtInsByName = map[string]ID{}
|
var builtInsByName = map[string]ID{}
|
||||||
|
|||||||
@@ -132,12 +132,12 @@ pub func decoder.decode?(dst writer1, src reader1)() {
|
|||||||
// previous value of history_index, as we will overwrite the whole
|
// previous value of history_index, as we will overwrite the whole
|
||||||
// ringbuffer.
|
// ringbuffer.
|
||||||
written = written.suffix(up_to:0x8000)
|
written = written.suffix(up_to:0x8000)
|
||||||
this.history[:].copy_from(s:written)
|
this.history[:].copy_from_slice(s:written)
|
||||||
this.history_index = 0x8000
|
this.history_index = 0x8000
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, append written to the history ringbuffer starting at
|
// Otherwise, append written to the history ringbuffer starting at
|
||||||
// the previous history_index (modulo 0x8000).
|
// the previous history_index (modulo 0x8000).
|
||||||
var n u64 = this.history[this.history_index & 0x7FFF:].copy_from(s:written)
|
var n u64 = this.history[this.history_index & 0x7FFF:].copy_from_slice(s:written)
|
||||||
if n < written.length() {
|
if n < written.length() {
|
||||||
// a_slice.copy_from(s:b_slice) returns the minimum of the two
|
// a_slice.copy_from(s:b_slice) returns the minimum of the two
|
||||||
// slice lengths. If that value is less than b_slice.length(),
|
// slice lengths. If that value is less than b_slice.length(),
|
||||||
@@ -147,7 +147,7 @@ pub func decoder.decode?(dst writer1, src reader1)() {
|
|||||||
// to wrap around and copy the remainder of written over the
|
// to wrap around and copy the remainder of written over the
|
||||||
// start of the history ringbuffer.
|
// start of the history ringbuffer.
|
||||||
written = written[n:]
|
written = written[n:]
|
||||||
n = this.history[:].copy_from(s:written)
|
n = this.history[:].copy_from_slice(s:written)
|
||||||
// Set history_index (modulo 0x8000) to the length of this
|
// Set history_index (modulo 0x8000) to the length of this
|
||||||
// remainder. The &0x7FFF is redundant, but proves to the
|
// remainder. The &0x7FFF is redundant, but proves to the
|
||||||
// compiler that the conversion to u32 will not overflow. The
|
// compiler that the conversion to u32 will not overflow. The
|
||||||
@@ -209,7 +209,7 @@ pri func decoder.decode_uncompressed?(dst writer1, src reader1)() {
|
|||||||
}
|
}
|
||||||
length = length.low_bits(n:16)
|
length = length.low_bits(n:16)
|
||||||
while true {
|
while true {
|
||||||
var n u32 = in.dst.copy_from32(r:in.src, length:length)
|
var n u32 = in.dst.copy_from_reader32(r:in.src, length:length)
|
||||||
// TODO: assert n <= length and simplify the subsequent if.
|
// TODO: assert n <= length and simplify the subsequent if.
|
||||||
if length == n {
|
if length == n {
|
||||||
break
|
break
|
||||||
@@ -395,7 +395,7 @@ pri func decoder.decode_huffman?(dst writer1, src reader1)() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Copy from in.dst.
|
// Copy from in.dst.
|
||||||
n = in.dst.copy_history32(distance:distance, length:length)
|
n = in.dst.copy_from_history32(distance:distance, length:length)
|
||||||
if length == n {
|
if length == n {
|
||||||
break
|
break
|
||||||
} else if length < n {
|
} else if length < n {
|
||||||
|
|||||||
@@ -110,8 +110,8 @@ pub func lzw_decoder.decode?(dst writer1, src reader1)() {
|
|||||||
inv c < 256,
|
inv c < 256,
|
||||||
{
|
{
|
||||||
var expansion[] u8 = this.stack[s:]
|
var expansion[] u8 = this.stack[s:]
|
||||||
// TODO: change write to copy_from_slice.
|
// TODO: copy_from_slice should return n_copied.
|
||||||
in.dst.write?(x:expansion)
|
in.dst.copy_from_slice?(x:expansion)
|
||||||
if expansion.length() == 0 { // Avoid "unused variable" C compiler warning.
|
if expansion.length() == 0 { // Avoid "unused variable" C compiler warning.
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in new issue
Block a user