Skip to content

Remove _silgen_name from all Apple overlays except Dispatch and Foundation #5309

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Oct 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apinotes/AppKit.apinotes
Original file line number Diff line number Diff line change
Expand Up @@ -1369,3 +1369,6 @@ Enumerators:
SwiftName: viewNotSizable
- Name: NSWindowStyleMaskBorderless
SwiftName: borderless
Functions:
- Name: NSApplicationMain
SwiftPrivate: true
7 changes: 5 additions & 2 deletions stdlib/public/SDK/AppKit/AppKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,13 @@ public extension NSGradient {

// Fix the ARGV type of NSApplicationMain, which nonsensically takes
// argv as a const char**.
@_silgen_name("NSApplicationMain")
public func NSApplicationMain(
_ argc: Int32, _ argv: UnsafeMutablePointer<UnsafeMutablePointer<CChar>?>
) -> Int32
) -> Int32 {
return argv.withMemoryRebound(to: UnsafePointer<CChar>.self, capacity: Int(argc)) {
__NSApplicationMain(argc, $0)
}
}

extension NSColor : _ExpressibleByColorLiteral {
public required convenience init(colorLiteralRed red: Float, green: Float,
Expand Down
1 change: 0 additions & 1 deletion stdlib/public/SDK/GameplayKit/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
add_swift_library(swiftGameplayKit ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
GameplayKit.swift
GameplayKit.mm

SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
Expand Down
24 changes: 0 additions & 24 deletions stdlib/public/SDK/GameplayKit/GameplayKit.mm

This file was deleted.

14 changes: 8 additions & 6 deletions stdlib/public/SDK/GameplayKit/GameplayKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ extension GKEntity {
}
}

@_silgen_name("GK_Swift_GKStateMachine_stateForClass")
internal func GK_Swift_GKStateMachine_stateForClass(
_ self_: AnyObject,
_ stateClass: AnyObject) -> AnyObject?
@objc
internal protocol _SwiftGKStateMachineLike {
@objc(stateForClass:)
func state(forClass: AnyClass) -> AnyObject?
}

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

1 change: 0 additions & 1 deletion stdlib/public/SDK/ObjectiveC/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
add_swift_library(swiftObjectiveC ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
ObjectiveC.mm
ObjectiveC.swift

SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
Expand Down
11 changes: 3 additions & 8 deletions stdlib/public/SDK/ObjectiveC/ObjectiveC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

@_exported
import ObjectiveC
import _SwiftObjectiveCOverlayShims

//===----------------------------------------------------------------------===//
// Objective-C Primitive Types
Expand Down Expand Up @@ -180,18 +181,12 @@ typealias Zone = NSZone
// @autoreleasepool substitute
//===----------------------------------------------------------------------===//

@_silgen_name("_swift_objc_autoreleasePoolPush")
func __pushAutoreleasePool() -> OpaquePointer

@_silgen_name("_swift_objc_autoreleasePoolPop")
func __popAutoreleasePool(_ pool: OpaquePointer)

public func autoreleasepool<Result>(
invoking body: () throws -> Result
) rethrows -> Result {
let pool = __pushAutoreleasePool()
let pool = _swift_objc_autoreleasePoolPush()
defer {
__popAutoreleasePool(pool)
_swift_objc_autoreleasePoolPop(pool)
}
return try body()
}
Expand Down
1 change: 0 additions & 1 deletion stdlib/public/SDK/SafariServices/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
add_swift_library(swiftSafariServices ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
SafariServices.mm
SafariServices.swift

SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
Expand Down
6 changes: 2 additions & 4 deletions stdlib/public/SDK/SafariServices/SafariServices.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
//===----------------------------------------------------------------------===//

@_exported import SafariServices // Clang module

@_silgen_name("_swift_SafariServices_isSafariServicesAvailable")
internal func _isSafariServicesAvailable() -> Bool
import _SwiftSafariServicesOverlayShims

@available(OSX, introduced: 10.11)
public func SFSafariServicesAvailable() -> Bool {
return _isSafariServicesAvailable()
return _swift_SafariServices_isSafariServicesAvailable()
}
1 change: 0 additions & 1 deletion stdlib/public/SDK/SceneKit/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
add_swift_library(swiftSceneKit ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
SceneKit.swift.gyb
Thunks.mm

SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
Expand Down
11 changes: 2 additions & 9 deletions stdlib/public/SDK/SceneKit/SceneKit.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -224,18 +224,11 @@ extension SCNBoundingVolume {

// MARK: APIs refined for Swift

@_silgen_name("SCN_Swift_SCNSceneSource_entryWithIdentifier")
internal func SCN_Swift_SCNSceneSource_entryWithIdentifier(
_ self_: AnyObject,
_ uid: NSString,
_ entryClass: AnyObject) -> AnyObject?

@available(iOS, introduced: 8.0)
@available(OSX, introduced: 10.8)
extension SCNSceneSource {
public func entryWithIdentifier<T>(_ uid: String, withClass entryClass: T.Type) -> T? {
return SCN_Swift_SCNSceneSource_entryWithIdentifier(
self, uid as NSString, entryClass as! AnyClass) as! T?
public func entryWithIdentifier<T: AnyObject>(_ uid: String, withClass entryClass: T.Type) -> T? {
return self.__entry(withIdentifier: uid, with: entryClass) as! T?
}
}

Expand Down
28 changes: 0 additions & 28 deletions stdlib/public/SDK/SceneKit/Thunks.mm

This file was deleted.

17 changes: 6 additions & 11 deletions stdlib/public/SDK/XCTest/XCTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@
@_exported import XCTest // Clang module

import CoreGraphics

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

// --- Failure Formatting ---

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

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

// --- Exception Support ---

@_silgen_name("_XCTRunThrowableBlockBridge")
func _XCTRunThrowableBlockBridge(_: @convention(block) () -> Void) -> NSDictionary

/// The Swift-style result of evaluating a block which may throw an exception.
enum _XCTThrowableBlockResult {
case success
Expand All @@ -70,13 +65,13 @@ func _XCTRunThrowableBlock(_ block: () throws -> Void) -> _XCTThrowableBlockResu
if let blockError = blockErrorOptional {
return .failedWithError(error: blockError)
} else if d.count > 0 {
let t: String = d["type"] as! String
let t: String = d["type"]!

if t == "objc" {
return .failedWithException(
className: d["className"] as! String,
name: d["name"] as! String,
reason: d["reason"] as! String)
className: d["className"]!,
name: d["name"]!,
reason: d["reason"]!)
} else {
return .failedWithUnknownException
}
Expand Down
23 changes: 1 addition & 22 deletions stdlib/public/SDK/XCTest/XCTestCaseAdditions.mm
Original file line number Diff line number Diff line change
Expand Up @@ -126,36 +126,15 @@ - (NSString *)className
@end


// Swift's memory management expectations are different than Objective-C; it
// expects everything to be +1 rather than +0. So we need to bridge the
// _XCTCurrentTestCase function to return a +1 object.

XCT_EXPORT XCTestCase *_XCTCurrentTestCase(void);

XCT_EXPORT SWIFT_CC(swift) NS_RETURNS_RETAINED
XCTestCase *_XCTCurrentTestCaseBridge(void);

NS_RETURNS_RETAINED XCTestCase *_XCTCurrentTestCaseBridge(void)
{
return [_XCTCurrentTestCase() retain];
}


// Since Swift doesn't natively support exceptions, but Objective-C code can
// still throw them, use a helper to evaluate a block that may result in an
// exception being thrown that passes back the most important information about
// it.
//
// If no exception is thrown by the block, returns an empty dictionary.
//
// Note that this function needs Swift calling conventions, hence the use of
// NS_RETURNS_RETAINED and Block_release. (The argument should also be marked
// NS_RELEASES_ARGUMENT, but clang doesn't realize that a block parameter
// should be treated as an Objective-C parameter here.)

XCT_EXPORT NS_RETURNS_RETAINED NSDictionary *_XCTRunThrowableBlockBridge(void (^block)());
XCT_EXPORT NSDictionary *_XCTRunThrowableBlockBridge(void (^block)());

SWIFT_CC(swift) NS_RETURNS_RETAINED
NSDictionary *_XCTRunThrowableBlockBridge(void (^block)())
{
NSDictionary *result;
Expand Down
1 change: 0 additions & 1 deletion stdlib/public/SDK/XPC/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
add_swift_library(swiftXPC ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
XPC.swift
XPC.mm

SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
Expand Down
Loading