Skip to content

Commit

Permalink
Modernize Objective-C
Browse files Browse the repository at this point in the history
Via tools/mac/rewrite_modern_objc.py in the Chromium repo

Bug: chromium:324079
Change-Id: I3160331899b3ea75e0ebc78abd9a0a84e9339b40
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2904179
Reviewed-by: Mark Mentovai <[email protected]>
Commit-Queue: Leonard Grey <[email protected]>
  • Loading branch information
speednoisemovement authored and Commit Bot committed May 18, 2021
1 parent a6494f9 commit 3a112cf
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
5 changes: 2 additions & 3 deletions tools/mac/on_demand_service_tool.mm
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,12 @@ int OnDemandServiceToolMain(int argc, char* argv[]) {
dictionaryWithCapacity:options.mach_services.size()];
for (std::string mach_service : options.mach_services) {
NSString* mach_service_ns = base::SysUTF8ToNSString(mach_service);
[mach_services setObject:@YES forKey:mach_service_ns];
mach_services[mach_service_ns] = @YES;
}

NSMutableDictionary* mutable_job_dictionary =
[[job_dictionary mutableCopy] autorelease];
[mutable_job_dictionary setObject:mach_services
forKey:@LAUNCH_JOBKEY_MACHSERVICES];
mutable_job_dictionary[@LAUNCH_JOBKEY_MACHSERVICES] = mach_services;
job_dictionary = mutable_job_dictionary;
}

Expand Down
2 changes: 1 addition & 1 deletion util/mac/launchd.mm
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ launch_data_t CFPropertyToLaunchData(CFPropertyListRef property_cf) {
}

CFPropertyListRef value_cf =
implicit_cast<CFPropertyListRef>([dictionary_ns objectForKey:key]);
implicit_cast<CFPropertyListRef>(dictionary_ns[key]);
launch_data_t value_launch = CFPropertyToLaunchData(value_cf);
if (!value_launch) {
return nullptr;
Expand Down
14 changes: 7 additions & 7 deletions util/mac/launchd_test.mm
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@
@0.0,
@1.0,
@-1.0,
[NSNumber numberWithFloat:std::numeric_limits<float>::min()],
[NSNumber numberWithFloat:std::numeric_limits<float>::max()],
[NSNumber numberWithDouble:std::numeric_limits<double>::min()],
[NSNumber numberWithDouble:std::numeric_limits<double>::max()],
@(std::numeric_limits<float>::min()),
@(std::numeric_limits<float>::max()),
@(std::numeric_limits<double>::min()),
@(std::numeric_limits<double>::max()),
@3.1415926535897932,
[NSNumber numberWithDouble:std::numeric_limits<double>::infinity()],
[NSNumber numberWithDouble:std::numeric_limits<double>::quiet_NaN()],
[NSNumber numberWithDouble:std::numeric_limits<double>::signaling_NaN()],
@(std::numeric_limits<double>::infinity()),
@(std::numeric_limits<double>::quiet_NaN()),
@(std::numeric_limits<double>::signaling_NaN()),
};

for (size_t index = 0; index < base::size(double_nses); ++index) {
Expand Down
14 changes: 5 additions & 9 deletions util/net/http_transport_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,11 @@

// CFNetwork would use the main bundle’s CFBundleName, or the main
// executable’s filename if none.
user_agent = AppendEscapedFormat(
user_agent, @"%@", [NSString stringWithUTF8String:PACKAGE_NAME]);
user_agent = AppendEscapedFormat(user_agent, @"%@", @PACKAGE_NAME);

// CFNetwork would use the main bundle’s CFBundleVersion, or the string
// “(unknown version)” if none.
user_agent = AppendEscapedFormat(
user_agent, @"/%@", [NSString stringWithUTF8String:PACKAGE_VERSION]);
user_agent = AppendEscapedFormat(user_agent, @"/%@", @PACKAGE_VERSION);

// Expected to be CFNetwork.
NSBundle* nsurl_bundle = [NSBundle bundleForClass:[NSURLRequest class]];
Expand All @@ -78,10 +76,8 @@
if (uname(&os) != 0) {
PLOG(WARNING) << "uname";
} else {
user_agent = AppendEscapedFormat(
user_agent, @" %@", [NSString stringWithUTF8String:os.sysname]);
user_agent = AppendEscapedFormat(
user_agent, @"/%@", [NSString stringWithUTF8String:os.release]);
user_agent = AppendEscapedFormat(user_agent, @" %@", @(os.sysname));
user_agent = AppendEscapedFormat(user_agent, @"/%@", @(os.release));

// CFNetwork just uses the equivalent of os.machine to obtain the native
// (kernel) architecture. Here, give the process’ architecture as well as
Expand All @@ -98,7 +94,7 @@
#endif
user_agent = AppendEscapedFormat(user_agent, @" (%@", arch);

NSString* machine = [NSString stringWithUTF8String:os.machine];
NSString* machine = @(os.machine);
if (![machine isEqualToString:arch]) {
user_agent = AppendEscapedFormat(user_agent, @"; %@", machine);
}
Expand Down

0 comments on commit 3a112cf

Please sign in to comment.