Open mattiekat opened 2 years ago
#[repr(u8)] #[derive(Debug, Display, Copy, Clone, Eq, PartialEq)] pub enum RainwayChannelMode { Unreliable = 0, Reliable = 1, }
Take this perfectly innocuous looking enum in Rust. It generates this wonderfully correct C/C++ header definition via cbindgen:
enum RainwayChannelMode #ifdef __cplusplus : uint8_t #endif // __cplusplus { Unreliable = 0, Reliable = 1, }; #ifndef __cplusplus typedef uint8_t RainwayChannelMode; #endif // __cplusplus
But then node-clangffi seems to think it is a bit confusing because it ends up generating
export enum RainwayChannelMode { Unreliable = 0, Reliable = 1, } export type RainwayChannelMode = number; // ... export const RainwayChannelModeDef = ref.types.int; export const RainwayChannelModeDef = ref.types.uint8;
Basically we need the uint8_t typedef to override the size, but to only keep the enum definition.
uint8_t
Now that Bebop supports varying enum sizes this might be a bigger priority
Take this perfectly innocuous looking enum in Rust. It generates this wonderfully correct C/C++ header definition via cbindgen:
But then node-clangffi seems to think it is a bit confusing because it ends up generating
Basically we need the
uint8_t
typedef to override the size, but to only keep the enum definition.