Commit a8c8ac81
a8c8ac8156dcMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 19 files · +16 added · ~3 modified
Description
Merge pull request #245 from rramsden/introduce-ffi-feat
feat(codegen) Foreign function interface for calling C libraries
Details
- Commit
- a8c8ac8156dc
- Parent
- 59a71e89659c
- Merge parent
- 5f5f2fdbf572
README.mdmodifiedView file
@@ -209,6 +209,15 @@
209209
**I/O**: `puts`, `print`, `printf`, `p`, `gets`, `ARGV`, `ENV[]`,210210
`File.read/write/open` (with blocks), `system()`, backtick.211211
212+
**FFI**: Direct C calls without an extension compiler. Declarations213+
(`ffi_func`, `ffi_lib`, `ffi_const`, `ffi_buffer`, `ffi_read_*`) live214+
inside a `module` body; the codegen emits externs and the `spinel`215+
wrapper picks up `-l` flags from marker comments. Scalars, strings,216+
opaque `:ptr`, integer constants, raw byte buffers, and struct-field217+
reads are covered. See [docs/FFI.md](docs/FFI.md) for the full spec218+
and [examples/ffi/](examples/ffi/) for runnable demos against libc/219+
libm and sqlite3.220+
212221
## Optimizations213222
214223
Whole-program type inference drives several compile-time optimizations:docs/FFI.mdaddedView file
Loading diff…
examples/ffi/libm/README.mdaddedView file
Loading diff…
examples/ffi/libm/libm.rbaddedView file
Loading diff…
examples/ffi/sqlite/README.mdaddedView file
Loading diff…
examples/ffi/sqlite/blog.rbaddedView file
Loading diff…
examples/ffi/sqlite/sqlite3_lib.rbaddedView file
Loading diff…
spinelmodifiedView file
Loading diff…
spinel_codegen.rbmodifiedView file
Loading diff…
test/ffi_buffer_reader.rbaddedView file
Loading diff…
test/ffi_buffer_reader.rb.expectedaddedView file
Loading diff…
test/ffi_const.rbaddedView file
Loading diff…
test/ffi_const.rb.expectedaddedView file
Loading diff…
test/ffi_libc_libm_basic.rbaddedView file
Loading diff…
test/ffi_libc_libm_basic.rb.expectedaddedView file
Loading diff…
test/ffi_ptr_nil.rbaddedView file
Loading diff…
test/ffi_ptr_nil.rb.expectedaddedView file
Loading diff…
test/ffi_void_return.rbaddedView file
Loading diff…
test/ffi_void_return.rb.expectedaddedView file
Loading diff…