Browse Source

Use opaque-type for types defined in ctru-sys

pull/18/head
Ian Chamberlain 3 years ago
parent
commit
9f67a92a42
No known key found for this signature in database
GPG Key ID: AE5484D09405AA60
  1. 13
      bindgen.sh
  2. 55
      src/bindings.rs

13
bindgen.sh

@ -12,7 +12,6 @@ fi
set -euxo pipefail set -euxo pipefail
bindgen "$DEVKITPRO/libctru/include/citro3d.h" \ bindgen "$DEVKITPRO/libctru/include/citro3d.h" \
--verbose \
--rust-target nightly \ --rust-target nightly \
--use-core \ --use-core \
--distrust-clang-mangling \ --distrust-clang-mangling \
@ -25,12 +24,12 @@ bindgen "$DEVKITPRO/libctru/include/citro3d.h" \
--blocklist-type "u(8|16|32|64)" \ --blocklist-type "u(8|16|32|64)" \
--blocklist-type "__builtin_va_list" \ --blocklist-type "__builtin_va_list" \
--blocklist-type "__va_list" \ --blocklist-type "__va_list" \
--blocklist-type "GPU_.*" \ --opaque-type "GPU_.*" \
--blocklist-type "GFX_.*" \ --opaque-type "GFX_.*" \
--blocklist-type "gfx.*_t" \ --opaque-type "gfx.*_t" \
--blocklist-type "DVL.*" \ --opaque-type "DVL.*" \
--blocklist-type "shader.*" \ --opaque-type "shader.*" \
--blocklist-type "float24Uniform_s" \ --opaque-type "float24Uniform_s" \
--allowlist-type "C3D_.*" \ --allowlist-type "C3D_.*" \
--allowlist-function "C3D_.*" \ --allowlist-function "C3D_.*" \
--allowlist-var "C3D_.*" \ --allowlist-var "C3D_.*" \

55
src/bindings.rs

@ -82,49 +82,6 @@ where
} }
} }
} }
#[repr(C)]
pub struct __BindgenUnionField<T>(::core::marker::PhantomData<T>);
impl<T> __BindgenUnionField<T> {
#[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<T> ::core::default::Default for __BindgenUnionField<T> {
#[inline]
fn default() -> Self {
Self::new()
}
}
impl<T> ::core::clone::Clone for __BindgenUnionField<T> {
#[inline]
fn clone(&self) -> Self {
Self::new()
}
}
impl<T> ::core::marker::Copy for __BindgenUnionField<T> {}
impl<T> ::core::fmt::Debug for __BindgenUnionField<T> {
fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
impl<T> ::core::hash::Hash for __BindgenUnionField<T> {
fn hash<H: ::core::hash::Hasher>(&self, _state: &mut H) {}
}
impl<T> ::core::cmp::PartialEq for __BindgenUnionField<T> {
fn eq(&self, _other: &__BindgenUnionField<T>) -> bool {
true
}
}
impl<T> ::core::cmp::Eq for __BindgenUnionField<T> {}
pub const C3D_AspectRatioTop: f64 = 1.6666666666666667; pub const C3D_AspectRatioTop: f64 = 1.6666666666666667;
pub const C3D_AspectRatioBot: f64 = 1.3333333333333333; pub const C3D_AspectRatioBot: f64 = 1.3333333333333333;
pub const C3D_MTXSTACK_SIZE: u32 = 8; pub const C3D_MTXSTACK_SIZE: u32 = 8;
@ -553,6 +510,7 @@ pub struct C3D_TexCube {
pub data: [*mut ::libc::c_void; 6usize], pub data: [*mut ::libc::c_void; 6usize],
} }
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone)]
pub struct C3D_Tex { pub struct C3D_Tex {
pub __bindgen_anon_1: C3D_Tex__bindgen_ty_1, pub __bindgen_anon_1: C3D_Tex__bindgen_ty_1,
pub _bitfield_align_1: [u32; 0], pub _bitfield_align_1: [u32; 0],
@ -632,6 +590,7 @@ impl C3D_Tex {
} }
#[repr(C)] #[repr(C)]
#[repr(align(8))] #[repr(align(8))]
#[derive(Copy, Clone)]
pub struct C3D_TexInitParams { pub struct C3D_TexInitParams {
pub width: u16_, pub width: u16_,
pub height: u16_, pub height: u16_,
@ -1341,6 +1300,7 @@ extern "C" {
pub fn C3D_GasLutBind(lut: *mut C3D_GasLut); pub fn C3D_GasLutBind(lut: *mut C3D_GasLut);
} }
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone)]
pub struct C3D_FrameBuf { pub struct C3D_FrameBuf {
pub colorBuf: *mut ::libc::c_void, pub colorBuf: *mut ::libc::c_void,
pub depthBuf: *mut ::libc::c_void, pub depthBuf: *mut ::libc::c_void,
@ -1432,6 +1392,7 @@ extern "C" {
} }
pub type C3D_RenderTarget = C3D_RenderTarget_tag; pub type C3D_RenderTarget = C3D_RenderTarget_tag;
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone)]
pub struct C3D_RenderTarget_tag { pub struct C3D_RenderTarget_tag {
pub next: *mut C3D_RenderTarget, pub next: *mut C3D_RenderTarget,
pub prev: *mut C3D_RenderTarget, pub prev: *mut C3D_RenderTarget,
@ -1481,10 +1442,10 @@ extern "C" {
pub fn C3D_GetProcessingTime() -> f32; pub fn C3D_GetProcessingTime() -> f32;
} }
#[repr(C)] #[repr(C)]
pub struct C3D_DEPTHTYPE { #[derive(Copy, Clone)]
pub __i: __BindgenUnionField<::libc::c_int>, pub union C3D_DEPTHTYPE {
pub __e: __BindgenUnionField<GPU_DEPTHBUF>, pub __i: ::libc::c_int,
pub bindgen_union_field: u32, pub __e: GPU_DEPTHBUF,
} }
extern "C" { extern "C" {
pub fn C3D_RenderTargetCreate( pub fn C3D_RenderTargetCreate(

Loading…
Cancel
Save