From 75a8ee9bf9cdbec73fea074fea4dc0681d375cba Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Mon, 13 Jun 2016 21:37:50 -0400 Subject: [PATCH] Removed intmax_t from everything else EXCEPT the Windows code. Now it's time for THAT... --- common/areaevents.c | 2 +- common/uipriv.h | 14 +++++++------- darwin/editablecombo.m | 2 +- darwin/form.m | 8 ++++---- examples/controlgallery/main.c | 2 +- test/drawtests.c | 2 +- test/page4.c | 2 +- test/page8.c | 2 +- test/spaced.c | 12 ++++++------ test/test.h | 2 +- unix/area.c | 3 +++ windows/areaevents.cpp | 1 + 12 files changed, 28 insertions(+), 24 deletions(-) diff --git a/common/areaevents.c b/common/areaevents.c index c4abf102..cf3c288c 100644 --- a/common/areaevents.c +++ b/common/areaevents.c @@ -14,7 +14,7 @@ Thanks to mclasen, garnacho_, halfline, and tristan in irc.gimp.net/#gtk+. // x, y, xdist, ydist, and c.rect must have the same units // so must time, maxTime, and c.prevTime -uintmax_t clickCounterClick(clickCounter *c, uintmax_t button, intmax_t x, intmax_t y, uintptr_t time, uintptr_t maxTime, intmax_t xdist, intmax_t ydist) +int clickCounterClick(clickCounter *c, int button, int x, int y, uintptr_t time, uintptr_t maxTime, int32_t xdist, int32_t ydist) { // different button than before? if so, don't count if (button != c->curButton) diff --git a/common/uipriv.h b/common/uipriv.h index 73210719..63f44467 100644 --- a/common/uipriv.h +++ b/common/uipriv.h @@ -36,15 +36,15 @@ typedef struct clickCounter clickCounter; // you should call Reset() to zero-initialize a new instance // it doesn't matter that all the non-count fields are zero: the first click will fail the curButton test straightaway, so it'll return 1 and set the rest of the structure accordingly struct clickCounter { - uintmax_t curButton; - intmax_t rectX0; - intmax_t rectY0; - intmax_t rectX1; - intmax_t rectY1; + int curButton; + int rectX0; + int rectY0; + int rectX1; + int rectY1; uintptr_t prevTime; - uintmax_t count; + int count; }; -extern uintmax_t clickCounterClick(clickCounter *, uintmax_t, intmax_t, intmax_t, uintptr_t, uintptr_t, intmax_t, intmax_t); +extern int clickCounterClick(clickCounter *, int, int, int, uintptr_t, uintptr_t, int32_t, int32_t); extern void clickCounterReset(clickCounter *); extern int fromScancode(uintptr_t, uiAreaKeyEvent *); diff --git a/darwin/editablecombo.m b/darwin/editablecombo.m index c676c562..434add70 100644 --- a/darwin/editablecombo.m +++ b/darwin/editablecombo.m @@ -127,7 +127,7 @@ void uiEditableComboboxSetText(uiEditableCombobox *c, const char *text) #if 0 // LONGTERM -void uiEditableComboboxSetSelected(uiEditableCombobox *c, intmax_t n) +void uiEditableComboboxSetSelected(uiEditableCombobox *c, int n) { if (c->editable) { // see https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ComboBox/Tasks/SettingComboBoxValue.html#//apple_ref/doc/uid/20000256 diff --git a/darwin/form.m b/darwin/form.m index ffebc67e..cdc3563b 100644 --- a/darwin/form.m +++ b/darwin/form.m @@ -23,7 +23,7 @@ uiForm *f; NSMutableArray *children; int padded; - uintmax_t nStretchy; + int nStretchy; NSLayoutConstraint *first; NSMutableArray *inBetweens; @@ -40,7 +40,7 @@ - (CGFloat)paddingAmount; - (void)establishOurConstraints; - (void)append:(NSString *)label c:(uiControl *)c stretchy:(int)stretchy; -//TODO- (void)delete:(uintmax_t)n; +//TODO- (void)delete:(int)n; - (int)isPadded; - (void)setPadded:(int)p; - (BOOL)hugsTrailing; @@ -338,7 +338,7 @@ struct uiForm { formChild *fc; NSLayoutPriority priority; NSLayoutAttribute attribute; - uintmax_t oldnStretchy; + int oldnStretchy; fc = [[formChild alloc] initWithLabel:newLabel(label)]; fc.c = c; @@ -389,7 +389,7 @@ struct uiForm { [fc release]; // we don't need the initial reference now } -//TODO- (void)delete:(uintmax_t)n +//TODO- (void)delete:(int)n - (int)isPadded { diff --git a/examples/controlgallery/main.c b/examples/controlgallery/main.c index 24e8130f..fd9c8ea5 100644 --- a/examples/controlgallery/main.c +++ b/examples/controlgallery/main.c @@ -317,7 +317,7 @@ static uiSpinbox *spinbox; static uiSlider *slider; static uiProgressBar *progressbar; -static void update(intmax_t value) +static void update(int value) { uiSpinboxSetValue(spinbox, value); uiSliderSetValue(slider, value); diff --git a/test/drawtests.c b/test/drawtests.c index 09ecac45..b6de753f 100644 --- a/test/drawtests.c +++ b/test/drawtests.c @@ -1964,7 +1964,7 @@ static const struct drawtest tests[] = { { NULL, NULL }, }; -void runDrawTest(intmax_t n, uiAreaDrawParams *p) +void runDrawTest(int n, uiAreaDrawParams *p) { (*(tests[n].draw))(p); } diff --git a/test/page4.c b/test/page4.c index 5a448c44..ce4a6afb 100644 --- a/test/page4.c +++ b/test/page4.c @@ -8,7 +8,7 @@ static uiProgressBar *pbar; #define CHANGED(what) \ static void on ## what ## Changed(ui ## what *this, void *data) \ { \ - uintmax_t value; \ + int value; \ printf("on %s changed\n", #what); \ value = ui ## what ## Value(this); \ uiSpinboxSetValue(spinbox, value); \ diff --git a/test/page8.c b/test/page8.c index 3819257d..7d855560 100644 --- a/test/page8.c +++ b/test/page8.c @@ -5,7 +5,7 @@ static void onListFonts(uiButton *b, void *data) { uiDrawFontFamilies *ff; char *this; - uintmax_t i, n; + int i, n; uiMultilineEntrySetText(uiMultilineEntry(data), ""); ff = uiDrawListFontFamilies(); diff --git a/test/spaced.c b/test/spaced.c index a54a0089..02db99ae 100644 --- a/test/spaced.c +++ b/test/spaced.c @@ -7,8 +7,8 @@ struct thing { }; static struct thing *things = NULL; -static uintmax_t len = 0; -static uintmax_t cap = 0; +static size_t len = 0; +static size_t cap = 0; #define grow 32 @@ -37,9 +37,9 @@ enum types { void setSpaced(int spaced) { - uintmax_t i; + size_t i; void *p; - uintmax_t j, n; + size_t j, n; for (i = 0; i < len; i++) { p = things[i].ptr; @@ -72,9 +72,9 @@ void querySpaced(char out[12]) // more than enough { int m = 0; int p = 0; - uintmax_t i; + size_t i; void *pp; - uintmax_t j, n; + size_t j, n; for (i = 0; i < len; i++) { pp = things[i].ptr; diff --git a/test/test.h b/test/test.h index 2afe3e39..e1b16299 100644 --- a/test/test.h +++ b/test/test.h @@ -50,7 +50,7 @@ extern uiBox *makePage5(uiWindow *); extern uiBox *makePage6(void); // drawtests.c -extern void runDrawTest(intmax_t, uiAreaDrawParams *); +extern void runDrawTest(int, uiAreaDrawParams *); extern void populateComboboxWithTests(uiCombobox *); // page7.c diff --git a/unix/area.c b/unix/area.c index eab01681..c5b490d6 100644 --- a/unix/area.c +++ b/unix/area.c @@ -251,6 +251,9 @@ static gboolean areaWidget_button_press_event(GtkWidget *w, GdkEventButton *e) "gtk-double-click-distance", &maxDistance, NULL); // don't unref settings; it's transfer-none (thanks gregier in irc.gimp.net/#gtk+) + // e->time is guint32 + // e->x and e->y are floating-point; just make them 32-bit integers + // maxTime and maxDistance... are gint, which *should* fit, hopefully... me.Count = clickCounterClick(a->cc, me.Down, e->x, e->y, e->time, maxTime, diff --git a/windows/areaevents.cpp b/windows/areaevents.cpp index 0aa5bee9..7d391b85 100644 --- a/windows/areaevents.cpp +++ b/windows/areaevents.cpp @@ -117,6 +117,7 @@ static void areaMouseEvent(uiArea *a, int down, int up, WPARAM wParam, LPARAM l if (me.Down != 0) // GetMessageTime() returns LONG and GetDoubleClckTime() returns UINT, which are int32 and uint32, respectively, but we don't need to worry about the signedness because for the same bit widths and two's complement arithmetic, s1-s2 == u1-u2 if bits(s1)==bits(s2) and bits(u1)==bits(u2) (and Windows requires two's complement: http://blogs.msdn.com/b/oldnewthing/archive/2005/05/27/422551.aspx) // signedness isn't much of an issue for these calls anyway because http://stackoverflow.com/questions/24022225/what-are-the-sign-extension-rules-for-calling-windows-api-functions-stdcall-t and that we're only using unsigned values (think back to how you (didn't) handle signedness in assembly language) AND because of the above AND because the statistics below (time interval and width/height) really don't make sense if negative + // GetSystemMetrics() returns int, which is int32 me.Count = clickCounterClick(&(a->cc), me.Down, me.X, me.Y, GetMessageTime(), GetDoubleClickTime(),