Subject: bug#27041: closed (Re: bug#27041: MacOS 10.6: fix NS build)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 24 May 2017 19:04:02 +0000

Your bug report

#27041: MacOS 10.6: fix NS build

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
27041: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=27041
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#27041: MacOS 10.6: fix NS build
From: Alan Third <[email-masked]>
To: "Charles A. Roelli" <[email-masked]>
Cc: [email-masked]
Date: Wed, 24 May 2017 20:03:34 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

On Wed, May 24, 2017 at 08:13:21PM +0200, Charles A. Roelli wrote:
> Thanks for your help.
> 
> I changed the conditional to this:
> 
> 
> #if defined(NS_IMPL_GNUSTEP) || MAC_OS_X_VERSION_MAX_ALLOWED <
> MAC_OS_X_VERSION_10_7
> typedef id instancetype;
> typedef NSUInteger NSWindowStyleMask;
> #endif
> 
> 
> And it compiles fine without my previous changes.  Can you verify that this
> still builds with GNUstep?  If not, we can leave the 'int' instead of the
> 'NSUInteger'.

It works fine on GNUstep too, so I’ve pushed the change.

FWIW, that instancetype type appears to be a built‐in and we should
probably be doing some sort of check whether the compiler supports it
natively or not. I don’t know how to go about doing that.

> > > I also see this warning when compiling macfont.m:
> > > 
> > > macfont.m: In function ‘mac_font_shape_1’:
> > > macfont.m:416: warning: ‘NSLayoutManager’ may not respond to
> > > ‘-getGlyphsInRange:glyphs:properties:characterIndexes:bidiLevels:’
> > > macfont.m:416: warning: (Messages without a matching method signature
> > > macfont.m:416: warning: will be assumed to return ‘id’ and accept
> > > macfont.m:416: warning: ‘...’ as arguments.)
> > > 
> > > (some new arguments were added in the recent changes).  But this doesn't
> > > seem to affect functionality so I've left that change as is.

This warning doesn’t make much sense to me. I’ve looked up the
documentation and the new method being used has allegedly been
available since macOS 10.5.

https://developer.apple.com/reference/appkit/nslayoutmanager/1403104-getglyphsinrange

I guess if it’s working we can just ignore it.

-- 
Alan Third

Subject: MacOS 10.6: fix NS build
From: "Charles A. Roelli" <[email-masked]>
To: [email-masked]
Date: Tue, 23 May 2017 20:57:04 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Was getting these errors:

========
nsterm.h:455: error: expected ‘)’ before ‘instancetype’
nsterm.h:456: error: expected ‘)’ before ‘instancetype’
nsterm.h:460: error: expected ‘)’ before ‘instancetype’
nsterm.h:463: error: expected ‘)’ before ‘instancetype’
nsterm.h:523: error: expected ‘)’ before ‘instancetype’
nsterm.h:557: error: expected ‘)’ before ‘instancetype’
nsterm.h:592: error: expected ‘)’ before ‘instancetype’
nsterm.h:611: error: expected ‘)’ before ‘instancetype’
nsterm.h:659: error: expected ‘)’ before ‘instancetype’
nsterm.h:661: error: expected ‘)’ before ‘instancetype’
nsterm.h:663: error: expected ‘)’ before ‘instancetype’
nsterm.h:664: error: expected ‘)’ before ‘instancetype’
nsterm.h:703: error: expected ‘)’ before ‘instancetype’
nsterm.h:706: error: expected ‘)’ before ‘instancetype’
nsterm.h:710: error: expected ‘)’ before ‘instancetype’
nsterm.h:711: error: expected ‘)’ before ‘instancetype’
nsterm.h:712: error: expected ‘)’ before ‘instancetype’
nsterm.h:735: error: expected ‘)’ before ‘instancetype’
nsterm.m:6900: error: expected ‘)’ before ‘instancetype’
nsterm.m:7630: error: expected ‘)’ before ‘instancetype’
nsterm.m:7655: error: expected ‘)’ before ‘instancetype’
nsterm.m:7681: error: expected ‘)’ before ‘instancetype’
nsterm.m:7909: error: expected ‘)’ before ‘instancetype’
nsterm.m:8261: error: expected ‘)’ before ‘instancetype’
nsterm.m:8345: error: expected ‘)’ before ‘instancetype’
nsterm.m:8353: error: expected ‘)’ before ‘instancetype’
nsterm.m:8408: error: expected ‘)’ before ‘instancetype’
nsterm.m:8487: error: expected ‘)’ before ‘instancetype’
========

   CC       nsmenu.o
nsmenu.m:1496: error: expected ‘)’ before ‘NSWindowStyleMask’
nsmenu.m: In function ‘-[EmacsDialogPanel 
initWithContentRect:styleMask:backing:defer:]’:
nsmenu.m:1498: warning: conflicting types for 
‘-(id)initWithContentRect:(NSRect)contentRect styleMask:(id)aStyle 
backing:(NSBackingStoreType)backingType defer:(BOOL)flag’
/System/Library/Frameworks/AppKit.framework/Headers/NSWindow.h:264: 
warning: previous declaration of 
‘-(id)initWithContentRect:(NSRect)contentRect 
styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType 
defer:(BOOL)flag’
nsmenu.m:1520: warning: assignment makes pointer from integer without a cast
nsmenu.m:1525: warning: passing argument 2 of 
‘initWithContentRect:styleMask:backing:defer:’ makes integer from 
pointer without a cast
========

This is with an LLVM/GCC that came with MacOS 10.6:

i686-apple-darwin10-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 
5658) (LLVM build 2335.15.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I've changed the source back to compile correctly (see patch).  It comes 
down to
removing the "instancetype" identifiers and reverting an 
NSWindowStyleMask to an
NSUInteger.

I also see this warning when compiling macfont.m:

macfont.m: In function ‘mac_font_shape_1’:
macfont.m:416: warning: ‘NSLayoutManager’ may not respond to 
‘-getGlyphsInRange:glyphs:properties:characterIndexes:bidiLevels:’
macfont.m:416: warning: (Messages without a matching method signature
macfont.m:416: warning: will be assumed to return ‘id’ and accept
macfont.m:416: warning: ‘...’ as arguments.)

(some new arguments were added in the recent changes).  But this doesn't 
seem to affect functionality so I've left that change as is.

>From e588d3efad0cc410237a78c41af26eca6ca24318 Mon Sep 17 00:00:00 2001
From: Charles A. Roelli <[email-masked]>
Date: Tue, 23 May 2017 20:52:56 +0200
Subject: [PATCH] Fix NS build in MacOS 10.6

---
 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 fb2322a..8c0cbd5 100644
--- a/src/nsimage.m
+++ b/src/nsimage.m
@@ -152,7 +152,7 @@ Updated by Christian Limpach ([email-masked])
 
 @implementation EmacsImage
 
-+ (instancetype)allocInitFromFile: (Lisp_Object)file
++ 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. */
-- (instancetype)initFromXBM: (unsigned char *)bits width: (int)w height: (int)h
+- 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 @@ - (instancetype)initFromXBM: (unsigned char *)bits width: (int)w height: (int)h
 }
 
 /* Set color for a bitmap image.  */
-- (instancetype)setXBMColor: (NSColor *)color
+- setXBMColor: (NSColor *)color
 {
   NSSize s = [self size];
   unsigned char *planes[5];
@@ -309,7 +309,7 @@ - (instancetype)setXBMColor: (NSColor *)color
 }

-- (instancetype)initForXPMWithDepth: (int)depth width: (int)width height: (int)height
+- 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 37a1a62..2847bc6 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -493,7 +493,7 @@
 @implementation EmacsMenu
 
 /* override designated initializer */
-- (instancetype)initWithTitle: (NSString *)title
+- initWithTitle: (NSString *)title
 {
   frame = 0;
   if ((self = [super initWithTitle: title]))
@@ -503,7 +503,7 @@ - (instancetype)initWithTitle: (NSString *)title

 /* used for top-level */
-- (instancetype)initWithTitle: (NSString *)title frame: (struct frame *)f
+- 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
 
-- (instancetype)initForView: (EmacsView *)view withIdentifier: (NSString *)identifier
+- initForView: (EmacsView *)view withIdentifier: (NSString *)identifier
 {
   NSTRACE ("[EmacsToolbar initForView: withIdentifier:]");
 
@@ -1302,7 +1302,7 @@ - (void)setVisible:(BOOL)shown
    display. */
 @implementation EmacsTooltip
 
-- (instancetype)init
+- 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
 
-- (instancetype)initWithContentRect: (NSRect)contentRect styleMask: (NSWindowStyleMask)aStyle
+- initWithContentRect: (NSRect)contentRect styleMask: (NSUInteger)aStyle
               backing: (NSBackingStoreType)backingType defer: (BOOL)flag
 {
   NSSize spacing = {SPACER, SPACER};
@@ -1697,7 +1697,7 @@ - (void)clicked: sender
 }

-- (instancetype)initFromContents: (Lisp_Object)contents isQuestion: (BOOL)isQ
+- initFromContents: (Lisp_Object)contents isQuestion: (BOOL)isQ
 {
   Lisp_Object head;
   [super init];
diff --git a/src/nsterm.h b/src/nsterm.h
index 443a40e..63472f2 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -451,16 +451,16 @@
    }
 
 /* AppKit-side interface */
-- (instancetype)menuDown: (id)sender;
-- (instancetype)toolbarClicked: (id)item;
-- (instancetype)toggleToolbar: (id)sender;
+- menuDown: (id)sender;
+- toolbarClicked: (id)item;
+- toggleToolbar: (id)sender;
 - (void)keyDown: (NSEvent *)theEvent;
 - (void)mouseDown: (NSEvent *)theEvent;
 - (void)mouseUp: (NSEvent *)theEvent;
-- (instancetype)setMiniwindowImage: (BOOL)setMini;
+- setMiniwindowImage: (BOOL)setMini;
 
 /* Emacs-side interface */
-- (instancetype) initFrameFromEmacs: (struct frame *) f;
+- initFrameFromEmacs: (struct frame *) f;
 - (void) createToolbar: (struct frame *)f;
 - (void) setRows: (int) r andColumns: (int) c;
 - (void) setWindowClosing: (BOOL)closing;
@@ -520,7 +520,7 @@
   unsigned long keyEquivModMask;
 }
 
-- (instancetype)initWithTitle: (NSString *)title frame: (struct frame *)f;
+- initWithTitle: (NSString *)title frame: (struct frame *)f;
 - (void)setFrame: (struct frame *)f;
 - (void)menuNeedsUpdate: (NSMenu *)menu; /* (delegate method) */
 - (NSString *)parseKeyEquiv: (const char *)key;
@@ -554,7 +554,7 @@
      NSArray *prevIdentifiers;
      unsigned long enablement, prevEnablement;
    }
-- (instancetype) initForView: (EmacsView *)view withIdentifier: (NSString *)identifier;
+- initForView: (EmacsView *)view withIdentifier: (NSString *)identifier;
 - (void) clearActive;
 - (void) clearAll;
 - (BOOL) changed;
@@ -589,7 +589,7 @@
    Lisp_Object dialog_return;
    Lisp_Object *button_values;
    }
-- (instancetype)initFromContents: (Lisp_Object)menu isQuestion: (BOOL)isQ;
+- 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;
@@ -608,7 +608,7 @@
     NSTextField *textField;
     NSTimer *timer;
   }
-- (instancetype) init;
+- init;
 - (void) setText: (char *)text;
 - (void) showAtX: (int)x Y: (int)y for: (int)seconds;
 - (void) hide;
@@ -656,12 +656,12 @@
   NSColor *stippleMask;
   unsigned long xbm_fg;
 }
-+ (instancetype)allocInitFromFile: (Lisp_Object)file;
++ allocInitFromFile: (Lisp_Object)file;
 - (void)dealloc;
-- (instancetype)initFromXBM: (unsigned char *)bits width: (int)w height: (int)h
+- initFromXBM: (unsigned char *)bits width: (int)w height: (int)h
                   fg: (unsigned long)fg bg: (unsigned long)bg;
-- (instancetype)setXBMColor: (NSColor *)color;
-- (instancetype)initForXPMWithDepth: (int)depth width: (int)width height: (int)height;
+- setXBMColor: (NSColor *)color;
+- 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
@@ -700,16 +700,16 @@
    int em_whole;
    }
 
-- (instancetype) initFrame: (NSRect )r window: (Lisp_Object)win;
+- initFrame: (NSRect )r window: (Lisp_Object)win;
 - (void)setFrame: (NSRect)r;
 
-- (instancetype) setPosition: (int) position portion: (int) portion whole: (int) whole;
+- 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;
-- (instancetype)repeatScroll: (NSTimer *)sender;
-- (instancetype)condemn;
-- (instancetype)reprieve;
+- repeatScroll: (NSTimer *)sender;
+- condemn;
+- reprieve;
 - (bool)judge;
 + (CGFloat)scrollerWidth;
 @end
@@ -732,7 +732,7 @@
   unsigned long maxChar, maxGlyph;
   long i, len;
 }
-- (instancetype)initWithCapacity: (unsigned long) c;
+- 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 e69aa43..b0bb9ec 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -6897,7 +6897,7 @@ This avoids an extra clear and redraw (flicker) at frame creation.  */
 }

-- (instancetype) initFrameFromEmacs: (struct frame *)f
+- initFrameFromEmacs: (struct frame *)f
 {
   NSRect r, wr;
   Lisp_Object tem;
@@ -7627,7 +7627,7 @@ - (void)mouseExited: (NSEvent *)theEvent
 }

-- (instancetype)menuDown: sender
+- menuDown: sender
 {
   NSTRACE ("[EmacsView menuDown:]");
   if (context_menu_value == -1)
@@ -7652,7 +7652,7 @@ - (EmacsToolbar *)toolbar

 /* this gets called on toolbar button click */
-- (instancetype)toolbarClicked: (id)item
+- toolbarClicked: (id)item
 {
   NSEvent *theEvent;
   int idx = [item tag] * TOOL_BAR_ITEM_NSLOTS;
@@ -7678,7 +7678,7 @@ - (instancetype)toolbarClicked: (id)item
 }

-- (instancetype)toggleToolbar: (id)sender
+- toggleToolbar: (id)sender
 {
   NSTRACE ("[EmacsView toggleToolbar:]");
 
@@ -7906,7 +7906,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*') */
-- (instancetype)setMiniwindowImage: (BOOL) setMini
+- setMiniwindowImage: (BOOL) setMini
 {
   id image = [[self window] miniwindowImage];
   NSTRACE ("[EmacsView setMiniwindowImage:%d]", setMini);
@@ -8258,7 +8258,7 @@ + (CGFloat) scrollerWidth
   return r;
 }
 
-- (instancetype)initFrame: (NSRect )r window: (Lisp_Object)nwin
+- initFrame: (NSRect )r window: (Lisp_Object)nwin
 {
   NSTRACE ("[EmacsScroller initFrame: window:]");
 
@@ -8342,7 +8342,7 @@ - (void)dealloc
 }

-- (instancetype)condemn
+- condemn
 {
   NSTRACE ("[EmacsScroller condemn]");
   condemned =YES;
@@ -8350,7 +8350,7 @@ - (instancetype)condemn
 }

-- (instancetype)reprieve
+- reprieve
 {
   NSTRACE ("[EmacsScroller reprieve]");
   condemned =NO;
@@ -8405,7 +8405,7 @@ - (int) checkSamePosition: (int) position portion: (int) portion
 }

-- (instancetype)setPosition: (int)position portion: (int)portion whole: (int)whole
+- setPosition: (int)position portion: (int)portion whole: (int)whole
 {
   NSTRACE ("[EmacsScroller setPosition:portion:whole:]");
 
@@ -8484,7 +8484,7 @@ - (void) sendScrollEventAtLoc: (float)loc fromEvent: (NSEvent *)e

 /* called manually thru timer to implement repeated button action w/hold-down */
-- (instancetype)repeatScroll: (NSTimer *)scrollEntry
+- repeatScroll: (NSTimer *)scrollEntry
 {
   NSEvent *e = [[self window] currentEvent];
   NSPoint p =  [[self window] mouseLocationOutsideOfEventStream];
-- 
1.7.4.4