aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/golang.org/x/net/html/atom/gen.go
diff options
context:
space:
mode:
authorAlex Pilon <apilon@hashicorp.com>2019-02-22 18:24:37 -0500
committerAlex Pilon <apilon@hashicorp.com>2019-02-22 18:24:37 -0500
commit15c0b25d011f37e7c20aeca9eaf461f78285b8d9 (patch)
tree255c250a5c9d4801c74092d33b7337d8c14438ff /vendor/golang.org/x/net/html/atom/gen.go
parent07971ca38143c5faf951d152fba370ddcbe26ad5 (diff)
downloadterraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.tar.gz
terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.tar.zst
terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.zip
deps: github.com/hashicorp/terraform@sdk-v0.11-with-go-modules
Updated via: go get github.com/hashicorp/terraform@sdk-v0.11-with-go-modules and go mod tidy
Diffstat (limited to 'vendor/golang.org/x/net/html/atom/gen.go')
-rw-r--r--vendor/golang.org/x/net/html/atom/gen.go135
1 files changed, 98 insertions, 37 deletions
diff --git a/vendor/golang.org/x/net/html/atom/gen.go b/vendor/golang.org/x/net/html/atom/gen.go
index 6bfa866..cc5dc5d 100644
--- a/vendor/golang.org/x/net/html/atom/gen.go
+++ b/vendor/golang.org/x/net/html/atom/gen.go
@@ -4,17 +4,17 @@
4 4
5// +build ignore 5// +build ignore
6 6
7package main 7//go:generate go run gen.go
8//go:generate go run gen.go -test
8 9
9// This program generates table.go and table_test.go. 10package main
10// Invoke as
11//
12// go run gen.go |gofmt >table.go
13// go run gen.go -test |gofmt >table_test.go
14 11
15import ( 12import (
13 "bytes"
16 "flag" 14 "flag"
17 "fmt" 15 "fmt"
16 "go/format"
17 "io/ioutil"
18 "math/rand" 18 "math/rand"
19 "os" 19 "os"
20 "sort" 20 "sort"
@@ -42,6 +42,18 @@ func identifier(s string) string {
42 42
43var test = flag.Bool("test", false, "generate table_test.go") 43var test = flag.Bool("test", false, "generate table_test.go")
44 44
45func genFile(name string, buf *bytes.Buffer) {
46 b, err := format.Source(buf.Bytes())
47 if err != nil {
48 fmt.Fprintln(os.Stderr, err)
49 os.Exit(1)
50 }
51 if err := ioutil.WriteFile(name, b, 0644); err != nil {
52 fmt.Fprintln(os.Stderr, err)
53 os.Exit(1)
54 }
55}
56
45func main() { 57func main() {
46 flag.Parse() 58 flag.Parse()
47 59
@@ -52,32 +64,31 @@ func main() {
52 all = append(all, extra...) 64 all = append(all, extra...)
53 sort.Strings(all) 65 sort.Strings(all)
54 66
55 if *test {
56 fmt.Printf("// generated by go run gen.go -test; DO NOT EDIT\n\n")
57 fmt.Printf("package atom\n\n")
58 fmt.Printf("var testAtomList = []string{\n")
59 for _, s := range all {
60 fmt.Printf("\t%q,\n", s)
61 }
62 fmt.Printf("}\n")
63 return
64 }
65
66 // uniq - lists have dups 67 // uniq - lists have dups
67 // compute max len too
68 maxLen := 0
69 w := 0 68 w := 0
70 for _, s := range all { 69 for _, s := range all {
71 if w == 0 || all[w-1] != s { 70 if w == 0 || all[w-1] != s {
72 if maxLen < len(s) {
73 maxLen = len(s)
74 }
75 all[w] = s 71 all[w] = s
76 w++ 72 w++
77 } 73 }
78 } 74 }
79 all = all[:w] 75 all = all[:w]
80 76
77 if *test {
78 var buf bytes.Buffer
79 fmt.Fprintln(&buf, "// Code generated by go generate gen.go; DO NOT EDIT.\n")
80 fmt.Fprintln(&buf, "//go:generate go run gen.go -test\n")
81 fmt.Fprintln(&buf, "package atom\n")
82 fmt.Fprintln(&buf, "var testAtomList = []string{")
83 for _, s := range all {
84 fmt.Fprintf(&buf, "\t%q,\n", s)
85 }
86 fmt.Fprintln(&buf, "}")
87
88 genFile("table_test.go", &buf)
89 return
90 }
91
81 // Find hash that minimizes table size. 92 // Find hash that minimizes table size.
82 var best *table 93 var best *table
83 for i := 0; i < 1000000; i++ { 94 for i := 0; i < 1000000; i++ {
@@ -163,36 +174,46 @@ func main() {
163 atom[s] = uint32(off<<8 | len(s)) 174 atom[s] = uint32(off<<8 | len(s))
164 } 175 }
165 176
177 var buf bytes.Buffer
166 // Generate the Go code. 178 // Generate the Go code.
167 fmt.Printf("// generated by go run gen.go; DO NOT EDIT\n\n") 179 fmt.Fprintln(&buf, "// Code generated by go generate gen.go; DO NOT EDIT.\n")
168 fmt.Printf("package atom\n\nconst (\n") 180 fmt.Fprintln(&buf, "//go:generate go run gen.go\n")
181 fmt.Fprintln(&buf, "package atom\n\nconst (")
182
183 // compute max len
184 maxLen := 0
169 for _, s := range all { 185 for _, s := range all {
170 fmt.Printf("\t%s Atom = %#x\n", identifier(s), atom[s]) 186 if maxLen < len(s) {
187 maxLen = len(s)
188 }
189 fmt.Fprintf(&buf, "\t%s Atom = %#x\n", identifier(s), atom[s])
171 } 190 }
172 fmt.Printf(")\n\n") 191 fmt.Fprintln(&buf, ")\n")
173 192
174 fmt.Printf("const hash0 = %#x\n\n", best.h0) 193 fmt.Fprintf(&buf, "const hash0 = %#x\n\n", best.h0)
175 fmt.Printf("const maxAtomLen = %d\n\n", maxLen) 194 fmt.Fprintf(&buf, "const maxAtomLen = %d\n\n", maxLen)
176 195
177 fmt.Printf("var table = [1<<%d]Atom{\n", best.k) 196 fmt.Fprintf(&buf, "var table = [1<<%d]Atom{\n", best.k)
178 for i, s := range best.tab { 197 for i, s := range best.tab {
179 if s == "" { 198 if s == "" {
180 continue 199 continue
181 } 200 }
182 fmt.Printf("\t%#x: %#x, // %s\n", i, atom[s], s) 201 fmt.Fprintf(&buf, "\t%#x: %#x, // %s\n", i, atom[s], s)
183 } 202 }
184 fmt.Printf("}\n") 203 fmt.Fprintf(&buf, "}\n")
185 datasize := (1 << best.k) * 4 204 datasize := (1 << best.k) * 4
186 205
187 fmt.Printf("const atomText =\n") 206 fmt.Fprintln(&buf, "const atomText =")
188 textsize := len(text) 207 textsize := len(text)
189 for len(text) > 60 { 208 for len(text) > 60 {
190 fmt.Printf("\t%q +\n", text[:60]) 209 fmt.Fprintf(&buf, "\t%q +\n", text[:60])
191 text = text[60:] 210 text = text[60:]
192 } 211 }
193 fmt.Printf("\t%q\n\n", text) 212 fmt.Fprintf(&buf, "\t%q\n\n", text)
213
214 genFile("table.go", &buf)
194 215
195 fmt.Fprintf(os.Stderr, "%d atoms; %d string bytes + %d tables = %d total data\n", len(all), textsize, datasize, textsize+datasize) 216 fmt.Fprintf(os.Stdout, "%d atoms; %d string bytes + %d tables = %d total data\n", len(all), textsize, datasize, textsize+datasize)
196} 217}
197 218
198type byLen []string 219type byLen []string
@@ -285,8 +306,10 @@ func (t *table) push(i uint32, depth int) bool {
285 306
286// The lists of element names and attribute keys were taken from 307// The lists of element names and attribute keys were taken from
287// https://html.spec.whatwg.org/multipage/indices.html#index 308// https://html.spec.whatwg.org/multipage/indices.html#index
288// as of the "HTML Living Standard - Last Updated 21 February 2015" version. 309// as of the "HTML Living Standard - Last Updated 18 September 2017" version.
289 310
311// "command", "keygen" and "menuitem" have been removed from the spec,
312// but are kept here for backwards compatibility.
290var elements = []string{ 313var elements = []string{
291 "a", 314 "a",
292 "abbr", 315 "abbr",
@@ -349,6 +372,7 @@ var elements = []string{
349 "legend", 372 "legend",
350 "li", 373 "li",
351 "link", 374 "link",
375 "main",
352 "map", 376 "map",
353 "mark", 377 "mark",
354 "menu", 378 "menu",
@@ -364,6 +388,7 @@ var elements = []string{
364 "output", 388 "output",
365 "p", 389 "p",
366 "param", 390 "param",
391 "picture",
367 "pre", 392 "pre",
368 "progress", 393 "progress",
369 "q", 394 "q",
@@ -375,6 +400,7 @@ var elements = []string{
375 "script", 400 "script",
376 "section", 401 "section",
377 "select", 402 "select",
403 "slot",
378 "small", 404 "small",
379 "source", 405 "source",
380 "span", 406 "span",
@@ -403,14 +429,21 @@ var elements = []string{
403} 429}
404 430
405// https://html.spec.whatwg.org/multipage/indices.html#attributes-3 431// https://html.spec.whatwg.org/multipage/indices.html#attributes-3
406 432//
433// "challenge", "command", "contextmenu", "dropzone", "icon", "keytype", "mediagroup",
434// "radiogroup", "spellcheck", "scoped", "seamless", "sortable" and "sorted" have been removed from the spec,
435// but are kept here for backwards compatibility.
407var attributes = []string{ 436var attributes = []string{
408 "abbr", 437 "abbr",
409 "accept", 438 "accept",
410 "accept-charset", 439 "accept-charset",
411 "accesskey", 440 "accesskey",
412 "action", 441 "action",
442 "allowfullscreen",
443 "allowpaymentrequest",
444 "allowusermedia",
413 "alt", 445 "alt",
446 "as",
414 "async", 447 "async",
415 "autocomplete", 448 "autocomplete",
416 "autofocus", 449 "autofocus",
@@ -420,6 +453,7 @@ var attributes = []string{
420 "checked", 453 "checked",
421 "cite", 454 "cite",
422 "class", 455 "class",
456 "color",
423 "cols", 457 "cols",
424 "colspan", 458 "colspan",
425 "command", 459 "command",
@@ -457,6 +491,8 @@ var attributes = []string{
457 "icon", 491 "icon",
458 "id", 492 "id",
459 "inputmode", 493 "inputmode",
494 "integrity",
495 "is",
460 "ismap", 496 "ismap",
461 "itemid", 497 "itemid",
462 "itemprop", 498 "itemprop",
@@ -481,16 +517,20 @@ var attributes = []string{
481 "multiple", 517 "multiple",
482 "muted", 518 "muted",
483 "name", 519 "name",
520 "nomodule",
521 "nonce",
484 "novalidate", 522 "novalidate",
485 "open", 523 "open",
486 "optimum", 524 "optimum",
487 "pattern", 525 "pattern",
488 "ping", 526 "ping",
489 "placeholder", 527 "placeholder",
528 "playsinline",
490 "poster", 529 "poster",
491 "preload", 530 "preload",
492 "radiogroup", 531 "radiogroup",
493 "readonly", 532 "readonly",
533 "referrerpolicy",
494 "rel", 534 "rel",
495 "required", 535 "required",
496 "reversed", 536 "reversed",
@@ -507,10 +547,13 @@ var attributes = []string{
507 "sizes", 547 "sizes",
508 "sortable", 548 "sortable",
509 "sorted", 549 "sorted",
550 "slot",
510 "span", 551 "span",
552 "spellcheck",
511 "src", 553 "src",
512 "srcdoc", 554 "srcdoc",
513 "srclang", 555 "srclang",
556 "srcset",
514 "start", 557 "start",
515 "step", 558 "step",
516 "style", 559 "style",
@@ -520,16 +563,22 @@ var attributes = []string{
520 "translate", 563 "translate",
521 "type", 564 "type",
522 "typemustmatch", 565 "typemustmatch",
566 "updateviacache",
523 "usemap", 567 "usemap",
524 "value", 568 "value",
525 "width", 569 "width",
570 "workertype",
526 "wrap", 571 "wrap",
527} 572}
528 573
574// "onautocomplete", "onautocompleteerror", "onmousewheel",
575// "onshow" and "onsort" have been removed from the spec,
576// but are kept here for backwards compatibility.
529var eventHandlers = []string{ 577var eventHandlers = []string{
530 "onabort", 578 "onabort",
531 "onautocomplete", 579 "onautocomplete",
532 "onautocompleteerror", 580 "onautocompleteerror",
581 "onauxclick",
533 "onafterprint", 582 "onafterprint",
534 "onbeforeprint", 583 "onbeforeprint",
535 "onbeforeunload", 584 "onbeforeunload",
@@ -541,11 +590,14 @@ var eventHandlers = []string{
541 "onclick", 590 "onclick",
542 "onclose", 591 "onclose",
543 "oncontextmenu", 592 "oncontextmenu",
593 "oncopy",
544 "oncuechange", 594 "oncuechange",
595 "oncut",
545 "ondblclick", 596 "ondblclick",
546 "ondrag", 597 "ondrag",
547 "ondragend", 598 "ondragend",
548 "ondragenter", 599 "ondragenter",
600 "ondragexit",
549 "ondragleave", 601 "ondragleave",
550 "ondragover", 602 "ondragover",
551 "ondragstart", 603 "ondragstart",
@@ -565,18 +617,24 @@ var eventHandlers = []string{
565 "onload", 617 "onload",
566 "onloadeddata", 618 "onloadeddata",
567 "onloadedmetadata", 619 "onloadedmetadata",
620 "onloadend",
568 "onloadstart", 621 "onloadstart",
569 "onmessage", 622 "onmessage",
623 "onmessageerror",
570 "onmousedown", 624 "onmousedown",
625 "onmouseenter",
626 "onmouseleave",
571 "onmousemove", 627 "onmousemove",
572 "onmouseout", 628 "onmouseout",
573 "onmouseover", 629 "onmouseover",
574 "onmouseup", 630 "onmouseup",
575 "onmousewheel", 631 "onmousewheel",
632 "onwheel",
576 "onoffline", 633 "onoffline",
577 "ononline", 634 "ononline",
578 "onpagehide", 635 "onpagehide",
579 "onpageshow", 636 "onpageshow",
637 "onpaste",
580 "onpause", 638 "onpause",
581 "onplay", 639 "onplay",
582 "onplaying", 640 "onplaying",
@@ -585,7 +643,9 @@ var eventHandlers = []string{
585 "onratechange", 643 "onratechange",
586 "onreset", 644 "onreset",
587 "onresize", 645 "onresize",
646 "onrejectionhandled",
588 "onscroll", 647 "onscroll",
648 "onsecuritypolicyviolation",
589 "onseeked", 649 "onseeked",
590 "onseeking", 650 "onseeking",
591 "onselect", 651 "onselect",
@@ -597,6 +657,7 @@ var eventHandlers = []string{
597 "onsuspend", 657 "onsuspend",
598 "ontimeupdate", 658 "ontimeupdate",
599 "ontoggle", 659 "ontoggle",
660 "onunhandledrejection",
600 "onunload", 661 "onunload",
601 "onvolumechange", 662 "onvolumechange",
602 "onwaiting", 663 "onwaiting",