Re: [swift-users] C/FFI interop

2015-12-23 Thread Thomas Catterall via swift-users
Indeed I was - I'm quite sorry for the confusion, I didn't make my intent clear as I should have, such as through example. What I'm referring to is, for instance, offering a way for a Ruby library to interface with a module written in Swift to communicate with Redis (as an example, not

Re: [swift-users] C/FFI interop

2015-12-23 Thread Eric Wing via swift-users
On 12/23/15, Thomas Catterall via swift-users wrote: > Indeed I was - I'm quite sorry for the confusion, I didn't make my intent > clear as I should have, such as through example. What I'm referring to is, > for instance, offering a way for a Ruby library to interface with

Re: [swift-users] C/FFI interop

2015-12-23 Thread Jason Dusek via swift-users
I think the OP was asking not about importing C symbols into Swift but rather exporting Swift to C. On Wed, 23 Dec 2015 at 15:18 Brent Royal-Gordon via swift-users < swift-users@swift.org> wrote: > > What are the current facilities planned or in development for FFI? Just > as Swift functions can

Re: [swift-users] C/FFI interop

2015-12-23 Thread Brent Royal-Gordon via swift-users
> What are the current facilities planned or in development for FFI? Just as > Swift functions can be exposed through @objc, how would I add a similar > capability for pure C? Is this what, in fact, module maps might be for? > > I ask since writing high performance native code for dynamic

Re: [swift-users] C/FFI interop

2015-12-23 Thread David Turnbull via swift-users
On Wed, Dec 23, 2015 at 8:30 AM, swizzlr via swift-users < swift-users@swift.org> wrote: > It would be great for Swift if people started writing native bindings in > it as opposed to C, but... > No buts. It's started already. For example, here's my Mac and Linux OpenGL loader that's 100% pure

Re: [swift-users] C/FFI interop

2015-12-23 Thread Brent Royal-Gordon via swift-users
> Option 2. Use this syntax and swift-demangle to figure out the symbols: > > public var badfood:@convention(c)(Int) -> Void = { (i:Int) in > print(i) > } There's an @asmname("foo") directive which can override name mangling, but I don't know how useful it is in practice for this kind of

Re: [swift-users] C/FFI interop

2015-12-23 Thread David Turnbull via swift-users
Option 1. Export your Swift to Obj-C. Write Obj-C that exports C. Compile to a library. Option 2. Use this syntax and swift-demangle to figure out the symbols: public var badfood:@convention(c)(Int) -> Void = { (i:Int) in print(i) } -david On 12/23/15, Thomas Catterall via swift-users