Skip to content

Commit

Permalink
• began to clean code for minimizing warnings (Xcode 4.4), to fix err…
Browse files Browse the repository at this point in the history
…oneous code snippets (>= SDK 10.7), and to be compatible with >= SDK 10.7 - but min SDK is still 10.5

git-svn-id: https://svn.r-project.org/R-packages/trunk/Mac-GUI@6227 694ef91d-65df-0310-b7bb-92e67a308ead
  • Loading branch information
Hans-Jörg Bibiko committed Aug 2, 2012
1 parent a5ac43f commit c527ef0
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 41 deletions.
16 changes: 12 additions & 4 deletions RController.m
Original file line number Diff line number Diff line change
Expand Up @@ -397,10 +397,18 @@ - (void) awakeFromNib {
char *cRLIBS = getenv("R_LIBS");
NSString *addPath = [[NSString stringWithFormat:@"~/Library/R/%@/library", Rapp_R_version_short] stringByExpandingTildeInPath];
if (![fm fileExistsAtPath:addPath]) { // make sure the directory exists
[fm createDirectoryAtPath:[@"~/Library/R" stringByExpandingTildeInPath] attributes:nil];
[fm createDirectoryAtPath:[[NSString stringWithFormat:@"~/Library/R/%@", Rapp_R_version_short] stringByExpandingTildeInPath] attributes:nil];
[fm createDirectoryAtPath:addPath attributes:nil];
}

// [fm createDirectoryAtPath:[@"~/Library/R" stringByExpandingTildeInPath] attributes:nil];
// [fm createDirectoryAtPath:[[NSString stringWithFormat:@"~/Library/R/%@", Rapp_R_version_short] stringByExpandingTildeInPath] attributes:nil];
// [fm createDirectoryAtPath:addPath attributes:nil];

NSError *err = nil;
[fm createDirectoryAtPath:addPath withIntermediateDirectories:YES attributes:nil error:&err];
if(err != nil) {
NSBeep();
NSLog(@"The directory '%@' couldn't be created!", addPath);
}
}
if (cRLIBS && *cRLIBS)
addPath = [NSString stringWithFormat: @"%s:%@", cRLIBS, addPath];
setenv("R_LIBS", [addPath UTF8String], 1);
Expand Down
2 changes: 1 addition & 1 deletion RDocumentController.m
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ - (void)windowWillCloseNotifications:(NSNotification*) aNotification

// if no document is associated wit this window, check whether this is a Quartz Cocoa window
if (!d && [[(NSObject*)[w delegate] className] isEqualToString:@"QuartzCocoaView"]) {
d = [[QuartzCocoaDocument alloc] initWithWindow:w];
d = (RDocument*)[[QuartzCocoaDocument alloc] initWithWindow:w];
[d makeWindowControllers];
[[NSDocumentController sharedDocumentController] addDocument:d];
[d release];
Expand Down
22 changes: 11 additions & 11 deletions REditor.m
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ - (void)setDataTable:(BOOL)removeAll
if(!objectData) return;

for (i = 0; i < numberOfColumns; i++) {
NSTableColumn *col = [[NSTableColumn alloc] initWithIdentifier:[NSNumber numberWithInt:i]];
NSTableColumn *col = [[NSTableColumn alloc] initWithIdentifier:[NSString stringWithFormat:@"%ld", i]];
NSString *colName = NSArrayObjectAtIndex(objectColumnNames, i);
NSInteger colType = [NSArrayObjectAtIndex(objectColumnTypes, i) intValue];
if(colName) {
Expand All @@ -377,20 +377,20 @@ - (void)setDataTable:(BOOL)removeAll

// column auto-sizing
for(i = 0; i < numberOfColumns; i++) {
[[editorSource tableColumnWithIdentifier:[NSNumber numberWithInt:i]] setWidth:
[[editorSource tableColumnWithIdentifier:[NSString stringWithFormat:@"%ld", i]] setWidth:
[editorSource widthForColumn:i andHeaderName:NSArrayObjectAtIndex(objectColumnNames, i)]];
if(i+1 < numberOfColumns)
[[[[editorSource tableColumnWithIdentifier:[NSNumber numberWithInt:i]] headerCell] controlView] setNextKeyView:[[[editorSource tableColumnWithIdentifier:[NSNumber numberWithInt:i+1]] headerCell] controlView]];
[[[[editorSource tableColumnWithIdentifier:[NSString stringWithFormat:@"%ld", i]] headerCell] controlView] setNextKeyView:[[[editorSource tableColumnWithIdentifier:[NSString stringWithFormat:@"%ld", i+1]] headerCell] controlView]];
else if(i-1 == numberOfColumns)
[[[[editorSource tableColumnWithIdentifier:[NSNumber numberWithInt:i]] headerCell] controlView] setNextKeyView:editorSource];
[[[[editorSource tableColumnWithIdentifier:[NSString stringWithFormat:@"%ld", i]] headerCell] controlView] setNextKeyView:editorSource];
}

[editorSource sizeLastColumnToFit];

//tries to fix problem with last row
if ( [[editorSource tableColumnWithIdentifier:[NSNumber numberWithInteger:numberOfColumns-1]] width] < 30 )
[[editorSource tableColumnWithIdentifier:[NSNumber numberWithInteger:numberOfColumns-1]]
setWidth:[[editorSource tableColumnWithIdentifier:[NSNumber numberWithInteger:0]] width]];
if ( [[editorSource tableColumnWithIdentifier:[NSString stringWithFormat:@"%ld", numberOfColumns-1]] width] < 30 )
[[editorSource tableColumnWithIdentifier:[NSString stringWithFormat:@"%ld", numberOfColumns-1]]
setWidth:[[editorSource tableColumnWithIdentifier:[NSString stringWithFormat:@"%ld", 0L]] width]];

[editorSource reloadData];

Expand Down Expand Up @@ -577,7 +577,7 @@ - (BOOL)textView:(NSTextView *)aTextView doCommandBySelector:(SEL)commandSelecto

// Trap ESC while editing column names to cancel editing
if (@selector(cancelOperation:) == commandSelector) {
NSTableColumn *col = [editorSource tableColumnWithIdentifier:[NSNumber numberWithInteger:editedColumnNameIndex]];
NSTableColumn *col = [editorSource tableColumnWithIdentifier:[NSString stringWithFormat:@"%ld", editedColumnNameIndex]];
[[col headerCell] setTitle:[[col headerCell] titleBeforeEditing]];
editedColumnNameIndex = -1;
[[[[REditor getDEController] window] fieldEditor:NO forObject:[col headerCell]] setFieldEditor:YES];
Expand All @@ -595,7 +595,7 @@ - (BOOL)textView:(NSTextView *)aTextView doCommandBySelector:(SEL)commandSelecto
|| @selector(insertBacktab:) == commandSelector
) {

NSTableColumn *col = [editorSource tableColumnWithIdentifier:[NSNumber numberWithInteger:editedColumnNameIndex]];
NSTableColumn *col = [editorSource tableColumnWithIdentifier:[NSString stringWithFormat:@"%ld", editedColumnNameIndex]];
if(![[[REditor getDEController] window] fieldEditor:NO forObject:[col headerCell]]) return NO;
NSString *newColumnName = [[[[[REditor getDEController] window] fieldEditor:NO forObject:[col headerCell]] string] copy];

Expand Down Expand Up @@ -966,7 +966,7 @@ - (IBAction)remCols:(id)sender
return;

while (current_index != NSNotFound) {
[editorSource removeTableColumn:[editorSource tableColumnWithIdentifier:[NSNumber numberWithInteger:current_index]]];
[editorSource removeTableColumn:[editorSource tableColumnWithIdentifier:[NSString stringWithFormat:@"%ld", current_index]]];
current_index = [cols indexGreaterThanIndex:current_index];
}

Expand All @@ -988,7 +988,7 @@ - (IBAction)remCols:(id)sender
} else {

for(i = 0; i < numberOfColumns; i++)
[[[editorSource tableColumns] objectAtIndex:i] setIdentifier:[NSNumber numberWithInteger:i]];
[[[editorSource tableColumns] objectAtIndex:i] setIdentifier:[NSString stringWithFormat:@"%ld", i]];

[editorSource reloadData];

Expand Down
37 changes: 18 additions & 19 deletions RTextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ - (void)keyDown:(NSEvent *)theEvent
SLog(@"RTextView: suppressed auto-pairing");
[super keyDown:theEvent];
if(hilite && [[self delegate] respondsToSelector:@selector(highlightBracesWithShift:andWarn:)])
[[self delegate] highlightBracesWithShift:-1 andWarn:YES];
[(id)[self delegate] highlightBracesWithShift:-1 andWarn:YES];
return;
}

Expand Down Expand Up @@ -489,7 +489,7 @@ - (void)keyDown:(NSEvent *)theEvent
[super keyDown:theEvent];

if(hilite && [[self delegate] respondsToSelector:@selector(highlightBracesWithShift:andWarn:)])
[[self delegate] highlightBracesWithShift:-1 andWarn:YES];
[(id)[self delegate] highlightBracesWithShift:-1 andWarn:YES];
}

- (void)deleteBackward:(id)sender
Expand Down Expand Up @@ -565,7 +565,7 @@ - (int)parserContextForPosition:(int)position
if (thisLine.location == position)
return context;

SLog(@"RTextView: parserContextForPosition: %d, line span=%d:%d", position, thisLine.location, thisLine.length);
SLog(@"RTextView: parserContextForPosition: %d, line span=%ld:%ld", position, thisLine.location, thisLine.length);

int i = thisLine.location;
BOOL skip = NO;
Expand Down Expand Up @@ -651,7 +651,7 @@ - (NSRange)rangeForUserCompletion
} else { // normal completion
userRange.location++; // skip past first bad one
userRange.length = selection.location - userRange.location;
SLog(@" - returned range: %d:%d", userRange.location, userRange.length);
SLog(@" - returned range: %ld:%ld", userRange.location, userRange.length);

// FIXME: do we really need to change it? Cocoa should be doing it .. (and does in Lion)
if (os_version < 11.0)
Expand Down Expand Up @@ -758,7 +758,7 @@ - (void) showHelpForCurrentFunction
[keyWin toggleToolbarShown:nil];

if([[self delegate] respondsToSelector:@selector(searchToolbarView)])
aSearchField = [[self delegate] searchToolbarView];
aSearchField = [(id)[self delegate] searchToolbarView];

if(aSearchField == nil || ![aSearchField isKindOfClass:[NSSearchField class]]) return;

Expand Down Expand Up @@ -1055,8 +1055,8 @@ - (NSString*)functionNameForCurrentScope
// we have to check class since it runs in its own thread (but not sure - if one uses
// [self isRConsole] it doesn't work)
if([[self delegate] isKindOfClass:[RController class]] & ([[RController sharedController] lastCommittedLength] <= selectedRange.location)) {
parseRange = NSMakeRange([[self delegate] lastCommittedLength],
[parseString length]-[[self delegate] lastCommittedLength]);
parseRange = NSMakeRange([(id)[self delegate] lastCommittedLength],
[parseString length]-[(id)[self delegate] lastCommittedLength]);
}

// sanety check; if it fails bail
Expand Down Expand Up @@ -1318,8 +1318,8 @@ - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
draggingLocation = [self convertPoint:draggingLocation fromView:nil];
NSUInteger characterIndex = [self characterIndexOfPoint:draggingLocation];
if([[self delegate] isKindOfClass:[RController class]])
if(characterIndex < [[self delegate] lastCommittedLength])
characterIndex = [[self delegate] lastCommittedLength];
if(characterIndex < [(id)[self delegate] lastCommittedLength])
characterIndex = [(id)[self delegate] lastCommittedLength];
[self setSelectedRange:NSMakeRange(characterIndex,0)];

NSMutableString *insertionString = [NSMutableString string];
Expand Down Expand Up @@ -1354,9 +1354,9 @@ - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
anError = nil;
NSString *cmd = [NSString stringWithContentsOfFile:[NSString stringWithFormat:@"%@r/%@", userDragActionDir, kUserCommandFileName] encoding:NSUTF8StringEncoding error:&anError];
if(anError == nil) {
[[self delegate] setStatusLineText:NLS(@"press ⌘. to cancel")];
[(id)[self delegate] setStatusLineText:NLS(@"press ⌘. to cancel")];
NSString *res = [cmd evaluateAsBashCommandWithEnvironment:env atPath:[NSString stringWithFormat:@"%@r", userDragActionDir] error:&anError];
[[self delegate] setStatusLineText:@""];
[(id)[self delegate] setStatusLineText:@""];
if(anError != nil) {
NSAlert *alert = [NSAlert alertWithMessageText:NLS(@"Snippet Error")
defaultButton:NLS(@"OK")
Expand Down Expand Up @@ -1388,7 +1388,7 @@ - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
}
} else {
if([sender draggingSourceOperationMask] == 4) {
[insertionString appendString:[NSString stringWithFormat:@"source('%@'${%d:, chdir = ${%d:%@}})%@",
[insertionString appendString:[NSString stringWithFormat:@"source('%@'${%ld:, chdir = ${%ld:%@}})%@",
[[filepath stringByReplacingOccurrencesOfRegex:
[NSString stringWithFormat:@"^%@", curDir] withString:@""] stringByAbbreviatingWithTildeInPath], snip_cnt, snip_cnt+1,
([filepath rangeOfString:@"/"].length) ? @"TRUE" : @"FALSE" ,
Expand All @@ -1400,10 +1400,9 @@ - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
[filepath stringByAbbreviatingWithTildeInPath],
(i < ([files count]-1)) ? suffix : @""]];
else {
[insertionString appendString:[NSString stringWithFormat:@"source('%@'${%d:, chdir = ${%d:%@}})%@",
[insertionString appendString:[NSString stringWithFormat:@"source('%@'${%ld:, chdir = ${%ld:%@}})%@",
[filepath stringByAbbreviatingWithTildeInPath], snip_cnt, snip_cnt+1,
([filepath rangeOfString:@"/"].length) ? @"TRUE" : @"FALSE" ,
(i < ([files count]-1)) ? suffix : @""]];
([filepath rangeOfString:@"/"].length) ? @"TRUE" : @"FALSE" , (i < ([files count]-1)) ? suffix : @""]];
snip_cnt++;
}
}
Expand All @@ -1413,9 +1412,9 @@ - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
else if([extension isEqualToString:@"rdata"]) {
if((userDragActionDir && [fm fileExistsAtPath:[NSString stringWithFormat:@"%@/rdata/%@", userDragActionDir, kUserCommandFileName]])) {
anError = nil;
[[self delegate] setStatusLineText:NLS(@"press ⌘. to cancel")];
[(id)[self delegate] setStatusLineText:NLS(@"press ⌘. to cancel")];
NSString *cmd = [NSString stringWithContentsOfFile:[NSString stringWithFormat:@"%@rdata/%@", userDragActionDir, kUserCommandFileName] encoding:NSUTF8StringEncoding error:&anError];
[[self delegate] setStatusLineText:@""];
[(id)[self delegate] setStatusLineText:@""];
if(anError == nil) {
NSString *res = [cmd evaluateAsBashCommandWithEnvironment:env atPath:[NSString stringWithFormat:@"%@rdata", userDragActionDir] error:&anError];
if(anError != nil) {
Expand Down Expand Up @@ -1469,9 +1468,9 @@ - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
anError = nil;
NSString *cmd = [NSString stringWithContentsOfFile:[NSString stringWithFormat:@"%@%@/%@", userDragActionDir, extension, kUserCommandFileName] encoding:NSUTF8StringEncoding error:&anError];
if(anError == nil) {
[[self delegate] setStatusLineText:NLS(@"press ⌘. to cancel")];
[(id)[self delegate] setStatusLineText:NLS(@"press ⌘. to cancel")];
NSString *res = [cmd evaluateAsBashCommandWithEnvironment:env atPath:[NSString stringWithFormat:@"%@%@", userDragActionDir, extension] error:&anError];
[[self delegate] setStatusLineText:@""];
[(id)[self delegate] setStatusLineText:@""];
if(anError != nil) {
NSAlert *alert = [NSAlert alertWithMessageText:NLS(@"Snippet Error")
defaultButton:NLS(@"OK")
Expand Down
4 changes: 2 additions & 2 deletions RWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ - (void)swipeWithEvent:(NSEvent *)event
onEdge = [NSNumber numberWithInt:NSMinXEdge];

if(onEdge) {
[[self delegate] toggleHistory:onEdge];
[(id)[self delegate] toggleHistory:onEdge];
return;
}

Expand All @@ -79,7 +79,7 @@ - (void)swipeWithEvent:(NSEvent *)event
// (WebView*)webView [which returns the web view in question]
if([[self delegate] respondsToSelector:@selector(supportsWebViewSwipingInHistory)]) {

WebView* wv = [[self delegate] webView];
WebView* wv = [(id)[self delegate] webView];

CGFloat x = [event deltaX];
CGFloat y = [event deltaY];
Expand Down
8 changes: 4 additions & 4 deletions Tools/RChooseMenuItemDialog.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ - (id)init;

- (IBAction)menuItemHandler:(id)sender
{
[[self delegate] setSelectedItemIndex:[sender tag]];
[[self delegate] setWaitForChoice:NO];
[(id)[self delegate] setSelectedItemIndex:[sender tag]];
[(id)[self delegate] setWaitForChoice:NO];
}

- (NSMenu *)menuForEvent:(NSEvent *)event
{
return [[self delegate] contextMenu];
return [(id)[self delegate] contextMenu];
}

@end
Expand Down Expand Up @@ -108,7 +108,7 @@ - (void)initDialog
[self setAlphaValue:0.0f];

dummyTextView = [[RChooseMenuItemDialogTextView alloc] init];
[dummyTextView setDelegate:self];
[dummyTextView setDelegate:(id)self];

[self setContentView:dummyTextView];

Expand Down

0 comments on commit c527ef0

Please sign in to comment.