Skip to content
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

fileprivate updates #413

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion Foundation/NSAffineTransform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public class NSAffineTransform : NSObject, NSCopying, NSSecureCoding {
[ m21 m22 0 ]
[ tX tY 1 ]
*/
private extension NSAffineTransformStruct {
fileprivate extension NSAffineTransformStruct {
/**
Creates an affine transformation matrix from translation values.
The matrix takes the following form:
Expand Down
2 changes: 1 addition & 1 deletion Foundation/NSArray.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ extension Array : _ObjectTypeBridgeable {
}

public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSCoding {
private let _cfinfo = _CFInfo(typeID: CFArrayGetTypeID())
fileprivate let _cfinfo = _CFInfo(typeID: CFArrayGetTypeID())
internal var _storage = [AnyObject]()

public var count: Int {
Expand Down
8 changes: 4 additions & 4 deletions Foundation/NSAttributedString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import CoreFoundation

public class NSAttributedString : NSObject, NSCopying, NSMutableCopying, NSSecureCoding {

private let _cfinfo = _CFInfo(typeID: CFAttributedStringGetTypeID())
private let _string: NSString
private let _attributeArray: CFRunArrayRef
fileprivate let _cfinfo = _CFInfo(typeID: CFAttributedStringGetTypeID())
fileprivate let _string: NSString
fileprivate let _attributeArray: CFRunArrayRef

public required init?(coder aDecoder: NSCoder) {
NSUnimplemented()
Expand Down Expand Up @@ -120,7 +120,7 @@ public class NSAttributedString : NSObject, NSCopying, NSMutableCopying, NSSecur

public init(attributedString attrStr: NSAttributedString) { NSUnimplemented() }

private func addAttributesToAttributeArray(attrs: [String : AnyObject]?) {
fileprivate func addAttributesToAttributeArray(attrs: [String : AnyObject]?) {
guard _string.length > 0 else {
return
}
Expand Down
4 changes: 2 additions & 2 deletions Foundation/NSBundle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import CoreFoundation

public class NSBundle : NSObject {
private var _bundle : CFBundle!
fileprivate var _bundle : CFBundle!

private static var _mainBundle : NSBundle = {
fileprivate static var _mainBundle : NSBundle = {
return NSBundle(cfBundle: CFBundleGetMainBundle())
}()

Expand Down
2 changes: 1 addition & 1 deletion Foundation/NSCFDictionary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ internal final class _NSCFDictionary : NSMutableDictionary {
}

// This doesn't feel like a particularly efficient generator of CFDictionary keys, but it works for now. We should probably put a function into CF that allows us to simply iterate the keys directly from the underlying CF storage.
private struct _NSCFKeyGenerator : IteratorProtocol {
fileprivate struct _NSCFKeyGenerator : IteratorProtocol {
var keyArray : [NSObject] = []
var index : Int = 0
let count : Int
Expand Down
14 changes: 7 additions & 7 deletions Foundation/NSCache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


public class NSCache : NSObject {
private class NSCacheEntry {
fileprivate class NSCacheEntry {
var key: AnyObject
var value: AnyObject
var cost: Int
Expand All @@ -22,10 +22,10 @@ public class NSCache : NSObject {
}
}

private var _entries = Dictionary<UnsafePointer<Void>, NSCacheEntry>()
private let _lock = NSLock()
private var _totalCost = 0
private var _byCost: NSCacheEntry?
fileprivate var _entries = Dictionary<UnsafePointer<Void>, NSCacheEntry>()
fileprivate let _lock = NSLock()
fileprivate var _totalCost = 0
fileprivate var _byCost: NSCacheEntry?

public var name: String = ""
public var totalCostLimit: Int = -1 // limits are imprecise/not strict
Expand Down Expand Up @@ -56,7 +56,7 @@ public class NSCache : NSObject {
setObject(obj, forKey: key, cost: 0)
}

private func remove(_ entry: NSCacheEntry) {
fileprivate func remove(_ entry: NSCacheEntry) {
let oldPrev = entry.prevByCost
let oldNext = entry.nextByCost
oldPrev?.nextByCost = oldNext
Expand All @@ -66,7 +66,7 @@ public class NSCache : NSObject {
}
}

private func insert(_ entry: NSCacheEntry) {
fileprivate func insert(_ entry: NSCacheEntry) {
if _byCost == nil {
_byCost = entry
} else {
Expand Down
30 changes: 15 additions & 15 deletions Foundation/NSCalendar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ public struct NSCalendarOptions : OptionSet {

public class NSCalendar : NSObject, NSCopying, NSSecureCoding {
typealias CFType = CFCalendar
private var _base = _CFInfo(typeID: CFCalendarGetTypeID())
private var _identifier: UnsafeMutablePointer<Void>? = nil
private var _locale: UnsafeMutablePointer<Void>? = nil
private var _localeID: UnsafeMutablePointer<Void>? = nil
private var _tz: UnsafeMutablePointer<Void>? = nil
private var _cal: UnsafeMutablePointer<Void>? = nil
fileprivate var _base = _CFInfo(typeID: CFCalendarGetTypeID())
fileprivate var _identifier: UnsafeMutablePointer<Void>? = nil
fileprivate var _locale: UnsafeMutablePointer<Void>? = nil
fileprivate var _localeID: UnsafeMutablePointer<Void>? = nil
fileprivate var _tz: UnsafeMutablePointer<Void>? = nil
fileprivate var _cal: UnsafeMutablePointer<Void>? = nil

internal var _cfObject: CFType {
return unsafeBitCast(self, to: CFCalendar.self)
Expand Down Expand Up @@ -130,7 +130,7 @@ public class NSCalendar : NSObject, NSCopying, NSSecureCoding {
}
}

private var _startDate : NSDate? {
fileprivate var _startDate : NSDate? {
get {
return CFCalendarCopyGregorianStartDate(self._cfObject)?._nsObject
}
Expand Down Expand Up @@ -250,7 +250,7 @@ public class NSCalendar : NSObject, NSCopying, NSSecureCoding {

// Methods to return component name strings localized to the calendar's locale

private func _symbols(_ key: CFString) -> [String] {
fileprivate func _symbols(_ key: CFString) -> [String] {
let dateFormatter = CFDateFormatterCreate(kCFAllocatorSystemDefault, locale?._cfObject, kCFDateFormatterNoStyle, kCFDateFormatterNoStyle)
CFDateFormatterSetProperty(dateFormatter, kCFDateFormatterCalendarKey, _cfObject)
let result = (CFDateFormatterCopyProperty(dateFormatter, key) as! CFArray)._swiftObject
Expand All @@ -259,7 +259,7 @@ public class NSCalendar : NSObject, NSCopying, NSSecureCoding {
}
}

private func _symbol(_ key: CFString) -> String {
fileprivate func _symbol(_ key: CFString) -> String {
let dateFormatter = CFDateFormatterCreate(kCFAllocatorSystemDefault, locale?._cfObject, kCFDateFormatterNoStyle, kCFDateFormatterNoStyle)
CFDateFormatterSetProperty(dateFormatter, kCFDateFormatterCalendarKey, self._cfObject)
return (CFDateFormatterCopyProperty(dateFormatter, key) as! CFString)._swiftObject
Expand Down Expand Up @@ -394,14 +394,14 @@ public class NSCalendar : NSObject, NSCopying, NSSecureCoding {
return nil
}

private func _convert(_ component: Int, type: String, vector: inout [Int32], compDesc: inout [Int8]) {
fileprivate func _convert(_ component: Int, type: String, vector: inout [Int32], compDesc: inout [Int8]) {
if component != NSDateComponentUndefined {
vector.append(Int32(component))
compDesc.append(Int8(type.utf8[type.utf8.startIndex]))
}
}

private func _convert(_ comps: NSDateComponents) -> (Array<Int32>, Array<Int8>) {
fileprivate func _convert(_ comps: NSDateComponents) -> (Array<Int32>, Array<Int8>) {
var vector = [Int32]()
var compDesc = [Int8]()
_convert(comps.era, type: "E", vector: &vector, compDesc: &compDesc)
Expand Down Expand Up @@ -446,13 +446,13 @@ public class NSCalendar : NSObject, NSCopying, NSSecureCoding {
}
}

private func _setup(_ unitFlags: NSCalendarUnit, field: NSCalendarUnit, type: String, compDesc: inout [Int8]) {
fileprivate func _setup(_ unitFlags: NSCalendarUnit, field: NSCalendarUnit, type: String, compDesc: inout [Int8]) {
if unitFlags.contains(field) {
compDesc.append(Int8(type.utf8[type.utf8.startIndex]))
}
}

private func _setup(_ unitFlags: NSCalendarUnit) -> [Int8] {
fileprivate func _setup(_ unitFlags: NSCalendarUnit) -> [Int8] {
var compDesc = [Int8]()
_setup(unitFlags, field: .era, type: "G", compDesc: &compDesc)
_setup(unitFlags, field: .year, type: "y", compDesc: &compDesc)
Expand All @@ -473,14 +473,14 @@ public class NSCalendar : NSObject, NSCopying, NSSecureCoding {
return compDesc
}

private func _setComp(_ unitFlags: NSCalendarUnit, field: NSCalendarUnit, vector: [Int32], compIndex: inout Int, setter: (Int32) -> Void) {
fileprivate func _setComp(_ unitFlags: NSCalendarUnit, field: NSCalendarUnit, vector: [Int32], compIndex: inout Int, setter: (Int32) -> Void) {
if unitFlags.contains(field) {
setter(vector[compIndex])
compIndex += 1
}
}

private func _components(_ unitFlags: NSCalendarUnit, vector: [Int32]) -> NSDateComponents {
fileprivate func _components(_ unitFlags: NSCalendarUnit, vector: [Int32]) -> NSDateComponents {
var compIdx = 0
let comps = NSDateComponents()
_setComp(unitFlags, field: .era, vector: vector, compIndex: &compIdx) { comps.era = Int($0) }
Expand Down
10 changes: 5 additions & 5 deletions Foundation/NSCharacterSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ let kCFCharacterSetIllegal = CFCharacterSetPredefinedSet.illegal

public class NSCharacterSet : NSObject, NSCopying, NSMutableCopying, NSCoding {
typealias CFType = CFCharacterSet
private var _base = _CFInfo(typeID: CFCharacterSetGetTypeID())
private var _hashValue = CFHashCode(0)
private var _buffer: UnsafeMutablePointer<Void>? = nil
private var _length = CFIndex(0)
private var _annex: UnsafeMutablePointer<Void>? = nil
fileprivate var _base = _CFInfo(typeID: CFCharacterSetGetTypeID())
fileprivate var _hashValue = CFHashCode(0)
fileprivate var _buffer: UnsafeMutablePointer<Void>? = nil
fileprivate var _length = CFIndex(0)
fileprivate var _annex: UnsafeMutablePointer<Void>? = nil

internal var _cfObject: CFType {
return unsafeBitCast(self, to: CFType.self)
Expand Down
14 changes: 7 additions & 7 deletions Foundation/NSConcreteValue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ internal class NSConcreteValue : NSValue {
}
}

private static var _cachedTypeInfo = Dictionary<String, TypeInfo>()
private static var _cachedTypeInfoLock = NSLock()
fileprivate static var _cachedTypeInfo = Dictionary<String, TypeInfo>()
fileprivate static var _cachedTypeInfoLock = NSLock()

private var _typeInfo : TypeInfo
private var _storage : UnsafeMutablePointer<UInt8>
fileprivate var _typeInfo : TypeInfo
fileprivate var _storage : UnsafeMutablePointer<UInt8>

required init(bytes value: UnsafePointer<Void>, objCType type: UnsafePointer<Int8>) {
let spec = String(cString: type)
Expand Down Expand Up @@ -141,15 +141,15 @@ internal class NSConcreteValue : NSValue {
}
}

private var _size : Int {
fileprivate var _size : Int {
return self._typeInfo.size
}

private var value : UnsafeMutablePointer<Void> {
fileprivate var value : UnsafeMutablePointer<Void> {
return unsafeBitCast(self._storage, to: UnsafeMutablePointer<Void>.self)
}

private func _isEqualToValue(_ other: NSConcreteValue) -> Bool {
fileprivate func _isEqualToValue(_ other: NSConcreteValue) -> Bool {
if self === other {
return true
}
Expand Down
46 changes: 23 additions & 23 deletions Foundation/NSData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,26 @@ public struct NSDataBase64DecodingOptions : OptionSet {
public static let anchored = NSDataSearchOptions(rawValue: UInt(1 << 1))
}

private final class _NSDataDeallocator {
fileprivate final class _NSDataDeallocator {
var handler: (UnsafeMutablePointer<Void>, Int) -> Void = {_,_ in }
}

private let __kCFMutable: CFOptionFlags = 0x01
private let __kCFGrowable: CFOptionFlags = 0x02
private let __kCFMutableVarietyMask: CFOptionFlags = 0x03
private let __kCFBytesInline: CFOptionFlags = 0x04
private let __kCFUseAllocator: CFOptionFlags = 0x08
private let __kCFDontDeallocate: CFOptionFlags = 0x10
private let __kCFAllocatesCollectable: CFOptionFlags = 0x20
fileprivate let __kCFMutable: CFOptionFlags = 0x01
fileprivate let __kCFGrowable: CFOptionFlags = 0x02
fileprivate let __kCFMutableVarietyMask: CFOptionFlags = 0x03
fileprivate let __kCFBytesInline: CFOptionFlags = 0x04
fileprivate let __kCFUseAllocator: CFOptionFlags = 0x08
fileprivate let __kCFDontDeallocate: CFOptionFlags = 0x10
fileprivate let __kCFAllocatesCollectable: CFOptionFlags = 0x20

public class NSData : NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
typealias CFType = CFData
private var _base = _CFInfo(typeID: CFDataGetTypeID())
private var _length: CFIndex = 0
private var _capacity: CFIndex = 0
private var _deallocator: UnsafeMutablePointer<Void>? = nil // for CF only
private var _deallocHandler: _NSDataDeallocator? = _NSDataDeallocator() // for Swift
private var _bytes: UnsafeMutablePointer<UInt8>? = nil
fileprivate var _base = _CFInfo(typeID: CFDataGetTypeID())
fileprivate var _length: CFIndex = 0
fileprivate var _capacity: CFIndex = 0
fileprivate var _deallocator: UnsafeMutablePointer<Void>? = nil // for CF only
fileprivate var _deallocHandler: _NSDataDeallocator? = _NSDataDeallocator() // for Swift
fileprivate var _bytes: UnsafeMutablePointer<UInt8>? = nil

internal var _cfObject: CFType {
if self.dynamicType === NSData.self || self.dynamicType === NSMutableData.self {
Expand Down Expand Up @@ -185,7 +185,7 @@ public class NSData : NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
return true
}

private func byteDescription(limit: Int? = nil) -> String {
fileprivate func byteDescription(limit: Int? = nil) -> String {
var s = ""
let buffer = UnsafePointer<UInt8>(bytes)
var i = 0
Expand Down Expand Up @@ -539,7 +539,7 @@ extension NSData {
}
return location.map {NSRange(location: $0, length: search.count)} ?? NSRange(location: NSNotFound, length: 0)
}
private static func searchSubSequence<T : Collection, T2 : Sequence where T.Iterator.Element : Equatable, T.Iterator.Element == T2.Iterator.Element, T.SubSequence.Iterator.Element == T.Iterator.Element, T.Indices.Iterator.Element == T.Index>(_ subSequence : T2, inSequence seq: T,anchored : Bool) -> T.Index? {
fileprivate static func searchSubSequence<T : Collection, T2 : Sequence where T.Iterator.Element : Equatable, T.Iterator.Element == T2.Iterator.Element, T.SubSequence.Iterator.Element == T.Iterator.Element, T.Indices.Iterator.Element == T.Index>(_ subSequence : T2, inSequence seq: T,anchored : Bool) -> T.Index? {
for index in seq.indices {
if seq.suffix(from: index).starts(with: subSequence) {
return index
Expand Down Expand Up @@ -655,7 +655,7 @@ extension NSData {
/**
The ranges of ASCII characters that are used to encode data in Base64.
*/
private static let base64ByteMappings: [Range<UInt8>] = [
fileprivate static let base64ByteMappings: [Range<UInt8>] = [
65 ..< 91, // A-Z
97 ..< 123, // a-z
48 ..< 58, // 0-9
Expand All @@ -665,7 +665,7 @@ extension NSData {
/**
Padding character used when the number of bytes to encode is not divisible by 3
*/
private static let base64Padding : UInt8 = 61 // =
fileprivate static let base64Padding : UInt8 = 61 // =

/**
This method takes a byte with a character from Base64-encoded string
Expand All @@ -674,12 +674,12 @@ extension NSData {
- parameter byte: The byte with the Base64 character.
- returns: Base64DecodedByte value containing the result (Valid , Invalid, Padding)
*/
private enum Base64DecodedByte {
fileprivate enum Base64DecodedByte {
case Valid(UInt8)
case Invalid
case Padding
}
private static func base64DecodeByte(_ byte: UInt8) -> Base64DecodedByte {
fileprivate static func base64DecodeByte(_ byte: UInt8) -> Base64DecodedByte {
guard byte != base64Padding else {return .Padding}
var decodedStart: UInt8 = 0
for range in base64ByteMappings {
Expand All @@ -702,7 +702,7 @@ extension NSData {
- parameter byte: The byte to encode
- returns: The ASCII value for the encoded character.
*/
private static func base64EncodeByte(_ byte: UInt8) -> UInt8 {
fileprivate static func base64EncodeByte(_ byte: UInt8) -> UInt8 {
assert(byte < 64)
var decodedStart: UInt8 = 0
for range in base64ByteMappings {
Expand All @@ -726,7 +726,7 @@ extension NSData {
- parameter options: Options for handling invalid input
- returns: The decoded bytes.
*/
private static func base64DecodeBytes(_ bytes: [UInt8], options: NSDataBase64DecodingOptions = []) -> [UInt8]? {
fileprivate static func base64DecodeBytes(_ bytes: [UInt8], options: NSDataBase64DecodingOptions = []) -> [UInt8]? {
var decodedBytes = [UInt8]()
decodedBytes.reserveCapacity((bytes.count/3)*2)

Expand Down Expand Up @@ -796,7 +796,7 @@ extension NSData {
- parameter options: Options for formatting the result
- returns: The Base64-encoding for those bytes.
*/
private static func base64EncodeBytes(_ bytes: [UInt8], options: NSDataBase64EncodingOptions = []) -> [UInt8] {
fileprivate static func base64EncodeBytes(_ bytes: [UInt8], options: NSDataBase64EncodingOptions = []) -> [UInt8] {
var result = [UInt8]()
result.reserveCapacity((bytes.count/3)*4)

Expand Down
8 changes: 4 additions & 4 deletions Foundation/NSDateFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import CoreFoundation

public class NSDateFormatter : NSFormatter {
typealias CFType = CFDateFormatter
private var __cfObject: CFType?
private var _cfObject: CFType {
fileprivate var __cfObject: CFType?
fileprivate var _cfObject: CFType {
guard let obj = __cfObject else {
#if os(OSX) || os(iOS)
let dateStyle = CFDateFormatterStyle(rawValue: CFIndex(self.dateStyle.rawValue))!
Expand Down Expand Up @@ -83,7 +83,7 @@ public class NSDateFormatter : NSFormatter {
NSUnimplemented()
}

private func _reset() {
fileprivate func _reset() {
__cfObject = nil
}

Expand Down Expand Up @@ -123,7 +123,7 @@ public class NSDateFormatter : NSFormatter {
}
}

private var _dateFormat: String? { willSet { _reset() } }
fileprivate var _dateFormat: String? { willSet { _reset() } }
public var dateFormat: String! {
get {
guard let format = _dateFormat else {
Expand Down
Loading