Fix Swift compile error on ARM 64-bit

This commit is contained in:
Andrew Bettison 2018-04-30 21:09:02 +09:30
parent 7993332fe9
commit bb5fc482c7

View File

@ -101,11 +101,24 @@ private func cliPuts(_ context: UnsafeMutablePointer<cli_context>?, _ str: Unsaf
} }
} }
// The va_list C type on i386, armv7 and i86_64 is CVaListPointer, whereas on
// arm64 it is Optional<CVaListPointer>.
#if arch(arm64)
private func cliVprintf(_ context: UnsafeMutablePointer<cli_context>?, _ fmt: UnsafePointer<CChar>?, _ ap: CVaListPointer?) -> Void {
let str = NSString(format: String(cString: fmt!), arguments: ap!)
_self(context).putString(String(data: str.data(using: String.Encoding.utf16.rawValue)!, encoding:.utf16)!)
}
#else
private func cliVprintf(_ context: UnsafeMutablePointer<cli_context>?, _ fmt: UnsafePointer<CChar>?, _ ap: CVaListPointer) -> Void { private func cliVprintf(_ context: UnsafeMutablePointer<cli_context>?, _ fmt: UnsafePointer<CChar>?, _ ap: CVaListPointer) -> Void {
let str = NSString(format: String(cString: fmt!), arguments: ap) let str = NSString(format: String(cString: fmt!), arguments: ap)
_self(context).putString(String(data: str.data(using: String.Encoding.utf16.rawValue)!, encoding:.utf16)!) _self(context).putString(String(data: str.data(using: String.Encoding.utf16.rawValue)!, encoding:.utf16)!)
} }
#endif
private func cliPutLong(_ context: UnsafeMutablePointer<cli_context>?, _ value: Int64, _ delim: UnsafePointer<CChar>?) -> Void { private func cliPutLong(_ context: UnsafeMutablePointer<cli_context>?, _ value: Int64, _ delim: UnsafePointer<CChar>?) -> Void {
_self(context).putLong(value, delim != nil ? String(cString: delim!) : nil) _self(context).putLong(value, delim != nil ? String(cString: delim!) : nil)
} }