joelffi - Foreign Function Interface Toolchain
joelffi is the command-line tool for managing foreign function interfaces, bindings, and interoperability with other languages.
Installation
joelffi is included with JOEL:
joelffi --versionQuick Start
# Generate C bindings
joelffi bind library.h --lang c
# Generate Python bindings
joelffi bind module.py --lang python
# Generate Rust bindings
joelffi bind crate.rs --lang rustBinding Generation
Generate bindings for foreign functions:
# Generate C bindings
joelffi bind library.h --lang c --output bindings.joel
# Generate Python bindings
joelffi bind module.py --lang python
# Generate Rust bindings
joelffi bind crate.rs --lang rust
# Generate JavaScript bindings
joelffi bind module.js --lang javascript
# Generate from header file
joelffi bind header.h --output bindings.joelC Interoperability
Work with C libraries:
# Generate C bindings
joelffi c bind library.h
# Link C library
joelffi c link libmylib.a
# Compile with C
joelffi c compile app.joel --link libmylib.a
# Generate C header
joelffi c header app.joel --output app.hPython Interoperability
Interact with Python:
# Generate Python bindings
joelffi python bind module.py
# Call Python function
joelffi python call "math.sqrt" --args 16
# Embed Python
joelffi python embed app.joel
# Generate Python module
joelffi python module app.joel --output app.pyRust Interoperability
Work with Rust crates:
# Generate Rust bindings
joelffi rust bind crate.rs
# Link Rust crate
joelffi rust link my_crate
# Generate Rust FFI
joelffi rust ffi app.joel --output lib.rsJavaScript Interoperability
Interact with JavaScript:
# Generate JS bindings
joelffi js bind module.js
# Call JS function
joelffi js call "Math.max" --args 1,2,3
# Generate Node.js module
joelffi js module app.joel --output app.jsProtocol Support
Generate protocol bindings:
# Generate gRPC bindings
joelffi grpc service.proto
# Generate GraphQL bindings
joelffi graphql schema.graphql
# Generate REST API bindings
joelffi rest api.jsonExamples
C Library Binding
# Generate bindings from C header
joelffi bind math.h --lang c --output math_bindings.joelOutput (math_bindings.joel):
[Compiled]
extern "C" {
fn sqrt(x: f64) -> f64
fn sin(x: f64) -> f64
fn cos(x: f64) -> f64
}Python Integration
# Generate Python bindings
joelffi python bind calculator.py
# Use in JOEL
joelffi python call "calculator.add" --args 1,2Command Reference
Binding Commands
joelffi bind <file>- Generate bindingsjoelffi bind <file> --lang <lang>- Language-specific bindings
Language Commands
joelffi c <command>- C interoperabilityjoelffi python <command>- Python interoperabilityjoelffi rust <command>- Rust interoperabilityjoelffi js <command>- JavaScript interoperability
Protocol Commands
joelffi grpc <file>- gRPC bindingsjoelffi graphql <file>- GraphQL bindingsjoelffi rest <file>- REST API bindings