Skip to content

Commit e6b286a

Browse files
authored
Merge pull request swiftlang#454 from swiftwasm/main
[pull] swiftwasm from main
2 parents 9a3d60b + 2ab55d9 commit e6b286a

File tree

8 files changed

+65
-64
lines changed

8 files changed

+65
-64
lines changed

Sources/Foundation/NSCharacterSet.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ fileprivate extension String {
6262

6363
open class NSCharacterSet : NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
6464
typealias CFType = CFCharacterSet
65-
private var _base = _CFInfo(typeID: CFCharacterSetGetTypeID())
66-
private var _hashValue = UInt(0) // CFHashCode
67-
private var _buffer: UnsafeMutableRawPointer? = nil
68-
private var _length = Int(0) // CFIndex
69-
private var _annex: UnsafeMutableRawPointer? = nil
65+
internal var _base = _CFInfo(typeID: CFCharacterSetGetTypeID())
66+
internal var _hashValue = UInt(0) // CFHashCode
67+
internal var _buffer: UnsafeMutableRawPointer? = nil
68+
internal var _length = Int(0) // CFIndex
69+
internal var _annex: UnsafeMutableRawPointer? = nil
7070

7171
internal var _cfObject: CFType {
7272
return unsafeBitCast(self, to: CFType.self)

Sources/Foundation/NSCoder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ open class NSCoder : NSObject {
743743
_hasFailed = true
744744
}
745745

746-
internal private(set) var _hasFailed = false
746+
internal var _hasFailed = false
747747

748748
open internal(set) var decodingFailurePolicy: NSCoder.DecodingFailurePolicy = .raiseException
749749

Sources/Foundation/NSData.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ extension NSData {
5656
}
5757
}
5858

59-
private final class _NSDataDeallocator {
59+
internal final class _NSDataDeallocator {
6060
var handler: (UnsafeMutableRawPointer, Int) -> Void = {_,_ in }
6161
}
6262

@@ -70,12 +70,12 @@ private let __kCFDontDeallocate: CFOptionFlags = 4
7070
open class NSData : NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
7171
typealias CFType = CFData
7272

73-
private var _base = _CFInfo(typeID: CFDataGetTypeID())
74-
private var _length: Int = 0 // CFIndex
75-
private var _capacity: Int = 0 // CFIndex
76-
private var _deallocator: UnsafeMutableRawPointer? = nil // for CF only
77-
private var _deallocHandler: _NSDataDeallocator? = _NSDataDeallocator() // for Swift
78-
private var _bytes: UnsafeMutablePointer<UInt8>? = nil
73+
internal var _base = _CFInfo(typeID: CFDataGetTypeID())
74+
internal var _length: Int = 0 // CFIndex
75+
internal var _capacity: Int = 0 // CFIndex
76+
internal var _deallocator: UnsafeMutableRawPointer? = nil // for CF only
77+
internal var _deallocHandler: _NSDataDeallocator? = _NSDataDeallocator() // for Swift
78+
internal var _bytes: UnsafeMutablePointer<UInt8>? = nil
7979

8080
internal final var _cfObject: CFType {
8181
if type(of: self) === NSData.self || type(of: self) === NSMutableData.self {
@@ -112,7 +112,7 @@ open class NSData : NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
112112
}
113113
}
114114

115-
fileprivate init(bytes: UnsafeMutableRawPointer?, length: Int, copy: Bool = false, deallocator: ((UnsafeMutableRawPointer, Int) -> Void)? = nil) {
115+
internal init(bytes: UnsafeMutableRawPointer?, length: Int, copy: Bool = false, deallocator: ((UnsafeMutableRawPointer, Int) -> Void)? = nil) {
116116
super.init()
117117
_init(bytes: bytes, length: length, copy: copy, deallocator: deallocator)
118118
}
@@ -340,7 +340,7 @@ open class NSData : NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
340340
return NSMutableData(bytes: UnsafeMutableRawPointer(mutating: bytes), length: length, copy: true, deallocator: nil)
341341
}
342342

343-
private func byteDescription(limit: Int? = nil) -> String {
343+
internal func byteDescription(limit: Int? = nil) -> String {
344344
var s = ""
345345
var i = 0
346346
while i < self.length {

Sources/Foundation/NSDictionary.swift

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,28 @@
1313
import Dispatch
1414
#endif
1515

16+
fileprivate func getDescription(of object: Any) -> String? {
17+
switch object {
18+
case let nsArray as NSArray:
19+
return nsArray.description(withLocale: nil, indent: 1)
20+
case let nsDecimalNumber as NSDecimalNumber:
21+
return nsDecimalNumber.description(withLocale: nil)
22+
case let nsDate as NSDate:
23+
return nsDate.description(with: nil)
24+
case let nsOrderedSet as NSOrderedSet:
25+
return nsOrderedSet.description(withLocale: nil)
26+
case let nsSet as NSSet:
27+
return nsSet.description(withLocale: nil)
28+
case let nsDictionary as NSDictionary:
29+
return nsDictionary.description(withLocale: nil)
30+
case let hashableObject as Dictionary<AnyHashable, Any>:
31+
return hashableObject._nsObject.description(withLocale: nil, indent: 1)
32+
default:
33+
return nil
34+
}
35+
}
36+
37+
1638
open class NSDictionary : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSCoding, ExpressibleByDictionaryLiteral {
1739
private let _cfinfo = _CFInfo(typeID: CFDictionaryGetTypeID())
1840
internal var _storage: [NSObject: AnyObject]
@@ -298,27 +320,6 @@ open class NSDictionary : NSObject, NSCopying, NSMutableCopying, NSSecureCoding,
298320
return description(withLocale: nil)
299321
}
300322

301-
private func getDescription(of object: Any) -> String? {
302-
switch object {
303-
case let nsArray as NSArray:
304-
return nsArray.description(withLocale: nil, indent: 1)
305-
case let nsDecimalNumber as NSDecimalNumber:
306-
return nsDecimalNumber.description(withLocale: nil)
307-
case let nsDate as NSDate:
308-
return nsDate.description(with: nil)
309-
case let nsOrderedSet as NSOrderedSet:
310-
return nsOrderedSet.description(withLocale: nil)
311-
case let nsSet as NSSet:
312-
return nsSet.description(withLocale: nil)
313-
case let nsDictionary as NSDictionary:
314-
return nsDictionary.description(withLocale: nil)
315-
case let hashableObject as Dictionary<AnyHashable, Any>:
316-
return hashableObject._nsObject.description(withLocale: nil, indent: 1)
317-
default:
318-
return nil
319-
}
320-
}
321-
322323
open var descriptionInStringsFileFormat: String {
323324
var lines = [String]()
324325
for key in self.allKeys {

Sources/Foundation/NSNumber.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ extension NSNumber : ExpressibleByFloatLiteral, ExpressibleByIntegerLiteral, Exp
594594

595595
}
596596

597-
private struct CFSInt128Struct {
597+
internal struct CFSInt128Struct {
598598
var high: Int64
599599
var low: UInt64
600600
}
@@ -606,8 +606,8 @@ fileprivate func cast<T, U>(_ t: T) -> U {
606606
open class NSNumber : NSValue {
607607
typealias CFType = CFNumber
608608
// This layout MUST be the same as CFNumber so that they are bridgeable
609-
private var _base = _CFInfo(typeID: CFNumberGetTypeID())
610-
private var _pad: UInt64 = 0
609+
internal var _base = _CFInfo(typeID: CFNumberGetTypeID())
610+
internal var _pad: UInt64 = 0
611611

612612
internal final var _cfObject: CFType {
613613
return unsafeBitCast(self, to: CFType.self)
@@ -905,7 +905,7 @@ open class NSNumber : NSValue {
905905
return .init(truncatingIfNeeded: value.low)
906906
}
907907

908-
private var int128Value: CFSInt128Struct {
908+
internal var int128Value: CFSInt128Struct {
909909
var value = CFSInt128Struct(high: 0, low: 0)
910910
CFNumberGetValue(_cfObject, kCFNumberSInt128Type, &value)
911911
return value

Sources/Foundation/NSObject.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ open class NSObject : NSObjectProtocol, Equatable, Hashable {
367367
// Please note:
368368
// the following methods are not overridable in swift-corelibs-foundation.
369369

370-
private class var nsObjectSuperclass: NSObject.Type? {
370+
internal class var nsObjectSuperclass: NSObject.Type? {
371371
// Pretend that {Swift,}Foundation.NSObject is the top of the class hierarchy.
372372
// On Darwin, avoids dipping into the class hierarchy that exists above this class,
373373
// which is ultimately rooted in the ObjC NSObject class.

Sources/Foundation/Progress.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ import Dispatch
3131
*/
3232
open class Progress : NSObject {
3333

34-
private weak var _parent : Progress?
35-
private var _children : Set<Progress>
36-
private var _selfFraction : _ProgressFraction
37-
private var _childFraction : _ProgressFraction
38-
private var _userInfo : [ProgressUserInfoKey : Any]
34+
internal weak var _parent : Progress?
35+
internal var _children : Set<Progress>
36+
internal var _selfFraction : _ProgressFraction
37+
internal var _childFraction : _ProgressFraction
38+
internal var _userInfo : [ProgressUserInfoKey : Any]
3939

4040
// This is set once, but after initialization
41-
private var _portionOfParent : Int64
41+
internal var _portionOfParent : Int64
4242

4343
static private var _tsdKey = "_Foundation_CurrentProgressKey"
4444

@@ -168,7 +168,7 @@ open class Progress : NSObject {
168168
}
169169
}
170170

171-
private func _setParent(_ parent: Progress, portion: Int64) {
171+
internal func _setParent(_ parent: Progress, portion: Int64) {
172172
_parent = parent
173173
_portionOfParent = portion
174174

@@ -417,18 +417,18 @@ open class Progress : NSObject {
417417
// MARK: -
418418
// MARK: Implementation of unit counts
419419

420-
private var _overallFraction : _ProgressFraction {
420+
internal var _overallFraction : _ProgressFraction {
421421
return _selfFraction + _childFraction
422422
}
423423

424-
private func _addCompletedUnitCount(_ unitCount : Int64) {
424+
internal func _addCompletedUnitCount(_ unitCount : Int64) {
425425
let old = _overallFraction
426426
_selfFraction.completed += unitCount
427427
let new = _overallFraction
428428
_updateFractionCompleted(from: old, to: new)
429429
}
430430

431-
private func _updateFractionCompleted(from: _ProgressFraction, to: _ProgressFraction) {
431+
internal func _updateFractionCompleted(from: _ProgressFraction, to: _ProgressFraction) {
432432
if from != to {
433433
_parent?._updateChild(self, from: from, to: to, portion: _portionOfParent)
434434
}

Tests/Foundation/Tests/TestNSData.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ import CoreFoundation
2020
class TestNSData: LoopbackServerTest {
2121

2222
class AllOnesImmutableData : NSData {
23-
private var _length : Int
23+
private var __length : Int
2424
var _pointer : UnsafeMutableBufferPointer<UInt8>? {
2525
willSet {
2626
if let p = _pointer { free(p.baseAddress) }
2727
}
2828
}
2929

3030
init(length: Int) {
31-
_length = length
31+
__length = length
3232
super.init()
3333
}
3434

@@ -45,7 +45,7 @@ class TestNSData: LoopbackServerTest {
4545

4646
override var length : Int {
4747
get {
48-
return _length
48+
return __length
4949
}
5050
}
5151

@@ -78,15 +78,15 @@ class TestNSData: LoopbackServerTest {
7878

7979
class AllOnesData : NSMutableData {
8080

81-
private var _length : Int
81+
private var __length : Int
8282
var _pointer : UnsafeMutableBufferPointer<UInt8>? {
8383
willSet {
8484
if let p = _pointer { free(p.baseAddress) }
8585
}
8686
}
8787

8888
override init(length: Int) {
89-
_length = length
89+
__length = length
9090
super.init()
9191
}
9292

@@ -103,22 +103,22 @@ class TestNSData: LoopbackServerTest {
103103

104104
override var length : Int {
105105
get {
106-
return _length
106+
return __length
107107
}
108108
set {
109109
if let ptr = _pointer {
110110
// Copy the data to our new length buffer
111111
let newBuffer = malloc(newValue)!
112-
if newValue <= _length {
112+
if newValue <= __length {
113113
memmove(newBuffer, ptr.baseAddress!, newValue)
114-
} else if newValue > _length {
115-
memmove(newBuffer, ptr.baseAddress!, _length)
116-
memset(newBuffer + _length, 1, newValue - _length)
114+
} else if newValue > __length {
115+
memmove(newBuffer, ptr.baseAddress!, __length)
116+
memset(newBuffer + __length, 1, newValue - __length)
117117
}
118118
let bytePtr = newBuffer.bindMemory(to: UInt8.self, capacity: newValue)
119119
_pointer = UnsafeMutableBufferPointer(start: bytePtr, count: newValue)
120120
}
121-
_length = newValue
121+
__length = newValue
122122
}
123123
}
124124

@@ -138,7 +138,7 @@ class TestNSData: LoopbackServerTest {
138138
}
139139

140140
override var mutableBytes: UnsafeMutableRawPointer {
141-
let newBufferLength = _length
141+
let newBufferLength = __length
142142
let newBuffer = malloc(newBufferLength)
143143
if let ptr = _pointer {
144144
// Copy the existing data to the new box, then return its pointer
@@ -150,7 +150,7 @@ class TestNSData: LoopbackServerTest {
150150
let bytePtr = newBuffer!.bindMemory(to: UInt8.self, capacity: newBufferLength)
151151
let result = UnsafeMutableBufferPointer(start: bytePtr, count: newBufferLength)
152152
_pointer = result
153-
_length = newBufferLength
153+
__length = newBufferLength
154154
return UnsafeMutableRawPointer(result.baseAddress!)
155155
}
156156

0 commit comments

Comments
 (0)