Skip to content

Commit

Permalink
API Notes: Mark several APIs as unavailable.
Browse files Browse the repository at this point in the history
 - Make NSZone functions unavailable radar://16688847
 - Distributed Objects subsystem should not be imported into Swift radar://16689104
 - NSCalendarDate is available in Swift, but deprecated radar://16689207
 - Do not import NSMethodSignature class and related methods radar://16689329
 - NSInvocationOperation should be unavailble in Swift radar://17921785

Swift SVN r22090
  • Loading branch information
AnnaZaks committed Sep 18, 2014
1 parent 317f809 commit c61280c
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 21 deletions.
84 changes: 65 additions & 19 deletions apinotes/Foundation.apinotes
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,8 @@ Classes:
- Name: weekdaySymbols
Nullability: N
- Name: NSCalendarDate
Availability: none
AvailabilityMsg: "use NSCalendar, NSDateComponents, and NSDateFormatter instead"
Methods:
- Selector: calendarDate
MethodKind: Class
Expand Down Expand Up @@ -1857,6 +1859,8 @@ Classes:
- Name: name
Nullability: O
- Name: NSConnection
Availability: none
AvailabilityMsg: "you may be able to use XPC instead"
Methods:
- Selector: 'addRequestMode:'
MethodKind: Instance
Expand Down Expand Up @@ -2824,6 +2828,8 @@ Classes:
- Name: fileAttributes
Nullability: O
- Name: NSDistantObject
Availability: none
AvailabilityMsg: "you may be able to use XPC instead"
Methods:
- Selector: 'initWithCoder:'
MethodKind: Instance
Expand Down Expand Up @@ -2863,6 +2869,8 @@ Classes:
- Name: connectionForProxy
Nullability: N
- Name: NSDistantObjectRequest
Availability: none
AvailabilityMsg: "you may be able to use XPC instead"
Methods:
- Selector: 'replyWithException:'
MethodKind: Instance
Expand Down Expand Up @@ -4418,25 +4426,7 @@ Classes:
- Name: NSInvocation
Availability: none
- Name: NSInvocationOperation
Methods:
- Selector: 'initWithInvocation:'
MethodKind: Instance
Nullability:
- N
NullabilityOfRet: U
DesignatedInit: true
- Selector: 'initWithTarget:selector:object:'
MethodKind: Instance
Nullability:
- N
- S
- O
NullabilityOfRet: O
Properties:
- Name: invocation
Nullability: N
- Name: result
Nullability: O
Availability: none
- Name: NSItemProvider
Methods:
- Selector: 'hasItemConformingToTypeIdentifier:'
Expand Down Expand Up @@ -4910,6 +4900,8 @@ Classes:
- U
NullabilityOfRet: N
- Name: NSMachBootstrapServer
Availability: none
AvailabilityMsg: "you may be able to use XPC instead"
Methods:
- Selector: 'portForName:'
MethodKind: Instance
Expand Down Expand Up @@ -5078,6 +5070,8 @@ Classes:
- S
NullabilityOfRet: N
- Name: NSMessagePortNameServer
Availability: none
AvailabilityMsg: "you may be able to use XPC instead"
Methods:
- Selector: 'portForName:'
MethodKind: Instance
Expand Down Expand Up @@ -5182,6 +5176,7 @@ Classes:
- Name: value
Nullability: N
- Name: NSMethodSignature
Availability: none
Methods:
- Selector: 'signatureWithObjCTypes:'
MethodKind: Class
Expand Down Expand Up @@ -6901,6 +6896,8 @@ Classes:
- O
NullabilityOfRet: S
- Name: NSPortCoder
Availability: none
AvailabilityMsg: "you may be able to use XPC instead"
Methods:
- Selector: decodePortObject
MethodKind: Instance
Expand Down Expand Up @@ -6933,6 +6930,8 @@ Classes:
- Name: sendPort
Nullability: O
- Name: NSPortNameServer
Availability: none
AvailabilityMsg: "you may be able to use XPC instead"
Methods:
- Selector: 'portForName:'
MethodKind: Instance
Expand Down Expand Up @@ -8045,6 +8044,8 @@ Classes:
- Name: address
Nullability: N
- Name: NSSocketPortNameServer
Availability: none
AvailabilityMsg: "you may be able to use XPC instead"
Methods:
- Selector: 'portForName:'
MethodKind: Instance
Expand Down Expand Up @@ -11391,6 +11392,20 @@ Classes:
Nullability: O
- Name: endpoint
Nullability: N
- Name: NSObject
Availability: none
Methods:
- Selector: 'replacementObjectForPortCoder:'
MethodKind: Instance
Availability: none
AvailabilityMsg: "you may be able to use XPC instead"
- Selector: 'instanceMethodSignatureForSelector:'
MethodKind: Class
Availability: none
Properties:
- Name: 'classForPortCoder'
Availability: none
AvailabilityMsg: "you may be able to use XPC instead"
Protocols:
- Name: NSCacheDelegate
Methods:
Expand All @@ -11413,6 +11428,8 @@ Protocols:
- N
NullabilityOfRet: N
- Name: NSConnectionDelegate
Availability: none
AvailabilityMsg: "you may be able to use XPC instead"
Methods:
- Selector: 'authenticateComponents:withData:'
MethodKind: Instance
Expand Down Expand Up @@ -12525,14 +12542,43 @@ Protocols:
Nullability:
- N
NullabilityOfRet: N
Globals:
- Name: NSConnectionDidDieNotification
Availability: none
AvailabilityMsg: "you may be able to use XPC instead"
- Name: NSConnectionDidInitializeNotification
Availability: none
AvailabilityMsg: "you may be able to use XPC instead"
- Name: NSConnectionReplyMode
Availability: none
AvailabilityMsg: "you may be able to use XPC instead"
- Name: NSFailedAuthenticationException
Availability: none
AvailabilityMsg: "you may be able to use XPC instead"
Functions:
- Name: NSZoneName
Nullability:
- N
NullabilityOfRet: N
Availability: none
- Name: NSSetZoneName
Nullability:
- N
- N
Availability: none
AvailabilityMsg: ''
- Name: NSCreateZone
Availability: none
- Name: NSRecycleZone
Availability: none
- Name: NSZoneCalloc
Availability: none
- Name: NSZoneFree
Availability: none
- Name: NSZoneFromPointer
Availability: none
- Name: NSZoneMalloc
Availability: none
- Name: NSZoneRealloc
Availability: none

28 changes: 27 additions & 1 deletion test/ClangModules/availability.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ func test_deprecated_imported_as_unavailable(s:UnsafeMutablePointer<CChar>) {
let x = tmpnam(s) // expected-error {{'tmpnam' is unavailable: Due to security concerns inherent in the design of tmpnam(3), it is highly recommended that you use mkstemp(3) instead.}}
}

func test_NSInvocation(x:NSInvocation) {} // expected-error {{'NSInvocation' is unavailable}}
func test_NSInvocation(x: NSInvocation, // expected-error {{'NSInvocation' is unavailable}}
y: NSInvocationOperation,// expected-error {{'NSInvocationOperation' is unavailable}}
z: NSMethodSignature) {} // expected-error {{'NSMethodSignature' is unavailable}}

func test_class_avail(x:NSObject, obj: AnyObject) {
x.`class`() // expected-error {{'class()' is unavailable: use 'dynamicType' instead}}
Expand Down Expand Up @@ -75,3 +77,27 @@ func testRedeclarations() {
let _: UnavailProto2 // expected-error {{is unavailable: middle}}
let _: UnavailProto3 // expected-error {{is unavailable: last}}
}

func test_NSZone(z : NSZone) {
NSCreateZone(1, 1, true) // expected-error {{'NSCreateZone' is unavailable}}
NSSetZoneName(z, "name") // expected-error {{'NSSetZoneName' is unavailable}}
NSZoneName(z) // expected-error {{'NSZoneName' is unavailable}}
}

func test_DistributedObjects(o: NSObject,
a: NSConnection, // expected-error {{'NSConnection' is unavailable: you may be able to use XPC instead}}
b: NSConnectionDelegate, // expected-error {{'NSConnectionDelegate' is unavailable: you may be able to use XPC instead}}
c: NSDistantObjectRequest, // expected-error {{'NSDistantObjectRequest' is unavailable: you may be able to use XPC instead}}
d: NSDistantObject, // expected-error {{'NSDistantObject' is unavailable: you may be able to use XPC instead}}
e: NSPortNameServer, // expected-error {{'NSPortNameServer' is unavailable: you may be able to use XPC instead}}
f: NSMachBootstrapServer, // expected-error {{'NSMachBootstrapServer' is unavailable: you may be able to use XPC instead}}
g: NSMessagePortNameServer, // expected-error {{'NSMessagePortNameServer' is unavailable: you may be able to use XPC instead}}
h: NSSocketPortNameServer, // expected-error {{'NSSocketPortNameServer' is unavailable: you may be able to use XPC instead}}
i: NSPortCoder) { // expected-error {{'NSPortCoder' is unavailable: you may be able to use XPC instead}}

let ca = NSConnectionDidDieNotification // expected-error {{'NSConnectionDidDieNotification' is unavailable: you may be able to use XPC instead}}
let cc = NSConnectionReplyMode // expected-error {{'NSConnectionReplyMode' is unavailable: you may be able to use XPC instead}}
o.classForPortCoder // expected-error {{'classForPortCoder' is unavailable: you may be able to use XPC instead}}
}

func test_NSCalendarDate(o: NSCalendarDate) {} // expected-error {{'NSCalendarDate' is unavailable: use NSCalendar, NSDateComponents, and NSDateFormatter instead}}
1 change: 0 additions & 1 deletion test/IDE/print_clang_decls.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
// FOUNDATION-LABEL: {{^}}/// Unavailable Global Functions{{$}}
// FOUNDATION-NEXT: @availability(*, unavailable)
// FOUNDATION-NEXT: NSSetZoneName(zone: NSZone, name: String)
// FOUNDATION-NEXT: NSZoneName(zone: NSZone) -> String

// APPKIT-LABEL: {{^}}extension NSString {{{$}}

Expand Down
32 changes: 32 additions & 0 deletions test/Inputs/clang-importer-sdk/usr/include/Foundation.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,38 @@ extern CFTypeRef CFAutorelease(CFTypeRef __attribute__((cf_consumed)) arg) __att
extern CGColorRef CGColorRetain(CGColorRef color) __attribute__((availability(macosx,introduced=10.3)));
extern void CGColorRelease(CGColorRef color) __attribute__((availability(macosx,introduced=10.3)));

@interface NSObject (NSDistributedObjects)
@property (readonly) Class classForPortCoder;
@end

extern NSString * const NSConnectionReplyMode;
extern NSString * const NSConnectionDidDieNotification;
@interface NSConnection : NSObject {
}
@end
@interface NSPortCoder : NSCoder
@end
@protocol NSConnectionDelegate <NSObject>
@end
@interface NSDistantObjectRequest : NSObject
@end
@interface NSDistantObject
@end
@interface NSPortNameServer : NSObject
@end
@interface NSMachBootstrapServer : NSPortNameServer
@end
@interface NSMessagePortNameServer : NSPortNameServer
@end
@interface NSSocketPortNameServer : NSPortNameServer
@end
@interface NSCalendarDate : NSDate
@end
@interface NSInvocationOperation
@end
@interface NSMethodSignature : NSObject
@end
/// Unavailable Global Functions
extern void NSSetZoneName(NSZone *zone, NSString *name);
extern NSString *NSZoneName(NSZone *zone);
extern NSZone *NSCreateZone(NSUInteger startSize, NSUInteger granularity, BOOL canFree);

0 comments on commit c61280c

Please sign in to comment.