Generates CPython bindings for Interoptopus.
Usage
Assuming you have written a crate containing your FFI logic called example_library_ffi and
want to generate CPython bindings for Python 3.7+, follow the instructions below.
Inside Your Library
Add Interoptopus attributes to the library you have written, and define an inventory function listing all symbols you wish to export. An overview of all supported constructs can be found in the reference project.
use ;
use ;
Add these to your Cargo.toml so the attributes and the binding generator can be found
(replace ... with the latest version):
[]
= ["cdylib", "rlib"]
[]
= "..."
= "..."
Create a unit test in tests/bindings.rs which will generate your bindings when run
with cargo test. In real projects you might want to add this code to another crate instead:
use NamespaceMappings;
use Error;
use Bindings;
Now run cargo test.
If anything is unclear you can find a working sample on Github.
Generated Output
The output below is what this backend might generate. Have a look at the [Config] struct
if you want to customize something. If you really don't like how something is generated it is
easy to create your own.
=
= None
"""Initializes the native library. Must be called at least once before anything else."""
global
=
=
=
return
=
=
# These fields represent the underlying C data layout
=
=
=
return
return
return
return