use crate::*;

impl Default for apk_package {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}

impl ::std::fmt::Debug for apk_package {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        write ! (f , "apk_package {{ hash_node: {:?}, foreach_genid: {:?}, __bindgen_anon_1: {:?}, name: {:?}, ipkg: {:?}, version: {:?}, arch: {:?}, license: {:?}, origin: {:?}, maintainer: {:?}, url: {:?}, description: {:?}, commit: {:?}, filename: {:?}, depends: {:?}, install_if: {:?}, provides: {:?}, installed_size: {:?}, size: {:?}, build_time: {:?}, provider_priority: {:?}, repos : {:?}, marked : {:?}, uninstallable : {:?}, cached_non_repository : {:?}, csum: {:?} }}" , self . hash_node , self . foreach_genid , self . __bindgen_anon_1 , self . name , self . ipkg , self . version , self . arch , self . license , self . origin , self . maintainer , self . url , self . description , self . commit , self . filename , self . depends , self . install_if , self . provides , self . installed_size , self . size , self . build_time , self . provider_priority , self . repos() , self . marked() , self . uninstallable() , self . cached_non_repository (), self . csum)
    }
}

// can't be auto-generated since the bitfields aren't correctly generated by bindgen#
// (they shoul be 5 bytes big in total, bindgen makes them take up 8)

#[repr(C)]
pub struct apk_package {
    pub hash_node: apk_hash_node,
    pub foreach_genid: ::std::os::raw::c_uint,
    __bindgen_anon_1: apk_package__bindgen_ty_1,
    pub name: *mut apk_name,
    pub ipkg: *mut apk_installed_package,
    pub version: *mut apk_blob_t,
    pub arch: *mut apk_blob_t,
    pub license: *mut apk_blob_t,
    pub origin: *mut apk_blob_t,
    pub maintainer: *mut apk_blob_t,
    pub url: *mut ::std::os::raw::c_char,
    pub description: *mut ::std::os::raw::c_char,
    pub commit: *mut ::std::os::raw::c_char,
    pub filename: *mut ::std::os::raw::c_char,
    pub depends: *mut apk_dependency_array,
    pub install_if: *mut apk_dependency_array,
    pub provides: *mut apk_dependency_array,
    pub installed_size: usize,
    pub size: usize,
    pub build_time: time_t,
    pub provider_priority: ::std::os::raw::c_ushort,
    bitfields: private::apk_package_bitfield,
    pub csum: apk_checksum,
}

impl apk_package {
    pub fn repos(&self) -> u32 {
        self.bitfields.repos()
    }

    pub fn marked(&self) -> u8 {
        self.bitfields.marked()
    }

    pub fn uninstallable(&self) -> u8 {
        self.bitfields.uninstallable()
    }

    pub fn cached_non_repository(&self) -> u8 {
        self.bitfields.cached_non_repository()
    }

    pub fn set_repos(&mut self, val: u32) {
        self.bitfields.set_repos(val)
    }

    pub fn set_marked(&mut self, val: u8) {
        self.bitfields.set_marked(val)
    }

    pub fn set_uninstallable(&mut self, val: u8) {
        self.bitfields.set_uninstallable(val)
    }

    pub fn set_cached_non_repository(&mut self, val: u8) {
        self.bitfields.set_cached_non_repository(val)
    }
}

#[allow(dead_code)]
mod private {
    #[modular_bitfield::bitfield]
    #[repr(C)]
    pub struct apk_package_bitfield {
        pub repos: u32,
        pub marked: u8,
        pub uninstallable: u8,
        pub cached_non_repository: u8,
    }
}

#[cfg(all(test, target_pointer_width = "64"))]
mod test {
    use super::*;

    #[test]
    fn bindgen_test_layout_apk_package() {
        assert_eq!(
            ::std::mem::size_of::<apk_package>(),
            200usize,
            concat!("Size of: ", stringify!(apk_package))
        );
        assert_eq!(
            ::std::mem::align_of::<apk_package>(),
            8usize,
            concat!("Alignment of ", stringify!(apk_package))
        );
        fn test_field_hash_node() {
            assert_eq!(
                unsafe {
                    let uninit = ::std::mem::MaybeUninit::<apk_package>::uninit();
                    let ptr = uninit.as_ptr();
                    ::std::ptr::addr_of!((*ptr).hash_node) as usize - ptr as usize
                },
                0usize,
                concat!(
                    "Offset of field: ",
                    stringify!(apk_package),
                    "::",
                    stringify!(hash_node)
                )
            );
        }
        test_field_hash_node();
        fn test_field_foreach_genid() {
            assert_eq!(
                unsafe {
                    let uninit = ::std::mem::MaybeUninit::<apk_package>::uninit();
                    let ptr = uninit.as_ptr();
                    ::std::ptr::addr_of!((*ptr).foreach_genid) as usize - ptr as usize
                },
                8usize,
                concat!(
                    "Offset of field: ",
                    stringify!(apk_package),
                    "::",
                    stringify!(foreach_genid)
                )
            );
        }
        test_field_foreach_genid();
        fn test_field_name() {
            assert_eq!(
                unsafe {
                    let uninit = ::std::mem::MaybeUninit::<apk_package>::uninit();
                    let ptr = uninit.as_ptr();
                    ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize
                },
                32usize,
                concat!(
                    "Offset of field: ",
                    stringify!(apk_package),
                    "::",
                    stringify!(name)
                )
            );
        }
        test_field_name();
        fn test_field_ipkg() {
            assert_eq!(
                unsafe {
                    let uninit = ::std::mem::MaybeUninit::<apk_package>::uninit();
                    let ptr = uninit.as_ptr();
                    ::std::ptr::addr_of!((*ptr).ipkg) as usize - ptr as usize
                },
                40usize,
                concat!(
                    "Offset of field: ",
                    stringify!(apk_package),
                    "::",
                    stringify!(ipkg)
                )
            );
        }
        test_field_ipkg();
        fn test_field_version() {
            assert_eq!(
                unsafe {
                    let uninit = ::std::mem::MaybeUninit::<apk_package>::uninit();
                    let ptr = uninit.as_ptr();
                    ::std::ptr::addr_of!((*ptr).version) as usize - ptr as usize
                },
                48usize,
                concat!(
                    "Offset of field: ",
                    stringify!(apk_package),
                    "::",
                    stringify!(version)
                )
            );
        }
        test_field_version();
        fn test_field_arch() {
            assert_eq!(
                unsafe {
                    let uninit = ::std::mem::MaybeUninit::<apk_package>::uninit();
                    let ptr = uninit.as_ptr();
                    ::std::ptr::addr_of!((*ptr).arch) as usize - ptr as usize
                },
                56usize,
                concat!(
                    "Offset of field: ",
                    stringify!(apk_package),
                    "::",
                    stringify!(arch)
                )
            );
        }
        test_field_arch();
        fn test_field_license() {
            assert_eq!(
                unsafe {
                    let uninit = ::std::mem::MaybeUninit::<apk_package>::uninit();
                    let ptr = uninit.as_ptr();
                    ::std::ptr::addr_of!((*ptr).license) as usize - ptr as usize
                },
                64usize,
                concat!(
                    "Offset of field: ",
                    stringify!(apk_package),
                    "::",
                    stringify!(license)
                )
            );
        }
        test_field_license();
        fn test_field_origin() {
            assert_eq!(
                unsafe {
                    let uninit = ::std::mem::MaybeUninit::<apk_package>::uninit();
                    let ptr = uninit.as_ptr();
                    ::std::ptr::addr_of!((*ptr).origin) as usize - ptr as usize
                },
                72usize,
                concat!(
                    "Offset of field: ",
                    stringify!(apk_package),
                    "::",
                    stringify!(origin)
                )
            );
        }
        test_field_origin();
        fn test_field_maintainer() {
            assert_eq!(
                unsafe {
                    let uninit = ::std::mem::MaybeUninit::<apk_package>::uninit();
                    let ptr = uninit.as_ptr();
                    ::std::ptr::addr_of!((*ptr).maintainer) as usize - ptr as usize
                },
                80usize,
                concat!(
                    "Offset of field: ",
                    stringify!(apk_package),
                    "::",
                    stringify!(maintainer)
                )
            );
        }
        test_field_maintainer();
        fn test_field_url() {
            assert_eq!(
                unsafe {
                    let uninit = ::std::mem::MaybeUninit::<apk_package>::uninit();
                    let ptr = uninit.as_ptr();
                    ::std::ptr::addr_of!((*ptr).url) as usize - ptr as usize
                },
                88usize,
                concat!(
                    "Offset of field: ",
                    stringify!(apk_package),
                    "::",
                    stringify!(url)
                )
            );
        }
        test_field_url();
        fn test_field_description() {
            assert_eq!(
                unsafe {
                    let uninit = ::std::mem::MaybeUninit::<apk_package>::uninit();
                    let ptr = uninit.as_ptr();
                    ::std::ptr::addr_of!((*ptr).description) as usize - ptr as usize
                },
                96usize,
                concat!(
                    "Offset of field: ",
                    stringify!(apk_package),
                    "::",
                    stringify!(description)
                )
            );
        }
        test_field_description();
        fn test_field_commit() {
            assert_eq!(
                unsafe {
                    let uninit = ::std::mem::MaybeUninit::<apk_package>::uninit();
                    let ptr = uninit.as_ptr();
                    ::std::ptr::addr_of!((*ptr).commit) as usize - ptr as usize
                },
                104usize,
                concat!(
                    "Offset of field: ",
                    stringify!(apk_package),
                    "::",
                    stringify!(commit)
                )
            );
        }
        test_field_commit();
        fn test_field_filename() {
            assert_eq!(
                unsafe {
                    let uninit = ::std::mem::MaybeUninit::<apk_package>::uninit();
                    let ptr = uninit.as_ptr();
                    ::std::ptr::addr_of!((*ptr).filename) as usize - ptr as usize
                },
                112usize,
                concat!(
                    "Offset of field: ",
                    stringify!(apk_package),
                    "::",
                    stringify!(filename)
                )
            );
        }
        test_field_filename();
        fn test_field_depends() {
            assert_eq!(
                unsafe {
                    let uninit = ::std::mem::MaybeUninit::<apk_package>::uninit();
                    let ptr = uninit.as_ptr();
                    ::std::ptr::addr_of!((*ptr).depends) as usize - ptr as usize
                },
                120usize,
                concat!(
                    "Offset of field: ",
                    stringify!(apk_package),
                    "::",
                    stringify!(depends)
                )
            );
        }
        test_field_depends();
        fn test_field_install_if() {
            assert_eq!(
                unsafe {
                    let uninit = ::std::mem::MaybeUninit::<apk_package>::uninit();
                    let ptr = uninit.as_ptr();
                    ::std::ptr::addr_of!((*ptr).install_if) as usize - ptr as usize
                },
                128usize,
                concat!(
                    "Offset of field: ",
                    stringify!(apk_package),
                    "::",
                    stringify!(install_if)
                )
            );
        }
        test_field_install_if();
        fn test_field_provides() {
            assert_eq!(
                unsafe {
                    let uninit = ::std::mem::MaybeUninit::<apk_package>::uninit();
                    let ptr = uninit.as_ptr();
                    ::std::ptr::addr_of!((*ptr).provides) as usize - ptr as usize
                },
                136usize,
                concat!(
                    "Offset of field: ",
                    stringify!(apk_package),
                    "::",
                    stringify!(provides)
                )
            );
        }
        test_field_provides();
        fn test_field_installed_size() {
            assert_eq!(
                unsafe {
                    let uninit = ::std::mem::MaybeUninit::<apk_package>::uninit();
                    let ptr = uninit.as_ptr();
                    ::std::ptr::addr_of!((*ptr).installed_size) as usize - ptr as usize
                },
                144usize,
                concat!(
                    "Offset of field: ",
                    stringify!(apk_package),
                    "::",
                    stringify!(installed_size)
                )
            );
        }
        test_field_installed_size();
        fn test_field_size() {
            assert_eq!(
                unsafe {
                    let uninit = ::std::mem::MaybeUninit::<apk_package>::uninit();
                    let ptr = uninit.as_ptr();
                    ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize
                },
                152usize,
                concat!(
                    "Offset of field: ",
                    stringify!(apk_package),
                    "::",
                    stringify!(size)
                )
            );
        }
        test_field_size();
        fn test_field_build_time() {
            assert_eq!(
                unsafe {
                    let uninit = ::std::mem::MaybeUninit::<apk_package>::uninit();
                    let ptr = uninit.as_ptr();
                    ::std::ptr::addr_of!((*ptr).build_time) as usize - ptr as usize
                },
                160usize,
                concat!(
                    "Offset of field: ",
                    stringify!(apk_package),
                    "::",
                    stringify!(build_time)
                )
            );
        }
        test_field_build_time();
        fn test_field_provider_priority() {
            assert_eq!(
                unsafe {
                    let uninit = ::std::mem::MaybeUninit::<apk_package>::uninit();
                    let ptr = uninit.as_ptr();
                    ::std::ptr::addr_of!((*ptr).provider_priority) as usize - ptr as usize
                },
                168usize,
                concat!(
                    "Offset of field: ",
                    stringify!(apk_package),
                    "::",
                    stringify!(provider_priority)
                )
            );
        }
        test_field_provider_priority();
        fn test_field_csum() {
            assert_eq!(
                unsafe {
                    let uninit = ::std::mem::MaybeUninit::<apk_package>::uninit();
                    let ptr = uninit.as_ptr();
                    ::std::ptr::addr_of!((*ptr).csum) as usize - ptr as usize
                },
                177usize,
                concat!(
                    "Offset of field: ",
                    stringify!(apk_package),
                    "::",
                    stringify!(csum)
                )
            );
        }
        test_field_csum();
    }
}
