Stripped C-style comments from C sources and headers where appropriate.

This commit is contained in:
Pietro Gagliardi 2014-08-14 10:42:10 -04:00
parent 19976849e1
commit c1dc235d3b
14 changed files with 102 additions and 106 deletions

View File

@ -1,6 +1,4 @@
/* 24 march 2014 */
/* TODO either strip the // comments or find out if --std=c99 is safe for cgo */
// 24 march 2014
#include "winapi_windows.h"
#include "_cgo_export.h"
@ -319,13 +317,13 @@ static LRESULT CALLBACK areaWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
data = (void *) GetWindowLongPtrW(hwnd, GWLP_USERDATA);
if (data == NULL) {
/* the lpParam is available during WM_NCCREATE and WM_CREATE */
// the lpParam is available during WM_NCCREATE and WM_CREATE
if (uMsg == WM_NCCREATE) {
storelpParam(hwnd, lParam);
data = (void *) GetWindowLongPtrW(hwnd, GWLP_USERDATA);
storeAreaHWND(data, hwnd);
}
/* act as if we're not ready yet, even during WM_NCCREATE (nothing important to the switch statement below happens here anyway) */
// act as if we're not ready yet, even during WM_NCCREATE (nothing important to the switch statement below happens here anyway)
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
}
@ -414,7 +412,7 @@ static LRESULT CALLBACK areaWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
}
xmissedmsg("Area", "areaWndProc()", uMsg);
return 0; /* unreached */
return 0; // unreached
}
DWORD makeAreaWindowClass(char **errmsg)

View File

@ -1,4 +1,4 @@
/* 17 july 2014 */
// 17 july 2014
#include "winapi_windows.h"
#include "_cgo_export.h"
@ -20,7 +20,7 @@ static LRESULT CALLBACK buttonSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA
return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam);
}
xmissedmsg("Button", "buttonSubProc()", uMsg);
return 0; /* unreached */
return 0; // unreached
}
void setButtonSubclass(HWND hwnd, void *data)
@ -36,7 +36,7 @@ static LRESULT CALLBACK checkboxSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPA
if (HIWORD(wParam) == BN_CLICKED) {
WPARAM check;
/* we didn't use BS_AUTOCHECKBOX (see controls_windows.go) so we have to manage the check state ourselves */
// we didn't use BS_AUTOCHECKBOX (see controls_windows.go) so we have to manage the check state ourselves
check = BST_CHECKED;
if (SendMessage(hwnd, BM_GETCHECK, 0, 0) == BST_CHECKED)
check = BST_UNCHECKED;
@ -53,7 +53,7 @@ static LRESULT CALLBACK checkboxSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPA
return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam);
}
xmissedmsg("Checkbox", "checkboxSubProc()", uMsg);
return 0; /* unreached */
return 0; // unreached
}
void setCheckboxSubclass(HWND hwnd, void *data)

View File

@ -1,11 +1,11 @@
/* 17 july 2014 */
// 17 july 2014
#include "winapi_windows.h"
static ULONG_PTR comctlManifestCookie;
static HMODULE comctl32;
/* these are listed as WINAPI in both Microsoft's and MinGW's headers, but not on MSDN for some reason */
// these are listed as WINAPI in both Microsoft's and MinGW's headers, but not on MSDN for some reason
BOOL (*WINAPI fv_SetWindowSubclass)(HWND, SUBCLASSPROC, UINT_PTR, DWORD_PTR);
BOOL (*WINAPI fv_RemoveWindowSubclass)(HWND, SUBCLASSPROC, UINT_PTR);
LRESULT (*WINAPI fv_DefSubclassProc)(HWND, UINT, WPARAM, LPARAM);
@ -16,7 +16,7 @@ LRESULT (*WINAPI fv_DefSubclassProc)(HWND, UINT, WPARAM, LPARAM);
ICC_LISTVIEW_CLASSES | /* list views */ \
0)
/* note that this is an 8-bit character string we're writing; see the encoding clause */
// note that this is an 8-bit character string we're writing; see the encoding clause
static const char manifest[] = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">\n<assemblyIdentity\n version=\"1.0.0.0\"\n processorArchitecture=\"*\"\n name=\"CompanyName.ProductName.YourApplication\"\n type=\"win32\"\n/>\n<description>Your application description here.</description>\n<dependency>\n <dependentAssembly>\n <assemblyIdentity\n type=\"win32\"\n name=\"Microsoft.Windows.Common-Controls\"\n version=\"6.0.0.0\"\n processorArchitecture=\"*\"\n publicKeyToken=\"6595b64144ccf1df\"\n language=\"*\"\n />\n </dependentAssembly>\n</dependency>\n</assembly>\n";
/*
@ -38,7 +38,7 @@ DWORD initCommonControls(char **errmsg)
HANDLE ac;
INITCOMMONCONTROLSEX icc;
FARPROC f;
/* this is listed as WINAPI in both Microsoft's and MinGW's headers, but not on MSDN for some reason */
// this is listed as WINAPI in both Microsoft's and MinGW's headers, but not on MSDN for some reason
BOOL (*WINAPI ficc)(const LPINITCOMMONCONTROLSEX);
if (GetTempPathW(MAX_PATH + 1, temppath) == 0) {
@ -50,14 +50,14 @@ DWORD initCommonControls(char **errmsg)
return GetLastError();
}
file = CreateFileW(filename, GENERIC_WRITE,
0, /* don't share while writing */
0, // don't share while writing
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (file == NULL) {
*errmsg = "error creating manifest file";
return GetLastError();
}
nExpected = (sizeof manifest / sizeof manifest[0]) - 1; /* - 1 to omit the terminating null character)
SetLastError(0); /* catch errorless short writes */
nExpected = (sizeof manifest / sizeof manifest[0]) - 1; // - 1 to omit the terminating null character)
SetLastError(0); // catch errorless short writes
if (WriteFile(file, manifest, nExpected, &nGot, NULL) == 0) {
*errmsg = "error writing manifest file";
return GetLastError();
@ -100,7 +100,7 @@ DWORD initCommonControls(char **errmsg)
return GetLastError();
}
/* GetProcAddress() only takes a multibyte string */
// GetProcAddress() only takes a multibyte string
#define LOAD(fn) f = GetProcAddress(comctl32, fn); \
if (f == NULL) { \
*errmsg = "error loading " fn "()"; \

View File

@ -1,6 +1,6 @@
// +build !windows,!darwin
/* 13 august 2014 */
// 13 august 2014
#include "gtk_unix.h"
#include "_cgo_export.h"
@ -18,7 +18,7 @@ typedef struct goContainerClass goContainerClass;
struct goContainer {
GtkContainer parent_instance;
void *gocontainer;
GPtrArray *children; /* for forall() */
GPtrArray *children; // for forall()
};
struct goContainerClass {

View File

@ -1,4 +1,4 @@
/* 17 july 2014 */
// 17 july 2014
#include "winapi_windows.h"
#include "_cgo_export.h"
@ -22,13 +22,13 @@ static LRESULT CALLBACK containerWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LP
data = (void *) GetWindowLongPtrW(hwnd, GWLP_USERDATA);
if (data == NULL) {
/* the lpParam is available during WM_NCCREATE and WM_CREATE */
// the lpParam is available during WM_NCCREATE and WM_CREATE
if (uMsg == WM_NCCREATE) {
storelpParam(hwnd, lParam);
data = (void *) GetWindowLongPtrW(hwnd, GWLP_USERDATA);
storeContainerHWND(data, hwnd);
}
/* act as if we're not ready yet, even during WM_NCCREATE (nothing important to the switch statement below happens here anyway) */
// act as if we're not ready yet, even during WM_NCCREATE (nothing important to the switch statement below happens here anyway)
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
}
@ -46,7 +46,7 @@ static LRESULT CALLBACK containerWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LP
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
}
xmissedmsg("container", "containerWndProc()", uMsg);
return 0; /* unreached */
return 0; // unreached
}
DWORD makeContainerWindowClass(char **errmsg)

View File

@ -1,4 +1,4 @@
/* 17 july 2014 */
// 17 july 2014
#include "winapi_windows.h"
#include "_cgo_export.h"
@ -13,12 +13,10 @@ HWND newControl(LPWSTR class, DWORD style, DWORD extstyle)
style | WS_CHILD | WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
/*
the following has the consequence of making the control message-only at first
this shouldn't cause any problems... hopefully not
but see the msgwndproc() for caveat info
also don't use low control IDs as they will conflict with dialog boxes (IDCANCEL, etc.)
*/
// the following has the consequence of making the control message-only at first
// this shouldn't cause any problems... hopefully not
// but see the msgwndproc() for caveat info
// also don't use low control IDs as they will conflict with dialog boxes (IDCANCEL, etc.)
msgwin, (HMENU) 100, hInstance, NULL);
if (hwnd == NULL)
xpanic("error creating control", GetLastError());
@ -44,7 +42,7 @@ LRESULT forwardCommand(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
HWND control = (HWND) lParam;
/* don't generate an event if the control (if there is one) is unparented (a child of the message-only window) */
// don't generate an event if the control (if there is one) is unparented (a child of the message-only window)
if (control != NULL && IsChild(msgwin, control) == 0)
return SendMessageW(control, msgCOMMAND, wParam, lParam);
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
@ -55,7 +53,7 @@ LRESULT forwardNotify(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
NMHDR *nmhdr = (NMHDR *) lParam;
HWND control = nmhdr->hwndFrom;
/* don't generate an event if the control (if there is one) is unparented (a child of the message-only window) */
// don't generate an event if the control (if there is one) is unparented (a child of the message-only window)
if (control != NULL && IsChild(msgwin, control) == 0)
return SendMessageW(control, msgNOTIFY, wParam, lParam);
return DefWindowProcW(hwnd, uMsg, wParam, lParam);

View File

@ -1,4 +1,4 @@
/* 16 march 2014 */
// 16 march 2014
#ifndef __GO_UI_GTK_UNIX_H__
#define __GO_UI_GTK_UNIX_H__
@ -9,20 +9,20 @@ MAX_ALLOWED signals that programs will not use features introduced in newer vers
Thanks to desrt in irc.gimp.net/#gtk+
*/
/* GLib/GObject */
// GLib/GObject
#define GLIB_VERSION_MIN_REQUIRED GLIB_VERSION_2_32
#define GLIB_VERSION_MAX_ALLOWED GLIB_VERSION_2_32
/* GDK/GTK+ */
// GDK/GTK+
#define GDK_VERSION_MIN_REQUIRED GDK_VERSION_3_4
#define GDK_VERSION_MAX_ALLOWED GDK_VERSION_3_4
/* cairo has no such macros (thanks Company in irc.gimp.net/#gtk+) */
// cairo has no such macros (thanks Company in irc.gimp.net/#gtk+)
#include <stdlib.h>
#include <gtk/gtk.h>
/* table_unix.c */
// table_unix.c
extern void tableAppendColumn(GtkTreeView *, gint, gchar *);
typedef struct goTableModel goTableModel;
typedef struct goTableModelClass goTableModelClass;
@ -36,7 +36,7 @@ struct goTableModelClass {
extern goTableModel *newTableModel(void *);
extern void tableUpdate(goTableModel *, gint, gint);
/* container_unix.c */
// container_unix.c
extern GtkWidget *newContainer(void *);
#endif

View File

@ -1,4 +1,4 @@
/* 17 july 2014 */
// 17 july 2014
#include "winapi_windows.h"
@ -21,7 +21,7 @@ DWORD initWindows(char **errmsg)
STARTUPINFOW si;
NONCLIENTMETRICSW ncm;
/* WinMain() parameters */
// WinMain() parameters
hInstance = GetModuleHandleW(NULL);
if (hInstance == NULL) {
*errmsg = "error getting hInstance";
@ -32,7 +32,7 @@ DWORD initWindows(char **errmsg)
if ((si.dwFlags & STARTF_USESHOWWINDOW) != 0)
nCmdShow = si.wShowWindow;
/* icons and cursors */
// icons and cursors
hDefaultIcon = LoadIconW(NULL, IDI_APPLICATION);
if (hDefaultIcon == NULL) {
*errmsg = "error loading default icon";
@ -44,7 +44,7 @@ DWORD initWindows(char **errmsg)
return GetLastError();
}
/* standard fonts */
// standard fonts
#define GETFONT(l, f, n) l = CreateFontIndirectW(&ncm.f); \
if (l == NULL) { \
*errmsg = "error loading " n " font"; \

View File

@ -1,9 +1,9 @@
/* 25 july 2014 */
// 25 july 2014
#include "winapi_windows.h"
#include "_cgo_export.h"
/* provided for cgo's benefit */
// provided for cgo's benefit
LPWSTR xWC_TABCONTROL = WC_TABCONTROL;
static LRESULT CALLBACK tabSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR id, DWORD_PTR data)
@ -16,10 +16,10 @@ static LRESULT CALLBACK tabSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
switch (nmhdr->code) {
case TCN_SELCHANGING:
r = SendMessageW(hwnd, TCM_GETCURSEL, 0, 0);
if (r == (LRESULT) -1) /* no tab currently selected */
if (r == (LRESULT) -1) // no tab currently selected
return FALSE;
tabChanging((void *) data, r);
return FALSE; /* allow change */
return FALSE; // allow change
case TCN_SELCHANGE:
tabChanged((void *) data, SendMessageW(hwnd, TCM_GETCURSEL, 0, 0));
return 0;
@ -33,7 +33,7 @@ static LRESULT CALLBACK tabSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam);
}
xmissedmsg("Tab", "tabSubProc()", uMsg);
return 0; /* unreached */
return 0; // unreached
}
void setTabSubclass(HWND hwnd, void *data)
@ -50,7 +50,7 @@ void tabAppend(HWND hwnd, LPWSTR name)
ZeroMemory(&item, sizeof (TCITEM));
item.mask = TCIF_TEXT;
item.pszText = name;
/* MSDN's example code uses the first invalid index directly for this */
// MSDN's example code uses the first invalid index directly for this
n = SendMessageW(hwnd, TCM_GETITEMCOUNT, 0, 0);
if (SendMessageW(hwnd, TCM_INSERTITEM, (WPARAM) n, (LPARAM) (&item)) == (LRESULT) -1)
xpanic("error adding tab to Tab", GetLastError());
@ -58,11 +58,11 @@ void tabAppend(HWND hwnd, LPWSTR name)
void tabGetContentRect(HWND hwnd, RECT *r)
{
/* not &r; already a pointer (thanks MindChild in irc.efnet.net/#winprog for spotting my failure) */
// not &r; already a pointer (thanks MindChild in irc.efnet.net/#winprog for spotting my failure)
SendMessageW(hwnd, TCM_ADJUSTRECT, FALSE, (LPARAM) r);
}
/* theoretically we don't need to iterate over every tab for this, but let's do it just to be safe */
// theoretically we don't need to iterate over every tab for this, but let's do it just to be safe
LONG tabGetTabHeight(HWND hwnd)
{
RECT r;
@ -70,7 +70,7 @@ LONG tabGetTabHeight(HWND hwnd)
LONG tallest;
n = SendMessageW(hwnd, TCM_GETITEMCOUNT, 0, 0);
/* if there are no tabs, then the control just draws a box over the full window rect, reserving no space for tabs; this is handled with the next line */
// if there are no tabs, then the control just draws a box over the full window rect, reserving no space for tabs; this is handled with the next line
tallest = 0;
for (i = 0; i < n; i++) {
if (SendMessageW(hwnd, TCM_GETITEMRECT, (WPARAM) i, (LPARAM) (&r)) == FALSE)

View File

@ -1,6 +1,6 @@
// +build !windows,!darwin
/* 29 july 2014 */
// 29 july 2014
#include "gtk_unix.h"
#include "_cgo_export.h"
@ -14,7 +14,7 @@ void tableAppendColumn(GtkTreeView *table, gint index, gchar *name)
col = gtk_tree_view_column_new_with_attributes(name, renderer,
"text", index,
NULL);
/* allow columns to be resized */
// allow columns to be resized
gtk_tree_view_column_set_resizable(col, TRUE);
gtk_tree_view_append_column(table, col);
}
@ -37,7 +37,7 @@ G_DEFINE_TYPE_WITH_CODE(goTableModel, goTableModel, G_TYPE_OBJECT,
static void goTableModel_init(goTableModel *t)
{
/* do nothing */
// do nothing
}
static void goTableModel_dispose(GObject *obj)
@ -50,14 +50,14 @@ static void goTableModel_finalize(GObject *obj)
G_OBJECT_CLASS(goTableModel_parent_class)->finalize(obj);
}
/* and now for the interface function definitions */
// and now for the interface function definitions
static GtkTreeModelFlags goTableModel_get_flags(GtkTreeModel *model)
{
return GTK_TREE_MODEL_LIST_ONLY;
}
/* get_n_columns in Go */
// get_n_columns in Go
static GType goTableModel_get_column_type(GtkTreeModel *model, gint column)
{
@ -86,9 +86,9 @@ bad:
static GtkTreePath *goTableModel_get_path(GtkTreeModel *model, GtkTreeIter *iter)
{
/* note: from this point forward, the GOOD_STAMP checks ensure that the index stored in iter is nonnegative */
// note: from this point forward, the GOOD_STAMP checks ensure that the index stored in iter is nonnegative
if (iter->stamp != GOOD_STAMP)
return NULL; /* this is what both GtkListStore and GtkTreeStore do */
return NULL; // this is what both GtkListStore and GtkTreeStore do
return gtk_tree_path_new_from_indices(FROM(iter->user_data), -1);
}
@ -98,10 +98,10 @@ static void goTableModel_get_value(GtkTreeModel *model, GtkTreeIter *iter, gint
gchar *str;
if (iter->stamp != GOOD_STAMP)
return; /* this is what both GtkListStore and GtkTreeStore do */
/* we (actually cgo) allocated str with malloc(), not g_malloc(), so let's free it explicitly and give the GValue a copy to be safe */
return; // this is what both GtkListStore and GtkTreeStore do
// we (actually cgo) allocated str with malloc(), not g_malloc(), so let's free it explicitly and give the GValue a copy to be safe
str = goTableModel_do_get_value(t->gotable, FROM(iter->user_data), column);
/* value is uninitialized */
// value is uninitialized
g_value_init(value, G_TYPE_STRING);
g_value_set_string(value, str);
free(str);
@ -113,7 +113,7 @@ static gboolean goTableModel_iter_next(GtkTreeModel *model, GtkTreeIter *iter)
gint index;
if (iter->stamp != GOOD_STAMP)
return FALSE; /* this is what both GtkListStore and GtkTreeStore do */
return FALSE; // this is what both GtkListStore and GtkTreeStore do
index = FROM(iter->user_data);
index++;
if (index >= goTableModel_getRowCount(t->gotable)) {
@ -130,7 +130,7 @@ static gboolean goTableModel_iter_previous(GtkTreeModel *model, GtkTreeIter *ite
gint index;
if (iter->stamp != GOOD_STAMP)
return FALSE; /* this is what both GtkListStore and GtkTreeStore do */
return FALSE; // this is what both GtkListStore and GtkTreeStore do
index = FROM(iter->user_data);
if (index <= 0) {
iter->stamp = BAD_STAMP;
@ -187,11 +187,11 @@ static gboolean goTableModel_iter_parent(GtkTreeModel *model, GtkTreeIter *paren
return FALSE;
}
/* end of interface definitions */
// end of interface definitions
static void goTableModel_initGtkTreeModel(GtkTreeModelIface *interface)
{
/* don't chain; we have nothing to chain to */
// don't chain; we have nothing to chain to
#define DEF(x) interface->x = goTableModel_ ## x;
DEF(get_flags)
DEF(get_n_columns)
@ -206,7 +206,7 @@ static void goTableModel_initGtkTreeModel(GtkTreeModelIface *interface)
DEF(iter_n_children)
DEF(iter_nth_child)
DEF(iter_parent)
/* no need for ref_node and unref_node */
// no need for ref_node and unref_node
}
static GParamSpec *goTableModelProperties[2];
@ -247,7 +247,7 @@ goTableModel *newTableModel(void *gotable)
return (goTableModel *) g_object_new(goTableModel_get_type(), "gotable", (gpointer) gotable, NULL);
}
/* somewhat naive, but the only alternatives seem to be unloading/reloading the model (or the view!), which is bleh */
// somewhat naive, but the only alternatives seem to be unloading/reloading the model (or the view!), which is bleh
void tableUpdate(goTableModel *t, gint old, gint new)
{
gint i;
@ -256,7 +256,7 @@ void tableUpdate(goTableModel *t, gint old, gint new)
GtkTreeIter iter;
iter.stamp = GOOD_STAMP;
/* first, append extra items */
// first, append extra items
if (old < new) {
for (i = old; i < new; i++) {
path = gtk_tree_path_new_from_indices(i, -1);
@ -266,18 +266,18 @@ void tableUpdate(goTableModel *t, gint old, gint new)
nUpdate = old;
} else
nUpdate = new;
/* next, update existing items */
// next, update existing items
for (i = 0; i < nUpdate; i++) {
path = gtk_tree_path_new_from_indices(i, -1);
iter.user_data = TO(i);
g_signal_emit_by_name(t, "row-updated", path, &iter);
}
/* finally, remove deleted items */
// finally, remove deleted items
if (old > new)
for (i = new; i < old; i++) {
/* note that we repeatedly remove the row at index new, as that changes with each removal; NOT i */
// note that we repeatedly remove the row at index new, as that changes with each removal; NOT i
path = gtk_tree_path_new_from_indices(new, -1);
/* row-deleted has no iter */
// row-deleted has no iter
g_signal_emit_by_name(t, "row-deleted", path);
}
}

View File

@ -1,9 +1,9 @@
/* 28 july 2014 */
// 28 july 2014
#include "winapi_windows.h"
#include "_cgo_export.h"
/* provided for cgo's benefit */
// provided for cgo's benefit
LPWSTR xWC_LISTVIEW = WC_LISTVIEW;
static LRESULT CALLBACK tableSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR id, DWORD_PTR data)
@ -19,8 +19,8 @@ static LRESULT CALLBACK tableSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
return 0;
}
return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam);
/* see table.autoresize() in table_windows.go for the column autosize policy */
case WM_NOTIFY: /* from the contained header control */
// see table.autoresize() in table_windows.go for the column autosize policy
case WM_NOTIFY: // from the contained header control
if (nmhdr->code == HDN_BEGINTRACK)
tableStopColumnAutosize((void *) data);
return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam);
@ -32,7 +32,7 @@ static LRESULT CALLBACK tableSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam);
}
xmissedmsg("Button", "tableSubProc()", uMsg);
return 0; /* unreached */
return 0; // unreached
}
void setTableSubclass(HWND hwnd, void *data)
@ -63,7 +63,7 @@ void tableUpdate(HWND hwnd, int nItems)
void tableAddExtendedStyles(HWND hwnd, LPARAM styles)
{
/* the bits of WPARAM specify which bits of LPARAM to look for; having WPARAM == LPARAM ensures that only the bits we want to add are affected */
// the bits of WPARAM specify which bits of LPARAM to look for; having WPARAM == LPARAM ensures that only the bits we want to add are affected
SendMessageW(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, (WPARAM) styles, styles);
}

View File

@ -1,9 +1,9 @@
/* 17 july 2014 */
// 17 july 2014
#include "winapi_windows.h"
#include "_cgo_export.h"
/* note that this includes the terminating '\0' */
// note that this includes the terminating '\0'
#define NAREACLASS (sizeof areaWindowClass / sizeof areaWindowClass[0])
void uimsgloop(void)
@ -19,7 +19,7 @@ void uimsgloop(void)
res = GetMessageW(&msg, NULL, 0, 0);
if (res < 0)
xpanic("error calling GetMessage()", GetLastError());
if (res == 0) /* WM_QUIT */
if (res == 0) // WM_QUIT
break;
active = GetActiveWindow();
if (active != NULL) {
@ -70,7 +70,7 @@ static LRESULT CALLBACK msgwinproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
}
xmissedmsg("message-only", "msgwinproc()", uMsg);
return 0; /* unreachable */
return 0; // unreachable
}
DWORD makemsgwin(char **errmsg)

View File

@ -1,6 +1,6 @@
/* 17 july 2014 */
// 17 july 2014
/* cgo will include this file multiple times */
// cgo will include this file multiple times
#ifndef __GO_UI_WINAPI_WINDOWS_H__
#define __GO_UI_WINAPI_WINDOWS_H__
@ -8,7 +8,7 @@
#define _UNICODE
#define STRICT
#define STRICT_TYPED_ITEMIDS
/* get Windows version right; right now Windows XP */
// get Windows version right; right now Windows XP
#define WINVER 0x0501
#define _WIN32_WINNT 0x0501
#define _WIN32_WINDOWS 0x0501 /* according to Microsoft's winperf.h */
@ -22,29 +22,29 @@
#include <wchar.h>
#include <windowsx.h>
/* global messages unique to everything */
// global messages unique to everything
enum {
msgRequest = WM_APP + 1, /* + 1 just to be safe */
msgCOMMAND, /* WM_COMMAND proxy; see forwardCommand() in controls_windows.go */
msgNOTIFY, /* WM_NOTIFY proxy */
msgRequest = WM_APP + 1, // + 1 just to be safe
msgCOMMAND, // WM_COMMAND proxy; see forwardCommand() in controls_windows.go
msgNOTIFY, // WM_NOTIFY proxy
msgAreaSizeChanged,
msgAreaRepaintAll,
};
/* uitask_windows.c */
// uitask_windows.c
extern void uimsgloop(void);
extern void issue(void *);
extern HWND msgwin;
extern DWORD makemsgwin(char **);
/* comctl32_windows.c */
// comctl32_windows.c
extern DWORD initCommonControls(char **);
/* these are listed as WINAPI in both Microsoft's and MinGW's headers, but not on MSDN for some reason */
// 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);
/* control_windows.c */
// control_windows.c
extern HWND newControl(LPWSTR, DWORD, DWORD);
extern void controlSetParent(HWND, HWND);
extern void controlSetControlFont(HWND);
@ -53,13 +53,13 @@ extern LRESULT forwardNotify(HWND, UINT, WPARAM, LPARAM);
extern void moveWindow(HWND, int, int, int, int);
extern LONG controlTextLength(HWND, LPWSTR);
/* basicctrls_windows.c */
// basicctrls_windows.c
extern void setButtonSubclass(HWND, void *);
extern void setCheckboxSubclass(HWND, void *);
extern BOOL checkboxChecked(HWND);
extern void checkboxSetChecked(HWND, BOOL);
/* init_windows.c */
// init_windows.c
extern HINSTANCE hInstance;
extern int nCmdShow;
extern HICON hDefaultIcon;
@ -72,26 +72,26 @@ extern HFONT statusbarFont;
extern HBRUSH hollowBrush;
extern DWORD initWindows(char **);
/* window_windows.c */
// window_windows.c
extern DWORD makeWindowWindowClass(char **);
extern HWND newWindow(LPWSTR, int, int, void *);
extern void windowClose(HWND);
/* common_windows.c */
// common_windows.c
extern LRESULT getWindowTextLen(HWND);
extern void getWindowText(HWND, WPARAM, LPWSTR);
extern void setWindowText(HWND, LPWSTR);
extern void updateWindow(HWND);
extern void storelpParam(HWND, LPARAM);
/* tab_windows.go */
// tab_windows.go
extern LPWSTR xWC_TABCONTROL;
extern void setTabSubclass(HWND, void *);
extern void tabAppend(HWND, LPWSTR);
extern void tabGetContentRect(HWND, RECT *);
extern LONG tabGetTabHeight(HWND);
/* table_windows.go */
// table_windows.go
extern LPWSTR xWC_LISTVIEW;
extern void setTableSubclass(HWND, void *);
extern void tableAppendColumn(HWND, int, LPWSTR);
@ -99,12 +99,12 @@ extern void tableUpdate(HWND, int);
extern void tableAddExtendedStyles(HWND, LPARAM);
extern void tableAutosizeColumns(HWND, int);
/* container_windows.c */
// container_windows.c
extern DWORD makeContainerWindowClass(char **);
extern HWND newContainer(void *);
extern void calculateBaseUnits(HWND, int *, int *, LONG *);
/* area_window.c */
// area_window.c
#define areaWindowClass L"gouiarea"
extern void repaintArea(HWND);
extern DWORD makeAreaWindowClass(char **);

View File

@ -1,4 +1,4 @@
/* 17 july 2014 */
// 17 july 2014
#include "winapi_windows.h"
#include "_cgo_export.h"
@ -12,13 +12,13 @@ static LRESULT CALLBACK windowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA
data = (void *) GetWindowLongPtrW(hwnd, GWLP_USERDATA);
if (data == NULL) {
/* the lpParam is available during WM_NCCREATE and WM_CREATE */
// the lpParam is available during WM_NCCREATE and WM_CREATE
if (uMsg == WM_NCCREATE) {
storelpParam(hwnd, lParam);
data = (void *) GetWindowLongPtrW(hwnd, GWLP_USERDATA);
storeWindowHWND(data, hwnd);
}
/* act as if we're not ready yet, even during WM_NCCREATE (nothing important to the switch statement below happens here anyway) */
// act as if we're not ready yet, even during WM_NCCREATE (nothing important to the switch statement below happens here anyway)
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
}
@ -39,7 +39,7 @@ static LRESULT CALLBACK windowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
}
xmissedmsg("Window", "windowWinProc()", uMsg);
return 0; /* unreached */
return 0; // unreached
}
DWORD makeWindowWindowClass(char **errmsg)