//! `louise bindgen`: Louise bindings for the simple functions of a C //! header (ADR 0015). //! //! It writes two files: a Louise module of `@extern` declarations, and //! the C shim they call, which converts values (ADR 0005, Revision 1). //! Both are meant to be checked in and regenerated, not edited. //! //! **The supported subset.** A function is bound when every parameter //! and its result are among: //! //! | C | Louise | //! |---|---| //! | integer types (`int`, `unsigned long`, `int64_t`, `size_t`, ...) | `Int`: a value out of range panics, both ways | //! | `float`, `double` | `Float` | //! | `bool`, `_Bool` | `Bool` | //! | `const char *s` followed by an integer named `n` or ending in `len`, `length` or `size` | one `String`: pointer and length | //! | `const char *` alone | `String` (NUL-terminated: stops at an embedded NUL); a result is copied, and `NULL` panics | //! | a pointer to an *opaque* struct (declared, never defined in the header) | `Resource` | //! | a function pointer with one `void *` parameter, plus one `void *` parameter of the function itself | a callback, `fn(...) -> R / ` | //! | `void` result | `()` | //! //! - **Resources.** A pointer *result* becomes a resource only from a //! function named like a constructor (`_new`, `_create`, `_open`, //! `_copy`, `_clone`); other functions may return a pointer they still //! own. Its finalizer is the one `void f(T *)` function whose name ends //! in `_free`, `_destroy`, `_delete` or `_release`; that function is not //! bound (calling it would free the value twice). Resources are not //! thread-safe (pinned to their actor). A `NULL` result panics. //! - **Callbacks** follow ADR 0015: a trampoline per C signature, with //! `tl_callback` as the environment. Their parameters and results are //! scalars or `const char *`. //! - **Effects.** Every binding performs ``: bindgen cannot know that //! a C function is pure. //! - **Everything else is skipped and reported:** macros, enums, structs //! with fields, variables, `static inline` functions, variadic //! functions, writable `char *`, other pointers, arrays, structs by //! value, callbacks without a `void *` environment. //! //! Headers are read without a preprocessor (see [`parse`]), so a function //! declared through a macro is reported as unrecognised. mod generate; mod parse; pub use generate::{Bindings, Skipped, generate};