Struct autocxx_engine::IncludeCppEngine[][src]

pub struct IncludeCppEngine { /* fields omitted */ }

Core of the autocxx engine.

The basic idea is this. We will run bindgen which will spit out a ton of Rust code corresponding to all the types and functions defined in C++. We’ll then post-process that bindgen output into a form suitable for ingestion by cxx. (It’s the BridgeConverter mod which does that.) Along the way, the bridge_converter might tell us of additional C++ code which we should generate, e.g. wrappers to move things into and out of UniquePtrs.

flowchart TB s[(C++ headers)] s --> lc rss[(.rs input)] rss --> parser parser --> include_cpp_conf cpp_output[(C++ output)] rs_output[(.rs output)] subgraph autocxx[autocxx_engine] parser[File parser] subgraph bindgen[autocxx_bindgen] lc[libclang parse] bir(bindgen IR) lc --> bir end bgo(bindgen generated bindings) bir --> bgo include_cpp_conf(Config from include_cpp) syn[Parse with syn] bgo --> syn conv[['conversion' mod: see below]] syn --> conv rsgen(Generated .rs TokenStream) conv --> rsgen subgraph cxx_gen cxx_codegen[cxx_gen C++ codegen] end rsgen --> cxx_codegen end conv -- autocxx C++ codegen --> cpp_output rsgen -- autocxx .rs codegen --> rs_output cxx_codegen -- cxx C++ codegen --> cpp_output subgraph rustc [rustc build] subgraph autocxx_macro include_cpp[autocxx include_cpp macro] end subgraph cxx cxxm[cxx procedural macro] end comprs(Fully expanded Rust code) end rs_output-. included .->include_cpp include_cpp --> cxxm cxxm --> comprs rss --> rustc include_cpp_conf -. used to configure .-> bindgen include_cpp_conf --> conv link[linker] cpp_output --> link comprs --> link

Here’s a zoomed-in view of the “conversion” part:

flowchart TB syn[(syn parse)] apis(Unanalyzed APIs) subgraph parse tc(TypeConverter) syn ==> parse_bindgen end parse_bindgen ==> apis parse_bindgen -.-> tc subgraph analysis pod[POD analysis] tc -.-> pod apis ==> pod podapis(APIs with POD analysis) pod ==> podapis fun[Function materialization analysis] tc -.-> fun podapis ==> fun funapis(APIs with function analysis) fun ==> funapis gc[Garbage collection] funapis ==> gc ctypes[C int analysis] gc ==> ctypes ctypes ==> finalapis end finalapis(Analyzed APIs) codegenrs(.rs codegen) codegencpp(.cpp codegen) finalapis ==> codegenrs finalapis ==> codegencpp

Implementations

impl IncludeCppEngine[src]

pub fn new_from_syn(mac: Macro) -> Result<Self>[src]

pub fn get_rs_filename(&self) -> String[src]

pub fn generate_rs(&self) -> TokenStream2[src]

Generate the Rust bindings. Call generate first.

pub fn generate(
    &mut self,
    inc_dirs: Vec<PathBuf>,
    definitions: &[impl AsRef<str>],
    dep_recorder: Option<Box<dyn RebuildDependencyRecorder>>
) -> Result<()>
[src]

Actually examine the headers to find out what needs generating. Most errors occur at this stage as we fail to interpret the C++ headers properly.

See documentation for this type for flow diagrams and more details.

pub fn generate_h_and_cxx(&self) -> Result<GeneratedCpp, Error>[src]

Generate C++-side bindings for these APIs. Call generate first.

pub fn include_dirs(&self) -> &Vec<PathBuf>[src]

Return the include directories used for this include_cpp invocation.

Trait Implementations

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.