-
Notifications
You must be signed in to change notification settings - Fork 53
Open
Description
As discussed in #45, constants are currently generated like this:
#[allow(non_upper_case_globals)]
impl MyCustomMsg {
pub const MY_CONSTANT_ONE: _bindgen_ty_139 = my_custom_package__msg__MyCustomMsg__MY_CONSTANT_ONE;
}Instead of the actual type defined in the msg/idl file, we get a bindgen generated type. This is because constants are defined like this in the generated c header files:
enum
{
my_custom_package__msg__MyCustomMsg__MY_CONSTANT_ONE = 1
};If we knew the constant was a i8, we could generate the code like this instead:
#[allow(non_upper_case_globals)]
impl MyCustomMsg {
pub const MY_CONSTANT_ONE: i8 = my_custom_package__msg__MyCustomMsg__MY_CONSTANT_ONE as i8;
}But since we currently do not read the msg files, I am not sure how to get the actual type of the constant. It could be that we need to start reading the msg files, but that would lead to a large rewrite of the msg generation code. Maybe a fun project for the future...
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels