chromedp/cmd/chromedp-gen/templates/domain.qtpl.go

659 lines
17 KiB
Go
Raw Normal View History

2017-01-24 15:09:23 +00:00
// This file is automatically generated by qtc from "domain.qtpl".
// See https://github.com/valyala/quicktemplate for details.
//line templates/domain.qtpl:1
package templates
//line templates/domain.qtpl:1
import (
qtio422016 "io"
qt422016 "github.com/valyala/quicktemplate"
)
//line templates/domain.qtpl:1
import (
2017-01-26 07:28:34 +00:00
"github.com/knq/chromedp/cmd/chromedp-gen/internal"
2017-01-24 15:09:23 +00:00
)
// DomainTemplate is the template for a single domain.
//line templates/domain.qtpl:6
var (
_ = qtio422016.Copy
_ = qt422016.AcquireByteBuffer
)
//line templates/domain.qtpl:6
2017-01-26 07:28:34 +00:00
func StreamDomainTemplate(qw422016 *qt422016.Writer, d *internal.Domain, domains []*internal.Domain) {
2017-01-24 15:09:23 +00:00
//line templates/domain.qtpl:6
qw422016.N().S(`
`)
//line templates/domain.qtpl:7
2017-01-26 07:28:34 +00:00
qw422016.N().S(FileImportTemplate(map[string]string{
*internal.FlagPkg: "cdp",
}))
//line templates/domain.qtpl:9
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:10
2017-01-24 15:09:23 +00:00
for _, c := range d.Commands {
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:10
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:11
2017-01-24 15:09:23 +00:00
qw422016.N().S(CommandTemplate(c, d, domains))
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:11
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:12
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:12
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:13
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:13
func WriteDomainTemplate(qq422016 qtio422016.Writer, d *internal.Domain, domains []*internal.Domain) {
//line templates/domain.qtpl:13
2017-01-24 15:09:23 +00:00
qw422016 := qt422016.AcquireWriter(qq422016)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:13
2017-01-24 15:09:23 +00:00
StreamDomainTemplate(qw422016, d, domains)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:13
2017-01-24 15:09:23 +00:00
qt422016.ReleaseWriter(qw422016)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:13
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:13
func DomainTemplate(d *internal.Domain, domains []*internal.Domain) string {
//line templates/domain.qtpl:13
2017-01-24 15:09:23 +00:00
qb422016 := qt422016.AcquireByteBuffer()
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:13
2017-01-24 15:09:23 +00:00
WriteDomainTemplate(qb422016, d, domains)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:13
2017-01-24 15:09:23 +00:00
qs422016 := string(qb422016.B)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:13
2017-01-24 15:09:23 +00:00
qt422016.ReleaseByteBuffer(qb422016)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:13
2017-01-24 15:09:23 +00:00
return qs422016
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:13
2017-01-24 15:09:23 +00:00
}
// CommandTemplate is the general command template.
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:16
func StreamCommandTemplate(qw422016 *qt422016.Writer, c *internal.Type, d *internal.Domain, domains []*internal.Domain) {
//line templates/domain.qtpl:16
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:17
2017-01-24 15:09:23 +00:00
/* add *Param type */
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:17
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:18
qw422016.N().S(TypeTemplate(c, internal.CommandTypePrefix, internal.CommandTypeSuffix, d, domains, nil, false, true))
//line templates/domain.qtpl:18
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:20
2017-01-24 15:09:23 +00:00
/* add Command func */
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:20
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:21
2017-01-24 15:09:23 +00:00
qw422016.N().S(CommandFuncTemplate(c, d, domains))
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:21
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:23
2017-01-24 15:09:23 +00:00
/* add param funcs (only if it has parameters and a returns). */
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:23
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:24
2017-01-24 15:09:23 +00:00
if len(c.Parameters) != 0 {
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:24
2017-01-24 15:09:23 +00:00
for _, p := range c.Parameters {
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:24
2017-01-24 15:09:23 +00:00
if !p.Optional {
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:24
2017-01-24 15:09:23 +00:00
continue
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:24
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:24
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:25
2017-01-24 15:09:23 +00:00
qw422016.N().S(CommandOptionFuncTemplate(p, c, d, domains))
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:25
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:26
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:26
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:26
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:28
2017-01-24 15:09:23 +00:00
/* add *Returns type */
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:28
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:29
2017-01-24 15:09:23 +00:00
if len(c.Returns) != 0 {
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:29
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:30
qw422016.N().S(TypeTemplate(&internal.Type{
2017-01-24 15:09:23 +00:00
ID: c.Name,
2017-01-26 07:28:34 +00:00
Type: internal.TypeObject,
2017-01-24 15:09:23 +00:00
Description: "Return values.",
Properties: c.Returns,
2017-01-26 07:28:34 +00:00
}, internal.CommandReturnsPrefix, internal.CommandReturnsSuffix, d, domains, nil, false, false))
//line templates/domain.qtpl:35
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:36
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:36
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:38
2017-01-24 15:09:23 +00:00
/* add CommandParams.Do func */
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:38
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:39
2017-01-24 15:09:23 +00:00
qw422016.N().S(CommandDoFuncTemplate(c, d, domains))
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:39
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:40
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:40
func WriteCommandTemplate(qq422016 qtio422016.Writer, c *internal.Type, d *internal.Domain, domains []*internal.Domain) {
//line templates/domain.qtpl:40
2017-01-24 15:09:23 +00:00
qw422016 := qt422016.AcquireWriter(qq422016)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:40
2017-01-24 15:09:23 +00:00
StreamCommandTemplate(qw422016, c, d, domains)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:40
2017-01-24 15:09:23 +00:00
qt422016.ReleaseWriter(qw422016)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:40
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:40
func CommandTemplate(c *internal.Type, d *internal.Domain, domains []*internal.Domain) string {
//line templates/domain.qtpl:40
2017-01-24 15:09:23 +00:00
qb422016 := qt422016.AcquireByteBuffer()
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:40
2017-01-24 15:09:23 +00:00
WriteCommandTemplate(qb422016, c, d, domains)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:40
2017-01-24 15:09:23 +00:00
qs422016 := string(qb422016.B)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:40
2017-01-24 15:09:23 +00:00
qt422016.ReleaseByteBuffer(qb422016)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:40
2017-01-24 15:09:23 +00:00
return qs422016
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:40
2017-01-24 15:09:23 +00:00
}
// CommandFuncTemplate is the command func template.
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:43
func StreamCommandFuncTemplate(qw422016 *qt422016.Writer, c *internal.Type, d *internal.Domain, domains []*internal.Domain) {
//line templates/domain.qtpl:44
2017-01-24 15:09:23 +00:00
cmdName := c.CamelName()
typ := c.CommandType()
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:46
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:47
qw422016.N().S(formatComment(c.GetDescription(), "", cmdName+" "))
//line templates/domain.qtpl:47
2017-01-24 15:09:23 +00:00
if len(c.Parameters) > 0 {
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:47
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
2017-01-26 07:28:34 +00:00
//
2017-01-24 15:09:23 +00:00
// parameters:`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:49
2017-01-24 15:09:23 +00:00
for _, p := range c.Parameters {
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:49
2017-01-24 15:09:23 +00:00
if p.Optional {
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:49
2017-01-24 15:09:23 +00:00
continue
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:49
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:49
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
// `)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:50
2017-01-24 15:09:23 +00:00
qw422016.N().S(p.String())
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:50
2017-01-24 15:09:23 +00:00
if p.Optional {
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:50
2017-01-24 15:09:23 +00:00
qw422016.N().S(` (optional)`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:50
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:50
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:50
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:50
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
func `)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:51
2017-01-24 15:09:23 +00:00
qw422016.N().S(cmdName)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:51
2017-01-24 15:09:23 +00:00
qw422016.N().S(`(`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:51
2017-01-24 15:09:23 +00:00
qw422016.N().S(c.ParamList(d, domains, false))
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:51
2017-01-24 15:09:23 +00:00
qw422016.N().S(`) *`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:51
2017-01-24 15:09:23 +00:00
qw422016.N().S(typ)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:51
2017-01-24 15:09:23 +00:00
qw422016.N().S(`{
return &`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:52
2017-01-24 15:09:23 +00:00
qw422016.N().S(typ)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:52
2017-01-24 15:09:23 +00:00
qw422016.N().S(`{`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:52
2017-01-24 15:09:23 +00:00
for _, t := range c.Parameters {
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:52
2017-01-24 15:09:23 +00:00
if !t.Optional {
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:52
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:53
2017-01-24 15:09:23 +00:00
qw422016.N().S(t.GoName(false))
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:53
2017-01-24 15:09:23 +00:00
qw422016.N().S(`: `)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:53
2017-01-24 15:09:23 +00:00
qw422016.N().S(t.GoName(true))
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:53
2017-01-24 15:09:23 +00:00
qw422016.N().S(`,`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:53
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:53
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:53
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
}
}
`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:56
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:56
func WriteCommandFuncTemplate(qq422016 qtio422016.Writer, c *internal.Type, d *internal.Domain, domains []*internal.Domain) {
//line templates/domain.qtpl:56
2017-01-24 15:09:23 +00:00
qw422016 := qt422016.AcquireWriter(qq422016)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:56
2017-01-24 15:09:23 +00:00
StreamCommandFuncTemplate(qw422016, c, d, domains)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:56
2017-01-24 15:09:23 +00:00
qt422016.ReleaseWriter(qw422016)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:56
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:56
func CommandFuncTemplate(c *internal.Type, d *internal.Domain, domains []*internal.Domain) string {
//line templates/domain.qtpl:56
2017-01-24 15:09:23 +00:00
qb422016 := qt422016.AcquireByteBuffer()
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:56
2017-01-24 15:09:23 +00:00
WriteCommandFuncTemplate(qb422016, c, d, domains)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:56
2017-01-24 15:09:23 +00:00
qs422016 := string(qb422016.B)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:56
2017-01-24 15:09:23 +00:00
qt422016.ReleaseByteBuffer(qb422016)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:56
2017-01-24 15:09:23 +00:00
return qs422016
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:56
2017-01-24 15:09:23 +00:00
}
// CommandOptionFuncTemplate is the command option func template.
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:59
func StreamCommandOptionFuncTemplate(qw422016 *qt422016.Writer, t *internal.Type, c *internal.Type, d *internal.Domain, domains []*internal.Domain) {
//line templates/domain.qtpl:60
2017-01-24 15:09:23 +00:00
n := t.GoName(false)
2017-01-26 07:28:34 +00:00
optName := internal.OptionFuncPrefix + n + internal.OptionFuncSuffix
2017-01-24 15:09:23 +00:00
typ := c.CommandType()
v := t.GoName(true)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:64
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:65
qw422016.N().S(formatComment(t.GetDescription(), "", optName+" "))
//line templates/domain.qtpl:65
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
func (p `)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:66
2017-01-24 15:09:23 +00:00
qw422016.N().S(typ)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:66
2017-01-24 15:09:23 +00:00
qw422016.N().S(`) `)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:66
2017-01-24 15:09:23 +00:00
qw422016.N().S(optName)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:66
2017-01-24 15:09:23 +00:00
qw422016.N().S(`(`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:66
2017-01-24 15:09:23 +00:00
qw422016.N().S(v)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:66
2017-01-24 15:09:23 +00:00
qw422016.N().S(` `)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:66
2017-01-24 15:09:23 +00:00
qw422016.N().S(t.GoType(d, domains))
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:66
2017-01-24 15:09:23 +00:00
qw422016.N().S(`) *`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:66
2017-01-24 15:09:23 +00:00
qw422016.N().S(typ)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:66
2017-01-24 15:09:23 +00:00
qw422016.N().S(`{
p.`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:67
2017-01-24 15:09:23 +00:00
qw422016.N().S(n)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:67
2017-01-24 15:09:23 +00:00
qw422016.N().S(` = `)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:67
2017-01-24 15:09:23 +00:00
qw422016.N().S(v)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:67
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
return &p
}
`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:70
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:70
func WriteCommandOptionFuncTemplate(qq422016 qtio422016.Writer, t *internal.Type, c *internal.Type, d *internal.Domain, domains []*internal.Domain) {
//line templates/domain.qtpl:70
2017-01-24 15:09:23 +00:00
qw422016 := qt422016.AcquireWriter(qq422016)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:70
2017-01-24 15:09:23 +00:00
StreamCommandOptionFuncTemplate(qw422016, t, c, d, domains)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:70
2017-01-24 15:09:23 +00:00
qt422016.ReleaseWriter(qw422016)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:70
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:70
func CommandOptionFuncTemplate(t *internal.Type, c *internal.Type, d *internal.Domain, domains []*internal.Domain) string {
//line templates/domain.qtpl:70
2017-01-24 15:09:23 +00:00
qb422016 := qt422016.AcquireByteBuffer()
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:70
2017-01-24 15:09:23 +00:00
WriteCommandOptionFuncTemplate(qb422016, t, c, d, domains)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:70
2017-01-24 15:09:23 +00:00
qs422016 := string(qb422016.B)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:70
2017-01-24 15:09:23 +00:00
qt422016.ReleaseByteBuffer(qb422016)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:70
2017-01-24 15:09:23 +00:00
return qs422016
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:70
2017-01-24 15:09:23 +00:00
}
// CommandDoFuncTemplate is the command do func template.
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:73
func StreamCommandDoFuncTemplate(qw422016 *qt422016.Writer, c *internal.Type, d *internal.Domain, domains []*internal.Domain) {
//line templates/domain.qtpl:74
2017-01-24 15:09:23 +00:00
typ := c.CommandType()
hasEmptyParams := len(c.Parameters) == 0
hasEmptyRet := len(c.Returns) == 0
emptyRet := c.EmptyRetList(d, domains)
if emptyRet != "" {
emptyRet += ", "
}
retTypeList := c.RetTypeList(d, domains)
if retTypeList != "" {
retTypeList += ", "
}
retValueList := c.RetValueList(d, domains)
if retValueList != "" {
retValueList += ", "
}
b64ret := c.Base64EncodedRetParam()
// determine if there's a conditional return value with it
b64cond := false
for _, p := range c.Returns {
2017-01-26 07:28:34 +00:00
if p.Name == internal.Base64EncodedParamName {
2017-01-24 15:09:23 +00:00
b64cond = true
break
}
}
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:104
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
// Do executes `)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:105
2017-01-24 15:09:23 +00:00
qw422016.N().S(c.ProtoName(d))
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:105
2017-01-24 15:09:23 +00:00
qw422016.N().S(`.`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:105
2017-01-24 15:09:23 +00:00
if len(c.Returns) > 0 {
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:105
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
//
// returns:`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:107
2017-01-24 15:09:23 +00:00
for _, p := range c.Returns {
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:107
if p.Name == internal.Base64EncodedParamName {
//line templates/domain.qtpl:107
2017-01-24 15:09:23 +00:00
continue
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:107
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:107
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
// `)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:108
2017-01-24 15:09:23 +00:00
qw422016.N().S(p.String())
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:108
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:108
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:108
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
func (p *`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:109
2017-01-24 15:09:23 +00:00
qw422016.N().S(typ)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:109
qw422016.N().S(`) Do(ctxt context.Context, h cdp.FrameHandler) (`)
//line templates/domain.qtpl:109
2017-01-24 15:09:23 +00:00
qw422016.N().S(retTypeList)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:109
2017-01-24 15:09:23 +00:00
qw422016.N().S(`err error) {
if ctxt == nil {
ctxt = context.Background()
}`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:112
2017-01-24 15:09:23 +00:00
if !hasEmptyParams {
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:112
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return `)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:117
2017-01-24 15:09:23 +00:00
qw422016.N().S(emptyRet)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:117
2017-01-24 15:09:23 +00:00
qw422016.N().S(`err
}`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:118
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:118
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
// execute
2017-01-26 07:28:34 +00:00
ch := h.Execute(ctxt, cdp.`)
//line templates/domain.qtpl:121
2017-01-24 15:09:23 +00:00
qw422016.N().S(c.CommandMethodType(d))
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:121
2017-01-24 15:09:23 +00:00
qw422016.N().S(`, `)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:121
2017-01-24 15:09:23 +00:00
if hasEmptyParams {
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:121
qw422016.N().S(`cdp.Empty`)
//line templates/domain.qtpl:121
2017-01-24 15:09:23 +00:00
} else {
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:121
2017-01-24 15:09:23 +00:00
qw422016.N().S(`easyjson.RawMessage(buf)`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:121
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:121
2017-01-24 15:09:23 +00:00
qw422016.N().S(`)
// read response
select {
case res := <-ch:
if res == nil {
return `)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:127
2017-01-24 15:09:23 +00:00
qw422016.N().S(emptyRet)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:127
qw422016.N().S(`cdp.ErrChannelClosed
2017-01-24 15:09:23 +00:00
}
switch v := res.(type) {
case easyjson.RawMessage:`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:131
2017-01-24 15:09:23 +00:00
if !hasEmptyRet {
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:131
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
// unmarshal
var r `)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:133
2017-01-24 15:09:23 +00:00
qw422016.N().S(c.CommandReturnsType())
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:133
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
err = easyjson.Unmarshal(v, &r)
if err != nil {
return `)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:136
2017-01-24 15:09:23 +00:00
qw422016.N().S(emptyRet)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:136
qw422016.N().S(`cdp.ErrInvalidResult
2017-01-24 15:09:23 +00:00
}`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:137
2017-01-24 15:09:23 +00:00
if b64ret != nil {
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:137
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
// decode
var dec []byte`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:140
2017-01-24 15:09:23 +00:00
if b64cond {
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:140
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
if r.Base64encoded {`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:141
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:141
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
dec, err = base64.StdEncoding.DecodeString(r.`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:142
2017-01-24 15:09:23 +00:00
qw422016.N().S(b64ret.GoName(false))
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:142
2017-01-24 15:09:23 +00:00
qw422016.N().S(`)
if err != nil {
return nil, err
}`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:145
2017-01-24 15:09:23 +00:00
if b64cond {
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:145
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
} else {
dec = []byte(r.`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:147
2017-01-24 15:09:23 +00:00
qw422016.N().S(b64ret.GoName(false))
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:147
2017-01-24 15:09:23 +00:00
qw422016.N().S(`)
}`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:148
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:148
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:148
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:149
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:149
2017-01-24 15:09:23 +00:00
qw422016.N().S(`
return `)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:150
2017-01-24 15:09:23 +00:00
qw422016.N().S(retValueList)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:150
2017-01-24 15:09:23 +00:00
qw422016.N().S(`nil
case error:
return `)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:153
2017-01-24 15:09:23 +00:00
qw422016.N().S(emptyRet)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:153
2017-01-24 15:09:23 +00:00
qw422016.N().S(`v
}
case <-ctxt.Done():
return `)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:157
2017-01-24 15:09:23 +00:00
qw422016.N().S(emptyRet)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:157
qw422016.N().S(`cdp.ErrContextDone
2017-01-24 15:09:23 +00:00
}
return `)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:160
2017-01-24 15:09:23 +00:00
qw422016.N().S(emptyRet)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:160
qw422016.N().S(`cdp.ErrUnknownResult
2017-01-24 15:09:23 +00:00
}
`)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:162
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:162
func WriteCommandDoFuncTemplate(qq422016 qtio422016.Writer, c *internal.Type, d *internal.Domain, domains []*internal.Domain) {
//line templates/domain.qtpl:162
2017-01-24 15:09:23 +00:00
qw422016 := qt422016.AcquireWriter(qq422016)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:162
2017-01-24 15:09:23 +00:00
StreamCommandDoFuncTemplate(qw422016, c, d, domains)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:162
2017-01-24 15:09:23 +00:00
qt422016.ReleaseWriter(qw422016)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:162
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:162
func CommandDoFuncTemplate(c *internal.Type, d *internal.Domain, domains []*internal.Domain) string {
//line templates/domain.qtpl:162
2017-01-24 15:09:23 +00:00
qb422016 := qt422016.AcquireByteBuffer()
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:162
2017-01-24 15:09:23 +00:00
WriteCommandDoFuncTemplate(qb422016, c, d, domains)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:162
2017-01-24 15:09:23 +00:00
qs422016 := string(qb422016.B)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:162
2017-01-24 15:09:23 +00:00
qt422016.ReleaseByteBuffer(qb422016)
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:162
2017-01-24 15:09:23 +00:00
return qs422016
2017-01-26 07:28:34 +00:00
//line templates/domain.qtpl:162
2017-01-24 15:09:23 +00:00
}