diff options
| author | Alan Third | 2017-05-25 19:23:39 +0100 |
|---|---|---|
| committer | Alan Third | 2017-05-27 00:46:23 +0100 |
| commit | 0d676deba49ccab9a6a07bc1deeacff51dd44cbf (patch) | |
| tree | fb8cd2f9f9f239d09e4ea9cb260e63c9b8b6035f | |
| parent | dc79aa10f117dea1204634626a5f96a21722807f (diff) | |
| download | emacs-0d676deba49ccab9a6a07bc1deeacff51dd44cbf.tar.gz emacs-0d676deba49ccab9a6a07bc1deeacff51dd44cbf.zip | |
Check if instancetype supported in ObjC
* configure.ac: Add check for instancetype.
* src/nsterm.h [!NATIVE_OBJC_INSTANCETYPE]: Define instancetype.
| -rw-r--r-- | configure.ac | 19 | ||||
| -rw-r--r-- | src/nsterm.h | 20 |
2 files changed, 30 insertions, 9 deletions
diff --git a/configure.ac b/configure.ac index 6d23b5d214e..164454dff30 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -1980,6 +1980,25 @@ AC_SUBST(ns_self_contained) | |||
| 1980 | AC_SUBST(NS_OBJ) | 1980 | AC_SUBST(NS_OBJ) |
| 1981 | AC_SUBST(NS_OBJC_OBJ) | 1981 | AC_SUBST(NS_OBJC_OBJ) |
| 1982 | 1982 | ||
| 1983 | if test "${HAVE_NS}" = yes; then | ||
| 1984 | AC_CACHE_CHECK( | ||
| 1985 | [if the Objective C compiler supports instancetype], | ||
| 1986 | [emacs_cv_objc_instancetype], | ||
| 1987 | [AC_LANG_PUSH([Objective C]) | ||
| 1988 | AC_COMPILE_IFELSE( | ||
| 1989 | [AC_LANG_SOURCE([[@interface Test | ||
| 1990 | + (instancetype)test; | ||
| 1991 | @end]])], | ||
| 1992 | emacs_cv_objc_instancetype=yes, | ||
| 1993 | emacs_cv_objc_instancetype=no) | ||
| 1994 | AC_LANG_POP([Objective C])]) | ||
| 1995 | |||
| 1996 | if test x$emacs_cv_objc_instancetype = xyes ; then | ||
| 1997 | AC_DEFINE(NATIVE_OBJC_INSTANCETYPE, 1, | ||
| 1998 | [Define if ObjC compiler supports instancetype natively.]) | ||
| 1999 | fi | ||
| 2000 | fi | ||
| 2001 | |||
| 1983 | HAVE_W32=no | 2002 | HAVE_W32=no |
| 1984 | W32_OBJ= | 2003 | W32_OBJ= |
| 1985 | W32_LIBS= | 2004 | W32_LIBS= |
diff --git a/src/nsterm.h b/src/nsterm.h index 8f3d92b3537..f75e3759e4f 100644 --- a/src/nsterm.h +++ b/src/nsterm.h | |||
| @@ -62,15 +62,6 @@ typedef CGFloat EmacsCGFloat; | |||
| 62 | typedef float EmacsCGFloat; | 62 | typedef float EmacsCGFloat; |
| 63 | #endif | 63 | #endif |
| 64 | 64 | ||
| 65 | /* FIXME: instancetype is a language built-in, but older versions of | ||
| 66 | Clang don't support it, and I don't know if GCC supports it at all. | ||
| 67 | Should this be tested for in ./configure? */ | ||
| 68 | #if defined (NS_IMPL_GNUSTEP) | ||
| 69 | || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_10 | ||
| 70 | typedef id instancetype; | ||
| 71 | typedef NSUInteger NSWindowStyleMask; | ||
| 72 | #endif | ||
| 73 | |||
| 74 | /* ========================================================================== | 65 | /* ========================================================================== |
| 75 | 66 | ||
| 76 | Trace support | 67 | Trace support |
| @@ -365,6 +356,12 @@ char const * nstrace_fullscreen_type_name (int); | |||
| 365 | #endif | 356 | #endif |
| 366 | 357 | ||
| 367 | 358 | ||
| 359 | /* If the compiler doesn't support instancetype, map it to id. */ | ||
| 360 | #ifndef NATIVE_OBJC_INSTANCETYPE | ||
| 361 | typedef id instancetype; | ||
| 362 | #endif | ||
| 363 | |||
| 364 | |||
| 368 | /* ========================================================================== | 365 | /* ========================================================================== |
| 369 | 366 | ||
| 370 | NSColor, EmacsColor category. | 367 | NSColor, EmacsColor category. |
| @@ -1302,6 +1299,11 @@ extern char gnustep_base_version[]; /* version tracking */ | |||
| 1302 | #define NSWindowStyleMaskUtilityWindow NSUtilityWindowMask | 1299 | #define NSWindowStyleMaskUtilityWindow NSUtilityWindowMask |
| 1303 | #define NSAlertStyleCritical NSCriticalAlertStyle | 1300 | #define NSAlertStyleCritical NSCriticalAlertStyle |
| 1304 | #define NSControlSizeRegular NSRegularControlSize | 1301 | #define NSControlSizeRegular NSRegularControlSize |
| 1302 | |||
| 1303 | /* And adds NSWindowStyleMask. */ | ||
| 1304 | #ifdef __OBJC__ | ||
| 1305 | typedef NSUInteger NSWindowStyleMask; | ||
| 1306 | #endif | ||
| 1305 | #endif | 1307 | #endif |
| 1306 | 1308 | ||
| 1307 | #endif /* HAVE_NS */ | 1309 | #endif /* HAVE_NS */ |