From 51b9eb81e806112f924441114a7e1035f9999e2a Mon Sep 17 00:00:00 2001 From: Julius Rakow Date: Sat, 14 Jul 2018 14:48:04 +0200 Subject: [PATCH] split const integers into signed and unsigned --- crates/backend/src/ast.rs | 3 ++- crates/backend/src/codegen.rs | 10 +++++++--- crates/webidl/Cargo.toml | 2 +- crates/webidl/src/util.rs | 3 ++- crates/webidl/tests/all/consts.rs | 6 ++---- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/crates/backend/src/ast.rs b/crates/backend/src/ast.rs index 5a332a087e4..041066af1b7 100644 --- a/crates/backend/src/ast.rs +++ b/crates/backend/src/ast.rs @@ -189,7 +189,8 @@ pub struct Const { pub enum ConstValue { BooleanLiteral(bool), FloatLiteral(f64), - IntegerLiteral(i64), + SignedIntegerLiteral(i64), + UnsignedIntegerLiteral(u64), Null, } diff --git a/crates/backend/src/codegen.rs b/crates/backend/src/codegen.rs index c8261b46312..d8034a102f6 100644 --- a/crates/backend/src/codegen.rs +++ b/crates/backend/src/codegen.rs @@ -986,11 +986,15 @@ impl ToTokens for ast::Const { FloatLiteral(f) => { let f = Literal::f64_unsuffixed(f); quote!(#f) - } - IntegerLiteral(i) => { + }, + SignedIntegerLiteral(i) => { let i = Literal::i64_unsuffixed(i); quote!(#i) - } + }, + UnsignedIntegerLiteral(i) => { + let i = Literal::u64_unsuffixed(i); + quote!(#i) + }, Null => unimplemented!(), }; diff --git a/crates/webidl/Cargo.toml b/crates/webidl/Cargo.toml index 86011c7f446..43d541474f6 100644 --- a/crates/webidl/Cargo.toml +++ b/crates/webidl/Cargo.toml @@ -14,4 +14,4 @@ proc-macro2 = "0.4" quote = '0.6' syn = { version = '0.14', features = ['full'] } wasm-bindgen-backend = { version = "=0.2.11", path = "../backend" } -webidl = "0.6.0" +webidl = "0.7.0" diff --git a/crates/webidl/src/util.rs b/crates/webidl/src/util.rs index 93c7d05069f..517716a4469 100644 --- a/crates/webidl/src/util.rs +++ b/crates/webidl/src/util.rs @@ -43,7 +43,8 @@ pub fn webidl_const_v_to_backend_const_v(v: &webidl::ast::ConstValue) -> backend match *v { webidl::ast::ConstValue::BooleanLiteral(b) => backend::ast::ConstValue::BooleanLiteral(b), 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, } } diff --git a/crates/webidl/tests/all/consts.rs b/crates/webidl/tests/all/consts.rs index 716fbe8a3ca..f491745ab2a 100644 --- a/crates/webidl/tests/all/consts.rs +++ b/crates/webidl/tests/all/consts.rs @@ -71,9 +71,7 @@ fn ints() { const long long imin = -9223372036854775808; const long long imax = 9223372036854775807; const unsigned long long umin = 0; - // bug in webidl - // https://github.com/sgodwincs/webidl-rs/issues/15 - //const unsigned long long umax = 18446744073709551615; + const unsigned long long umax = 18446744073709551615; }; "#, ) @@ -121,7 +119,7 @@ fn ints() { assert_eq!(foo::LongLong::IMIN, i64::min_value()); assert_eq!(foo::LongLong::IMAX, i64::max_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()); } "#, )