hack to allow paths in type names
parent
90f5d88c20
commit
fb0ecffd74
|
@ -68,16 +68,16 @@ macro_rules! rd_impl {
|
||||||
let $nam = usize_from_u32($nam);
|
let $nam = usize_from_u32($nam);
|
||||||
};
|
};
|
||||||
($e:ident, $b:expr, $at:expr, $n:expr;
|
($e:ident, $b:expr, $at:expr, $n:expr;
|
||||||
$nam:ident, enum, $et:ident, $t:ident
|
$nam:ident, enum, $et:ident$(::$etc:ident)*, $t:ident
|
||||||
) => {
|
) => {
|
||||||
$crate::rd_impl!($e, $b, $at, $n; $nam, $t);
|
$crate::rd_impl!($e, $b, $at, $n; $nam, $t);
|
||||||
let $nam = $et::try_from($nam)?;
|
let $nam = $et$(::$etc)*::try_from($nam)?;
|
||||||
};
|
};
|
||||||
($e:ident, $b:expr, $at:expr, $n:expr;
|
($e:ident, $b:expr, $at:expr, $n:expr;
|
||||||
$nam:ident, flag, $ft:ident, $t:ident
|
$nam:ident, flag, $ft:ident$(::$ftc:ident)*, $t:ident
|
||||||
) => {
|
) => {
|
||||||
$crate::rd_impl!($e, $b, $at, $n; $nam, $t);
|
$crate::rd_impl!($e, $b, $at, $n; $nam, $t);
|
||||||
let $nam = flag_ok!($ft, $nam)?;
|
let $nam = flag_ok!($ft$(::$ftc)*, $nam)?;
|
||||||
};
|
};
|
||||||
|
|
||||||
// no endianness
|
// no endianness
|
||||||
|
@ -186,12 +186,12 @@ macro_rules! read_data {
|
||||||
(
|
(
|
||||||
endian: $e:ident, buf: $b:expr, size: $sz:expr, start: $at:expr, data {
|
endian: $e:ident, buf: $b:expr, size: $sz:expr, start: $at:expr, data {
|
||||||
$(let $nam:ident = $t:ident$(::$tc:ident)*[$n:expr $(; $rn:expr)?]
|
$(let $nam:ident = $t:ident$(::$tc:ident)*[$n:expr $(; $rn:expr)?]
|
||||||
$($ex:ident)*;)*
|
$($ex:ident$(::$exc:ident)*)*;)*
|
||||||
}
|
}
|
||||||
) => {
|
) => {
|
||||||
$crate::check_data!($at + $sz, $b);
|
$crate::check_data!($at + $sz, $b);
|
||||||
$($crate::rd_impl!($e, $b, $at, $n;
|
$($crate::rd_impl!($e, $b, $at, $n;
|
||||||
$($rn;)? $nam, $($ex,)* $t$(::$tc)*);)*
|
$($rn;)? $nam, $($ex$(::$exc)*,)* $t$(::$tc)*);)*
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@ macro_rules! ok {
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! flag_ok {
|
macro_rules! flag_ok {
|
||||||
($t:ident, $v:expr) => {
|
($t:ident$(::$tc:ident)*, $v:expr) => {
|
||||||
match $t::from_bits($v) {
|
match $t$(::$tc)*::from_bits($v) {
|
||||||
Some(v) => Ok(v),
|
Some(v) => Ok(v),
|
||||||
None => Err(err_msg(concat!("bad ", stringify!($t)))),
|
None => Err(err_msg(concat!("bad ", stringify!($t)))),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue