mirror of
https://gitee.com/openharmony/third_party_rust_nom
synced 2024-11-27 09:40:54 +00:00
support native endianness in number parsers
This commit is contained in:
parent
b52d460276
commit
1baaa7c6de
@ -755,6 +755,10 @@ where
|
||||
match endian {
|
||||
crate::number::Endianness::Big => be_u16,
|
||||
crate::number::Endianness::Little => le_u16,
|
||||
#[cfg(target_endian = "big")]
|
||||
crate::number::Endianness::Native => be_u16,
|
||||
#[cfg(target_endian = "little")]
|
||||
crate::number::Endianness::Native => le_u16,
|
||||
}
|
||||
}
|
||||
|
||||
@ -790,6 +794,10 @@ where
|
||||
match endian {
|
||||
crate::number::Endianness::Big => be_u24,
|
||||
crate::number::Endianness::Little => le_u24,
|
||||
#[cfg(target_endian = "big")]
|
||||
crate::number::Endianness::Native => be_u24,
|
||||
#[cfg(target_endian = "little")]
|
||||
crate::number::Endianness::Native => le_u24,
|
||||
}
|
||||
}
|
||||
|
||||
@ -825,6 +833,10 @@ where
|
||||
match endian {
|
||||
crate::number::Endianness::Big => be_u32,
|
||||
crate::number::Endianness::Little => le_u32,
|
||||
#[cfg(target_endian = "big")]
|
||||
crate::number::Endianness::Native => be_u32,
|
||||
#[cfg(target_endian = "little")]
|
||||
crate::number::Endianness::Native => le_u32,
|
||||
}
|
||||
}
|
||||
|
||||
@ -860,6 +872,10 @@ where
|
||||
match endian {
|
||||
crate::number::Endianness::Big => be_u64,
|
||||
crate::number::Endianness::Little => le_u64,
|
||||
#[cfg(target_endian = "big")]
|
||||
crate::number::Endianness::Native => be_u64,
|
||||
#[cfg(target_endian = "little")]
|
||||
crate::number::Endianness::Native => le_u64,
|
||||
}
|
||||
}
|
||||
|
||||
@ -896,6 +912,10 @@ where
|
||||
match endian {
|
||||
crate::number::Endianness::Big => be_u128,
|
||||
crate::number::Endianness::Little => le_u128,
|
||||
#[cfg(target_endian = "big")]
|
||||
crate::number::Endianness::Native => be_u128,
|
||||
#[cfg(target_endian = "little")]
|
||||
crate::number::Endianness::Native => le_u128,
|
||||
}
|
||||
}
|
||||
|
||||
@ -955,6 +975,10 @@ where
|
||||
match endian {
|
||||
crate::number::Endianness::Big => be_i16,
|
||||
crate::number::Endianness::Little => le_i16,
|
||||
#[cfg(target_endian = "big")]
|
||||
crate::number::Endianness::Native => be_i16,
|
||||
#[cfg(target_endian = "little")]
|
||||
crate::number::Endianness::Native => le_i16,
|
||||
}
|
||||
}
|
||||
|
||||
@ -990,6 +1014,10 @@ where
|
||||
match endian {
|
||||
crate::number::Endianness::Big => be_i24,
|
||||
crate::number::Endianness::Little => le_i24,
|
||||
#[cfg(target_endian = "big")]
|
||||
crate::number::Endianness::Native => be_i24,
|
||||
#[cfg(target_endian = "little")]
|
||||
crate::number::Endianness::Native => le_i24,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1025,6 +1053,10 @@ where
|
||||
match endian {
|
||||
crate::number::Endianness::Big => be_i32,
|
||||
crate::number::Endianness::Little => le_i32,
|
||||
#[cfg(target_endian = "big")]
|
||||
crate::number::Endianness::Native => be_i32,
|
||||
#[cfg(target_endian = "little")]
|
||||
crate::number::Endianness::Native => le_i32,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1060,6 +1092,10 @@ where
|
||||
match endian {
|
||||
crate::number::Endianness::Big => be_i64,
|
||||
crate::number::Endianness::Little => le_i64,
|
||||
#[cfg(target_endian = "big")]
|
||||
crate::number::Endianness::Native => be_i64,
|
||||
#[cfg(target_endian = "little")]
|
||||
crate::number::Endianness::Native => le_i64,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1096,6 +1132,10 @@ where
|
||||
match endian {
|
||||
crate::number::Endianness::Big => be_i128,
|
||||
crate::number::Endianness::Little => le_i128,
|
||||
#[cfg(target_endian = "big")]
|
||||
crate::number::Endianness::Native => be_i128,
|
||||
#[cfg(target_endian = "little")]
|
||||
crate::number::Endianness::Native => le_i128,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1235,6 +1275,10 @@ where
|
||||
match endian {
|
||||
crate::number::Endianness::Big => be_f32,
|
||||
crate::number::Endianness::Little => le_f32,
|
||||
#[cfg(target_endian = "big")]
|
||||
crate::number::Endianness::Native => be_f32,
|
||||
#[cfg(target_endian = "little")]
|
||||
crate::number::Endianness::Native => le_f32,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1270,6 +1314,10 @@ where
|
||||
match endian {
|
||||
crate::number::Endianness::Big => be_f64,
|
||||
crate::number::Endianness::Little => le_f64,
|
||||
#[cfg(target_endian = "big")]
|
||||
crate::number::Endianness::Native => be_f64,
|
||||
#[cfg(target_endian = "little")]
|
||||
crate::number::Endianness::Native => le_f64,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,4 +13,6 @@ pub enum Endianness {
|
||||
Big,
|
||||
/// Little endian
|
||||
Little,
|
||||
/// Will match the host's endianness
|
||||
Native,
|
||||
}
|
||||
|
@ -729,6 +729,10 @@ where
|
||||
match endian {
|
||||
crate::number::Endianness::Big => be_u16,
|
||||
crate::number::Endianness::Little => le_u16,
|
||||
#[cfg(target_endian = "big")]
|
||||
crate::number::Endianness::Native => be_u16,
|
||||
#[cfg(target_endian = "little")]
|
||||
crate::number::Endianness::Native => le_u16,
|
||||
}
|
||||
}
|
||||
|
||||
@ -764,6 +768,10 @@ where
|
||||
match endian {
|
||||
crate::number::Endianness::Big => be_u24,
|
||||
crate::number::Endianness::Little => le_u24,
|
||||
#[cfg(target_endian = "big")]
|
||||
crate::number::Endianness::Native => be_u24,
|
||||
#[cfg(target_endian = "little")]
|
||||
crate::number::Endianness::Native => le_u24,
|
||||
}
|
||||
}
|
||||
|
||||
@ -799,6 +807,10 @@ where
|
||||
match endian {
|
||||
crate::number::Endianness::Big => be_u32,
|
||||
crate::number::Endianness::Little => le_u32,
|
||||
#[cfg(target_endian = "big")]
|
||||
crate::number::Endianness::Native => be_u32,
|
||||
#[cfg(target_endian = "little")]
|
||||
crate::number::Endianness::Native => le_u32,
|
||||
}
|
||||
}
|
||||
|
||||
@ -834,6 +846,10 @@ where
|
||||
match endian {
|
||||
crate::number::Endianness::Big => be_u64,
|
||||
crate::number::Endianness::Little => le_u64,
|
||||
#[cfg(target_endian = "big")]
|
||||
crate::number::Endianness::Native => be_u64,
|
||||
#[cfg(target_endian = "little")]
|
||||
crate::number::Endianness::Native => le_u64,
|
||||
}
|
||||
}
|
||||
|
||||
@ -870,6 +886,10 @@ where
|
||||
match endian {
|
||||
crate::number::Endianness::Big => be_u128,
|
||||
crate::number::Endianness::Little => le_u128,
|
||||
#[cfg(target_endian = "big")]
|
||||
crate::number::Endianness::Native => be_u128,
|
||||
#[cfg(target_endian = "little")]
|
||||
crate::number::Endianness::Native => le_u128,
|
||||
}
|
||||
}
|
||||
|
||||
@ -929,6 +949,10 @@ where
|
||||
match endian {
|
||||
crate::number::Endianness::Big => be_i16,
|
||||
crate::number::Endianness::Little => le_i16,
|
||||
#[cfg(target_endian = "big")]
|
||||
crate::number::Endianness::Native => be_i16,
|
||||
#[cfg(target_endian = "little")]
|
||||
crate::number::Endianness::Native => le_i16,
|
||||
}
|
||||
}
|
||||
|
||||
@ -964,6 +988,10 @@ where
|
||||
match endian {
|
||||
crate::number::Endianness::Big => be_i24,
|
||||
crate::number::Endianness::Little => le_i24,
|
||||
#[cfg(target_endian = "big")]
|
||||
crate::number::Endianness::Native => be_i24,
|
||||
#[cfg(target_endian = "little")]
|
||||
crate::number::Endianness::Native => le_i24,
|
||||
}
|
||||
}
|
||||
|
||||
@ -999,6 +1027,10 @@ where
|
||||
match endian {
|
||||
crate::number::Endianness::Big => be_i32,
|
||||
crate::number::Endianness::Little => le_i32,
|
||||
#[cfg(target_endian = "big")]
|
||||
crate::number::Endianness::Native => be_i32,
|
||||
#[cfg(target_endian = "little")]
|
||||
crate::number::Endianness::Native => le_i32,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1034,6 +1066,10 @@ where
|
||||
match endian {
|
||||
crate::number::Endianness::Big => be_i64,
|
||||
crate::number::Endianness::Little => le_i64,
|
||||
#[cfg(target_endian = "big")]
|
||||
crate::number::Endianness::Native => be_i64,
|
||||
#[cfg(target_endian = "little")]
|
||||
crate::number::Endianness::Native => le_i64,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1070,6 +1106,10 @@ where
|
||||
match endian {
|
||||
crate::number::Endianness::Big => be_i128,
|
||||
crate::number::Endianness::Little => le_i128,
|
||||
#[cfg(target_endian = "big")]
|
||||
crate::number::Endianness::Native => be_i128,
|
||||
#[cfg(target_endian = "little")]
|
||||
crate::number::Endianness::Native => le_i128,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1205,6 +1245,10 @@ where
|
||||
match endian {
|
||||
crate::number::Endianness::Big => be_f32,
|
||||
crate::number::Endianness::Little => le_f32,
|
||||
#[cfg(target_endian = "big")]
|
||||
crate::number::Endianness::Native => be_f32,
|
||||
#[cfg(target_endian = "little")]
|
||||
crate::number::Endianness::Native => le_f32,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1240,6 +1284,10 @@ where
|
||||
match endian {
|
||||
crate::number::Endianness::Big => be_f64,
|
||||
crate::number::Endianness::Little => le_f64,
|
||||
#[cfg(target_endian = "big")]
|
||||
crate::number::Endianness::Native => be_f64,
|
||||
#[cfg(target_endian = "little")]
|
||||
crate::number::Endianness::Native => le_f64,
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user