binaryEncodeCall generates code for marshaler interfaces
(vname, method, writeType, arg string)
| 77 | |
| 78 | // binaryEncodeCall generates code for marshaler interfaces |
| 79 | func (e *encodeGen) binaryEncodeCall(vname, method, writeType, arg string) { |
| 80 | bts := randIdent() |
| 81 | e.p.printf("\nvar %s []byte", bts) |
| 82 | if arg == "" { |
| 83 | e.p.printf("\n%s, err = %s.%s()", bts, vname, method) |
| 84 | } else { |
| 85 | e.p.printf("\n%s, err = %s.%s(%s)", bts, vname, method, arg) |
| 86 | } |
| 87 | e.p.wrapErrCheck(e.ctx.ArgsStr()) |
| 88 | if writeType == "String" { |
| 89 | e.writeAndCheck(writeType, literalFmt, "string("+bts+")") |
| 90 | } else { |
| 91 | e.writeAndCheck(writeType, literalFmt, bts) |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | func (e *encodeGen) Execute(p Elem, ctx Context) error { |
| 96 | e.ctx = &ctx |
no test coverage detected