<html><body><p>I've made some progress on getting libdispatch types like dispatch_queue_t to implement the Swift object model and be imported as Swift classes.  As Joe suggested last week, I am attempting to implement the Swift object model in libdispatch (and get the importer to realize that). <br><br>To simplify things, I created a tiny simulation of libdispatch [1] and used it to explore options.   I think I've ended up in a reasonable point, but before actually making the changes for real in libdispatch and submitting pull requests I want to get a sanity check on the approach.<br><br>Summary of the changes:<br>        1. In the ClangImporter, I added <font size="4">more Dispatch types to MappedTypes.def and a new value, MappedCTypeKind::SwiftClass</font>.<br><br>        2. In the simulated libdispatch, I define <font face="Menlo-Regular">DISPATCH_RETURNS_RETAINED</font> to be <font face="Menlo-Regular">__attribute__((cf_returns_retained))</font> instead of <font face="Menlo-Regular">__attribute__((__ns_returns_retained__))</font><br><br>        3. In the simulated libdispatch, I wired dispatch_retain/dispatch_release to swift_retain/release.  I used swift_allocObject to create instances of dispatch_queue_t, etc.<br><br>        4. In Dispatch.swift I define stub classes DispatchObject, DispatchQueue, etc. in a class hierarchy.   I use the compiler-generated metadata for these classes when calling swift_allocObject for the isa pointer.<br><br><br>The changes to ClangImporter can be browsed at [2]. <br><br>thanks for any feedback,<br><br>--dave<br><br>[1] <a href="https://github.com/dgrove-oss/swift-object-model-experiments">https://github.com/dgrove-oss/swift-object-model-experiments</a><br>[2] <a href="https://github.com/dgrove-oss/swift/tree/dispatch-import-exploration">https://github.com/dgrove-oss/swift/tree/dispatch-import-exploration</a><br><br><BR>
</body></html>