Modernize Objective-C

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 <mark@chromium.org>
Commit-Queue: Leonard Grey <lgrey@chromium.org>
This commit is contained in:
Leonard Grey 2021-05-18 14:34:34 -04:00 committed by Commit Bot
parent a6494f9df6
commit 3a112cfefd
4 changed files with 15 additions and 20 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -78,14 +78,14 @@ TEST(Launchd, CFPropertyToLaunchData_FloatingPoint) {
@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) {

View File

@ -52,13 +52,11 @@ NSString* UserAgentString() {
// CFNetwork would use the main bundles CFBundleName, or the main
// executables filename if none.
user_agent = AppendEscapedFormat(
user_agent, @"%@", [NSString stringWithUTF8String:PACKAGE_NAME]);
user_agent = AppendEscapedFormat(user_agent, @"%@", @PACKAGE_NAME);
// CFNetwork would use the main bundles 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]];
@ -78,10 +76,8 @@ NSString* UserAgentString() {
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
@ -98,7 +94,7 @@ NSString* UserAgentString() {
#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);
}