diff --git a/sdl2-sys/build.rs b/sdl2-sys/build.rs index 167869d61a..1015bc6519 100644 --- a/sdl2-sys/build.rs +++ b/sdl2-sys/build.rs @@ -657,6 +657,8 @@ fn generate_bindings(target: &str, host: &str, headers_paths: &[String]) { let mut bindings = bindgen::Builder::default() // enable no_std-friendly output by only using core definitions .use_core() + .bitfield_enum("SDL_RendererFlip") + .newtype_enum("SDL_Keymod") .default_enum_style(bindgen::EnumVariation::Rust { non_exhaustive: false, }) diff --git a/sdl2-sys/sdl_bindings.rs b/sdl2-sys/sdl_bindings.rs index c04ce6e54c..845b57aaa1 100644 --- a/sdl2-sys/sdl_bindings.rs +++ b/sdl2-sys/sdl_bindings.rs @@ -1,8 +1,5 @@ -/* automatically generated by rust-bindgen 0.69.4 */ +/* automatically generated by rust-bindgen 0.69.5 */ -#[derive(PartialEq, Copy, Clone, Hash, Debug, Default)] -#[repr(transparent)] -pub struct __BindgenFloat16(pub u16); pub const __LINUX__: u32 = 1; pub const HAVE_STDARG_H: u32 = 1; pub const HAVE_STDDEF_H: u32 = 1; @@ -18,6 +15,7 @@ pub const SDL_THREADS_DISABLED: u32 = 1; pub const SDL_TIMERS_DISABLED: u32 = 1; pub const SDL_VIDEO_DRIVER_DUMMY: u32 = 1; pub const SDL_FILESYSTEM_DUMMY: u32 = 1; +pub const __GNUC_VA_LIST: u32 = 1; pub const _STDINT_H: u32 = 1; pub const _FEATURES_H: u32 = 1; pub const _DEFAULT_SOURCE: u32 = 1; @@ -35,49 +33,43 @@ pub const __USE_POSIX199506: u32 = 1; pub const __USE_XOPEN2K: u32 = 1; pub const __USE_XOPEN2K8: u32 = 1; pub const _ATFILE_SOURCE: u32 = 1; -pub const __WORDSIZE: u32 = 64; -pub const __WORDSIZE_TIME64_COMPAT32: u32 = 1; -pub const __SYSCALL_WORDSIZE: u32 = 64; -pub const __TIMESIZE: u32 = 64; pub const __USE_MISC: u32 = 1; pub const __USE_ATFILE: u32 = 1; pub const __USE_FORTIFY_LEVEL: u32 = 0; pub const __GLIBC_USE_DEPRECATED_GETS: u32 = 0; pub const __GLIBC_USE_DEPRECATED_SCANF: u32 = 0; -pub const __GLIBC_USE_C2X_STRTOL: u32 = 0; pub const _STDC_PREDEF_H: u32 = 1; pub const __STDC_IEC_559__: u32 = 1; -pub const __STDC_IEC_60559_BFP__: u32 = 201404; pub const __STDC_IEC_559_COMPLEX__: u32 = 1; -pub const __STDC_IEC_60559_COMPLEX__: u32 = 201404; pub const __STDC_ISO_10646__: u32 = 201706; pub const __GNU_LIBRARY__: u32 = 6; pub const __GLIBC__: u32 = 2; -pub const __GLIBC_MINOR__: u32 = 39; +pub const __GLIBC_MINOR__: u32 = 31; pub const _SYS_CDEFS_H: u32 = 1; pub const __glibc_c99_flexarr_available: u32 = 1; -pub const __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI: u32 = 0; +pub const __WORDSIZE: u32 = 64; +pub const __WORDSIZE_TIME64_COMPAT32: u32 = 1; +pub const __SYSCALL_WORDSIZE: u32 = 64; +pub const __LONG_DOUBLE_USES_FLOAT128: u32 = 0; pub const __HAVE_GENERIC_SELECTION: u32 = 1; pub const __GLIBC_USE_LIB_EXT2: u32 = 0; pub const __GLIBC_USE_IEC_60559_BFP_EXT: u32 = 0; pub const __GLIBC_USE_IEC_60559_BFP_EXT_C2X: u32 = 0; -pub const __GLIBC_USE_IEC_60559_EXT: u32 = 0; pub const __GLIBC_USE_IEC_60559_FUNCS_EXT: u32 = 0; pub const __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X: u32 = 0; pub const __GLIBC_USE_IEC_60559_TYPES_EXT: u32 = 0; pub const _BITS_TYPES_H: u32 = 1; +pub const __TIMESIZE: u32 = 64; pub const _BITS_TYPESIZES_H: u32 = 1; pub const __OFF_T_MATCHES_OFF64_T: u32 = 1; pub const __INO_T_MATCHES_INO64_T: u32 = 1; pub const __RLIM_T_MATCHES_RLIM64_T: u32 = 1; pub const __STATFS_MATCHES_STATFS64: u32 = 1; -pub const __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64: u32 = 1; pub const __FD_SETSIZE: u32 = 1024; pub const _BITS_TIME64_H: u32 = 1; pub const _BITS_WCHAR_H: u32 = 1; pub const _BITS_STDINT_INTN_H: u32 = 1; pub const _BITS_STDINT_UINTN_H: u32 = 1; -pub const _BITS_STDINT_LEAST_H: u32 = 1; pub const INT8_MIN: i32 = -128; pub const INT16_MIN: i32 = -32768; pub const INT32_MIN: i32 = -2147483648; @@ -194,6 +186,7 @@ pub const WNOWAIT: u32 = 16777216; pub const __WNOTHREAD: u32 = 536870912; pub const __WALL: u32 = 1073741824; pub const __WCLONE: u32 = 2147483648; +pub const __ENUM_IDTYPE_T: u32 = 1; pub const __W_CONTINUED: u32 = 65535; pub const __WCOREFLAG: u32 = 128; pub const __HAVE_FLOAT128: u32 = 0; @@ -224,6 +217,7 @@ pub const __time_t_defined: u32 = 1; pub const __timer_t_defined: u32 = 1; pub const __BIT_TYPES_DEFINED__: u32 = 1; pub const _SYS_SELECT_H: u32 = 1; +pub const __FD_ZERO_STOS: &[u8; 6] = b"stosq\0"; pub const __sigset_t_defined: u32 = 1; pub const __timeval_defined: u32 = 1; pub const _STRUCT_TIMESPEC: u32 = 1; @@ -1061,8 +1055,8 @@ fn bindgen_test_layout_max_align_t() { ) ); } -pub type __gnuc_va_list = __builtin_va_list; pub type va_list = __builtin_va_list; +pub type __gnuc_va_list = __builtin_va_list; pub type __u_char = libc::c_uchar; pub type __u_short = libc::c_ushort; pub type __u_int = libc::c_uint; @@ -1134,7 +1128,6 @@ pub type __id_t = libc::c_uint; pub type __time_t = libc::c_long; pub type __useconds_t = libc::c_uint; pub type __suseconds_t = libc::c_long; -pub type __suseconds64_t = libc::c_long; pub type __daddr_t = libc::c_int; pub type __key_t = libc::c_int; pub type __clockid_t = libc::c_int; @@ -3119,6 +3112,13 @@ pub type __v4sf = [f32; 4usize]; pub type __m128 = [f32; 4usize]; pub type __m128_u = [f32; 4usize]; pub type __v4su = [libc::c_uint; 4usize]; +#[repr(u32)] +#[derive(Copy, Clone, Hash, PartialEq, Eq)] +pub enum idtype_t { + P_ALL = 0, + P_PID = 1, + P_PGID = 2, +} pub type _Float32 = f32; pub type _Float64 = f64; pub type _Float32x = f64; @@ -3521,93 +3521,6 @@ pub type fsblkcnt_t = __fsblkcnt_t; pub type fsfilcnt_t = __fsfilcnt_t; #[repr(C)] #[derive(Copy, Clone)] -pub union __atomic_wide_counter { - pub __value64: libc::c_ulonglong, - pub __value32: __atomic_wide_counter__bindgen_ty_1, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct __atomic_wide_counter__bindgen_ty_1 { - pub __low: libc::c_uint, - pub __high: libc::c_uint, -} -#[test] -fn bindgen_test_layout___atomic_wide_counter__bindgen_ty_1() { - const UNINIT: ::core::mem::MaybeUninit<__atomic_wide_counter__bindgen_ty_1> = - ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::<__atomic_wide_counter__bindgen_ty_1>(), - 8usize, - concat!("Size of: ", stringify!(__atomic_wide_counter__bindgen_ty_1)) - ); - assert_eq!( - ::core::mem::align_of::<__atomic_wide_counter__bindgen_ty_1>(), - 4usize, - concat!( - "Alignment of ", - stringify!(__atomic_wide_counter__bindgen_ty_1) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).__low) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(__atomic_wide_counter__bindgen_ty_1), - "::", - stringify!(__low) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).__high) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(__atomic_wide_counter__bindgen_ty_1), - "::", - stringify!(__high) - ) - ); -} -#[test] -fn bindgen_test_layout___atomic_wide_counter() { - const UNINIT: ::core::mem::MaybeUninit<__atomic_wide_counter> = - ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::<__atomic_wide_counter>(), - 8usize, - concat!("Size of: ", stringify!(__atomic_wide_counter)) - ); - assert_eq!( - ::core::mem::align_of::<__atomic_wide_counter>(), - 8usize, - concat!("Alignment of ", stringify!(__atomic_wide_counter)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).__value64) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(__atomic_wide_counter), - "::", - stringify!(__value64) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).__value32) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(__atomic_wide_counter), - "::", - stringify!(__value32) - ) - ); -} -#[repr(C)] -#[derive(Copy, Clone)] pub struct __pthread_internal_list { pub __prev: *mut __pthread_internal_list, pub __next: *mut __pthread_internal_list, @@ -3943,48 +3856,208 @@ fn bindgen_test_layout___pthread_rwlock_arch_t() { #[repr(C)] #[derive(Copy, Clone)] pub struct __pthread_cond_s { - pub __wseq: __atomic_wide_counter, - pub __g1_start: __atomic_wide_counter, + pub __bindgen_anon_1: __pthread_cond_s__bindgen_ty_1, + pub __bindgen_anon_2: __pthread_cond_s__bindgen_ty_2, pub __g_refs: [libc::c_uint; 2usize], pub __g_size: [libc::c_uint; 2usize], pub __g1_orig_size: libc::c_uint, pub __wrefs: libc::c_uint, pub __g_signals: [libc::c_uint; 2usize], } +#[repr(C)] +#[derive(Copy, Clone)] +pub union __pthread_cond_s__bindgen_ty_1 { + pub __wseq: libc::c_ulonglong, + pub __wseq32: __pthread_cond_s__bindgen_ty_1__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct __pthread_cond_s__bindgen_ty_1__bindgen_ty_1 { + pub __low: libc::c_uint, + pub __high: libc::c_uint, +} #[test] -fn bindgen_test_layout___pthread_cond_s() { - const UNINIT: ::core::mem::MaybeUninit<__pthread_cond_s> = ::core::mem::MaybeUninit::uninit(); +fn bindgen_test_layout___pthread_cond_s__bindgen_ty_1__bindgen_ty_1() { + const UNINIT: ::core::mem::MaybeUninit<__pthread_cond_s__bindgen_ty_1__bindgen_ty_1> = + ::core::mem::MaybeUninit::uninit(); let ptr = UNINIT.as_ptr(); assert_eq!( - ::core::mem::size_of::<__pthread_cond_s>(), - 48usize, - concat!("Size of: ", stringify!(__pthread_cond_s)) + ::core::mem::size_of::<__pthread_cond_s__bindgen_ty_1__bindgen_ty_1>(), + 8usize, + concat!( + "Size of: ", + stringify!(__pthread_cond_s__bindgen_ty_1__bindgen_ty_1) + ) ); assert_eq!( - ::core::mem::align_of::<__pthread_cond_s>(), + ::core::mem::align_of::<__pthread_cond_s__bindgen_ty_1__bindgen_ty_1>(), + 4usize, + concat!( + "Alignment of ", + stringify!(__pthread_cond_s__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__low) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__pthread_cond_s__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(__low) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__high) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(__pthread_cond_s__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(__high) + ) + ); +} +#[test] +fn bindgen_test_layout___pthread_cond_s__bindgen_ty_1() { + const UNINIT: ::core::mem::MaybeUninit<__pthread_cond_s__bindgen_ty_1> = + ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::<__pthread_cond_s__bindgen_ty_1>(), 8usize, - concat!("Alignment of ", stringify!(__pthread_cond_s)) + concat!("Size of: ", stringify!(__pthread_cond_s__bindgen_ty_1)) + ); + assert_eq!( + ::core::mem::align_of::<__pthread_cond_s__bindgen_ty_1>(), + 8usize, + concat!("Alignment of ", stringify!(__pthread_cond_s__bindgen_ty_1)) ); assert_eq!( unsafe { ::core::ptr::addr_of!((*ptr).__wseq) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(__pthread_cond_s), + stringify!(__pthread_cond_s__bindgen_ty_1), "::", stringify!(__wseq) ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).__g1_start) as usize - ptr as usize }, + unsafe { ::core::ptr::addr_of!((*ptr).__wseq32) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__pthread_cond_s__bindgen_ty_1), + "::", + stringify!(__wseq32) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union __pthread_cond_s__bindgen_ty_2 { + pub __g1_start: libc::c_ulonglong, + pub __g1_start32: __pthread_cond_s__bindgen_ty_2__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct __pthread_cond_s__bindgen_ty_2__bindgen_ty_1 { + pub __low: libc::c_uint, + pub __high: libc::c_uint, +} +#[test] +fn bindgen_test_layout___pthread_cond_s__bindgen_ty_2__bindgen_ty_1() { + const UNINIT: ::core::mem::MaybeUninit<__pthread_cond_s__bindgen_ty_2__bindgen_ty_1> = + ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::<__pthread_cond_s__bindgen_ty_2__bindgen_ty_1>(), 8usize, + concat!( + "Size of: ", + stringify!(__pthread_cond_s__bindgen_ty_2__bindgen_ty_1) + ) + ); + assert_eq!( + ::core::mem::align_of::<__pthread_cond_s__bindgen_ty_2__bindgen_ty_1>(), + 4usize, + concat!( + "Alignment of ", + stringify!(__pthread_cond_s__bindgen_ty_2__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__low) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(__pthread_cond_s), + stringify!(__pthread_cond_s__bindgen_ty_2__bindgen_ty_1), + "::", + stringify!(__low) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__high) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(__pthread_cond_s__bindgen_ty_2__bindgen_ty_1), + "::", + stringify!(__high) + ) + ); +} +#[test] +fn bindgen_test_layout___pthread_cond_s__bindgen_ty_2() { + const UNINIT: ::core::mem::MaybeUninit<__pthread_cond_s__bindgen_ty_2> = + ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::<__pthread_cond_s__bindgen_ty_2>(), + 8usize, + concat!("Size of: ", stringify!(__pthread_cond_s__bindgen_ty_2)) + ); + assert_eq!( + ::core::mem::align_of::<__pthread_cond_s__bindgen_ty_2>(), + 8usize, + concat!("Alignment of ", stringify!(__pthread_cond_s__bindgen_ty_2)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__g1_start) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__pthread_cond_s__bindgen_ty_2), "::", stringify!(__g1_start) ) ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__g1_start32) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__pthread_cond_s__bindgen_ty_2), + "::", + stringify!(__g1_start32) + ) + ); +} +#[test] +fn bindgen_test_layout___pthread_cond_s() { + const UNINIT: ::core::mem::MaybeUninit<__pthread_cond_s> = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::<__pthread_cond_s>(), + 48usize, + concat!("Size of: ", stringify!(__pthread_cond_s)) + ); + assert_eq!( + ::core::mem::align_of::<__pthread_cond_s>(), + 8usize, + concat!("Alignment of ", stringify!(__pthread_cond_s)) + ); assert_eq!( unsafe { ::core::ptr::addr_of!((*ptr).__g_refs) as usize - ptr as usize }, 16usize, @@ -4036,38 +4109,6 @@ fn bindgen_test_layout___pthread_cond_s() { ) ); } -pub type __tss_t = libc::c_uint; -pub type __thrd_t = libc::c_ulong; -#[repr(C)] -#[derive(Copy, Clone)] -pub struct __once_flag { - pub __data: libc::c_int, -} -#[test] -fn bindgen_test_layout___once_flag() { - const UNINIT: ::core::mem::MaybeUninit<__once_flag> = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::<__once_flag>(), - 4usize, - concat!("Size of: ", stringify!(__once_flag)) - ); - assert_eq!( - ::core::mem::align_of::<__once_flag>(), - 4usize, - concat!("Alignment of ", stringify!(__once_flag)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).__data) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(__once_flag), - "::", - stringify!(__data) - ) - ); -} pub type pthread_t = libc::c_ulong; #[repr(C)] #[derive(Copy, Clone)] @@ -4755,15 +4796,6 @@ extern "C" { extern "C" { pub fn lcong48_r(__param: *mut libc::c_ushort, __buffer: *mut drand48_data) -> libc::c_int; } -extern "C" { - pub fn arc4random() -> __uint32_t; -} -extern "C" { - pub fn arc4random_buf(__buf: *mut libc::c_void, __size: usize); -} -extern "C" { - pub fn arc4random_uniform(__upper_bound: __uint32_t) -> __uint32_t; -} extern "C" { pub fn malloc(__size: libc::c_ulong) -> *mut libc::c_void; } @@ -4773,9 +4805,6 @@ extern "C" { extern "C" { pub fn realloc(__ptr: *mut libc::c_void, __size: libc::c_ulong) -> *mut libc::c_void; } -extern "C" { - pub fn free(__ptr: *mut libc::c_void); -} extern "C" { pub fn reallocarray( __ptr: *mut libc::c_void, @@ -4783,6 +4812,9 @@ extern "C" { __size: usize, ) -> *mut libc::c_void; } +extern "C" { + pub fn free(__ptr: *mut libc::c_void); +} extern "C" { pub fn alloca(__size: libc::c_ulong) -> *mut libc::c_void; } @@ -4797,7 +4829,7 @@ extern "C" { ) -> libc::c_int; } extern "C" { - pub fn aligned_alloc(__alignment: libc::c_ulong, __size: libc::c_ulong) -> *mut libc::c_void; + pub fn aligned_alloc(__alignment: usize, __size: usize) -> *mut libc::c_void; } extern "C" { pub fn abort() -> !; @@ -5030,11 +5062,6 @@ pub type __v2du = [libc::c_ulonglong; 2usize]; pub type __v8hu = [libc::c_ushort; 8usize]; pub type __v16qu = [libc::c_uchar; 16usize]; pub type __v16qs = [libc::c_schar; 16usize]; -pub type __v8hf = [__BindgenFloat16; 8usize]; -pub type __m128h = [__BindgenFloat16; 8usize]; -pub type __m128h_u = [__BindgenFloat16; 8usize]; -pub type __v8bf = u128; -pub type __m128bh = u128; extern "C" { pub fn _mm_clflush(__p: *const libc::c_void); } @@ -7903,30 +7930,63 @@ pub enum SDL_KeyCode { SDLK_ENDCALL = 1073742114, } impl SDL_Keymod { - pub const KMOD_RESERVED: SDL_Keymod = SDL_Keymod::KMOD_SCROLL; + pub const KMOD_NONE: SDL_Keymod = SDL_Keymod(0); } -#[repr(u32)] +impl SDL_Keymod { + pub const KMOD_LSHIFT: SDL_Keymod = SDL_Keymod(1); +} +impl SDL_Keymod { + pub const KMOD_RSHIFT: SDL_Keymod = SDL_Keymod(2); +} +impl SDL_Keymod { + pub const KMOD_LCTRL: SDL_Keymod = SDL_Keymod(64); +} +impl SDL_Keymod { + pub const KMOD_RCTRL: SDL_Keymod = SDL_Keymod(128); +} +impl SDL_Keymod { + pub const KMOD_LALT: SDL_Keymod = SDL_Keymod(256); +} +impl SDL_Keymod { + pub const KMOD_RALT: SDL_Keymod = SDL_Keymod(512); +} +impl SDL_Keymod { + pub const KMOD_LGUI: SDL_Keymod = SDL_Keymod(1024); +} +impl SDL_Keymod { + pub const KMOD_RGUI: SDL_Keymod = SDL_Keymod(2048); +} +impl SDL_Keymod { + pub const KMOD_NUM: SDL_Keymod = SDL_Keymod(4096); +} +impl SDL_Keymod { + pub const KMOD_CAPS: SDL_Keymod = SDL_Keymod(8192); +} +impl SDL_Keymod { + pub const KMOD_MODE: SDL_Keymod = SDL_Keymod(16384); +} +impl SDL_Keymod { + pub const KMOD_SCROLL: SDL_Keymod = SDL_Keymod(32768); +} +impl SDL_Keymod { + pub const KMOD_CTRL: SDL_Keymod = SDL_Keymod(192); +} +impl SDL_Keymod { + pub const KMOD_SHIFT: SDL_Keymod = SDL_Keymod(3); +} +impl SDL_Keymod { + pub const KMOD_ALT: SDL_Keymod = SDL_Keymod(768); +} +impl SDL_Keymod { + pub const KMOD_GUI: SDL_Keymod = SDL_Keymod(3072); +} +impl SDL_Keymod { + pub const KMOD_RESERVED: SDL_Keymod = SDL_Keymod(32768); +} +#[repr(transparent)] #[doc = " \\brief Enumeration of valid key mods (possibly OR'd together)."] #[derive(Copy, Clone, Hash, PartialEq, Eq)] -pub enum SDL_Keymod { - KMOD_NONE = 0, - KMOD_LSHIFT = 1, - KMOD_RSHIFT = 2, - KMOD_LCTRL = 64, - KMOD_RCTRL = 128, - KMOD_LALT = 256, - KMOD_RALT = 512, - KMOD_LGUI = 1024, - KMOD_RGUI = 2048, - KMOD_NUM = 4096, - KMOD_CAPS = 8192, - KMOD_MODE = 16384, - KMOD_SCROLL = 32768, - KMOD_CTRL = 192, - KMOD_SHIFT = 3, - KMOD_ALT = 768, - KMOD_GUI = 3072, -} +pub struct SDL_Keymod(pub libc::c_uint); #[doc = " \\brief The SDL keysym structure, used in key events.\n\n \\note If you are looking for translated character input, see the ::SDL_TEXTINPUT event."] #[repr(C)] #[derive(Copy, Clone)] @@ -15484,17 +15544,48 @@ pub enum SDL_TextureModulate { #[doc = "< srcA = srcA * alpha"] SDL_TEXTUREMODULATE_ALPHA = 2, } -#[repr(u32)] -#[doc = " Flip constants for SDL_RenderCopyEx"] -#[derive(Copy, Clone, Hash, PartialEq, Eq)] -pub enum SDL_RendererFlip { +impl SDL_RendererFlip { #[doc = "< Do not flip"] - SDL_FLIP_NONE = 0, + pub const SDL_FLIP_NONE: SDL_RendererFlip = SDL_RendererFlip(0); +} +impl SDL_RendererFlip { #[doc = "< flip horizontally"] - SDL_FLIP_HORIZONTAL = 1, + pub const SDL_FLIP_HORIZONTAL: SDL_RendererFlip = SDL_RendererFlip(1); +} +impl SDL_RendererFlip { #[doc = "< flip vertically"] - SDL_FLIP_VERTICAL = 2, + pub const SDL_FLIP_VERTICAL: SDL_RendererFlip = SDL_RendererFlip(2); +} +impl ::core::ops::BitOr for SDL_RendererFlip { + type Output = Self; + #[inline] + fn bitor(self, other: Self) -> Self { + SDL_RendererFlip(self.0 | other.0) + } +} +impl ::core::ops::BitOrAssign for SDL_RendererFlip { + #[inline] + fn bitor_assign(&mut self, rhs: SDL_RendererFlip) { + self.0 |= rhs.0; + } +} +impl ::core::ops::BitAnd for SDL_RendererFlip { + type Output = Self; + #[inline] + fn bitand(self, other: Self) -> Self { + SDL_RendererFlip(self.0 & other.0) + } +} +impl ::core::ops::BitAndAssign for SDL_RendererFlip { + #[inline] + fn bitand_assign(&mut self, rhs: SDL_RendererFlip) { + self.0 &= rhs.0; + } } +#[repr(transparent)] +#[doc = " Flip constants for SDL_RenderCopyEx"] +#[derive(Copy, Clone, Hash, PartialEq, Eq)] +pub struct SDL_RendererFlip(pub libc::c_uint); #[doc = " A structure representing rendering state"] #[repr(C)] #[derive(Copy, Clone)] @@ -25969,9 +26060,6 @@ extern "C" { extern "C" { pub fn XInitThreads() -> libc::c_int; } -extern "C" { - pub fn XFreeThreads() -> libc::c_int; -} extern "C" { pub fn XLockDisplay(arg1: *mut Display); } @@ -26070,15 +26158,6 @@ pub type XIOErrorHandler = extern "C" { pub fn XSetIOErrorHandler(arg1: XIOErrorHandler) -> XIOErrorHandler; } -pub type XIOErrorExitHandler = - ::core::option::Option; -extern "C" { - pub fn XSetIOErrorExitHandler( - arg1: *mut Display, - arg2: XIOErrorExitHandler, - arg3: *mut libc::c_void, - ); -} extern "C" { pub fn XListPixmapFormats( arg1: *mut Display, diff --git a/src/sdl2/keyboard/mod.rs b/src/sdl2/keyboard/mod.rs index b276373daa..ea1a721493 100644 --- a/src/sdl2/keyboard/mod.rs +++ b/src/sdl2/keyboard/mod.rs @@ -7,7 +7,6 @@ use crate::EventPump; use std::fmt; use std::iter::FilterMap; -use std::mem::transmute; use crate::sys; @@ -18,19 +17,19 @@ pub use self::scancode::Scancode; bitflags! { pub struct Mod: u16 { - const NOMOD = 0x0000; - const LSHIFTMOD = 0x0001; - const RSHIFTMOD = 0x0002; - const LCTRLMOD = 0x0040; - const RCTRLMOD = 0x0080; - const LALTMOD = 0x0100; - const RALTMOD = 0x0200; - const LGUIMOD = 0x0400; - const RGUIMOD = 0x0800; - const NUMMOD = 0x1000; - const CAPSMOD = 0x2000; - const MODEMOD = 0x4000; - const RESERVEDMOD = 0x8000; + const NOMOD = crate::sys::SDL_Keymod::KMOD_NONE.0 as u16; + const LSHIFTMOD = crate::sys::SDL_Keymod::KMOD_LSHIFT.0 as u16; + const RSHIFTMOD = crate::sys::SDL_Keymod::KMOD_RSHIFT.0 as u16; + const LCTRLMOD = crate::sys::SDL_Keymod::KMOD_LCTRL.0 as u16; + const RCTRLMOD = crate::sys::SDL_Keymod::KMOD_RCTRL.0 as u16; + const LALTMOD = crate::sys::SDL_Keymod::KMOD_LALT.0 as u16; + const RALTMOD = crate::sys::SDL_Keymod::KMOD_RALT.0 as u16; + const LGUIMOD = crate::sys::SDL_Keymod::KMOD_LGUI.0 as u16; + const RGUIMOD = crate::sys::SDL_Keymod::KMOD_RGUI.0 as u16; + const NUMMOD = crate::sys::SDL_Keymod::KMOD_NUM.0 as u16; + const CAPSMOD = crate::sys::SDL_Keymod::KMOD_CAPS.0 as u16; + const MODEMOD = crate::sys::SDL_Keymod::KMOD_MODE.0 as u16; + const RESERVEDMOD = crate::sys::SDL_Keymod::KMOD_RESERVED.0 as u16; } } @@ -186,13 +185,14 @@ impl KeyboardUtil { #[doc(alias = "SDL_GetModState")] pub fn mod_state(&self) -> Mod { - unsafe { Mod::from_bits(sys::SDL_GetModState() as u16).unwrap() } + unsafe { Mod::from_bits(sys::SDL_GetModState().0 as u16).unwrap() } } #[doc(alias = "SDL_SetModState")] pub fn set_mod_state(&self, flags: Mod) { + let arg = sys::SDL_Keymod(flags.bits() as u32); unsafe { - sys::SDL_SetModState(transmute::(flags.bits() as u32)); + sys::SDL_SetModState(arg); } } } diff --git a/src/sdl2/render.rs b/src/sdl2/render.rs index 6d48ff3941..0df4acd9bd 100644 --- a/src/sdl2/render.rs +++ b/src/sdl2/render.rs @@ -1637,16 +1637,13 @@ impl Canvas { R2: Into>, P: Into>, { - use crate::sys::SDL_RendererFlip::*; - let flip = unsafe { - match (flip_horizontal, flip_vertical) { - (false, false) => SDL_FLIP_NONE, - (true, false) => SDL_FLIP_HORIZONTAL, - (false, true) => SDL_FLIP_VERTICAL, - (true, true) => transmute::( - transmute::(SDL_FLIP_HORIZONTAL) - | transmute::(SDL_FLIP_VERTICAL), - ), + let flip = match (flip_horizontal, flip_vertical) { + (false, false) => crate::sys::SDL_RendererFlip::SDL_FLIP_NONE, + (true, false) => crate::sys::SDL_RendererFlip::SDL_FLIP_HORIZONTAL, + (false, true) => crate::sys::SDL_RendererFlip::SDL_FLIP_VERTICAL, + (true, true) => { + crate::sys::SDL_RendererFlip::SDL_FLIP_HORIZONTAL + | crate::sys::SDL_RendererFlip::SDL_FLIP_VERTICAL } }; @@ -1743,16 +1740,13 @@ impl Canvas { R2: Into>, P: Into>, { - use crate::sys::SDL_RendererFlip::*; - let flip = unsafe { - match (flip_horizontal, flip_vertical) { - (false, false) => SDL_FLIP_NONE, - (true, false) => SDL_FLIP_HORIZONTAL, - (false, true) => SDL_FLIP_VERTICAL, - (true, true) => transmute::( - transmute::(SDL_FLIP_HORIZONTAL) - | transmute::(SDL_FLIP_VERTICAL), - ), + let flip = match (flip_horizontal, flip_vertical) { + (false, false) => crate::sys::SDL_RendererFlip::SDL_FLIP_NONE, + (true, false) => crate::sys::SDL_RendererFlip::SDL_FLIP_HORIZONTAL, + (false, true) => crate::sys::SDL_RendererFlip::SDL_FLIP_VERTICAL, + (true, true) => { + crate::sys::SDL_RendererFlip::SDL_FLIP_HORIZONTAL + | crate::sys::SDL_RendererFlip::SDL_FLIP_VERTICAL } };