-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e9a299c
commit 753d7a1
Showing
4 changed files
with
235 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is taken from SwiftNIO open source project | ||
// | ||
// Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors | ||
// Licensed under Apache License v2.0 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
|
||
extension UnsafePointer { | ||
init(_ ptr: UnsafePointer<Pointee>) { | ||
self = ptr | ||
} | ||
|
||
static func make(optional ptr: UnsafePointer<Pointee>?) -> UnsafePointer<Pointee>? { | ||
return ptr.map(UnsafePointer<Pointee>.init) | ||
} | ||
|
||
static func make(optional ptr: OpaquePointer?) -> UnsafePointer<Pointee>? { | ||
return ptr.map(UnsafePointer<Pointee>.init) | ||
} | ||
} | ||
|
||
extension UnsafeMutablePointer { | ||
init(_ ptr: UnsafeMutableRawPointer) { | ||
let x = UnsafeMutablePointer<Pointee>(bitPattern: UInt(bitPattern: ptr))! | ||
self = x | ||
} | ||
|
||
static func make(optional ptr: UnsafeMutablePointer<Pointee>?) -> UnsafeMutablePointer<Pointee>? { | ||
return ptr.map(UnsafeMutablePointer<Pointee>.init) | ||
} | ||
|
||
static func make(optional ptr: UnsafeMutableRawPointer?) -> UnsafeMutablePointer<Pointee>? { | ||
return ptr.map(UnsafeMutablePointer<Pointee>.init) | ||
} | ||
|
||
static func make(optional ptr: OpaquePointer?) -> UnsafeMutablePointer<Pointee>? { | ||
return ptr.map(UnsafeMutablePointer<Pointee>.init) | ||
} | ||
} | ||
|
||
extension UnsafeMutableRawPointer { | ||
static func make(optional ptr: OpaquePointer?) -> UnsafeMutableRawPointer? { | ||
return ptr.map(UnsafeMutableRawPointer.init) | ||
} | ||
} | ||
|
||
extension OpaquePointer { | ||
init(_ ptr: OpaquePointer) { | ||
self = ptr | ||
} | ||
|
||
static func make(optional ptr: OpaquePointer?) -> OpaquePointer? { | ||
return ptr.map(OpaquePointer.init) | ||
} | ||
|
||
static func make(optional ptr: UnsafeMutableRawPointer?) -> OpaquePointer? { | ||
return ptr.map(OpaquePointer.init) | ||
} | ||
|
||
static func make<Pointee>(optional ptr: UnsafeMutablePointer<Pointee>?) -> OpaquePointer? { | ||
return ptr.map(OpaquePointer.init) | ||
} | ||
} |
Oops, something went wrong.