Crate interoptopus_backend_c[][src]

Expand description

Generates C bindings for Interoptopus.

Usage

In your library or a support project add this:

use my_crate::ffi_inventory;

#[test]
fn generate_c_bindings() {
    use interoptopus::Interop;
    use interoptopus_backend_c::{Generator, CWriter, Config};

    // Converts an `ffi_inventory()` into Python interop definitions.
    Generator::new(Config::default(), ffi_inventory()).write_to("module.h")
}

And we might produce something like this:

#ifndef module
#define module

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>
#include <stdbool.h>

typedef struct Vec3f32
{
    float x;
    float y;
    float z;
} Vec3f32;

Vec3f32 my_game_function(Vec3f32* input);

#ifdef __cplusplus
}
#endif

#endif /* module */

Structs

Configures C code generation.

Implements CTypeConverter.

Start here, main converter implementing Interop.

Traits

Converts Interoptopus types to C types.

Writes the C file format, impl this trait to customize output.