Format .m files

This commit is contained in:
Chris Thrasher 2022-07-11 23:43:51 -06:00 committed by Lukas Dürrenberger
parent dd0f0ff4c6
commit 55a1a2a4c4
6 changed files with 53 additions and 66 deletions

View File

@ -22,7 +22,7 @@ endif()
# Run # Run
set(SOURCES "") set(SOURCES "")
foreach(FOLDER IN ITEMS examples include src test tools) foreach(FOLDER IN ITEMS examples include src test tools)
file(GLOB_RECURSE folder_files "${FOLDER}/*.h" "${FOLDER}/*.hpp" "${FOLDER}/*.inl" "${FOLDER}/*.cpp" "${FOLDER}/*.mm") file(GLOB_RECURSE folder_files "${FOLDER}/*.h" "${FOLDER}/*.hpp" "${FOLDER}/*.inl" "${FOLDER}/*.cpp" "${FOLDER}/*.mm" "${FOLDER}/*.m")
list(FILTER folder_files EXCLUDE REGEX "gl.h|vulkan.h|stb_perlin.h") # 3rd party code to exclude from formatting list(FILTER folder_files EXCLUDE REGEX "gl.h|vulkan.h|stb_perlin.h") # 3rd party code to exclude from formatting
list(APPEND SOURCES ${folder_files}) list(APPEND SOURCES ${folder_files})
endforeach() endforeach()

View File

@ -25,7 +25,7 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
int main(int argc, char *argv[]) int main(int argc, char* argv[])
{ {
return NSApplicationMain(argc, (const char **)argv); return NSApplicationMain(argc, (const char**)argv);
} }

View File

@ -29,11 +29,11 @@
#import <SFML/Window/OSX/SFApplication.h> #import <SFML/Window/OSX/SFApplication.h>
#if defined(__APPLE__) #if defined(__APPLE__)
#if defined(__clang__) #if defined(__clang__)
#pragma clang diagnostic ignored "-Wdeprecated-declarations" #pragma clang diagnostic ignored "-Wdeprecated-declarations"
#elif defined(__GNUC__) #elif defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif #endif
#endif #endif
@ -42,7 +42,7 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
+(void)processEvent + (void)processEvent
{ {
[SFApplication sharedApplication]; // Make sure NSApp exists [SFApplication sharedApplication]; // Make sure NSApp exists
NSEvent* event = nil; NSEvent* event = nil;
@ -58,7 +58,7 @@
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
+(void)setUpMenuBar + (void)setUpMenuBar
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
@ -73,17 +73,17 @@
// Application Menu (aka Apple Menu) // Application Menu (aka Apple Menu)
NSMenuItem* appleItem = [mainMenu addItemWithTitle:@"" action:nil keyEquivalent:@""]; NSMenuItem* appleItem = [mainMenu addItemWithTitle:@"" action:nil keyEquivalent:@""];
NSMenu* appleMenu = [[SFApplication newAppleMenu] autorelease]; NSMenu* appleMenu = [[SFApplication newAppleMenu] autorelease];
[appleItem setSubmenu:appleMenu]; [appleItem setSubmenu:appleMenu];
// File Menu // File Menu
NSMenuItem* fileItem = [mainMenu addItemWithTitle:@"" action:nil keyEquivalent:@""]; NSMenuItem* fileItem = [mainMenu addItemWithTitle:@"" action:nil keyEquivalent:@""];
NSMenu* fileMenu = [[SFApplication newFileMenu] autorelease]; NSMenu* fileMenu = [[SFApplication newFileMenu] autorelease];
[fileItem setSubmenu:fileMenu]; [fileItem setSubmenu:fileMenu];
// Window menu // Window menu
NSMenuItem* windowItem = [mainMenu addItemWithTitle:@"" action:nil keyEquivalent:@""]; NSMenuItem* windowItem = [mainMenu addItemWithTitle:@"" action:nil keyEquivalent:@""];
NSMenu* windowMenu = [[SFApplication newWindowMenu] autorelease]; NSMenu* windowMenu = [[SFApplication newWindowMenu] autorelease];
[windowItem setSubmenu:windowMenu]; [windowItem setSubmenu:windowMenu];
[NSApp setWindowsMenu:windowMenu]; [NSApp setWindowsMenu:windowMenu];
@ -92,7 +92,7 @@
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
+(NSMenu*)newAppleMenu + (NSMenu*)newAppleMenu
{ {
// Apple menu is as follow: // Apple menu is as follow:
// //
@ -126,18 +126,14 @@
[appleMenu addItem:[NSMenuItem separatorItem]]; [appleMenu addItem:[NSMenuItem separatorItem]];
// PREFERENCES // PREFERENCES
[appleMenu addItemWithTitle:@"Preferences..." [appleMenu addItemWithTitle:@"Preferences..." action:nil keyEquivalent:@""];
action:nil
keyEquivalent:@""];
// SEPARATOR // SEPARATOR
[appleMenu addItem:[NSMenuItem separatorItem]]; [appleMenu addItem:[NSMenuItem separatorItem]];
// SERVICES // SERVICES
NSMenu* serviceMenu = [[[NSMenu alloc] initWithTitle:@""] autorelease]; NSMenu* serviceMenu = [[[NSMenu alloc] initWithTitle:@""] autorelease];
NSMenuItem* serviceItem = [appleMenu addItemWithTitle:@"Services" NSMenuItem* serviceItem = [appleMenu addItemWithTitle:@"Services" action:nil keyEquivalent:@""];
action:nil
keyEquivalent:@""];
[serviceItem setSubmenu:serviceMenu]; [serviceItem setSubmenu:serviceMenu];
[NSApp setServicesMenu:serviceMenu]; [NSApp setServicesMenu:serviceMenu];
@ -145,20 +141,17 @@
[appleMenu addItem:[NSMenuItem separatorItem]]; [appleMenu addItem:[NSMenuItem separatorItem]];
// HIDE // HIDE
[appleMenu addItemWithTitle:[@"Hide " stringByAppendingString:appName] [appleMenu addItemWithTitle:[@"Hide " stringByAppendingString:appName] action:@selector(hide:) keyEquivalent:@"h"];
action:@selector(hide:)
keyEquivalent:@"h"];
// HIDE OTHER // HIDE OTHER
NSMenuItem* hideOtherItem = [appleMenu addItemWithTitle:@"Hide Others" NSMenuItem* hideOtherItem = [appleMenu
action:@selector(hideOtherApplications:) addItemWithTitle:@"Hide Others"
keyEquivalent:@"h"]; action:@selector(hideOtherApplications:)
keyEquivalent:@"h"];
[hideOtherItem setKeyEquivalentModifierMask:(NSAlternateKeyMask | NSCommandKeyMask)]; [hideOtherItem setKeyEquivalentModifierMask:(NSAlternateKeyMask | NSCommandKeyMask)];
// SHOW ALL // SHOW ALL
[appleMenu addItemWithTitle:@"Show All" [appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""];
action:@selector(unhideAllApplications:)
keyEquivalent:@""];
// SEPARATOR // SEPARATOR
[appleMenu addItem:[NSMenuItem separatorItem]]; [appleMenu addItem:[NSMenuItem separatorItem]];
@ -175,7 +168,7 @@
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
+(NSMenu*)newFileMenu + (NSMenu*)newFileMenu
{ {
// The File menu is as follow: // The File menu is as follow:
// //
@ -186,9 +179,10 @@
NSMenu* fileMenu = [[NSMenu alloc] initWithTitle:@"File"]; NSMenu* fileMenu = [[NSMenu alloc] initWithTitle:@"File"];
// CLOSE WINDOW // CLOSE WINDOW
NSMenuItem* closeItem = [[NSMenuItem alloc] initWithTitle:@"Close Window" NSMenuItem* closeItem = [[NSMenuItem alloc]
action:@selector(performClose:) initWithTitle:@"Close Window"
keyEquivalent:@"w"]; action:@selector(performClose:)
keyEquivalent:@"w"];
[fileMenu addItem:closeItem]; [fileMenu addItem:closeItem];
[closeItem release]; [closeItem release];
@ -197,7 +191,7 @@
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
+(NSMenu*)newWindowMenu + (NSMenu*)newWindowMenu
{ {
// The Window menu is as follow: // The Window menu is as follow:
// //
@ -211,31 +205,28 @@
NSMenu* windowMenu = [[NSMenu alloc] initWithTitle:@"Window"]; NSMenu* windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
// MINIMIZE // MINIMIZE
NSMenuItem* minimizeItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" NSMenuItem* minimizeItem = [[NSMenuItem alloc]
action:@selector(performMiniaturize:) initWithTitle:@"Minimize"
keyEquivalent:@"m"]; action:@selector(performMiniaturize:)
keyEquivalent:@"m"];
[windowMenu addItem:minimizeItem]; [windowMenu addItem:minimizeItem];
[minimizeItem release]; [minimizeItem release];
// ZOOM // ZOOM
[windowMenu addItemWithTitle:@"Zoom" [windowMenu addItemWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""];
action:@selector(performZoom:)
keyEquivalent:@""];
// SEPARATOR // SEPARATOR
[windowMenu addItem:[NSMenuItem separatorItem]]; [windowMenu addItem:[NSMenuItem separatorItem]];
// BRING ALL TO FRONT // BRING ALL TO FRONT
[windowMenu addItemWithTitle:@"Bring All to Front" [windowMenu addItemWithTitle:@"Bring All to Front" action:@selector(bringAllToFront:) keyEquivalent:@""];
action:@selector(bringAllToFront:)
keyEquivalent:@""];
return windowMenu; return windowMenu;
} }
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
+(NSString*)applicationName + (NSString*)applicationName
{ {
// First, try localized name // First, try localized name
NSString* appName = [[[NSBundle mainBundle] localizedInfoDictionary] objectForKey:@"CFBundleDisplayName"]; NSString* appName = [[[NSBundle mainBundle] localizedInfoDictionary] objectForKey:@"CFBundleDisplayName"];
@ -253,7 +244,7 @@
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
-(void)bringAllToFront:(id)sender - (void)bringAllToFront:(id)sender
{ {
(void)sender; (void)sender;
[[NSApp windows] makeObjectsPerformSelector:@selector(orderFrontRegardless)]; [[NSApp windows] makeObjectsPerformSelector:@selector(orderFrontRegardless)];
@ -261,7 +252,7 @@
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
-(void)sendEvent:(NSEvent *)anEvent - (void)sendEvent:(NSEvent*)anEvent
{ {
// Fullscreen windows have a strange behaviour with key up. To make // Fullscreen windows have a strange behaviour with key up. To make
// sure the user gets an event we call (if possible) sfKeyUp on our // sure the user gets an event we call (if possible) sfKeyUp on our
@ -278,5 +269,3 @@
@end @end

View File

@ -29,11 +29,11 @@
#import <SFML/Window/OSX/SFApplicationDelegate.h> #import <SFML/Window/OSX/SFApplicationDelegate.h>
#if defined(__APPLE__) #if defined(__APPLE__)
#if defined(__clang__) #if defined(__clang__)
#pragma clang diagnostic ignored "-Wdeprecated-declarations" #pragma clang diagnostic ignored "-Wdeprecated-declarations"
#elif defined(__GNUC__) #elif defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif #endif
#endif #endif
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -41,7 +41,7 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
-(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender
{ {
(void)sender; (void)sender;
// Generate close event for each SFML window // Generate close event for each SFML window
@ -51,7 +51,7 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
-(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)theApplication - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)theApplication
{ {
(void)theApplication; (void)theApplication;
return YES; return YES;
@ -59,4 +59,3 @@
@end @end

View File

@ -30,11 +30,10 @@
@implementation SFSilentResponder @implementation SFSilentResponder
-(void)doCommandBySelector:(SEL)sel - (void)doCommandBySelector:(SEL)sel
{ {
// Just do nothing, to prevent sound alerts // Just do nothing, to prevent sound alerts
(void)sel; (void)sel;
} }
@end @end

View File

@ -32,28 +32,28 @@
@implementation SFWindow @implementation SFWindow
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
-(BOOL)acceptsFirstResponder - (BOOL)acceptsFirstResponder
{ {
return YES; return YES;
} }
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
-(BOOL)canBecomeKeyWindow - (BOOL)canBecomeKeyWindow
{ {
return YES; return YES;
} }
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
-(BOOL)canBecomeMainWindow - (BOOL)canBecomeMainWindow
{ {
return YES; return YES;
} }
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
-(void)keyDown:(NSEvent*)theEvent - (void)keyDown:(NSEvent*)theEvent
{ {
// Do nothing except preventing a system alert each time a key is pressed // Do nothing except preventing a system alert each time a key is pressed
// //
@ -67,7 +67,7 @@
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
-(void)performClose:(id)sender - (void)performClose:(id)sender
{ {
// From Apple documentation: // From Apple documentation:
// //
@ -98,7 +98,7 @@
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
-(BOOL)validateMenuItem:(NSMenuItem*)menuItem - (BOOL)validateMenuItem:(NSMenuItem*)menuItem
{ {
return [menuItem action] == @selector(performClose:) || [super validateMenuItem:menuItem]; return [menuItem action] == @selector(performClose:) || [super validateMenuItem:menuItem];
} }
@ -110,7 +110,7 @@
@implementation NSWindow (SFML) @implementation NSWindow (SFML)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
-(id)sfClose - (id)sfClose
{ {
[self performClose:nil]; [self performClose:nil];
return nil; return nil;