physx-rs icon indicating copy to clipboard operation
physx-rs copied to clipboard

Generate type-safe Rust enums from PhysX enums

Open h3r2tic opened this issue 5 years ago • 1 comments

The code generator for physx-sys currently generates this peculiar construct for C++ enums:

pub mod PxMeshMidPhase{
    pub type Enum = u32;
    pub const eBVH33: Enum = 0u64 as u32;
    pub const eBVH34: Enum = 1u64 as u32;
    pub const eLAST: Enum = 2u64 as u32;
}

This is to match the C++ closely in terms of usage, and allow binary ops on flags.

While workable, the solution doesn't provide type safety, and makes it unwieldy to match on. We should investigate using more proper Rust enums an type-safe flags.

h3r2tic avatar Apr 03 '19 14:04 h3r2tic

@h3r2tic I looked through my browser history and I think it was this crate I was referring to earlier: https://docs.rs/enumflags2/0.5.1/enumflags2/.

tgolsson avatar Apr 03 '19 19:04 tgolsson

Oops, this was fixed in #183

Jake-Shadle avatar Apr 19 '23 07:04 Jake-Shadle