Skip to content

Commit 8839232

Browse files
authored
Merge pull request #368 from macvim-dev/fix/warnings
Suppress warnings for Xcode 8
2 parents 0b2421e + 60ea35d commit 8839232

18 files changed

+131
-61
lines changed

src/MacVim/DBPrefsWindowController.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ - (void)windowDidLoad
7575
// If the developer attached a window to this controller
7676
// in Interface Builder, it gets replaced with this one.
7777
NSPanel *window = [[[NSPanel alloc] initWithContentRect:NSMakeRect(0,0,1000,1000)
78-
styleMask:(NSTitledWindowMask |
79-
NSClosableWindowMask)
78+
styleMask:(NSWindowStyleMaskTitled |
79+
NSWindowStyleMaskClosable)
8080
backing:NSBackingStoreBuffered
8181
defer:YES] autorelease];
8282
[window setHidesOnDeactivate:NO];

src/MacVim/MMAppController.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ - (NSApplicationTerminateReply)applicationShouldTerminate:
518518

519519
if (modifiedBuffers) {
520520
NSAlert *alert = [[NSAlert alloc] init];
521-
[alert setAlertStyle:NSWarningAlertStyle];
521+
[alert setAlertStyle:NSAlertStyleWarning];
522522
[alert addButtonWithTitle:NSLocalizedString(@"Quit",
523523
@"Dialog button")];
524524
[alert addButtonWithTitle:NSLocalizedString(@"Cancel",
@@ -548,7 +548,7 @@ - (NSApplicationTerminateReply)applicationShouldTerminate:
548548

549549
if (numWindows > 1 || numTabs > 1) {
550550
NSAlert *alert = [[NSAlert alloc] init];
551-
[alert setAlertStyle:NSWarningAlertStyle];
551+
[alert setAlertStyle:NSAlertStyleWarning];
552552
[alert addButtonWithTitle:NSLocalizedString(@"Quit",
553553
@"Dialog button")];
554554
[alert addButtonWithTitle:NSLocalizedString(@"Cancel",
@@ -1582,7 +1582,7 @@ - (NSArray *)filterFilesAndNotify:(NSArray *)filenames
15821582
}
15831583

15841584
[alert setInformativeText:text];
1585-
[alert setAlertStyle:NSWarningAlertStyle];
1585+
[alert setAlertStyle:NSAlertStyleWarning];
15861586

15871587
[alert runModal];
15881588
[alert release];
@@ -1751,7 +1751,7 @@ - (void)handleGetURLEvent:(NSAppleEventDescriptor *)event
17511751
@"Unknown URL Scheme dialog, text"),
17521752
[url host]]];
17531753

1754-
[alert setAlertStyle:NSWarningAlertStyle];
1754+
[alert setAlertStyle:NSAlertStyleWarning];
17551755
[alert runModal];
17561756
[alert release];
17571757
}

src/MacVim/MMBackend.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3179,7 +3179,7 @@ static int eventModifierFlagsToVimModMask(int modifierFlags)
31793179
modMask |= MOD_MASK_CTRL;
31803180
if (modifierFlags & NSAlternateKeyMask)
31813181
modMask |= MOD_MASK_ALT;
3182-
if (modifierFlags & NSCommandKeyMask)
3182+
if (modifierFlags & NSEventModifierFlagCommand)
31833183
modMask |= MOD_MASK_CMD;
31843184

31853185
return modMask;

src/MacVim/MMTextViewHelper.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ - (void)keyDown:(NSEvent *)event
163163
ASLogDebug(@"MACMETA key, don't interpret it");
164164
string = unmod;
165165
} else if (imState && (flags & NSControlKeyMask)
166-
&& !(flags & (NSAlternateKeyMask|NSCommandKeyMask))
166+
&& !(flags & (NSAlternateKeyMask|NSEventModifierFlagCommand))
167167
&& [unmod length] == 1
168168
&& ([unmod characterAtIndex:0] == '6' ||
169169
[unmod characterAtIndex:0] == '^')) {
@@ -180,7 +180,7 @@ - (void)keyDown:(NSEvent *)event
180180
[textView interpretKeyEvents:[NSArray arrayWithObject:event]];
181181
if (interpretKeyEventsSwallowedKey)
182182
string = nil;
183-
else if (flags & NSCommandKeyMask) {
183+
else if (flags & NSEventModifierFlagCommand) {
184184
// HACK! When Command is held we have to more or less guess whether
185185
// we should use characters or charactersIgnoringModifiers. The
186186
// following heuristic seems to work but it may have to change.

src/MacVim/MMVimController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,7 @@ - (void)popupMenuWithDescriptor:(NSArray *)desc
13281328
pt = [[windowController window] mouseLocationOutsideOfEventStream];
13291329
}
13301330

1331-
NSEvent *event = [NSEvent mouseEventWithType:NSRightMouseDown
1331+
NSEvent *event = [NSEvent mouseEventWithType:NSEventTypeRightMouseDown
13321332
location:pt
13331333
modifierFlags:0
13341334
timestamp:0

src/MacVim/MMVimView.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,11 @@ - (void)drawRect:(NSRect)rect
197197
// weird behind the window resize throbber, so emulate the look of an
198198
// NSScrollView in the bottom right corner.
199199
if (![[self window] showsResizeIndicator] // XXX: make this a flag
200-
|| !([[self window] styleMask] & NSTexturedBackgroundWindowMask))
200+
|| !([[self window] styleMask] & NSWindowStyleMaskTexturedBackground))
201201
return;
202202

203203
#if (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7)
204-
int sw = [NSScroller scrollerWidthForControlSize:NSRegularControlSize scrollerStyle:NSScrollerStyleLegacy];
204+
int sw = [NSScroller scrollerWidthForControlSize:NSControlSizeRegular scrollerStyle:NSScrollerStyleLegacy];
205205
#else
206206
int sw = [NSScroller scrollerWidth];
207207
#endif
@@ -704,7 +704,7 @@ - (void)placeScrollbars
704704

705705
NSRect rect;
706706
#if (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7)
707-
CGFloat scrollerWidth = [NSScroller scrollerWidthForControlSize:NSRegularControlSize scrollerStyle:NSScrollerStyleLegacy];
707+
CGFloat scrollerWidth = [NSScroller scrollerWidthForControlSize:NSControlSizeRegular scrollerStyle:NSScrollerStyleLegacy];
708708
#else
709709
CGFloat scrollerWidth = [NSScroller scrollerWidth];
710710
#endif
@@ -818,7 +818,7 @@ - (NSSize)vimViewSizeForTextViewSize:(NSSize)textViewSize
818818
{
819819
NSSize size = textViewSize;
820820
#if (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7)
821-
CGFloat scrollerWidth = [NSScroller scrollerWidthForControlSize:NSRegularControlSize scrollerStyle:NSScrollerStyleLegacy];
821+
CGFloat scrollerWidth = [NSScroller scrollerWidthForControlSize:NSControlSizeRegular scrollerStyle:NSScrollerStyleLegacy];
822822
#else
823823
CGFloat scrollerWidth = [NSScroller scrollerWidth];
824824
#endif
@@ -840,7 +840,7 @@ - (NSRect)textViewRectForVimViewSize:(NSSize)contentSize
840840
{
841841
NSRect rect = { {0, 0}, {contentSize.width, contentSize.height} };
842842
#if (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7)
843-
CGFloat scrollerWidth = [NSScroller scrollerWidthForControlSize:NSRegularControlSize scrollerStyle:NSScrollerStyleLegacy];
843+
CGFloat scrollerWidth = [NSScroller scrollerWidthForControlSize:NSControlSizeRegular scrollerStyle:NSScrollerStyleLegacy];
844844
#else
845845
CGFloat scrollerWidth = [NSScroller scrollerWidth];
846846
#endif

src/MacVim/MMWindowController.m

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,15 @@ @implementation MMWindowController
127127

128128
- (id)initWithVimController:(MMVimController *)controller
129129
{
130-
unsigned styleMask = NSTitledWindowMask | NSClosableWindowMask
131-
| NSMiniaturizableWindowMask | NSResizableWindowMask
132-
| NSUnifiedTitleAndToolbarWindowMask
133-
| NSTexturedBackgroundWindowMask;
130+
unsigned styleMask = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable
131+
| NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable
132+
| NSWindowStyleMaskUnifiedTitleAndToolbar
133+
| NSWindowStyleMaskTexturedBackground;
134134

135135
if ([[NSUserDefaults standardUserDefaults]
136136
boolForKey:MMNoTitleBarWindowKey]) {
137137
// No title bar setting
138-
styleMask &= ~NSTitledWindowMask;
138+
styleMask &= ~NSWindowStyleMaskTitled;
139139
}
140140

141141
// NOTE: The content rect is only used the very first time MacVim is
@@ -175,7 +175,7 @@ - (id)initWithVimController:(MMVimController *)controller
175175
[win setDelegate:self];
176176
[win setInitialFirstResponder:[vimView textView]];
177177

178-
if ([win styleMask] & NSTexturedBackgroundWindowMask) {
178+
if ([win styleMask] & NSWindowStyleMaskTexturedBackground) {
179179
// On Leopard, we want to have a textured window to have nice
180180
// looking tabs. But the textured window look implies rounded
181181
// corners, which looks really weird -- disable them. This is a
@@ -1066,8 +1066,8 @@ - (IBAction)zoom:(id)sender
10661066

10671067
// Decide whether too zoom horizontally or not (always zoom vertically).
10681068
NSEvent *event = [NSApp currentEvent];
1069-
BOOL cmdLeftClick = [event type] == NSLeftMouseUp &&
1070-
[event modifierFlags] & NSCommandKeyMask;
1069+
BOOL cmdLeftClick = [event type] == NSEventTypeLeftMouseUp &&
1070+
[event modifierFlags] & NSEventModifierFlagCommand;
10711071
BOOL zoomBoth = [[NSUserDefaults standardUserDefaults]
10721072
boolForKey:MMZoomBothKey];
10731073
zoomBoth = (zoomBoth && !cmdLeftClick) || (!zoomBoth && cmdLeftClick);
@@ -1179,7 +1179,7 @@ - (void)window:(NSWindow *)window
11791179
[context setDuration:0.5*duration];
11801180
[[window animator] setAlphaValue:0];
11811181
} completionHandler:^{
1182-
[window setStyleMask:([window styleMask] | NSFullScreenWindowMask)];
1182+
[window setStyleMask:([window styleMask] | NSWindowStyleMaskFullScreen)];
11831183
NSString *tabBarStyle = [[self class] tabBarStyleForUnified];
11841184
[[vimView tabBarControl] setStyleNamed:tabBarStyle];
11851185
[self updateTablineSeparator];
@@ -1244,7 +1244,7 @@ - (void)windowDidFailToEnterFullScreen:(NSWindow *)window
12441244

12451245
fullScreenEnabled = NO;
12461246
[window setAlphaValue:1];
1247-
[window setStyleMask:([window styleMask] & ~NSFullScreenWindowMask)];
1247+
[window setStyleMask:([window styleMask] & ~NSWindowStyleMaskFullScreen)];
12481248
NSString *tabBarStyle = [[self class] tabBarStyleForMetal];
12491249
[[vimView tabBarControl] setStyleNamed:tabBarStyle];
12501250
[self updateTablineSeparator];
@@ -1275,7 +1275,7 @@ - (void)window:(NSWindow *)window
12751275
[context setDuration:0.5*duration];
12761276
[[window animator] setAlphaValue:0];
12771277
} completionHandler:^{
1278-
[window setStyleMask:([window styleMask] & ~NSFullScreenWindowMask)];
1278+
[window setStyleMask:([window styleMask] & ~NSWindowStyleMaskFullScreen)];
12791279
NSString *tabBarStyle = [[self class] tabBarStyleForMetal];
12801280
[[vimView tabBarControl] setStyleNamed:tabBarStyle];
12811281
[self updateTablineSeparator];
@@ -1323,7 +1323,7 @@ - (void)windowDidFailToExitFullScreen:(NSWindow *)window
13231323

13241324
fullScreenEnabled = YES;
13251325
[window setAlphaValue:1];
1326-
[window setStyleMask:([window styleMask] | NSFullScreenWindowMask)];
1326+
[window setStyleMask:([window styleMask] | NSWindowStyleMaskFullScreen)];
13271327
NSString *tabBarStyle = [[self class] tabBarStyleForUnified];
13281328
[[vimView tabBarControl] setStyleNamed:tabBarStyle];
13291329
[self updateTablineSeparator];
@@ -1513,7 +1513,7 @@ - (void)updateTablineSeparator
15131513
BOOL tabBarVisible = ![[vimView tabBarControl] isHidden];
15141514
BOOL toolbarHidden = [decoratedWindow toolbar] == nil;
15151515
BOOL windowTextured = ([decoratedWindow styleMask] &
1516-
NSTexturedBackgroundWindowMask) != 0;
1516+
NSWindowStyleMaskTexturedBackground) != 0;
15171517
BOOL hideSeparator = NO;
15181518

15191519
if (fullScreenEnabled || tabBarVisible)

src/MacVim/MacVim.h

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
*/
1010

1111
#import <Cocoa/Cocoa.h>
12-
#import <asl.h>
13-
1412

1513
// Taken from /usr/include/AvailabilityMacros.h
1614
#ifndef MAC_OS_X_VERSION_10_7
@@ -28,6 +26,9 @@
2826
#ifndef MAC_OS_X_VERSION_10_11
2927
# define MAC_OS_X_VERSION_10_11 101100
3028
#endif
29+
#ifndef MAC_OS_X_VERSION_10_12
30+
# define MAC_OS_X_VERSION_10_12 101200
31+
#endif
3132

3233
// Needed for pre-10.11 SDK
3334
#ifndef NSAppKitVersionNumber10_10
@@ -37,6 +38,29 @@
3738
# define NSAppKitVersionNumber10_10_Max 1349
3839
#endif
3940

41+
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
42+
// Deprecated constants in 10.12 SDK
43+
# define NSAlertStyleWarning NSWarningAlertStyle
44+
# define NSControlSizeRegular NSRegularControlSize
45+
# define NSEventModifierFlagCommand NSCommandKeyMask
46+
# define NSEventTypeLeftMouseUp NSLeftMouseUp
47+
# define NSEventTypeRightMouseDown NSRightMouseDown
48+
# define NSWindowStyleMaskClosable NSClosableWindowMask
49+
# define NSWindowStyleMaskFullScreen NSFullScreenWindowMask
50+
# define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask
51+
# define NSWindowStyleMaskResizable NSResizableWindowMask
52+
# define NSWindowStyleMaskTexturedBackground NSTexturedBackgroundWindowMask
53+
# define NSWindowStyleMaskTitled NSTitledWindowMask
54+
# define NSWindowStyleMaskUnifiedTitleAndToolbar NSUnifiedTitleAndToolbarWindowMask
55+
#endif
56+
57+
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
58+
# import <asl.h>
59+
# define MM_USE_ASL
60+
#else
61+
# import <os/log.h>
62+
#endif
63+
4064

4165
//
4266
// This is the protocol MMBackend implements.
@@ -360,7 +384,10 @@ extern int ASLogLevel;
360384

361385
void ASLInit();
362386

363-
#define ASLog(level, fmt, ...) \
387+
#if defined(MM_USE_ASL)
388+
389+
# define MM_ASL_LEVEL_DEFAULT ASL_LEVEL_NOTICE
390+
# define ASLog(level, fmt, ...) \
364391
if (level <= ASLogLevel) { \
365392
asl_log(NULL, NULL, level, "%s@%d: %s", \
366393
__PRETTY_FUNCTION__, __LINE__, \
@@ -369,10 +396,30 @@ void ASLInit();
369396

370397
// Note: These macros are used like ASLogErr(@"text num=%d", 42). Objective-C
371398
// style specifiers (%@) are supported.
372-
#define ASLogCrit(fmt, ...) ASLog(ASL_LEVEL_CRIT, fmt, ##__VA_ARGS__)
373-
#define ASLogErr(fmt, ...) ASLog(ASL_LEVEL_ERR, fmt, ##__VA_ARGS__)
374-
#define ASLogWarn(fmt, ...) ASLog(ASL_LEVEL_WARNING, fmt, ##__VA_ARGS__)
375-
#define ASLogNotice(fmt, ...) ASLog(ASL_LEVEL_NOTICE, fmt, ##__VA_ARGS__)
376-
#define ASLogInfo(fmt, ...) ASLog(ASL_LEVEL_INFO, fmt, ##__VA_ARGS__)
377-
#define ASLogDebug(fmt, ...) ASLog(ASL_LEVEL_DEBUG, fmt, ##__VA_ARGS__)
378-
#define ASLogTmp(fmt, ...) ASLog(ASL_LEVEL_NOTICE, fmt, ##__VA_ARGS__)
399+
# define ASLogCrit(fmt, ...) ASLog(ASL_LEVEL_CRIT, fmt, ##__VA_ARGS__)
400+
# define ASLogErr(fmt, ...) ASLog(ASL_LEVEL_ERR, fmt, ##__VA_ARGS__)
401+
# define ASLogWarn(fmt, ...) ASLog(ASL_LEVEL_WARNING, fmt, ##__VA_ARGS__)
402+
# define ASLogNotice(fmt, ...) ASLog(ASL_LEVEL_NOTICE, fmt, ##__VA_ARGS__)
403+
# define ASLogInfo(fmt, ...) ASLog(ASL_LEVEL_INFO, fmt, ##__VA_ARGS__)
404+
# define ASLogDebug(fmt, ...) ASLog(ASL_LEVEL_DEBUG, fmt, ##__VA_ARGS__)
405+
# define ASLogTmp(fmt, ...) ASLog(ASL_LEVEL_NOTICE, fmt, ##__VA_ARGS__)
406+
407+
#else
408+
409+
# define MM_ASL_LEVEL_DEFAULT OS_LOG_TYPE_DEFAULT
410+
# define ASLog(level, fmt, ...) \
411+
if (level <= ASLogLevel) { \
412+
os_log_with_type(OS_LOG_DEFAULT, level, "%s@%d: %s", \
413+
__PRETTY_FUNCTION__, __LINE__, \
414+
[[NSString stringWithFormat:fmt, ##__VA_ARGS__] UTF8String]); \
415+
}
416+
417+
# define ASLogCrit(fmt, ...) ASLog(OS_LOG_TYPE_FAULT, fmt, ##__VA_ARGS__)
418+
# define ASLogErr(fmt, ...) ASLog(OS_LOG_TYPE_ERROR, fmt, ##__VA_ARGS__)
419+
# define ASLogWarn(fmt, ...) ASLog(OS_LOG_TYPE_DEFAULT, fmt, ##__VA_ARGS__)
420+
# define ASLogNotice(fmt, ...) ASLog(OS_LOG_TYPE_DEFAULT, fmt, ##__VA_ARGS__)
421+
# define ASLogInfo(fmt, ...) ASLog(OS_LOG_TYPE_INFO, fmt, ##__VA_ARGS__)
422+
# define ASLogDebug(fmt, ...) ASLog(OS_LOG_TYPE_DEBUG, fmt, ##__VA_ARGS__)
423+
# define ASLogTmp(fmt, ...) ASLog(OS_LOG_TYPE_DEFAULT, fmt, ##__VA_ARGS__)
424+
425+
#endif

src/MacVim/MacVim.m

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
// Vim find pasteboard type (string contains Vim regex patterns)
125125
NSString *VimFindPboardType = @"VimFindPboardType";
126126

127-
int ASLogLevel = ASL_LEVEL_NOTICE;
127+
int ASLogLevel = MM_ASL_LEVEL_DEFAULT;
128128

129129

130130

@@ -378,17 +378,33 @@ + (id)dictionaryWithData:(NSData *)data
378378
if (logLevelObj) {
379379
int logLevel = [logLevelObj intValue];
380380
if (logLevel < 0) logLevel = 0;
381+
#if defined(MM_USE_ASL)
381382
if (logLevel > ASL_LEVEL_DEBUG) logLevel = ASL_LEVEL_DEBUG;
382-
383-
ASLogLevel = logLevel;
384383
asl_set_filter(NULL, ASL_FILTER_MASK_UPTO(logLevel));
384+
#else
385+
switch (logLevel) {
386+
case 0: case 1: case 2:
387+
logLevel = OS_LOG_TYPE_FAULT; break;
388+
case 3:
389+
logLevel = OS_LOG_TYPE_ERROR; break;
390+
case 4: case 5:
391+
logLevel = OS_LOG_TYPE_DEFAULT; break;
392+
case 6:
393+
logLevel = OS_LOG_TYPE_INFO; break;
394+
default:
395+
logLevel = OS_LOG_TYPE_DEBUG; break;
396+
}
397+
#endif
398+
ASLogLevel = logLevel;
385399
}
386400

401+
#if defined(MM_USE_ASL)
387402
// Allow for changing whether a copy of each log should be sent to stderr
388403
// (this defaults to NO if this key is missing in the user defaults
389404
// database). The above filter mask is applied to logs going to stderr,
390405
// contrary to how "vanilla" ASL works.
391406
BOOL logToStdErr = [ud boolForKey:MMLogToStdErrKey];
392407
if (logToStdErr)
393408
asl_add_log_file(NULL, 2); // The file descriptor for stderr is 2
409+
#endif
394410
}

src/MacVim/Miscellaneous.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ - (NSInteger)tag
260260
[button setAction:@selector(hiddenFilesButtonToggled:)];
261261

262262
// Use the regular control size (checkbox is a bit smaller without this)
263-
NSControlSize buttonSize = NSRegularControlSize;
263+
NSControlSize buttonSize = NSControlSizeRegular;
264264
float fontSize = [NSFont systemFontSizeForControlSize:buttonSize];
265265
NSCell *theCell = [button cell];
266266
NSFont *theFont = [NSFont fontWithName:[[theCell font] fontName]

0 commit comments

Comments
 (0)