From mboxrd@z Thu Jan 1 00:00:00 1970
Path: news.gmane.org!.POSTED!not-for-mail
From: Philipp Stephani
Newsgroups: gmane.emacs.devel
Subject: [PATCH 01/13] Nextstep: Use instancetype explicit return type
Date: Sat, 20 May 2017 16:58:29 +0200
Message-ID: <20170520145841.94282-1-phst@google.com>
NNTP-Posting-Host: blaine.gmane.org
X-Trace: blaine.gmane.org 1495292588 21149 195.159.176.226 (20 May 2017 15:03:08 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sat, 20 May 2017 15:03:08 +0000 (UTC)
Cc: Philipp Stephani
To: emacs-devel@gnu.org
Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat May 20 17:03:00 2017
Return-path:
Envelope-to: ged-emacs-devel@m.gmane.org
Original-Received: from lists.gnu.org ([208.118.235.17])
by blaine.gmane.org with esmtp (Exim 4.84_2)
(envelope-from )
id 1dC5uE-0005IJ-1Q
for ged-emacs-devel@m.gmane.org; Sat, 20 May 2017 17:02:58 +0200
Original-Received: from localhost ([::1]:34522 helo=lists.gnu.org)
by lists.gnu.org with esmtp (Exim 4.71)
(envelope-from )
id 1dC5uJ-0001Pn-KW
for ged-emacs-devel@m.gmane.org; Sat, 20 May 2017 11:03:03 -0400
Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49926)
by lists.gnu.org with esmtp (Exim 4.71)
(envelope-from ) id 1dC5qg-0007qL-K4
for emacs-devel@gnu.org; Sat, 20 May 2017 10:59:20 -0400
Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
(envelope-from ) id 1dC5qb-0003Ek-NC
for emacs-devel@gnu.org; Sat, 20 May 2017 10:59:18 -0400
Original-Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:35718)
by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
(Exim 4.71) (envelope-from )
id 1dC5qb-0003Eb-Bd
for emacs-devel@gnu.org; Sat, 20 May 2017 10:59:13 -0400
Original-Received: by mail-wr0-x242.google.com with SMTP id g12so5234314wrg.2
for ; Sat, 20 May 2017 07:59:12 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
h=from:to:cc:subject:date:message-id;
bh=9JlWYbgKyO0wzjNhD5bX8hPv3MCfSb21lRSNKu+2Sms=;
b=fXjsyf99Ru+Q/Won7id623aBb4Ii+AbHygupOzt2IXbe3SXCJ4cX1iC0RM/1sexS/K
nVklD5DkzxdCodr3X16viOyrlWLbowrTsYso1vzjJg6XMR00pbO0/iDqfxG2ZMSVzPKV
D1oZ5LCr9UO6FjP6yoQztPSoK0AFjUCAl5C4sdF5HvCydqRUAkgJ5HEtbTf4m3yB/b/X
0QMKWIt6auRFuWRDoPQgkODhujTzftHc4nVpxoRpiA/bwQ889H70MK7uiecS0jYoagAq
40lO6kVcamNlMIBt0xX2pzWGcMa1xRBPGAhJUm0pd+qFsB14O0kakzTMFa0VOlr4GWGd
wdFQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:from:to:cc:subject:date:message-id;
bh=9JlWYbgKyO0wzjNhD5bX8hPv3MCfSb21lRSNKu+2Sms=;
b=DrJWYm/s2+23tQPebR3Ag3gpiXuU9vyVIuNu819mQqYX05w20S/DvkoOIKeNqHJSEJ
BpX8f3aYx48PrfuojfROVxDtN/Tf3pDTrkUy4f7cMP0Q2Rk+CF6GrdP+6mmBt1zcfAgP
5ffuNQBkKfQLde3MdoH1JBt6VZ4PgabaQWLeqyPPKFN1omi0Lmwn81DB2X1IpjgiHi57
6yoW2WvmT4BJipPuL9rg+Fv4CVWK67f/ODs/8i01aKwJipuN3G6+hRI8dTOAwFvQsVDK
OSszqKM+KzwU7GGrIfnwtp/U6vnTjoOlatwcojmD1uE/pyS5C74R4Ka2QmmCqDVRheHm
DbXQ==
X-Gm-Message-State: AODbwcAtV1TETmTvz2zacePRmkMi+ZqGCu1OzcD+i9Lt5LUf4larvcXX
/B3U6/asf7ZzeA==
X-Received: by 10.223.164.208 with SMTP id h16mr5804615wrb.142.1495292351803;
Sat, 20 May 2017 07:59:11 -0700 (PDT)
Original-Received: from p.cm.cablesurf.de (46.128.198.151.dynamic.cablesurf.de.
[46.128.198.151])
by smtp.gmail.com with ESMTPSA id 4sm7795937wrv.33.2017.05.20.07.59.10
(version=TLS1 cipher=AES128-SHA bits=128/128);
Sat, 20 May 2017 07:59:11 -0700 (PDT)
X-Google-Original-From: Philipp Stephani
X-Mailer: git-send-email 2.13.0
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
recognized.
X-Received-From: 2a00:1450:400c:c0c::242
X-BeenThere: emacs-devel@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: "Emacs development discussions."
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org
Original-Sender: "Emacs-devel"
Xref: news.gmane.org gmane.emacs.devel:215021
Archived-At:
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