12 lines
305 B
Swift
12 lines
305 B
Swift
import Foundation
|
|
|
|
enum Mem {
|
|
static func bridge<T: AnyObject>(_ obj: T) -> UnsafeMutableRawPointer {
|
|
Unmanaged.passUnretained(obj).toOpaque()
|
|
}
|
|
|
|
static func bridge<T: AnyObject>(_ ptr: UnsafeMutableRawPointer) -> T {
|
|
Unmanaged<T>.fromOpaque(ptr).takeUnretainedValue()
|
|
}
|
|
}
|