From 55a1a2a4c438bba2bf2286d7ddcbde0f6933e5ac Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Mon, 11 Jul 2022 23:43:51 -0600 Subject: [PATCH] Format .m files --- cmake/Format.cmake | 2 +- examples/cocoa/main.m | 4 +- src/SFML/Window/OSX/SFApplication.m | 81 +++++++++------------ src/SFML/Window/OSX/SFApplicationDelegate.m | 15 ++-- src/SFML/Window/OSX/SFSilentResponder.m | 3 +- src/SFML/Window/OSX/SFWindow.m | 14 ++-- 6 files changed, 53 insertions(+), 66 deletions(-) diff --git a/cmake/Format.cmake b/cmake/Format.cmake index bd6609c6a..92d84533a 100644 --- a/cmake/Format.cmake +++ b/cmake/Format.cmake @@ -22,7 +22,7 @@ endif() # Run set(SOURCES "") 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(APPEND SOURCES ${folder_files}) endforeach() diff --git a/examples/cocoa/main.m b/examples/cocoa/main.m index 8b8f1f964..e8c0799ef 100644 --- a/examples/cocoa/main.m +++ b/examples/cocoa/main.m @@ -25,7 +25,7 @@ #import -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { - return NSApplicationMain(argc, (const char **)argv); + return NSApplicationMain(argc, (const char**)argv); } diff --git a/src/SFML/Window/OSX/SFApplication.m b/src/SFML/Window/OSX/SFApplication.m index 240e37b48..20a5466ab 100644 --- a/src/SFML/Window/OSX/SFApplication.m +++ b/src/SFML/Window/OSX/SFApplication.m @@ -29,11 +29,11 @@ #import #if defined(__APPLE__) - #if defined(__clang__) - #pragma clang diagnostic ignored "-Wdeprecated-declarations" - #elif defined(__GNUC__) - #pragma GCC diagnostic ignored "-Wdeprecated-declarations" - #endif +#if defined(__clang__) +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#elif defined(__GNUC__) +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif #endif @@ -42,7 +42,7 @@ //////////////////////////////////////////////////////////// -+(void)processEvent ++ (void)processEvent { [SFApplication sharedApplication]; // Make sure NSApp exists NSEvent* event = nil; @@ -58,7 +58,7 @@ //////////////////////////////////////////////////////// -+(void)setUpMenuBar ++ (void)setUpMenuBar { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -73,17 +73,17 @@ // Application Menu (aka Apple Menu) NSMenuItem* appleItem = [mainMenu addItemWithTitle:@"" action:nil keyEquivalent:@""]; - NSMenu* appleMenu = [[SFApplication newAppleMenu] autorelease]; + NSMenu* appleMenu = [[SFApplication newAppleMenu] autorelease]; [appleItem setSubmenu:appleMenu]; // File Menu NSMenuItem* fileItem = [mainMenu addItemWithTitle:@"" action:nil keyEquivalent:@""]; - NSMenu* fileMenu = [[SFApplication newFileMenu] autorelease]; + NSMenu* fileMenu = [[SFApplication newFileMenu] autorelease]; [fileItem setSubmenu:fileMenu]; // Window menu NSMenuItem* windowItem = [mainMenu addItemWithTitle:@"" action:nil keyEquivalent:@""]; - NSMenu* windowMenu = [[SFApplication newWindowMenu] autorelease]; + NSMenu* windowMenu = [[SFApplication newWindowMenu] autorelease]; [windowItem setSubmenu:windowMenu]; [NSApp setWindowsMenu:windowMenu]; @@ -92,7 +92,7 @@ //////////////////////////////////////////////////////// -+(NSMenu*)newAppleMenu ++ (NSMenu*)newAppleMenu { // Apple menu is as follow: // @@ -126,18 +126,14 @@ [appleMenu addItem:[NSMenuItem separatorItem]]; // PREFERENCES - [appleMenu addItemWithTitle:@"Preferences..." - action:nil - keyEquivalent:@""]; + [appleMenu addItemWithTitle:@"Preferences..." action:nil keyEquivalent:@""]; // SEPARATOR [appleMenu addItem:[NSMenuItem separatorItem]]; // SERVICES - NSMenu* serviceMenu = [[[NSMenu alloc] initWithTitle:@""] autorelease]; - NSMenuItem* serviceItem = [appleMenu addItemWithTitle:@"Services" - action:nil - keyEquivalent:@""]; + NSMenu* serviceMenu = [[[NSMenu alloc] initWithTitle:@""] autorelease]; + NSMenuItem* serviceItem = [appleMenu addItemWithTitle:@"Services" action:nil keyEquivalent:@""]; [serviceItem setSubmenu:serviceMenu]; [NSApp setServicesMenu:serviceMenu]; @@ -145,20 +141,17 @@ [appleMenu addItem:[NSMenuItem separatorItem]]; // HIDE - [appleMenu addItemWithTitle:[@"Hide " stringByAppendingString:appName] - action:@selector(hide:) - keyEquivalent:@"h"]; + [appleMenu addItemWithTitle:[@"Hide " stringByAppendingString:appName] action:@selector(hide:) keyEquivalent:@"h"]; // HIDE OTHER - NSMenuItem* hideOtherItem = [appleMenu addItemWithTitle:@"Hide Others" - action:@selector(hideOtherApplications:) - keyEquivalent:@"h"]; + NSMenuItem* hideOtherItem = [appleMenu + addItemWithTitle:@"Hide Others" + action:@selector(hideOtherApplications:) + keyEquivalent:@"h"]; [hideOtherItem setKeyEquivalentModifierMask:(NSAlternateKeyMask | NSCommandKeyMask)]; // SHOW ALL - [appleMenu addItemWithTitle:@"Show All" - action:@selector(unhideAllApplications:) - keyEquivalent:@""]; + [appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""]; // SEPARATOR [appleMenu addItem:[NSMenuItem separatorItem]]; @@ -175,7 +168,7 @@ //////////////////////////////////////////////////////// -+(NSMenu*)newFileMenu ++ (NSMenu*)newFileMenu { // The File menu is as follow: // @@ -186,9 +179,10 @@ NSMenu* fileMenu = [[NSMenu alloc] initWithTitle:@"File"]; // CLOSE WINDOW - NSMenuItem* closeItem = [[NSMenuItem alloc] initWithTitle:@"Close Window" - action:@selector(performClose:) - keyEquivalent:@"w"]; + NSMenuItem* closeItem = [[NSMenuItem alloc] + initWithTitle:@"Close Window" + action:@selector(performClose:) + keyEquivalent:@"w"]; [fileMenu addItem:closeItem]; [closeItem release]; @@ -197,7 +191,7 @@ //////////////////////////////////////////////////////// -+(NSMenu*)newWindowMenu ++ (NSMenu*)newWindowMenu { // The Window menu is as follow: // @@ -211,31 +205,28 @@ NSMenu* windowMenu = [[NSMenu alloc] initWithTitle:@"Window"]; // MINIMIZE - NSMenuItem* minimizeItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" - action:@selector(performMiniaturize:) - keyEquivalent:@"m"]; + NSMenuItem* minimizeItem = [[NSMenuItem alloc] + initWithTitle:@"Minimize" + action:@selector(performMiniaturize:) + keyEquivalent:@"m"]; [windowMenu addItem:minimizeItem]; [minimizeItem release]; // ZOOM - [windowMenu addItemWithTitle:@"Zoom" - action:@selector(performZoom:) - keyEquivalent:@""]; + [windowMenu addItemWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""]; // SEPARATOR [windowMenu addItem:[NSMenuItem separatorItem]]; // BRING ALL TO FRONT - [windowMenu addItemWithTitle:@"Bring All to Front" - action:@selector(bringAllToFront:) - keyEquivalent:@""]; + [windowMenu addItemWithTitle:@"Bring All to Front" action:@selector(bringAllToFront:) keyEquivalent:@""]; return windowMenu; } //////////////////////////////////////////////////////// -+(NSString*)applicationName ++ (NSString*)applicationName { // First, try localized name NSString* appName = [[[NSBundle mainBundle] localizedInfoDictionary] objectForKey:@"CFBundleDisplayName"]; @@ -253,7 +244,7 @@ //////////////////////////////////////////////////////// --(void)bringAllToFront:(id)sender +- (void)bringAllToFront:(id)sender { (void)sender; [[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 // sure the user gets an event we call (if possible) sfKeyUp on our @@ -278,5 +269,3 @@ @end - - diff --git a/src/SFML/Window/OSX/SFApplicationDelegate.m b/src/SFML/Window/OSX/SFApplicationDelegate.m index cbdfa9637..df10351b5 100644 --- a/src/SFML/Window/OSX/SFApplicationDelegate.m +++ b/src/SFML/Window/OSX/SFApplicationDelegate.m @@ -29,11 +29,11 @@ #import #if defined(__APPLE__) - #if defined(__clang__) - #pragma clang diagnostic ignored "-Wdeprecated-declarations" - #elif defined(__GNUC__) - #pragma GCC diagnostic ignored "-Wdeprecated-declarations" - #endif +#if defined(__clang__) +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#elif defined(__GNUC__) +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif #endif //////////////////////////////////////////////////////////// @@ -41,7 +41,7 @@ //////////////////////////////////////////////////////////// --(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender +- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender { (void)sender; // Generate close event for each SFML window @@ -51,7 +51,7 @@ //////////////////////////////////////////////////////////// --(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)theApplication +- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)theApplication { (void)theApplication; return YES; @@ -59,4 +59,3 @@ @end - diff --git a/src/SFML/Window/OSX/SFSilentResponder.m b/src/SFML/Window/OSX/SFSilentResponder.m index f1a1adfe8..de3cd8139 100644 --- a/src/SFML/Window/OSX/SFSilentResponder.m +++ b/src/SFML/Window/OSX/SFSilentResponder.m @@ -30,11 +30,10 @@ @implementation SFSilentResponder --(void)doCommandBySelector:(SEL)sel +- (void)doCommandBySelector:(SEL)sel { // Just do nothing, to prevent sound alerts (void)sel; } @end - diff --git a/src/SFML/Window/OSX/SFWindow.m b/src/SFML/Window/OSX/SFWindow.m index ee33e2339..a6c612db0 100644 --- a/src/SFML/Window/OSX/SFWindow.m +++ b/src/SFML/Window/OSX/SFWindow.m @@ -32,28 +32,28 @@ @implementation SFWindow //////////////////////////////////////////////////////// --(BOOL)acceptsFirstResponder +- (BOOL)acceptsFirstResponder { return YES; } //////////////////////////////////////////////////////// --(BOOL)canBecomeKeyWindow +- (BOOL)canBecomeKeyWindow { return YES; } //////////////////////////////////////////////////////// --(BOOL)canBecomeMainWindow +- (BOOL)canBecomeMainWindow { return YES; } //////////////////////////////////////////////////////// --(void)keyDown:(NSEvent*)theEvent +- (void)keyDown:(NSEvent*)theEvent { // 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: // @@ -98,7 +98,7 @@ //////////////////////////////////////////////////////// --(BOOL)validateMenuItem:(NSMenuItem*)menuItem +- (BOOL)validateMenuItem:(NSMenuItem*)menuItem { return [menuItem action] == @selector(performClose:) || [super validateMenuItem:menuItem]; } @@ -110,7 +110,7 @@ @implementation NSWindow (SFML) //////////////////////////////////////////////////////////// --(id)sfClose +- (id)sfClose { [self performClose:nil]; return nil;