Have copy_from return the number of bytes copied.

This commit is contained in:
Nigel Tao committed 2017-09-28 17:27:34 +10:00
1 parent a9bdeee7c1
commit f1643be221
9 files changed
+38 -28

No files matched your search

+14
View File
@@ -169,6 +169,20 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, rp replacementPolicy, pp pare
b.printf("%sdst.buf ? %swptr_dst : NULL)", aPrefix, bPrefix)
return nil
}
if isThatMethod(g.tm, n, t.KeyCopyFrom, 1) {
b.writes("puffs_base_slice_u8_copy_from(")
receiver := n.LHS().Expr().LHS().Expr()
if err := g.writeExpr(b, receiver, replaceCallSuspendibles, parenthesesMandatory, depth); err != nil {
return err
}
b.writeb(',')
a := n.Args()[0].Arg().Value()
if err := g.writeExpr(b, a, replaceCallSuspendibles, parenthesesMandatory, depth); err != nil {
return err
}
b.writes(")\n")
return nil
}
if isThatMethod(g.tm, n, t.KeyLength, 0) {
if pp == parenthesesMandatory {
b.writeb('(')