// This file is automatically generated by qtc from "extra.qtpl". // See https://github.com/valyala/quicktemplate for details. //line templates/extra.qtpl:1 package templates //line templates/extra.qtpl:1 import ( qtio422016 "io" qt422016 "github.com/valyala/quicktemplate" ) //line templates/extra.qtpl:1 import ( . "github.com/knq/chromedp/cmd/chromedp-gen/internal" ) // ExtraTimestampTemplate is a special template for the Timestamp type that // defines its JSON unmarshaling. //line templates/extra.qtpl:7 var ( _ = qtio422016.Copy _ = qt422016.AcquireByteBuffer ) //line templates/extra.qtpl:7 func StreamExtraTimestampTemplate(qw422016 *qt422016.Writer, t *Type, d *Domain) { //line templates/extra.qtpl:8 typ := t.IdOrName() //line templates/extra.qtpl:9 qw422016.N().S(` // MarshalEasyJSON satisfies easyjson.Marshaler. func (t `) //line templates/extra.qtpl:11 qw422016.N().S(typ) //line templates/extra.qtpl:11 qw422016.N().S(`) MarshalEasyJSON(out *jwriter.Writer) { out.Float64(float64(time.Time(t).Sub(sysutil.BootTime()))/float64(time.Second)) } // MarshalJSON satisfies json.Marshaler. func (t `) //line templates/extra.qtpl:16 qw422016.N().S(typ) //line templates/extra.qtpl:16 qw422016.N().S(`) MarshalJSON() ([]byte, error) { return easyjson.Marshal(t) } // UnmarshalEasyJSON satisfies easyjson.Unmarshaler. func (t *`) //line templates/extra.qtpl:21 qw422016.N().S(typ) //line templates/extra.qtpl:21 qw422016.N().S(`) UnmarshalEasyJSON(in *jlexer.Lexer) { *t = `) //line templates/extra.qtpl:22 qw422016.N().S(typ) //line templates/extra.qtpl:22 qw422016.N().S(`(sysutil.BootTime().Add(time.Duration(in.Float64()*float64(time.Second)))) } // UnmarshalJSON satisfies json.Unmarshaler. func (t *`) //line templates/extra.qtpl:26 qw422016.N().S(typ) //line templates/extra.qtpl:26 qw422016.N().S(`) UnmarshalJSON(buf []byte) error { return easyjson.Unmarshal(buf, t) } `) //line templates/extra.qtpl:29 } //line templates/extra.qtpl:29 func WriteExtraTimestampTemplate(qq422016 qtio422016.Writer, t *Type, d *Domain) { //line templates/extra.qtpl:29 qw422016 := qt422016.AcquireWriter(qq422016) //line templates/extra.qtpl:29 StreamExtraTimestampTemplate(qw422016, t, d) //line templates/extra.qtpl:29 qt422016.ReleaseWriter(qw422016) //line templates/extra.qtpl:29 } //line templates/extra.qtpl:29 func ExtraTimestampTemplate(t *Type, d *Domain) string { //line templates/extra.qtpl:29 qb422016 := qt422016.AcquireByteBuffer() //line templates/extra.qtpl:29 WriteExtraTimestampTemplate(qb422016, t, d) //line templates/extra.qtpl:29 qs422016 := string(qb422016.B) //line templates/extra.qtpl:29 qt422016.ReleaseByteBuffer(qb422016) //line templates/extra.qtpl:29 return qs422016 //line templates/extra.qtpl:29 } // ExtraFrameTemplate is a special template for the Page.Frame type, adding FrameState. //line templates/extra.qtpl:32 func StreamExtraFrameTemplate(qw422016 *qt422016.Writer) { //line templates/extra.qtpl:32 qw422016.N().S(` // FrameState is the state of a Frame. type FrameState uint16 // FrameState enum values. const ( FrameDOMContentEventFired FrameState = 1 << (15 - iota) FrameLoadEventFired FrameAttached FrameNavigated FrameLoading FrameScheduledNavigation ) // frameStateNames are the names of the frame states. var frameStateNames = map[FrameState]string{ FrameDOMContentEventFired: "DOMContentEventFired", FrameLoadEventFired: "LoadEventFired", FrameAttached: "Attached", FrameNavigated: "Navigated", FrameLoading: "Loading", FrameScheduledNavigation: "ScheduledNavigation", } // String satisfies stringer interface. func (fs FrameState) String() string { var s []string for k, v := range frameStateNames { if fs&k != 0 { s = append(s, v) } } return "[" + strings.Join(s, " ") + "]" } `) //line templates/extra.qtpl:66 } //line templates/extra.qtpl:66 func WriteExtraFrameTemplate(qq422016 qtio422016.Writer) { //line templates/extra.qtpl:66 qw422016 := qt422016.AcquireWriter(qq422016) //line templates/extra.qtpl:66 StreamExtraFrameTemplate(qw422016) //line templates/extra.qtpl:66 qt422016.ReleaseWriter(qw422016) //line templates/extra.qtpl:66 } //line templates/extra.qtpl:66 func ExtraFrameTemplate() string { //line templates/extra.qtpl:66 qb422016 := qt422016.AcquireByteBuffer() //line templates/extra.qtpl:66 WriteExtraFrameTemplate(qb422016) //line templates/extra.qtpl:66 qs422016 := string(qb422016.B) //line templates/extra.qtpl:66 qt422016.ReleaseByteBuffer(qb422016) //line templates/extra.qtpl:66 return qs422016 //line templates/extra.qtpl:66 } // ExtraNodeTemplate is a special template for the DOM.Node type, adding NodeState. //line templates/extra.qtpl:69 func StreamExtraNodeTemplate(qw422016 *qt422016.Writer) { //line templates/extra.qtpl:69 qw422016.N().S(` // AttributeValue returns the named attribute for the node. func (n *Node) AttributeValue(name string) string { n.RLock() defer n.RUnlock() for i := 0; i < len(n.Attributes); i+=2 { if n.Attributes[i] == name { return n.Attributes[i+1] } } return "" } // xpath builds the xpath string. func (n *Node) xpath(stopWhenID bool) string { p := "" pos := "" id := n.AttributeValue("id") switch { case n.Parent == nil: return n.LocalName case stopWhenID && id != "": p = "/" pos = `) //line templates/extra.qtpl:69 qw422016.N().S("`") //line templates/extra.qtpl:69 qw422016.N().S(`[@id='`) //line templates/extra.qtpl:69 qw422016.N().S("`") //line templates/extra.qtpl:69 qw422016.N().S(`+id+`) //line templates/extra.qtpl:69 qw422016.N().S("`") //line templates/extra.qtpl:69 qw422016.N().S(`']`) //line templates/extra.qtpl:69 qw422016.N().S("`") //line templates/extra.qtpl:69 qw422016.N().S(` case n.Parent != nil: i := 0 var found bool for j := 0; j < len(n.Parent.Children); j++ { if n.Parent.Children[j].LocalName == n.LocalName { i++ } if n.Parent.Children[j].NodeID == n.NodeID { found = true break } } p = n.Parent.xpath(stopWhenID) if found { pos = "["+strconv.Itoa(i)+"]" } } return p + "/" + n.LocalName + pos } // XPathByID returns the XPath tree for the node, stopping at the first parent // with an id attribute. func (n *Node) XPathByID() string { return n.xpath(true) } // XPath returns the full XPath tree for the node. func (n *Node) XPath() string { return n.xpath(false) } // NodeState is the state of a DOM node. type NodeState uint8 // NodeState enum values. const ( NodeReady NodeState = 1 << (7 - iota) NodeVisible NodeHighlighted ) // nodeStateNames are the names of the node states. var nodeStateNames = map[NodeState]string{ NodeReady: "Ready", NodeVisible: "Visible", NodeHighlighted: "Highlighted", } // String satisfies stringer interface. func (ns NodeState) String() string { var s []string for k, v := range nodeStateNames { if ns&k != 0 { s = append(s, v) } } return "[" + strings.Join(s, " ") + "]" } `) //line templates/extra.qtpl:157 } //line templates/extra.qtpl:157 func WriteExtraNodeTemplate(qq422016 qtio422016.Writer) { //line templates/extra.qtpl:157 qw422016 := qt422016.AcquireWriter(qq422016) //line templates/extra.qtpl:157 StreamExtraNodeTemplate(qw422016) //line templates/extra.qtpl:157 qt422016.ReleaseWriter(qw422016) //line templates/extra.qtpl:157 } //line templates/extra.qtpl:157 func ExtraNodeTemplate() string { //line templates/extra.qtpl:157 qb422016 := qt422016.AcquireByteBuffer() //line templates/extra.qtpl:157 WriteExtraNodeTemplate(qb422016) //line templates/extra.qtpl:157 qs422016 := string(qb422016.B) //line templates/extra.qtpl:157 qt422016.ReleaseByteBuffer(qb422016) //line templates/extra.qtpl:157 return qs422016 //line templates/extra.qtpl:157 } // ExtraFixStringUnmarshaler is a template that forces values to be parsed properly. //line templates/extra.qtpl:160 func StreamExtraFixStringUnmarshaler(qw422016 *qt422016.Writer, typ, parseFunc, extra string) { //line templates/extra.qtpl:160 qw422016.N().S(` // UnmarshalEasyJSON satisfies easyjson.Unmarshaler. func (t *`) //line templates/extra.qtpl:162 qw422016.N().S(typ) //line templates/extra.qtpl:162 qw422016.N().S(`) UnmarshalEasyJSON(in *jlexer.Lexer) { buf := in.Raw() if l := len(buf); l > 2 && buf[0] == '"' && buf[l-1] == '"' { buf = buf[1:l-1] } `) //line templates/extra.qtpl:167 if parseFunc != "" { //line templates/extra.qtpl:167 qw422016.N().S(` v, err := strconv.`) //line templates/extra.qtpl:168 qw422016.N().S(parseFunc) //line templates/extra.qtpl:168 qw422016.N().S(`(string(buf)`) //line templates/extra.qtpl:168 qw422016.N().S(extra) //line templates/extra.qtpl:168 qw422016.N().S(`) if err != nil { in.AddError(err) } `) //line templates/extra.qtpl:172 } //line templates/extra.qtpl:172 qw422016.N().S(` *t = `) //line templates/extra.qtpl:173 qw422016.N().S(typ) //line templates/extra.qtpl:173 qw422016.N().S(`(`) //line templates/extra.qtpl:173 if parseFunc != "" { //line templates/extra.qtpl:173 qw422016.N().S(`v`) //line templates/extra.qtpl:173 } else { //line templates/extra.qtpl:173 qw422016.N().S(`buf`) //line templates/extra.qtpl:173 } //line templates/extra.qtpl:173 qw422016.N().S(`) } // UnmarshalJSON satisfies json.Unmarshaler. func (t *`) //line templates/extra.qtpl:177 qw422016.N().S(typ) //line templates/extra.qtpl:177 qw422016.N().S(`) UnmarshalJSON(buf []byte) error { return easyjson.Unmarshal(buf, t) } `) //line templates/extra.qtpl:180 } //line templates/extra.qtpl:180 func WriteExtraFixStringUnmarshaler(qq422016 qtio422016.Writer, typ, parseFunc, extra string) { //line templates/extra.qtpl:180 qw422016 := qt422016.AcquireWriter(qq422016) //line templates/extra.qtpl:180 StreamExtraFixStringUnmarshaler(qw422016, typ, parseFunc, extra) //line templates/extra.qtpl:180 qt422016.ReleaseWriter(qw422016) //line templates/extra.qtpl:180 } //line templates/extra.qtpl:180 func ExtraFixStringUnmarshaler(typ, parseFunc, extra string) string { //line templates/extra.qtpl:180 qb422016 := qt422016.AcquireByteBuffer() //line templates/extra.qtpl:180 WriteExtraFixStringUnmarshaler(qb422016, typ, parseFunc, extra) //line templates/extra.qtpl:180 qs422016 := string(qb422016.B) //line templates/extra.qtpl:180 qt422016.ReleaseByteBuffer(qb422016) //line templates/extra.qtpl:180 return qs422016 //line templates/extra.qtpl:180 } // ExtraInternalTypes is the template for additional internal type // declarations. //line templates/extra.qtpl:184 func StreamExtraInternalTypes(qw422016 *qt422016.Writer) { //line templates/extra.qtpl:184 qw422016.N().S(` // Error satisfies the error interface. func (t ErrorType) Error() string { return string(t) } // FrameHandler is the common interface for a frame handler. type FrameHandler interface { SetActive(context.Context, FrameID) error GetRoot(context.Context) (*Node, error) WaitFrame(context.Context, FrameID) (*Frame, error) WaitNode(context.Context, *Frame, NodeID) (*Node, error) Listen(...MethodType) <-chan interface{} // Execute executes the specified command using the supplied context and // parameters. Execute(context.Context, MethodType, easyjson.RawMessage) <-chan interface{} } // Empty is an empty JSON object message var Empty = easyjson.RawMessage(`) //line templates/extra.qtpl:184 qw422016.N().S("`") //line templates/extra.qtpl:184 qw422016.N().S(`{}`) //line templates/extra.qtpl:184 qw422016.N().S("`") //line templates/extra.qtpl:184 qw422016.N().S(`) `) //line templates/extra.qtpl:206 } //line templates/extra.qtpl:206 func WriteExtraInternalTypes(qq422016 qtio422016.Writer) { //line templates/extra.qtpl:206 qw422016 := qt422016.AcquireWriter(qq422016) //line templates/extra.qtpl:206 StreamExtraInternalTypes(qw422016) //line templates/extra.qtpl:206 qt422016.ReleaseWriter(qw422016) //line templates/extra.qtpl:206 } //line templates/extra.qtpl:206 func ExtraInternalTypes() string { //line templates/extra.qtpl:206 qb422016 := qt422016.AcquireByteBuffer() //line templates/extra.qtpl:206 WriteExtraInternalTypes(qb422016) //line templates/extra.qtpl:206 qs422016 := string(qb422016.B) //line templates/extra.qtpl:206 qt422016.ReleaseByteBuffer(qb422016) //line templates/extra.qtpl:206 return qs422016 //line templates/extra.qtpl:206 } // ExtraUtilTemplate generates the decode func for the Message type. //line templates/extra.qtpl:209 func StreamExtraUtilTemplate(qw422016 *qt422016.Writer, domains []*Domain) { //line templates/extra.qtpl:209 qw422016.N().S(` type empty struct{} var emptyVal = &empty{} // UnmarshalMessage unmarshals the message result or params. func UnmarshalMessage(msg *Message) (interface{}, error) { var v easyjson.Unmarshaler switch msg.Method {`) //line templates/extra.qtpl:216 for _, d := range domains { //line templates/extra.qtpl:216 for _, c := range d.Commands { //line templates/extra.qtpl:216 qw422016.N().S(` case `) //line templates/extra.qtpl:217 qw422016.N().S(c.CommandMethodType(d)) //line templates/extra.qtpl:217 qw422016.N().S(`:`) //line templates/extra.qtpl:217 if len(c.Returns) == 0 { //line templates/extra.qtpl:217 qw422016.N().S(` return emptyVal, nil`) //line templates/extra.qtpl:218 } else { //line templates/extra.qtpl:218 qw422016.N().S(` v = new(`) //line templates/extra.qtpl:219 qw422016.N().S(d.PackageRefName()) //line templates/extra.qtpl:219 qw422016.N().S(`.`) //line templates/extra.qtpl:219 qw422016.N().S(c.CommandReturnsType()) //line templates/extra.qtpl:219 qw422016.N().S(`)`) //line templates/extra.qtpl:219 } //line templates/extra.qtpl:219 qw422016.N().S(` `) //line templates/extra.qtpl:220 } //line templates/extra.qtpl:220 for _, e := range d.Events { //line templates/extra.qtpl:220 qw422016.N().S(` case `) //line templates/extra.qtpl:221 qw422016.N().S(e.EventMethodType(d)) //line templates/extra.qtpl:221 qw422016.N().S(`: v = new(`) //line templates/extra.qtpl:222 qw422016.N().S(d.PackageRefName()) //line templates/extra.qtpl:222 qw422016.N().S(`.`) //line templates/extra.qtpl:222 qw422016.N().S(e.EventType()) //line templates/extra.qtpl:222 qw422016.N().S(`) `) //line templates/extra.qtpl:223 } //line templates/extra.qtpl:223 } //line templates/extra.qtpl:223 qw422016.N().S(`} var buf easyjson.RawMessage switch { case msg.Params != nil: buf = msg.Params case msg.Result != nil: buf = msg.Result default: return nil, errors.New("msg missing params or result") } err := easyjson.Unmarshal(buf, v) if err != nil { return nil, err } return v, nil } `) //line templates/extra.qtpl:244 } //line templates/extra.qtpl:244 func WriteExtraUtilTemplate(qq422016 qtio422016.Writer, domains []*Domain) { //line templates/extra.qtpl:244 qw422016 := qt422016.AcquireWriter(qq422016) //line templates/extra.qtpl:244 StreamExtraUtilTemplate(qw422016, domains) //line templates/extra.qtpl:244 qt422016.ReleaseWriter(qw422016) //line templates/extra.qtpl:244 } //line templates/extra.qtpl:244 func ExtraUtilTemplate(domains []*Domain) string { //line templates/extra.qtpl:244 qb422016 := qt422016.AcquireByteBuffer() //line templates/extra.qtpl:244 WriteExtraUtilTemplate(qb422016, domains) //line templates/extra.qtpl:244 qs422016 := string(qb422016.B) //line templates/extra.qtpl:244 qt422016.ReleaseByteBuffer(qb422016) //line templates/extra.qtpl:244 return qs422016 //line templates/extra.qtpl:244 } //line templates/extra.qtpl:246 func StreamExtraMethodTypeDomainDecoder(qw422016 *qt422016.Writer) { //line templates/extra.qtpl:246 qw422016.N().S(` // Domain returns the Chrome Debugging Protocol domain of the event or command. func (t MethodType) Domain() string { return string(t[:strings.IndexByte(string(t), '.')]) } `) //line templates/extra.qtpl:251 } //line templates/extra.qtpl:251 func WriteExtraMethodTypeDomainDecoder(qq422016 qtio422016.Writer) { //line templates/extra.qtpl:251 qw422016 := qt422016.AcquireWriter(qq422016) //line templates/extra.qtpl:251 StreamExtraMethodTypeDomainDecoder(qw422016) //line templates/extra.qtpl:251 qt422016.ReleaseWriter(qw422016) //line templates/extra.qtpl:251 } //line templates/extra.qtpl:251 func ExtraMethodTypeDomainDecoder() string { //line templates/extra.qtpl:251 qb422016 := qt422016.AcquireByteBuffer() //line templates/extra.qtpl:251 WriteExtraMethodTypeDomainDecoder(qb422016) //line templates/extra.qtpl:251 qs422016 := string(qb422016.B) //line templates/extra.qtpl:251 qt422016.ReleaseByteBuffer(qb422016) //line templates/extra.qtpl:251 return qs422016 //line templates/extra.qtpl:251 }