-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Support WebIDL constants #470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great. Most of my comments are minor nickpicks, so I'm going to merge this now and just address them myself in #460, which changes a lot of the same code.
pub struct Const { | ||
pub vis: syn::Visibility, | ||
pub name: Ident, | ||
pub interface_name: Ident, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use class
here, rather than interface_name
, and made the value an Option<String>
. It is more consist with the function import.
@@ -42,6 +42,7 @@ pub enum ImportKind { | |||
Static(ImportStatic), | |||
Type(ImportType), | |||
Enum(ImportEnum), | |||
Const(Const), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't really an import, constants are not really importing anything. This constants should really be a field in the program.
|
||
#[wasm_bindgen] | ||
pub fn test() { | ||
assert_eq!(foo::floats::F, 0.0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe make this 0.0_f32
to insure that F
isn't accidentally a f64
.
assert!(foo::floats::INF.is_sign_positive()); | ||
assert!(foo::floats::NAN.is_nan()); | ||
|
||
assert_eq!(foo::doubles::D, 0.0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And 0.0_f64
here.
const unsigned long long umin = 0; | ||
// bug in webidl | ||
// https://github.com/sgodwincs/webidl-rs/issues/15 | ||
//const unsigned long long umax = 18446744073709551615; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unfortunate. Upon scanning the docs, it doesn't look like weedle has this bug (it seems to preserve the literal string). I've wondered if we should use weedle instead since its dependencies are much more aligned with our own.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would also let us skip lalrpop, which is an incredible crate, but a long build time to hoist on to downstream users :-/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it was already fixed, that was fast
fn webidl_parse( | ||
&self, | ||
program: &mut backend::ast::Program, | ||
interface_name: &'a str, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe self_name
here to be more consistent with the other impls.
Fix #259