Skip to content

Commit f767040

Browse files
authored
Merge pull request #13316 from ikesyo/nsrange-init
2 parents 3866bd2 + dacd46c commit f767040

File tree

3 files changed

+30
-30
lines changed

3 files changed

+30
-30
lines changed

stdlib/public/SDK/Foundation/Data.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
13721372

13731373
guard !copyRange.isEmpty else { return 0 }
13741374

1375-
let nsRange = NSMakeRange(copyRange.lowerBound, copyRange.upperBound - copyRange.lowerBound)
1375+
let nsRange = NSRange(location: copyRange.lowerBound, length: copyRange.upperBound - copyRange.lowerBound)
13761376
_copyBytesHelper(to: buffer.baseAddress!, from: nsRange)
13771377
return copyRange.count
13781378
}
@@ -1428,9 +1428,9 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
14281428
let nsRange : NSRange
14291429
if let r = range {
14301430
_validateRange(r)
1431-
nsRange = NSMakeRange(r.lowerBound, r.upperBound - r.lowerBound)
1431+
nsRange = NSRange(location: r.lowerBound, length: r.upperBound - r.lowerBound)
14321432
} else {
1433-
nsRange = NSMakeRange(0, _backing.length)
1433+
nsRange = NSRange(location: 0, length: _backing.length)
14341434
}
14351435
let result = _backing.withInteriorPointerReference(_sliceRange) {
14361436
$0.range(of: dataToFind, options: options, in: nsRange)
@@ -1512,7 +1512,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
15121512
// it is worth noting that the range here may be out of bounds of the Data itself (which triggers a growth)
15131513
precondition(range.lowerBound >= 0, "Ranges must not be negative bounds")
15141514
precondition(range.upperBound >= 0, "Ranges must not be negative bounds")
1515-
let range = NSMakeRange(range.lowerBound, range.upperBound - range.lowerBound)
1515+
let range = NSRange(location: range.lowerBound, length: range.upperBound - range.lowerBound)
15161516
if !isKnownUniquelyReferenced(&_backing) {
15171517
_backing = _backing.mutableCopy(_sliceRange)
15181518
}
@@ -1581,7 +1581,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
15811581
@inline(__always)
15821582
public mutating func replaceSubrange(_ subrange: Range<Index>, with bytes: UnsafeRawPointer, count cnt: Int) {
15831583
_validateRange(subrange)
1584-
let nsRange = NSMakeRange(subrange.lowerBound, subrange.upperBound - subrange.lowerBound)
1584+
let nsRange = NSRange(location: subrange.lowerBound, length: subrange.upperBound - subrange.lowerBound)
15851585
if !isKnownUniquelyReferenced(&_backing) {
15861586
_backing = _backing.mutableCopy(_sliceRange)
15871587
}

stdlib/public/SDK/Foundation/IndexSet.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ extension IndexSet {
791791
}
792792

793793
private func _toNSRange(_ r: Range<IndexSet.Element>) -> NSRange {
794-
return NSMakeRange(r.lowerBound, r.upperBound - r.lowerBound)
794+
return NSRange(location: r.lowerBound, length: r.upperBound - r.lowerBound)
795795
}
796796

797797
extension IndexSet : _ObjectiveCBridgeable {

stdlib/public/SDK/Metal/Metal.swift

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
extension MTLBlitCommandEncoder {
1818

1919
public func fill(buffer: MTLBuffer, range: Range<Int>, value: UInt8) {
20-
__fill(buffer, range: NSMakeRange(range.lowerBound, range.count), value: value)
20+
__fill(buffer, range: NSRange(location: range.lowerBound, length: range.count), value: value)
2121
}
2222
}
2323

@@ -28,13 +28,13 @@ extension MTLBuffer {
2828
#if os(OSX)
2929
@available(macOS, introduced: 10.11)
3030
public func didModifyRange(_ range: Range<Int>) {
31-
__didModifyRange(NSMakeRange(range.lowerBound, range.count))
31+
__didModifyRange(NSRange(location: range.lowerBound, length: range.count))
3232
}
3333
#endif
3434

3535
@available(macOS 10.12, iOS 10.0, tvOS 10.0, *)
3636
public func addDebugMarker(_ marker: String, range: Range<Int>) {
37-
__addDebugMarker(marker, range: NSMakeRange(range.lowerBound, range.count))
37+
__addDebugMarker(marker, range: NSRange(location: range.lowerBound, length: range.count))
3838
}
3939
}
4040

@@ -53,19 +53,19 @@ extension MTLComputeCommandEncoder {
5353
}
5454

5555
public func setBuffers(_ buffers: [MTLBuffer?], offsets: [Int], range: Range<Int>) {
56-
__setBuffers(buffers, offsets: offsets, with: NSMakeRange(range.lowerBound, range.count))
56+
__setBuffers(buffers, offsets: offsets, with: NSRange(location: range.lowerBound, length: range.count))
5757
}
5858

5959
public func setTextures(_ textures: [MTLTexture?], range: Range<Int>) {
60-
__setTextures(textures, with: NSMakeRange(range.lowerBound, range.count))
60+
__setTextures(textures, with: NSRange(location: range.lowerBound, length: range.count))
6161
}
6262

6363
public func setSamplerStates(_ samplers: [MTLSamplerState?], range: Range<Int>) {
64-
__setSamplerStates(samplers, with: NSMakeRange(range.lowerBound, range.count))
64+
__setSamplerStates(samplers, with: NSRange(location: range.lowerBound, length: range.count))
6565
}
6666

6767
public func setSamplerStates(_ samplers: [MTLSamplerState?], lodMinClamps: [Float], lodMaxClamps: [Float], range: Range<Int>) {
68-
__setSamplerStates(samplers, lodMinClamps: lodMinClamps, lodMaxClamps: lodMaxClamps, with: NSMakeRange(range.lowerBound, range.count))
68+
__setSamplerStates(samplers, lodMinClamps: lodMinClamps, lodMaxClamps: lodMaxClamps, with: NSRange(location: range.lowerBound, length: range.count))
6969
}
7070
}
7171

@@ -97,7 +97,7 @@ public func MTLCopyAllDevicesWithObserver(handler: @escaping MTLDeviceNotificati
9797
extension MTLFunctionConstantValues {
9898

9999
public func setConstantValues(_ values: UnsafeRawPointer, type: MTLDataType, range: Range<Int>) {
100-
__setConstantValues(values, type: type, with: NSMakeRange(range.lowerBound, range.count))
100+
__setConstantValues(values, type: type, with: NSRange(location: range.lowerBound, length: range.count))
101101
}
102102

103103
}
@@ -107,15 +107,15 @@ extension MTLFunctionConstantValues {
107107
extension MTLArgumentEncoder {
108108

109109
public func setBuffers(_ buffers: [MTLBuffer?], offsets: [Int], range: Range<Int>) {
110-
__setBuffers(buffers, offsets: offsets, with: NSMakeRange(range.lowerBound, range.count))
110+
__setBuffers(buffers, offsets: offsets, with: NSRange(location: range.lowerBound, length: range.count))
111111
}
112112

113113
public func setTextures(_ textures: [MTLTexture?], range: Range<Int>) {
114-
__setTextures(textures, with: NSMakeRange(range.lowerBound, range.count))
114+
__setTextures(textures, with: NSRange(location: range.lowerBound, length: range.count))
115115
}
116116

117117
public func setSamplerStates(_ samplers: [MTLSamplerState?], range: Range<Int>) {
118-
__setSamplerStates(samplers, with: NSMakeRange(range.lowerBound, range.count))
118+
__setSamplerStates(samplers, with: NSRange(location: range.lowerBound, length: range.count))
119119
}
120120
}
121121

@@ -146,57 +146,57 @@ extension MTLRenderCommandEncoder {
146146
#endif
147147

148148
public func setVertexBuffers(_ buffers: [MTLBuffer?], offsets: [Int], range: Range<Int>) {
149-
__setVertexBuffers(buffers, offsets: offsets, with: NSMakeRange(range.lowerBound, range.count))
149+
__setVertexBuffers(buffers, offsets: offsets, with: NSRange(location: range.lowerBound, length: range.count))
150150
}
151151

152152
public func setVertexTextures(_ textures: [MTLTexture?], range: Range<Int>) {
153-
__setVertexTextures(textures, with: NSMakeRange(range.lowerBound, range.count))
153+
__setVertexTextures(textures, with: NSRange(location: range.lowerBound, length: range.count))
154154
}
155155

156156
public func setVertexSamplerStates(_ samplers: [MTLSamplerState?], range: Range<Int>) {
157-
__setVertexSamplerStates(samplers, with: NSMakeRange(range.lowerBound, range.count))
157+
__setVertexSamplerStates(samplers, with: NSRange(location: range.lowerBound, length: range.count))
158158
}
159159

160160
public func setVertexSamplerStates(_ samplers: [MTLSamplerState?], lodMinClamps: [Float], lodMaxClamps: [Float], range: Range<Int>) {
161-
__setVertexSamplerStates(samplers, lodMinClamps: lodMinClamps, lodMaxClamps: lodMaxClamps, with: NSMakeRange(range.lowerBound, range.count))
161+
__setVertexSamplerStates(samplers, lodMinClamps: lodMinClamps, lodMaxClamps: lodMaxClamps, with: NSRange(location: range.lowerBound, length: range.count))
162162
}
163163

164164
public func setFragmentBuffers(_ buffers: [MTLBuffer?], offsets: [Int], range: Range<Int>) {
165-
__setFragmentBuffers(buffers, offsets: offsets, with: NSMakeRange(range.lowerBound, range.count))
165+
__setFragmentBuffers(buffers, offsets: offsets, with: NSRange(location: range.lowerBound, length: range.count))
166166
}
167167

168168
public func setFragmentTextures(_ textures: [MTLTexture?], range: Range<Int>) {
169-
__setFragmentTextures(textures, with: NSMakeRange(range.lowerBound, range.count))
169+
__setFragmentTextures(textures, with: NSRange(location: range.lowerBound, length: range.count))
170170
}
171171

172172
public func setFragmentSamplerStates(_ samplers: [MTLSamplerState?], range: Range<Int>) {
173-
__setFragmentSamplerStates(samplers, with: NSMakeRange(range.lowerBound, range.count))
173+
__setFragmentSamplerStates(samplers, with: NSRange(location: range.lowerBound, length: range.count))
174174
}
175175

176176
public func setFragmentSamplerStates(_ samplers: [MTLSamplerState?], lodMinClamps: [Float], lodMaxClamps: [Float], range: Range<Int>) {
177-
__setFragmentSamplerStates(samplers, lodMinClamps: lodMinClamps, lodMaxClamps: lodMaxClamps, with: NSMakeRange(range.lowerBound, range.count))
177+
__setFragmentSamplerStates(samplers, lodMinClamps: lodMinClamps, lodMaxClamps: lodMaxClamps, with: NSRange(location: range.lowerBound, length: range.count))
178178
}
179179

180180
#if os(iOS)
181181

182182
@available(iOS 11.0, *)
183183
public func setTileBuffers(_ buffers: [MTLBuffer?], offsets: [Int], range: Range<Int>) {
184-
__setTileBuffers(buffers, offsets: offsets, with: NSMakeRange(range.lowerBound, range.count))
184+
__setTileBuffers(buffers, offsets: offsets, with: NSRange(location: range.lowerBound, length: range.count))
185185
}
186186

187187
@available(iOS 11.0, *)
188188
public func setTileTextures(_ textures: [MTLTexture?], range: Range<Int>) {
189-
__setTileTextures(textures, with: NSMakeRange(range.lowerBound, range.count))
189+
__setTileTextures(textures, with: NSRange(location: range.lowerBound, length: range.count))
190190
}
191191

192192
@available(iOS 11.0, *)
193193
public func setTileSamplerStates(_ samplers: [MTLSamplerState?], range: Range<Int>) {
194-
__setTileSamplerStates(samplers, with: NSMakeRange(range.lowerBound, range.count))
194+
__setTileSamplerStates(samplers, with: NSRange(location: range.lowerBound, length: range.count))
195195
}
196196

197197
@available(iOS 11.0, *)
198198
public func setTileSamplerStates(_ samplers: [MTLSamplerState?], lodMinClamps: [Float], lodMaxClamps: [Float], range: Range<Int>) {
199-
__setTileSamplerStates(samplers, lodMinClamps: lodMinClamps, lodMaxClamps: lodMaxClamps, with: NSMakeRange(range.lowerBound, range.count))
199+
__setTileSamplerStates(samplers, lodMinClamps: lodMinClamps, lodMaxClamps: lodMaxClamps, with: NSRange(location: range.lowerBound, length: range.count))
200200
}
201201
#endif
202202
}
@@ -226,6 +226,6 @@ extension MTLTexture {
226226

227227
@available(macOS 10.11, iOS 9.0, tvOS 9.0, *)
228228
public func makeTextureView(pixelFormat: MTLPixelFormat, textureType: MTLTextureType, levels levelRange: Range<Int>, slices sliceRange: Range<Int>) -> MTLTexture? {
229-
return __newTextureView(with: pixelFormat, textureType: textureType, levels: NSMakeRange(levelRange.lowerBound, levelRange.count), slices: NSMakeRange(sliceRange.lowerBound, sliceRange.count))
229+
return __newTextureView(with: pixelFormat, textureType: textureType, levels: NSRange(location: levelRange.lowerBound, length: levelRange.count), slices: NSRange(location: sliceRange.lowerBound, length: sliceRange.count))
230230
}
231231
}

0 commit comments

Comments
 (0)