[swift-users] How to bridge between CoreFoundation and SwiftFoundation on Linux?

Bouke Haarsma bouke at haarsma.eu
Wed Sep 21 15:06:35 CDT 2016


The code is for another project. I’m trying to build a (partial) Swift implementation of NetService. See also https://github.com/Bouke/NetService/tree/linux <https://github.com/Bouke/NetService/tree/linux>.

Apparently that protocol is EOL;

> // slated for removal, these are the swift-corelibs-only variant of the _ObjectiveCBridgeable
> internal protocol _CFBridgeable {
>     associatedtype CFType
>     var _cfObject: CFType { get }
> }


—
Bouke


> On 21 Sep 2016, at 21:56, Will Stanton <willstanton1 at yahoo.com> wrote:
> 
> Hello Bouke,
> 
> Is that code you’re working on within SwiftFoundation or for another project?
> 
> I believe _cfObject can bridge String to CFString within SwiftFoundation (but it’s an internal property), for example in NSDateFormatter.swift:
> String -> CFString
> _setFormatterAttribute(formatter, attributeName: kCFDateFormatterAMSymbol, value: _amSymbol?._cfObject)
> CFString -> String
> (CFDateFormatterCopyProperty(_cfObject, kCFDateFormatterAMSymbol) as! NSString)._swiftObject
> 
> 
> Within SwiftFoundation, it seems CFReadStream+CFWriteStream do not have associated CFTypes. That may be because their implementations just started, but I am not sure what the plan is with those classes and `protocol _CFBridgeable`.
> 
> 
> Regards,
> Will Stanton
> 
>> On Sep 21, 2016, at 12:38 AM, Bouke Haarsma via swift-users <swift-users at swift.org> wrote:
>> 
>> Hi all,
>> 
>> When working with CoreFoundation objects (e.g. CFReadStream, CFWriteStream) it isn't immediately obvious to me how to bridge them to SwiftFoundation counterparts (InputStream / OutputStream).
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160921/9e4523db/attachment.html>


More information about the swift-users mailing list