Skip to content

Commit

Permalink
rename _bindgen_ty to _u
Browse files Browse the repository at this point in the history
  • Loading branch information
FlannyH committed May 6, 2024
1 parent 2a0d7c7 commit 30c6a92
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 32 deletions.
19 changes: 19 additions & 0 deletions bindings_generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ fn main() {

bindgen::Builder::default()
.header(header.to_str().unwrap())
.parse_callbacks(Box::new(RenameCallback))
.clang_args(&[
format!("-I{}", include_dir.to_str().unwrap()).as_str(),
"-Wno-microsoft-enum-forward-reference",
Expand All @@ -31,3 +32,21 @@ fn main() {
.write_to_file(out_file)
.expect("Couldn't write bindings!");
}

use bindgen::callbacks::ParseCallbacks;

#[derive(Debug)]
struct RenameCallback;
impl ParseCallbacks for RenameCallback {
fn item_name(&self, item: &str) -> Option<String> {
match item {
v if item.contains("_bindgen_ty_1") => {
Some(v.replace("__bindgen_ty_1", "_u").to_string())
}
v if item.contains("_bindgen_ty_") => {
Some(v.replace("__bindgen_ty_", "_u_").to_string())
}
_ => None,
}
}
}
52 changes: 26 additions & 26 deletions src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,12 +584,12 @@ pub enum IRRootParameterType {
#[derive(Copy, Clone)]
pub struct IRRootParameter {
pub ParameterType: IRRootParameterType,
pub u_1: IRRootParameter__bindgen_ty_1,
pub u_1: IRRootParameter_u,
pub ShaderVisibility: IRShaderVisibility,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union IRRootParameter__bindgen_ty_1 {
pub union IRRootParameter_u {
pub DescriptorTable: IRRootDescriptorTable,
pub Constants: IRRootConstants,
pub Descriptor: IRRootDescriptor,
Expand Down Expand Up @@ -716,12 +716,12 @@ pub struct IRRootDescriptor1 {
#[derive(Copy, Clone)]
pub struct IRRootParameter1 {
pub ParameterType: IRRootParameterType,
pub u_1: IRRootParameter1__bindgen_ty_1,
pub u_1: IRRootParameter1_u,
pub ShaderVisibility: IRShaderVisibility,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union IRRootParameter1__bindgen_ty_1 {
pub union IRRootParameter1_u {
pub DescriptorTable: IRRootDescriptorTable1,
pub Constants: IRRootConstants,
pub Descriptor: IRRootDescriptor1,
Expand All @@ -739,11 +739,11 @@ pub struct IRRootSignatureDescriptor1 {
#[derive(Copy, Clone)]
pub struct IRVersionedRootSignatureDescriptor {
pub version: IRRootSignatureVersion,
pub u_1: IRVersionedRootSignatureDescriptor__bindgen_ty_1,
pub u_1: IRVersionedRootSignatureDescriptor_u,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union IRVersionedRootSignatureDescriptor__bindgen_ty_1 {
pub union IRVersionedRootSignatureDescriptor_u {
pub desc_1_0: IRRootSignatureDescriptor,
pub desc_1_1: IRRootSignatureDescriptor1,
}
Expand Down Expand Up @@ -773,11 +773,11 @@ pub enum IRInputLayoutDescriptorVersion {
#[derive(Copy, Clone)]
pub struct IRVersionedInputLayoutDescriptor {
pub version: IRInputLayoutDescriptorVersion,
pub u_1: IRVersionedInputLayoutDescriptor__bindgen_ty_1,
pub u_1: IRVersionedInputLayoutDescriptor_u,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union IRVersionedInputLayoutDescriptor__bindgen_ty_1 {
pub union IRVersionedInputLayoutDescriptor_u {
pub desc_1_0: IRInputLayoutDescriptor1,
}
#[repr(u32)]
Expand Down Expand Up @@ -970,11 +970,11 @@ pub struct IRCSInfo_1_0 {
#[derive(Copy, Clone)]
pub struct IRVersionedCSInfo {
pub version: IRReflectionVersion,
pub u_1: IRVersionedCSInfo__bindgen_ty_1,
pub u_1: IRVersionedCSInfo_u,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union IRVersionedCSInfo__bindgen_ty_1 {
pub union IRVersionedCSInfo_u {
pub info_1_0: IRCSInfo_1_0,
}
#[repr(C)]
Expand All @@ -997,11 +997,11 @@ pub struct IRVSInfo_1_0 {
#[derive(Copy, Clone)]
pub struct IRVersionedVSInfo {
pub version: IRReflectionVersion,
pub u_1: IRVersionedVSInfo__bindgen_ty_1,
pub u_1: IRVersionedVSInfo_u,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union IRVersionedVSInfo__bindgen_ty_1 {
pub union IRVersionedVSInfo_u {
pub info_1_0: IRVSInfo_1_0,
}
#[repr(C)]
Expand All @@ -1015,11 +1015,11 @@ pub struct IRFSInfo_1_0 {
#[derive(Copy, Clone)]
pub struct IRVersionedFSInfo {
pub version: IRReflectionVersion,
pub u_1: IRVersionedFSInfo__bindgen_ty_1,
pub u_1: IRVersionedFSInfo_u,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union IRVersionedFSInfo__bindgen_ty_1 {
pub union IRVersionedFSInfo_u {
pub info_1_0: IRFSInfo_1_0,
}
#[repr(C)]
Expand All @@ -1045,11 +1045,11 @@ pub struct IRGSInfo_1_0 {
#[derive(Copy, Clone)]
pub struct IRVersionedGSInfo {
pub version: IRReflectionVersion,
pub u_1: IRVersionedGSInfo__bindgen_ty_1,
pub u_1: IRVersionedGSInfo_u,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union IRVersionedGSInfo__bindgen_ty_1 {
pub union IRVersionedGSInfo_u {
pub info_1_0: IRGSInfo_1_0,
}
#[repr(C)]
Expand All @@ -1074,11 +1074,11 @@ pub struct IRHSInfo_1_0 {
#[derive(Copy, Clone)]
pub struct IRVersionedHSInfo {
pub version: IRReflectionVersion,
pub u_1: IRVersionedHSInfo__bindgen_ty_1,
pub u_1: IRVersionedHSInfo_u,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union IRVersionedHSInfo__bindgen_ty_1 {
pub union IRVersionedHSInfo_u {
pub info_1_0: IRHSInfo_1_0,
}
#[repr(C)]
Expand All @@ -1095,11 +1095,11 @@ pub struct IRDSInfo_1_0 {
#[derive(Copy, Clone)]
pub struct IRVersionedDSInfo {
pub version: IRReflectionVersion,
pub u_1: IRVersionedDSInfo__bindgen_ty_1,
pub u_1: IRVersionedDSInfo_u,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union IRVersionedDSInfo__bindgen_ty_1 {
pub union IRVersionedDSInfo_u {
pub info_1_0: IRDSInfo_1_0,
}
#[repr(u32)]
Expand All @@ -1123,11 +1123,11 @@ pub struct IRMSInfo_1_0 {
#[derive(Copy, Clone)]
pub struct IRVersionedMSInfo {
pub version: IRReflectionVersion,
pub u_1: IRVersionedMSInfo__bindgen_ty_1,
pub u_1: IRVersionedMSInfo_u,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union IRVersionedMSInfo__bindgen_ty_1 {
pub union IRVersionedMSInfo_u {
pub info_1_0: IRMSInfo_1_0,
}
#[repr(C)]
Expand All @@ -1140,11 +1140,11 @@ pub struct IRASInfo_1_0 {
#[derive(Copy, Clone)]
pub struct IRVersionedASInfo {
pub version: IRReflectionVersion,
pub u_1: IRVersionedASInfo__bindgen_ty_1,
pub u_1: IRVersionedASInfo_u,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union IRVersionedASInfo__bindgen_ty_1 {
pub union IRVersionedASInfo_u {
pub info_1_0: IRASInfo_1_0,
}
#[repr(C)]
Expand All @@ -1156,11 +1156,11 @@ pub struct IRRTInfo_1_0 {
#[derive(Copy, Clone)]
pub struct IRVersionedRTInfo {
pub version: IRReflectionVersion,
pub u_1: IRVersionedRTInfo__bindgen_ty_1,
pub u_1: IRVersionedRTInfo_u,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union IRVersionedRTInfo__bindgen_ty_1 {
pub union IRVersionedRTInfo_u {
pub info_1_0: IRRTInfo_1_0,
}
#[doc = " Represents a shader resource location from reflection data."]
Expand Down
11 changes: 5 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ mod bindings;
pub use bindings::{
IRCSInfo_1_0, IRComparisonFunction, IRDescriptorRangeType, IRFilter, IRHitGroupType,
IRObjectType, IRRaytracingPipelineFlags, IRReflectionVersion, IRResourceLocation,
IRResourceType, IRRootConstants, IRRootParameter1,
IRRootParameter1__bindgen_ty_1 as IRRootParameter1_u, IRRootParameterType,
IRRootSignatureDescriptor1, IRRootSignatureFlags, IRRootSignatureVersion, IRShaderStage,
IRShaderVisibility, IRStaticBorderColor, IRStaticSamplerDescriptor, IRTextureAddressMode,
IRVersionedCSInfo, IRVersionedRootSignatureDescriptor,
IRVersionedRootSignatureDescriptor__bindgen_ty_1 as IRVersionedRootSignatureDescriptor_u,
IRResourceType, IRRootConstants, IRRootParameter1, IRRootParameter1_u, IRRootParameterType,
IRRootParameter_u, IRRootSignatureDescriptor1, IRRootSignatureFlags, IRRootSignatureVersion,
IRShaderStage, IRShaderVisibility, IRStaticBorderColor, IRStaticSamplerDescriptor,
IRTextureAddressMode, IRVersionedCSInfo, IRVersionedRootSignatureDescriptor,
IRVersionedRootSignatureDescriptor_u,
};

pub struct IRShaderReflection {
Expand Down

0 comments on commit 30c6a92

Please sign in to comment.