[swift-dev] feedback on alternatives for importing libdispatch types into Swift on Liunx
David P Grove
groved at us.ibm.com
Thu Feb 25 17:34:47 CST 2016
Currently on Linux, the various libdispatch types (dispatch_object_t,
dispatch_queue_t, etc.) are imported into Swift as COpaquePointer on Linux.
This causes a number of problems including:
(a) The intended subtyping relationships are lost, resulting in some
of the dispatch APIs not being usable (https://bugs.swift.org/browse/SR-737
)
(b) The libdispatch types can't be used in Swift where AnyObject is
expected (https://bugs.swift.org/browse/SR-740)
(c) In Swift code that manipulates values coming from libdispatch,
the expected retain/release operations are not generated by the compiler on
Linux.
I can see two obvious ways to tackle these issues (and perhaps other
problems with the same root cause I haven't encountered yet).
(1) Stay with the current C-level code of libdispatch where
dispatch_object_t et al. simulate enough of the Objective-C object model
that they can masquerade as Objective-C objects. Convince the Swift
compiler to import them as Objective-C types on Linux even though there is
not an Objective-C runtime (just the stubbed out bits of it that are in
libdispatch).
(2) Change the current C-level code of libdispatch so that on Linux
dispatch_object_t et al. simulate/implement enough of the Swift object
model that they can masquerade as Swift objects. Convince the Swift
compiler to import them as Swift types.
My gut is that (2) is the more desirable path to pursue. The main downside
I see is that it will likely make libdispatch.so dependent on
libswiftCore.so (to avoid replicating object model implementation
functions).
Before seriously starting down either path, I'd like to get some guidance
on what experts think the desired outcome should be and if I've overlooked
a better option.
thanks,
--dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20160225/77b0888c/attachment.html>
More information about the swift-dev
mailing list