src/msg/header.rs
#[macro_export]
macro_rules! wiredef_header_map {
($hsize:ty ; $($rest:tt)*) => {
wiredef_header_map!(@acc $hsize ; 0 ; $($rest)*);
};
(@acc $hsize:ty ; $acc:expr ;) => {
pub const BASE: $hsize = $acc;
};
(@acc $hsize:ty ; $acc:expr ; $field:ident : $bit:literal = $val:literal | $($rest:tt)*) => {
pub const $field: ($hsize, $hsize) = (1 << $bit, $val);
wiredef_header_map!(@acc $hsize ; $acc | ($val << $bit) ; $($rest)*);
};
(@acc $hsize:ty ; $acc:expr ; $field:ident : $bit:literal = $val:literal) => {
pub const $field: ($hsize, $hsize) = (1 << $bit, $val);
pub const BASE: $hsize = $acc | ($val << $bit);
};
(@acc $hsize:ty ; $acc:expr ; $field:ident : $bit:literal | $($rest:tt)*) => {
pub const $field: $hsize = 1 << $bit;
wiredef_header_map!(@acc $hsize ; $acc ; $($rest)*);
};
(@acc $hsize:ty ; $acc:expr ; $field:ident : $bit:literal) => {
pub const $field: $hsize = 1 << $bit;
pub const BASE: $hsize = $acc;
};
(@acc $hsize:ty ; $acc:expr ; $field:ident : $high:literal .. $low:literal = $val:literal | $($rest:tt)*) => {
pub const $field: ($hsize, $hsize) = (((1 << ($high - $low + 1)) - 1) << $low, $val);
wiredef_header_map!(@acc $hsize ; $acc | ($val << $low) ; $($rest)*);
};
(@acc $hsize:ty ; $acc:expr ; $field:ident : $high:literal .. $low:literal = $val:literal) => {
pub const $field: ($hsize, $hsize) = (((1 << ($high - $low + 1)) - 1) << $low, $val);
pub const BASE: $hsize = $acc | ($val << $low);
};
}
#[macro_export]
macro_rules! wiredef_header_write {
($hsize:ty ; $self:ident, $buf:ident, $header: ident, $field:ident, $ty:ty, []) => {};
($hsize:ty ; $self:ident, $buf:ident, $header: ident, $field:ident, $ty:ty, [size=prefixed]) => {};
}