3 unstable releases
0.2.0 | Oct 11, 2020 |
---|---|
0.1.1 | Jul 12, 2020 |
0.1.0 | Jul 10, 2020 |
#37 in #int
18KB
393 lines
wrapgen
wrapgen
is a tool to automatically generate Rust wrappers around C functions called via FFI.
It will wrap pointer returns in an Option
and int
returns in a Result
.
As of now, wrapgen
only works if your functions adhere to the C convention of returning
0 on a successful run and another value otherwise.
How to use wrapgen
You can use wrapgen as a standalone binary:
wrapgen input.rs output.rs
where input.rs
contains one function declaration per line
or include it in your build.rs
file:
fn main() {
WrapGen::new("input1.rs")
.add_file("input2.rs")
.function("fn my_test_fn(arg1: cty::c_int) -> cty::c_int")
.prefix("rs_")
.use_core(false)
.generate("output.rs");
}
lib.rs
:
wrapgen
is a tool to automatically generate Rust wrappers around C functions called via FFI.
It will wrap pointer returns in an Option
and int
returns in a Result
.
As of now, wrapgen
only works if your functions adhere to the C convention of returning
0 on a successful run and another value otherwise.
How to use wrapgen
You can use wrapgen as a standalone binary:
wrapgen input.rs output.rs
where input.rs
contains one function declaration per line
or include it in your build.rs
file:
fn main() {
WrapGen::new("input1.rs")
.add_file("input2.rs")
.function("fn my_test_fn(arg1: cty::c_int) -> cty::c_int")
.prefix("rs_")
.use_core(false)
.generate("output.rs");
}
Dependencies
~2–3MB
~53K SLoC