easyjson.go 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. // Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.
  2. package cdproto
  3. import (
  4. json "encoding/json"
  5. target "github.com/chromedp/cdproto/target"
  6. easyjson "github.com/mailru/easyjson"
  7. jlexer "github.com/mailru/easyjson/jlexer"
  8. jwriter "github.com/mailru/easyjson/jwriter"
  9. )
  10. // suppress unused package warning
  11. var (
  12. _ *json.RawMessage
  13. _ *jlexer.Lexer
  14. _ *jwriter.Writer
  15. _ easyjson.Marshaler
  16. )
  17. func easyjsonC5a4559bDecodeGithubComChromedpCdproto(in *jlexer.Lexer, out *empty) {
  18. isTopLevel := in.IsStart()
  19. if in.IsNull() {
  20. if isTopLevel {
  21. in.Consumed()
  22. }
  23. in.Skip()
  24. return
  25. }
  26. in.Delim('{')
  27. for !in.IsDelim('}') {
  28. key := in.UnsafeFieldName(false)
  29. in.WantColon()
  30. if in.IsNull() {
  31. in.Skip()
  32. in.WantComma()
  33. continue
  34. }
  35. switch key {
  36. default:
  37. in.SkipRecursive()
  38. }
  39. in.WantComma()
  40. }
  41. in.Delim('}')
  42. if isTopLevel {
  43. in.Consumed()
  44. }
  45. }
  46. func easyjsonC5a4559bEncodeGithubComChromedpCdproto(out *jwriter.Writer, in empty) {
  47. out.RawByte('{')
  48. first := true
  49. _ = first
  50. out.RawByte('}')
  51. }
  52. // MarshalJSON supports json.Marshaler interface
  53. func (v empty) MarshalJSON() ([]byte, error) {
  54. w := jwriter.Writer{}
  55. easyjsonC5a4559bEncodeGithubComChromedpCdproto(&w, v)
  56. return w.Buffer.BuildBytes(), w.Error
  57. }
  58. // MarshalEasyJSON supports easyjson.Marshaler interface
  59. func (v empty) MarshalEasyJSON(w *jwriter.Writer) {
  60. easyjsonC5a4559bEncodeGithubComChromedpCdproto(w, v)
  61. }
  62. // UnmarshalJSON supports json.Unmarshaler interface
  63. func (v *empty) UnmarshalJSON(data []byte) error {
  64. r := jlexer.Lexer{Data: data}
  65. easyjsonC5a4559bDecodeGithubComChromedpCdproto(&r, v)
  66. return r.Error()
  67. }
  68. // UnmarshalEasyJSON supports easyjson.Unmarshaler interface
  69. func (v *empty) UnmarshalEasyJSON(l *jlexer.Lexer) {
  70. easyjsonC5a4559bDecodeGithubComChromedpCdproto(l, v)
  71. }
  72. func easyjsonC5a4559bDecodeGithubComChromedpCdproto1(in *jlexer.Lexer, out *Message) {
  73. isTopLevel := in.IsStart()
  74. if in.IsNull() {
  75. if isTopLevel {
  76. in.Consumed()
  77. }
  78. in.Skip()
  79. return
  80. }
  81. in.Delim('{')
  82. for !in.IsDelim('}') {
  83. key := in.UnsafeFieldName(false)
  84. in.WantColon()
  85. if in.IsNull() {
  86. in.Skip()
  87. in.WantComma()
  88. continue
  89. }
  90. switch key {
  91. case "id":
  92. out.ID = int64(in.Int64())
  93. case "sessionId":
  94. out.SessionID = target.SessionID(in.String())
  95. case "method":
  96. out.Method = MethodType(in.String())
  97. case "params":
  98. (out.Params).UnmarshalEasyJSON(in)
  99. case "result":
  100. (out.Result).UnmarshalEasyJSON(in)
  101. case "error":
  102. if in.IsNull() {
  103. in.Skip()
  104. out.Error = nil
  105. } else {
  106. if out.Error == nil {
  107. out.Error = new(Error)
  108. }
  109. (*out.Error).UnmarshalEasyJSON(in)
  110. }
  111. default:
  112. in.SkipRecursive()
  113. }
  114. in.WantComma()
  115. }
  116. in.Delim('}')
  117. if isTopLevel {
  118. in.Consumed()
  119. }
  120. }
  121. func easyjsonC5a4559bEncodeGithubComChromedpCdproto1(out *jwriter.Writer, in Message) {
  122. out.RawByte('{')
  123. first := true
  124. _ = first
  125. if in.ID != 0 {
  126. const prefix string = ",\"id\":"
  127. first = false
  128. out.RawString(prefix[1:])
  129. out.Int64(int64(in.ID))
  130. }
  131. if in.SessionID != "" {
  132. const prefix string = ",\"sessionId\":"
  133. if first {
  134. first = false
  135. out.RawString(prefix[1:])
  136. } else {
  137. out.RawString(prefix)
  138. }
  139. out.String(string(in.SessionID))
  140. }
  141. if in.Method != "" {
  142. const prefix string = ",\"method\":"
  143. if first {
  144. first = false
  145. out.RawString(prefix[1:])
  146. } else {
  147. out.RawString(prefix)
  148. }
  149. out.String(string(in.Method))
  150. }
  151. if (in.Params).IsDefined() {
  152. const prefix string = ",\"params\":"
  153. if first {
  154. first = false
  155. out.RawString(prefix[1:])
  156. } else {
  157. out.RawString(prefix)
  158. }
  159. (in.Params).MarshalEasyJSON(out)
  160. }
  161. if (in.Result).IsDefined() {
  162. const prefix string = ",\"result\":"
  163. if first {
  164. first = false
  165. out.RawString(prefix[1:])
  166. } else {
  167. out.RawString(prefix)
  168. }
  169. (in.Result).MarshalEasyJSON(out)
  170. }
  171. if in.Error != nil {
  172. const prefix string = ",\"error\":"
  173. if first {
  174. first = false
  175. out.RawString(prefix[1:])
  176. } else {
  177. out.RawString(prefix)
  178. }
  179. (*in.Error).MarshalEasyJSON(out)
  180. }
  181. out.RawByte('}')
  182. }
  183. // MarshalJSON supports json.Marshaler interface
  184. func (v Message) MarshalJSON() ([]byte, error) {
  185. w := jwriter.Writer{}
  186. easyjsonC5a4559bEncodeGithubComChromedpCdproto1(&w, v)
  187. return w.Buffer.BuildBytes(), w.Error
  188. }
  189. // MarshalEasyJSON supports easyjson.Marshaler interface
  190. func (v Message) MarshalEasyJSON(w *jwriter.Writer) {
  191. easyjsonC5a4559bEncodeGithubComChromedpCdproto1(w, v)
  192. }
  193. // UnmarshalJSON supports json.Unmarshaler interface
  194. func (v *Message) UnmarshalJSON(data []byte) error {
  195. r := jlexer.Lexer{Data: data}
  196. easyjsonC5a4559bDecodeGithubComChromedpCdproto1(&r, v)
  197. return r.Error()
  198. }
  199. // UnmarshalEasyJSON supports easyjson.Unmarshaler interface
  200. func (v *Message) UnmarshalEasyJSON(l *jlexer.Lexer) {
  201. easyjsonC5a4559bDecodeGithubComChromedpCdproto1(l, v)
  202. }
  203. func easyjsonC5a4559bDecodeGithubComChromedpCdproto2(in *jlexer.Lexer, out *Error) {
  204. isTopLevel := in.IsStart()
  205. if in.IsNull() {
  206. if isTopLevel {
  207. in.Consumed()
  208. }
  209. in.Skip()
  210. return
  211. }
  212. in.Delim('{')
  213. for !in.IsDelim('}') {
  214. key := in.UnsafeFieldName(false)
  215. in.WantColon()
  216. if in.IsNull() {
  217. in.Skip()
  218. in.WantComma()
  219. continue
  220. }
  221. switch key {
  222. case "code":
  223. out.Code = int64(in.Int64())
  224. case "message":
  225. out.Message = string(in.String())
  226. default:
  227. in.SkipRecursive()
  228. }
  229. in.WantComma()
  230. }
  231. in.Delim('}')
  232. if isTopLevel {
  233. in.Consumed()
  234. }
  235. }
  236. func easyjsonC5a4559bEncodeGithubComChromedpCdproto2(out *jwriter.Writer, in Error) {
  237. out.RawByte('{')
  238. first := true
  239. _ = first
  240. {
  241. const prefix string = ",\"code\":"
  242. out.RawString(prefix[1:])
  243. out.Int64(int64(in.Code))
  244. }
  245. {
  246. const prefix string = ",\"message\":"
  247. out.RawString(prefix)
  248. out.String(string(in.Message))
  249. }
  250. out.RawByte('}')
  251. }
  252. // MarshalJSON supports json.Marshaler interface
  253. func (v Error) MarshalJSON() ([]byte, error) {
  254. w := jwriter.Writer{}
  255. easyjsonC5a4559bEncodeGithubComChromedpCdproto2(&w, v)
  256. return w.Buffer.BuildBytes(), w.Error
  257. }
  258. // MarshalEasyJSON supports easyjson.Marshaler interface
  259. func (v Error) MarshalEasyJSON(w *jwriter.Writer) {
  260. easyjsonC5a4559bEncodeGithubComChromedpCdproto2(w, v)
  261. }
  262. // UnmarshalJSON supports json.Unmarshaler interface
  263. func (v *Error) UnmarshalJSON(data []byte) error {
  264. r := jlexer.Lexer{Data: data}
  265. easyjsonC5a4559bDecodeGithubComChromedpCdproto2(&r, v)
  266. return r.Error()
  267. }
  268. // UnmarshalEasyJSON supports easyjson.Unmarshaler interface
  269. func (v *Error) UnmarshalEasyJSON(l *jlexer.Lexer) {
  270. easyjsonC5a4559bDecodeGithubComChromedpCdproto2(l, v)
  271. }