From 9f67a92a422da7b631c1747130abfd0a9cadbb7c Mon Sep 17 00:00:00 2001 From: Ian Chamberlain Date: Sat, 29 Jan 2022 12:43:41 -0500 Subject: [PATCH] Use opaque-type for types defined in ctru-sys --- bindgen.sh | 13 ++++++------ src/bindings.rs | 55 +++++++------------------------------------------ 2 files changed, 14 insertions(+), 54 deletions(-) diff --git a/bindgen.sh b/bindgen.sh index 8969472..1ef716a 100755 --- a/bindgen.sh +++ b/bindgen.sh @@ -12,7 +12,6 @@ fi set -euxo pipefail bindgen "$DEVKITPRO/libctru/include/citro3d.h" \ - --verbose \ --rust-target nightly \ --use-core \ --distrust-clang-mangling \ @@ -25,12 +24,12 @@ bindgen "$DEVKITPRO/libctru/include/citro3d.h" \ --blocklist-type "u(8|16|32|64)" \ --blocklist-type "__builtin_va_list" \ --blocklist-type "__va_list" \ - --blocklist-type "GPU_.*" \ - --blocklist-type "GFX_.*" \ - --blocklist-type "gfx.*_t" \ - --blocklist-type "DVL.*" \ - --blocklist-type "shader.*" \ - --blocklist-type "float24Uniform_s" \ + --opaque-type "GPU_.*" \ + --opaque-type "GFX_.*" \ + --opaque-type "gfx.*_t" \ + --opaque-type "DVL.*" \ + --opaque-type "shader.*" \ + --opaque-type "float24Uniform_s" \ --allowlist-type "C3D_.*" \ --allowlist-function "C3D_.*" \ --allowlist-var "C3D_.*" \ diff --git a/src/bindings.rs b/src/bindings.rs index ac8ba3a..c332c5e 100644 --- a/src/bindings.rs +++ b/src/bindings.rs @@ -82,49 +82,6 @@ where } } } -#[repr(C)] -pub struct __BindgenUnionField(::core::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub const fn new() -> Self { - __BindgenUnionField(::core::marker::PhantomData) - } - #[inline] - pub unsafe fn as_ref(&self) -> &T { - ::core::mem::transmute(self) - } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { - ::core::mem::transmute(self) - } -} -impl ::core::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { - Self::new() - } -} -impl ::core::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { - Self::new() - } -} -impl ::core::marker::Copy for __BindgenUnionField {} -impl ::core::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::core::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) {} -} -impl ::core::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { - true - } -} -impl ::core::cmp::Eq for __BindgenUnionField {} pub const C3D_AspectRatioTop: f64 = 1.6666666666666667; pub const C3D_AspectRatioBot: f64 = 1.3333333333333333; pub const C3D_MTXSTACK_SIZE: u32 = 8; @@ -553,6 +510,7 @@ pub struct C3D_TexCube { pub data: [*mut ::libc::c_void; 6usize], } #[repr(C)] +#[derive(Copy, Clone)] pub struct C3D_Tex { pub __bindgen_anon_1: C3D_Tex__bindgen_ty_1, pub _bitfield_align_1: [u32; 0], @@ -632,6 +590,7 @@ impl C3D_Tex { } #[repr(C)] #[repr(align(8))] +#[derive(Copy, Clone)] pub struct C3D_TexInitParams { pub width: u16_, pub height: u16_, @@ -1341,6 +1300,7 @@ extern "C" { pub fn C3D_GasLutBind(lut: *mut C3D_GasLut); } #[repr(C)] +#[derive(Copy, Clone)] pub struct C3D_FrameBuf { pub colorBuf: *mut ::libc::c_void, pub depthBuf: *mut ::libc::c_void, @@ -1432,6 +1392,7 @@ extern "C" { } pub type C3D_RenderTarget = C3D_RenderTarget_tag; #[repr(C)] +#[derive(Copy, Clone)] pub struct C3D_RenderTarget_tag { pub next: *mut C3D_RenderTarget, pub prev: *mut C3D_RenderTarget, @@ -1481,10 +1442,10 @@ extern "C" { pub fn C3D_GetProcessingTime() -> f32; } #[repr(C)] -pub struct C3D_DEPTHTYPE { - pub __i: __BindgenUnionField<::libc::c_int>, - pub __e: __BindgenUnionField, - pub bindgen_union_field: u32, +#[derive(Copy, Clone)] +pub union C3D_DEPTHTYPE { + pub __i: ::libc::c_int, + pub __e: GPU_DEPTHBUF, } extern "C" { pub fn C3D_RenderTargetCreate(