pub fn generate<T: HeaderFFIGen>(filename: &str, api_def: &ApiDef, mut imp: T) -> Result<()> {
        let mut temp_string = String::with_capacity(128);
        let mut dest = BufWriter::with_capacity(512 * 1024, File::create(filename)?);

        // Generate header
        imp.gen_header(&mut dest)?;

        // Generate forward declarations if needed
        for sdef in &api_def.class_structs {
            imp.gen_forward_declaration(&mut dest, &sdef)?;
        }

        // generate all structs
        for sdef in &api_def.class_structs {
            // Construct Funcs name
            temp_string.clear();
            temp_string.push_str("RU");
            temp_string.push_str(&sdef.name);
            temp_string.push_str("Funcs");

            // Generate the funcs implementation
            imp.gen_struct_declaration(&mut dest, &temp_string)?;

            if sdef.should_have_create_func() {
                imp.gen_destroy_func(&mut dest, &sdef.name)?;
            }

            // Generate all functions
            for func in &sdef.functions {
                imp.gen_function(&mut dest, &func)?;
            }

            imp.gen_struct_end_declaration(&mut dest, &temp_string)?;

            // Generate the AllFuncs struct
            temp_string.clear();
            temp_string.push_str("RU");
            temp_string.push_str(&sdef.name);
            temp_string.push_str("AllFuncs");

            imp.gen_struct_declaration(&mut dest, &temp_string)?;

            for name in &sdef.full_inherit {
                imp.gen_funcs_declaration(&mut dest, name, name)?;
            }

            imp.gen_struct_end_declaration(&mut dest, &temp_string)?;

            // Construct struct name
            temp_string.clear();
            temp_string.push_str("RU");
            temp_string.push_str(&sdef.name);

            // Generate the struct implementation
            imp.gen_struct_declaration(&mut dest, &temp_string)?;
            imp.gen_rubase_ptr_data(&mut dest, "qt_data")?;
            imp.gen_rubase_ptr_data(&mut dest, "host_data")?;
            imp.gen_funcs_declaration(&mut dest, "all", &format!("{}All", sdef.name))?;
            imp.gen_struct_end_declaration(&mut dest, &temp_string)?;
        }

        imp.generate_post_declarations(&mut dest, api_def)
    }
///
///  Main generation function that generates the structs
///
Main generation function that generates the structs
Main generation function that generates the structs
pub fn generate<T: HeaderFFIGen>(filename: &str, api_def: &ApiDef, mut imp: T) -> Result<()> {
        let mut temp_string = String::with_capacity(128);
        let mut dest = BufWriter::with_capacity(512 * 1024, File::create(filename)?);
        // Generate header
        imp.gen_header(&mut dest)?;
        // Generate forward declarations if needed
        for sdef in &api_def.class_structs {
            imp.gen_forward_declaration(&mut dest, &sdef)?;
        }
        // generate all structs
        for sdef in &api_def.class_structs {
            // Construct Funcs name
            temp_string.clear();
            temp_string.push_str("RU");
            temp_string.push_str(&sdef.name);
            temp_string.push_str("Funcs");
            // Generate the funcs implementation
            imp.gen_struct_declaration(&mut dest, &temp_string)?;
            if sdef.should_have_create_func() {
                imp.gen_destroy_func(&mut dest, &sdef.name)?;
            }
            // Generate all functions
            for func in &sdef.functions {
                imp.gen_function(&mut dest, &func)?;
            }
            imp.gen_struct_end_declaration(&mut dest, &temp_string)?;
            // Generate the AllFuncs struct
            temp_string.clear();
            temp_string.push_str("RU");
            temp_string.push_str(&sdef.name);
            temp_string.push_str("AllFuncs");
            imp.gen_struct_declaration(&mut dest, &temp_string)?;
            for name in &sdef.full_inherit {
                imp.gen_funcs_declaration(&mut dest, name, name)?;
            }
            imp.gen_struct_end_declaration(&mut dest, &temp_string)?;
            // Construct struct name
            temp_string.clear();
            temp_string.push_str("RU");
            temp_string.push_str(&sdef.name);
            // Generate the struct implementation
            imp.gen_struct_declaration(&mut dest, &temp_string)?;
            imp.gen_rubase_ptr_data(&mut dest, "qt_data")?;
            imp.gen_rubase_ptr_data(&mut dest, "host_data")?;
            imp.gen_funcs_declaration(&mut dest, "all", &format!("{}All", sdef.name))?;
            imp.gen_struct_end_declaration(&mut dest, &temp_string)?;
        }
        imp.generate_post_declarations(&mut dest, api_def)
    }
pub fn generate < T : HeaderFFIGen > ( filename : & str , api_def : & ApiDef , mut imp : T ) -> Result < ( ) > { let mut temp_string = String :: with_capacity ( 128 ) ; let mut dest = BufWriter :: with_capacity ( 512 * 1024 , File :: create ( filename ) ? ) ; // Generate header imp . gen_header ( & mut dest ) ? ; // Generate forward declarations if needed for sdef in & api_def . class_structs { imp . gen_forward_declaration ( & mut dest , & sdef ) ? ; } // generate all structs for sdef in & api_def . class_structs { // Construct Funcs name temp_string . clear ( ) ; temp_string . push_str ( " " ) ; temp_string . push_str ( & sdef . name ) ; temp_string . push_str ( " " ) ; // Generate the funcs implementation imp . gen_struct_declaration ( & mut dest , & temp_string ) ? ; if sdef . should_have_create_func ( ) { imp . gen_destroy_func ( & mut dest , & sdef . name ) ? ; } // Generate all functions for func in & sdef . functions { imp . gen_function ( & mut dest , & func ) ? ; } imp . gen_struct_end_declaration ( & mut dest , & temp_string ) ? ; // Generate the AllFuncs struct temp_string . clear ( ) ; temp_string . push_str ( " " ) ; temp_string . push_str ( & sdef . name ) ; temp_string . push_str ( " " ) ; imp . gen_struct_declaration ( & mut dest , & temp_string ) ? ; for name in & sdef . full_inherit { imp . gen_funcs_declaration ( & mut dest , name , name ) ? ; } imp . gen_struct_end_declaration ( & mut dest , & temp_string ) ? ; // Construct struct name temp_string . clear ( ) ; temp_string . push_str ( " " ) ; temp_string . push_str ( & sdef . name ) ; // Generate the struct implementation imp . gen_struct_declaration ( & mut dest , & temp_string ) ? ; imp . gen_rubase_ptr_data ( & mut dest , " " ) ? ; imp . gen_rubase_ptr_data ( & mut dest , " " ) ? ; imp . gen_funcs_declaration ( & mut dest , " " , & format ! ( " " sdef name ) ) ? ; imp . gen_struct_end_declaration ( & mut dest , & temp_string ) ? ; } imp . generate_post_declarations ( & mut dest , api_def ) }
Main generation function that generates the structs
Main generation function that generates the structs
filename
&str
api_def
&ApiDef
imp
T
filename
&str
api_def
&ApiDef
imp
T