-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Added WebAssembly.Global #2595
Added WebAssembly.Global #2595
Conversation
crates/js-sys/src/lib.rs
Outdated
/// | ||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global) | ||
#[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)] | ||
pub fn new(global_descriptor: &Object, value: Option<usize>) -> Result<Global, JsValue>; |
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'm unsure if here value should be Option<f64>
instead
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 think Object
here should probably be a GlobalDescriptor
dictionary with typed field accesses, and value
should be JsValue
most likely to support externref
globals.
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.
Done. I set value
to Option<&JsValue>
&JsValue
.
For the global_descriptor
I used the same pattern as WebAssembly.Table
or WebAssembly.Memory
: using Object
.
I do agree that having a GlobalDescriptor
dictionary would be safer, but I'm not clear on how to do it looking at the code. Any tips here would be appreciated.
PS: perhaps we can improve the Global
, Table
and Memory
constructors to take a proper descriptor type instead of an Object
in a PR apart?
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 good to me, but I think CI is failing?
crates/js-sys/src/lib.rs
Outdated
/// | ||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global) | ||
#[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)] | ||
pub fn new(global_descriptor: &Object, value: Option<usize>) -> Result<Global, JsValue>; |
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 think Object
here should probably be a GlobalDescriptor
dictionary with typed field accesses, and value
should be JsValue
most likely to support externref
globals.
Tests are failing ( Any help here would be appreciated! EDIT: I figured it out, was a bit obscure error raising as a side-effect of having one extra implementation. I believe tests shall be passing soon. So the PR should be ready to review! |
Thanks! |
Added WebAssembly.Global