Skip to content

PLIST to Data alignment with Foundation #721

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 24, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions Foundation/NSPropertyList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ open class PropertyListSerialization : NSObject {
#else
let fmt = CFPropertyListFormat(format.rawValue)
#endif
return CFPropertyListIsValid(unsafeBitCast(_SwiftValue.store(plist), to: CFPropertyList.self), fmt)
let plistObj = _SwiftValue.store(plist)
return CFPropertyListIsValid(plistObj, fmt)
}
open class func data(fromPropertyList plist: AnyObject, format: PropertyListFormat, options opt: WriteOptions) throws -> Data {

open class func data(fromPropertyList plist: Any, format: PropertyListFormat, options opt: WriteOptions) throws -> Data {
var error: Unmanaged<CFError>? = nil
let result = withUnsafeMutablePointer(to: &error) { (outErr: UnsafeMutablePointer<Unmanaged<CFError>?>) -> CFData? in
#if os(OSX) || os(iOS)
Expand All @@ -56,15 +57,16 @@ open class PropertyListSerialization : NSObject {
let fmt = CFPropertyListFormat(format.rawValue)
#endif
let options = CFOptionFlags(opt)
return CFPropertyListCreateData(kCFAllocatorSystemDefault, plist, fmt, options, outErr)
let plistObj = _SwiftValue.store(plist)
return CFPropertyListCreateData(kCFAllocatorSystemDefault, plistObj, fmt, options, outErr)
}
if let res = result {
return res._swiftObject
} else {
throw error!.takeRetainedValue()._nsObject
}
}

/// - Experiment: Note that the return type of this function is different than on Darwin Foundation (Any instead of AnyObject). This is likely to change once we have a more complete story for bridging in place.
open class func propertyList(from data: Data, options opt: ReadOptions = [], format: UnsafeMutablePointer<PropertyListFormat>?) throws -> Any {
var fmt = kCFPropertyListBinaryFormat_v1_0
Expand Down