aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPhilipp Stephani2017-05-20 16:36:24 +0200
committerPhilipp Stephani2017-05-21 21:49:09 +0200
commit84b28ec759ed3d294c2f49353942ae76e0c75532 (patch)
tree2f562d459878de7c76b03bcb62bf87ca555f0e79 /src
parent08212929ba7052883bd506be320dfaaae5b68970 (diff)
downloademacs-84b28ec759ed3d294c2f49353942ae76e0c75532.tar.gz
emacs-84b28ec759ed3d294c2f49353942ae76e0c75532.zip
Nextstep: Use instancetype explicit return type
This removes compiler warnings on macOS and improves type safety. * nsterm.m (initFrameFromEmacs:): (menuDown:): (toolbarClicked:): (toggleToolbar:): (setMiniwindowImage:): (initFrame:window:): (condemn, reprieve, setPosition:portion:whole:): (repeatScroll:): * nsmenu.m (initWithTitle:): (initWithTitle:frame:): (initForView:withIdentifier:): (init, initWithContentRect:styleMask:backing:defer:): (initFromContents:isQuestion:): * nsimage.m (allocInitFromFile:): (initFromXBM:width:height:fg:bg:): (setXBMColor:): (initForXPMWithDepth:width:height:): Use instancetype as return type instead of implicit id.
Diffstat (limited to 'src')
-rw-r--r--src/nsimage.m8
-rw-r--r--src/nsmenu.m12
-rw-r--r--src/nsterm.h38
-rw-r--r--src/nsterm.m20
4 files changed, 39 insertions, 39 deletions
diff --git a/src/nsimage.m b/src/nsimage.m
index e87da77ccf1..1c82fa780a0 100644
--- a/src/nsimage.m
+++ b/src/nsimage.m
@@ -152,7 +152,7 @@ ns_set_alpha (void *img, int x, int y, unsigned char a)
152 152
153@implementation EmacsImage 153@implementation EmacsImage
154 154
155+ allocInitFromFile: (Lisp_Object)file 155+ (instancetype)allocInitFromFile: (Lisp_Object)file
156{ 156{
157 NSImageRep *imgRep; 157 NSImageRep *imgRep;
158 Lisp_Object found; 158 Lisp_Object found;
@@ -197,7 +197,7 @@ ns_set_alpha (void *img, int x, int y, unsigned char a)
197 197
198/* Create image from monochrome bitmap. If both FG and BG are 0 198/* Create image from monochrome bitmap. If both FG and BG are 0
199 (black), set the background to white and make it transparent. */ 199 (black), set the background to white and make it transparent. */
200- initFromXBM: (unsigned char *)bits width: (int)w height: (int)h 200- (instancetype)initFromXBM: (unsigned char *)bits width: (int)w height: (int)h
201 fg: (unsigned long)fg bg: (unsigned long)bg 201 fg: (unsigned long)fg bg: (unsigned long)bg
202{ 202{
203 unsigned char *planes[5]; 203 unsigned char *planes[5];
@@ -269,7 +269,7 @@ ns_set_alpha (void *img, int x, int y, unsigned char a)
269} 269}
270 270
271/* Set color for a bitmap image. */ 271/* Set color for a bitmap image. */
272- setXBMColor: (NSColor *)color 272- (instancetype)setXBMColor: (NSColor *)color
273{ 273{
274 NSSize s = [self size]; 274 NSSize s = [self size];
275 unsigned char *planes[5]; 275 unsigned char *planes[5];
@@ -309,7 +309,7 @@ ns_set_alpha (void *img, int x, int y, unsigned char a)
309} 309}
310 310
311 311
312- initForXPMWithDepth: (int)depth width: (int)width height: (int)height 312- (instancetype)initForXPMWithDepth: (int)depth width: (int)width height: (int)height
313{ 313{
314 NSSize s = {width, height}; 314 NSSize s = {width, height};
315 int i; 315 int i;
diff --git a/src/nsmenu.m b/src/nsmenu.m
index 8dc6ea1d344..5e863bb17d7 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -493,7 +493,7 @@ x_activate_menubar (struct frame *f)
493@implementation EmacsMenu 493@implementation EmacsMenu
494 494
495/* override designated initializer */ 495/* override designated initializer */
496- initWithTitle: (NSString *)title 496- (instancetype)initWithTitle: (NSString *)title
497{ 497{
498 frame = 0; 498 frame = 0;
499 if ((self = [super initWithTitle: title])) 499 if ((self = [super initWithTitle: title]))
@@ -503,7 +503,7 @@ x_activate_menubar (struct frame *f)
503 503
504 504
505/* used for top-level */ 505/* used for top-level */
506- initWithTitle: (NSString *)title frame: (struct frame *)f 506- (instancetype)initWithTitle: (NSString *)title frame: (struct frame *)f
507{ 507{
508 [self initWithTitle: title]; 508 [self initWithTitle: title];
509 frame = f; 509 frame = f;
@@ -1146,7 +1146,7 @@ update_frame_tool_bar (struct frame *f)
1146 1146
1147@implementation EmacsToolbar 1147@implementation EmacsToolbar
1148 1148
1149- initForView: (EmacsView *)view withIdentifier: (NSString *)identifier 1149- (instancetype)initForView: (EmacsView *)view withIdentifier: (NSString *)identifier
1150{ 1150{
1151 NSTRACE ("[EmacsToolbar initForView: withIdentifier:]"); 1151 NSTRACE ("[EmacsToolbar initForView: withIdentifier:]");
1152 1152
@@ -1302,7 +1302,7 @@ update_frame_tool_bar (struct frame *f)
1302 display. */ 1302 display. */
1303@implementation EmacsTooltip 1303@implementation EmacsTooltip
1304 1304
1305- init 1305- (instancetype)init
1306{ 1306{
1307 NSColor *col = [NSColor colorWithCalibratedRed: 1.0 green: 1.0 1307 NSColor *col = [NSColor colorWithCalibratedRed: 1.0 green: 1.0
1308 blue: 0.792 alpha: 0.95]; 1308 blue: 0.792 alpha: 0.95];
@@ -1493,7 +1493,7 @@ ns_popup_dialog (struct frame *f, Lisp_Object header, Lisp_Object contents)
1493#define TEXTHEIGHT 20.0 1493#define TEXTHEIGHT 20.0
1494#define MINCELLWIDTH 90.0 1494#define MINCELLWIDTH 90.0
1495 1495
1496- initWithContentRect: (NSRect)contentRect styleMask: (NSUInteger)aStyle 1496- (instancetype)initWithContentRect: (NSRect)contentRect styleMask: (NSWindowStyleMask)aStyle
1497 backing: (NSBackingStoreType)backingType defer: (BOOL)flag 1497 backing: (NSBackingStoreType)backingType defer: (BOOL)flag
1498{ 1498{
1499 NSSize spacing = {SPACER, SPACER}; 1499 NSSize spacing = {SPACER, SPACER};
@@ -1697,7 +1697,7 @@ ns_popup_dialog (struct frame *f, Lisp_Object header, Lisp_Object contents)
1697} 1697}
1698 1698
1699 1699
1700- initFromContents: (Lisp_Object)contents isQuestion: (BOOL)isQ 1700- (instancetype)initFromContents: (Lisp_Object)contents isQuestion: (BOOL)isQ
1701{ 1701{
1702 Lisp_Object head; 1702 Lisp_Object head;
1703 [super init]; 1703 [super init];
diff --git a/src/nsterm.h b/src/nsterm.h
index ac339bf4792..5da949e1fb1 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -444,16 +444,16 @@ char const * nstrace_fullscreen_type_name (int);
444 } 444 }
445 445
446/* AppKit-side interface */ 446/* AppKit-side interface */
447- menuDown: (id)sender; 447- (instancetype)menuDown: (id)sender;
448- toolbarClicked: (id)item; 448- (instancetype)toolbarClicked: (id)item;
449- toggleToolbar: (id)sender; 449- (instancetype)toggleToolbar: (id)sender;
450- (void)keyDown: (NSEvent *)theEvent; 450- (void)keyDown: (NSEvent *)theEvent;
451- (void)mouseDown: (NSEvent *)theEvent; 451- (void)mouseDown: (NSEvent *)theEvent;
452- (void)mouseUp: (NSEvent *)theEvent; 452- (void)mouseUp: (NSEvent *)theEvent;
453- setMiniwindowImage: (BOOL)setMini; 453- (instancetype)setMiniwindowImage: (BOOL)setMini;
454 454
455/* Emacs-side interface */ 455/* Emacs-side interface */
456- initFrameFromEmacs: (struct frame *) f; 456- (instancetype) initFrameFromEmacs: (struct frame *) f;
457- (void) createToolbar: (struct frame *)f; 457- (void) createToolbar: (struct frame *)f;
458- (void) setRows: (int) r andColumns: (int) c; 458- (void) setRows: (int) r andColumns: (int) c;
459- (void) setWindowClosing: (BOOL)closing; 459- (void) setWindowClosing: (BOOL)closing;
@@ -513,7 +513,7 @@ char const * nstrace_fullscreen_type_name (int);
513 unsigned long keyEquivModMask; 513 unsigned long keyEquivModMask;
514} 514}
515 515
516- initWithTitle: (NSString *)title frame: (struct frame *)f; 516- (instancetype)initWithTitle: (NSString *)title frame: (struct frame *)f;
517- (void)setFrame: (struct frame *)f; 517- (void)setFrame: (struct frame *)f;
518- (void)menuNeedsUpdate: (NSMenu *)menu; /* (delegate method) */ 518- (void)menuNeedsUpdate: (NSMenu *)menu; /* (delegate method) */
519- (NSString *)parseKeyEquiv: (const char *)key; 519- (NSString *)parseKeyEquiv: (const char *)key;
@@ -547,7 +547,7 @@ char const * nstrace_fullscreen_type_name (int);
547 NSArray *prevIdentifiers; 547 NSArray *prevIdentifiers;
548 unsigned long enablement, prevEnablement; 548 unsigned long enablement, prevEnablement;
549 } 549 }
550- initForView: (EmacsView *)view withIdentifier: (NSString *)identifier; 550- (instancetype) initForView: (EmacsView *)view withIdentifier: (NSString *)identifier;
551- (void) clearActive; 551- (void) clearActive;
552- (void) clearAll; 552- (void) clearAll;
553- (BOOL) changed; 553- (BOOL) changed;
@@ -582,7 +582,7 @@ char const * nstrace_fullscreen_type_name (int);
582 Lisp_Object dialog_return; 582 Lisp_Object dialog_return;
583 Lisp_Object *button_values; 583 Lisp_Object *button_values;
584 } 584 }
585- initFromContents: (Lisp_Object)menu isQuestion: (BOOL)isQ; 585- (instancetype)initFromContents: (Lisp_Object)menu isQuestion: (BOOL)isQ;
586- (void)process_dialog: (Lisp_Object)list; 586- (void)process_dialog: (Lisp_Object)list;
587- (void)addButton: (char *)str value: (int)tag row: (int)row; 587- (void)addButton: (char *)str value: (int)tag row: (int)row;
588- (void)addString: (char *)str row: (int)row; 588- (void)addString: (char *)str row: (int)row;
@@ -601,7 +601,7 @@ char const * nstrace_fullscreen_type_name (int);
601 NSTextField *textField; 601 NSTextField *textField;
602 NSTimer *timer; 602 NSTimer *timer;
603 } 603 }
604- init; 604- (instancetype) init;
605- (void) setText: (char *)text; 605- (void) setText: (char *)text;
606- (void) showAtX: (int)x Y: (int)y for: (int)seconds; 606- (void) showAtX: (int)x Y: (int)y for: (int)seconds;
607- (void) hide; 607- (void) hide;
@@ -649,12 +649,12 @@ char const * nstrace_fullscreen_type_name (int);
649 NSColor *stippleMask; 649 NSColor *stippleMask;
650 unsigned long xbm_fg; 650 unsigned long xbm_fg;
651} 651}
652+ allocInitFromFile: (Lisp_Object)file; 652+ (instancetype)allocInitFromFile: (Lisp_Object)file;
653- (void)dealloc; 653- (void)dealloc;
654- initFromXBM: (unsigned char *)bits width: (int)w height: (int)h 654- (instancetype)initFromXBM: (unsigned char *)bits width: (int)w height: (int)h
655 fg: (unsigned long)fg bg: (unsigned long)bg; 655 fg: (unsigned long)fg bg: (unsigned long)bg;
656- setXBMColor: (NSColor *)color; 656- (instancetype)setXBMColor: (NSColor *)color;
657- initForXPMWithDepth: (int)depth width: (int)width height: (int)height; 657- (instancetype)initForXPMWithDepth: (int)depth width: (int)width height: (int)height;
658- (void)setPixmapData; 658- (void)setPixmapData;
659- (unsigned long)getPixelAtX: (int)x Y: (int)y; 659- (unsigned long)getPixelAtX: (int)x Y: (int)y;
660- (void)setPixelAtX: (int)x Y: (int)y toRed: (unsigned char)r 660- (void)setPixelAtX: (int)x Y: (int)y toRed: (unsigned char)r
@@ -693,16 +693,16 @@ char const * nstrace_fullscreen_type_name (int);
693 int em_whole; 693 int em_whole;
694 } 694 }
695 695
696- initFrame: (NSRect )r window: (Lisp_Object)win; 696- (instancetype) initFrame: (NSRect )r window: (Lisp_Object)win;
697- (void)setFrame: (NSRect)r; 697- (void)setFrame: (NSRect)r;
698 698
699- setPosition: (int) position portion: (int) portion whole: (int) whole; 699- (instancetype) setPosition: (int) position portion: (int) portion whole: (int) whole;
700- (int) checkSamePosition: (int)position portion: (int)portion 700- (int) checkSamePosition: (int)position portion: (int)portion
701 whole: (int)whole; 701 whole: (int)whole;
702- (void) sendScrollEventAtLoc: (float)loc fromEvent: (NSEvent *)e; 702- (void) sendScrollEventAtLoc: (float)loc fromEvent: (NSEvent *)e;
703- repeatScroll: (NSTimer *)sender; 703- (instancetype)repeatScroll: (NSTimer *)sender;
704- condemn; 704- (instancetype)condemn;
705- reprieve; 705- (instancetype)reprieve;
706- (bool)judge; 706- (bool)judge;
707+ (CGFloat)scrollerWidth; 707+ (CGFloat)scrollerWidth;
708@end 708@end
@@ -725,7 +725,7 @@ char const * nstrace_fullscreen_type_name (int);
725 unsigned long maxChar, maxGlyph; 725 unsigned long maxChar, maxGlyph;
726 long i, len; 726 long i, len;
727} 727}
728- initWithCapacity: (unsigned long) c; 728- (instancetype)initWithCapacity: (unsigned long) c;
729- (void) setString: (NSString *)str font: (NSFont *)font; 729- (void) setString: (NSString *)str font: (NSFont *)font;
730@end 730@end
731#endif /* NS_IMPL_COCOA */ 731#endif /* NS_IMPL_COCOA */
diff --git a/src/nsterm.m b/src/nsterm.m
index a7ab73b63e3..50ce9398fbc 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -6896,7 +6896,7 @@ not_in_argv (NSString *arg)
6896} 6896}
6897 6897
6898 6898
6899- initFrameFromEmacs: (struct frame *)f 6899- (instancetype) initFrameFromEmacs: (struct frame *)f
6900{ 6900{
6901 NSRect r, wr; 6901 NSRect r, wr;
6902 Lisp_Object tem; 6902 Lisp_Object tem;
@@ -7626,7 +7626,7 @@ not_in_argv (NSString *arg)
7626} 7626}
7627 7627
7628 7628
7629- menuDown: sender 7629- (instancetype)menuDown: sender
7630{ 7630{
7631 NSTRACE ("[EmacsView menuDown:]"); 7631 NSTRACE ("[EmacsView menuDown:]");
7632 if (context_menu_value == -1) 7632 if (context_menu_value == -1)
@@ -7651,7 +7651,7 @@ not_in_argv (NSString *arg)
7651 7651
7652 7652
7653/* this gets called on toolbar button click */ 7653/* this gets called on toolbar button click */
7654- toolbarClicked: (id)item 7654- (instancetype)toolbarClicked: (id)item
7655{ 7655{
7656 NSEvent *theEvent; 7656 NSEvent *theEvent;
7657 int idx = [item tag] * TOOL_BAR_ITEM_NSLOTS; 7657 int idx = [item tag] * TOOL_BAR_ITEM_NSLOTS;
@@ -7677,7 +7677,7 @@ not_in_argv (NSString *arg)
7677} 7677}
7678 7678
7679 7679
7680- toggleToolbar: (id)sender 7680- (instancetype)toggleToolbar: (id)sender
7681{ 7681{
7682 NSTRACE ("[EmacsView toggleToolbar:]"); 7682 NSTRACE ("[EmacsView toggleToolbar:]");
7683 7683
@@ -7905,7 +7905,7 @@ not_in_argv (NSString *arg)
7905 (gives a miniaturized version of the window); currently we use the latter for 7905 (gives a miniaturized version of the window); currently we use the latter for
7906 frames whose active buffer doesn't correspond to any file 7906 frames whose active buffer doesn't correspond to any file
7907 (e.g., '*scratch*') */ 7907 (e.g., '*scratch*') */
7908- setMiniwindowImage: (BOOL) setMini 7908- (instancetype)setMiniwindowImage: (BOOL) setMini
7909{ 7909{
7910 id image = [[self window] miniwindowImage]; 7910 id image = [[self window] miniwindowImage];
7911 NSTRACE ("[EmacsView setMiniwindowImage:%d]", setMini); 7911 NSTRACE ("[EmacsView setMiniwindowImage:%d]", setMini);
@@ -8257,7 +8257,7 @@ not_in_argv (NSString *arg)
8257 return r; 8257 return r;
8258} 8258}
8259 8259
8260- initFrame: (NSRect )r window: (Lisp_Object)nwin 8260- (instancetype)initFrame: (NSRect )r window: (Lisp_Object)nwin
8261{ 8261{
8262 NSTRACE ("[EmacsScroller initFrame: window:]"); 8262 NSTRACE ("[EmacsScroller initFrame: window:]");
8263 8263
@@ -8341,7 +8341,7 @@ not_in_argv (NSString *arg)
8341} 8341}
8342 8342
8343 8343
8344- condemn 8344- (instancetype)condemn
8345{ 8345{
8346 NSTRACE ("[EmacsScroller condemn]"); 8346 NSTRACE ("[EmacsScroller condemn]");
8347 condemned =YES; 8347 condemned =YES;
@@ -8349,7 +8349,7 @@ not_in_argv (NSString *arg)
8349} 8349}
8350 8350
8351 8351
8352- reprieve 8352- (instancetype)reprieve
8353{ 8353{
8354 NSTRACE ("[EmacsScroller reprieve]"); 8354 NSTRACE ("[EmacsScroller reprieve]");
8355 condemned =NO; 8355 condemned =NO;
@@ -8404,7 +8404,7 @@ not_in_argv (NSString *arg)
8404} 8404}
8405 8405
8406 8406
8407- setPosition: (int)position portion: (int)portion whole: (int)whole 8407- (instancetype)setPosition: (int)position portion: (int)portion whole: (int)whole
8408{ 8408{
8409 NSTRACE ("[EmacsScroller setPosition:portion:whole:]"); 8409 NSTRACE ("[EmacsScroller setPosition:portion:whole:]");
8410 8410
@@ -8483,7 +8483,7 @@ not_in_argv (NSString *arg)
8483 8483
8484 8484
8485/* called manually thru timer to implement repeated button action w/hold-down */ 8485/* called manually thru timer to implement repeated button action w/hold-down */
8486- repeatScroll: (NSTimer *)scrollEntry 8486- (instancetype)repeatScroll: (NSTimer *)scrollEntry
8487{ 8487{
8488 NSEvent *e = [[self window] currentEvent]; 8488 NSEvent *e = [[self window] currentEvent];
8489 NSPoint p = [[self window] mouseLocationOutsideOfEventStream]; 8489 NSPoint p = [[self window] mouseLocationOutsideOfEventStream];