windows/mkwinsyscall: simplify generated code for booleans

Change-Id: I31ca4f93924a593e7952c483084616141998a03c
GitHub-Last-Rev: d4fd0c7eca99ed2c22400d819388168e830ce529
GitHub-Pull-Request: golang/sys#88
Reviewed-on: https://go-review.googlesource.com/c/sys/+/259302
Trust: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
This commit is contained in:
Sebastiaan van Stijn
2020-10-08 06:45:18 +00:00
committed by Alex Brainman
parent 280f808b4a
commit c1f3e3309c
2 changed files with 8 additions and 76 deletions
+8 -14
View File
@@ -105,26 +105,20 @@ func (p *Param) tmpVar() string {
// BoolTmpVarCode returns source code for bool temp variable.
func (p *Param) BoolTmpVarCode() string {
const code = `var %s uint32
if %s {
%s = 1
} else {
%s = 0
const code = `var %[1]s uint32
if %[2]s {
%[1]s = 1
}`
tmp := p.tmpVar()
return fmt.Sprintf(code, tmp, p.Name, tmp, tmp)
return fmt.Sprintf(code, p.tmpVar(), p.Name)
}
// BoolPointerTmpVarCode returns source code for bool temp variable.
func (p *Param) BoolPointerTmpVarCode() string {
const code = `var %s uint32
if *%s {
%s = 1
} else {
%s = 0
const code = `var %[1]s uint32
if *%[2]s {
%[1]s = 1
}`
tmp := p.tmpVar()
return fmt.Sprintf(code, tmp, p.Name, tmp, tmp)
return fmt.Sprintf(code, p.tmpVar(), p.Name)
}
// SliceTmpVarCode returns source code for slice temp variable.