mirror of
https://github.com/fluencelabs/interface-types
synced 2025-06-24 20:21:40 +00:00
support u128
This commit is contained in:
@ -29,6 +29,7 @@ where
|
||||
IType::U64 => 0x07_u8.to_bytes(writer),
|
||||
IType::F32 => 0x08_u8.to_bytes(writer),
|
||||
IType::F64 => 0x09_u8.to_bytes(writer),
|
||||
IType::U128 => 0x46_u8.to_bytes(writer),
|
||||
IType::String => 0x0a_u8.to_bytes(writer),
|
||||
IType::ByteArray => 0x3C_u8.to_bytes(writer),
|
||||
IType::Array(ty) => {
|
||||
@ -87,6 +88,7 @@ mod keyword {
|
||||
custom_keyword!(u16);
|
||||
custom_keyword!(u32);
|
||||
custom_keyword!(u64);
|
||||
custom_keyword!(u128);
|
||||
custom_keyword!(string);
|
||||
custom_keyword!(array);
|
||||
}
|
||||
@ -138,6 +140,10 @@ impl Parse<'_> for IType {
|
||||
parser.parse::<keyword::f64>()?;
|
||||
|
||||
Ok(IType::F64)
|
||||
} else if lookahead.peek::<keyword::u128>() {
|
||||
parser.parse::<keyword::u128>()?;
|
||||
|
||||
Ok(IType::U128)
|
||||
} else if lookahead.peek::<keyword::string>() {
|
||||
parser.parse::<keyword::string>()?;
|
||||
|
||||
|
@ -22,14 +22,14 @@ macro_rules! native {
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<&IValue> for $native_type {
|
||||
impl TryFrom<IValue> for $native_type {
|
||||
type Error = WasmValueNativeCastError;
|
||||
|
||||
fn try_from(w: &IValue) -> Result<Self, Self::Error> {
|
||||
fn try_from(w: IValue) -> Result<Self, Self::Error> {
|
||||
match w {
|
||||
IValue::$variant(n) => Ok(n.clone()),
|
||||
IValue::$variant(n) => Ok(n),
|
||||
_ => Err(WasmValueNativeCastError {
|
||||
from: w.clone(),
|
||||
from: w,
|
||||
to: <$native_type>::INTERFACE_TYPE,
|
||||
}),
|
||||
}
|
||||
@ -48,4 +48,6 @@ native!(u32, U32);
|
||||
native!(u64, U64);
|
||||
native!(f32, F32);
|
||||
native!(f64, F64);
|
||||
native!(u128, U128);
|
||||
native!(String, String);
|
||||
native!(Vec<u8>, ByteArray);
|
||||
|
@ -41,6 +41,9 @@ pub enum IType {
|
||||
/// A 64-bits float.
|
||||
F64,
|
||||
|
||||
/// A 128-bit unsigned integer.
|
||||
U128,
|
||||
|
||||
/// A string.
|
||||
String,
|
||||
|
||||
@ -112,6 +115,7 @@ impl ToString for &IType {
|
||||
IType::U64 => "u64".to_string(),
|
||||
IType::F32 => "f32".to_string(),
|
||||
IType::F64 => "f64".to_string(),
|
||||
IType::U128 => "u128".to_string(),
|
||||
IType::String => "string".to_string(),
|
||||
IType::ByteArray => "array (u8)".to_string(),
|
||||
IType::Array(ty) => format!("array ({})", ty.as_ref().to_string()),
|
||||
|
@ -38,6 +38,9 @@ pub enum IValue {
|
||||
/// A 64-bits float.
|
||||
F64(f64),
|
||||
|
||||
/// A 128-bits integer.
|
||||
U128(u128),
|
||||
|
||||
/// A string.
|
||||
String(String),
|
||||
|
||||
|
Reference in New Issue
Block a user