mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-26 11:34:22 +03:00
split const integers into signed and unsigned
This commit is contained in:
parent
1e32e91877
commit
51b9eb81e8
@ -189,7 +189,8 @@ pub struct Const {
|
|||||||
pub enum ConstValue {
|
pub enum ConstValue {
|
||||||
BooleanLiteral(bool),
|
BooleanLiteral(bool),
|
||||||
FloatLiteral(f64),
|
FloatLiteral(f64),
|
||||||
IntegerLiteral(i64),
|
SignedIntegerLiteral(i64),
|
||||||
|
UnsignedIntegerLiteral(u64),
|
||||||
Null,
|
Null,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -986,11 +986,15 @@ impl ToTokens for ast::Const {
|
|||||||
FloatLiteral(f) => {
|
FloatLiteral(f) => {
|
||||||
let f = Literal::f64_unsuffixed(f);
|
let f = Literal::f64_unsuffixed(f);
|
||||||
quote!(#f)
|
quote!(#f)
|
||||||
}
|
},
|
||||||
IntegerLiteral(i) => {
|
SignedIntegerLiteral(i) => {
|
||||||
let i = Literal::i64_unsuffixed(i);
|
let i = Literal::i64_unsuffixed(i);
|
||||||
quote!(#i)
|
quote!(#i)
|
||||||
}
|
},
|
||||||
|
UnsignedIntegerLiteral(i) => {
|
||||||
|
let i = Literal::u64_unsuffixed(i);
|
||||||
|
quote!(#i)
|
||||||
|
},
|
||||||
Null => unimplemented!(),
|
Null => unimplemented!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -14,4 +14,4 @@ proc-macro2 = "0.4"
|
|||||||
quote = '0.6'
|
quote = '0.6'
|
||||||
syn = { version = '0.14', features = ['full'] }
|
syn = { version = '0.14', features = ['full'] }
|
||||||
wasm-bindgen-backend = { version = "=0.2.11", path = "../backend" }
|
wasm-bindgen-backend = { version = "=0.2.11", path = "../backend" }
|
||||||
webidl = "0.6.0"
|
webidl = "0.7.0"
|
||||||
|
@ -43,7 +43,8 @@ pub fn webidl_const_v_to_backend_const_v(v: &webidl::ast::ConstValue) -> backend
|
|||||||
match *v {
|
match *v {
|
||||||
webidl::ast::ConstValue::BooleanLiteral(b) => backend::ast::ConstValue::BooleanLiteral(b),
|
webidl::ast::ConstValue::BooleanLiteral(b) => backend::ast::ConstValue::BooleanLiteral(b),
|
||||||
webidl::ast::ConstValue::FloatLiteral(f) => backend::ast::ConstValue::FloatLiteral(f),
|
webidl::ast::ConstValue::FloatLiteral(f) => backend::ast::ConstValue::FloatLiteral(f),
|
||||||
webidl::ast::ConstValue::IntegerLiteral(i) => backend::ast::ConstValue::IntegerLiteral(i),
|
webidl::ast::ConstValue::SignedIntegerLiteral(i) => backend::ast::ConstValue::SignedIntegerLiteral(i),
|
||||||
|
webidl::ast::ConstValue::UnsignedIntegerLiteral(u) => backend::ast::ConstValue::UnsignedIntegerLiteral(u),
|
||||||
webidl::ast::ConstValue::Null => backend::ast::ConstValue::Null,
|
webidl::ast::ConstValue::Null => backend::ast::ConstValue::Null,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,9 +71,7 @@ fn ints() {
|
|||||||
const long long imin = -9223372036854775808;
|
const long long imin = -9223372036854775808;
|
||||||
const long long imax = 9223372036854775807;
|
const long long imax = 9223372036854775807;
|
||||||
const unsigned long long umin = 0;
|
const unsigned long long umin = 0;
|
||||||
// bug in webidl
|
const unsigned long long umax = 18446744073709551615;
|
||||||
// https://github.com/sgodwincs/webidl-rs/issues/15
|
|
||||||
//const unsigned long long umax = 18446744073709551615;
|
|
||||||
};
|
};
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
@ -121,7 +119,7 @@ fn ints() {
|
|||||||
assert_eq!(foo::LongLong::IMIN, i64::min_value());
|
assert_eq!(foo::LongLong::IMIN, i64::min_value());
|
||||||
assert_eq!(foo::LongLong::IMAX, i64::max_value());
|
assert_eq!(foo::LongLong::IMAX, i64::max_value());
|
||||||
assert_eq!(foo::LongLong::UMIN, u64::min_value());
|
assert_eq!(foo::LongLong::UMIN, u64::min_value());
|
||||||
//assert_eq!(foo::LongLong::UMAX, u64::max_value());
|
assert_eq!(foo::LongLong::UMAX, u64::max_value());
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user