Replies: 4 comments 3 replies
-
Just a quick comment on this one: allowing to unset values would effectively void the conditions that should hold for reading the properties. Meaning that all getters would need to be wrapped in an I guess you could implement the |
Beta Was this translation helpful? Give feedback.
-
Not all of them - the UPD: oh, yeah, dictionaries, right. They don't have definitions like that, and thus must absolutely always do the explicit |
Beta Was this translation helpful? Give feedback.
-
They actually do, so I think your suggestion of allowing to unset optional values only would work great. E.g. the first dictionary declaration I could find going alphabetically in the enabled WebIDLs: wasm-bindgen/crates/web-sys/webidls/enabled/AnalyserNode.webidl Lines 13 to 18 in e78db23 It just looks like the code generation for dictionary constructors produces undefined behavior by not setting default values in wasm-bindgen/crates/web-sys/src/features/gen_AnalyserOptions.rs Lines 30 to 38 in e78db23 I'll open a separate issue for that. |
Beta Was this translation helpful? Give feedback.
-
Covered by #1793.
I don't think this is something we want to add generally to all dictionary types without some well justified use-case.
I think introducing a typed However having the WebIDL generator use
Reviewing this is in my backlog.
AFAIK there isn't anything
Similar to
Unfortunately I don't know what that means.
I wasn't aware that anybody would use this outside of
Really? I didn't encounter something like this yet I believe, but yeah, I wouldn't know why not to take that into account.
A quick try showed that attributes aren't passed on to the variants, so yeah, that should be fixed.
I'm not sure how much convenience I want to add directly to
Hm, again, not too sure what to think of this. Open to discussing more specific improvements.
The WebIDL generator is not meant for public consumption and I don't believe this is something we want to take on with the limited maintainer resources we have, considering this can all be done externally. Though obviously any improvements to I appreciate the input, its good to hear from users to see where exactly we can improve things! |
Beta Was this translation helpful? Give feedback.
-
I was doing a manual implementation for the WebTransport types, and here's case-study-based a list of missing features that makes WebIDL codegen really unusable:
ReadableStream
, pretty much everywhere in thegetStats
for WebTransport, etc.Option<T>
instead ofT
, or generate an additional accessor to allowunset_...
.js_sys::Promise
it returned instead. We should consider adding types support to thejs_sys::Promise
, and also generating the calls that return promises as realasync fn
s. This is, however, blocked by Add.into()
to the generated code for async fns #3919, asasync
fn generation is broken..into()
to the generated code for async fns #3919. Theasync
fn generation is broken.catch
is not generated correctly. This is an issue with WebIDL definitions, as they lack the machine-readable data on whether a call can throw or not - but nonetheless I count this towards the list of issues of the WebIDL-generated rust code.ReadableStream
/WriteableStream
should have a generic indicating what type they produce - they are capable of streaming not just the bytes (i.e. binary data, where they act like Read/Write), but objects too (acting more like a stream / async iterator in rust sense).final
at the codegen level.wasm_bindgen_webidl
as a dependency and use it in my crate - as the latest version is not published, and the last published is very old and conflicts with the rest of the crates. This is by far the easiest issue to solve.Also, some nits I encountered while implementing things manually.
missing_docs
lint is triggered forwasm_bindgen
macro enums.wasm_bindgen
macro, as in syntax sugar for generating both getter and setter from the same attribute.Not sure this is the right place for this, and those issue are most definitely reported before - but this is a case study organized in one place, and will hopefully act like a concise roadmap towards a better support for WebIDL. Hopefully if all those are solved somehow we'd get a way nicer codegen.
For now, using WebIDL is much more painful than using custom type declarations.
Beta Was this translation helpful? Give feedback.
All reactions