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

Commit f5a7a08

Browse files
authored
Update Objective-C column limit to 100 (#3585)
The Google style guide specifies a limit of 100 columns. https://google.github.io/styleguide/objcguide.xml?showone=Line_Length#Line_Length The Chromium style guide specifies 80. https://chromium.googlesource.com/chromium/src/+/master/styleguide/objective-c/objective-c.md
1 parent 1084a83 commit f5a7a08

29 files changed

+333
-537
lines changed

.clang-format

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ BasedOnStyle: Chromium
77
# 'int>>' if the file already contains at least one such instance.)
88
Standard: Cpp11
99
SortIncludes: true
10+
---
11+
Language: ObjC
12+
ColumnLimit: 100

fml/platform/darwin/message_loop_darwin.mm

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
CFRunLoopTimerContext timer_context = {
2020
.info = this,
2121
};
22-
delayed_wake_timer_.Reset(CFRunLoopTimerCreate(
23-
kCFAllocatorDefault, kDistantFuture /* fire date */,
24-
HUGE_VAL /* interval */, 0 /* flags */, 0 /* order */,
25-
reinterpret_cast<CFRunLoopTimerCallBack>(&MessageLoopDarwin::OnTimerFire)
26-
/* callout */,
27-
&timer_context /* context */));
22+
delayed_wake_timer_.Reset(
23+
CFRunLoopTimerCreate(kCFAllocatorDefault, kDistantFuture /* fire date */,
24+
HUGE_VAL /* interval */, 0 /* flags */, 0 /* order */,
25+
reinterpret_cast<CFRunLoopTimerCallBack>(&MessageLoopDarwin::OnTimerFire)
26+
/* callout */,
27+
&timer_context /* context */));
2828
FTL_DCHECK(delayed_wake_timer_ != nullptr);
2929
CFRunLoopAddTimer(loop_, delayed_wake_timer_, kCFRunLoopCommonModes);
3030
}
@@ -41,8 +41,7 @@
4141

4242
while (running_) {
4343
@autoreleasepool {
44-
int result =
45-
CFRunLoopRunInMode(kCFRunLoopDefaultMode, kDistantFuture, YES);
44+
int result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, kDistantFuture, YES);
4645
if (result == kCFRunLoopRunStopped || result == kCFRunLoopRunFinished) {
4746
// This handles the case where the loop is terminated using
4847
// CoreFoundation APIs.
@@ -65,12 +64,10 @@
6564
// different and must be accounted for.
6665
CFRunLoopTimerSetNextFireDate(
6766
delayed_wake_timer_,
68-
CFAbsoluteTimeGetCurrent() +
69-
(time_point - ftl::TimePoint::Now()).ToSecondsF());
67+
CFAbsoluteTimeGetCurrent() + (time_point - ftl::TimePoint::Now()).ToSecondsF());
7068
}
7169

72-
void MessageLoopDarwin::OnTimerFire(CFRunLoopTimerRef timer,
73-
MessageLoopDarwin* loop) {
70+
void MessageLoopDarwin::OnTimerFire(CFRunLoopTimerRef timer, MessageLoopDarwin* loop) {
7471
@autoreleasepool {
7572
// RunExpiredTasksNow rearms the timer as appropriate via a call to WakeUp.
7673
loop->RunExpiredTasksNow();

fml/platform/darwin/paths_darwin.mm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
namespace paths {
1313

1414
std::pair<bool, std::string> GetExecutableDirectoryPath() {
15-
return {true, files::GetDirectoryName(
16-
[NSBundle mainBundle].executablePath.UTF8String)};
15+
return {true, files::GetDirectoryName([NSBundle mainBundle].executablePath.UTF8String)};
1716
}
1817

1918
} // namespace paths

fml/platform/darwin/resource_mapping_darwin.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
namespace fml {
1010

1111
ResourceMappingDarwin::ResourceMappingDarwin(const std::string& resource)
12-
: actual_([[[NSBundle mainBundle] pathForResource:@(resource.c_str())
13-
ofType:nil] UTF8String]) {}
12+
: actual_([[[NSBundle mainBundle] pathForResource:@(resource.c_str()) ofType:nil] UTF8String]) {
13+
}
1414

1515
ResourceMappingDarwin::~ResourceMappingDarwin() = default;
1616

shell/platform/darwin/common/platform_mac.mm

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,14 @@
2020

2121
namespace shell {
2222

23-
static void RedirectIOConnectionsToSyslog(
24-
const ftl::CommandLine& command_line) {
23+
static void RedirectIOConnectionsToSyslog(const ftl::CommandLine& command_line) {
2524
#if TARGET_OS_IPHONE
2625
if (command_line.HasOption(FlagForSwitch(Switch::NoRedirectToSyslog))) {
2726
return;
2827
}
2928

30-
asl_log_descriptor(NULL, NULL, ASL_LEVEL_NOTICE, STDOUT_FILENO,
31-
ASL_LOG_DESCRIPTOR_WRITE);
32-
asl_log_descriptor(NULL, NULL, ASL_LEVEL_WARNING, STDERR_FILENO,
33-
ASL_LOG_DESCRIPTOR_WRITE);
29+
asl_log_descriptor(NULL, NULL, ASL_LEVEL_NOTICE, STDOUT_FILENO, ASL_LOG_DESCRIPTOR_WRITE);
30+
asl_log_descriptor(NULL, NULL, ASL_LEVEL_WARNING, STDERR_FILENO, ASL_LOG_DESCRIPTOR_WRITE);
3431
#endif
3532
}
3633

@@ -46,8 +43,7 @@ static void RedirectIOConnectionsToSyslog(
4643

4744
class EmbedderState {
4845
public:
49-
EmbedderState(std::string icu_data_path,
50-
std::string application_library_path) {
46+
EmbedderState(std::string icu_data_path, std::string application_library_path) {
5147
#if TARGET_OS_IPHONE
5248
// This calls crashes on MacOS because we haven't run Dart_Initialize yet.
5349
// See https://github.com/flutter/flutter/issues/4006
@@ -64,8 +60,7 @@ static void RedirectIOConnectionsToSyslog(
6460
// marker that can be used as a reference for startup.
6561
TRACE_EVENT_INSTANT0("flutter", "main");
6662

67-
shell::Shell::InitStandalone(std::move(command_line), icu_data_path,
68-
application_library_path);
63+
shell::Shell::InitStandalone(std::move(command_line), icu_data_path, application_library_path);
6964
}
7065

7166
~EmbedderState() {}
@@ -74,14 +69,12 @@ static void RedirectIOConnectionsToSyslog(
7469
FTL_DISALLOW_COPY_AND_ASSIGN(EmbedderState);
7570
};
7671

77-
void PlatformMacMain(std::string icu_data_path,
78-
std::string application_library_path) {
72+
void PlatformMacMain(std::string icu_data_path, std::string application_library_path) {
7973
static std::unique_ptr<EmbedderState> g_embedder;
8074
static std::once_flag once_main;
8175

8276
std::call_once(once_main, [&]() {
83-
g_embedder =
84-
WTF::MakeUnique<EmbedderState>(icu_data_path, application_library_path);
77+
g_embedder = WTF::MakeUnique<EmbedderState>(icu_data_path, application_library_path);
8578
});
8679
}
8780

@@ -150,12 +143,9 @@ bool AttemptLaunchFromCommandLineSwitches(Engine* engine) {
150143
[defaults synchronize];
151144
}
152145

153-
std::string bundle_path =
154-
ResolveCommandLineLaunchFlag(FlagForSwitch(Switch::FLX));
155-
std::string main =
156-
ResolveCommandLineLaunchFlag(FlagForSwitch(Switch::MainDartFile));
157-
std::string packages =
158-
ResolveCommandLineLaunchFlag(FlagForSwitch(Switch::Packages));
146+
std::string bundle_path = ResolveCommandLineLaunchFlag(FlagForSwitch(Switch::FLX));
147+
std::string main = ResolveCommandLineLaunchFlag(FlagForSwitch(Switch::MainDartFile));
148+
std::string packages = ResolveCommandLineLaunchFlag(FlagForSwitch(Switch::Packages));
159149

160150
if (!FlagsValidForCommandLineLaunch(bundle_path, main, packages)) {
161151
return false;
@@ -164,20 +154,16 @@ bool AttemptLaunchFromCommandLineSwitches(Engine* engine) {
164154
// Save the newly resolved dart main file and the package root to user
165155
// defaults so that the next time the user launches the application in the
166156
// simulator without the tooling, the application boots up.
167-
[defaults setObject:@(bundle_path.c_str())
168-
forKey:@(FlagForSwitch(Switch::FLX))];
169-
[defaults setObject:@(main.c_str())
170-
forKey:@(FlagForSwitch(Switch::MainDartFile))];
171-
[defaults setObject:@(packages.c_str())
172-
forKey:@(FlagForSwitch(Switch::Packages))];
157+
[defaults setObject:@(bundle_path.c_str()) forKey:@(FlagForSwitch(Switch::FLX))];
158+
[defaults setObject:@(main.c_str()) forKey:@(FlagForSwitch(Switch::MainDartFile))];
159+
[defaults setObject:@(packages.c_str()) forKey:@(FlagForSwitch(Switch::Packages))];
173160

174161
[defaults synchronize];
175162

176-
blink::Threads::UI()->PostTask(
177-
[ engine = engine->GetWeakPtr(), bundle_path, main, packages ] {
178-
if (engine)
179-
engine->RunBundleAndSource(bundle_path, main, packages);
180-
});
163+
blink::Threads::UI()->PostTask([ engine = engine->GetWeakPtr(), bundle_path, main, packages ] {
164+
if (engine)
165+
engine->RunBundleAndSource(bundle_path, main, packages);
166+
});
181167

182168
return true;
183169
}

shell/platform/darwin/desktop/flutter_window.mm

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ @interface FlutterWindow ()<NSWindowDelegate>
1515

1616
@end
1717

18-
static inline blink::PointerData::Change PointerChangeFromNSEventPhase(
19-
NSEventPhase phase) {
18+
static inline blink::PointerData::Change PointerChangeFromNSEventPhase(NSEventPhase phase) {
2019
switch (phase) {
2120
case NSEventPhaseNone:
2221
return blink::PointerData::Change::kCancel;
@@ -54,13 +53,11 @@ - (void)awakeFromNib {
5453
}
5554

5655
- (void)setupPlatformView {
57-
FTL_DCHECK(_platformView == nullptr)
58-
<< "The platform view must not already be set.";
56+
FTL_DCHECK(_platformView == nullptr) << "The platform view must not already be set.";
5957

6058
_platformView.reset(new shell::PlatformViewMac(self.renderSurface));
6159
_platformView->SetupResourceContextOnIOThread();
62-
_platformView->NotifyCreated(
63-
std::make_unique<shell::GPUSurfaceGL>(_platformView.get()));
60+
_platformView->NotifyCreated(std::make_unique<shell::GPUSurfaceGL>(_platformView.get()));
6461
}
6562

6663
// TODO(eseidel): This does not belong in flutter_window!
@@ -81,12 +78,11 @@ - (void)updateWindowSize {
8178
metrics.physical_width = size.width;
8279
metrics.physical_height = size.height;
8380

84-
blink::Threads::UI()->PostTask(
85-
[ engine = _platformView->engine().GetWeakPtr(), metrics ] {
86-
if (engine.get()) {
87-
engine->SetViewportMetrics(metrics);
88-
}
89-
});
81+
blink::Threads::UI()->PostTask([ engine = _platformView->engine().GetWeakPtr(), metrics ] {
82+
if (engine.get()) {
83+
engine->SetViewportMetrics(metrics);
84+
}
85+
});
9086
}
9187

9288
- (void)setupSurfaceIfNecessary {
@@ -103,8 +99,7 @@ - (void)setupSurfaceIfNecessary {
10399
#pragma mark - Responder overrides
104100

105101
- (void)dispatchEvent:(NSEvent*)event phase:(NSEventPhase)phase {
106-
NSPoint location =
107-
[_renderSurface convertPoint:event.locationInWindow fromView:nil];
102+
NSPoint location = [_renderSurface convertPoint:event.locationInWindow fromView:nil];
108103
location.y = _renderSurface.frame.size.height - location.y;
109104

110105
blink::PointerData pointer_data;
@@ -138,14 +133,13 @@ - (void)dispatchEvent:(NSEvent*)event phase:(NSEventPhase)phase {
138133
break;
139134
}
140135

141-
blink::Threads::UI()->PostTask(
142-
[ engine = _platformView->engine().GetWeakPtr(), pointer_data ] {
143-
if (engine.get()) {
144-
blink::PointerDataPacket packet(1);
145-
packet.SetPointerData(0, pointer_data);
146-
engine->DispatchPointerDataPacket(packet);
147-
}
148-
});
136+
blink::Threads::UI()->PostTask([ engine = _platformView->engine().GetWeakPtr(), pointer_data ] {
137+
if (engine.get()) {
138+
blink::PointerDataPacket packet(1);
139+
packet.SetPointerData(0, pointer_data);
140+
engine->DispatchPointerDataPacket(packet);
141+
}
142+
});
149143
}
150144

151145
- (void)mouseDown:(NSEvent*)event {

shell/platform/darwin/desktop/main_mac.mm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ int main(int argc, const char* argv[]) {
2727
}
2828

2929
// Decide between interactive and non-interactive modes.
30-
if (command_line.HasOption(
31-
shell::FlagForSwitch(shell::Switch::NonInteractive))) {
30+
if (command_line.HasOption(shell::FlagForSwitch(shell::Switch::NonInteractive))) {
3231
if (!shell::InitForTesting(std::move(command_line)))
3332
return 1;
3433
fml::MessageLoop::GetCurrent().Run();

shell/platform/darwin/desktop/platform_view_mac.mm

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@
2020
namespace shell {
2121

2222
PlatformViewMac::PlatformViewMac(NSOpenGLView* gl_view)
23-
: PlatformView(
24-
std::make_unique<GPURasterizer>(std::make_unique<ProcessInfoMac>())),
23+
: PlatformView(std::make_unique<GPURasterizer>(std::make_unique<ProcessInfoMac>())),
2524
opengl_view_([gl_view retain]),
26-
resource_loading_context_([[NSOpenGLContext alloc]
27-
initWithFormat:gl_view.pixelFormat
28-
shareContext:gl_view.openGLContext]) {
25+
resource_loading_context_([[NSOpenGLContext alloc] initWithFormat:gl_view.pixelFormat
26+
shareContext:gl_view.openGLContext]) {
2927
CreateEngine();
3028
PostAddToShellTask();
3129
}
@@ -41,35 +39,31 @@
4139

4240
const auto& command_line = shell::Shell::Shared().GetCommandLine();
4341

44-
std::string bundle_path =
45-
command_line.GetOptionValueWithDefault(FlagForSwitch(Switch::FLX), "");
42+
std::string bundle_path = command_line.GetOptionValueWithDefault(FlagForSwitch(Switch::FLX), "");
4643
if (!bundle_path.empty()) {
47-
blink::Threads::UI()->PostTask(
48-
[ engine = engine().GetWeakPtr(), bundle_path ] {
49-
if (engine)
50-
engine->RunBundle(bundle_path);
51-
});
44+
blink::Threads::UI()->PostTask([ engine = engine().GetWeakPtr(), bundle_path ] {
45+
if (engine)
46+
engine->RunBundle(bundle_path);
47+
});
5248
return;
5349
}
5450

5551
auto args = command_line.positional_args();
5652
if (args.size() > 0) {
5753
std::string main = args[0];
58-
std::string packages = command_line.GetOptionValueWithDefault(
59-
FlagForSwitch(Switch::Packages), "");
60-
blink::Threads::UI()->PostTask(
61-
[ engine = engine().GetWeakPtr(), main, packages ] {
62-
if (engine)
63-
engine->RunBundleAndSource(std::string(), main, packages);
64-
});
54+
std::string packages =
55+
command_line.GetOptionValueWithDefault(FlagForSwitch(Switch::Packages), "");
56+
blink::Threads::UI()->PostTask([ engine = engine().GetWeakPtr(), main, packages ] {
57+
if (engine)
58+
engine->RunBundleAndSource(std::string(), main, packages);
59+
});
6560
return;
6661
}
6762
}
6863

69-
void PlatformViewMac::SetupAndLoadFromSource(
70-
const std::string& assets_directory,
71-
const std::string& main,
72-
const std::string& packages) {
64+
void PlatformViewMac::SetupAndLoadFromSource(const std::string& assets_directory,
65+
const std::string& main,
66+
const std::string& packages) {
7367
blink::Threads::UI()->PostTask(
7468
[ engine = engine().GetWeakPtr(), assets_directory, main, packages ] {
7569
if (engine)

shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@ @implementation FlutterAppDelegate
1010
// Returns the key window's rootViewController, if it's a FlutterViewController.
1111
// Otherwise, returns nil.
1212
- (FlutterViewController*)rootFlutterViewController {
13-
UIViewController *viewController =
14-
[UIApplication sharedApplication].keyWindow.rootViewController;
13+
UIViewController* viewController = [UIApplication sharedApplication].keyWindow.rootViewController;
1514
if ([viewController isKindOfClass:[FlutterViewController class]]) {
1615
return (FlutterViewController*)viewController;
1716
}
1817
return nil;
1918
}
2019

21-
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
20+
- (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
2221
[super touchesBegan:touches withEvent:event];
2322

2423
// Pass status bar taps to key window Flutter rootViewController.

0 commit comments

Comments
 (0)