Skip to content

Commit

Permalink
Convert the Dispatch and Foundation overlays to 'fileprivate'. (#3753)
Browse files Browse the repository at this point in the history
Similar to the work in apple/swift-corelibs-foundation#445.

Groundwork for SE-0025 ('private' and 'fileprivate').
No intended functionality change.
  • Loading branch information
jrose-apple committed Jul 26, 2016
1 parent c41edb8 commit 0712ffc
Show file tree
Hide file tree
Showing 19 changed files with 45 additions and 45 deletions.
4 changes: 2 additions & 2 deletions stdlib/public/SDK/Dispatch/Data.swift
Expand Up @@ -29,7 +29,7 @@ public struct DispatchData : RandomAccessCollection, _ObjectiveCBridgeable {
/// A custom deallocator
case custom(DispatchQueue?, @convention(block) () -> Void)

private var _deallocator: (DispatchQueue?, @convention(block) () -> Void) {
fileprivate var _deallocator: (DispatchQueue?, @convention(block) () -> Void) {
switch self {
case .free: return (nil, _dispatch_data_destructor_free())
case .unmap: return (nil, _dispatch_data_destructor_munmap())
Expand All @@ -38,7 +38,7 @@ public struct DispatchData : RandomAccessCollection, _ObjectiveCBridgeable {
}
}

private var __wrapped: __DispatchData
fileprivate var __wrapped: __DispatchData

/// Initialize a `Data` with copied memory content.
///
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/SDK/Dispatch/Queue.swift
Expand Up @@ -33,7 +33,7 @@ public extension DispatchQueue {
@available(OSX 10.12, iOS 10.0, tvOS 10.0, watchOS 3.0, *)
public static let initiallyInactive = Attributes(rawValue: 1<<2)

private func _attr() -> __OS_dispatch_queue_attr? {
fileprivate func _attr() -> __OS_dispatch_queue_attr? {
var attr: __OS_dispatch_queue_attr? = nil

if self.contains(.concurrent) {
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/SDK/Dispatch/Time.swift
Expand Up @@ -20,7 +20,7 @@ public struct DispatchTime : Comparable {

public static let distantFuture = DispatchTime(rawValue: ~0)

private init(rawValue: dispatch_time_t) {
fileprivate init(rawValue: dispatch_time_t) {
self.rawValue = rawValue
}

Expand Down Expand Up @@ -60,7 +60,7 @@ public struct DispatchWallTime : Comparable {

public static let distantFuture = DispatchWallTime(rawValue: ~0)

private init(rawValue: dispatch_time_t) {
fileprivate init(rawValue: dispatch_time_t) {
self.rawValue = rawValue
}

Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/SDK/Foundation/Boxing.swift
Expand Up @@ -16,7 +16,7 @@
///
/// Note: This assumes that the result of calling copy() is mutable. The documentation says that classes which do not have a mutable/immutable distinction should just adopt NSCopying instead of NSMutableCopying.
internal final class _MutableHandle<MutableType : NSObject where MutableType : NSCopying> {
private var _pointer : MutableType
fileprivate var _pointer : MutableType

init(reference : MutableType) {
_pointer = reference.copy() as! MutableType
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/SDK/Foundation/Calendar.swift
Expand Up @@ -115,7 +115,7 @@ public struct Calendar : CustomStringConvertible, CustomDebugStringConvertible,
// MARK: -
// MARK: Bridging

private init(reference : NSCalendar) {
fileprivate init(reference : NSCalendar) {
_handle = _MutableHandle(reference: reference)
if __NSCalendarIsAutoupdating(reference) {
_autoupdating = true
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/SDK/Foundation/CharacterSet.swift
Expand Up @@ -82,7 +82,7 @@ public struct CharacterSet : ReferenceConvertible, Equatable, Hashable, SetAlgeb

// MARK: Init methods

private init(_bridged characterSet: NSCharacterSet) {
fileprivate init(_bridged characterSet: NSCharacterSet) {
// We must copy the input because it might be mutable; just like storing a value type in ObjC
_wrapped = _SwiftNSCharacterSet(immutableObject: characterSet.copy() as AnyObject)
}
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/SDK/Foundation/Data.swift
Expand Up @@ -103,7 +103,7 @@ public struct Data : ReferenceConvertible, CustomStringConvertible, Equatable, H
/// A custom deallocator.
case custom((UnsafeMutablePointer<UInt8>, Int) -> Void)

private var _deallocator : ((UnsafeMutablePointer<Void>, Int) -> Void)? {
fileprivate var _deallocator : ((UnsafeMutablePointer<Void>, Int) -> Void)? {
switch self {
case .virtualMemory:
return { __NSDataInvokeDeallocatorVM($0, $1) }
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/SDK/Foundation/Date.swift
Expand Up @@ -21,7 +21,7 @@ import CoreFoundation
public struct Date : ReferenceConvertible, Comparable, Equatable, CustomStringConvertible {
public typealias ReferenceType = NSDate

private var _time : TimeInterval
fileprivate var _time : TimeInterval

/// The number of seconds from 1 January 1970 to the reference date, 1 January 2001.
public static let timeIntervalBetween1970AndReferenceDate : TimeInterval = 978307200.0
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/SDK/Foundation/DateComponents.swift
Expand Up @@ -277,7 +277,7 @@ public struct DateComponents : ReferenceConvertible, Hashable, Equatable, _Mutab

// MARK: - Bridging Helpers

private init(reference: NSDateComponents) {
fileprivate init(reference: NSDateComponents) {
_handle = _MutableHandle(reference: reference)
}

Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/SDK/Foundation/IndexPath.swift
Expand Up @@ -156,7 +156,7 @@ public struct IndexPath : ReferenceConvertible, Equatable, Hashable, MutableColl

// MARK: - Bridging Helpers

private init(nsIndexPath: ReferenceType) {
fileprivate init(nsIndexPath: ReferenceType) {
let count = nsIndexPath.length
if count == 0 {
_indexes = []
Expand All @@ -171,7 +171,7 @@ public struct IndexPath : ReferenceConvertible, Equatable, Hashable, MutableColl
}
}

private func makeReference() -> ReferenceType {
fileprivate func makeReference() -> ReferenceType {
return _indexes.withUnsafeBufferPointer {
return ReferenceType(indexes: $0.baseAddress, length: $0.count)
}
Expand Down
26 changes: 13 additions & 13 deletions stdlib/public/SDK/Foundation/IndexSet.swift
Expand Up @@ -101,12 +101,12 @@ public struct IndexSet : ReferenceConvertible, Equatable, BidirectionalCollectio
public let startIndex : Index
public let endIndex : Index

private var indexSet : IndexSet
fileprivate var indexSet : IndexSet

// Range of element values
private var intersectingRange : Range<IndexSet.Element>?

private init(indexSet : IndexSet, intersecting range : Range<IndexSet.Element>?) {
fileprivate init(indexSet : IndexSet, intersecting range : Range<IndexSet.Element>?) {
self.indexSet = indexSet
self.intersectingRange = range

Expand Down Expand Up @@ -170,12 +170,12 @@ public struct IndexSet : ReferenceConvertible, Equatable, BidirectionalCollectio

/// The mechanism for accessing the integers stored in an IndexSet.
public struct Index : CustomStringConvertible, Comparable {
private var value : IndexSet.Element
private var extent : Range<IndexSet.Element>
private var rangeIndex : Int
private let rangeCount : Int
fileprivate var value : IndexSet.Element
fileprivate var extent : Range<IndexSet.Element>
fileprivate var rangeIndex : Int
fileprivate let rangeCount : Int

private init(value: Int, extent: Range<Int>, rangeIndex: Int, rangeCount: Int) {
fileprivate init(value: Int, extent: Range<Int>, rangeIndex: Int, rangeCount: Int) {
self.value = value
self.extent = extent
self.rangeCount = rangeCount
Expand All @@ -190,7 +190,7 @@ public struct IndexSet : ReferenceConvertible, Equatable, BidirectionalCollectio
public typealias ReferenceType = NSIndexSet
public typealias Element = Int

private var _handle: _MutablePairHandle<NSIndexSet, NSMutableIndexSet>
fileprivate var _handle: _MutablePairHandle<NSIndexSet, NSMutableIndexSet>

/// Initialize an `IndexSet` with a range of integers.
public init(integersIn range: Range<Element>) {
Expand Down Expand Up @@ -768,11 +768,11 @@ public struct IndexSet : ReferenceConvertible, Equatable, BidirectionalCollectio

// MARK: - Bridging Support

private var reference: NSIndexSet {
fileprivate var reference: NSIndexSet {
return _handle.reference
}

private init(reference: NSIndexSet) {
fileprivate init(reference: NSIndexSet) {
_handle = _MutablePairHandle(reference)
}
}
Expand All @@ -788,7 +788,7 @@ private struct IndexSetBoundaryIterator : IteratorProtocol {
private var i1UsedLower : Bool
private var i2UsedLower : Bool

private init(_ is1 : IndexSet, _ is2 : IndexSet) {
fileprivate init(_ is1 : IndexSet, _ is2 : IndexSet) {
i1 = is1.rangeView.makeIterator()
i2 = is2.rangeView.makeIterator()

Expand All @@ -800,7 +800,7 @@ private struct IndexSetBoundaryIterator : IteratorProtocol {
i2UsedLower = false
}

private mutating func next() -> Element? {
fileprivate mutating func next() -> Element? {
if i1Range == nil && i2Range == nil {
return nil
}
Expand Down Expand Up @@ -900,7 +900,7 @@ private enum _MutablePair<ImmutableType, MutableType> {
///
/// a.k.a. Box
private final class _MutablePairHandle<ImmutableType : NSObject, MutableType : NSObject where ImmutableType : NSMutableCopying, MutableType : NSMutableCopying> {
private var _pointer: _MutablePair<ImmutableType, MutableType>
fileprivate var _pointer: _MutablePair<ImmutableType, MutableType>

/// Initialize with an immutable reference instance.
///
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/SDK/Foundation/Locale.swift
Expand Up @@ -34,7 +34,7 @@ public struct Locale : CustomStringConvertible, CustomDebugStringConvertible, Ha

public typealias LanguageDirection = NSLocale.LanguageDirection

private var _wrapped : NSLocale
fileprivate var _wrapped : NSLocale
private var _autoupdating : Bool

/// Returns a locale which tracks the user's current preferences.
Expand All @@ -61,7 +61,7 @@ public struct Locale : CustomStringConvertible, CustomDebugStringConvertible, Ha
_autoupdating = false
}

private init(reference: NSLocale) {
fileprivate init(reference: NSLocale) {
_wrapped = reference.copy() as! NSLocale
if __NSLocaleIsAutoupdating(reference) {
_autoupdating = true
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/SDK/Foundation/PersonNameComponents.swift
Expand Up @@ -21,7 +21,7 @@ public struct PersonNameComponents : ReferenceConvertible, Hashable, Equatable,
_handle = _MutableHandle(adoptingReference: NSPersonNameComponents())
}

private init(reference: NSPersonNameComponents) {
fileprivate init(reference: NSPersonNameComponents) {
_handle = _MutableHandle(reference: reference)
}

Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/SDK/Foundation/TimeZone.swift
Expand Up @@ -33,7 +33,7 @@ internal func __NSTimeZoneCurrent() -> NSTimeZone
public struct TimeZone : CustomStringConvertible, CustomDebugStringConvertible, Hashable, Equatable, ReferenceConvertible {
public typealias ReferenceType = NSTimeZone

private var _wrapped : NSTimeZone
fileprivate var _wrapped : NSTimeZone
private var _autoupdating : Bool

/// The time zone currently used by the system.
Expand Down Expand Up @@ -100,7 +100,7 @@ public struct TimeZone : CustomStringConvertible, CustomDebugStringConvertible,
}
}

private init(reference: NSTimeZone) {
fileprivate init(reference: NSTimeZone) {
if __NSTimeZoneIsAutoupdating(reference) {
// we can't copy this or we lose its auto-ness (27048257)
// fortunately it's immutable
Expand Down
10 changes: 5 additions & 5 deletions stdlib/public/SDK/Foundation/URL.swift
Expand Up @@ -36,15 +36,15 @@ public struct URLThumbnailSizeKey : RawRepresentable, Hashable {
As a convenience, volume resource values can be requested from any file system URL. The value returned will reflect the property value for the volume on which the resource is located.
*/
public struct URLResourceValues {
private var _values: [URLResourceKey: Any]
private var _keys: Set<URLResourceKey>
fileprivate var _values: [URLResourceKey: Any]
fileprivate var _keys: Set<URLResourceKey>

public init() {
_values = [:]
_keys = []
}

private init(keys: Set<URLResourceKey>, values: [URLResourceKey: Any]) {
fileprivate init(keys: Set<URLResourceKey>, values: [URLResourceKey: Any]) {
_values = values
_keys = keys
}
Expand Down Expand Up @@ -477,7 +477,7 @@ public struct URLResourceValues {
*/
public struct URL : ReferenceConvertible, CustomStringConvertible, Equatable {
public typealias ReferenceType = NSURL
private var _url : NSURL
fileprivate var _url : NSURL

public typealias BookmarkResolutionOptions = NSURL.BookmarkResolutionOptions
public typealias BookmarkCreationOptions = NSURL.BookmarkCreationOptions
Expand Down Expand Up @@ -1130,7 +1130,7 @@ public struct URL : ReferenceConvertible, CustomStringConvertible, Equatable {
}
}

private init(reference: NSURL) {
fileprivate init(reference: NSURL) {
_url = URL._converted(from: reference).copy() as! NSURL
}

Expand Down
8 changes: 4 additions & 4 deletions stdlib/public/SDK/Foundation/URLComponents.swift
Expand Up @@ -305,7 +305,7 @@ public struct URLComponents : ReferenceConvertible, Hashable, CustomStringConver

// MARK: - Bridging

private init(reference: NSURLComponents) {
fileprivate init(reference: NSURLComponents) {
_handle = _MutableHandle(reference: reference)
}

Expand Down Expand Up @@ -349,14 +349,14 @@ extension URLComponents : _ObjectiveCBridgeable {
public struct URLQueryItem : ReferenceConvertible, Hashable, Equatable, CustomStringConvertible {
public typealias ReferenceType = NSURLQueryItem

private var _queryItem : NSURLQueryItem
fileprivate var _queryItem : NSURLQueryItem

public init(name: String, value: String?) {
_queryItem = NSURLQueryItem(name: name, value: value)
}

private init(reference: NSURLQueryItem) { _queryItem = reference.copy() as! NSURLQueryItem }
private var reference : NSURLQueryItem { return _queryItem }
fileprivate init(reference: NSURLQueryItem) { _queryItem = reference.copy() as! NSURLQueryItem }
fileprivate var reference : NSURLQueryItem { return _queryItem }

public var name : String {
get { return _queryItem.name }
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/SDK/Foundation/URLRequest.swift
Expand Up @@ -41,7 +41,7 @@ public struct URLRequest : ReferenceConvertible, CustomStringConvertible, Equata
_handle = _MutableHandle(adoptingReference: NSMutableURLRequest(url: url, cachePolicy: cachePolicy, timeoutInterval: timeoutInterval))
}

private init(_bridged request: NSURLRequest) {
fileprivate init(_bridged request: NSURLRequest) {
_handle = _MutableHandle(reference: request.mutableCopy() as! NSMutableURLRequest)
}

Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/SDK/Foundation/UUID.swift
Expand Up @@ -27,7 +27,7 @@ public struct UUID : ReferenceConvertible, Hashable, Equatable, CustomStringConv
}
}

private init(reference: NSUUID) {
fileprivate init(reference: NSUUID) {
var bytes: uuid_t = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
withUnsafeMutablePointer(&bytes) {
reference.getBytes(unsafeBitCast($0, to: UnsafeMutablePointer<UInt8>.self))
Expand Down Expand Up @@ -79,7 +79,7 @@ public struct UUID : ReferenceConvertible, Hashable, Equatable, CustomStringConv

// MARK: - Bridging Support

private var reference: NSUUID {
fileprivate var reference: NSUUID {
var bytes = uuid
return withUnsafePointer(&bytes) {
return NSUUID(uuidBytes: unsafeBitCast($0, to: UnsafePointer<UInt8>.self))
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/SDK/Foundation/UserInfo.swift
Expand Up @@ -46,8 +46,8 @@ internal class _NSUserInfoDictionaryKeyEnumerator : NSEnumerator {
}

internal class _NSUserInfoDictionary : NSMutableDictionary {
private var _objc = [NSObject : AnyObject]()
private var _swift = [NSObject : Any]()
fileprivate var _objc = [NSObject : AnyObject]()
fileprivate var _swift = [NSObject : Any]()

/// Note: these two init methods are the only proper method of construction and must be marked as "convenience" and call super.init() because the overlay has required init methods in extensions
private convenience init(objc: [NSObject : AnyObject], swift: [NSObject : Any]) {
Expand Down

0 comments on commit 0712ffc

Please sign in to comment.