pub fn generate(
        &mut self,
        inc_dirs: &str,
        dep_recorder: Option<Box<dyn RebuildDependencyRecorder>>,
    ) -> Result<()> {
        let inc_dirs = Self::canonize_inc_dirs(inc_dirs)?;

        // If we are in parse only mode, do nothing. This is used for
        // doc tests to ensure the parsing is valid, but we can't expect
        // valid C++ header files or linkers to allow a complete build.
        match self.state {
            State::ParseOnly => return Ok(()),
            State::NotGenerated => {}
            State::Generated(_) => panic!("Only call generate once"),
        }

        if self.config.type_config.allowlist_is_empty() {
            return Err(Error::NoGenerationRequested);
        }

        let mut builder = self.make_bindgen_builder(&inc_dirs);
        if let Some(dep_recorder) = dep_recorder {
            builder = builder.parse_callbacks(Box::new(AutocxxParseCallbacks(dep_recorder)));
        }
        let bindings = self
            .inject_header_into_bindgen(builder)
            .generate()
            .map_err(Error::Bindgen)?;
        let bindings = self.parse_bindings(bindings)?;

        let include_list = self.generate_include_list();
        let converter = BridgeConverter::new(&include_list, &self.config.type_config);

        let conversion = converter
            .convert(
                bindings,
                self.config.exclude_utilities,
                self.config.unsafe_policy.clone(),
                self.build_header(),
            )
            .map_err(Error::Conversion)?;
        let mut items = conversion.rs;
        let mut new_bindings: ItemMod = parse_quote! {
            #[allow(non_snake_case)]
            #[allow(dead_code)]
            #[allow(non_upper_case_globals)]
            #[allow(non_camel_case_types)]
            mod ffi {
            }
        };
        new_bindings.content.as_mut().unwrap().1.append(&mut items);
        info!(
            "New bindings:\n{}",
            rust_pretty_printer::pretty_print(&new_bindings.to_token_stream())
        );
        self.state = State::Generated(Box::new(GenerationResults {
            item_mod: new_bindings,
            additional_cpp_generator: conversion.cpp,
            inc_dirs,
        }));
        Ok(())
    }
/// 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.
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.
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(
        &mut self,
        inc_dirs: &str,
        dep_recorder: Option<Box<dyn RebuildDependencyRecorder>>,
    ) -> Result<()> {
        let inc_dirs = Self::canonize_inc_dirs(inc_dirs)?;
        // If we are in parse only mode, do nothing. This is used for
        // doc tests to ensure the parsing is valid, but we can't expect
        // valid C++ header files or linkers to allow a complete build.
        match self.state {
            State::ParseOnly => return Ok(()),
            State::NotGenerated => {}
            State::Generated(_) => panic!("Only call generate once"),
        }
        if self.config.type_config.allowlist_is_empty() {
            return Err(Error::NoGenerationRequested);
        }
        let mut builder = self.make_bindgen_builder(&inc_dirs);
        if let Some(dep_recorder) = dep_recorder {
            builder = builder.parse_callbacks(Box::new(AutocxxParseCallbacks(dep_recorder)));
        }
        let bindings = self
            .inject_header_into_bindgen(builder)
            .generate()
            .map_err(Error::Bindgen)?;
        let bindings = self.parse_bindings(bindings)?;
        let include_list = self.generate_include_list();
        let converter = BridgeConverter::new(&include_list, &self.config.type_config);
        let conversion = converter
            .convert(
                bindings,
                self.config.exclude_utilities,
                self.config.unsafe_policy.clone(),
                self.build_header(),
            )
            .map_err(Error::Conversion)?;
        let mut items = conversion.rs;
        let mut new_bindings: ItemMod = parse_quote! {
            #[allow(non_snake_case)]
            #[allow(dead_code)]
            #[allow(non_upper_case_globals)]
            #[allow(non_camel_case_types)]
            mod ffi {
            }
        };
        new_bindings.content.as_mut().unwrap().1.append(&mut items);
        info!(
            "New bindings:\n{}",
            rust_pretty_printer::pretty_print(&new_bindings.to_token_stream())
        );
        self.state = State::Generated(Box::new(GenerationResults {
            item_mod: new_bindings,
            additional_cpp_generator: conversion.cpp,
            inc_dirs,
        }));
        Ok(())
    }
pub fn generate ( & mut self , inc_dirs : & str , dep_recorder : Option < Box < dyn RebuildDependencyRecorder > > , ) -> Result < ( ) > { let inc_dirs = Self :: canonize_inc_dirs ( inc_dirs ) ? ; // If we are in parse only mode, do nothing. This is used for // doc tests to ensure the parsing is valid, but we can't expect // valid C++ header files or linkers to allow a complete build. match self . state { State :: ParseOnly => return Ok ( ( ) ) , State :: NotGenerated => { } State :: Generated ( _ ) => panic ! ( " " ) , } if self . config . type_config . allowlist_is_empty ( ) { return Err ( Error :: NoGenerationRequested ) ; } let mut builder = self . make_bindgen_builder ( & inc_dirs ) ; if let Some ( dep_recorder ) = dep_recorder { builder = builder . parse_callbacks ( Box :: new ( AutocxxParseCallbacks ( dep_recorder ) ) ) ; } let bindings = self . inject_header_into_bindgen ( builder ) . generate ( ) . map_err ( Error :: Bindgen ) ? ; let bindings = self . parse_bindings ( bindings ) ? ; let include_list = self . generate_include_list ( ) ; let converter = BridgeConverter :: new ( & include_list , & self . config . type_config ) ; let conversion = converter . convert ( bindings , self . config . exclude_utilities , self . config . unsafe_policy . clone ( ) , self . build_header ( ) , ) . map_err ( Error :: Conversion ) ? ; let mut items = conversion . rs ; let mut new_bindings : ItemMod = parse_quote ! { [ allow ( non_snake_case ) ] [ allow ( dead_code ) ] [ allow ( non_upper_case_globals ) ] [ allow ( non_camel_case_types ) ] mod ffi { } } ; new_bindings . content . as_mut ( ) . unwrap ( ) . 1 . append ( & mut items ) ; info ! ( " \n " rust_pretty_printer pretty_print ( new_bindings to_token_stream ( ) ) ) ; self . state = State :: Generated ( Box :: new ( GenerationResults { item_mod : new_bindings , additional_cpp_generator : conversion . cpp , inc_dirs , } ) ) ; Ok ( ( ) ) }
Actually examine the headers to find out what needs generating.
Actually examine the headers to find out what needs generating .
&mut self
inc_dirs
&str
dep_recorder
Option<Box<dyn RebuildDependencyRecorder>>
&mut self
inc_dirs
&str
dep_recorder
Option<Box<dyn RebuildDependencyRecorder>>