> On Dec 11, 2015, at 4:33 AM, Geordie Jay via swift-dev <swift-dev@swift.org> 
> wrote:
> 
> Hi, maybe one of the Apple devs can help out with this quick Q:
> 
> To interface with the JNI, we’d presumably need to call swift functions from 
> our compiled swift binaries from C (or directly from Java, the result being 
> the same). Is there a way to demangle certain symbols in the output binary to 
> this effect, or is there another / a better way to access Swift functions 
> from C?

Others can probably give a more detailed response, but...

There’s a Swift demangler in Swift’s “Basic” library (lib/Basic/Demangle.cpp), 
along with a standalone tool (swift-demangle) you can experiment with. The 
information in the mangled name should be complete enough to call, but you’ll 
need to match Swift’s calling convention.

If it’s just a specific set of Swift functions you want to call from C, you can 
use the @_silgen_name attribute to override the mangled name, and/or make them 
@convention(c) to use the C calling convention.

        - Doug


_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev

Reply via email to