[swift-evolution] Rewrite imported C function signatures

Thomas Guthrie tomguthrie at gmail.com
Tue Mar 29 10:34:53 CDT 2016


> On 29 Mar 2016, at 11:02, Carlos Rodríguez Domínguez via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Well, those proposal are more oriented towards annotating on C/Objective-C files to allow a more sophisticate import into swift. However, my proposal is to be able to directly annotate in swift, in order to fix “old-style” imports, autogenerated code, etc. Please, allow me to repeat myself, but consider the example of Core Data, in which model classes are autogenerated from a graphical model that, for instance, lacks from enums’ support. Therefore, if we use Core Data, then we can not use enums (Please, take a look at the proposal named "[swift-evolution] Promote "primitive" types to enums in extensions” in order to understand the intention of my proposal as a whole).

If you can’t annotate the headers why not have a wrapper module that uses the C version of the module internally? Then anywhere that uses the original, int using version, has to explicitly import it. (For example a Sqlite module internally imports CSqlite) I don’t know if SwiftPM allows explicit submodules <http://clang.llvm.org/docs/Modules.html#submodule-declaration> but if it does that means only your wrapper module has access to the int version.

This seems much better than an annotation that basically only hides an imported function that you’d have to include in any project using the C library anyway.


— Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160329/a77c73f0/attachment.html>


More information about the swift-evolution mailing list