diff --git a/apinotes/AppKit.apinotes b/apinotes/AppKit.apinotes index 66d182838dd6d..9581d4a133bf5 100644 --- a/apinotes/AppKit.apinotes +++ b/apinotes/AppKit.apinotes @@ -1369,3 +1369,6 @@ Enumerators: SwiftName: viewNotSizable - Name: NSWindowStyleMaskBorderless SwiftName: borderless +Functions: +- Name: NSApplicationMain + SwiftPrivate: true diff --git a/stdlib/public/SDK/AppKit/AppKit.swift b/stdlib/public/SDK/AppKit/AppKit.swift index 8309c3f5231f0..c36e05b4c4c49 100644 --- a/stdlib/public/SDK/AppKit/AppKit.swift +++ b/stdlib/public/SDK/AppKit/AppKit.swift @@ -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?> -) -> Int32 +) -> Int32 { + return argv.withMemoryRebound(to: UnsafePointer.self, capacity: Int(argc)) { + __NSApplicationMain(argc, $0) + } +} extension NSColor : _ExpressibleByColorLiteral { public required convenience init(colorLiteralRed red: Float, green: Float, diff --git a/stdlib/public/SDK/GameplayKit/CMakeLists.txt b/stdlib/public/SDK/GameplayKit/CMakeLists.txt index b910d9d98a5f4..32476f2526747 100644 --- a/stdlib/public/SDK/GameplayKit/CMakeLists.txt +++ b/stdlib/public/SDK/GameplayKit/CMakeLists.txt @@ -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}" diff --git a/stdlib/public/SDK/GameplayKit/GameplayKit.mm b/stdlib/public/SDK/GameplayKit/GameplayKit.mm deleted file mode 100644 index f68498880adc2..0000000000000 --- a/stdlib/public/SDK/GameplayKit/GameplayKit.mm +++ /dev/null @@ -1,24 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See http://swift.org/LICENSE.txt for license information -// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// - -#import - -#include "swift/Runtime/Config.h" - -extern "C" SWIFT_CC(swift) NS_RETURNS_RETAINED GKState * _Nullable -GK_Swift_GKStateMachine_stateForClass(id NS_RELEASES_ARGUMENT __nonnull self_, - Class __nonnull stateClass) { - GKStateMachine *stateMachine = self_; - id state = [[stateMachine stateForClass:stateClass] retain]; - [self_ release]; - return state; -} diff --git a/stdlib/public/SDK/GameplayKit/GameplayKit.swift b/stdlib/public/SDK/GameplayKit/GameplayKit.swift index 6d57c22e85e44..9aea50a2880a3 100644 --- a/stdlib/public/SDK/GameplayKit/GameplayKit.swift +++ b/stdlib/public/SDK/GameplayKit/GameplayKit.swift @@ -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) @@ -85,8 +86,9 @@ extension GKStateMachine { /// - Parameter forClass: the type of the state you want to get public func state( 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? } } diff --git a/stdlib/public/SDK/ObjectiveC/CMakeLists.txt b/stdlib/public/SDK/ObjectiveC/CMakeLists.txt index e63668f9445ad..d120114cfe8fb 100644 --- a/stdlib/public/SDK/ObjectiveC/CMakeLists.txt +++ b/stdlib/public/SDK/ObjectiveC/CMakeLists.txt @@ -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}" diff --git a/stdlib/public/SDK/ObjectiveC/ObjectiveC.swift b/stdlib/public/SDK/ObjectiveC/ObjectiveC.swift index d7e41b82de0c6..854f279773674 100644 --- a/stdlib/public/SDK/ObjectiveC/ObjectiveC.swift +++ b/stdlib/public/SDK/ObjectiveC/ObjectiveC.swift @@ -12,6 +12,7 @@ @_exported import ObjectiveC +import _SwiftObjectiveCOverlayShims //===----------------------------------------------------------------------===// // Objective-C Primitive Types @@ -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( invoking body: () throws -> Result ) rethrows -> Result { - let pool = __pushAutoreleasePool() + let pool = _swift_objc_autoreleasePoolPush() defer { - __popAutoreleasePool(pool) + _swift_objc_autoreleasePoolPop(pool) } return try body() } diff --git a/stdlib/public/SDK/SafariServices/CMakeLists.txt b/stdlib/public/SDK/SafariServices/CMakeLists.txt index 2ea40ab2c356c..9f7f858fd71f8 100644 --- a/stdlib/public/SDK/SafariServices/CMakeLists.txt +++ b/stdlib/public/SDK/SafariServices/CMakeLists.txt @@ -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}" diff --git a/stdlib/public/SDK/SafariServices/SafariServices.swift b/stdlib/public/SDK/SafariServices/SafariServices.swift index 75e2870090429..5361040888fad 100644 --- a/stdlib/public/SDK/SafariServices/SafariServices.swift +++ b/stdlib/public/SDK/SafariServices/SafariServices.swift @@ -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() } diff --git a/stdlib/public/SDK/SceneKit/CMakeLists.txt b/stdlib/public/SDK/SceneKit/CMakeLists.txt index b5439e04833f5..e36fab16aa198 100644 --- a/stdlib/public/SDK/SceneKit/CMakeLists.txt +++ b/stdlib/public/SDK/SceneKit/CMakeLists.txt @@ -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}" diff --git a/stdlib/public/SDK/SceneKit/SceneKit.swift.gyb b/stdlib/public/SDK/SceneKit/SceneKit.swift.gyb index 986f25c22c474..12ed230317206 100644 --- a/stdlib/public/SDK/SceneKit/SceneKit.swift.gyb +++ b/stdlib/public/SDK/SceneKit/SceneKit.swift.gyb @@ -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(_ uid: String, withClass entryClass: T.Type) -> T? { - return SCN_Swift_SCNSceneSource_entryWithIdentifier( - self, uid as NSString, entryClass as! AnyClass) as! T? + public func entryWithIdentifier(_ uid: String, withClass entryClass: T.Type) -> T? { + return self.__entry(withIdentifier: uid, with: entryClass) as! T? } } diff --git a/stdlib/public/SDK/SceneKit/Thunks.mm b/stdlib/public/SDK/SceneKit/Thunks.mm deleted file mode 100644 index 9c6550de49d94..0000000000000 --- a/stdlib/public/SDK/SceneKit/Thunks.mm +++ /dev/null @@ -1,28 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See http://swift.org/LICENSE.txt for license information -// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// - -#import - -#include "swift/Runtime/Config.h" - -SWIFT_CC(swift) -extern "C" NS_RETURNS_RETAINED _Nullable id -SCN_Swift_SCNSceneSource_entryWithIdentifier( - id NS_RELEASES_ARGUMENT _Nonnull self_, - NSString *NS_RELEASES_ARGUMENT _Nonnull uid, Class _Nonnull entryClass) { - SCNSceneSource *sceneSource = self_; - id Result = [[sceneSource entryWithIdentifier:uid withClass:entryClass] retain]; - [self_ release]; - [uid release]; - return Result; -} - diff --git a/stdlib/public/SDK/XCTest/XCTest.swift b/stdlib/public/SDK/XCTest/XCTest.swift index b91725884c9af..b41d53a5dfc8f 100644 --- a/stdlib/public/SDK/XCTest/XCTest.swift +++ b/stdlib/public/SDK/XCTest/XCTest.swift @@ -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()) } @@ -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 @@ -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 } diff --git a/stdlib/public/SDK/XCTest/XCTestCaseAdditions.mm b/stdlib/public/SDK/XCTest/XCTestCaseAdditions.mm index 4d1bb3b89b9af..e799ac842c5f7 100644 --- a/stdlib/public/SDK/XCTest/XCTestCaseAdditions.mm +++ b/stdlib/public/SDK/XCTest/XCTestCaseAdditions.mm @@ -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; diff --git a/stdlib/public/SDK/XPC/CMakeLists.txt b/stdlib/public/SDK/XPC/CMakeLists.txt index d4ef978a2e029..22e5de7b61eb2 100644 --- a/stdlib/public/SDK/XPC/CMakeLists.txt +++ b/stdlib/public/SDK/XPC/CMakeLists.txt @@ -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}" diff --git a/stdlib/public/SDK/XPC/XPC.swift b/stdlib/public/SDK/XPC/XPC.swift index 6c5ce196ad317..bc9448975544d 100644 --- a/stdlib/public/SDK/XPC/XPC.swift +++ b/stdlib/public/SDK/XPC/XPC.swift @@ -11,76 +11,77 @@ //===----------------------------------------------------------------------===// @_exported import XPC +import _SwiftXPCOverlayShims //===----------------------------------------------------------------------===// // XPC Types //===----------------------------------------------------------------------===// public var XPC_TYPE_CONNECTION: xpc_type_t { - return _swift_xpc_type_connection() + return _swift_xpc_type_CONNECTION() } public var XPC_TYPE_ENDPOINT: xpc_type_t { - return _swift_xpc_type_endpoint() + return _swift_xpc_type_ENDPOINT() } public var XPC_TYPE_NULL: xpc_type_t { - return _swift_xpc_type_null() + return _swift_xpc_type_NULL() } public var XPC_TYPE_BOOL: xpc_type_t { - return _swift_xpc_type_bool() + return _swift_xpc_type_BOOL() } public var XPC_TYPE_INT64: xpc_type_t { - return _swift_xpc_type_int64() + return _swift_xpc_type_INT64() } public var XPC_TYPE_UINT64: xpc_type_t { - return _swift_xpc_type_uint64() + return _swift_xpc_type_UINT64() } public var XPC_TYPE_DOUBLE: xpc_type_t { - return _swift_xpc_type_double() + return _swift_xpc_type_DOUBLE() } public var XPC_TYPE_DATE: xpc_type_t { - return _swift_xpc_type_date() + return _swift_xpc_type_DATE() } public var XPC_TYPE_DATA: xpc_type_t { - return _swift_xpc_type_data() + return _swift_xpc_type_DATA() } public var XPC_TYPE_STRING: xpc_type_t { - return _swift_xpc_type_string() + return _swift_xpc_type_STRING() } public var XPC_TYPE_UUID: xpc_type_t { - return _swift_xpc_type_uuid() + return _swift_xpc_type_UUID() } public var XPC_TYPE_FD: xpc_type_t { - return _swift_xpc_type_fd() + return _swift_xpc_type_FD() } public var XPC_TYPE_SHMEM: xpc_type_t { - return _swift_xpc_type_shmem() + return _swift_xpc_type_SHMEM() } public var XPC_TYPE_ARRAY: xpc_type_t { - return _swift_xpc_type_array() + return _swift_xpc_type_ARRAY() } public var XPC_TYPE_DICTIONARY: xpc_type_t { - return _swift_xpc_type_dictionary() + return _swift_xpc_type_DICTIONARY() } public var XPC_TYPE_ERROR: xpc_type_t { - return _swift_xpc_type_error() + return _swift_xpc_type_ERROR() } public var XPC_TYPE_ACTIVITY: xpc_type_t { - return _swift_xpc_type_activity() + return _swift_xpc_type_ACTIVITY() } //===----------------------------------------------------------------------===// @@ -103,63 +104,6 @@ public var XPC_ARRAY_APPEND: size_t { return -1 } -@_silgen_name("_swift_xpc_bool_true") -internal func _swift_xpc_bool_true() -> xpc_object_t - -@_silgen_name("_swift_xpc_bool_false") -internal func _swift_xpc_bool_false() -> xpc_object_t - -@_silgen_name("_swift_xpc_type_CONNECTION") -internal func _swift_xpc_type_connection() -> xpc_type_t - -@_silgen_name("_swift_xpc_type_ENDPOINT") -internal func _swift_xpc_type_endpoint() -> xpc_type_t - -@_silgen_name("_swift_xpc_type_NULL") -internal func _swift_xpc_type_null() -> xpc_type_t - -@_silgen_name("_swift_xpc_type_BOOL") -internal func _swift_xpc_type_bool() -> xpc_type_t - -@_silgen_name("_swift_xpc_type_INT64") -internal func _swift_xpc_type_int64() -> xpc_type_t - -@_silgen_name("_swift_xpc_type_UINT64") -internal func _swift_xpc_type_uint64() -> xpc_type_t - -@_silgen_name("_swift_xpc_type_DOUBLE") -internal func _swift_xpc_type_double() -> xpc_type_t - -@_silgen_name("_swift_xpc_type_DATE") -internal func _swift_xpc_type_date() -> xpc_type_t - -@_silgen_name("_swift_xpc_type_DATA") -internal func _swift_xpc_type_data() -> xpc_type_t - -@_silgen_name("_swift_xpc_type_STRING") -internal func _swift_xpc_type_string() -> xpc_type_t - -@_silgen_name("_swift_xpc_type_UUID") -internal func _swift_xpc_type_uuid() -> xpc_type_t - -@_silgen_name("_swift_xpc_type_FD") -internal func _swift_xpc_type_fd() -> xpc_type_t - -@_silgen_name("_swift_xpc_type_SHMEM") -internal func _swift_xpc_type_shmem() -> xpc_type_t - -@_silgen_name("_swift_xpc_type_ARRAY") -internal func _swift_xpc_type_array() -> xpc_type_t - -@_silgen_name("_swift_xpc_type_DICTIONARY") -internal func _swift_xpc_type_dictionary() -> xpc_type_t - -@_silgen_name("_swift_xpc_type_ERROR") -internal func _swift_xpc_type_error() -> xpc_type_t - -@_silgen_name("_swift_xpc_type_ACTIVITY") -internal func _swift_xpc_type_activity() -> xpc_type_t - // xpc/connection.h public var XPC_ERROR_CONNECTION_INTERRUPTED: xpc_object_t { @@ -173,12 +117,3 @@ public var XPC_ERROR_CONNECTION_INVALID: xpc_object_t { public var XPC_ERROR_TERMINATION_IMMINENT: xpc_object_t { return _swift_xpc_connection_termination_imminent() } - -@_silgen_name("_swift_xpc_connection_interrupted") -internal func _swift_xpc_connection_interrupted() -> xpc_object_t - -@_silgen_name("_swift_xpc_connection_invalid") -internal func _swift_xpc_connection_invalid() -> xpc_object_t - -@_silgen_name("_swift_xpc_connection_termination_imminent") -internal func _swift_xpc_connection_termination_imminent() -> xpc_object_t diff --git a/stdlib/public/SDK/os/os.mm b/stdlib/public/SDK/os/os.mm index a7674dfabfa63..6ec5da52c5b19 100644 --- a/stdlib/public/SDK/os/os.mm +++ b/stdlib/public/SDK/os/os.mm @@ -395,9 +395,7 @@ return true; } -#include "swift/Runtime/Config.h" - -SWIFT_CC(swift) __attribute__((__visibility__("default"))) +__attribute__((__visibility__("default"))) extern "C" void _swift_os_log(void *dso, os_log_t oslog, os_log_type_t type, const char *format, va_list args) { @@ -414,9 +412,3 @@ _os_log_impl(dso, oslog, type, format, (uint8_t *)buffer, context.content_sz); } } - -SWIFT_CC(swift) __attribute__((__visibility__("default"))) -extern "C" os_log_t -_swift_os_log_default(void) { - return OS_LOG_DEFAULT; -} diff --git a/stdlib/public/SDK/os/os_log.swift b/stdlib/public/SDK/os/os_log.swift index cc396f800914f..1c9b9fdb4a387 100644 --- a/stdlib/public/SDK/os/os_log.swift +++ b/stdlib/public/SDK/os/os_log.swift @@ -12,6 +12,7 @@ @_exported import os @_exported import os.log +import _SwiftOSOverlayShims @available(OSX 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) public func os_log( @@ -60,12 +61,6 @@ extension OSLog { } } -@_silgen_name("_swift_os_log") -internal func _swift_os_log(_ dso: UnsafeRawPointer!, _ log: OSLog, _ type: OSLogType, _ format: UnsafePointer!, _ args: CVaListPointer) - -@_silgen_name("_swift_os_log_default") -internal func _swift_os_log_default() -> OSLog - @available(*, unavailable, renamed: "OSLogType.default") public var OS_LOG_TYPE_DEFAULT: OSLogType { fatalError() diff --git a/stdlib/public/SwiftShims/CMakeLists.txt b/stdlib/public/SwiftShims/CMakeLists.txt index e8d37a3dbf460..19932125b8a56 100644 --- a/stdlib/public/SwiftShims/CMakeLists.txt +++ b/stdlib/public/SwiftShims/CMakeLists.txt @@ -14,6 +14,13 @@ set(sources SwiftStdint.h UnicodeShims.h Visibility.h + + ObjectiveCOverlayShims.h + OSOverlayShims.h + SafariServicesOverlayShims.h + XCTestOverlayShims.h + XPCOverlayShims.h + module.modulemap ) set(output_dir "${SWIFTLIB_DIR}/shims") diff --git a/stdlib/public/SwiftShims/OSOverlayShims.h b/stdlib/public/SwiftShims/OSOverlayShims.h new file mode 100644 index 0000000000000..5ca46c95e084d --- /dev/null +++ b/stdlib/public/SwiftShims/OSOverlayShims.h @@ -0,0 +1,29 @@ +//===--- OSOverlayShims.h -------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + +#ifndef SWIFT_STDLIB_SHIMS_OS_OVERLAY_H +#define SWIFT_STDLIB_SHIMS_OS_OVERLAY_H + +#include +#include + +extern void _swift_os_log(const void * _Nullable dso, os_log_t _Nonnull oslog, + os_log_type_t type, const char * _Nonnull format, + va_list args); + +static inline os_log_t _Nonnull +_swift_os_log_default(void) { + return OS_LOG_DEFAULT; +} + +#endif // SWIFT_STDLIB_SHIMS_OS_OVERLAY_H + diff --git a/stdlib/public/SDK/ObjectiveC/ObjectiveC.mm b/stdlib/public/SwiftShims/ObjectiveCOverlayShims.h similarity index 50% rename from stdlib/public/SDK/ObjectiveC/ObjectiveC.mm rename to stdlib/public/SwiftShims/ObjectiveCOverlayShims.h index 1963d2ef6d61f..4c78187872f85 100644 --- a/stdlib/public/SDK/ObjectiveC/ObjectiveC.mm +++ b/stdlib/public/SwiftShims/ObjectiveCOverlayShims.h @@ -1,4 +1,4 @@ -//===----------------------------------------------------------------------===// +//===--- ObjectiveCOverlayShims.h -----------------------------------------===// // // This source file is part of the Swift.org open source project // @@ -10,23 +10,17 @@ // //===----------------------------------------------------------------------===// -#include - -#include "swift/Runtime/Config.h" - -OBJC_EXPORT -void *objc_autoreleasePoolPush(void); +#ifndef SWIFT_STDLIB_SHIMS_OBJECTIVEC_OVERLAY_H +#define SWIFT_STDLIB_SHIMS_OBJECTIVEC_OVERLAY_H -OBJC_EXPORT -void objc_autoreleasePoolPop(void *); - -SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_INTERFACE -extern "C" void *_swift_objc_autoreleasePoolPush(void) { +static inline void *_swift_objc_autoreleasePoolPush() { + extern void *objc_autoreleasePoolPush(); return objc_autoreleasePoolPush(); } - -SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_INTERFACE -extern "C" void _swift_objc_autoreleasePoolPop(void *context) { - return objc_autoreleasePoolPop(context); +static inline void _swift_objc_autoreleasePoolPop(void *pool) { + extern void objc_autoreleasePoolPop(void *); + objc_autoreleasePoolPop(pool); } +#endif // SWIFT_STDLIB_SHIMS_OBJECTIVEC_OVERLAY_H + diff --git a/stdlib/public/SDK/SafariServices/SafariServices.mm b/stdlib/public/SwiftShims/SafariServicesOverlayShims.h similarity index 59% rename from stdlib/public/SDK/SafariServices/SafariServices.mm rename to stdlib/public/SwiftShims/SafariServicesOverlayShims.h index a3a184378a527..273b020210bc3 100644 --- a/stdlib/public/SDK/SafariServices/SafariServices.mm +++ b/stdlib/public/SwiftShims/SafariServicesOverlayShims.h @@ -1,4 +1,4 @@ -//===----------------------------------------------------------------------===// +//===--- SafariServicesOverlayShims.h -------------------------------------===// // // This source file is part of the Swift.org open source project // @@ -10,10 +10,14 @@ // //===----------------------------------------------------------------------===// +#ifndef SWIFT_STDLIB_SHIMS_SAFARISERVICES_OVERLAY_H +#define SWIFT_STDLIB_SHIMS_SAFARISERVICES_OVERLAY_H + #import -#include "swift/Runtime/Config.h" -SWIFT_CC(swift) -extern "C" bool _swift_SafariServices_isSafariServicesAvailable() { - return nullptr != &_SFSafariServicesAvailable; +static inline bool _swift_SafariServices_isSafariServicesAvailable() { + return NULL != &_SFSafariServicesAvailable; } + +#endif // SWIFT_STDLIB_SHIMS_SAFARISERVICES_OVERLAY_H + diff --git a/stdlib/public/SwiftShims/XCTestOverlayShims.h b/stdlib/public/SwiftShims/XCTestOverlayShims.h new file mode 100644 index 0000000000000..ba9d57adc6c02 --- /dev/null +++ b/stdlib/public/SwiftShims/XCTestOverlayShims.h @@ -0,0 +1,26 @@ +//===--- XCTestOverlayShims.h -------------------------------------------*-===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + +#ifndef SWIFT_STDLIB_SHIMS_XCTEST_OVERLAY_H +#define SWIFT_STDLIB_SHIMS_XCTEST_OVERLAY_H + +@import Foundation; + +@class XCTestCase; + +XCTestCase * _Nonnull _XCTCurrentTestCase(void); + +NSDictionary * _Nonnull +_XCTRunThrowableBlockBridge(void (^ _Nonnull NS_NOESCAPE block)()); + +#endif // SWIFT_STDLIB_SHIMS_XCTEST_OVERLAY_H + diff --git a/stdlib/public/SDK/XPC/XPC.mm b/stdlib/public/SwiftShims/XPCOverlayShims.h similarity index 53% rename from stdlib/public/SDK/XPC/XPC.mm rename to stdlib/public/SwiftShims/XPCOverlayShims.h index 6d6c48e49aa60..e6acab322b08d 100644 --- a/stdlib/public/SDK/XPC/XPC.mm +++ b/stdlib/public/SwiftShims/XPCOverlayShims.h @@ -1,4 +1,4 @@ -//===----------------------------------------------------------------------===// +//===--- XPCOverlayShims.h ------------------------------------------------===// // // This source file is part of the Swift.org open source project // @@ -10,65 +10,66 @@ // //===----------------------------------------------------------------------===// -#include +#ifndef SWIFT_STDLIB_SHIMS_XPC_OVERLAY_H +#define SWIFT_STDLIB_SHIMS_XPC_OVERLAY_H + +@import XPC; -__attribute__((visibility("hidden"))) -extern "C" xpc_type_t +static inline xpc_type_t _swift_xpc_get_type(xpc_object_t object) { return xpc_get_type(object); } -__attribute__((visibility("hidden"))) -extern "C" xpc_object_t +static inline xpc_object_t _swift_xpc_bool_true() { return XPC_BOOL_TRUE; } -__attribute__((visibility("hidden"))) -extern "C" xpc_object_t +static inline xpc_object_t _swift_xpc_bool_false() { return XPC_BOOL_FALSE; } -#define TYPE(t) \ - __attribute__((visibility("hidden"))) \ - extern "C" xpc_type_t \ +#define SWIFT_XPC_TYPE(t) \ + static inline xpc_type_t \ _swift_xpc_type_##t(void) { \ return XPC_TYPE_##t; \ } -TYPE(CONNECTION) -TYPE(ENDPOINT) -TYPE(NULL) -TYPE(BOOL) -TYPE(INT64) -TYPE(UINT64) -TYPE(DOUBLE) -TYPE(DATE) -TYPE(DATA) -TYPE(STRING) -TYPE(UUID) -TYPE(FD) -TYPE(SHMEM) -TYPE(ARRAY) -TYPE(DICTIONARY) -TYPE(ERROR) -TYPE(ACTIVITY) +SWIFT_XPC_TYPE(CONNECTION) +SWIFT_XPC_TYPE(ENDPOINT) +SWIFT_XPC_TYPE(NULL) +SWIFT_XPC_TYPE(BOOL) +SWIFT_XPC_TYPE(INT64) +SWIFT_XPC_TYPE(UINT64) +SWIFT_XPC_TYPE(DOUBLE) +SWIFT_XPC_TYPE(DATE) +SWIFT_XPC_TYPE(DATA) +SWIFT_XPC_TYPE(STRING) +SWIFT_XPC_TYPE(UUID) +SWIFT_XPC_TYPE(FD) +SWIFT_XPC_TYPE(SHMEM) +SWIFT_XPC_TYPE(ARRAY) +SWIFT_XPC_TYPE(DICTIONARY) +SWIFT_XPC_TYPE(ERROR) +SWIFT_XPC_TYPE(ACTIVITY) + +#undef SWIFT_XPC_TYPE -__attribute__((visibility("hidden"))) -extern "C" xpc_object_t +static inline xpc_object_t _swift_xpc_connection_interrupted(void) { return XPC_ERROR_CONNECTION_INTERRUPTED; } -__attribute__((visibility("hidden"))) -extern "C" xpc_object_t +static inline xpc_object_t _swift_xpc_connection_invalid(void) { return XPC_ERROR_CONNECTION_INVALID; } -__attribute__((visibility("hidden"))) -extern "C" xpc_object_t +static inline xpc_object_t _swift_xpc_connection_termination_imminent(void) { return XPC_ERROR_TERMINATION_IMMINENT; } + +#endif // SWIFT_STDLIB_SHIMS_XPC_OVERLAY_H + diff --git a/stdlib/public/SwiftShims/module.modulemap b/stdlib/public/SwiftShims/module.modulemap index e5a358e23730f..51c809d913f97 100644 --- a/stdlib/public/SwiftShims/module.modulemap +++ b/stdlib/public/SwiftShims/module.modulemap @@ -16,3 +16,30 @@ module SwiftShims { header "Visibility.h" export * } + +// Various headers used to build overlays on Apple platforms. +// Note: These deliberately do not use "export *" to avoid circularity issues +// (overlay -> shims -> framework -> overlay) +// FIXME: These are only needed when building each overlay; they declare no +// types and therefore would not strictly need to be present in an installed +// Swift. +// FIXME: These are not used at all on non-Apple platforms. +module _SwiftObjectiveCOverlayShims { + header "ObjectiveCOverlayShims.h" +} + +module _SwiftOSOverlayShims { + header "OSOverlayShims.h" +} + +module _SwiftSafariServicesOverlayShims { + header "SafariServicesOverlayShims.h" +} + +module _SwiftXCTestOverlayShims { + header "XCTestOverlayShims.h" +} + +module _SwiftXPCOverlayShims { + header "XPCOverlayShims.h" +}