emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 84b28ec 01/13: Nextstep: Use instancetype explicit


From: Philipp Stephani
Subject: [Emacs-diffs] master 84b28ec 01/13: Nextstep: Use instancetype explicit return type
Date: Sun, 21 May 2017 15:51:45 -0400 (EDT)

branch: master
commit 84b28ec759ed3d294c2f49353942ae76e0c75532
Author: Philipp Stephani <address@hidden>
Commit: Philipp Stephani <address@hidden>

    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.
---
 src/nsimage.m |  8 ++++----
 src/nsmenu.m  | 12 ++++++------
 src/nsterm.h  | 38 +++++++++++++++++++-------------------
 src/nsterm.m  | 20 ++++++++++----------
 4 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/src/nsimage.m b/src/nsimage.m
index e87da77..1c82fa7 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)
 
 @implementation EmacsImage
 
-+ allocInitFromFile: (Lisp_Object)file
++ (instancetype)allocInitFromFile: (Lisp_Object)file
 {
   NSImageRep *imgRep;
   Lisp_Object found;
@@ -197,7 +197,7 @@ ns_set_alpha (void *img, int x, int y, unsigned char a)
 
 /* Create image from monochrome bitmap. If both FG and BG are 0
    (black), set the background to white and make it transparent. */
-- initFromXBM: (unsigned char *)bits width: (int)w height: (int)h
+- (instancetype)initFromXBM: (unsigned char *)bits width: (int)w height: (int)h
            fg: (unsigned long)fg bg: (unsigned long)bg
 {
   unsigned char *planes[5];
@@ -269,7 +269,7 @@ ns_set_alpha (void *img, int x, int y, unsigned char a)
 }
 
 /* Set color for a bitmap image.  */
-- setXBMColor: (NSColor *)color
+- (instancetype)setXBMColor: (NSColor *)color
 {
   NSSize s = [self size];
   unsigned char *planes[5];
@@ -309,7 +309,7 @@ ns_set_alpha (void *img, int x, int y, unsigned char a)
 }
 
 
-- initForXPMWithDepth: (int)depth width: (int)width height: (int)height
+- (instancetype)initForXPMWithDepth: (int)depth width: (int)width height: 
(int)height
 {
   NSSize s = {width, height};
   int i;
diff --git a/src/nsmenu.m b/src/nsmenu.m
index 8dc6ea1..5e863bb 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -493,7 +493,7 @@ x_activate_menubar (struct frame *f)
 @implementation EmacsMenu
 
 /* override designated initializer */
-- initWithTitle: (NSString *)title
+- (instancetype)initWithTitle: (NSString *)title
 {
   frame = 0;
   if ((self = [super initWithTitle: title]))
@@ -503,7 +503,7 @@ x_activate_menubar (struct frame *f)
 
 
 /* used for top-level */
-- initWithTitle: (NSString *)title frame: (struct frame *)f
+- (instancetype)initWithTitle: (NSString *)title frame: (struct frame *)f
 {
   [self initWithTitle: title];
   frame = f;
@@ -1146,7 +1146,7 @@ update_frame_tool_bar (struct frame *f)
 
 @implementation EmacsToolbar
 
-- initForView: (EmacsView *)view withIdentifier: (NSString *)identifier
+- (instancetype)initForView: (EmacsView *)view withIdentifier: (NSString 
*)identifier
 {
   NSTRACE ("[EmacsToolbar initForView: withIdentifier:]");
 
@@ -1302,7 +1302,7 @@ update_frame_tool_bar (struct frame *f)
    display. */
 @implementation EmacsTooltip
 
-- init
+- (instancetype)init
 {
   NSColor *col = [NSColor colorWithCalibratedRed: 1.0 green: 1.0
                                             blue: 0.792 alpha: 0.95];
@@ -1493,7 +1493,7 @@ ns_popup_dialog (struct frame *f, Lisp_Object header, 
Lisp_Object contents)
 #define TEXTHEIGHT     20.0
 #define MINCELLWIDTH   90.0
 
-- initWithContentRect: (NSRect)contentRect styleMask: (NSUInteger)aStyle
+- (instancetype)initWithContentRect: (NSRect)contentRect styleMask: 
(NSWindowStyleMask)aStyle
               backing: (NSBackingStoreType)backingType defer: (BOOL)flag
 {
   NSSize spacing = {SPACER, SPACER};
@@ -1697,7 +1697,7 @@ ns_popup_dialog (struct frame *f, Lisp_Object header, 
Lisp_Object contents)
 }
 
 
-- initFromContents: (Lisp_Object)contents isQuestion: (BOOL)isQ
+- (instancetype)initFromContents: (Lisp_Object)contents isQuestion: (BOOL)isQ
 {
   Lisp_Object head;
   [super init];
diff --git a/src/nsterm.h b/src/nsterm.h
index ac339bf..5da949e 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -444,16 +444,16 @@ char const * nstrace_fullscreen_type_name (int);
    }
 
 /* AppKit-side interface */
-- menuDown: (id)sender;
-- toolbarClicked: (id)item;
-- toggleToolbar: (id)sender;
+- (instancetype)menuDown: (id)sender;
+- (instancetype)toolbarClicked: (id)item;
+- (instancetype)toggleToolbar: (id)sender;
 - (void)keyDown: (NSEvent *)theEvent;
 - (void)mouseDown: (NSEvent *)theEvent;
 - (void)mouseUp: (NSEvent *)theEvent;
-- setMiniwindowImage: (BOOL)setMini;
+- (instancetype)setMiniwindowImage: (BOOL)setMini;
 
 /* Emacs-side interface */
-- initFrameFromEmacs: (struct frame *) f;
+- (instancetype) initFrameFromEmacs: (struct frame *) f;
 - (void) createToolbar: (struct frame *)f;
 - (void) setRows: (int) r andColumns: (int) c;
 - (void) setWindowClosing: (BOOL)closing;
@@ -513,7 +513,7 @@ char const * nstrace_fullscreen_type_name (int);
   unsigned long keyEquivModMask;
 }
 
-- initWithTitle: (NSString *)title frame: (struct frame *)f;
+- (instancetype)initWithTitle: (NSString *)title frame: (struct frame *)f;
 - (void)setFrame: (struct frame *)f;
 - (void)menuNeedsUpdate: (NSMenu *)menu; /* (delegate method) */
 - (NSString *)parseKeyEquiv: (const char *)key;
@@ -547,7 +547,7 @@ char const * nstrace_fullscreen_type_name (int);
      NSArray *prevIdentifiers;
      unsigned long enablement, prevEnablement;
    }
-- initForView: (EmacsView *)view withIdentifier: (NSString *)identifier;
+- (instancetype) initForView: (EmacsView *)view withIdentifier: (NSString 
*)identifier;
 - (void) clearActive;
 - (void) clearAll;
 - (BOOL) changed;
@@ -582,7 +582,7 @@ char const * nstrace_fullscreen_type_name (int);
    Lisp_Object dialog_return;
    Lisp_Object *button_values;
    }
-- initFromContents: (Lisp_Object)menu isQuestion: (BOOL)isQ;
+- (instancetype)initFromContents: (Lisp_Object)menu isQuestion: (BOOL)isQ;
 - (void)process_dialog: (Lisp_Object)list;
 - (void)addButton: (char *)str value: (int)tag row: (int)row;
 - (void)addString: (char *)str row: (int)row;
@@ -601,7 +601,7 @@ char const * nstrace_fullscreen_type_name (int);
     NSTextField *textField;
     NSTimer *timer;
   }
-- init;
+- (instancetype) init;
 - (void) setText: (char *)text;
 - (void) showAtX: (int)x Y: (int)y for: (int)seconds;
 - (void) hide;
@@ -649,12 +649,12 @@ char const * nstrace_fullscreen_type_name (int);
   NSColor *stippleMask;
   unsigned long xbm_fg;
 }
-+ allocInitFromFile: (Lisp_Object)file;
++ (instancetype)allocInitFromFile: (Lisp_Object)file;
 - (void)dealloc;
-- initFromXBM: (unsigned char *)bits width: (int)w height: (int)h
+- (instancetype)initFromXBM: (unsigned char *)bits width: (int)w height: (int)h
                   fg: (unsigned long)fg bg: (unsigned long)bg;
-- setXBMColor: (NSColor *)color;
-- initForXPMWithDepth: (int)depth width: (int)width height: (int)height;
+- (instancetype)setXBMColor: (NSColor *)color;
+- (instancetype)initForXPMWithDepth: (int)depth width: (int)width height: 
(int)height;
 - (void)setPixmapData;
 - (unsigned long)getPixelAtX: (int)x Y: (int)y;
 - (void)setPixelAtX: (int)x Y: (int)y toRed: (unsigned char)r
@@ -693,16 +693,16 @@ char const * nstrace_fullscreen_type_name (int);
    int em_whole;
    }
 
-- initFrame: (NSRect )r window: (Lisp_Object)win;
+- (instancetype) initFrame: (NSRect )r window: (Lisp_Object)win;
 - (void)setFrame: (NSRect)r;
 
-- setPosition: (int) position portion: (int) portion whole: (int) whole;
+- (instancetype) setPosition: (int) position portion: (int) portion whole: 
(int) whole;
 - (int) checkSamePosition: (int)position portion: (int)portion
                     whole: (int)whole;
 - (void) sendScrollEventAtLoc: (float)loc fromEvent: (NSEvent *)e;
-- repeatScroll: (NSTimer *)sender;
-- condemn;
-- reprieve;
+- (instancetype)repeatScroll: (NSTimer *)sender;
+- (instancetype)condemn;
+- (instancetype)reprieve;
 - (bool)judge;
 + (CGFloat)scrollerWidth;
 @end
@@ -725,7 +725,7 @@ char const * nstrace_fullscreen_type_name (int);
   unsigned long maxChar, maxGlyph;
   long i, len;
 }
-- initWithCapacity: (unsigned long) c;
+- (instancetype)initWithCapacity: (unsigned long) c;
 - (void) setString: (NSString *)str font: (NSFont *)font;
 @end
 #endif /* NS_IMPL_COCOA */
diff --git a/src/nsterm.m b/src/nsterm.m
index a7ab73b..50ce939 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -6896,7 +6896,7 @@ not_in_argv (NSString *arg)
 }
 
 
-- initFrameFromEmacs: (struct frame *)f
+- (instancetype) initFrameFromEmacs: (struct frame *)f
 {
   NSRect r, wr;
   Lisp_Object tem;
@@ -7626,7 +7626,7 @@ not_in_argv (NSString *arg)
 }
 
 
-- menuDown: sender
+- (instancetype)menuDown: sender
 {
   NSTRACE ("[EmacsView menuDown:]");
   if (context_menu_value == -1)
@@ -7651,7 +7651,7 @@ not_in_argv (NSString *arg)
 
 
 /* this gets called on toolbar button click */
-- toolbarClicked: (id)item
+- (instancetype)toolbarClicked: (id)item
 {
   NSEvent *theEvent;
   int idx = [item tag] * TOOL_BAR_ITEM_NSLOTS;
@@ -7677,7 +7677,7 @@ not_in_argv (NSString *arg)
 }
 
 
-- toggleToolbar: (id)sender
+- (instancetype)toggleToolbar: (id)sender
 {
   NSTRACE ("[EmacsView toggleToolbar:]");
 
@@ -7905,7 +7905,7 @@ not_in_argv (NSString *arg)
    (gives a miniaturized version of the window); currently we use the latter 
for
    frames whose active buffer doesn't correspond to any file
    (e.g., '*scratch*') */
-- setMiniwindowImage: (BOOL) setMini
+- (instancetype)setMiniwindowImage: (BOOL) setMini
 {
   id image = [[self window] miniwindowImage];
   NSTRACE ("[EmacsView setMiniwindowImage:%d]", setMini);
@@ -8257,7 +8257,7 @@ not_in_argv (NSString *arg)
   return r;
 }
 
-- initFrame: (NSRect )r window: (Lisp_Object)nwin
+- (instancetype)initFrame: (NSRect )r window: (Lisp_Object)nwin
 {
   NSTRACE ("[EmacsScroller initFrame: window:]");
 
@@ -8341,7 +8341,7 @@ not_in_argv (NSString *arg)
 }
 
 
-- condemn
+- (instancetype)condemn
 {
   NSTRACE ("[EmacsScroller condemn]");
   condemned =YES;
@@ -8349,7 +8349,7 @@ not_in_argv (NSString *arg)
 }
 
 
-- reprieve
+- (instancetype)reprieve
 {
   NSTRACE ("[EmacsScroller reprieve]");
   condemned =NO;
@@ -8404,7 +8404,7 @@ not_in_argv (NSString *arg)
 }
 
 
-- setPosition: (int)position portion: (int)portion whole: (int)whole
+- (instancetype)setPosition: (int)position portion: (int)portion whole: 
(int)whole
 {
   NSTRACE ("[EmacsScroller setPosition:portion:whole:]");
 
@@ -8483,7 +8483,7 @@ not_in_argv (NSString *arg)
 
 
 /* called manually thru timer to implement repeated button action w/hold-down 
*/
-- repeatScroll: (NSTimer *)scrollEntry
+- (instancetype)repeatScroll: (NSTimer *)scrollEntry
 {
   NSEvent *e = [[self window] currentEvent];
   NSPoint p =  [[self window] mouseLocationOutsideOfEventStream];



reply via email to

[Prev in Thread] Current Thread [Next in Thread]