From 80828b8a7d2273d5f35b7114c8dfc10605fc5df8 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Fri, 1 Aug 2014 18:25:59 -0400 Subject: [PATCH] Changed LPCWSTR to LPWSTR in the Windows code as the C means const and there are a few cases of const->non-const conversions as a result. --- redo/basicctrls_windows.c | 2 +- redo/comctl32_windows.c | 2 +- redo/comctl32_windows.go | 2 +- redo/common_windows.c | 4 ++-- redo/common_windows.go | 6 +++--- redo/containerctrls_windows.c | 5 ++--- redo/control_windows.go | 2 +- redo/table_windows.c | 4 ++-- redo/winapi_windows.h | 18 +++++++++--------- redo/window_windows.c | 2 +- 10 files changed, 23 insertions(+), 24 deletions(-) diff --git a/redo/basicctrls_windows.c b/redo/basicctrls_windows.c index 8974bdb..58474c1 100644 --- a/redo/basicctrls_windows.c +++ b/redo/basicctrls_windows.c @@ -3,7 +3,7 @@ #include "winapi_windows.h" #include "_cgo_export.h" -HWND newWidget(LPCWSTR class, DWORD style, DWORD extstyle) +HWND newWidget(LPWSTR class, DWORD style, DWORD extstyle) { HWND hwnd; diff --git a/redo/comctl32_windows.c b/redo/comctl32_windows.c index e3e02cf..09b9605 100644 --- a/redo/comctl32_windows.c +++ b/redo/comctl32_windows.c @@ -16,7 +16,7 @@ LRESULT (*WINAPI fv_DefSubclassProc)(HWND, UINT, WPARAM, LPARAM); ICC_LISTVIEW_CLASSES | /* list views */ \ 0) -DWORD initCommonControls(LPCWSTR manifest, char **errmsg) +DWORD initCommonControls(LPWSTR manifest, char **errmsg) { ACTCTX actctx; HANDLE ac; diff --git a/redo/comctl32_windows.go b/redo/comctl32_windows.go index 55ba49f..8d5e62e 100644 --- a/redo/comctl32_windows.go +++ b/redo/comctl32_windows.go @@ -39,7 +39,7 @@ func initCommonControls() (err error) { var errmsg *C.char - errcode := C.initCommonControls(C.LPCWSTR(unsafe.Pointer(syscall.StringToUTF16Ptr(filename))), &errmsg) + errcode := C.initCommonControls(C.LPWSTR(unsafe.Pointer(syscall.StringToUTF16Ptr(filename))), &errmsg) if errcode != 0 || errmsg != nil { return fmt.Errorf("error actually initializing comctl32.dll: %s: %v", C.GoString(errmsg), syscall.Errno(errcode)) } diff --git a/redo/common_windows.c b/redo/common_windows.c index e317595..3999953 100644 --- a/redo/common_windows.c +++ b/redo/common_windows.c @@ -8,14 +8,14 @@ LRESULT getWindowTextLen(HWND hwnd) return SendMessageW(hwnd, WM_GETTEXTLENGTH, 0, 0); } -void getWindowText(HWND hwnd, WPARAM n, LPCWSTR buf) +void getWindowText(HWND hwnd, WPARAM n, LPWSTR buf) { SetLastError(0); if (SendMessageW(hwnd, WM_GETTEXT, n + 1, (LPARAM) buf) != n) xpanic("WM_GETTEXT did not copy the correct number of characters out", GetLastError()); } -void setWindowText(HWND hwnd, LPCWSTR text) +void setWindowText(HWND hwnd, LPWSTR text) { switch (SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM) text)) { case FALSE: diff --git a/redo/common_windows.go b/redo/common_windows.go index a80ee2e..37d0206 100644 --- a/redo/common_windows.go +++ b/redo/common_windows.go @@ -21,8 +21,8 @@ func xmissedmsg(purpose *C.char, f *C.char, uMsg C.UINT) { panic(fmt.Errorf("%s window procedure message %d does not return a value (bug in %s)", C.GoString(purpose), uMsg, C.GoString(f))) } -func toUTF16(s string) C.LPCWSTR { - return C.LPCWSTR(unsafe.Pointer(syscall.StringToUTF16Ptr(s))) +func toUTF16(s string) C.LPWSTR { + return C.LPWSTR(unsafe.Pointer(syscall.StringToUTF16Ptr(s))) } func getWindowText(hwnd C.HWND) string { @@ -31,6 +31,6 @@ func getWindowText(hwnd C.HWND) string { n := C.getWindowTextLen(hwnd) buf := make([]uint16, int(n + 1)) C.getWindowText(hwnd, C.WPARAM(n), - C.LPCWSTR(unsafe.Pointer(&buf[0]))) + C.LPWSTR(unsafe.Pointer(&buf[0]))) return syscall.UTF16ToString(buf) } diff --git a/redo/containerctrls_windows.c b/redo/containerctrls_windows.c index b5f3a97..6895ec4 100644 --- a/redo/containerctrls_windows.c +++ b/redo/containerctrls_windows.c @@ -4,7 +4,7 @@ #include "_cgo_export.h" /* provided for cgo's benefit */ -LPCWSTR xWC_TABCONTROL = WC_TABCONTROL; +LPWSTR xWC_TABCONTROL = WC_TABCONTROL; static LRESULT CALLBACK tabSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR id, DWORD_PTR data) { @@ -42,14 +42,13 @@ void setTabSubclass(HWND hwnd, void *data) xpanic("error subclassing Tab to give it its own event handler", GetLastError()); } -void tabAppend(HWND hwnd, LPCWSTR name) +void tabAppend(HWND hwnd, LPWSTR name) { TCITEM item; LRESULT n; ZeroMemory(&item, sizeof (TCITEM)); item.mask = TCIF_TEXT; - /* TODO the C means const; change everything to use LPWSTR instead */ item.pszText = name; /* MSDN's example code uses the first invalid index directly for this */ n = SendMessageW(hwnd, TCM_GETITEMCOUNT, 0, 0); diff --git a/redo/control_windows.go b/redo/control_windows.go index f75c765..a2c55e2 100644 --- a/redo/control_windows.go +++ b/redo/control_windows.go @@ -15,7 +15,7 @@ type controlParent struct { hwnd C.HWND } -func newControl(class C.LPCWSTR, style C.DWORD, extstyle C.DWORD) *controlbase { +func newControl(class C.LPWSTR, style C.DWORD, extstyle C.DWORD) *controlbase { c := new(controlbase) c.hwnd = C.newWidget(class, style, extstyle) c.controldefs = new(controldefs) diff --git a/redo/table_windows.c b/redo/table_windows.c index b6cf32a..56a3b02 100644 --- a/redo/table_windows.c +++ b/redo/table_windows.c @@ -4,7 +4,7 @@ #include "_cgo_export.h" /* provided for cgo's benefit */ -LPCWSTR xWC_LISTVIEW = WC_LISTVIEW; +LPWSTR xWC_LISTVIEW = WC_LISTVIEW; static LRESULT CALLBACK tableSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR id, DWORD_PTR data) { @@ -37,7 +37,7 @@ void setTableSubclass(HWND hwnd, void *data) xpanic("error subclassing Table to give it its own event handler", GetLastError()); } -void tableAppendColumn(HWND hwnd, int index, LPCWSTR name) +void tableAppendColumn(HWND hwnd, int index, LPWSTR name) { LVCOLUMNW col; diff --git a/redo/winapi_windows.h b/redo/winapi_windows.h index 51bbe0e..4bd035c 100644 --- a/redo/winapi_windows.h +++ b/redo/winapi_windows.h @@ -33,14 +33,14 @@ extern HWND msgwin; extern DWORD makemsgwin(char **); /* comctl32_windows.c */ -extern DWORD initCommonControls(LPCWSTR, char **); +extern DWORD initCommonControls(LPWSTR, char **); /* these are listed as WINAPI in both Microsoft's and MinGW's headers, but not on MSDN for some reason */ extern BOOL (*WINAPI fv_SetWindowSubclass)(HWND, SUBCLASSPROC, UINT_PTR, DWORD_PTR); extern BOOL (*WINAPI fv_RemoveWindowSubclass)(HWND, SUBCLASSPROC, UINT_PTR); extern LRESULT (*WINAPI fv_DefSubclassProc)(HWND, UINT, WPARAM, LPARAM); /* controls_windows.c */ -extern HWND newWidget(LPCWSTR, DWORD, DWORD); +extern HWND newWidget(LPWSTR, DWORD, DWORD); extern void controlSetParent(HWND, HWND); extern void controlSetControlFont(HWND); extern LRESULT forwardCommand(HWND, UINT, WPARAM, LPARAM); @@ -71,26 +71,26 @@ extern void moveWindow(HWND, int, int, int, int); /* window_windows.c */ extern DWORD makeWindowWindowClass(char **); -extern HWND newWindow(LPCWSTR, int, int, void *); +extern HWND newWindow(LPWSTR, int, int, void *); extern void windowClose(HWND); /* common_windows.c */ extern LRESULT getWindowTextLen(HWND); -extern void getWindowText(HWND, WPARAM, LPCWSTR); -extern void setWindowText(HWND, LPCWSTR); +extern void getWindowText(HWND, WPARAM, LPWSTR); +extern void setWindowText(HWND, LPWSTR); extern void updateWindow(HWND); extern void storelpParam(HWND, LPARAM); /* containers_windows.go */ -extern LPCWSTR xWC_TABCONTROL; +extern LPWSTR xWC_TABCONTROL; extern void setTabSubclass(HWND, void *); -extern void tabAppend(HWND, LPCWSTR); +extern void tabAppend(HWND, LPWSTR); extern void tabGetContentRect(HWND, RECT *); /* table_windows.go */ -extern LPCWSTR xWC_LISTVIEW; +extern LPWSTR xWC_LISTVIEW; extern void setTableSubclass(HWND, void *); -extern void tableAppendColumn(HWND, int, LPCWSTR); +extern void tableAppendColumn(HWND, int, LPWSTR); extern void tableUpdate(HWND, int); extern void tableAddExtendedStyles(HWND, LPARAM); diff --git a/redo/window_windows.c b/redo/window_windows.c index e848a89..9cf0654 100644 --- a/redo/window_windows.c +++ b/redo/window_windows.c @@ -60,7 +60,7 @@ DWORD makeWindowWindowClass(char **errmsg) return 0; } -HWND newWindow(LPCWSTR title, int width, int height, void *data) +HWND newWindow(LPWSTR title, int width, int height, void *data) { HWND hwnd;