diff options
author | Dmitri Shuralyov <dmitshur@golang.org> | 2019-03-30 03:23:49 -0400 |
---|---|---|
committer | Dmitri Shuralyov <dmitshur@golang.org> | 2019-03-30 15:02:33 +0000 |
commit | 1cd2f21070ecb547260f77e509ce60906a51b4ca (patch) | |
tree | e98c0a176ff13de9abf1ddbcd174547e38ce2733 /imports | |
parent | a96101f168f4ff1e2cd559ba4f61dbd091684e41 (diff) | |
download | golang-x-tools-1cd2f21070ecb547260f77e509ce60906a51b4ca.tar.gz |
imports: add syscall/js API to zstdlib.go
The syscall/js API is not included in the GOROOT/api/go1.*.txt files
at this time, and so it needs to be added to mkstdlib.go explicitly.
Run the cmd/api command directly in the generator to determine the
syscall/js API.
Regenerate zstdlib.go with the updated generator, using Go 1.12.1.
Fixes golang/go#27590
Change-Id: I541588986d70f67f4917d9b34bdd57ca44f538f7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/170014
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'imports')
-rw-r--r-- | imports/mkstdlib.go | 20 | ||||
-rw-r--r-- | imports/zstdlib.go | 23 |
2 files changed, 43 insertions, 0 deletions
diff --git a/imports/mkstdlib.go b/imports/mkstdlib.go index 5059ad4d7..c8865e555 100644 --- a/imports/mkstdlib.go +++ b/imports/mkstdlib.go @@ -14,6 +14,7 @@ import ( "io/ioutil" "log" "os" + "os/exec" "path/filepath" "regexp" "runtime" @@ -59,6 +60,10 @@ func main() { mustOpen(api("go1.10.txt")), mustOpen(api("go1.11.txt")), mustOpen(api("go1.12.txt")), + + // The API of the syscall/js package needs to be computed explicitly, + // because it's not included in the GOROOT/api/go1.*.txt files at this time. + syscallJSAPI(), ) sc := bufio.NewScanner(f) @@ -110,3 +115,18 @@ func main() { log.Fatal(err) } } + +// syscallJSAPI returns the API of the syscall/js package. +// It's computed from the contents of $(go env GOROOT)/src/syscall/js. +func syscallJSAPI() io.Reader { + var exeSuffix string + if runtime.GOOS == "windows" { + exeSuffix = ".exe" + } + cmd := exec.Command("go"+exeSuffix, "run", "cmd/api", "-contexts", "js-wasm", "syscall/js") + out, err := cmd.Output() + if err != nil { + log.Fatalln(err) + } + return bytes.NewReader(out) +} diff --git a/imports/zstdlib.go b/imports/zstdlib.go index c18a0095b..d81b8c530 100644 --- a/imports/zstdlib.go +++ b/imports/zstdlib.go @@ -9783,6 +9783,29 @@ var stdlib = map[string]map[string]bool{ "XP1_UNI_RECV": true, "XP1_UNI_SEND": true, }, + "syscall/js": map[string]bool{ + "Error": true, + "Func": true, + "FuncOf": true, + "Global": true, + "Null": true, + "Type": true, + "TypeBoolean": true, + "TypeFunction": true, + "TypeNull": true, + "TypeNumber": true, + "TypeObject": true, + "TypeString": true, + "TypeSymbol": true, + "TypeUndefined": true, + "TypedArray": true, + "TypedArrayOf": true, + "Undefined": true, + "Value": true, + "ValueError": true, + "ValueOf": true, + "Wrapper": true, + }, "testing": map[string]bool{ "AllocsPerRun": true, "B": true, |