mirror of
https://github.com/rwinkhart/sys.git
synced 2026-09-06 09:07:16 -04:00
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:
committed by
Alex Brainman
parent
280f808b4a
commit
c1f3e3309c
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user