Removed intmax_t from everything else EXCEPT the Windows code. Now it's time for THAT...

This commit is contained in:
Pietro Gagliardi 2016-06-13 21:37:50 -04:00
parent 2affdab837
commit 75a8ee9bf9
12 changed files with 28 additions and 24 deletions

View File

@ -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 // x, y, xdist, ydist, and c.rect must have the same units
// so must time, maxTime, and c.prevTime // 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 // different button than before? if so, don't count
if (button != c->curButton) if (button != c->curButton)

View File

@ -36,15 +36,15 @@ typedef struct clickCounter clickCounter;
// you should call Reset() to zero-initialize a new instance // 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 // 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 { struct clickCounter {
uintmax_t curButton; int curButton;
intmax_t rectX0; int rectX0;
intmax_t rectY0; int rectY0;
intmax_t rectX1; int rectX1;
intmax_t rectY1; int rectY1;
uintptr_t prevTime; 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 void clickCounterReset(clickCounter *);
extern int fromScancode(uintptr_t, uiAreaKeyEvent *); extern int fromScancode(uintptr_t, uiAreaKeyEvent *);

View File

@ -127,7 +127,7 @@ void uiEditableComboboxSetText(uiEditableCombobox *c, const char *text)
#if 0 #if 0
// LONGTERM // LONGTERM
void uiEditableComboboxSetSelected(uiEditableCombobox *c, intmax_t n) void uiEditableComboboxSetSelected(uiEditableCombobox *c, int n)
{ {
if (c->editable) { if (c->editable) {
// see https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ComboBox/Tasks/SettingComboBoxValue.html#//apple_ref/doc/uid/20000256 // see https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ComboBox/Tasks/SettingComboBoxValue.html#//apple_ref/doc/uid/20000256

View File

@ -23,7 +23,7 @@
uiForm *f; uiForm *f;
NSMutableArray *children; NSMutableArray *children;
int padded; int padded;
uintmax_t nStretchy; int nStretchy;
NSLayoutConstraint *first; NSLayoutConstraint *first;
NSMutableArray *inBetweens; NSMutableArray *inBetweens;
@ -40,7 +40,7 @@
- (CGFloat)paddingAmount; - (CGFloat)paddingAmount;
- (void)establishOurConstraints; - (void)establishOurConstraints;
- (void)append:(NSString *)label c:(uiControl *)c stretchy:(int)stretchy; - (void)append:(NSString *)label c:(uiControl *)c stretchy:(int)stretchy;
//TODO- (void)delete:(uintmax_t)n; //TODO- (void)delete:(int)n;
- (int)isPadded; - (int)isPadded;
- (void)setPadded:(int)p; - (void)setPadded:(int)p;
- (BOOL)hugsTrailing; - (BOOL)hugsTrailing;
@ -338,7 +338,7 @@ struct uiForm {
formChild *fc; formChild *fc;
NSLayoutPriority priority; NSLayoutPriority priority;
NSLayoutAttribute attribute; NSLayoutAttribute attribute;
uintmax_t oldnStretchy; int oldnStretchy;
fc = [[formChild alloc] initWithLabel:newLabel(label)]; fc = [[formChild alloc] initWithLabel:newLabel(label)];
fc.c = c; fc.c = c;
@ -389,7 +389,7 @@ struct uiForm {
[fc release]; // we don't need the initial reference now [fc release]; // we don't need the initial reference now
} }
//TODO- (void)delete:(uintmax_t)n //TODO- (void)delete:(int)n
- (int)isPadded - (int)isPadded
{ {

View File

@ -317,7 +317,7 @@ static uiSpinbox *spinbox;
static uiSlider *slider; static uiSlider *slider;
static uiProgressBar *progressbar; static uiProgressBar *progressbar;
static void update(intmax_t value) static void update(int value)
{ {
uiSpinboxSetValue(spinbox, value); uiSpinboxSetValue(spinbox, value);
uiSliderSetValue(slider, value); uiSliderSetValue(slider, value);

View File

@ -1964,7 +1964,7 @@ static const struct drawtest tests[] = {
{ NULL, NULL }, { NULL, NULL },
}; };
void runDrawTest(intmax_t n, uiAreaDrawParams *p) void runDrawTest(int n, uiAreaDrawParams *p)
{ {
(*(tests[n].draw))(p); (*(tests[n].draw))(p);
} }

View File

@ -8,7 +8,7 @@ static uiProgressBar *pbar;
#define CHANGED(what) \ #define CHANGED(what) \
static void on ## what ## Changed(ui ## what *this, void *data) \ static void on ## what ## Changed(ui ## what *this, void *data) \
{ \ { \
uintmax_t value; \ int value; \
printf("on %s changed\n", #what); \ printf("on %s changed\n", #what); \
value = ui ## what ## Value(this); \ value = ui ## what ## Value(this); \
uiSpinboxSetValue(spinbox, value); \ uiSpinboxSetValue(spinbox, value); \

View File

@ -5,7 +5,7 @@ static void onListFonts(uiButton *b, void *data)
{ {
uiDrawFontFamilies *ff; uiDrawFontFamilies *ff;
char *this; char *this;
uintmax_t i, n; int i, n;
uiMultilineEntrySetText(uiMultilineEntry(data), ""); uiMultilineEntrySetText(uiMultilineEntry(data), "");
ff = uiDrawListFontFamilies(); ff = uiDrawListFontFamilies();

View File

@ -7,8 +7,8 @@ struct thing {
}; };
static struct thing *things = NULL; static struct thing *things = NULL;
static uintmax_t len = 0; static size_t len = 0;
static uintmax_t cap = 0; static size_t cap = 0;
#define grow 32 #define grow 32
@ -37,9 +37,9 @@ enum types {
void setSpaced(int spaced) void setSpaced(int spaced)
{ {
uintmax_t i; size_t i;
void *p; void *p;
uintmax_t j, n; size_t j, n;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
p = things[i].ptr; p = things[i].ptr;
@ -72,9 +72,9 @@ void querySpaced(char out[12]) // more than enough
{ {
int m = 0; int m = 0;
int p = 0; int p = 0;
uintmax_t i; size_t i;
void *pp; void *pp;
uintmax_t j, n; size_t j, n;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
pp = things[i].ptr; pp = things[i].ptr;

View File

@ -50,7 +50,7 @@ extern uiBox *makePage5(uiWindow *);
extern uiBox *makePage6(void); extern uiBox *makePage6(void);
// drawtests.c // drawtests.c
extern void runDrawTest(intmax_t, uiAreaDrawParams *); extern void runDrawTest(int, uiAreaDrawParams *);
extern void populateComboboxWithTests(uiCombobox *); extern void populateComboboxWithTests(uiCombobox *);
// page7.c // page7.c

View File

@ -251,6 +251,9 @@ static gboolean areaWidget_button_press_event(GtkWidget *w, GdkEventButton *e)
"gtk-double-click-distance", &maxDistance, "gtk-double-click-distance", &maxDistance,
NULL); NULL);
// don't unref settings; it's transfer-none (thanks gregier in irc.gimp.net/#gtk+) // 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, me.Count = clickCounterClick(a->cc, me.Down,
e->x, e->y, e->x, e->y,
e->time, maxTime, e->time, maxTime,

View File

@ -117,6 +117,7 @@ static void areaMouseEvent(uiArea *a, int down, int up, WPARAM wParam, LPARAM l
if (me.Down != 0) 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) // 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 // 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.Count = clickCounterClick(&(a->cc), me.Down,
me.X, me.Y, me.X, me.Y,
GetMessageTime(), GetDoubleClickTime(), GetMessageTime(), GetDoubleClickTime(),