fn write_get_fn(o: &mut BufWriter<File>, s: &Struct, m: &Member, impl_type_param: &str,
        impl_type_param_block: &str, structs: &HashMap<String, Struct>, is_for_builder: bool)
        -> io::Result<()> {
    let t = INDENT;
    if member_is_excluded(&m.orig_name) || m.is_ptr_count { return Ok(()); }
    let sig = MemberSig::new(m, s, structs, impl_type_param);

    let fn_name = sig.fn_name;
    // let fn_name = if m.is_handle_type {
    //     format!("{}_handle", sig.fn_name)
    // } else {
    //     sig.fn_name
    // };

    let return_type = if m.is_handle_type {
        if let Some(_) = m.ptr_count_member_orig_name {
            format!("&'a [{}{}]", ORIG_PRE, m.orig_type)
        } else if m.is_ptr {
            format!("&'a {}{}", ORIG_PRE, m.orig_type)
        } else {
            format!("{}{}", ORIG_PRE, m.orig_type)
        }
    } else {
        sig.return_type
    };

    let get_pre = if is_for_builder { "get_" } else { "" };

    writeln!(o, "{t}pub fn {}{}<{}>(&'a self) -> {} {{", get_pre, fn_name,
        sig.get_fn_type_params, return_type, t=t)?;

    if sig.arg_is_struct {
        if m.is_ptr {
            if sig.arg_is_slice {
                if let Some(ref count_orig_name) = m.ptr_count_member_orig_name {
                    if count_orig_name == "codeSize" {
                        write!(o, "{t}{t}unsafe {{ slice::from_raw_parts(self.raw.{} as *const _, \
                            self.raw.{} / 4) }}", m.orig_name, count_orig_name, t=t)?;
                    // } else if sig.arg_is_repr_c {
                    //     write!(o, "{t}{t}unsafe {{ slice::from_raw_parts(self.raw.{} as *const _, \
                    //         self.raw.{} as usize) }}", m.orig_name, count_orig_name, t=t)?;
                    } else {
                        write!(o, "{t}{t}unsafe {{ slice::from_raw_parts(self.raw.{} as *const _, \
                            self.raw.{} as usize) }}", m.orig_name, count_orig_name, t=t)?;
                    }
                } else {
                    // write!(o, "{t}{t}&*(self.raw.{} as *const {}{} as *const _)", m.orig_name,
                    //     ORIG_PRE, m.orig_type, t=t)?;
                    // write!(o, "{t}{t}", t=t)?;
                    // write!(o, "unsafe {{ slice::from_raw_parts(self.raw.{} as *const _, \
                    //     self.raw.{} as usize) }}", m.orig_name, count_orig_name)?;
                }
            } else {
                assert!(sig.arg_is_repr_c);
                write!(o, "{t}{t}unsafe {{ &*(self.raw.{} as *const {}{} as *const _) }}", m.orig_name,
                    ORIG_PRE, m.orig_type, t=t)?;
            }
        } else {
            if let Some(ref len) = m.array_len {
                write!(o, "{t}{t}", t=t)?;
                write!(o, "unsafe {{ slice::from_raw_parts(&self.raw.{} \
                    as *const {}{} as *const _, ", m.orig_name, ORIG_PRE, m.orig_type)?;
                match len.parse::<usize>() {
                    Ok(_) => write!(o, "{} as usize) ", len)?,
                    Err(_) => write!(o, "{}{} as usize) ", ORIG_PRE, len)?,
                }
                write!(o, "}}",  )?;
            } else {
                assert!(sig.arg_is_repr_c);
                write!(o, "{t}{t}unsafe {{ &*(&self.raw.{} as *const {}{} as *const {}) }}", m.orig_name,
                    ORIG_PRE, m.orig_type, m.voodoo_type, t=t)?;
            }
        }
    } else {
        // write!(o, "{t}{t}self.raw.{}", m.orig_name, t=t)?;
        if let Some(ref count_orig_name) = m.ptr_count_member_orig_name {
            write!(o, "{t}{t}", t=t)?;
            write!(o, "unsafe {{ slice::from_raw_parts(self.raw.{} as *const _, self.raw.{} as usize) }}",
                m.orig_name, count_orig_name)?;
        } else if sig.convert_return_to_c_str {
            write!(o, "{t}{t}", t=t)?;
            write!(o, "unsafe {{ CStr::from_ptr(")?;
            match m.array_len {
                Some(_) => write!(o, "&self.raw.{} as *const _", m.orig_name)?,
                None => write!(o, "self.raw.{}", m.orig_name)?,
            }
            write!(o, ") }}")?;
        } else if sig.convert_return_to_slice {
            match m.array_len {
                Some(ref len) => {
                    // write!(o, "{t}{t}", t=t)?;
                    // write!(o, "unsafe {{ slice::from_raw_parts(self.raw.{} as *const _, \
                    //     {} as usize) }}", m.orig_name, len)?;

                    write!(o, "{t}{t}", t=t)?;
                    write!(o, "unsafe {{ slice::from_raw_parts(&self.raw.{} as *const _, ", m.orig_name)?;
                    match len.parse::<usize>() {
                        Ok(_) => write!(o, "{} as usize) ", len)?,
                        Err(_) => write!(o, "{}{} as usize) ", ORIG_PRE, len)?,
                    }
                    write!(o, "}}",  )?;
                },
                None => panic!("supposed to convert to slice but no len avail"),
            }
        } else if sig.convert_return_to_flags {
            write!(o, "{t}{t}{}::from_bits(self.raw.{})\n{t}{t}{t}\
                .expect(\"{}::{}: error converting flags\")",
                m.voodoo_type, m.orig_name, s.voodoo_name, fn_name, t=t)?;
        } else if m.voodoo_type.as_str() == "bool" {
            write!(o, "{t}{t}self.raw.{} != 0", m.orig_name, t=t)?;
        } else if sig.convert_return && !m.is_ptr {
            write!(o, "{t}{t}self.raw.{}", m.orig_name, t=t)?;
            write!(o, ".into()")?;
        } else if m.is_handle_type && m.is_ptr {
            write!(o, "{t}{t}unsafe {{ &*(self.raw.{} as *const _) }}", m.orig_name, t=t)?;
        } else if m.is_ptr {
            if sig.unsafe_to_set {
                write!(o, "{t}{t}self.raw.{}", m.orig_name, t=t)?;
            // } else if sig.arg_is_slice {

            } else {
                write!(o, "{t}{t}unsafe {{ &*(self.raw.{} as *const _) }}", m.orig_name, t=t)?;
            }
        } else {
            write!(o, "{t}{t}self.raw.{}", m.orig_name, t=t)?;
        }
    }


    // IF IS_REPR_C:
    // unsafe { *(&self.raw.memoryTypes
    //         as *const [vks::VkMemoryType; vks::VK_MAX_MEMORY_TYPES]
    //         as *const [MemoryType; vks::VK_MAX_MEMORY_TYPES]) }

    write!(o, "\n")?;

    write!(o, "{t}}}\n\n", t=t)?;
    Ok(())
}
/// Writes a getter function to the output buffer.
Writes a getter function to the output buffer.
Writes a getter function to the output buffer .
fn write_get_fn(o: &mut BufWriter<File>, s: &Struct, m: &Member, impl_type_param: &str,
        impl_type_param_block: &str, structs: &HashMap<String, Struct>, is_for_builder: bool)
        -> io::Result<()> {
    let t = INDENT;
    if member_is_excluded(&m.orig_name) || m.is_ptr_count { return Ok(()); }
    let sig = MemberSig::new(m, s, structs, impl_type_param);
    let fn_name = sig.fn_name;
    // let fn_name = if m.is_handle_type {
    //     format!("{}_handle", sig.fn_name)
    // } else {
    //     sig.fn_name
    // };
    let return_type = if m.is_handle_type {
        if let Some(_) = m.ptr_count_member_orig_name {
            format!("&'a [{}{}]", ORIG_PRE, m.orig_type)
        } else if m.is_ptr {
            format!("&'a {}{}", ORIG_PRE, m.orig_type)
        } else {
            format!("{}{}", ORIG_PRE, m.orig_type)
        }
    } else {
        sig.return_type
    };
    let get_pre = if is_for_builder { "get_" } else { "" };
    writeln!(o, "{t}pub fn {}{}<{}>(&'a self) -> {} {{", get_pre, fn_name,
        sig.get_fn_type_params, return_type, t=t)?;
    if sig.arg_is_struct {
        if m.is_ptr {
            if sig.arg_is_slice {
                if let Some(ref count_orig_name) = m.ptr_count_member_orig_name {
                    if count_orig_name == "codeSize" {
                        write!(o, "{t}{t}unsafe {{ slice::from_raw_parts(self.raw.{} as *const _, \
                            self.raw.{} / 4) }}", m.orig_name, count_orig_name, t=t)?;
                    // } else if sig.arg_is_repr_c {
                    //     write!(o, "{t}{t}unsafe {{ slice::from_raw_parts(self.raw.{} as *const _, \
                    //         self.raw.{} as usize) }}", m.orig_name, count_orig_name, t=t)?;
                    } else {
                        write!(o, "{t}{t}unsafe {{ slice::from_raw_parts(self.raw.{} as *const _, \
                            self.raw.{} as usize) }}", m.orig_name, count_orig_name, t=t)?;
                    }
                } else {
                    // write!(o, "{t}{t}&*(self.raw.{} as *const {}{} as *const _)", m.orig_name,
                    //     ORIG_PRE, m.orig_type, t=t)?;
                    // write!(o, "{t}{t}", t=t)?;
                    // write!(o, "unsafe {{ slice::from_raw_parts(self.raw.{} as *const _, \
                    //     self.raw.{} as usize) }}", m.orig_name, count_orig_name)?;
                }
            } else {
                assert!(sig.arg_is_repr_c);
                write!(o, "{t}{t}unsafe {{ &*(self.raw.{} as *const {}{} as *const _) }}", m.orig_name,
                    ORIG_PRE, m.orig_type, t=t)?;
            }
        } else {
            if let Some(ref len) = m.array_len {
                write!(o, "{t}{t}", t=t)?;
                write!(o, "unsafe {{ slice::from_raw_parts(&self.raw.{} \
                    as *const {}{} as *const _, ", m.orig_name, ORIG_PRE, m.orig_type)?;
                match len.parse::<usize>() {
                    Ok(_) => write!(o, "{} as usize) ", len)?,
                    Err(_) => write!(o, "{}{} as usize) ", ORIG_PRE, len)?,
                }
                write!(o, "}}",  )?;
            } else {
                assert!(sig.arg_is_repr_c);
                write!(o, "{t}{t}unsafe {{ &*(&self.raw.{} as *const {}{} as *const {}) }}", m.orig_name,
                    ORIG_PRE, m.orig_type, m.voodoo_type, t=t)?;
            }
        }
    } else {
        // write!(o, "{t}{t}self.raw.{}", m.orig_name, t=t)?;
        if let Some(ref count_orig_name) = m.ptr_count_member_orig_name {
            write!(o, "{t}{t}", t=t)?;
            write!(o, "unsafe {{ slice::from_raw_parts(self.raw.{} as *const _, self.raw.{} as usize) }}",
                m.orig_name, count_orig_name)?;
        } else if sig.convert_return_to_c_str {
            write!(o, "{t}{t}", t=t)?;
            write!(o, "unsafe {{ CStr::from_ptr(")?;
            match m.array_len {
                Some(_) => write!(o, "&self.raw.{} as *const _", m.orig_name)?,
                None => write!(o, "self.raw.{}", m.orig_name)?,
            }
            write!(o, ") }}")?;
        } else if sig.convert_return_to_slice {
            match m.array_len {
                Some(ref len) => {
                    // write!(o, "{t}{t}", t=t)?;
                    // write!(o, "unsafe {{ slice::from_raw_parts(self.raw.{} as *const _, \
                    //     {} as usize) }}", m.orig_name, len)?;
                    write!(o, "{t}{t}", t=t)?;
                    write!(o, "unsafe {{ slice::from_raw_parts(&self.raw.{} as *const _, ", m.orig_name)?;
                    match len.parse::<usize>() {
                        Ok(_) => write!(o, "{} as usize) ", len)?,
                        Err(_) => write!(o, "{}{} as usize) ", ORIG_PRE, len)?,
                    }
                    write!(o, "}}",  )?;
                },
                None => panic!("supposed to convert to slice but no len avail"),
            }
        } else if sig.convert_return_to_flags {
            write!(o, "{t}{t}{}::from_bits(self.raw.{})\n{t}{t}{t}\
                .expect(\"{}::{}: error converting flags\")",
                m.voodoo_type, m.orig_name, s.voodoo_name, fn_name, t=t)?;
        } else if m.voodoo_type.as_str() == "bool" {
            write!(o, "{t}{t}self.raw.{} != 0", m.orig_name, t=t)?;
        } else if sig.convert_return && !m.is_ptr {
            write!(o, "{t}{t}self.raw.{}", m.orig_name, t=t)?;
            write!(o, ".into()")?;
        } else if m.is_handle_type && m.is_ptr {
            write!(o, "{t}{t}unsafe {{ &*(self.raw.{} as *const _) }}", m.orig_name, t=t)?;
        } else if m.is_ptr {
            if sig.unsafe_to_set {
                write!(o, "{t}{t}self.raw.{}", m.orig_name, t=t)?;
            // } else if sig.arg_is_slice {
            } else {
                write!(o, "{t}{t}unsafe {{ &*(self.raw.{} as *const _) }}", m.orig_name, t=t)?;
            }
        } else {
            write!(o, "{t}{t}self.raw.{}", m.orig_name, t=t)?;
        }
    }
    // IF IS_REPR_C:
    // unsafe { *(&self.raw.memoryTypes
    //         as *const [vks::VkMemoryType; vks::VK_MAX_MEMORY_TYPES]
    //         as *const [MemoryType; vks::VK_MAX_MEMORY_TYPES]) }
    write!(o, "\n")?;
    write!(o, "{t}}}\n\n", t=t)?;
    Ok(())
}
fn write_get_fn ( o : & mut BufWriter < File > , s : & Struct , m : & Member , impl_type_param : & str , impl_type_param_block : & str , structs : & HashMap < String , Struct > , is_for_builder : bool ) -> io :: Result < ( ) > { let t = INDENT ; if member_is_excluded ( & m . orig_name ) || m . is_ptr_count { return Ok ( ( ) ) ; } let sig = MemberSig :: new ( m , s , structs , impl_type_param ) ; let fn_name = sig . fn_name ; // let fn_name = if m.is_handle_type { //     format!("{}_handle", sig.fn_name) // } else { //     sig.fn_name // }; let return_type = if m . is_handle_type { if let Some ( _ ) = m . ptr_count_member_orig_name { format ! ( " " ORIG_PRE m orig_type ) } else if m . is_ptr { format ! ( " " ORIG_PRE m orig_type ) } else { format ! ( " " ORIG_PRE m orig_type ) } } else { sig . return_type } ; let get_pre = if is_for_builder { " " } else { " " } ; writeln ! ( o " " get_pre fn_name sig get_fn_type_params return_type t t ) ? ; if sig . arg_is_struct { if m . is_ptr { if sig . arg_is_slice { if let Some ( ref count_orig_name ) = m . ptr_count_member_orig_name { if count_orig_name == " " { write ! ( o " \
 " m orig_name count_orig_name t t ) ? ; // } else if sig.arg_is_repr_c { //     write!(o, "{t}{t}unsafe {{ slice::from_raw_parts(self.raw.{} as *const _, \ //         self.raw.{} as usize) }}", m.orig_name, count_orig_name, t=t)?; } else { write ! ( o " \
 " m orig_name count_orig_name t t ) ? ; } } else { // write!(o, "{t}{t}&*(self.raw.{} as *const {}{} as *const _)", m.orig_name, //     ORIG_PRE, m.orig_type, t=t)?; // write!(o, "{t}{t}", t=t)?; // write!(o, "unsafe {{ slice::from_raw_parts(self.raw.{} as *const _, \ //     self.raw.{} as usize) }}", m.orig_name, count_orig_name)?; } } else { assert ! ( sig arg_is_repr_c ) ; write ! ( o " " m orig_name ORIG_PRE m orig_type t t ) ? ; } } else { if let Some ( ref len ) = m . array_len { write ! ( o " " t t ) ? ; write ! ( o " \
 " m orig_name ORIG_PRE m orig_type ) ? ; match len . parse :: < usize > ( ) { Ok ( _ ) => write ! ( o " " len ) ? , Err ( _ ) => write ! ( o " " ORIG_PRE len ) ? , } write ! ( o " " ) ? ; } else { assert ! ( sig arg_is_repr_c ) ; write ! ( o " " m orig_name ORIG_PRE m orig_type m voodoo_type t t ) ? ; } } } else { // write!(o, "{t}{t}self.raw.{}", m.orig_name, t=t)?; if let Some ( ref count_orig_name ) = m . ptr_count_member_orig_name { write ! ( o " " t t ) ? ; write ! ( o " " m orig_name count_orig_name ) ? ; } else if sig . convert_return_to_c_str { write ! ( o " " t t ) ? ; write ! ( o " " ) ? ; match m . array_len { Some ( _ ) => write ! ( o " " m orig_name ) ? , None => write ! ( o " " m orig_name ) ? , } write ! ( o " " ) ? ; } else if sig . convert_return_to_slice { match m . array_len { Some ( ref len ) => { // write!(o, "{t}{t}", t=t)?; // write!(o, "unsafe {{ slice::from_raw_parts(self.raw.{} as *const _, \ //     {} as usize) }}", m.orig_name, len)?; write ! ( o " " t t ) ? ; write ! ( o " " m orig_name ) ? ; match len . parse :: < usize > ( ) { Ok ( _ ) => write ! ( o " " len ) ? , Err ( _ ) => write ! ( o " " ORIG_PRE len ) ? , } write ! ( o " " ) ? ; } , None => panic ! ( " " ) , } } else if sig . convert_return_to_flags { write ! ( o " \n \
 \" \" " m voodoo_type m orig_name s voodoo_name fn_name t t ) ? ; } else if m . voodoo_type . as_str ( ) == " " { write ! ( o " " m orig_name t t ) ? ; } else if sig . convert_return && ! m . is_ptr { write ! ( o " " m orig_name t t ) ? ; write ! ( o " " ) ? ; } else if m . is_handle_type && m . is_ptr { write ! ( o " " m orig_name t t ) ? ; } else if m . is_ptr { if sig . unsafe_to_set { write ! ( o " " m orig_name t t ) ? ; // } else if sig.arg_is_slice { } else { write ! ( o " " m orig_name t t ) ? ; } } else { write ! ( o " " m orig_name t t ) ? ; } } // IF IS_REPR_C: // unsafe { *(&self.raw.memoryTypes //         as *const [vks::VkMemoryType; vks::VK_MAX_MEMORY_TYPES] //         as *const [MemoryType; vks::VK_MAX_MEMORY_TYPES]) } write ! ( o " \n " ) ? ; write ! ( o " \n \n " t t ) ? ; Ok ( ( ) ) }
Writes a getter function to the output buffer.
Writes a getter function to the output buffer .
o
&mut BufWriter<File>
s
&Struct
m
&Member
impl_type_param
&str
impl_type_param_block
&str
structs
&HashMap<String, Struct>
is_for_builder
bool
o
&mut BufWriter<File>
s
&Struct
m
&Member
impl_type_param
&str
impl_type_param_block
&str
structs
&HashMap<String, Struct>
is_for_builder
bool