Changed most instances of var to const in the Windows code. Only one left...
This commit is contained in:
parent
0d23bda925
commit
eb0188a099
|
@ -50,8 +50,8 @@ References:
|
|||
- http://support.microsoft.com/kb/830033
|
||||
*/
|
||||
func forceCommonControls6() (err error) {
|
||||
var (
|
||||
// from winbase.h; var because Go won't let me convert this constant
|
||||
const (
|
||||
// from winbase.h
|
||||
_INVALID_HANDLE_VALUE = -1
|
||||
)
|
||||
|
||||
|
@ -85,7 +85,7 @@ func forceCommonControls6() (err error) {
|
|||
actctx.lpSource = syscall.StringToUTF16Ptr(filename)
|
||||
|
||||
r1, _, err := _createActCtx.Call(uintptr(unsafe.Pointer(&actctx)))
|
||||
if r1 == uintptr(_INVALID_HANDLE_VALUE) { // failure
|
||||
if r1 == negConst(_INVALID_HANDLE_VALUE) { // failure
|
||||
return fmt.Errorf("error creating activation context for synthesized manifest file: %v", err)
|
||||
}
|
||||
r1, _, err = _activateActCtx.Call(
|
||||
|
|
|
@ -76,6 +76,12 @@ type _RECT struct {
|
|||
bottom int32
|
||||
}
|
||||
|
||||
// Go doesn't allow negative constants to be forced into unsigned types at compile-time; this will do it at runtime.
|
||||
// TODO make sure sign extension works fine here (check Go's rules and ABI sign extension rules)
|
||||
func negConst(c int) uintptr {
|
||||
return uintptr(c)
|
||||
}
|
||||
|
||||
// Predefined cursor resource IDs.
|
||||
const (
|
||||
_IDC_APPSTARTING = 32650
|
||||
|
|
|
@ -179,7 +179,7 @@ const (
|
|||
)
|
||||
|
||||
// Combobox errors.
|
||||
var ( // var so they can be cast to uintptr
|
||||
const (
|
||||
// from winuser.h
|
||||
_CB_ERR = (-1)
|
||||
_CB_ERRSPACE = (-2)
|
||||
|
@ -356,7 +356,7 @@ const (
|
|||
)
|
||||
|
||||
// Listbox errors.
|
||||
var ( // var so they can be cast to uintptr
|
||||
const (
|
||||
// from winuser.h
|
||||
_LB_OKAY = 0
|
||||
_LB_ERR = (-1)
|
||||
|
|
|
@ -35,8 +35,8 @@ type classData struct {
|
|||
insertBeforeMsg uintptr
|
||||
deleteMsg uintptr
|
||||
selectedIndexMsg uintptr
|
||||
selectedIndexErr int
|
||||
addSpaceErr int
|
||||
selectedIndexErr uintptr
|
||||
addSpaceErr uintptr
|
||||
lenMsg uintptr
|
||||
}
|
||||
|
||||
|
@ -69,8 +69,8 @@ var classTypes = [nctypes]*classData{
|
|||
insertBeforeMsg: _CB_INSERTSTRING,
|
||||
deleteMsg: _CB_DELETESTRING,
|
||||
selectedIndexMsg: _CB_GETCURSEL,
|
||||
selectedIndexErr: _CB_ERR,
|
||||
addSpaceErr: _CB_ERRSPACE,
|
||||
selectedIndexErr: negConst(_CB_ERR),
|
||||
addSpaceErr: negConst(_CB_ERRSPACE),
|
||||
lenMsg: _CB_GETCOUNT,
|
||||
},
|
||||
c_lineedit: &classData{
|
||||
|
@ -100,8 +100,8 @@ var classTypes = [nctypes]*classData{
|
|||
insertBeforeMsg: _LB_INSERTSTRING,
|
||||
deleteMsg: _LB_DELETESTRING,
|
||||
selectedIndexMsg: _LB_GETCURSEL,
|
||||
selectedIndexErr: _LB_ERR,
|
||||
addSpaceErr: _LB_ERRSPACE,
|
||||
selectedIndexErr: negConst(_LB_ERR),
|
||||
addSpaceErr: negConst(_LB_ERRSPACE),
|
||||
lenMsg: _LB_GETCOUNT,
|
||||
},
|
||||
c_progressbar: &classData{
|
||||
|
@ -422,7 +422,7 @@ func (s *sysData) selectedIndices() []int {
|
|||
ret: ret,
|
||||
}
|
||||
r := <-ret
|
||||
if r.ret == uintptr(_LB_ERR) {
|
||||
if r.ret == negConst(_LB_ERR) {
|
||||
panic("UI library internal error: LB_ERR from LB_GETSELCOUNT in what we know is a multi-selection listbox")
|
||||
}
|
||||
if r.ret == 0 { // nothing selected
|
||||
|
@ -440,7 +440,7 @@ func (s *sysData) selectedIndices() []int {
|
|||
ret: ret,
|
||||
}
|
||||
r = <-ret
|
||||
if r.ret == uintptr(_LB_ERR) {
|
||||
if r.ret == negConst(_LB_ERR) {
|
||||
panic("UI library internal error: LB_ERR from LB_GETSELITEMS in what we know is a multi-selection listbox")
|
||||
}
|
||||
return indices
|
||||
|
@ -463,7 +463,7 @@ func (s *sysData) selectedTexts() []string {
|
|||
ret: ret,
|
||||
}
|
||||
r := <-ret
|
||||
if r.ret == uintptr(_LB_ERR) {
|
||||
if r.ret == negConst(_LB_ERR) {
|
||||
panic("UI library internal error: LB_ERR from LB_GETTEXTLEN in what we know is a valid listbox index (came from LB_GETSELITEMS)")
|
||||
}
|
||||
str := make([]uint16, r.ret)
|
||||
|
@ -478,7 +478,7 @@ func (s *sysData) selectedTexts() []string {
|
|||
ret: ret,
|
||||
}
|
||||
r = <-ret
|
||||
if r.ret == uintptr(_LB_ERR) {
|
||||
if r.ret == negConst(_LB_ERR) {
|
||||
panic("UI library internal error: LB_ERR from LB_GETTEXT in what we know is a valid listbox index (came from LB_GETSELITEMS)")
|
||||
}
|
||||
strings[i] = syscall.UTF16ToString(str)
|
||||
|
@ -537,7 +537,7 @@ func (s *sysData) setIndeterminate() {
|
|||
call: _setWindowLong,
|
||||
p: []uintptr{
|
||||
uintptr(s.hwnd),
|
||||
uintptr(_GWL_STYLE),
|
||||
negConst(_GWL_STYLE),
|
||||
uintptr(classTypes[s.ctype].style | _PBS_MARQUEE),
|
||||
},
|
||||
ret: ret,
|
||||
|
@ -584,7 +584,7 @@ func (s *sysData) setProgress(percent int) {
|
|||
call: _setWindowLong,
|
||||
p: []uintptr{
|
||||
uintptr(s.hwnd),
|
||||
uintptr(_GWL_STYLE),
|
||||
negConst(_GWL_STYLE),
|
||||
uintptr(classTypes[s.ctype].style),
|
||||
},
|
||||
ret: ret,
|
||||
|
|
|
@ -133,8 +133,8 @@ const (
|
|||
msghandlerclass = "gomsghandler"
|
||||
)
|
||||
|
||||
var (
|
||||
// fron winuser.h; var because Go won't let me
|
||||
const (
|
||||
// fron winuser.h
|
||||
_HWND_MESSAGE = -3
|
||||
)
|
||||
|
||||
|
@ -162,7 +162,7 @@ func makeMessageHandler() (hwnd _HWND, err error) {
|
|||
uintptr(_CW_USEDEFAULT),
|
||||
uintptr(_CW_USEDEFAULT),
|
||||
uintptr(_CW_USEDEFAULT),
|
||||
uintptr(_HWND_MESSAGE),
|
||||
negConst(_HWND_MESSAGE),
|
||||
uintptr(_NULL),
|
||||
uintptr(hInstance),
|
||||
uintptr(_NULL))
|
||||
|
|
|
@ -121,14 +121,6 @@ const (
|
|||
_HWND_TOP = _HWND(0)
|
||||
)
|
||||
|
||||
// SetWindowPos hWndInsertAfter values that Go won't allow as constants.
|
||||
var (
|
||||
__HWND_NOTOPMOST = -2
|
||||
_HWND_NOTOPMOST = _HWND(__HWND_NOTOPMOST)
|
||||
__HWND_TOPMOST = -1
|
||||
_HWND_TOPMOST = _HWND(__HWND_TOPMOST)
|
||||
)
|
||||
|
||||
// SetWindowPos uFlags values.
|
||||
const (
|
||||
_SWP_DRAWFRAME = 0x0020
|
||||
|
@ -244,7 +236,7 @@ const (
|
|||
)
|
||||
|
||||
// WM_STYLECHANGED and WM_STYLECHANGING values (wParam).
|
||||
var ( // var because Go won't let me cast a negative const to a uintptr
|
||||
const (
|
||||
_GWL_EXSTYLE = -20
|
||||
_GWL_STYLE = -16
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue