MCPcopy
hub / github.com/tinylib/msgp / binaryEncodeCall

Method binaryEncodeCall

gen/encode.go:79–93  ·  view source on GitHub ↗

binaryEncodeCall generates code for marshaler interfaces

(vname, method, writeType, arg string)

Source from the content-addressed store, hash-verified

77
78// binaryEncodeCall generates code for marshaler interfaces
79func (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
95func (e *encodeGen) Execute(p Elem, ctx Context) error {
96 e.ctx = &ctx

Callers 1

gBaseMethod · 0.95

Calls 5

writeAndCheckMethod · 0.95
randIdentFunction · 0.85
printfMethod · 0.80
wrapErrCheckMethod · 0.80
ArgsStrMethod · 0.80

Tested by

no test coverage detected