Skip to content

Commit e582465

Browse files
committed
stdlib: use the modern spellings for nullability
Use the portable spelling for the nullability keywords (_Nullable, _Nonnullable, _Null_unspecified) rather than the old spelling (__nullable, __nonnullable, __null_unspecified). NFC.
1 parent ebbc643 commit e582465

File tree

6 files changed

+133
-129
lines changed

6 files changed

+133
-129
lines changed

stdlib/public/SDK/Foundation/FileManagerThunks.m

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,24 @@
1212

1313
#import <Foundation/Foundation.h>
1414

15-
extern /*"C"*/ NS_RETURNS_RETAINED id NS_Swift_NSFileManager_replaceItemAtURL_withItemAtURL_backupItemName_options(
16-
NSFileManager *NS_RELEASES_ARGUMENT __nonnull self_,
17-
NSURL *NS_RELEASES_ARGUMENT __nonnull originalItemURL,
18-
NSURL *NS_RELEASES_ARGUMENT __nonnull newItemURL,
19-
NSString *NS_RELEASES_ARGUMENT __nonnull backupItemName,
20-
NSUInteger options,
21-
NSError *__nullable *__nullable error) {
15+
extern /*"C"*/ NS_RETURNS_RETAINED id
16+
NS_Swift_NSFileManager_replaceItemAtURL_withItemAtURL_backupItemName_options(
17+
NSFileManager *NS_RELEASES_ARGUMENT _Nonnull self_,
18+
NSURL *NS_RELEASES_ARGUMENT _Nonnull originalItemURL,
19+
NSURL *NS_RELEASES_ARGUMENT _Nonnull newItemURL,
20+
NSString *NS_RELEASES_ARGUMENT _Nonnull backupItemName, NSUInteger options,
21+
NSError *_Nullable *_Nullable error) {
2222

23-
NSURL *result = nil;
24-
[self_ replaceItemAtURL:originalItemURL withItemAtURL:originalItemURL backupItemName:backupItemName options:(NSFileManagerItemReplacementOptions)options resultingItemURL:&result error:error];
25-
[self_ release];
26-
[originalItemURL release];
27-
[newItemURL release];
28-
[backupItemName release];
29-
return [result retain];
23+
NSURL *result = nil;
24+
[self_ replaceItemAtURL:originalItemURL
25+
withItemAtURL:originalItemURL
26+
backupItemName:backupItemName
27+
options:(NSFileManagerItemReplacementOptions)options
28+
resultingItemURL:&result
29+
error:error];
30+
[self_ release];
31+
[originalItemURL release];
32+
[newItemURL release];
33+
[backupItemName release];
34+
return [result retain];
3035
}

stdlib/public/SDK/Foundation/NotificationThunks.m

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,19 @@
1212

1313
#import <Foundation/Foundation.h>
1414

15-
extern NS_RETURNS_RETAINED __nullable id
16-
__NSNotificationCreate(
17-
NSString *NS_RELEASES_ARGUMENT __nonnull name,
18-
id NS_RELEASES_ARGUMENT __nullable object,
19-
NSDictionary *NS_RELEASES_ARGUMENT __nullable userInfo) {
15+
extern NS_RETURNS_RETAINED _Nullable id
16+
__NSNotificationCreate(NSString *NS_RELEASES_ARGUMENT _Nonnull name,
17+
id NS_RELEASES_ARGUMENT _Nullable object,
18+
NSDictionary *NS_RELEASES_ARGUMENT _Nullable userInfo) {
2019
NSNotification *notif = [[NSNotification alloc] initWithName:name object:object userInfo:userInfo];
2120
[name release];
2221
[object release];
2322
[userInfo release];
2423
return notif;
2524
}
2625

27-
extern NS_RETURNS_RETAINED __nullable id
28-
__NSNotificationUserInfo(
29-
NSNotification *NS_RELEASES_ARGUMENT __nonnull notif) {
26+
extern NS_RETURNS_RETAINED _Nullable id
27+
__NSNotificationUserInfo(NSNotification *NS_RELEASES_ARGUMENT _Nonnull notif) {
3028
NSDictionary *userInfo = [notif.userInfo retain]; // avoid the copy here since this is fetching the stored dictionary and copying it might destroy it's type
3129
[notif release];
3230
return userInfo;

stdlib/public/SDK/Foundation/Thunks.mm

Lines changed: 71 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@
1717
#include "swift/Runtime/Config.h"
1818

1919
SWIFT_CC(swift)
20-
extern "C" void
21-
NS_Swift_NSUndoManager_registerUndoWithTargetHandler(
22-
id NS_RELEASES_ARGUMENT __nonnull self_,
23-
id NS_RELEASES_ARGUMENT __nonnull target,
24-
void (^__nonnull handler)(id __nonnull)) {
20+
extern "C" void NS_Swift_NSUndoManager_registerUndoWithTargetHandler(
21+
id NS_RELEASES_ARGUMENT _Nonnull self_,
22+
id NS_RELEASES_ARGUMENT _Nonnull target,
23+
void (^_Nonnull handler)(id _Nonnull)) {
2524

2625
NSUndoManager *undoManager = self_;
2726
[undoManager registerUndoWithTarget:target handler:handler];
@@ -34,9 +33,9 @@
3433

3534
// -- NSCoder
3635
SWIFT_CC(swift)
37-
extern "C" NS_RETURNS_RETAINED __nullable id
38-
NS_Swift_NSCoder_decodeObject(id NS_RELEASES_ARGUMENT __nonnull self_,
39-
NSError *__nullable *__nullable error) {
36+
extern "C" NS_RETURNS_RETAINED _Nullable id
37+
NS_Swift_NSCoder_decodeObject(id NS_RELEASES_ARGUMENT _Nonnull self_,
38+
NSError *_Nullable *_Nullable error) {
4039
NSCoder *coder = (NSCoder *)self_;
4140
id result = nil;
4241
if (error) {
@@ -49,10 +48,10 @@
4948
}
5049

5150
SWIFT_CC(swift)
52-
extern "C" NS_RETURNS_RETAINED __nullable id
53-
NS_Swift_NSCoder_decodeObjectForKey(id NS_RELEASES_ARGUMENT __nonnull self_,
54-
id NS_RELEASES_ARGUMENT __nonnull key,
55-
NSError *__nullable *__nullable error) {
51+
extern "C" NS_RETURNS_RETAINED _Nullable id
52+
NS_Swift_NSCoder_decodeObjectForKey(id NS_RELEASES_ARGUMENT _Nonnull self_,
53+
id NS_RELEASES_ARGUMENT _Nonnull key,
54+
NSError *_Nullable *_Nullable error) {
5655
NSCoder *coder = (NSCoder *)self_;
5756
id result = nil;
5857
if (error) {
@@ -66,12 +65,11 @@
6665
}
6766

6867
SWIFT_CC(swift)
69-
extern "C" NS_RETURNS_RETAINED __nullable id
68+
extern "C" NS_RETURNS_RETAINED _Nullable id
7069
NS_Swift_NSCoder_decodeObjectOfClassForKey(
71-
id NS_RELEASES_ARGUMENT __nonnull self_,
72-
id NS_RELEASES_ARGUMENT __nonnull cls,
73-
id NS_RELEASES_ARGUMENT __nonnull key,
74-
NSError *__nullable *__nullable error) {
70+
id NS_RELEASES_ARGUMENT _Nonnull self_,
71+
id NS_RELEASES_ARGUMENT _Nonnull cls, id NS_RELEASES_ARGUMENT _Nonnull key,
72+
NSError *_Nullable *_Nullable error) {
7573
NSCoder *coder = (NSCoder *)self_;
7674
id result = nil;
7775
if (error) {
@@ -85,12 +83,11 @@
8583
}
8684

8785
SWIFT_CC(swift)
88-
extern "C" NS_RETURNS_RETAINED __nullable id
86+
extern "C" NS_RETURNS_RETAINED _Nullable id
8987
NS_Swift_NSCoder_decodeObjectOfClassesForKey(
90-
id NS_RELEASES_ARGUMENT __nonnull self_,
91-
NSSet *NS_RELEASES_ARGUMENT __nullable classes,
92-
id NS_RELEASES_ARGUMENT __nonnull key,
93-
NSError *__nullable *__nullable error) {
88+
id NS_RELEASES_ARGUMENT _Nonnull self_,
89+
NSSet *NS_RELEASES_ARGUMENT _Nullable classes,
90+
id NS_RELEASES_ARGUMENT _Nonnull key, NSError *_Nullable *_Nullable error) {
9491
NSCoder *coder = (NSCoder *)self_;
9592
id result = nil;
9693
if (error) {
@@ -106,10 +103,10 @@
106103

107104
// -- NSKeyedUnarchiver
108105
SWIFT_CC(swift)
109-
extern "C" NS_RETURNS_RETAINED __nullable id
106+
extern "C" NS_RETURNS_RETAINED _Nullable id
110107
NS_Swift_NSKeyedUnarchiver_unarchiveObjectWithData(
111-
Class Self_, id NS_RELEASES_ARGUMENT __nonnull data,
112-
NSError *__nullable *__nullable error) {
108+
Class Self_, id NS_RELEASES_ARGUMENT _Nonnull data,
109+
NSError *_Nullable *_Nullable error) {
113110
id result = nil;
114111
if (error) {
115112
result = [Self_ unarchiveTopLevelObjectWithData:data error:error];
@@ -124,10 +121,12 @@
124121

125122
// Unfortunately the importer does not realize that [NSCalendar initWithIdentifier:] has been around forever, and only sees the iOS 8 availability of [NSCalendar calendarWithIdentifier:].
126123
SWIFT_CC(swift)
127-
extern "C" NS_RETURNS_RETAINED NSCalendar * __nullable __NSCalendarInit(NSString * NS_RELEASES_ARGUMENT __nonnull identifier) {
128-
NSCalendar *result = [[NSCalendar alloc] initWithCalendarIdentifier:identifier];
129-
[identifier release];
130-
return result;
124+
extern "C" NS_RETURNS_RETAINED NSCalendar *_Nullable __NSCalendarInit(
125+
NSString *NS_RELEASES_ARGUMENT _Nonnull identifier) {
126+
NSCalendar *result =
127+
[[NSCalendar alloc] initWithCalendarIdentifier:identifier];
128+
[identifier release];
129+
return result;
131130
}
132131

133132
SWIFT_CC(swift)
@@ -162,49 +161,54 @@
162161

163162
// Autoupdating Subclasses
164163
SWIFT_CC(swift)
165-
extern "C" BOOL __NSCalendarIsAutoupdating(NSCalendar *NS_RELEASES_ARGUMENT __nonnull calendar) {
166-
static dispatch_once_t onceToken;
167-
static Class autoCalendarClass;
168-
static Class olderAutoCalendarClass; // Pre 10.12/10.0
169-
dispatch_once(&onceToken, ^{
170-
autoCalendarClass = (Class)objc_lookUpClass("_NSAutoCalendar");
171-
olderAutoCalendarClass = (Class)objc_lookUpClass("NSAutoCalendar");
172-
});
173-
BOOL result = (autoCalendarClass && [calendar isKindOfClass:autoCalendarClass]) || (olderAutoCalendarClass && [calendar isKindOfClass:olderAutoCalendarClass]);
174-
[calendar release];
175-
return result;
176-
}
177-
178-
SWIFT_CC(swift)
179-
extern "C" BOOL __NSTimeZoneIsAutoupdating(NSTimeZone *NS_RELEASES_ARGUMENT __nonnull timeZone) {
180-
static dispatch_once_t onceToken;
181-
static Class autoTimeZoneClass;
182-
dispatch_once(&onceToken, ^{
183-
autoTimeZoneClass = (Class)objc_lookUpClass("__NSLocalTimeZone");
184-
});
185-
BOOL result = [timeZone isKindOfClass:autoTimeZoneClass];
186-
[timeZone release];
187-
return result;
188-
}
189-
190-
SWIFT_CC(swift)
191-
extern "C" BOOL __NSLocaleIsAutoupdating(NSTimeZone *NS_RELEASES_ARGUMENT __nonnull locale) {
192-
static dispatch_once_t onceToken;
193-
static Class autoLocaleClass;
194-
dispatch_once(&onceToken, ^{
195-
autoLocaleClass = (Class)objc_lookUpClass("NSAutoLocale");
196-
});
197-
BOOL result = [locale isKindOfClass:autoLocaleClass];
198-
[locale release];
199-
return result;
164+
extern "C" BOOL
165+
__NSCalendarIsAutoupdating(NSCalendar *NS_RELEASES_ARGUMENT _Nonnull calendar) {
166+
static dispatch_once_t onceToken;
167+
static Class autoCalendarClass;
168+
static Class olderAutoCalendarClass; // Pre 10.12/10.0
169+
dispatch_once(&onceToken, ^{
170+
autoCalendarClass = (Class)objc_lookUpClass("_NSAutoCalendar");
171+
olderAutoCalendarClass = (Class)objc_lookUpClass("NSAutoCalendar");
172+
});
173+
BOOL result =
174+
(autoCalendarClass && [calendar isKindOfClass:autoCalendarClass]) ||
175+
(olderAutoCalendarClass &&
176+
[calendar isKindOfClass:olderAutoCalendarClass]);
177+
[calendar release];
178+
return result;
179+
}
180+
181+
SWIFT_CC(swift)
182+
extern "C" BOOL
183+
__NSTimeZoneIsAutoupdating(NSTimeZone *NS_RELEASES_ARGUMENT _Nonnull timeZone) {
184+
static dispatch_once_t onceToken;
185+
static Class autoTimeZoneClass;
186+
dispatch_once(&onceToken, ^{
187+
autoTimeZoneClass = (Class)objc_lookUpClass("__NSLocalTimeZone");
188+
});
189+
BOOL result = [timeZone isKindOfClass:autoTimeZoneClass];
190+
[timeZone release];
191+
return result;
192+
}
193+
194+
SWIFT_CC(swift)
195+
extern "C" BOOL
196+
__NSLocaleIsAutoupdating(NSTimeZone *NS_RELEASES_ARGUMENT _Nonnull locale) {
197+
static dispatch_once_t onceToken;
198+
static Class autoLocaleClass;
199+
dispatch_once(&onceToken, ^{
200+
autoLocaleClass = (Class)objc_lookUpClass("NSAutoLocale");
201+
});
202+
BOOL result = [locale isKindOfClass:autoLocaleClass];
203+
[locale release];
204+
return result;
200205
}
201206

202207
// -- NSError
203208
SWIFT_CC(swift)
204209
extern "C" void
205-
NS_Swift_performErrorRecoverySelector(_Nullable id delegate,
206-
SEL selector,
210+
NS_Swift_performErrorRecoverySelector(_Nullable id delegate, SEL selector,
207211
BOOL success,
208-
void * _Nullable contextInfo) {
212+
void *_Nullable contextInfo) {
209213
objc_msgSend(delegate, selector, success, contextInfo);
210214
}

stdlib/public/SDK/GameplayKit/GameplayKit.mm

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,18 @@
1414

1515
#include "swift/Runtime/Config.h"
1616

17-
extern "C" SWIFT_CC(swift) NS_RETURNS_RETAINED GKComponent * __nullable
18-
GK_Swift_GKEntity_componentForClass(
19-
id NS_RELEASES_ARGUMENT __nonnull self_,
20-
Class __nonnull componentClass) {
17+
extern "C" SWIFT_CC(swift) NS_RETURNS_RETAINED GKComponent * _Nullable
18+
GK_Swift_GKEntity_componentForClass(id NS_RELEASES_ARGUMENT __nonnull self_,
19+
Class __nonnull componentClass) {
2120
GKEntity *entity = self_;
2221
id component = [[entity componentForClass:componentClass] retain];
2322
[self_ release];
2423
return component;
2524
}
2625

27-
extern "C" SWIFT_CC(swift) NS_RETURNS_RETAINED GKState * __nullable
28-
GK_Swift_GKStateMachine_stateForClass(
29-
id NS_RELEASES_ARGUMENT __nonnull self_,
30-
Class __nonnull stateClass) {
26+
extern "C" SWIFT_CC(swift) NS_RETURNS_RETAINED GKState * _Nullable
27+
GK_Swift_GKStateMachine_stateForClass(id NS_RELEASES_ARGUMENT __nonnull self_,
28+
Class __nonnull stateClass) {
3129
GKStateMachine *stateMachine = self_;
3230
id state = [[stateMachine stateForClass:stateClass] retain];
3331
[self_ release];

stdlib/public/SDK/SceneKit/Thunks.mm

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515
#include "swift/Runtime/Config.h"
1616

1717
SWIFT_CC(swift)
18-
extern "C" NS_RETURNS_RETAINED __nullable id
18+
extern "C" NS_RETURNS_RETAINED _Nullable id
1919
SCN_Swift_SCNSceneSource_entryWithIdentifier(
20-
id NS_RELEASES_ARGUMENT __nonnull self_,
21-
NSString *NS_RELEASES_ARGUMENT __nonnull uid,
22-
Class __nonnull entryClass) {
20+
id NS_RELEASES_ARGUMENT _Nonnull self_,
21+
NSString *NS_RELEASES_ARGUMENT _Nonnull uid, Class _Nonnull entryClass) {
2322
SCNSceneSource *sceneSource = self_;
2423
id Result = [[sceneSource entryWithIdentifier:uid withClass:entryClass] retain];
2524
[self_ release];

stdlib/public/SwiftShims/CoreFoundationShims.h

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -56,54 +56,54 @@ typedef __swift_uint16_t _swift_shims_UniChar;
5656

5757
// Buffer is nullable in case the string is zero-length.
5858
SWIFT_RUNTIME_STDLIB_INTERFACE
59-
void _swift_stdlib_CFStringGetCharacters(_swift_shims_CFStringRef __nonnull theString,
60-
_swift_shims_CFRange range,
61-
_swift_shims_UniChar *__nullable buffer);
59+
void _swift_stdlib_CFStringGetCharacters(
60+
_swift_shims_CFStringRef _Nonnull theString, _swift_shims_CFRange range,
61+
_swift_shims_UniChar *_Nullable buffer);
6262

6363
SWIFT_RUNTIME_STDLIB_INTERFACE
64-
const _swift_shims_UniChar *__nullable _swift_stdlib_CFStringGetCharactersPtr(
65-
_swift_shims_CFStringRef __nonnull theString);
64+
const _swift_shims_UniChar *_Nullable _swift_stdlib_CFStringGetCharactersPtr(
65+
_swift_shims_CFStringRef _Nonnull theString);
6666

6767
SWIFT_RUNTIME_STDLIB_INTERFACE
68-
_swift_shims_CFIndex
69-
_swift_stdlib_CFStringGetLength(_swift_shims_CFStringRef __nonnull theString);
68+
_swift_shims_CFIndex _swift_stdlib_CFStringGetLength(
69+
_swift_shims_CFStringRef _Nonnull theString);
7070

7171
SWIFT_RUNTIME_STDLIB_INTERFACE
72-
_swift_shims_CFStringRef __nonnull _swift_stdlib_CFStringCreateWithSubstring(
73-
_swift_shims_CFAllocatorRef __nullable alloc,
74-
_swift_shims_CFStringRef __nonnull str, _swift_shims_CFRange range);
72+
_swift_shims_CFStringRef _Nonnull _swift_stdlib_CFStringCreateWithSubstring(
73+
_swift_shims_CFAllocatorRef _Nullable alloc,
74+
_swift_shims_CFStringRef _Nonnull str, _swift_shims_CFRange range);
7575

7676
SWIFT_RUNTIME_STDLIB_INTERFACE
77-
_swift_shims_UniChar
78-
_swift_stdlib_CFStringGetCharacterAtIndex(_swift_shims_CFStringRef __nonnull theString,
79-
_swift_shims_CFIndex idx);
77+
_swift_shims_UniChar _swift_stdlib_CFStringGetCharacterAtIndex(
78+
_swift_shims_CFStringRef _Nonnull theString, _swift_shims_CFIndex idx);
8079

8180
SWIFT_RUNTIME_STDLIB_INTERFACE
82-
_swift_shims_CFStringRef __nonnull _swift_stdlib_CFStringCreateCopy(
83-
_swift_shims_CFAllocatorRef __nullable alloc,
84-
_swift_shims_CFStringRef __nonnull theString);
81+
_swift_shims_CFStringRef _Nonnull _swift_stdlib_CFStringCreateCopy(
82+
_swift_shims_CFAllocatorRef _Nullable alloc,
83+
_swift_shims_CFStringRef _Nonnull theString);
8584

8685
SWIFT_RUNTIME_STDLIB_INTERFACE
87-
const char *__nullable _swift_stdlib_CFStringGetCStringPtr(
88-
_swift_shims_CFStringRef __nonnull theString,
86+
const char *_Nullable _swift_stdlib_CFStringGetCStringPtr(
87+
_swift_shims_CFStringRef _Nonnull theString,
8988
_swift_shims_CFStringEncoding encoding);
9089

9190
SWIFT_RUNTIME_STDLIB_INTERFACE
9291
_swift_shims_CFComparisonResult
93-
_swift_stdlib_CFStringCompare(_swift_shims_CFStringRef __nonnull theString1,
94-
_swift_shims_CFStringRef __nonnull theString2,
95-
_swift_shims_CFStringCompareFlags compareOptions);
92+
_swift_stdlib_CFStringCompare(_swift_shims_CFStringRef _Nonnull theString1,
93+
_swift_shims_CFStringRef _Nonnull theString2,
94+
_swift_shims_CFStringCompareFlags compareOptions);
9695

9796
SWIFT_RUNTIME_STDLIB_INTERFACE
98-
_swift_shims_Boolean
99-
_swift_stdlib_CFStringFindWithOptions(_swift_shims_CFStringRef __nonnull theString,
100-
_swift_shims_CFStringRef __nonnull stringToFind,
101-
_swift_shims_CFRange rangeToSearch,
102-
_swift_shims_CFStringCompareFlags searchOptions,
103-
_swift_shims_CFRange *__nullable result);
97+
_swift_shims_Boolean _swift_stdlib_CFStringFindWithOptions(
98+
_swift_shims_CFStringRef _Nonnull theString,
99+
_swift_shims_CFStringRef _Nonnull stringToFind,
100+
_swift_shims_CFRange rangeToSearch,
101+
_swift_shims_CFStringCompareFlags searchOptions,
102+
_swift_shims_CFRange *_Nullable result);
104103

105104
SWIFT_RUNTIME_STDLIB_INTERFACE
106-
_swift_shims_CFStringRef __nonnull _swift_stdlib_objcDebugDescription(id __nonnull nsObject);
105+
_swift_shims_CFStringRef _Nonnull _swift_stdlib_objcDebugDescription(
106+
id _Nonnull nsObject);
107107
#endif // __OBJC2__
108108

109109
#ifdef __cplusplus

0 commit comments

Comments
 (0)