mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
This avoids indirection by making calls directly to the C implementations which prevents potentials of mismatched intent or changes of calling convention of @_silgen. The added benefit is that all of the shims in this case are no longer visible symbols (anyone using them was not authorized out side of the Foundation overlay). Also the callout methods in the headers now all share similar naming shcemes for easier refactoring and searching in the style of __NS<class><action> style. The previous compiled C/Objective-C source files were built with MRR the new headers MUST be ARC by Swift import rules. The one caveat is that certain functions MUST avoid the bridge case (since they are part of the bridging code-paths and that would incur a recursive potential) which have the types erased up to NSObject * via the macro NS_NON_BRIDGED. The remaining @_silgen declarations are either swift functions exposed externally to the rest of Swift’s runtime or are included in NSNumber.gyb which the Foundation team has other plans for removing those @_silgen functions at a later date and Data.swift has one external function left with @_silgen which is blocked by a bug in the compiler which seems to improperly import that particular method as an inline c function.
35 lines
1.4 KiB
Swift
35 lines
1.4 KiB
Swift
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See https://swift.org/LICENSE.txt for license information
|
|
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
@_exported import Foundation // Clang module
|
|
import _SwiftFoundationOverlayShims
|
|
|
|
@_silgen_name("NS_Swift_NSUndoManager_registerUndoWithTargetHandler")
|
|
internal func NS_Swift_NSUndoManager_registerUndoWithTargetHandler(
|
|
_ self_: AnyObject,
|
|
_ target: AnyObject,
|
|
_ handler: @escaping @convention(block) (AnyObject) -> Void)
|
|
|
|
extension UndoManager {
|
|
@available(*, unavailable, renamed: "registerUndo(withTarget:handler:)")
|
|
public func registerUndoWithTarget<TargetType : AnyObject>(_ target: TargetType, handler: (TargetType) -> Void) {
|
|
fatalError("This API has been renamed")
|
|
}
|
|
|
|
@available(OSX 10.11, iOS 9.0, *)
|
|
public func registerUndo<TargetType : AnyObject>(withTarget target: TargetType, handler: @escaping (TargetType) -> Void) {
|
|
__NSUndoManagerRegisterWithTargetHandler( self, target) { internalTarget in
|
|
handler(internalTarget as! TargetType)
|
|
}
|
|
}
|
|
}
|