Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 411f09e

Browse files
Enforce asterisk alignment for C++ and ObjC pointers (#4703)
So far we've been using the default mode of prevailing-in-file, which means we aren't consistent within each language what mode we use. Now that clang-format can identify ObjC headers (which didn't used to be the case), we can enforce different styles for the two languages. This sets left-aligned for C++ to match the Flutter engine, and right-aligned for ObjC to match the prevaling Apple style.
1 parent 36d592f commit 411f09e

File tree

81 files changed

+1037
-1028
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+1037
-1028
lines changed

.clang-format

+8
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
11
BasedOnStyle: Google
2+
---
3+
Language: Cpp
4+
DerivePointerAlignment: false
5+
PointerAlignment: Left
6+
---
7+
Language: ObjC
8+
DerivePointerAlignment: false
9+
PointerAlignment: Right

packages/camera/camera/example/ios/Runner/main.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#import <UIKit/UIKit.h>
77
#import "AppDelegate.h"
88

9-
int main(int argc, char* argv[]) {
9+
int main(int argc, char *argv[]) {
1010
@autoreleasepool {
1111
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
1212
}

packages/camera/camera/example/ios/RunnerTests/ThreadSafeFlutterResultTests.m

+20-20
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ @interface ThreadSafeFlutterResultTests : XCTestCase
1010

1111
@implementation ThreadSafeFlutterResultTests
1212
- (void)testAsyncSendSuccess_ShouldCallResultOnMainThread {
13-
XCTestExpectation* expectation = [self expectationWithDescription:@"Result finished"];
13+
XCTestExpectation *expectation = [self expectationWithDescription:@"Result finished"];
1414

15-
FLTThreadSafeFlutterResult* threadSafeFlutterResult =
15+
FLTThreadSafeFlutterResult *threadSafeFlutterResult =
1616
[[FLTThreadSafeFlutterResult alloc] initWithResult:^(id _Nullable result) {
1717
XCTAssert(NSThread.isMainThread);
1818
[expectation fulfill];
@@ -26,9 +26,9 @@ - (void)testAsyncSendSuccess_ShouldCallResultOnMainThread {
2626
}
2727

2828
- (void)testSyncSendSuccess_ShouldCallResultOnMainThread {
29-
XCTestExpectation* expectation = [self expectationWithDescription:@"Result finished"];
29+
XCTestExpectation *expectation = [self expectationWithDescription:@"Result finished"];
3030

31-
FLTThreadSafeFlutterResult* threadSafeFlutterResult =
31+
FLTThreadSafeFlutterResult *threadSafeFlutterResult =
3232
[[FLTThreadSafeFlutterResult alloc] initWithResult:^(id _Nullable result) {
3333
XCTAssert(NSThread.isMainThread);
3434
[expectation fulfill];
@@ -38,9 +38,9 @@ - (void)testSyncSendSuccess_ShouldCallResultOnMainThread {
3838
}
3939

4040
- (void)testSendNotImplemented_ShouldSendNotImplementedToFlutterResult {
41-
XCTestExpectation* expectation = [self expectationWithDescription:@"Result finished"];
41+
XCTestExpectation *expectation = [self expectationWithDescription:@"Result finished"];
4242

43-
FLTThreadSafeFlutterResult* threadSafeFlutterResult =
43+
FLTThreadSafeFlutterResult *threadSafeFlutterResult =
4444
[[FLTThreadSafeFlutterResult alloc] initWithResult:^(id _Nullable result) {
4545
XCTAssert([result isKindOfClass:FlutterMethodNotImplemented.class]);
4646
[expectation fulfill];
@@ -54,15 +54,15 @@ - (void)testSendNotImplemented_ShouldSendNotImplementedToFlutterResult {
5454
}
5555

5656
- (void)testSendErrorDetails_ShouldSendErrorToFlutterResult {
57-
NSString* errorCode = @"errorCode";
58-
NSString* errorMessage = @"message";
59-
NSString* errorDetails = @"error details";
60-
XCTestExpectation* expectation = [self expectationWithDescription:@"Result finished"];
57+
NSString *errorCode = @"errorCode";
58+
NSString *errorMessage = @"message";
59+
NSString *errorDetails = @"error details";
60+
XCTestExpectation *expectation = [self expectationWithDescription:@"Result finished"];
6161

62-
FLTThreadSafeFlutterResult* threadSafeFlutterResult =
62+
FLTThreadSafeFlutterResult *threadSafeFlutterResult =
6363
[[FLTThreadSafeFlutterResult alloc] initWithResult:^(id _Nullable result) {
6464
XCTAssert([result isKindOfClass:FlutterError.class]);
65-
FlutterError* error = (FlutterError*)result;
65+
FlutterError *error = (FlutterError *)result;
6666
XCTAssertEqualObjects(error.code, errorCode);
6767
XCTAssertEqualObjects(error.message, errorMessage);
6868
XCTAssertEqualObjects(error.details, errorDetails);
@@ -77,14 +77,14 @@ - (void)testSendErrorDetails_ShouldSendErrorToFlutterResult {
7777
}
7878

7979
- (void)testSendNSError_ShouldSendErrorToFlutterResult {
80-
NSError* originalError = [[NSError alloc] initWithDomain:NSURLErrorDomain code:404 userInfo:nil];
81-
XCTestExpectation* expectation = [self expectationWithDescription:@"Result finished"];
80+
NSError *originalError = [[NSError alloc] initWithDomain:NSURLErrorDomain code:404 userInfo:nil];
81+
XCTestExpectation *expectation = [self expectationWithDescription:@"Result finished"];
8282

83-
FLTThreadSafeFlutterResult* threadSafeFlutterResult =
83+
FLTThreadSafeFlutterResult *threadSafeFlutterResult =
8484
[[FLTThreadSafeFlutterResult alloc] initWithResult:^(id _Nullable result) {
8585
XCTAssert([result isKindOfClass:FlutterError.class]);
86-
FlutterError* error = (FlutterError*)result;
87-
NSString* constructedErrorCode =
86+
FlutterError *error = (FlutterError *)result;
87+
NSString *constructedErrorCode =
8888
[NSString stringWithFormat:@"Error %d", (int)originalError.code];
8989
XCTAssertEqualObjects(error.code, constructedErrorCode);
9090
[expectation fulfill];
@@ -98,10 +98,10 @@ - (void)testSendNSError_ShouldSendErrorToFlutterResult {
9898
}
9999

100100
- (void)testSendResult_ShouldSendResultToFlutterResult {
101-
NSString* resultData = @"resultData";
102-
XCTestExpectation* expectation = [self expectationWithDescription:@"Result finished"];
101+
NSString *resultData = @"resultData";
102+
XCTestExpectation *expectation = [self expectationWithDescription:@"Result finished"];
103103

104-
FLTThreadSafeFlutterResult* threadSafeFlutterResult =
104+
FLTThreadSafeFlutterResult *threadSafeFlutterResult =
105105
[[FLTThreadSafeFlutterResult alloc] initWithResult:^(id _Nullable result) {
106106
XCTAssertEqualObjects(result, resultData);
107107
[expectation fulfill];

packages/camera/camera/ios/Classes/FLTThreadSafeFlutterResult.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@
3636
* Sends an NSError as result on the main thread.
3737
* @param error Error that will be send as FlutterError.
3838
*/
39-
- (void)sendError:(nonnull NSError*)error;
39+
- (void)sendError:(nonnull NSError *)error;
4040

4141
/**
4242
* Sends a FlutterError as result on the main thread.
4343
*/
44-
- (void)sendErrorWithCode:(nonnull NSString*)code
45-
message:(nullable NSString*)message
44+
- (void)sendErrorWithCode:(nonnull NSString *)code
45+
message:(nullable NSString *)message
4646
details:(nullable id)details;
4747

4848
/**

packages/camera/camera/ios/Classes/FLTThreadSafeFlutterResult.m

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ - (void)sendSuccessWithData:(id)data {
2626
[self send:data];
2727
}
2828

29-
- (void)sendError:(NSError*)error {
29+
- (void)sendError:(NSError *)error {
3030
[self sendErrorWithCode:[NSString stringWithFormat:@"Error %d", (int)error.code]
3131
message:error.localizedDescription
3232
details:error.domain];
3333
}
3434

35-
- (void)sendErrorWithCode:(NSString*)code
36-
message:(NSString* _Nullable)message
35+
- (void)sendErrorWithCode:(NSString *)code
36+
message:(NSString *_Nullable)message
3737
details:(id _Nullable)details {
38-
FlutterError* flutterError = [FlutterError errorWithCode:code message:message details:details];
38+
FlutterError *flutterError = [FlutterError errorWithCode:code message:message details:details];
3939
[self send:flutterError];
4040
}
4141

packages/file_selector/file_selector/example/windows/runner/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "utils.h"
1111

1212
int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
13-
_In_ wchar_t *command_line, _In_ int show_command) {
13+
_In_ wchar_t* command_line, _In_ int show_command) {
1414
// Attach to console when present (e.g., 'flutter run') or create a
1515
// new console when running with a debugger.
1616
if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {

packages/google_maps_flutter/google_maps_flutter/example/ios/Runner/AppDelegate.m

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
@implementation AppDelegate
1111

12-
- (BOOL)application:(UIApplication*)application
13-
didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
12+
- (BOOL)application:(UIApplication *)application
13+
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
1414
// Provide the GoogleMaps API key.
15-
NSString* mapsApiKey = [[NSProcessInfo processInfo] environment][@"MAPS_API_KEY"];
15+
NSString *mapsApiKey = [[NSProcessInfo processInfo] environment][@"MAPS_API_KEY"];
1616
if ([mapsApiKey length] == 0) {
1717
mapsApiKey = @"YOUR KEY HERE";
1818
}

packages/google_maps_flutter/google_maps_flutter/example/ios/Runner/main.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#import <UIKit/UIKit.h>
77
#import "AppDelegate.h"
88

9-
int main(int argc, char* argv[]) {
9+
int main(int argc, char *argv[]) {
1010
@autoreleasepool {
1111
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
1212
}

packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/GoogleMapsTests.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ @interface GoogleMapsTests : XCTestCase
1111
@implementation GoogleMapsTests
1212

1313
- (void)testPlugin {
14-
FLTGoogleMapsPlugin* plugin = [[FLTGoogleMapsPlugin alloc] init];
14+
FLTGoogleMapsPlugin *plugin = [[FLTGoogleMapsPlugin alloc] init];
1515
XCTAssertNotNil(plugin);
1616
}
1717

packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerUITests/GoogleMapsUITests.m

+17-17
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
@import os.log;
77

88
@interface GoogleMapsUITests : XCTestCase
9-
@property(nonatomic, strong) XCUIApplication* app;
9+
@property(nonatomic, strong) XCUIApplication *app;
1010
@end
1111

1212
@implementation GoogleMapsUITests
@@ -21,9 +21,9 @@ - (void)setUp {
2121
// See: https://github.com/flutter/flutter/issues/93325.
2222
[self
2323
addUIInterruptionMonitorWithDescription:@"Permission popups"
24-
handler:^BOOL(XCUIElement* _Nonnull interruptingElement) {
24+
handler:^BOOL(XCUIElement *_Nonnull interruptingElement) {
2525
if (@available(iOS 14, *)) {
26-
XCUIElement* locationPermission =
26+
XCUIElement *locationPermission =
2727
interruptingElement.buttons[@"Allow While Using App"];
2828
if (![locationPermission
2929
waitForExistenceWithTimeout:30.0]) {
@@ -33,7 +33,7 @@ - (void)setUp {
3333
[locationPermission tap];
3434

3535
} else {
36-
XCUIElement* allow =
36+
XCUIElement *allow =
3737
interruptingElement.buttons[@"Allow"];
3838
if (![allow waitForExistenceWithTimeout:30.0]) {
3939
XCTFail(@"Failed due to not able to find Allow button");
@@ -46,19 +46,19 @@ - (void)setUp {
4646

4747
// Temporarily disabled due to https://github.com/flutter/flutter/issues/93325
4848
- (void)skip_testUserInterface {
49-
XCUIApplication* app = self.app;
50-
XCUIElement* userInteface = app.staticTexts[@"User interface"];
49+
XCUIApplication *app = self.app;
50+
XCUIElement *userInteface = app.staticTexts[@"User interface"];
5151
if (![userInteface waitForExistenceWithTimeout:30.0]) {
5252
os_log_error(OS_LOG_DEFAULT, "%@", app.debugDescription);
5353
XCTFail(@"Failed due to not able to find User interface");
5454
}
5555
[userInteface tap];
56-
XCUIElement* platformView = app.otherElements[@"platform_view[0]"];
56+
XCUIElement *platformView = app.otherElements[@"platform_view[0]"];
5757
if (![platformView waitForExistenceWithTimeout:30.0]) {
5858
os_log_error(OS_LOG_DEFAULT, "%@", app.debugDescription);
5959
XCTFail(@"Failed due to not able to find platform view");
6060
}
61-
XCUIElement* compass = app.buttons[@"disable compass"];
61+
XCUIElement *compass = app.buttons[@"disable compass"];
6262
if (![compass waitForExistenceWithTimeout:30.0]) {
6363
os_log_error(OS_LOG_DEFAULT, "%@", app.debugDescription);
6464
XCTFail(@"Failed due to not able to find compass button");
@@ -67,21 +67,21 @@ - (void)skip_testUserInterface {
6767
}
6868

6969
- (void)testMapCoordinatesPage {
70-
XCUIApplication* app = self.app;
71-
XCUIElement* mapCoordinates = app.staticTexts[@"Map coordinates"];
70+
XCUIApplication *app = self.app;
71+
XCUIElement *mapCoordinates = app.staticTexts[@"Map coordinates"];
7272
if (![mapCoordinates waitForExistenceWithTimeout:30.0]) {
7373
os_log_error(OS_LOG_DEFAULT, "%@", app.debugDescription);
7474
XCTFail(@"Failed due to not able to find 'Map coordinates''");
7575
}
7676
[mapCoordinates tap];
7777

78-
XCUIElement* platformView = app.otherElements[@"platform_view[0]"];
78+
XCUIElement *platformView = app.otherElements[@"platform_view[0]"];
7979
if (![platformView waitForExistenceWithTimeout:30.0]) {
8080
os_log_error(OS_LOG_DEFAULT, "%@", app.debugDescription);
8181
XCTFail(@"Failed due to not able to find platform view");
8282
}
8383

84-
XCUIElement* getVisibleRegionBoundsButton = app.buttons[@"Get Visible Region Bounds"];
84+
XCUIElement *getVisibleRegionBoundsButton = app.buttons[@"Get Visible Region Bounds"];
8585
if (![getVisibleRegionBoundsButton waitForExistenceWithTimeout:30.0]) {
8686
os_log_error(OS_LOG_DEFAULT, "%@", app.debugDescription);
8787
XCTFail(@"Failed due to not able to find 'Get Visible Region Bounds''");
@@ -90,31 +90,31 @@ - (void)testMapCoordinatesPage {
9090
}
9191

9292
- (void)testMapClickPage {
93-
XCUIApplication* app = self.app;
94-
XCUIElement* mapClick = app.staticTexts[@"Map click"];
93+
XCUIApplication *app = self.app;
94+
XCUIElement *mapClick = app.staticTexts[@"Map click"];
9595
if (![mapClick waitForExistenceWithTimeout:30.0]) {
9696
os_log_error(OS_LOG_DEFAULT, "%@", app.debugDescription);
9797
XCTFail(@"Failed due to not able to find 'Map click''");
9898
}
9999
[mapClick tap];
100100

101-
XCUIElement* platformView = app.otherElements[@"platform_view[0]"];
101+
XCUIElement *platformView = app.otherElements[@"platform_view[0]"];
102102
if (![platformView waitForExistenceWithTimeout:30.0]) {
103103
os_log_error(OS_LOG_DEFAULT, "%@", app.debugDescription);
104104
XCTFail(@"Failed due to not able to find platform view");
105105
}
106106

107107
[platformView tap];
108108

109-
XCUIElement* tapped = app.staticTexts[@"Tapped"];
109+
XCUIElement *tapped = app.staticTexts[@"Tapped"];
110110
if (![tapped waitForExistenceWithTimeout:30.0]) {
111111
os_log_error(OS_LOG_DEFAULT, "%@", app.debugDescription);
112112
XCTFail(@"Failed due to not able to find 'tapped''");
113113
}
114114

115115
[platformView pressForDuration:5.0];
116116

117-
XCUIElement* longPressed = app.staticTexts[@"Long pressed"];
117+
XCUIElement *longPressed = app.staticTexts[@"Long pressed"];
118118
if (![longPressed waitForExistenceWithTimeout:30.0]) {
119119
os_log_error(OS_LOG_DEFAULT, "%@", app.debugDescription);
120120
XCTFail(@"Failed due to not able to find 'longPressed''");

0 commit comments

Comments
 (0)