Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/igor-makarov/swift-ffi
Demo for exporting Swift code to use with Ruby FFI
https://github.com/igor-makarov/swift-ffi
Last synced: about 1 month ago
JSON representation
Demo for exporting Swift code to use with Ruby FFI
- Host: GitHub
- URL: https://github.com/igor-makarov/swift-ffi
- Owner: igor-makarov
- Created: 2020-01-28T08:25:29.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-01-28T10:07:03.000Z (over 4 years ago)
- Last Synced: 2024-04-04T18:32:05.075Z (6 months ago)
- Language: Swift
- Size: 5.86 KB
- Stars: 11
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# swift-ffi
[![Travis (.org)](https://img.shields.io/travis/igor-makarov/swift-ffi?style=flat-square)](https://travis-ci.com/igor-makarov/swift-ffi)Shows how to use Swift code in a Ruby FFI.
See [swift_ffi.swift](Sources/swift-ffi/swift_ffi.swift) for the Swift code and [run.rb](run.rb) for the Ruby code.
The Swift code is exported as free functions using `@_cdecl` attribute. It's a little undocumented, but will probably be canonized at some point.
### Note:
The string function `swift_ffi_duplicate_string` returns a 'fresh' string, which means the dealloc is the responsibility of the Ruby code in this case. The Ruby code copies and frees the string before exposing it. Different C API design might have different constraints.