fn print_func<W: Write>(
    name_count_lookup: &mut HashMap<String, usize>,
    dest: &mut W,
    entry: &Entity,
    class_name: &str,
    docs: &HashMap<String, QDocFile>,
    func_type: AccessLevel,
) {
    let name = match entry.get_name() {
        Some(name) => name,
        None => return,
    };

    // Never generate private functions
    if func_type == AccessLevel::Private {
        return;
    }

    for skip in SKIP_NAMES {
        if name.contains(skip) {
            return;
        }
    }

    let full_name = format!("{}::{}", class_name, name);
    //println!("full name {}", full_name);

    // So this is slow. Better would be to setup the names so we could
    // just use a hash table to match it but as this is something
    // we do very infrequent (generating the base line from Qt)
    // having this taking a bit longer than needed isn't the end of the world.

    for (_, f) in docs {
        for entry in &f.0 {
            match entry.data {
                QDocItem::Function(ref name) => {
                    if name.contains(&full_name) {
                        print_doc_comments(dest, &entry.formatted_rustdoc(), 4);
                    }
                }

                QDocItem::Property(ref name) => {
                    if name.contains(&full_name) {
                        print_doc_comments(dest, &entry.formatted_rustdoc(), 4);
                    }
                }

                _ => (),
            }
        }
    }

    let mut name_count: usize = 0;

    if let Some(count) = name_count_lookup.get_mut(&name) {
        name_count = *count;
        *count += 1;
    }

    if !name_count_lookup.contains_key(&name) {
        name_count_lookup.insert(name.to_owned(), 2);
    }

    if name_count > 0 {
        writeln!(dest, "    [org_name({})]", name);
    }

    // check if we have any doc for this

    if func_type == AccessLevel::Signal {
        write!(dest, "    [signal] ");
    } else if entry.is_virtual_method() {
        write!(dest, "    [event] ");
    } else if entry.is_static_method() {
        write!(dest, "    [static] ");
    } else {
        write!(dest, "    ");
    }

    // If we have multiple instances of the same name
    // we just add _1, _2, etc to the names. These will be renamed (manually) later


    if name_count > 0 {
        write!(dest, "{}_{}", name.to_snake_case(), name_count);
    } else {
        write!(dest, "{}", name.to_snake_case());
    }

    if let Some(args) = entry.get_arguments() {
        if args.is_empty() {
            write!(dest, "()");
        } else {
            let mut count = 0;

            write!(dest, "(");

            print_arg(dest, &args[0], &mut count);

            for arg in &args[1..] {
                write!(dest, ", ");
                print_arg(dest, arg, &mut count);
            }

            write!(dest, ")");
        }
    } else {
        write!(dest, "()");
    }

    if let Some(res) = entry.get_result_type() {
        let display_name = res.get_display_name();

        if display_name.contains("void") {
            writeln!(dest, ",");
        } else {
            writeln!(dest, " -> {},", get_arg_type(&res, IsReturnType::Yes));
        }
    } else {
        writeln!(dest, "\n");
    }
}
///
/// Print a functio/method definition
///
Print a functio/method definition
Print a functio / method definition
fn print_func<W: Write>(
    name_count_lookup: &mut HashMap<String, usize>,
    dest: &mut W,
    entry: &Entity,
    class_name: &str,
    docs: &HashMap<String, QDocFile>,
    func_type: AccessLevel,
) {
    let name = match entry.get_name() {
        Some(name) => name,
        None => return,
    };
    // Never generate private functions
    if func_type == AccessLevel::Private {
        return;
    }
    for skip in SKIP_NAMES {
        if name.contains(skip) {
            return;
        }
    }
    let full_name = format!("{}::{}", class_name, name);
    //println!("full name {}", full_name);
    // So this is slow. Better would be to setup the names so we could
    // just use a hash table to match it but as this is something
    // we do very infrequent (generating the base line from Qt)
    // having this taking a bit longer than needed isn't the end of the world.
    for (_, f) in docs {
        for entry in &f.0 {
            match entry.data {
                QDocItem::Function(ref name) => {
                    if name.contains(&full_name) {
                        print_doc_comments(dest, &entry.formatted_rustdoc(), 4);
                    }
                }
                QDocItem::Property(ref name) => {
                    if name.contains(&full_name) {
                        print_doc_comments(dest, &entry.formatted_rustdoc(), 4);
                    }
                }
                _ => (),
            }
        }
    }
    let mut name_count: usize = 0;
    if let Some(count) = name_count_lookup.get_mut(&name) {
        name_count = *count;
        *count += 1;
    }
    if !name_count_lookup.contains_key(&name) {
        name_count_lookup.insert(name.to_owned(), 2);
    }
    if name_count > 0 {
        writeln!(dest, "    [org_name({})]", name);
    }
    // check if we have any doc for this
    if func_type == AccessLevel::Signal {
        write!(dest, "    [signal] ");
    } else if entry.is_virtual_method() {
        write!(dest, "    [event] ");
    } else if entry.is_static_method() {
        write!(dest, "    [static] ");
    } else {
        write!(dest, "    ");
    }
    // If we have multiple instances of the same name
    // we just add _1, _2, etc to the names. These will be renamed (manually) later
    if name_count > 0 {
        write!(dest, "{}_{}", name.to_snake_case(), name_count);
    } else {
        write!(dest, "{}", name.to_snake_case());
    }
    if let Some(args) = entry.get_arguments() {
        if args.is_empty() {
            write!(dest, "()");
        } else {
            let mut count = 0;
            write!(dest, "(");
            print_arg(dest, &args[0], &mut count);
            for arg in &args[1..] {
                write!(dest, ", ");
                print_arg(dest, arg, &mut count);
            }
            write!(dest, ")");
        }
    } else {
        write!(dest, "()");
    }
    if let Some(res) = entry.get_result_type() {
        let display_name = res.get_display_name();
        if display_name.contains("void") {
            writeln!(dest, ",");
        } else {
            writeln!(dest, " -> {},", get_arg_type(&res, IsReturnType::Yes));
        }
    } else {
        writeln!(dest, "\n");
    }
}
fn print_func < W : Write > ( name_count_lookup : & mut HashMap < String , usize > , dest : & mut W , entry : & Entity , class_name : & str , docs : & HashMap < String , QDocFile > , func_type : AccessLevel , ) { let name = match entry . get_name ( ) { Some ( name ) => name , None => return , } ; // Never generate private functions if func_type == AccessLevel :: Private { return ; } for skip in SKIP_NAMES { if name . contains ( skip ) { return ; } } let full_name = format ! ( " " class_name name ) ; //println!("full name {}", full_name); // So this is slow. Better would be to setup the names so we could // just use a hash table to match it but as this is something // we do very infrequent (generating the base line from Qt) // having this taking a bit longer than needed isn't the end of the world. for ( _ , f ) in docs { for entry in & f . 0 { match entry . data { QDocItem :: Function ( ref name ) => { if name . contains ( & full_name ) { print_doc_comments ( dest , & entry . formatted_rustdoc ( ) , 4 ) ; } } QDocItem :: Property ( ref name ) => { if name . contains ( & full_name ) { print_doc_comments ( dest , & entry . formatted_rustdoc ( ) , 4 ) ; } } _ => ( ) , } } } let mut name_count : usize = 0 ; if let Some ( count ) = name_count_lookup . get_mut ( & name ) { name_count = * count ; * count += 1 ; } if ! name_count_lookup . contains_key ( & name ) { name_count_lookup . insert ( name . to_owned ( ) , 2 ) ; } if name_count > 0 { writeln ! ( dest " " name ) ; } // check if we have any doc for this if func_type == AccessLevel :: Signal { write ! ( dest " " ) ; } else if entry . is_virtual_method ( ) { write ! ( dest " " ) ; } else if entry . is_static_method ( ) { write ! ( dest " " ) ; } else { write ! ( dest " " ) ; } // If we have multiple instances of the same name // we just add _1, _2, etc to the names. These will be renamed (manually) later if name_count > 0 { write ! ( dest " " name to_snake_case ( ) name_count ) ; } else { write ! ( dest " " name to_snake_case ( ) ) ; } if let Some ( args ) = entry . get_arguments ( ) { if args . is_empty ( ) { write ! ( dest " " ) ; } else { let mut count = 0 ; write ! ( dest " " ) ; print_arg ( dest , & args [ 0 ] , & mut count ) ; for arg in & args [ 1 .. ] { write ! ( dest " " ) ; print_arg ( dest , arg , & mut count ) ; } write ! ( dest " " ) ; } } else { write ! ( dest " " ) ; } if let Some ( res ) = entry . get_result_type ( ) { let display_name = res . get_display_name ( ) ; if display_name . contains ( " " ) { writeln ! ( dest " " ) ; } else { writeln ! ( dest " " get_arg_type ( res IsReturnType Yes ) ) ; } } else { writeln ! ( dest " \n " ) ; } }
Print a functio/method definition
Print a functio / method definition
name_count_lookup
&mut HashMap<String, usize>
dest
&mut W
entry
&Entity
class_name
&str
docs
&HashMap<String, QDocFile>
func_type
AccessLevel
name_count_lookup
&mut HashMap<String, usize>
dest
&mut W
entry
&Entity
class_name
&str
docs
&HashMap<String, QDocFile>
func_type
AccessLevel