move the stdlib to put noescape and autoclosure on the type, instead of

the parameter.  Progress towards SE-0049.
This commit is contained in:
Chris Lattner
2016-04-14 23:13:13 -07:00
parent ab14e6706f
commit 4fd8418ba7
37 changed files with 165 additions and 167 deletions

View File

@@ -21,7 +21,7 @@
//
@warn_unused_result
func _toNSArray<T, U : AnyObject>(_ a: [T], @noescape f: (T) -> U) -> NSArray {
func _toNSArray<T, U : AnyObject>(_ a: [T], f: @noescape (T) -> U) -> NSArray {
let result = NSMutableArray(capacity: a.count)
for s in a {
result.add(f(s))
@@ -79,7 +79,7 @@ extension Optional {
/// `body` is complicated than that results in unnecessarily repeated code.
internal func _withNilOrAddress<NSType : AnyObject, ResultType>(
of object: inout NSType?,
body: @noescape AutoreleasingUnsafeMutablePointer<NSType?>? -> ResultType
body: @noescape (AutoreleasingUnsafeMutablePointer<NSType?>?) -> ResultType
) -> ResultType {
return self == nil ? body(nil) : body(&object)
}
@@ -125,7 +125,7 @@ extension String {
/// memory referred to by `index`
func _withOptionalOutParameter<Result>(
_ index: UnsafeMutablePointer<Index>?,
@noescape body: (UnsafeMutablePointer<Int>?) -> Result
body: @noescape (UnsafeMutablePointer<Int>?) -> Result
) -> Result {
var utf16Index: Int = 0
let result = (index != nil ? body(&utf16Index) : body(nil))
@@ -138,7 +138,7 @@ extension String {
/// it into the memory referred to by `range`
func _withOptionalOutParameter<Result>(
_ range: UnsafeMutablePointer<Range<Index>>?,
@noescape body: (UnsafeMutablePointer<NSRange>?) -> Result
body: @noescape (UnsafeMutablePointer<NSRange>?) -> Result
) -> Result {
var nsRange = NSRange(location: 0, length: 0)
let result = (range != nil ? body(&nsRange) : body(nil))