mirror of
https://github.com/golang/sys.git
synced 2026-02-08 11:46:04 +03:00
windows/mkwinsyscall: deduplicate functions before printing variables
The same symbol name might be defined multiple times with different function names or signatures. In that case, it's an error to redefine the proc variable. So deduplicate these before printing. Change-Id: I7a636cd44fb1ea6f51840ef3924d6316e266faa0 Reviewed-on: https://go-review.googlesource.com/c/sys/+/288332 Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Jason A. Donenfeld <Jason@zx2c4.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
@@ -644,6 +644,7 @@ func (f *Fn) HelperName() string {
|
||||
// Source files and functions.
|
||||
type Source struct {
|
||||
Funcs []*Fn
|
||||
DLLFuncNames []*Fn
|
||||
Files []string
|
||||
StdLibImports []string
|
||||
ExternalImports []string
|
||||
@@ -676,6 +677,15 @@ func ParseFiles(fs []string) (*Source, error) {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
src.DLLFuncNames = make([]*Fn, 0, len(src.Funcs))
|
||||
uniq := make(map[string]bool, len(src.Funcs))
|
||||
for _, fn := range src.Funcs {
|
||||
name := fn.DLLFuncName()
|
||||
if !uniq[name] {
|
||||
src.DLLFuncNames = append(src.DLLFuncNames, fn)
|
||||
uniq[name] = true
|
||||
}
|
||||
}
|
||||
return src, nil
|
||||
}
|
||||
|
||||
@@ -920,7 +930,7 @@ var (
|
||||
{{define "dlls"}}{{range .DLLs}} mod{{.}} = {{newlazydll .}}
|
||||
{{end}}{{end}}
|
||||
|
||||
{{define "funcnames"}}{{range .Funcs}} proc{{.DLLFuncName}} = mod{{.DLLName}}.NewProc("{{.DLLFuncName}}")
|
||||
{{define "funcnames"}}{{range .DLLFuncNames}} proc{{.DLLFuncName}} = mod{{.DLLName}}.NewProc("{{.DLLFuncName}}")
|
||||
{{end}}{{end}}
|
||||
|
||||
{{define "helperbody"}}
|
||||
|
||||
Reference in New Issue
Block a user