unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#27041: MacOS 10.6: fix NS build
@ 2017-05-23 18:57 Charles A. Roelli
  2017-05-23 19:49 ` Alan Third
       [not found] ` <handler.27041.D27041.149565262621210.notifdone@debbugs.gnu.org>
  0 siblings, 2 replies; 8+ messages in thread
From: Charles A. Roelli @ 2017-05-23 18:57 UTC (permalink / raw)
  To: 27041

[-- Attachment #1: Type: text/plain, Size: 3780 bytes --]

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.



[-- Attachment #2: 0001-Fix-NS-build-in-MacOS-10.6.patch --]
[-- Type: text/x-patch, Size: 10228 bytes --]

From e588d3efad0cc410237a78c41af26eca6ca24318 Mon Sep 17 00:00:00 2001
From: Charles A. Roelli <charles@aurox.ch>
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 (chris@nice.ch)
 
 @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


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

* bug#27041: MacOS 10.6: fix NS build
  2017-05-23 18:57 bug#27041: MacOS 10.6: fix NS build Charles A. Roelli
@ 2017-05-23 19:49 ` Alan Third
  2017-05-24 18:13   ` Charles A. Roelli
       [not found] ` <handler.27041.D27041.149565262621210.notifdone@debbugs.gnu.org>
  1 sibling, 1 reply; 8+ messages in thread
From: Alan Third @ 2017-05-23 19:49 UTC (permalink / raw)
  To: Charles A. Roelli; +Cc: 27041

On Tue, May 23, 2017 at 08:57:04PM +0200, Charles A. Roelli wrote:
> 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.

Hi Charles, can you try enabling the two typedefs at ~ line 67 in
nsterm.h to see if the first batch of errors go away?

I guess it’s possible the second typedef should be an NSUInteger
instead of a plain int. I just took a guess and that silenced the
errors when building under GNUstep.

> 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.

Probably we should be using one function for recent macOS’s and
another for old ones. Yamamoto san had something to say about it, but
I’ve not had a chance to investigate:

http://lists.gnu.org/archive/html/emacs-devel/2017-05/msg00565.html

-- 
Alan Third





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

* bug#27041: MacOS 10.6: fix NS build
  2017-05-23 19:49 ` Alan Third
@ 2017-05-24 18:13   ` Charles A. Roelli
  2017-05-24 19:03     ` Alan Third
  0 siblings, 1 reply; 8+ messages in thread
From: Charles A. Roelli @ 2017-05-24 18:13 UTC (permalink / raw)
  To: Alan Third; +Cc: 27041

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'.


On 23/05/2017 21:49, Alan Third wrote:
> On Tue, May 23, 2017 at 08:57:04PM +0200, Charles A. Roelli wrote:
>> 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.
> Hi Charles, can you try enabling the two typedefs at ~ line 67 in
> nsterm.h to see if the first batch of errors go away?
>
> I guess it’s possible the second typedef should be an NSUInteger
> instead of a plain int. I just took a guess and that silenced the
> errors when building under GNUstep.
>
>> 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.
> Probably we should be using one function for recent macOS’s and
> another for old ones. Yamamoto san had something to say about it, but
> I’ve not had a chance to investigate:
>
> http://lists.gnu.org/archive/html/emacs-devel/2017-05/msg00565.html
>






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

* bug#27041: MacOS 10.6: fix NS build
  2017-05-24 18:13   ` Charles A. Roelli
@ 2017-05-24 19:03     ` Alan Third
  0 siblings, 0 replies; 8+ messages in thread
From: Alan Third @ 2017-05-24 19:03 UTC (permalink / raw)
  To: Charles A. Roelli; +Cc: 27041-done

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





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

* bug#27041: MacOS 10.6: fix NS build
       [not found] ` <handler.27041.D27041.149565262621210.notifdone@debbugs.gnu.org>
@ 2017-05-25  2:17   ` npostavs
  2017-05-25 18:46     ` bug#27041: [PATCH] Check if instancetype supported in ObjC Alan Third
  0 siblings, 1 reply; 8+ messages in thread
From: npostavs @ 2017-05-25  2:17 UTC (permalink / raw)
  To: 27041; +Cc: Alan Third, Charles A. Roelli

> 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 think you should add something like this to configure.ac:

  AC_CACHE_CHECK([if the Objective C compiler supports instancetype], emacs_cv_objc_instancetype,
    AC_LANG_PUSH([Objective C])
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[- (instancetype) foo: () {return self;}]])],
                      emacs_cv_objc_instancetype=yes, emacs_cv_objc_instancetype=no)
    AC_LANG_POP([Objective C]))
  if test x$emacs_cv_objc_exceptions = xyes ; then
    AC_DEFINE(NATIVE_OBJC_INSTANCETYPE, 1,
         [Define if ObjC compiler supports instancetype natively.])
  fi

Probably you have to fix the code I put inside AC_LANG_PROGRAM([[...]]),
I don't know Objective C at all.





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

* bug#27041: [PATCH] Check if instancetype supported in ObjC
  2017-05-25  2:17   ` npostavs
@ 2017-05-25 18:46     ` Alan Third
  2017-05-25 23:42       ` npostavs
  2017-05-26 19:25       ` Charles A. Roelli
  0 siblings, 2 replies; 8+ messages in thread
From: Alan Third @ 2017-05-25 18:46 UTC (permalink / raw)
  To: npostavs; +Cc: 27041, Charles A. Roelli

* configure.ac: Add check for instancetype.
* src/nsterm.h [!NATIVE_OBJC_INSTANCETYPE]: Define instancetype.
---
 configure.ac | 17 +++++++++++++++++
 src/nsterm.h | 20 +++++++++++---------
 2 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/configure.ac b/configure.ac
index 6d23b5d214..b525666a85 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1980,6 +1980,23 @@ AC_DEFUN
 AC_SUBST(NS_OBJ)
 AC_SUBST(NS_OBJC_OBJ)
 
+AC_CACHE_CHECK(
+  [if the Objective C compiler supports instancetype],
+  [emacs_cv_objc_instancetype],
+  [AC_LANG_PUSH([Objective C])
+   AC_COMPILE_IFELSE(
+     [AC_LANG_SOURCE([[@interface Test
+                        + (instancetype)test;
+                        @end]])],
+     emacs_cv_objc_instancetype=yes,
+     emacs_cv_objc_instancetype=no)
+   AC_LANG_POP([Objective C])])
+
+if test x$emacs_cv_objc_instancetype = xyes ; then
+  AC_DEFINE(NATIVE_OBJC_INSTANCETYPE, 1,
+            [Define if ObjC compiler supports instancetype natively.])
+fi
+
 HAVE_W32=no
 W32_OBJ=
 W32_LIBS=
diff --git a/src/nsterm.h b/src/nsterm.h
index 8f3d92b353..f75e3759e4 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -62,15 +62,6 @@ typedef CGFloat EmacsCGFloat;
 typedef float EmacsCGFloat;
 #endif
 
-/* FIXME: instancetype is a language built-in, but older versions of
-   Clang don't support it, and I don't know if GCC supports it at all.
-   Should this be tested for in ./configure? */
-#if defined (NS_IMPL_GNUSTEP)
-    || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_10
-typedef id instancetype;
-typedef NSUInteger NSWindowStyleMask;
-#endif
-
 /* ==========================================================================
 
    Trace support
@@ -365,6 +356,12 @@ char const * nstrace_fullscreen_type_name (int);
 #endif
 
 
+/* If the compiler doesn't support instancetype, map it to id. */
+#ifndef NATIVE_OBJC_INSTANCETYPE
+typedef id instancetype;
+#endif
+
+
 /* ==========================================================================
 
    NSColor, EmacsColor category.
@@ -1302,6 +1299,11 @@ extern char gnustep_base_version[];  /* version tracking */
 #define NSWindowStyleMaskUtilityWindow     NSUtilityWindowMask
 #define NSAlertStyleCritical               NSCriticalAlertStyle
 #define NSControlSizeRegular               NSRegularControlSize
+
+/* And adds NSWindowStyleMask. */
+#ifdef __OBJC__
+typedef NSUInteger NSWindowStyleMask;
+#endif
 #endif
 
 #endif	/* HAVE_NS */
-- 

Looks like this does the trick. Thanks Noam!

Charles, could you confirm this patch builds on 10.6?

-- 
Alan Third





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

* bug#27041: [PATCH] Check if instancetype supported in ObjC
  2017-05-25 18:46     ` bug#27041: [PATCH] Check if instancetype supported in ObjC Alan Third
@ 2017-05-25 23:42       ` npostavs
  2017-05-26 19:25       ` Charles A. Roelli
  1 sibling, 0 replies; 8+ messages in thread
From: npostavs @ 2017-05-25 23:42 UTC (permalink / raw)
  To: Alan Third; +Cc: 27041, Charles A. Roelli

Alan Third <alan@idiocy.org> writes:

> --- a/configure.ac
> +++ b/configure.ac
> @@ -1980,6 +1980,23 @@ AC_DEFUN
>  AC_SUBST(NS_OBJ)
>  AC_SUBST(NS_OBJC_OBJ)
>  
> +AC_CACHE_CHECK(
> +  [if the Objective C compiler supports instancetype],
> +  [emacs_cv_objc_instancetype],
> +  [AC_LANG_PUSH([Objective C])
> +   AC_COMPILE_IFELSE(
> +     [AC_LANG_SOURCE([[@interface Test
> +                        + (instancetype)test;
> +                        @end]])],
> +     emacs_cv_objc_instancetype=yes,
> +     emacs_cv_objc_instancetype=no)
> +   AC_LANG_POP([Objective C])])
> +
> +if test x$emacs_cv_objc_instancetype = xyes ; then
> +  AC_DEFINE(NATIVE_OBJC_INSTANCETYPE, 1,
> +            [Define if ObjC compiler supports instancetype natively.])
> +fi
> +
>  HAVE_W32=no
>  W32_OBJ=
>  W32_LIBS=

I guess this should be inside 'if test "${HAVE_NS}" = yes; ...'
(although it seems harmless anyway).





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

* bug#27041: [PATCH] Check if instancetype supported in ObjC
  2017-05-25 18:46     ` bug#27041: [PATCH] Check if instancetype supported in ObjC Alan Third
  2017-05-25 23:42       ` npostavs
@ 2017-05-26 19:25       ` Charles A. Roelli
  1 sibling, 0 replies; 8+ messages in thread
From: Charles A. Roelli @ 2017-05-26 19:25 UTC (permalink / raw)
  To: Alan Third, npostavs; +Cc: 27041

All good.  Thanks for the help!


On 25/05/2017 20:46, Alan Third wrote:
> * configure.ac: Add check for instancetype.
> * src/nsterm.h [!NATIVE_OBJC_INSTANCETYPE]: Define instancetype.
> ---
>   configure.ac | 17 +++++++++++++++++
>   src/nsterm.h | 20 +++++++++++---------
>   2 files changed, 28 insertions(+), 9 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index 6d23b5d214..b525666a85 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -1980,6 +1980,23 @@ AC_DEFUN
>   AC_SUBST(NS_OBJ)
>   AC_SUBST(NS_OBJC_OBJ)
>   
> +AC_CACHE_CHECK(
> +  [if the Objective C compiler supports instancetype],
> +  [emacs_cv_objc_instancetype],
> +  [AC_LANG_PUSH([Objective C])
> +   AC_COMPILE_IFELSE(
> +     [AC_LANG_SOURCE([[@interface Test
> +                        + (instancetype)test;
> +                        @end]])],
> +     emacs_cv_objc_instancetype=yes,
> +     emacs_cv_objc_instancetype=no)
> +   AC_LANG_POP([Objective C])])
> +
> +if test x$emacs_cv_objc_instancetype = xyes ; then
> +  AC_DEFINE(NATIVE_OBJC_INSTANCETYPE, 1,
> +            [Define if ObjC compiler supports instancetype natively.])
> +fi
> +
>   HAVE_W32=no
>   W32_OBJ=
>   W32_LIBS=
> diff --git a/src/nsterm.h b/src/nsterm.h
> index 8f3d92b353..f75e3759e4 100644
> --- a/src/nsterm.h
> +++ b/src/nsterm.h
> @@ -62,15 +62,6 @@ typedef CGFloat EmacsCGFloat;
>   typedef float EmacsCGFloat;
>   #endif
>   
> -/* FIXME: instancetype is a language built-in, but older versions of
> -   Clang don't support it, and I don't know if GCC supports it at all.
> -   Should this be tested for in ./configure? */
> -#if defined (NS_IMPL_GNUSTEP)
> -    || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_10
> -typedef id instancetype;
> -typedef NSUInteger NSWindowStyleMask;
> -#endif
> -
>   /* ==========================================================================
>   
>      Trace support
> @@ -365,6 +356,12 @@ char const * nstrace_fullscreen_type_name (int);
>   #endif
>   
>   
> +/* If the compiler doesn't support instancetype, map it to id. */
> +#ifndef NATIVE_OBJC_INSTANCETYPE
> +typedef id instancetype;
> +#endif
> +
> +
>   /* ==========================================================================
>   
>      NSColor, EmacsColor category.
> @@ -1302,6 +1299,11 @@ extern char gnustep_base_version[];  /* version tracking */
>   #define NSWindowStyleMaskUtilityWindow     NSUtilityWindowMask
>   #define NSAlertStyleCritical               NSCriticalAlertStyle
>   #define NSControlSizeRegular               NSRegularControlSize
> +
> +/* And adds NSWindowStyleMask. */
> +#ifdef __OBJC__
> +typedef NSUInteger NSWindowStyleMask;
> +#endif
>   #endif
>   
>   #endif	/* HAVE_NS */






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

end of thread, other threads:[~2017-05-26 19:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-23 18:57 bug#27041: MacOS 10.6: fix NS build Charles A. Roelli
2017-05-23 19:49 ` Alan Third
2017-05-24 18:13   ` Charles A. Roelli
2017-05-24 19:03     ` Alan Third
     [not found] ` <handler.27041.D27041.149565262621210.notifdone@debbugs.gnu.org>
2017-05-25  2:17   ` npostavs
2017-05-25 18:46     ` bug#27041: [PATCH] Check if instancetype supported in ObjC Alan Third
2017-05-25 23:42       ` npostavs
2017-05-26 19:25       ` Charles A. Roelli

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).