Prepare for 64 bit

Mostly fixes problems involving NSUInteger.
This commit is contained in:
Bjorn Winckler
2009-09-28 22:55:16 +02:00
parent 281f280eb1
commit be45005f25
12 changed files with 86 additions and 69 deletions
+1 -2
View File
@@ -54,8 +54,7 @@
NSEnumerator* myIterator = [commands objectEnumerator];
NSDictionary* currCommand;
while (currCommand = [myIterator nextObject])
{
while ((currCommand = [myIterator nextObject])) {
/* do something useful with currCommand */
FILE *ioPipe = NULL;
char junk[256];
+40 -26
View File
@@ -72,17 +72,19 @@ static float MMCascadeHorizontalOffset = 21;
static float MMCascadeVerticalOffset = 23;
#pragma options align=mac68k
#pragma pack(push,1)
// The alignment and sizes of these fields are based on trial-and-error. It
// may be necessary to adjust them to fit if Xcode ever changes this struct.
typedef struct
{
short unused1; // 0 (not used)
short lineNum; // line to select (< 0 to specify range)
long startRange; // start of selection range (if line < 0)
long endRange; // end of selection range (if line < 0)
long unused2; // 0 (not used)
long theDate; // modification date/time
} MMSelectionRange;
#pragma options align=reset
int16_t unused1; // 0 (not used)
int16_t lineNum; // line to select (< 0 to specify range)
int32_t startRange; // start of selection range (if line < 0)
int32_t endRange; // end of selection range (if line < 0)
int32_t unused2; // 0 (not used)
int32_t theDate; // modification date/time
} MMXcodeSelectionRange;
#pragma pack(pop)
// This is a private AppKit API gleaned from class-dump.
@@ -694,9 +696,9 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
- (void)removeVimController:(id)controller
{
ASLogDebug(@"Remove Vim controller pid=%d id=%d (processingFlag=%d)",
[controller pid], [controller identifier], processingFlag);
[controller pid], [controller vimControllerId], processingFlag);
int idx = [vimControllers indexOfObject:controller];
NSUInteger idx = [vimControllers indexOfObject:controller];
if (NSNotFound == idx) {
ASLogDebug(@"Controller not found, probably due to duplicate removal");
return;
@@ -1231,7 +1233,7 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
[vc release];
return [vc identifier];
return [vc vimControllerId];
}
- (oneway void)processInput:(in bycopy NSArray *)queue
@@ -1618,7 +1620,7 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
NSArray *queries = [[url query] componentsSeparatedByString:@"&"];
NSEnumerator *enumerator = [queries objectEnumerator];
NSString *param;
while( param = [enumerator nextObject] ) {
while ((param = [enumerator nextObject])) {
NSArray *arr = [param componentsSeparatedByString:@"="];
if ([arr count] == 2) {
[dict setValue:[[arr lastObject]
@@ -1739,19 +1741,30 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
[desc paramDescriptorForKeyword:keyAEPosition];
if (xcodedesc) {
NSRange range;
MMSelectionRange *sr = (MMSelectionRange*)[[xcodedesc data] bytes];
NSData *data = [xcodedesc data];
NSUInteger length = [data length];
if (sr->lineNum < 0) {
// Should select a range of lines.
range.location = sr->startRange + 1;
range.length = sr->endRange - sr->startRange + 1;
if (length == sizeof(MMXcodeSelectionRange)) {
MMXcodeSelectionRange *sr = (MMXcodeSelectionRange*)[data bytes];
ASLogDebug(@"Xcode selection range (%d,%d,%d,%d,%d,%d)",
sr->unused1, sr->lineNum, sr->startRange, sr->endRange,
sr->unused2, sr->theDate);
if (sr->lineNum < 0) {
// Should select a range of lines.
range.location = sr->startRange + 1;
range.length = sr->endRange - sr->startRange + 1;
} else {
// Should only move cursor to a line.
range.location = sr->lineNum + 1;
range.length = 0;
}
[dict setObject:NSStringFromRange(range) forKey:@"selectionRange"];
} else {
// Should only move cursor to a line.
range.location = sr->lineNum + 1;
range.length = 0;
ASLogErr(@"Xcode selection range size mismatch! got=%d expected=%d",
length, sizeof(MMXcodeSelectionRange));
}
[dict setObject:NSStringFromRange(range) forKey:@"selectionRange"];
}
// 3. Extract Spotlight search text (if any)
@@ -2266,7 +2279,7 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
int i = 0, count = [vimControllers count];
for (i = 0; i < count; ++i) {
MMVimController *vc = [vimControllers objectAtIndex:i];
if (ukey == [vc identifier]) {
if (ukey == [vc vimControllerId]) {
[vc processInputQueue:[queues objectForKey:key]]; // !exceptions
break;
}
@@ -2277,7 +2290,7 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
count = [cachedVimControllers count];
for (i = 0; i < count; ++i) {
MMVimController *vc = [cachedVimControllers objectAtIndex:i];
if (ukey == [vc identifier]) {
if (ukey == [vc vimControllerId]) {
[vc processInputQueue:[queues objectForKey:key]]; // !exceptions
break;
}
@@ -2305,7 +2318,8 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
- (void)addVimController:(MMVimController *)vc
{
ASLogDebug(@"Add Vim controller pid=%d id=%d", [vc pid], [vc identifier]);
ASLogDebug(@"Add Vim controller pid=%d id=%d",
[vc pid], [vc vimControllerId]);
int pid = [vc pid];
NSNumber *pidKey = [NSNumber numberWithInt:pid];
+2 -2
View File
@@ -48,7 +48,7 @@ typedef struct {
}
- (NSString *)string;
- (NSDictionary *)attributesAtIndex:(unsigned)index
- (NSDictionary *)attributesAtIndex:(NSUInteger)index
effectiveRange:(NSRangePointer)aRange;
- (id)attribute:(NSString *)attrib atIndex:(unsigned)index
effectiveRange:(NSRangePointer)range;
@@ -89,7 +89,7 @@ typedef struct {
- (NSSize)cellSize;
- (NSRect)rectForRowsInRange:(NSRange)range;
- (NSRect)rectForColumnsInRange:(NSRange)range;
- (unsigned)characterIndexForRow:(int)row column:(int)col;
- (NSUInteger)characterIndexForRow:(int)row column:(int)col;
- (BOOL)resizeToFitSize:(NSSize)size;
- (NSSize)fitToSize:(NSSize)size;
- (NSSize)fitToSize:(NSSize)size rows:(int *)rows columns:(int *)columns;
+4 -4
View File
@@ -112,7 +112,7 @@ static NSString *MMWideCharacterAttributeName = @"MMWideChar";
return [attribString string];
}
- (NSDictionary *)attributesAtIndex:(unsigned)index
- (NSDictionary *)attributesAtIndex:(NSUInteger)index
effectiveRange:(NSRangePointer)range
{
if (index >= [attribString length]) {
@@ -777,7 +777,7 @@ static NSString *MMWideCharacterAttributeName = @"MMWideChar";
- (NSRect)rectForRowsInRange:(NSRange)range
{
NSRect rect = { 0, 0, 0, 0 };
NSRect rect = { {0, 0}, {0, 0} };
unsigned start = range.location > maxRows ? maxRows : range.location;
unsigned length = range.length;
@@ -792,7 +792,7 @@ static NSString *MMWideCharacterAttributeName = @"MMWideChar";
- (NSRect)rectForColumnsInRange:(NSRange)range
{
NSRect rect = { 0, 0, 0, 0 };
NSRect rect = { {0, 0}, {0, 0} };
unsigned start = range.location > maxColumns ? maxColumns : range.location;
unsigned length = range.length;
@@ -805,7 +805,7 @@ static NSString *MMWideCharacterAttributeName = @"MMWideChar";
return rect;
}
- (unsigned)characterIndexForRow:(int)row column:(int)col
- (NSUInteger)characterIndexForRow:(int)row column:(int)col
{
int cells = 1;
NSRange range = [self charRangeForRow:row column:&col cells:&cells];
+6 -6
View File
@@ -26,7 +26,7 @@
- (void)willSetLineFragmentRect:(NSRectPointer)lineRect
forGlyphRange:(NSRange)glyphRange
usedRect:(NSRectPointer)usedRect
baselineOffset:(float *)baselineOffset
baselineOffset:(CGFloat *)baselineOffset
{
MMTextStorage *ts = (MMTextStorage*)[[self layoutManager] textStorage];
float h = [ts cellSize].height;
@@ -103,9 +103,9 @@
// height and that EOL glyphs are hidden.
//
- (void)layoutGlyphsInLayoutManager:(NSLayoutManager *)lm
startingAtGlyphIndex:(unsigned)startGlyphIdx
maxNumberOfLineFragments:(unsigned)maxNumLines
nextGlyphIndex:(unsigned *)nextGlyph
startingAtGlyphIndex:(NSUInteger)startGlyphIdx
maxNumberOfLineFragments:(NSUInteger)maxNumLines
nextGlyphIndex:(NSUInteger *)nextGlyph
{
// TODO: Check that it really is an MMTextStorage?
MMTextStorage *ts = (MMTextStorage*)[lm textStorage];
@@ -160,8 +160,8 @@
NSRange lineRange = { lineIdx, 0 };
NSRange glyphRange = { startGlyphIdx, 0 };
NSRect lineRect = { 0, line*cellSize.height,
[ts actualColumns]*cellSize.width, cellSize.height };
NSRect lineRect = { {0, line*cellSize.height},
{[ts actualColumns]*cellSize.width, cellSize.height} };
int endLine = line + maxNumLines;
if (endLine > actualRows)
endLine = actualRows;
+1 -1
View File
@@ -44,7 +44,7 @@
}
- (id)initWithBackend:(id)backend pid:(int)processIdentifier;
- (unsigned)identifier;
- (unsigned)vimControllerId;
- (id)backendProxy;
- (int)pid;
- (void)setServerName:(NSString *)name;
+3 -3
View File
@@ -184,7 +184,7 @@ static BOOL isUnsafeMessage(int msgid);
[super dealloc];
}
- (unsigned)identifier
- (unsigned)vimControllerId
{
return identifier;
}
@@ -986,7 +986,7 @@ static BOOL isUnsafeMessage(int msgid);
if (!toolbar) {
// NOTE! Each toolbar must have a unique identifier, else each
// window will have the same toolbar.
NSString *ident = [NSString stringWithFormat:@"%d", (int)self];
NSString *ident = [NSString stringWithFormat:@"%d", identifier];
toolbar = [[NSToolbar alloc] initWithIdentifier:ident];
[toolbar setShowsBaselineSeparator:NO];
@@ -1106,7 +1106,7 @@ static BOOL isUnsafeMessage(int msgid);
// Only remove toolbar items, never actually remove the toolbar
// itself or strange things may happen.
if ([desc count] == 2) {
int idx = [toolbar indexOfItemWithItemIdentifier:title];
NSUInteger idx = [toolbar indexOfItemWithItemIdentifier:title];
if (idx != NSNotFound)
[toolbar removeItemAtIndex:idx];
}
+15 -13
View File
@@ -43,7 +43,7 @@ enum {
NSRange range;
}
- (id)initWithIdentifier:(int32_t)ident type:(int)type;
- (int32_t)identifier;
- (int32_t)scrollerId;
- (int)type;
- (NSRange)range;
- (void)setRange:(NSRange)newRange;
@@ -55,7 +55,7 @@ enum {
- (BOOL)leftScrollbarVisible;
- (BOOL)rightScrollbarVisible;
- (void)placeScrollbars;
- (int)representedIndexOfTabViewItem:(NSTabViewItem *)tvi;
- (NSUInteger)representedIndexOfTabViewItem:(NSTabViewItem *)tvi;
- (MMScroller *)scrollbarForIdentifier:(int32_t)ident index:(unsigned *)idx;
- (NSSize)vimViewSizeForTextViewSize:(NSSize)textViewSize;
- (NSRect)textViewRectForVimViewSize:(NSSize)contentSize;
@@ -430,7 +430,7 @@ enum {
- (void)scroll:(id)sender
{
NSMutableData *data = [NSMutableData data];
int32_t ident = [(MMScroller*)sender identifier];
int32_t ident = [(MMScroller*)sender scrollerId];
int hitPart = [sender hitPart];
float value = [sender floatValue];
@@ -478,9 +478,10 @@ enum {
// flag is set when Vim initiated the selection.
if (!vimTaskSelectedTab) {
// Propagate the selection message to Vim.
int idx = [self representedIndexOfTabViewItem:tabViewItem];
NSUInteger idx = [self representedIndexOfTabViewItem:tabViewItem];
if (NSNotFound != idx) {
NSData *data = [NSData dataWithBytes:&idx length:sizeof(int)];
int i = (int)idx; // HACK! Never more than MAXINT tabs?!
NSData *data = [NSData dataWithBytes:&i length:sizeof(int)];
[vimController sendMessage:SelectTabMsgID data:data];
}
}
@@ -496,8 +497,9 @@ enum {
// HACK! This method is only called when the user clicks the close button
// on the tab. Instead of letting the tab bar close the tab, we return NO
// and pass a message on to Vim to let it handle the closing.
int idx = [self representedIndexOfTabViewItem:tabViewItem];
NSData *data = [NSData dataWithBytes:&idx length:sizeof(int)];
NSUInteger idx = [self representedIndexOfTabViewItem:tabViewItem];
int i = (int)idx; // HACK! Never more than MAXINT tabs?!
NSData *data = [NSData dataWithBytes:&i length:sizeof(int)];
[vimController sendMessage:CloseTabMsgID data:data];
return NO;
@@ -514,7 +516,7 @@ enum {
- (NSDragOperation)tabBarControl:(PSMTabBarControl *)theTabBarControl
draggingEntered:(id <NSDraggingInfo>)sender
forTabAtIndex:(unsigned)tabIndex
forTabAtIndex:(NSUInteger)tabIndex
{
NSPasteboard *pb = [sender draggingPasteboard];
return [[pb types] containsObject:NSFilenamesPboardType]
@@ -524,7 +526,7 @@ enum {
- (BOOL)tabBarControl:(PSMTabBarControl *)theTabBarControl
performDragOperation:(id <NSDraggingInfo>)sender
forTabAtIndex:(unsigned)tabIndex
forTabAtIndex:(NSUInteger)tabIndex
{
NSPasteboard *pb = [sender draggingPasteboard];
if ([[pb types] containsObject:NSFilenamesPboardType]) {
@@ -748,7 +750,7 @@ enum {
}
}
- (int)representedIndexOfTabViewItem:(NSTabViewItem *)tvi
- (NSUInteger)representedIndexOfTabViewItem:(NSTabViewItem *)tvi
{
NSArray *tabViewItems = [[self tabBarControl] representedTabViewItems];
return [tabViewItems indexOfObject:tvi];
@@ -759,7 +761,7 @@ enum {
unsigned i, count = [scrollbars count];
for (i = 0; i < count; ++i) {
MMScroller *scroller = [scrollbars objectAtIndex:i];
if ([scroller identifier] == ident) {
if ([scroller scrollerId] == ident) {
if (idx) *idx = i;
return scroller;
}
@@ -787,7 +789,7 @@ enum {
- (NSRect)textViewRectForVimViewSize:(NSSize)contentSize
{
NSRect rect = { 0, 0, contentSize.width, contentSize.height };
NSRect rect = { {0, 0}, {contentSize.width, contentSize.height} };
if (![[self tabBarControl] isHidden])
rect.size.height -= [[self tabBarControl] frame].size.height;
@@ -892,7 +894,7 @@ enum {
return self;
}
- (int32_t)identifier
- (int32_t)scrollerId
{
return identifier;
}
+1 -1
View File
@@ -18,7 +18,7 @@
}
- (id)initWithContentRect:(NSRect)rect
styleMask:(unsigned int)style
styleMask:(NSUInteger)style
backing:(NSBackingStoreType)bufferingType
defer:(BOOL)flag;
+2 -2
View File
@@ -35,7 +35,7 @@
@implementation MMWindow
- (id)initWithContentRect:(NSRect)rect
styleMask:(unsigned int)style
styleMask:(NSUInteger)style
backing:(NSBackingStoreType)bufferingType
defer:(BOOL)flag
{
@@ -47,7 +47,7 @@
[self setReleasedWhenClosed:NO];
NSRect tabSepRect = { 0, rect.size.height - 1, rect.size.width, 1 };
NSRect tabSepRect = { {0, rect.size.height - 1}, {rect.size.width, 1} };
tablineSeparator = [[NSBox alloc] initWithFrame:tabSepRect];
[tablineSeparator setBoxType:NSBoxSeparator];
+4 -3
View File
@@ -116,8 +116,8 @@ enum {
@interface NSToolbar (MMExtras)
- (int)indexOfItemWithItemIdentifier:(NSString *)identifier;
- (NSToolbarItem *)itemAtIndex:(int)idx;
- (NSUInteger)indexOfItemWithItemIdentifier:(NSString *)identifier;
- (NSToolbarItem *)itemAtIndex:(NSUInteger)idx;
- (NSToolbarItem *)itemWithItemIdentifier:(NSString *)identifier;
@end
@@ -128,7 +128,8 @@ enum {
@interface NSNumber (MMExtras)
- (int)tag;
// HACK to allow font size to be changed via menu (bound to Cmd+/Cmd-)
- (NSInteger)tag;
@end
+7 -6
View File
@@ -203,10 +203,10 @@ NSString *MMUseInlineImKey = @"MMUseInlineIm";
@implementation NSToolbar (MMExtras)
- (int)indexOfItemWithItemIdentifier:(NSString *)identifier
- (NSUInteger)indexOfItemWithItemIdentifier:(NSString *)identifier
{
NSArray *items = [self items];
int i, count = [items count];
NSUInteger i, count = [items count];
for (i = 0; i < count; ++i) {
id item = [items objectAtIndex:i];
if ([[item itemIdentifier] isEqual:identifier])
@@ -216,7 +216,7 @@ NSString *MMUseInlineImKey = @"MMUseInlineIm";
return NSNotFound;
}
- (NSToolbarItem *)itemAtIndex:(int)idx
- (NSToolbarItem *)itemAtIndex:(NSUInteger)idx
{
NSArray *items = [self items];
if (idx < 0 || idx >= [items count])
@@ -227,7 +227,7 @@ NSString *MMUseInlineImKey = @"MMUseInlineIm";
- (NSToolbarItem *)itemWithItemIdentifier:(NSString *)identifier
{
int idx = [self indexOfItemWithItemIdentifier:identifier];
NSUInteger idx = [self indexOfItemWithItemIdentifier:identifier];
return idx != NSNotFound ? [self itemAtIndex:idx] : nil;
}
@@ -243,7 +243,7 @@ NSString *MMUseInlineImKey = @"MMUseInlineIm";
NSArray *existingItems = [self tabViewItems];
NSEnumerator *e = [existingItems objectEnumerator];
NSTabViewItem *item;
while (item = [e nextObject]){
while ((item = [e nextObject])) {
[self removeTabViewItem:item];
}
}
@@ -255,7 +255,8 @@ NSString *MMUseInlineImKey = @"MMUseInlineIm";
@implementation NSNumber (MMExtras)
- (int)tag
// HACK to allow font size to be changed via menu (bound to Cmd+/Cmd-)
- (NSInteger)tag
{
return [self intValue];
}