Skip to content

Commit

Permalink
Find all the other userData and change those too
Browse files Browse the repository at this point in the history
  • Loading branch information
fu5ha committed Nov 8, 2023
1 parent 499fc09 commit 475ed90
Show file tree
Hide file tree
Showing 26 changed files with 713 additions and 470 deletions.
7 changes: 6 additions & 1 deletion physx-sys/pxbind/src/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,8 @@ pub enum Builtin {
// on the C++ side, `void*`, but we want to be able to pack arbitrary data into the space
// available so we treat it as a separate type so we can do that properly in the Rust side
UserData,
// same as above but `const void*
ConstUserData,
}

impl Builtin {
Expand Down Expand Up @@ -761,7 +763,8 @@ impl Builtin {
Self::Mat34V => "glam::Affine3A",
Self::Mat34 => "Affine",
Self::Mat44V | Self::Mat44 => "PxMat44",
Self::UserData => "UserDataField",
Self::UserData => "UserData",
Self::ConstUserData => "ConstUserData",
}
}

Expand Down Expand Up @@ -798,6 +801,7 @@ impl Builtin {
Self::Mat44V => "physx_Mat44V_Pod",
Self::Mat44 => "physx_PxMat44_Pod",
Self::UserData => "void*",
Self::ConstUserData => "const void*",
}
}

Expand Down Expand Up @@ -834,6 +838,7 @@ impl Builtin {
Self::Mat44V => "physx::PxMat44V",
Self::Mat44 => "physx::PxMat44",
Self::UserData => "void*",
Self::ConstUserData => "const void*",
}
}

Expand Down
13 changes: 8 additions & 5 deletions physx-sys/pxbind/src/consumer/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -714,11 +714,15 @@ impl<'ast> super::AstConsumer<'ast> {
}

let kind = if name == "userData" || name == "mUserData" {
QualType::Builtin(Builtin::UserData)
if kind.qual_type.contains("const") {
QualType::Builtin(Builtin::ConstUserData)
} else {
QualType::Builtin(Builtin::UserData)
}
} else {
self
.parse_type(kind, template_types)
.with_context(|| format!("failed to parse type for {rname}::{name}"))?
self.parse_type(kind, template_types).with_context(|| {
format!("failed to parse type for {rname}::{name}")
})?
};

// if matches!(&kind, QualType::FunctionPointer) {
Expand All @@ -727,7 +731,6 @@ impl<'ast> super::AstConsumer<'ast> {

let is_reference = matches!(kind, QualType::Reference { .. });


fields.push(FieldBinding {
name,
kind,
Expand Down
74 changes: 37 additions & 37 deletions physx-sys/pxbind/tests/snapshots/structgen__all_the_things-3.snap
Original file line number Diff line number Diff line change
Expand Up @@ -563,13 +563,13 @@ pub struct PxSimulationTetrahedronMeshData {
#[repr(C)]
pub struct PxActor {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct PxAggregate {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
Expand Down Expand Up @@ -894,31 +894,31 @@ pub struct PxArticulationTendonLimit {
#[repr(C)]
pub struct PxArticulationAttachment {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct PxArticulationTendonJoint {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct PxArticulationTendon {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct PxArticulationSpatialTendon {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct PxArticulationFixedTendon {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
Expand Down Expand Up @@ -971,31 +971,31 @@ pub struct PxArticulationCache {
#[repr(C)]
pub struct PxArticulationSensor {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct PxArticulationReducedCoordinate {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct PxArticulationJointReducedCoordinate {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct PxShape {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct PxRigidActor {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
Expand All @@ -1006,13 +1006,13 @@ pub struct PxNodeIndex {
#[repr(C)]
pub struct PxRigidBody {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct PxArticulationLink {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
Expand Down Expand Up @@ -1041,7 +1041,7 @@ pub struct PxConstraintShaderTable {
#[repr(C)]
pub struct PxConstraint {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
Expand Down Expand Up @@ -1150,13 +1150,13 @@ pub struct PxContactModifyPair {
#[repr(C)]
pub struct PxBaseMaterial {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct PxFEMMaterial {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
Expand All @@ -1176,7 +1176,7 @@ pub struct PxParticleRigidFilterPair {
#[repr(C)]
pub struct PxMaterial {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
Expand Down Expand Up @@ -1220,7 +1220,7 @@ pub struct PxParticleSpring {
#[repr(C)]
pub struct PxParticleMaterial {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
Expand Down Expand Up @@ -1349,13 +1349,13 @@ pub struct PxQueryFilterData {
#[repr(C)]
pub struct PxRigidDynamic {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct PxRigidStatic {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
Expand Down Expand Up @@ -1500,7 +1500,7 @@ pub struct PxSceneDesc {
pub flags: PxSceneFlags,
pub cpuDispatcher: *mut PxCpuDispatcher,
pub structgen_pad2: [u8; 8],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
pub solverBatchSize: u32,
pub solverArticulationBatchSize: u32,
pub nbContactDataBlocks: u32,
Expand Down Expand Up @@ -1604,7 +1604,7 @@ pub struct PxDominanceGroupPair {
#[repr(C)]
pub struct PxScene {
pub structgen_pad0: [u8; 8],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
Expand Down Expand Up @@ -1827,7 +1827,7 @@ pub struct PxControllerObstacleHit {
pub dir: PxVec3,
pub length: f32,
pub structgen_pad0: [u8; 4],
pub userData: *const std::ffi::c_void,
pub userData: ConstUserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
Expand Down Expand Up @@ -1861,7 +1861,7 @@ pub struct PxControllerDesc {
pub registerDeletionListener: bool,
pub clientID: u8,
pub structgen_pad3: [u8; 6],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
pub structgen_pad4: [u8; 8],
}
#[derive(Clone, Copy)]
Expand All @@ -1887,7 +1887,7 @@ pub struct PxBoxControllerDesc {
pub registerDeletionListener: bool,
pub clientID: u8,
pub structgen_pad3: [u8; 6],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
pub structgen_pad4: [u8; 4],
pub halfHeight: f32,
pub halfSideExtent: f32,
Expand Down Expand Up @@ -1916,7 +1916,7 @@ pub struct PxCapsuleControllerDesc {
pub registerDeletionListener: bool,
pub clientID: u8,
pub structgen_pad3: [u8; 6],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
pub structgen_pad4: [u8; 4],
pub radius: f32,
pub height: f32,
Expand Down Expand Up @@ -2046,7 +2046,7 @@ pub struct PxDefaultFileInputData {
#[repr(C)]
pub struct PxJoint {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
Expand All @@ -2058,7 +2058,7 @@ pub struct PxSpring {
#[repr(C)]
pub struct PxDistanceJoint {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
Expand All @@ -2072,13 +2072,13 @@ pub struct PxJacobianRow {
#[repr(C)]
pub struct PxContactJoint {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct PxFixedJoint {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
Expand Down Expand Up @@ -2149,19 +2149,19 @@ pub struct PxJointLimitPyramid {
#[repr(C)]
pub struct PxPrismaticJoint {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct PxRevoluteJoint {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct PxSphericalJoint {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
Expand All @@ -2175,19 +2175,19 @@ pub struct PxD6JointDrive {
#[repr(C)]
pub struct PxD6Joint {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct PxGearJoint {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct PxRackAndPinionJoint {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[derive(Clone, Copy)]
#[repr(C)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ pub struct PxGeometryHolder {
#[repr(C)]
pub struct PxShape {
pub structgen_pad0: [u8; 16],
pub userData: *mut std::ffi::c_void,
pub userData: UserData,
}
#[cfg(test)]
mod sizes {
Expand Down
Loading

0 comments on commit 475ed90

Please sign in to comment.