mirror of
https://github.com/golang/sys.git
synced 2026-02-09 04:06:04 +03:00
windows/mkwinsyscall: simplify generated code for booleans
Change-Id: I31ca4f93924a593e7952c483084616141998a03c
GitHub-Last-Rev: d4fd0c7eca
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.
|
||||
|
||||
@@ -763,8 +763,6 @@ func IsWow64Process(handle Handle, isWow64 *bool) (err error) {
|
||||
var _p0 uint32
|
||||
if *isWow64 {
|
||||
_p0 = 1
|
||||
} else {
|
||||
_p0 = 0
|
||||
}
|
||||
r1, _, e1 := syscall.Syscall(procIsWow64Process.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(&_p0)), 0)
|
||||
*isWow64 = _p0 != 0
|
||||
@@ -827,8 +825,6 @@ func GetOverlappedResult(handle Handle, overlapped *Overlapped, done *uint32, wa
|
||||
var _p0 uint32
|
||||
if wait {
|
||||
_p0 = 1
|
||||
} else {
|
||||
_p0 = 0
|
||||
}
|
||||
r1, _, e1 := syscall.Syscall6(procGetOverlappedResult.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(done)), uintptr(_p0), 0, 0)
|
||||
if r1 == 0 {
|
||||
@@ -1185,8 +1181,6 @@ func CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityA
|
||||
var _p0 uint32
|
||||
if inheritHandles {
|
||||
_p0 = 1
|
||||
} else {
|
||||
_p0 = 0
|
||||
}
|
||||
r1, _, e1 := syscall.Syscall12(procCreateProcessW.Addr(), 10, uintptr(unsafe.Pointer(appName)), uintptr(unsafe.Pointer(commandLine)), uintptr(unsafe.Pointer(procSecurity)), uintptr(unsafe.Pointer(threadSecurity)), uintptr(_p0), uintptr(creationFlags), uintptr(unsafe.Pointer(env)), uintptr(unsafe.Pointer(currentDir)), uintptr(unsafe.Pointer(startupInfo)), uintptr(unsafe.Pointer(outProcInfo)), 0, 0)
|
||||
if r1 == 0 {
|
||||
@@ -1203,8 +1197,6 @@ func OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) (ha
|
||||
var _p0 uint32
|
||||
if inheritHandle {
|
||||
_p0 = 1
|
||||
} else {
|
||||
_p0 = 0
|
||||
}
|
||||
r0, _, e1 := syscall.Syscall(procOpenProcess.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(processId))
|
||||
handle = Handle(r0)
|
||||
@@ -1290,8 +1282,6 @@ func DuplicateHandle(hSourceProcessHandle Handle, hSourceHandle Handle, hTargetP
|
||||
var _p0 uint32
|
||||
if bInheritHandle {
|
||||
_p0 = 1
|
||||
} else {
|
||||
_p0 = 0
|
||||
}
|
||||
r1, _, e1 := syscall.Syscall9(procDuplicateHandle.Addr(), 7, uintptr(hSourceProcessHandle), uintptr(hSourceHandle), uintptr(hTargetProcessHandle), uintptr(unsafe.Pointer(lpTargetHandle)), uintptr(dwDesiredAccess), uintptr(_p0), uintptr(dwOptions), 0, 0)
|
||||
if r1 == 0 {
|
||||
@@ -1321,8 +1311,6 @@ func waitForMultipleObjects(count uint32, handles uintptr, waitAll bool, waitMil
|
||||
var _p0 uint32
|
||||
if waitAll {
|
||||
_p0 = 1
|
||||
} else {
|
||||
_p0 = 0
|
||||
}
|
||||
r0, _, e1 := syscall.Syscall6(procWaitForMultipleObjects.Addr(), 4, uintptr(count), uintptr(handles), uintptr(_p0), uintptr(waitMilliseconds), 0, 0)
|
||||
event = uint32(r0)
|
||||
@@ -1464,8 +1452,6 @@ func CreateEnvironmentBlock(block **uint16, token Token, inheritExisting bool) (
|
||||
var _p0 uint32
|
||||
if inheritExisting {
|
||||
_p0 = 1
|
||||
} else {
|
||||
_p0 = 0
|
||||
}
|
||||
r1, _, e1 := syscall.Syscall(procCreateEnvironmentBlock.Addr(), 3, uintptr(unsafe.Pointer(block)), uintptr(token), uintptr(_p0))
|
||||
if r1 == 0 {
|
||||
@@ -1767,8 +1753,6 @@ func ReadDirectoryChanges(handle Handle, buf *byte, buflen uint32, watchSubTree
|
||||
var _p0 uint32
|
||||
if watchSubTree {
|
||||
_p0 = 1
|
||||
} else {
|
||||
_p0 = 0
|
||||
}
|
||||
r1, _, e1 := syscall.Syscall9(procReadDirectoryChangesW.Addr(), 8, uintptr(handle), uintptr(unsafe.Pointer(buf)), uintptr(buflen), uintptr(_p0), uintptr(mask), uintptr(unsafe.Pointer(retlen)), uintptr(unsafe.Pointer(overlapped)), uintptr(completionRoutine), 0)
|
||||
if r1 == 0 {
|
||||
@@ -2161,8 +2145,6 @@ func OpenEvent(desiredAccess uint32, inheritHandle bool, name *uint16) (handle H
|
||||
var _p0 uint32
|
||||
if inheritHandle {
|
||||
_p0 = 1
|
||||
} else {
|
||||
_p0 = 0
|
||||
}
|
||||
r0, _, e1 := syscall.Syscall(procOpenEventW.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(unsafe.Pointer(name)))
|
||||
handle = Handle(r0)
|
||||
@@ -2216,8 +2198,6 @@ func CreateMutex(mutexAttrs *SecurityAttributes, initialOwner bool, name *uint16
|
||||
var _p0 uint32
|
||||
if initialOwner {
|
||||
_p0 = 1
|
||||
} else {
|
||||
_p0 = 0
|
||||
}
|
||||
r0, _, e1 := syscall.Syscall(procCreateMutexW.Addr(), 3, uintptr(unsafe.Pointer(mutexAttrs)), uintptr(_p0), uintptr(unsafe.Pointer(name)))
|
||||
handle = Handle(r0)
|
||||
@@ -2248,8 +2228,6 @@ func OpenMutex(desiredAccess uint32, inheritHandle bool, name *uint16) (handle H
|
||||
var _p0 uint32
|
||||
if inheritHandle {
|
||||
_p0 = 1
|
||||
} else {
|
||||
_p0 = 0
|
||||
}
|
||||
r0, _, e1 := syscall.Syscall(procOpenMutexW.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(unsafe.Pointer(name)))
|
||||
handle = Handle(r0)
|
||||
@@ -2279,8 +2257,6 @@ func SleepEx(milliseconds uint32, alertable bool) (ret uint32) {
|
||||
var _p0 uint32
|
||||
if alertable {
|
||||
_p0 = 1
|
||||
} else {
|
||||
_p0 = 0
|
||||
}
|
||||
r0, _, _ := syscall.Syscall(procSleepEx.Addr(), 2, uintptr(milliseconds), uintptr(_p0), 0)
|
||||
ret = uint32(r0)
|
||||
@@ -2422,8 +2398,6 @@ func OpenThread(desiredAccess uint32, inheritHandle bool, threadId uint32) (hand
|
||||
var _p0 uint32
|
||||
if inheritHandle {
|
||||
_p0 = 1
|
||||
} else {
|
||||
_p0 = 0
|
||||
}
|
||||
r0, _, e1 := syscall.Syscall(procOpenThread.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(threadId))
|
||||
handle = Handle(r0)
|
||||
@@ -2441,8 +2415,6 @@ func SetProcessPriorityBoost(process Handle, disable bool) (err error) {
|
||||
var _p0 uint32
|
||||
if disable {
|
||||
_p0 = 1
|
||||
} else {
|
||||
_p0 = 0
|
||||
}
|
||||
r1, _, e1 := syscall.Syscall(procSetProcessPriorityBoost.Addr(), 2, uintptr(process), uintptr(_p0), 0)
|
||||
if r1 == 0 {
|
||||
@@ -2740,14 +2712,10 @@ func InitiateSystemShutdownEx(machineName *uint16, message *uint16, timeout uint
|
||||
var _p0 uint32
|
||||
if forceAppsClosed {
|
||||
_p0 = 1
|
||||
} else {
|
||||
_p0 = 0
|
||||
}
|
||||
var _p1 uint32
|
||||
if rebootAfterShutdown {
|
||||
_p1 = 1
|
||||
} else {
|
||||
_p1 = 0
|
||||
}
|
||||
r1, _, e1 := syscall.Syscall6(procInitiateSystemShutdownExW.Addr(), 6, uintptr(unsafe.Pointer(machineName)), uintptr(unsafe.Pointer(message)), uintptr(timeout), uintptr(_p0), uintptr(_p1), uintptr(reason))
|
||||
if r1 == 0 {
|
||||
@@ -3539,8 +3507,6 @@ func OpenThreadToken(thread Handle, access uint32, openAsSelf bool, token *Token
|
||||
var _p0 uint32
|
||||
if openAsSelf {
|
||||
_p0 = 1
|
||||
} else {
|
||||
_p0 = 0
|
||||
}
|
||||
r1, _, e1 := syscall.Syscall6(procOpenThreadToken.Addr(), 4, uintptr(thread), uintptr(access), uintptr(_p0), uintptr(unsafe.Pointer(token)), 0, 0)
|
||||
if r1 == 0 {
|
||||
@@ -3605,8 +3571,6 @@ func AdjustTokenPrivileges(token Token, disableAllPrivileges bool, newstate *Tok
|
||||
var _p0 uint32
|
||||
if disableAllPrivileges {
|
||||
_p0 = 1
|
||||
} else {
|
||||
_p0 = 0
|
||||
}
|
||||
r1, _, e1 := syscall.Syscall6(procAdjustTokenPrivileges.Addr(), 6, uintptr(token), uintptr(_p0), uintptr(unsafe.Pointer(newstate)), uintptr(buflen), uintptr(unsafe.Pointer(prevstate)), uintptr(unsafe.Pointer(returnlen)))
|
||||
if r1 == 0 {
|
||||
@@ -3623,8 +3587,6 @@ func AdjustTokenGroups(token Token, resetToDefault bool, newstate *Tokengroups,
|
||||
var _p0 uint32
|
||||
if resetToDefault {
|
||||
_p0 = 1
|
||||
} else {
|
||||
_p0 = 0
|
||||
}
|
||||
r1, _, e1 := syscall.Syscall6(procAdjustTokenGroups.Addr(), 6, uintptr(token), uintptr(_p0), uintptr(unsafe.Pointer(newstate)), uintptr(buflen), uintptr(unsafe.Pointer(prevstate)), uintptr(unsafe.Pointer(returnlen)))
|
||||
if r1 == 0 {
|
||||
@@ -3836,14 +3798,10 @@ func getSecurityDescriptorDacl(sd *SECURITY_DESCRIPTOR, daclPresent *bool, dacl
|
||||
var _p0 uint32
|
||||
if *daclPresent {
|
||||
_p0 = 1
|
||||
} else {
|
||||
_p0 = 0
|
||||
}
|
||||
var _p1 uint32
|
||||
if *daclDefaulted {
|
||||
_p1 = 1
|
||||
} else {
|
||||
_p1 = 0
|
||||
}
|
||||
r1, _, e1 := syscall.Syscall6(procGetSecurityDescriptorDacl.Addr(), 4, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(&_p0)), uintptr(unsafe.Pointer(dacl)), uintptr(unsafe.Pointer(&_p1)), 0, 0)
|
||||
*daclPresent = _p0 != 0
|
||||
@@ -3862,14 +3820,10 @@ func getSecurityDescriptorSacl(sd *SECURITY_DESCRIPTOR, saclPresent *bool, sacl
|
||||
var _p0 uint32
|
||||
if *saclPresent {
|
||||
_p0 = 1
|
||||
} else {
|
||||
_p0 = 0
|
||||
}
|
||||
var _p1 uint32
|
||||
if *saclDefaulted {
|
||||
_p1 = 1
|
||||
} else {
|
||||
_p1 = 0
|
||||
}
|
||||
r1, _, e1 := syscall.Syscall6(procGetSecurityDescriptorSacl.Addr(), 4, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(&_p0)), uintptr(unsafe.Pointer(sacl)), uintptr(unsafe.Pointer(&_p1)), 0, 0)
|
||||
*saclPresent = _p0 != 0
|
||||
@@ -3888,8 +3842,6 @@ func getSecurityDescriptorOwner(sd *SECURITY_DESCRIPTOR, owner **SID, ownerDefau
|
||||
var _p0 uint32
|
||||
if *ownerDefaulted {
|
||||
_p0 = 1
|
||||
} else {
|
||||
_p0 = 0
|
||||
}
|
||||
r1, _, e1 := syscall.Syscall(procGetSecurityDescriptorOwner.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(&_p0)))
|
||||
*ownerDefaulted = _p0 != 0
|
||||
@@ -3907,8 +3859,6 @@ func getSecurityDescriptorGroup(sd *SECURITY_DESCRIPTOR, group **SID, groupDefau
|
||||
var _p0 uint32
|
||||
if *groupDefaulted {
|
||||
_p0 = 1
|
||||
} else {
|
||||
_p0 = 0
|
||||
}
|
||||
r1, _, e1 := syscall.Syscall(procGetSecurityDescriptorGroup.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(&_p0)))
|
||||
*groupDefaulted = _p0 != 0
|
||||
@@ -3958,14 +3908,10 @@ func setSecurityDescriptorDacl(sd *SECURITY_DESCRIPTOR, daclPresent bool, dacl *
|
||||
var _p0 uint32
|
||||
if daclPresent {
|
||||
_p0 = 1
|
||||
} else {
|
||||
_p0 = 0
|
||||
}
|
||||
var _p1 uint32
|
||||
if daclDefaulted {
|
||||
_p1 = 1
|
||||
} else {
|
||||
_p1 = 0
|
||||
}
|
||||
r1, _, e1 := syscall.Syscall6(procSetSecurityDescriptorDacl.Addr(), 4, uintptr(unsafe.Pointer(sd)), uintptr(_p0), uintptr(unsafe.Pointer(dacl)), uintptr(_p1), 0, 0)
|
||||
if r1 == 0 {
|
||||
@@ -3982,14 +3928,10 @@ func setSecurityDescriptorSacl(sd *SECURITY_DESCRIPTOR, saclPresent bool, sacl *
|
||||
var _p0 uint32
|
||||
if saclPresent {
|
||||
_p0 = 1
|
||||
} else {
|
||||
_p0 = 0
|
||||
}
|
||||
var _p1 uint32
|
||||
if saclDefaulted {
|
||||
_p1 = 1
|
||||
} else {
|
||||
_p1 = 0
|
||||
}
|
||||
r1, _, e1 := syscall.Syscall6(procSetSecurityDescriptorSacl.Addr(), 4, uintptr(unsafe.Pointer(sd)), uintptr(_p0), uintptr(unsafe.Pointer(sacl)), uintptr(_p1), 0, 0)
|
||||
if r1 == 0 {
|
||||
@@ -4006,8 +3948,6 @@ func setSecurityDescriptorOwner(sd *SECURITY_DESCRIPTOR, owner *SID, ownerDefaul
|
||||
var _p0 uint32
|
||||
if ownerDefaulted {
|
||||
_p0 = 1
|
||||
} else {
|
||||
_p0 = 0
|
||||
}
|
||||
r1, _, e1 := syscall.Syscall(procSetSecurityDescriptorOwner.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(owner)), uintptr(_p0))
|
||||
if r1 == 0 {
|
||||
@@ -4024,8 +3964,6 @@ func setSecurityDescriptorGroup(sd *SECURITY_DESCRIPTOR, group *SID, groupDefaul
|
||||
var _p0 uint32
|
||||
if groupDefaulted {
|
||||
_p0 = 1
|
||||
} else {
|
||||
_p0 = 0
|
||||
}
|
||||
r1, _, e1 := syscall.Syscall(procSetSecurityDescriptorGroup.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(group)), uintptr(_p0))
|
||||
if r1 == 0 {
|
||||
|
||||
Reference in New Issue
Block a user