Skip to content

Commit 222811a

Browse files
authored
Merge pull request #5309 from jrose-apple/overlays-and-silgen_name
Remove _silgen_name from all Apple overlays except Dispatch and Foundation.
2 parents f241f2e + dce51ed commit 222811a

25 files changed

+193
-272
lines changed

apinotes/AppKit.apinotes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,3 +1369,6 @@ Enumerators:
13691369
SwiftName: viewNotSizable
13701370
- Name: NSWindowStyleMaskBorderless
13711371
SwiftName: borderless
1372+
Functions:
1373+
- Name: NSApplicationMain
1374+
SwiftPrivate: true

stdlib/public/SDK/AppKit/AppKit.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,13 @@ public extension NSGradient {
6262

6363
// Fix the ARGV type of NSApplicationMain, which nonsensically takes
6464
// argv as a const char**.
65-
@_silgen_name("NSApplicationMain")
6665
public func NSApplicationMain(
6766
_ argc: Int32, _ argv: UnsafeMutablePointer<UnsafeMutablePointer<CChar>?>
68-
) -> Int32
67+
) -> Int32 {
68+
return argv.withMemoryRebound(to: UnsafePointer<CChar>.self, capacity: Int(argc)) {
69+
__NSApplicationMain(argc, $0)
70+
}
71+
}
6972

7073
extension NSColor : _ExpressibleByColorLiteral {
7174
public required convenience init(colorLiteralRed red: Float, green: Float,

stdlib/public/SDK/GameplayKit/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
add_swift_library(swiftGameplayKit ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
22
GameplayKit.swift
3-
GameplayKit.mm
43

54
SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
65
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"

stdlib/public/SDK/GameplayKit/GameplayKit.mm

Lines changed: 0 additions & 24 deletions
This file was deleted.

stdlib/public/SDK/GameplayKit/GameplayKit.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,11 @@ extension GKEntity {
7272
}
7373
}
7474

75-
@_silgen_name("GK_Swift_GKStateMachine_stateForClass")
76-
internal func GK_Swift_GKStateMachine_stateForClass(
77-
_ self_: AnyObject,
78-
_ stateClass: AnyObject) -> AnyObject?
75+
@objc
76+
internal protocol _SwiftGKStateMachineLike {
77+
@objc(stateForClass:)
78+
func state(forClass: AnyClass) -> AnyObject?
79+
}
7980

8081
@available(iOS, introduced: 9.0)
8182
@available(OSX, introduced: 10.11)
@@ -85,8 +86,9 @@ extension GKStateMachine {
8586
/// - Parameter forClass: the type of the state you want to get
8687
public func state<StateType : GKState>(
8788
forClass stateClass: StateType.Type) -> StateType? {
88-
return GK_Swift_GKStateMachine_stateForClass(
89-
self, stateClass) as! StateType?
89+
// FIXME: GameplayKit marked state(forClass:) unavailable, which means we
90+
// can't use it from SwiftPrivate. Bounce through perform(_:with:) instead.
91+
return self.perform(#selector(_SwiftGKStateMachineLike.state(forClass:)), with: stateClass)?.takeUnretainedValue() as! StateType?
9092
}
9193
}
9294

stdlib/public/SDK/ObjectiveC/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
add_swift_library(swiftObjectiveC ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
2-
ObjectiveC.mm
32
ObjectiveC.swift
43

54
SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"

stdlib/public/SDK/ObjectiveC/ObjectiveC.swift

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

1313
@_exported
1414
import ObjectiveC
15+
import _SwiftObjectiveCOverlayShims
1516

1617
//===----------------------------------------------------------------------===//
1718
// Objective-C Primitive Types
@@ -180,18 +181,12 @@ typealias Zone = NSZone
180181
// @autoreleasepool substitute
181182
//===----------------------------------------------------------------------===//
182183

183-
@_silgen_name("_swift_objc_autoreleasePoolPush")
184-
func __pushAutoreleasePool() -> OpaquePointer
185-
186-
@_silgen_name("_swift_objc_autoreleasePoolPop")
187-
func __popAutoreleasePool(_ pool: OpaquePointer)
188-
189184
public func autoreleasepool<Result>(
190185
invoking body: () throws -> Result
191186
) rethrows -> Result {
192-
let pool = __pushAutoreleasePool()
187+
let pool = _swift_objc_autoreleasePoolPush()
193188
defer {
194-
__popAutoreleasePool(pool)
189+
_swift_objc_autoreleasePoolPop(pool)
195190
}
196191
return try body()
197192
}

stdlib/public/SDK/SafariServices/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
add_swift_library(swiftSafariServices ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
2-
SafariServices.mm
32
SafariServices.swift
43

54
SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"

stdlib/public/SDK/SafariServices/SafariServices.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
@_exported import SafariServices // Clang module
14-
15-
@_silgen_name("_swift_SafariServices_isSafariServicesAvailable")
16-
internal func _isSafariServicesAvailable() -> Bool
14+
import _SwiftSafariServicesOverlayShims
1715

1816
@available(OSX, introduced: 10.11)
1917
public func SFSafariServicesAvailable() -> Bool {
20-
return _isSafariServicesAvailable()
18+
return _swift_SafariServices_isSafariServicesAvailable()
2119
}

stdlib/public/SDK/SceneKit/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
add_swift_library(swiftSceneKit ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
22
SceneKit.swift.gyb
3-
Thunks.mm
43

54
SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
65
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"

stdlib/public/SDK/SceneKit/SceneKit.swift.gyb

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -224,18 +224,11 @@ extension SCNBoundingVolume {
224224

225225
// MARK: APIs refined for Swift
226226

227-
@_silgen_name("SCN_Swift_SCNSceneSource_entryWithIdentifier")
228-
internal func SCN_Swift_SCNSceneSource_entryWithIdentifier(
229-
_ self_: AnyObject,
230-
_ uid: NSString,
231-
_ entryClass: AnyObject) -> AnyObject?
232-
233227
@available(iOS, introduced: 8.0)
234228
@available(OSX, introduced: 10.8)
235229
extension SCNSceneSource {
236-
public func entryWithIdentifier<T>(_ uid: String, withClass entryClass: T.Type) -> T? {
237-
return SCN_Swift_SCNSceneSource_entryWithIdentifier(
238-
self, uid as NSString, entryClass as! AnyClass) as! T?
230+
public func entryWithIdentifier<T: AnyObject>(_ uid: String, withClass entryClass: T.Type) -> T? {
231+
return self.__entry(withIdentifier: uid, with: entryClass) as! T?
239232
}
240233
}
241234

stdlib/public/SDK/SceneKit/Thunks.mm

Lines changed: 0 additions & 28 deletions
This file was deleted.

stdlib/public/SDK/XCTest/XCTest.swift

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,14 @@
1313
@_exported import XCTest // Clang module
1414

1515
import CoreGraphics
16-
17-
/// Returns the current test case, so we can use free functions instead of methods for the overlay.
18-
@_silgen_name("_XCTCurrentTestCaseBridge") func _XCTCurrentTestCaseBridge() -> XCTestCase
16+
import _SwiftXCTestOverlayShims
1917

2018
// --- Failure Formatting ---
2119

2220
/// Register the failure, expected or unexpected, of the current test case.
2321
func _XCTRegisterFailure(_ expected: Bool, _ condition: String, _ message: @autoclosure () -> String, _ file: StaticString, _ line: UInt) -> Void {
2422
// Call the real _XCTFailureHandler.
25-
let test = _XCTCurrentTestCaseBridge()
23+
let test = _XCTCurrentTestCase()
2624
_XCTPreformattedFailureHandler(test, expected, file.description, line, condition, message())
2725
}
2826

@@ -43,9 +41,6 @@ func _XCTFailureDescription(_ assertionType: _XCTAssertionType, _ formatIndex: U
4341

4442
// --- Exception Support ---
4543

46-
@_silgen_name("_XCTRunThrowableBlockBridge")
47-
func _XCTRunThrowableBlockBridge(_: @convention(block) () -> Void) -> NSDictionary
48-
4944
/// The Swift-style result of evaluating a block which may throw an exception.
5045
enum _XCTThrowableBlockResult {
5146
case success
@@ -70,13 +65,13 @@ func _XCTRunThrowableBlock(_ block: () throws -> Void) -> _XCTThrowableBlockResu
7065
if let blockError = blockErrorOptional {
7166
return .failedWithError(error: blockError)
7267
} else if d.count > 0 {
73-
let t: String = d["type"] as! String
68+
let t: String = d["type"]!
7469

7570
if t == "objc" {
7671
return .failedWithException(
77-
className: d["className"] as! String,
78-
name: d["name"] as! String,
79-
reason: d["reason"] as! String)
72+
className: d["className"]!,
73+
name: d["name"]!,
74+
reason: d["reason"]!)
8075
} else {
8176
return .failedWithUnknownException
8277
}

stdlib/public/SDK/XCTest/XCTestCaseAdditions.mm

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -126,36 +126,15 @@ - (NSString *)className
126126
@end
127127

128128

129-
// Swift's memory management expectations are different than Objective-C; it
130-
// expects everything to be +1 rather than +0. So we need to bridge the
131-
// _XCTCurrentTestCase function to return a +1 object.
132-
133-
XCT_EXPORT XCTestCase *_XCTCurrentTestCase(void);
134-
135-
XCT_EXPORT SWIFT_CC(swift) NS_RETURNS_RETAINED
136-
XCTestCase *_XCTCurrentTestCaseBridge(void);
137-
138-
NS_RETURNS_RETAINED XCTestCase *_XCTCurrentTestCaseBridge(void)
139-
{
140-
return [_XCTCurrentTestCase() retain];
141-
}
142-
143-
144129
// Since Swift doesn't natively support exceptions, but Objective-C code can
145130
// still throw them, use a helper to evaluate a block that may result in an
146131
// exception being thrown that passes back the most important information about
147132
// it.
148133
//
149134
// If no exception is thrown by the block, returns an empty dictionary.
150-
//
151-
// Note that this function needs Swift calling conventions, hence the use of
152-
// NS_RETURNS_RETAINED and Block_release. (The argument should also be marked
153-
// NS_RELEASES_ARGUMENT, but clang doesn't realize that a block parameter
154-
// should be treated as an Objective-C parameter here.)
155135

156-
XCT_EXPORT NS_RETURNS_RETAINED NSDictionary *_XCTRunThrowableBlockBridge(void (^block)());
136+
XCT_EXPORT NSDictionary *_XCTRunThrowableBlockBridge(void (^block)());
157137

158-
SWIFT_CC(swift) NS_RETURNS_RETAINED
159138
NSDictionary *_XCTRunThrowableBlockBridge(void (^block)())
160139
{
161140
NSDictionary *result;

stdlib/public/SDK/XPC/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
add_swift_library(swiftXPC ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
22
XPC.swift
3-
XPC.mm
43

54
SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
65
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"

0 commit comments

Comments
 (0)