unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH 01/13] Nextstep: Use instancetype explicit return type
@ 2017-05-20 14:58 Philipp Stephani
  2017-05-20 14:58 ` [PATCH 02/13] Declare Nextstep unexec functions in lisp.h Philipp Stephani
                   ` (13 more replies)
  0 siblings, 14 replies; 20+ messages in thread
From: Philipp Stephani @ 2017-05-20 14:58 UTC (permalink / raw)
  To: emacs-devel; +Cc: Philipp Stephani

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 e87da77ccf..1c82fa780a 100644
--- a/src/nsimage.m
+++ b/src/nsimage.m
@@ -152,7 +152,7 @@ Updated by Christian Limpach (chris@nice.ch)
 
 @implementation EmacsImage
 
-+ allocInitFromFile: (Lisp_Object)file
++ (instancetype)allocInitFromFile: (Lisp_Object)file
 {
   NSImageRep *imgRep;
   Lisp_Object found;
@@ -197,7 +197,7 @@ - (void)dealloc
 
 /* 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 @@ - (void)dealloc
 }
 
 /* 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 @@ - (void)dealloc
 }
 
 
-- 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 8dc6ea1d34..5e863bb17d 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -493,7 +493,7 @@
 @implementation EmacsMenu
 
 /* override designated initializer */
-- initWithTitle: (NSString *)title
+- (instancetype)initWithTitle: (NSString *)title
 {
   frame = 0;
   if ((self = [super initWithTitle: title]))
@@ -503,7 +503,7 @@ @implementation EmacsMenu
 
 
 /* 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 @@ - (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (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 @@ - (void)setVisible:(BOOL)shown
    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 @@ @implementation EmacsDialogPanel
 #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 @@ - (void)clicked: sender
 }
 
 
-- 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 9285178d19..f9887d0515 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 c22c5a70ba..107635f034 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -6896,7 +6896,7 @@ This avoids an extra clear and redraw (flicker) at frame creation.  */
 }
 
 
-- initFrameFromEmacs: (struct frame *)f
+- (instancetype) initFrameFromEmacs: (struct frame *)f
 {
   NSRect r, wr;
   Lisp_Object tem;
@@ -7626,7 +7626,7 @@ - (void)mouseExited: (NSEvent *)theEvent
 }
 
 
-- menuDown: sender
+- (instancetype)menuDown: sender
 {
   NSTRACE ("[EmacsView menuDown:]");
   if (context_menu_value == -1)
@@ -7651,7 +7651,7 @@ - (EmacsToolbar *)toolbar
 
 
 /* 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 @@ - (EmacsToolbar *)toolbar
 }
 
 
-- toggleToolbar: (id)sender
+- (instancetype)toggleToolbar: (id)sender
 {
   NSTRACE ("[EmacsView toggleToolbar:]");
 
@@ -7905,7 +7905,7 @@ - (BOOL) writeSelectionToPasteboard: (NSPasteboard *)pb types: (NSArray *)types
    (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 @@ + (CGFloat) scrollerWidth
   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 @@ - (void)dealloc
 }
 
 
-- condemn
+- (instancetype)condemn
 {
   NSTRACE ("[EmacsScroller condemn]");
   condemned =YES;
@@ -8349,7 +8349,7 @@ - (void)dealloc
 }
 
 
-- reprieve
+- (instancetype)reprieve
 {
   NSTRACE ("[EmacsScroller reprieve]");
   condemned =NO;
@@ -8404,7 +8404,7 @@ - (int) checkSamePosition: (int) position portion: (int) portion
 }
 
 
-- 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 @@ - (void) sendScrollEventAtLoc: (float)loc fromEvent: (NSEvent *)e
 
 
 /* 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];
-- 
2.13.0




^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2017-05-23  9:46 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-20 14:58 [PATCH 01/13] Nextstep: Use instancetype explicit return type Philipp Stephani
2017-05-20 14:58 ` [PATCH 02/13] Declare Nextstep unexec functions in lisp.h Philipp Stephani
2017-05-20 14:58 ` [PATCH 03/13] Remove unused function print_regions Philipp Stephani
2017-05-20 14:58 ` [PATCH 04/13] Use NSCharacterCollection instead of CTCharacterCollection Philipp Stephani
2017-05-20 14:58 ` [PATCH 05/13] Make a function static that isn't used outside this file Philipp Stephani
2017-05-20 14:58 ` [PATCH 06/13] Remove calls to deprecated setUsesScreenFonts Philipp Stephani
2017-05-20 14:58 ` [PATCH 07/13] Remove trailing semicolons in method definitions Philipp Stephani
2017-05-20 14:58 ` [PATCH 08/13] Nextstep: remove some deprecated method calls Philipp Stephani
2017-05-20 14:58 ` [PATCH 09/13] Nextstep: Replace deprecated enumerators Philipp Stephani
2017-05-20 14:58 ` [PATCH 10/13] Remove unused automatic variables Philipp Stephani
2017-05-20 14:58 ` [PATCH 11/13] Clean up code around 'ns-list-services' Philipp Stephani
2017-05-20 14:58 ` [PATCH 12/13] Fix call of registerServicesMenuSendTypes Philipp Stephani
2017-05-20 14:58 ` [PATCH 13/13] Avoid uninitialized read Philipp Stephani
2017-05-21 15:30   ` John Wiegley
2017-05-20 20:23 ` [PATCH 01/13] Nextstep: Use instancetype explicit return type Paul Eggert
2017-05-20 22:45   ` mituharu
2017-05-21 20:00   ` Philipp Stephani
2017-05-22  2:36 ` Paul Eggert
2017-05-22 19:21   ` [PATCH] Fix GNUstep build Alan Third
2017-05-23  9:46     ` Paul Eggert

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).